OGRE  1.12.4
Object-Oriented Graphics Rendering Engine
Ogre::BspNode Class Reference

Encapsulates a node in a BSP tree. More...

#include <OgreBspNode.h>

+ Inheritance diagram for Ogre::BspNode:

Classes

struct  Brush
 

Public Types

typedef std::set< const MovableObject * > IntersectingObjectSet
 
typedef std::vector< Brush * > NodeBrushList
 

Public Member Functions

 BspNode (BspLevel *owner, bool isLeaf)
 Constructor, only to be used by BspLevel. More...
 
 BspNode ()
 
 ~BspNode ()
 
void _addMovable (const MovableObject *mov)
 Internal method for telling the node that a movable intersects it. More...
 
void _removeMovable (const MovableObject *mov)
 Internal method for telling the node that a movable no longer intersects it. More...
 
BspNodegetBack (void) const
 Returns a pointer to a BspNode containing the subspace on the negative side of the splitting plane. More...
 
const AxisAlignedBoxgetBoundingBox (void) const
 Returns the axis-aligned box which contains this node if it is a leaf. More...
 
Real getDistance (const Vector3 &pos) const
 Gets the signed distance to the dividing plane. More...
 
int getFaceGroupStart (void) const
 Returns the index to the face group index list for this leaf node. More...
 
BspNodegetFront (void) const
 Returns a pointer to a BspNode containing the subspace on the positive side of the splitting plane. More...
 
BspNodegetNextNode (const Vector3 &point) const
 Gets the next node down in the tree, with the intention of locating the leaf containing the given point. More...
 
int getNumFaceGroups (void) const
 Returns the number of faces contained in this leaf node. More...
 
const IntersectingObjectSetgetObjects (void) const
 
Plane::Side getSide (const Vector3 &point) const
 Determines which side of the splitting plane a worldspace point is. More...
 
const NodeBrushListgetSolidBrushes (void) const
 Main brush memory held on level. More...
 
const PlanegetSplitPlane (void) const
 Returns details of the plane which is used to subdivide the space of his node's children. More...
 
bool isLeaf (void) const
 Returns true if this node is a leaf (i.e. More...
 
bool isLeafVisible (const BspNode *leaf) const
 Determines if the passed in node (must also be a leaf) is visible from this leaf. More...
 

Friends

class BspLevel
 
std::ostream & operator<< (std::ostream &o, BspNode &n)
 

Detailed Description

Encapsulates a node in a BSP tree.

A BSP tree represents space partitioned by planes . The space which is partitioned is either the world (in the case of the root node) or the space derived from their parent node. Each node can have elements which are in front or behind it, which are it's children and these elements can either be further subdivided by planes, or they can be undivided spaces or 'leaf nodes' - these are the nodes which actually contain objects and world geometry.The leaves of the tree are the stopping point of any tree walking algorithm, both for rendering and collision detection etc. Ogre chooses not to represent splitting nodes and leaves as separate structures, but to merge the two for simplicity of the walking algorithm. If a node is a leaf, the isLeaf() method returns true and both getFront() and getBack() return null pointers. If the node is a partitioning plane isLeaf() returns false and getFront() and getBack() will return the corresponding BspNode objects.

Member Typedef Documentation

◆ IntersectingObjectSet

◆ NodeBrushList

typedef std::vector<Brush*> Ogre::BspNode::NodeBrushList

Constructor & Destructor Documentation

◆ BspNode() [1/2]

Ogre::BspNode::BspNode ( BspLevel owner,
bool  isLeaf 
)

Constructor, only to be used by BspLevel.

◆ BspNode() [2/2]

Ogre::BspNode::BspNode ( )

◆ ~BspNode()

Ogre::BspNode::~BspNode ( )

Member Function Documentation

◆ isLeaf()

bool Ogre::BspNode::isLeaf ( void  ) const

Returns true if this node is a leaf (i.e.

contains geometry) or false if it is a splitting plane. A BspNode can either be a splitting plane (the typical representation of a BSP node) or an undivided region contining geometry (a leaf node). Ogre represents both using the same class for simplicity of tree walking. However it is important that you use this method to determine which type you are dealing with, since certain methods are only supported with one of the subtypes. Details are given in the individual methods. Note that I could have represented splitting / leaf nodes as a class hierarchy but the virtual methods / run-time type identification would have a performance hit, and it would not make the code much (any?) simpler anyway. I think this is a fair trade-off in this case.

◆ getFront()

BspNode* Ogre::BspNode::getFront ( void  ) const

Returns a pointer to a BspNode containing the subspace on the positive side of the splitting plane.

This method should only be called on a splitting node, i.e. where isLeaf() returns false. Calling this method on a leaf node will throw an exception.

◆ getBack()

BspNode* Ogre::BspNode::getBack ( void  ) const

Returns a pointer to a BspNode containing the subspace on the negative side of the splitting plane.

This method should only be called on a splitting node, i.e. where isLeaf() returns false. Calling this method on a leaf node will throw an exception.

◆ getSide()

Plane::Side Ogre::BspNode::getSide ( const Vector3 point) const

Determines which side of the splitting plane a worldspace point is.

This method should only be called on a splitting node, i.e. where isLeaf() returns false. Calling this method on a leaf node will throw an exception.

◆ getNextNode()

BspNode* Ogre::BspNode::getNextNode ( const Vector3 point) const

Gets the next node down in the tree, with the intention of locating the leaf containing the given point.

This method should only be called on a splitting node, i.e. where isLeaf() returns false. Calling this method on a leaf node will throw an exception.

◆ getSplitPlane()

const Plane& Ogre::BspNode::getSplitPlane ( void  ) const

Returns details of the plane which is used to subdivide the space of his node's children.

This method should only be called on a splitting node, i.e. where isLeaf() returns false. Calling this method on a leaf node will throw an exception.

◆ getBoundingBox()

const AxisAlignedBox& Ogre::BspNode::getBoundingBox ( void  ) const

Returns the axis-aligned box which contains this node if it is a leaf.

This method should only be called on a leaf node. It returns a box which can be used in calls like Camera::isVisible to determine if the leaf node is visible in the view.

◆ getNumFaceGroups()

int Ogre::BspNode::getNumFaceGroups ( void  ) const

Returns the number of faces contained in this leaf node.

Should only be called on a leaf node.

◆ getFaceGroupStart()

int Ogre::BspNode::getFaceGroupStart ( void  ) const

Returns the index to the face group index list for this leaf node.

The contents of this buffer is a list of indexes which point to the actual face groups held in a central buffer in the BspLevel class (in actual fact for efficiency the indexes themselves are also held in a single buffer in BspLevel too). The reason for this indirection is that the buffer of indexes to face groups is organised in chunks relative to nodes, whilst the main buffer of face groups may not be. Should only be called on a leaf node.

◆ isLeafVisible()

bool Ogre::BspNode::isLeafVisible ( const BspNode leaf) const

Determines if the passed in node (must also be a leaf) is visible from this leaf.

Must only be called on a leaf node, and the parameter must also be a leaf node. If this method returns true, then the leaf passed in is visible from this leaf. Note that internally this uses the Potentially Visible Set (PVS) which is precalculated and stored with the BSP level.

◆ _addMovable()

void Ogre::BspNode::_addMovable ( const MovableObject mov)

Internal method for telling the node that a movable intersects it.

◆ _removeMovable()

void Ogre::BspNode::_removeMovable ( const MovableObject mov)

Internal method for telling the node that a movable no longer intersects it.

◆ getDistance()

Real Ogre::BspNode::getDistance ( const Vector3 pos) const

Gets the signed distance to the dividing plane.

◆ getSolidBrushes()

const NodeBrushList& Ogre::BspNode::getSolidBrushes ( void  ) const

Main brush memory held on level.

Get the list of solid Brushes for this node.

Remarks
Only applicable for leaf nodes.

◆ getObjects()

const IntersectingObjectSet& Ogre::BspNode::getObjects ( void  ) const
inline

Friends And Related Function Documentation

◆ BspLevel

friend class BspLevel
friend

◆ operator<<

std::ostream& operator<< ( std::ostream &  o,
BspNode n 
)
friend

The documentation for this class was generated from the following file: