Visualization Library 2.0.0
A lightweight C++ OpenGL middleware for 2D/3D graphics
|
[Download] [Tutorials] [All Classes] [Grouped Classes] |
ActorKdTree class extends the ActorTreeAbstract class implementing a space partitioning scheme based on a Kd-Tree. More...
#include <ActorKdTree.hpp>
Public Member Functions | |
ActorKdTree () | |
virtual int | childrenCount () const |
Returns the number of child nodes of an ActorTreeAbstract node. More... | |
virtual ActorTreeAbstract * | child (int i) |
Returns the i-th child node of an ActorTreeAbstract node. More... | |
virtual const ActorTreeAbstract * | child (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 Plane & | plane () const |
Returns the splitting plane used to divide its two child nodes. More... | |
ActorKdTree * | childN () |
Returns the child node that lies in the negative space defined by the splitting plane. More... | |
const ActorKdTree * | childN () const |
Returns the child node that lies in the negative space defined by the splitting plane. More... | |
ActorKdTree * | childP () |
Returns the child node that lies in the positive space defined by the splitting plane. More... | |
const ActorKdTree * | childP () const |
Returns the child node that lies in the positive space defined by the splitting plane. More... | |
ActorKdTree * | insertActor (Actor *actor) |
Inserts an Actor in the ActorKdTree node hierarchy. More... | |
ref< 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. 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 ActorTreeAbstract * | parent () const |
Returns the parent of a node. More... | |
ActorTreeAbstract * | parent () |
Returns the parent of a node. More... | |
const ActorCollection * | actors () const |
Returns the actors contained in a ActorTree node. More... | |
ActorCollection * | actors () |
Returns the actors contained in a ActorTree node. More... | |
const AABB & | aabb () 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... | |
ActorTreeAbstract * | eraseActor (Actor *actor) |
Removes the given Actor from the ActorTreeAbstract. More... | |
Actor * | addActor (Renderable *renderable, Effect *eff, Transform *tr=NULL) |
Utility function that adds an Actor and binds it to the given Renderable, Effect and Transform. More... | |
Actor * | addActor (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... | |
Object & | operator= (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... | |
IMutex * | refCountMutex () |
The mutex used to protect the reference counting of an Object across multiple threads. More... | |
const IMutex * | refCountMutex () 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< ActorKdTree > | mChildN |
ref< ActorKdTree > | mChildP |
Protected Attributes inherited from vl::ActorTreeAbstract | |
ActorTreeAbstract * | mParent |
ActorCollection | mActors |
AABB | mAABB |
bool | mEnabled |
Protected Attributes inherited from vl::Object | |
std::string | mObjectName |
IMutex * | mRefCountMutex |
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 () |
ActorKdTree class extends the ActorTreeAbstract class implementing a space partitioning scheme based on a Kd-Tree.
Definition at line 57 of file ActorKdTree.hpp.
|
inline |
Definition at line 62 of file ActorKdTree.hpp.
Referenced by kdtreeFromNonLeafyActors().
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.
Definition at line 104 of file ActorKdTree.cpp.
References vl::ActorTreeAbstract::prepareActors().
Referenced by vl::Terrain::init(), kdtreeFromNonLeafyActors(), and rebuildKdTree().
|
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.
|
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.
|
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().
|
inline |
Returns the child node that lies in the negative space defined by the splitting plane.
Definition at line 89 of file ActorKdTree.hpp.
|
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().
|
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.
|
virtual |
Returns the number of child nodes of an ActorTreeAbstract node.
Implements vl::ActorTreeAbstract.
Definition at line 286 of file ActorKdTree.cpp.
void ActorKdTree::harvestNonLeafActors | ( | ActorCollection & | actors | ) |
Removes the Actors in the internal nodes of the ActorKdTree and appends them in the given ActorCollection.
Definition at line 79 of file ActorKdTree.cpp.
References vl::ActorTreeAbstract::actors(), childN(), childP(), vl::Collection< T >::clear(), harvestNonLeafActors(), vl::ActorTreeAbstract::mAABB, mChildN, mChildP, vl::Collection< T >::push_back(), vl::AABB::setNull(), vl::Collection< T >::size(), and VL_CHECK.
Referenced by harvestNonLeafActors(), and kdtreeFromNonLeafyActors().
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.
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().
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().
|
inline |
Returns the splitting plane used to divide its two child nodes.
Definition at line 84 of file ActorKdTree.hpp.
Referenced by rebuildKdTree().
void ActorKdTree::rebuildKdTree | ( | int | max_depth = 100 , |
float | minimum_volume = 0 |
||
) |
Builds a ActorKdTree with the Actors contained in the tree.
Definition at line 111 of file ActorKdTree.cpp.
References vl::abs(), vl::ActorTreeAbstract::actors(), buildKdTree(), childN(), childP(), vl::Plane::classify(), vl::Collection< T >::clear(), vl::ActorTreeAbstract::extractActors(), vl::ActorTreeAbstract::mAABB, vl::ActorTreeAbstract::mActors, mChildN, mChildP, mPlane, NULL, plane(), vl::Collection< T >::push_back(), vl::Collection< T >::reserve(), vl::AABB::setNull(), vl::Collection< T >::size(), vl::Collection< T >::vector(), VL_CHECK, and vl::AABB::volume().
|
protected |
Definition at line 150 of file ActorKdTree.hpp.
Referenced by child(), childrenCount(), harvestNonLeafActors(), and rebuildKdTree().
|
protected |
Definition at line 151 of file ActorKdTree.hpp.
Referenced by child(), childrenCount(), harvestNonLeafActors(), and rebuildKdTree().
|
protected |
Definition at line 149 of file ActorKdTree.hpp.
Referenced by insertActor(), and rebuildKdTree().
Visualization Library 2.0.0 Reference Documentation
Updated on Wed Dec 23 2020 12:44:05.
© Copyright Michele Bosi. All rights reserved.