Cafu Engine
cf::ClipSys::CollisionModelStaticT::NodeT Class Reference

Public Types

enum  PlaneTypeE { NONE = -1, ALONG_X, ALONG_Y, ALONG_Z }
 As the nodes of an octree are not subdivided by arbitrary planes, but only by planes that are parallel to the three major axes, we do not store a full Plane3dT member with the nodes, but only a "compacted" representation: The type expresses which axes the plane is parallel to, the distance is the offset from the origin. More...
 

Public Member Functions

 NodeT ()
 The default constructor. More...
 
BoundingBox3dT GetBB () const
 Returns the bounding box of all contents (polygons, brushes, terrains) of this node. More...
 
unsigned long GetContents () const
 Returns the contents (the union of the contents of all polygons, brushes and terrains) of this node. More...
 
bool DetermineSplitPlane (const BoundingBox3dT &NodeBB, const double MIN_NODE_SIZE)
 Determines an axis-aligned split plane for further BSP partitioning of the contents of this node. More...
 
bool IntersectsAllChildren (const BoundingBox3dT &BB) const
 Determines whether the given BB intersects (is partly inside) each child of this node. More...
 
void Trace (const Vector3dT &A, const Vector3dT &B, double FracA, double FracB, const TraceParamsT &Params) const
 Traces an object along a line segment through the tree that is rooted at this node. More...
 
void Insert (const PolygonT *Poly)
 Recursively inserts the given polygon into the (sub-)tree at and below this node. More...
 
void Insert (const BrushT *Brush)
 Recursively inserts the given brush into the (sub-)tree at and below this node. More...
 
void Insert (const TerrainRefT *Terrain)
 Recursively inserts the given terrain into the (sub-)tree at and below this node. More...
 

Public Attributes

PlaneTypeE PlaneType
 The type of the plane that subdivides this node (no plane at all, normal vector along the x-, y- or z-axis). More...
 
double PlaneDist
 The distance of the plane to the origin. Corresponds to the Plane3fT::Dist member in a full plane. More...
 
NodeTParent
 The parent of this node, NULL if this is the root node. More...
 
NodeTChildren [2]
 The children of this node at each side of the plane (NULL if there is no plane / the node is a leaf). More...
 
ArrayT< const PolygonT * > Polygons
 The list of polygons in this node (used for traces, never for contents tests). More...
 
ArrayT< const BrushT * > Brushes
 The list of brushes in this node (brushes are both for traces and contents tests). More...
 
ArrayT< const TerrainRefT * > Terrains
 The list of terrains in this node (used for traces, never for contents tests). More...
 

Member Enumeration Documentation

As the nodes of an octree are not subdivided by arbitrary planes, but only by planes that are parallel to the three major axes, we do not store a full Plane3dT member with the nodes, but only a "compacted" representation: The type expresses which axes the plane is parallel to, the distance is the offset from the origin.

Enumerator
NONE 

No plane at all. Used for nodes that are actually leaves.

ALONG_X 

A plane with normal vector (1, 0, 0), parallel to the y- and z-axis.

ALONG_Y 

A plane with normal vector (0, 1, 0), parallel to the x- and z-axis.

ALONG_Z 

A plane with normal vector (0, 0, 1), parallel to the x- and y-axis.

Constructor & Destructor Documentation

cf::ClipSys::CollisionModelStaticT::NodeT::NodeT ( )
inline

The default constructor.

Note that NodeTs are managed by cf::PoolTs, and thus it makes no sense to have anything but a default ctor.

Member Function Documentation

bool CollisionModelStaticT::NodeT::DetermineSplitPlane ( const BoundingBox3dT NodeBB,
const double  MIN_NODE_SIZE 
)

Determines an axis-aligned split plane for further BSP partitioning of the contents of this node.

For choosing the split plane, the method considers the bounding-box planes of all objects (polygons, brushes, terrains) of this node and all its ancestors, provided that they are wholly or partially in BB. When a split plane was found, the PlaneType and PlaneDist members are appropriately set and true is returned, otherwise they are initialized with NONE and 0, respectively, and the return value is false.

Parameters
NodeBBThe relevant bounds in which a split plane is to be found from the contents of this node (plus ancestors).
MIN_NODE_SIZEThe minimum size (side length) that a node should not fall below.
Returns
whether a split plane has successfully been determined.
BoundingBox3dT CollisionModelStaticT::NodeT::GetBB ( ) const

Returns the bounding box of all contents (polygons, brushes, terrains) of this node.

unsigned long CollisionModelStaticT::NodeT::GetContents ( ) const

Returns the contents (the union of the contents of all polygons, brushes and terrains) of this node.

void CollisionModelStaticT::NodeT::Insert ( const PolygonT Poly)

Recursively inserts the given polygon into the (sub-)tree at and below this node.

void CollisionModelStaticT::NodeT::Insert ( const BrushT Brush)

Recursively inserts the given brush into the (sub-)tree at and below this node.

void CollisionModelStaticT::NodeT::Insert ( const TerrainRefT Terrain)

Recursively inserts the given terrain into the (sub-)tree at and below this node.

bool CollisionModelStaticT::NodeT::IntersectsAllChildren ( const BoundingBox3dT BB) const

Determines whether the given BB intersects (is partly inside) each child of this node.

Parameters
BBThe bounding box that is tested for intersection.
void CollisionModelStaticT::NodeT::Trace ( const Vector3dT A,
const Vector3dT B,
double  FracA,
double  FracB,
const TraceParamsT Params 
) const

Traces an object along a line segment through the tree that is rooted at this node.

The line segment is defined by the points Start and Start+Ray == End. The parameters to this method specify a sub-segment of the line through Start and End as follows: A = Start + Ray*FracA B = Start + Ray*FracB This is mostly important for the recursive implementation of this method, you typically just call it like: Trace(Start, End, 0, 1, Params);

Member Data Documentation

ArrayT<const BrushT*> cf::ClipSys::CollisionModelStaticT::NodeT::Brushes

The list of brushes in this node (brushes are both for traces and contents tests).

NodeT* cf::ClipSys::CollisionModelStaticT::NodeT::Children[2]

The children of this node at each side of the plane (NULL if there is no plane / the node is a leaf).

NodeT* cf::ClipSys::CollisionModelStaticT::NodeT::Parent

The parent of this node, NULL if this is the root node.

double cf::ClipSys::CollisionModelStaticT::NodeT::PlaneDist

The distance of the plane to the origin. Corresponds to the Plane3fT::Dist member in a full plane.

PlaneTypeE cf::ClipSys::CollisionModelStaticT::NodeT::PlaneType

The type of the plane that subdivides this node (no plane at all, normal vector along the x-, y- or z-axis).

ArrayT<const PolygonT*> cf::ClipSys::CollisionModelStaticT::NodeT::Polygons

The list of polygons in this node (used for traces, never for contents tests).

ArrayT<const TerrainRefT*> cf::ClipSys::CollisionModelStaticT::NodeT::Terrains

The list of terrains in this node (used for traces, never for contents tests).


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