Visualization Library 2.0.0

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
Public Member Functions | Protected Attributes | List of all members
vl::ActorKdTree Class Reference

ActorKdTree class extends the ActorTreeAbstract class implementing a space partitioning scheme based on a Kd-Tree. More...

#include <ActorKdTree.hpp>

+ Inheritance diagram for vl::ActorKdTree:

Public Member Functions

 ActorKdTree ()
 
virtual int childrenCount () const
 Returns the number of child nodes of an ActorTreeAbstract node. More...
 
virtual ActorTreeAbstractchild (int i)
 Returns the i-th child node of an ActorTreeAbstract node. More...
 
virtual const ActorTreeAbstractchild (int i) const
 Returns the i-th child node of an ActorTreeAbstract node. More...
 
void buildKdTree (ActorCollection &actors, int max_depth=100, float minimum_volume=0)
 Builds a ActorKdTree with the given list of Actors. More...
 
void rebuildKdTree (int max_depth=100, float minimum_volume=0)
 Builds a ActorKdTree with the Actors contained in the tree. More...
 
const Planeplane () const
 Returns the splitting plane used to divide its two child nodes. More...
 
ActorKdTreechildN ()
 Returns the child node that lies in the negative space defined by the splitting plane. More...
 
const ActorKdTreechildN () const
 Returns the child node that lies in the negative space defined by the splitting plane. More...
 
ActorKdTreechildP ()
 Returns the child node that lies in the positive space defined by the splitting plane. More...
 
const ActorKdTreechildP () const
 Returns the child node that lies in the positive space defined by the splitting plane. More...
 
ActorKdTreeinsertActor (Actor *actor)
 Inserts an Actor in the ActorKdTree node hierarchy. More...
 
ref< ActorKdTreekdtreeFromNonLeafyActors (int max_depth=100, float minimum_volume=0)
 Removes the Actors in the internal nodes of the ActorKdTree and uses them to create a new ActorKdTree. More...
 
void harvestNonLeafActors (ActorCollection &actors)
 Removes the Actors in the internal nodes of the ActorKdTree and appends them in the given ActorCollection. More...
 
- Public Member Functions inherited from vl::ActorTreeAbstract
 ActorTreeAbstract ()
 
const ActorTreeAbstractparent () const
 Returns the parent of a node. More...
 
ActorTreeAbstractparent ()
 Returns the parent of a node. More...
 
const ActorCollectionactors () const
 Returns the actors contained in a ActorTree node. More...
 
ActorCollectionactors ()
 Returns the actors contained in a ActorTree node. More...
 
const AABBaabb () const
 Returns the bounding box of a node. Such bounding box contains both the bounding boxes of the node's Actors and of the child nodes. More...
 
void computeAABB ()
 Recursively computes the bounding box of a node so that it includes the bounding boxes of the node's Actors and of the child nodes. More...
 
void extractActors (ActorCollection &list)
 Extracts all the Actors contained in th ActorTree hierarchy and appends them to the given ActorCollection. More...
 
void extractVisibleActors (ActorCollection &list, const Camera *camera, unsigned enable_mask=0xFFFFFFFF)
 Extracts the enabled and visible Actors contained in th ActorTree hierarchy and appends them to the given ActorCollection. More...
 
ActorTreeAbstracteraseActor (Actor *actor)
 Removes the given Actor from the ActorTreeAbstract. More...
 
ActoraddActor (Renderable *renderable, Effect *eff, Transform *tr=NULL)
 Utility function that adds an Actor and binds it to the given Renderable, Effect and Transform. More...
 
ActoraddActor (Actor *actor)
 Utility function equivalent to 'actors()->push_back(actor)'. More...
 
void setParent (ActorTreeAbstract *p)
 For internal use only. More...
 
void setEnabled (bool enabled)
 If false then extractVisibleActors() will ignore this node and all its children. More...
 
bool isEnabled () const
 If false then extractVisibleActors() will ignore this node and all its children. More...
 
- Public Member Functions inherited from vl::Object
 Object ()
 Constructor. More...
 
 Object (const Object &other)
 Copy constructor: copies the name, ref count mutex and user data. More...
 
Objectoperator= (const Object &other)
 Copy operator: copies the object's name, ref count mutex and user data. More...
 
const std::string & objectName () const
 The name of the object, by default set to the object's class name. More...
 
void setObjectName (const char *name)
 The name of the object, by default set to the object's class name in debug builds. More...
 
void setObjectName (const std::string &name)
 The name of the object, by default set to the object's class name in debug builds. More...
 
void setRefCountMutex (IMutex *mutex)
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
IMutexrefCountMutex ()
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
const IMutexrefCountMutex () const
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
int referenceCount () const
 Returns the number of references of an object. More...
 
void incReference () const
 Increments the reference count of an object. More...
 
void decReference ()
 Decrements the reference count of an object and deletes it if both automaticDelete() is true the count reaches 0. More...
 
void setAutomaticDelete (bool autodel_on)
 If set to true the Object is deleted when its reference count reaches 0. More...
 
bool automaticDelete () const
 If set to true the Object is deleted when its reference count reaches 0. More...
 
template<class T >
T * as ()
 Casts an Object to the specified class. More...
 
template<class T >
const T * as () const
 Casts an Object to the specified class. More...
 

Protected Attributes

Plane mPlane
 
ref< ActorKdTreemChildN
 
ref< ActorKdTreemChildP
 
- Protected Attributes inherited from vl::ActorTreeAbstract
ActorTreeAbstractmParent
 
ActorCollection mActors
 
AABB mAABB
 
bool mEnabled
 
- Protected Attributes inherited from vl::Object
std::string mObjectName
 
IMutexmRefCountMutex
 
int mReferenceCount
 
bool mAutomaticDelete
 

Additional Inherited Members

- Static Public Member Functions inherited from vl::ActorTreeAbstract
static void prepareActors (ActorCollection &actors)
 Updates the Transform and the bounds of the given Actors. More...
 
- Protected Member Functions inherited from vl::Object
virtual ~Object ()
 

Detailed Description

ActorKdTree class extends the ActorTreeAbstract class implementing a space partitioning scheme based on a Kd-Tree.

Note
When building the Kd-Tree, Visualization Library considers the Actors' LOD level 0.
See also

Definition at line 57 of file ActorKdTree.hpp.

Constructor & Destructor Documentation

◆ ActorKdTree()

vl::ActorKdTree::ActorKdTree ( )
inline

Definition at line 62 of file ActorKdTree.hpp.

Referenced by kdtreeFromNonLeafyActors().

Member Function Documentation

◆ buildKdTree()

void ActorKdTree::buildKdTree ( ActorCollection actors,
int  max_depth = 100,
float  minimum_volume = 0 
)

Builds a ActorKdTree with the given list of Actors.

The ActorKdTree generation routine will try to minimize the ActorKdTree depth. Note that this function is relatively quick, but is not for free. Consider that using a Core 2 Duo @2.0GHz you can process around 22.000 objects/sec.

Note
This method calls prepareActors() before computing the KdTree.

Definition at line 104 of file ActorKdTree.cpp.

References vl::ActorTreeAbstract::prepareActors().

Referenced by vl::Terrain::init(), kdtreeFromNonLeafyActors(), and rebuildKdTree().

◆ child() [1/2]

ActorTreeAbstract * ActorKdTree::child ( int  i)
virtual

Returns the i-th child node of an ActorTreeAbstract node.

Implements vl::ActorTreeAbstract.

Definition at line 297 of file ActorKdTree.cpp.

References vl::Log::error(), vl::ref< T >::get(), mChildN, mChildP, and NULL.

◆ child() [2/2]

const ActorTreeAbstract * ActorKdTree::child ( int  i) const
virtual

Returns the i-th child node of an ActorTreeAbstract node.

Implements vl::ActorTreeAbstract.

Definition at line 311 of file ActorKdTree.cpp.

References vl::Log::error(), vl::ref< T >::get(), mChildN, mChildP, and NULL.

◆ childN() [1/2]

ActorKdTree* vl::ActorKdTree::childN ( )
inline

Returns the child node that lies in the negative space defined by the splitting plane.

Definition at line 87 of file ActorKdTree.hpp.

Referenced by harvestNonLeafActors(), insertActor(), and rebuildKdTree().

◆ childN() [2/2]

const ActorKdTree* vl::ActorKdTree::childN ( ) const
inline

Returns the child node that lies in the negative space defined by the splitting plane.

Definition at line 89 of file ActorKdTree.hpp.

◆ childP() [1/2]

ActorKdTree* vl::ActorKdTree::childP ( )
inline

Returns the child node that lies in the positive space defined by the splitting plane.

Definition at line 92 of file ActorKdTree.hpp.

Referenced by harvestNonLeafActors(), insertActor(), and rebuildKdTree().

◆ childP() [2/2]

const ActorKdTree* vl::ActorKdTree::childP ( ) const
inline

Returns the child node that lies in the positive space defined by the splitting plane.

Definition at line 94 of file ActorKdTree.hpp.

References vl::ActorTreeAbstract::mParent, NULL, and VL_CHECK.

◆ childrenCount()

int ActorKdTree::childrenCount ( ) const
virtual

Returns the number of child nodes of an ActorTreeAbstract node.

Implements vl::ActorTreeAbstract.

Definition at line 286 of file ActorKdTree.cpp.

References mChildN, and mChildP.

◆ harvestNonLeafActors()

void ActorKdTree::harvestNonLeafActors ( ActorCollection actors)

◆ insertActor()

ActorKdTree * ActorKdTree::insertActor ( Actor actor)

Inserts an Actor in the ActorKdTree node hierarchy.

Note that the Actor is likely to be inserted in a node whose bounding volume does not surround the Actor's bounding volume. For this reason after you inserted one or more Actors in the ActorKdTree you should call computeAABB() on the root node of the ActorKdTree. Inserting and removing Actors is an expensive operation and produces an ActorKdTree that is less balanced than the one you would get by recompiling the whole ActorKdTree from scratch.

Returns
The ActorKdTree node in which the Actor has been inserted.
See also
ActorTree::eraseActor()

Definition at line 269 of file ActorKdTree.cpp.

References vl::ActorTreeAbstract::actors(), vl::Actor::boundingBox(), childN(), childP(), vl::Plane::classify(), insertActor(), vl::Actor::lod(), mPlane, vl::Collection< T >::push_back(), and VL_CHECK.

Referenced by insertActor().

◆ kdtreeFromNonLeafyActors()

ref< ActorKdTree > ActorKdTree::kdtreeFromNonLeafyActors ( int  max_depth = 100,
float  minimum_volume = 0 
)

Removes the Actors in the internal nodes of the ActorKdTree and uses them to create a new ActorKdTree.

Definition at line 70 of file ActorKdTree.cpp.

References ActorKdTree(), buildKdTree(), and harvestNonLeafActors().

◆ plane()

const Plane& vl::ActorKdTree::plane ( ) const
inline

Returns the splitting plane used to divide its two child nodes.

Definition at line 84 of file ActorKdTree.hpp.

Referenced by rebuildKdTree().

◆ rebuildKdTree()

void ActorKdTree::rebuildKdTree ( int  max_depth = 100,
float  minimum_volume = 0 
)

Member Data Documentation

◆ mChildN

ref<ActorKdTree> vl::ActorKdTree::mChildN
protected

Definition at line 150 of file ActorKdTree.hpp.

Referenced by child(), childrenCount(), harvestNonLeafActors(), and rebuildKdTree().

◆ mChildP

ref<ActorKdTree> vl::ActorKdTree::mChildP
protected

Definition at line 151 of file ActorKdTree.hpp.

Referenced by child(), childrenCount(), harvestNonLeafActors(), and rebuildKdTree().

◆ mPlane

Plane vl::ActorKdTree::mPlane
protected

Definition at line 149 of file ActorKdTree.hpp.

Referenced by insertActor(), and rebuildKdTree().


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