eng::BSP Class Reference

Axis-aligned BSP tree (specialized for Object class). More...

#include <eng_bsp.hh>

List of all members.

Public Types

enum  ePolicy { ePolicy_FORCE, ePolicy_THROW_EXCEPTION }
 What to do if an Object doesn't fit in the BSP's volume. More...

Public Member Functions

void ForEachObject (ForEachObjectFunctor &functor)
 BSP (const BoxVolume &boxVolume)
 ~BSP ()
CLASS_METHOD void SetPolicy (const ePolicy policy)
bool IfInside (const Volume &volume)
bool IfInside (const BoxVolume &boxVolume)
const BoxVolumeGetBoxVolume (void)
eAttached Attach (SharedPtr< Object > object)
eAttached Detach (SharedPtr< Object > object)
void Draw (void)

Public Attributes

CLASS_VAR uint msDebugRecursionLevel
CLASS_VAR bool msDebugDrawBox

Private Member Functions

BSP::Node::Ptr FindFit (SharedPtr< Object > object)
BSP::Node::Ptr FindFit (const BoxVolume &objectVolume)
bool IfContinueRecursion (const uint level)

Private Attributes

CLASS_VAR uint msRecursionLimit = eng::defs::DEFAULT_BSP_RECURSION_LIMIT
 use IfStopRecursion()
CLASS_VAR int msNodeLimit = eng::defs::DEFAULT_BSP_NODE_LIMIT
 limit amount of partitions
CLASS_VAR ePolicy msPolicy = BSP::ePolicy_THROW_EXCEPTION
Node::Ptr mRoot
 outer-level partition
int mNodeCnt

Friends

class Quadrant
class World

Classes

class  ForEachObjectFunctor
 For each Object in BSP. More...
class  Node
 BSP node. More...
class  Viewpoint
 Viewpoint for recursing a BSP tree. More...


Detailed Description

Axis-aligned BSP tree (specialized for Object class).

Member Enumeration Documentation

enum eng::BSP::ePolicy

What to do if an Object doesn't fit in the BSP's volume.

Enumerator:
ePolicy_FORCE  force Object into BSP::mRoot despite it not fitting
ePolicy_THROW_EXCEPTION 


Constructor & Destructor Documentation

eng::BSP::BSP ( const BoxVolume boxVolume  ) 

Construct as interior node.

eng::BSP::~BSP (  ) 


Member Function Documentation

void eng::BSP::ForEachObject ( ForEachObjectFunctor functor  ) 

For each Object in this BSP. To the caller, the order is undefined (definitely not sorted by distance).

void eng::BSP::SetPolicy ( const ePolicy  policy  ) 

Set the policy of the BSP code when error conditions occur such as when an Object doesn't fit.

bool eng::BSP::IfInside ( const Volume volume  )  [inline]

bool eng::BSP::IfInside ( const BoxVolume boxVolume  )  [inline]

const BoxVolume& eng::BSP::GetBoxVolume ( void   )  [inline]

eAttached eng::BSP::Attach ( SharedPtr< Object object  ) 

eAttached eng::BSP::Detach ( SharedPtr< Object object  ) 

void eng::BSP::Draw ( void   ) 

Draw all visible Objects in BSP. See Engine::Draw(). Traverses the BSP tree in back-to-front order relative to a viewpoint. The first Object visited will be the most distant from the viewpoint.

BSP::Node::Ptr eng::BSP::FindFit ( SharedPtr< Object object  )  [private]

BSP::Node::Ptr eng::BSP::FindFit ( const BoxVolume objectVolume  )  [private]

Recursively traverse BSP nodes to find the smallest BSP that contains a volume.

-- Might throw a C++ exception depending on policy --

Returns:
The smallest BSP node that contains a volume.
Parameters:
objectVolume Volume of an Object in world space.
In terms of geometry, this function recursively subdivides a volume. But in terms of CPU execution, its implementation is iterative for speed.

At this point, the Object is entirely inside this node. The goal is to find the smallest node that will entirely contain the Object. Split this node's volume into two half-spaces (left and right). If either fully contains the Object, recurse left or right. Otherwise, the goal was reached.

What about Objects that straddle a partition? An assertion will fail!!

bool eng::BSP::IfContinueRecursion ( const uint  level  )  [inline, private]

Returns:
True until recursion has descended too many levels or if too many partitions have been created.


Friends And Related Function Documentation

friend class Quadrant [friend]

friend class World [friend]


Member Data Documentation

uint eng::BSP::msDebugRecursionLevel

bool eng::BSP::msDebugDrawBox

uint eng::BSP::msRecursionLimit = eng::defs::DEFAULT_BSP_RECURSION_LIMIT [private]

use IfStopRecursion()

int eng::BSP::msNodeLimit = eng::defs::DEFAULT_BSP_NODE_LIMIT [private]

limit amount of partitions

BSP::ePolicy eng::BSP::msPolicy = BSP::ePolicy_THROW_EXCEPTION [private]

Node::Ptr eng::BSP::mRoot [private]

outer-level partition

int eng::BSP::mNodeCnt [private]


The documentation for this class was generated from the following files: Palomino 3D Engine documents generated by doxygen 1.5.3 on Fri Nov 23 11:26:21 2007