OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Ogre::BoneMemoryManager Class Reference

Wrap-around class that contains multiple ArrayMemoryManager, one per hierarchy depth. More...

#include <OgreBoneMemoryManager.h>

+ Inheritance diagram for Ogre::BoneMemoryManager:
+ Collaboration diagram for Ogre::BoneMemoryManager:

Public Member Functions

 BoneMemoryManager ()
 
virtual ~BoneMemoryManager ()
 
void _growToDepth (const vector< size_t >::type &bonesPerDepth)
 Since skeleton's hierarchy structure is known beforehand, we use this information for setting a better optimal cleanup value, to avoid excessive stalls when destroying skeleton instances. More...
 
virtual void applyRebase (ArrayMemoryManager::ManagerType managerType, uint16 level, const MemoryPoolVec &newBasePtrs, const ArrayMemoryManager::PtrdiffVec &diffsList)
 Called when the manager already grew it's memory pool to honour more node requests. More...
 
virtual void buildDiffList (ArrayMemoryManager::ManagerType managerType, uint16 level, const MemoryPoolVec &basePtrs, ArrayMemoryManager::PtrdiffVec &outDiffsList)
 Called when the manager needs to grow it's memory pool to honour more node requests. More...
 
size_t getFirstNode (BoneTransform &outTransform, size_t depth)
 Retrieves a Transform pointing to the first Node in the given depth. More...
 
size_t getNumDepths () const
 Retrieves the number of depth levels that have been created. More...
 
void migrateTo (BoneTransform &inOutTransform, size_t depth, BoneMemoryManager *dstBoneMemoryManager)
 Releases memory belonging to us, not before copying it into another manager. More...
 
void nodeAttached (BoneTransform &outTransform, size_t depth)
 Requests memory for the given transform to be attached, transferring existing values inside to the new memory block. More...
 
void nodeCreated (BoneTransform &outTransform, size_t depth)
 Requests memory for the given transform for the first, initializing values. More...
 
void nodeDestroyed (BoneTransform &outTransform, size_t depth)
 Releases current memory. More...
 
void nodeDettached (BoneTransform &outTransform, size_t depth)
 Releases current memory and requests memory from the root level. More...
 
void nodeMoved (BoneTransform &inOutTransform, size_t oldDepth, size_t newDepth)
 Requests memory for the given Node to be moved to a different depth level, transferring existing values inside to the new memory slot. More...
 
virtual void performCleanup (ArrayMemoryManager::ManagerType managerType, uint16 level, const MemoryPoolVec &basePtrs, size_t const *elementsMemSizes, size_t startInstance, size_t diffInstances)
 Called when too many nodes were destroyed in a non-LIFO fashion. More...
 
void setBoneRebaseListener (BySkeletonDef *l)
 

Private Types

typedef vector
< BoneArrayMemoryManager >
::type 
ArrayMemoryManagerVec
 

Private Member Functions

void growToDepth (size_t newDepth)
 Makes mMemoryManagers big enough to be able to fulfill mMemoryManagers[newDepth]. More...
 

Private Attributes

BySkeletonDefmBoneRebaseListener
 
ArrayMemoryManagerVec mMemoryManagers
 ArrayMemoryManagers grouped by hierarchy depth. More...
 

Detailed Description

Wrap-around class that contains multiple ArrayMemoryManager, one per hierarchy depth.

Remarks
This is the main memory manager that actually manages Bone, and have to be called when a new Bone was created, when a Bone gets detached from it's parent, when it's attached again, etc.
Note that some SceneManager implementations (i.e. Octree like) may want to have more than one BoneMemoryManager, for example one per octant.

Definition at line 56 of file OgreBoneMemoryManager.h.

Member Typedef Documentation

Constructor & Destructor Documentation

Ogre::BoneMemoryManager::BoneMemoryManager ( )
virtual Ogre::BoneMemoryManager::~BoneMemoryManager ( )
virtual

Member Function Documentation

void Ogre::BoneMemoryManager::_growToDepth ( const vector< size_t >::type &  bonesPerDepth)

Since skeleton's hierarchy structure is known beforehand, we use this information for setting a better optimal cleanup value, to avoid excessive stalls when destroying skeleton instances.

virtual void Ogre::BoneMemoryManager::applyRebase ( ArrayMemoryManager::ManagerType  managerType,
uint16  level,
const MemoryPoolVec newBasePtrs,
const ArrayMemoryManager::PtrdiffVec diffsList 
)
virtual

Called when the manager already grew it's memory pool to honour more node requests.

Remarks
Will use the new base ptr and the list we built in
See also
buildDiffList() to know what mChunkPtr & mIndex needs to be set for each ArrayVector3/etc we have.
Parameters
managerTypeThe derived type of this manager, so listener knows whether this is an Node or ObjectData manager
levelThe hierarchy depth level
newBasePtrsThe new base ptr.
diffsListThe list built in buildDiffList

Implements Ogre::ArrayMemoryManager::RebaseListener.

virtual void Ogre::BoneMemoryManager::buildDiffList ( ArrayMemoryManager::ManagerType  managerType,
uint16  level,
const MemoryPoolVec basePtrs,
ArrayMemoryManager::PtrdiffVec outDiffsList 
)
virtual

Called when the manager needs to grow it's memory pool to honour more node requests.

See the class description on why we need to do this (to avoid C++ undefined behavior)

Remarks
Needs to builds a list that will contain the difference in bytes between each ArrayVector3/ArrayMatrix4/etc and the base pointers in_the_order in which the derived class holds those pointers (i.e. in the order the SceneNodes are arranged in memory)
Parameters
managerTypeThe derived type of this manager, so listener knows whether this is an Node or ObjectData manager
levelThe hierarchy depth level
basePtrsThe base pointers from each pool so we can calculate the differences
utDiffsListThe list we'll generate. "outDiffsList" already has enough reserved space

Implements Ogre::ArrayMemoryManager::RebaseListener.

size_t Ogre::BoneMemoryManager::getFirstNode ( BoneTransform outTransform,
size_t  depth 
)

Retrieves a Transform pointing to the first Node in the given depth.

Parameters
outTransform[out] Transform with filled pointers to the first Node in this depth
depthCurrent hierarchy level depth it belongs to.
Returns
Number of Nodes in this depth level
size_t Ogre::BoneMemoryManager::getNumDepths ( ) const

Retrieves the number of depth levels that have been created.

Remarks
The return value is equal or below mMemoryManagers.size(), you should cache the result instead of calling this function too often.
void Ogre::BoneMemoryManager::growToDepth ( size_t  newDepth)
private

Makes mMemoryManagers big enough to be able to fulfill mMemoryManagers[newDepth].

Parameters
newDepthHierarchy level depth we wish to grow to.
void Ogre::BoneMemoryManager::migrateTo ( BoneTransform inOutTransform,
size_t  depth,
BoneMemoryManager dstBoneMemoryManager 
)

Releases memory belonging to us, not before copying it into another manager.

Remarks
This function is useful when implementing multiple Memory Managers in Scene Managers or when switching nodes from Static to/from Dynamic.
Parameters
inOutTransformValid Transform that belongs to us. Output will belong to the other memory mgr.
depthCurrent hierarchy level depth it belongs to.
dstBoneMemoryManagerBoneMemoryManager that will now own the transform.
void Ogre::BoneMemoryManager::nodeAttached ( BoneTransform outTransform,
size_t  depth 
)

Requests memory for the given transform to be attached, transferring existing values inside to the new memory block.

Remarks
Do NOT call this function twice in a row without having called nodeDettached in the middle
Parameters
outTransformTransform with filled pointers
depthHierarchy level depth the node belongs to. If 0, nothing happens.
void Ogre::BoneMemoryManager::nodeCreated ( BoneTransform outTransform,
size_t  depth 
)

Requests memory for the given transform for the first, initializing values.

Parameters
outTransformTransform with filled pointers
depthHierarchy level depth. 0 if not connected.
void Ogre::BoneMemoryManager::nodeDestroyed ( BoneTransform outTransform,
size_t  depth 
)

Releases current memory.

Parameters
outTransformTransform with nullified pointers
depthCurrent hierarchy level depth it belongs to.
void Ogre::BoneMemoryManager::nodeDettached ( BoneTransform outTransform,
size_t  depth 
)

Releases current memory and requests memory from the root level.

Remarks
Do NOT call this function twice in a row without having called nodeAttached in the middle
outTransform.mParents[outTransform.mIndex] is reset to a dummy parent node
Parameters
outTransformTransform with filled pointers
depthCurrent hierarchy level depth it belongs to. If 0, nothing happens.
void Ogre::BoneMemoryManager::nodeMoved ( BoneTransform inOutTransform,
size_t  oldDepth,
size_t  newDepth 
)

Requests memory for the given Node to be moved to a different depth level, transferring existing values inside to the new memory slot.

Parameters
inOutTransformTransform with filled pointers
oldDepthCurrent hierarchy level depth it belongs to.
newDepthHierarchy level depth it wants to belongs to.
virtual void Ogre::BoneMemoryManager::performCleanup ( ArrayMemoryManager::ManagerType  managerType,
uint16  level,
const MemoryPoolVec basePtrs,
size_t const *  elementsMemSizes,
size_t  startInstance,
size_t  diffInstances 
)
virtual

Called when too many nodes were destroyed in a non-LIFO fashion.

Without cleaning up, the scene manager will waste CPU & bandwidth on processing vectors & matrices that are not in use. The more fragmented/unordered those removals were, the worst it is. Try to create everything static first, then dynamic content.

Remarks
The manager behaves similarly to a Garbage Collector, as it is triggered after certain amount of nodes have been freed (unless they respected LIFO order)

In a way, it's very similar to vector::remove(), as removing an element from the middle means we need to shift everything past that point one place (or more).

Parameters
managerTypeThe derived type of this manager, so listener knows whether this is an Node or ObjectData manager
levelThe hierarchy depth level
basePtrsThe base ptrs.
startInstanceThe instance to which past that we need to shift
diffInstancesHow many places we need to shift backwards.

Implements Ogre::ArrayMemoryManager::RebaseListener.

void Ogre::BoneMemoryManager::setBoneRebaseListener ( BySkeletonDef l)
inline

Definition at line 162 of file OgreBoneMemoryManager.h.

Member Data Documentation

BySkeletonDef* Ogre::BoneMemoryManager::mBoneRebaseListener
private

Definition at line 62 of file OgreBoneMemoryManager.h.

ArrayMemoryManagerVec Ogre::BoneMemoryManager::mMemoryManagers
private

ArrayMemoryManagers grouped by hierarchy depth.

Definition at line 60 of file OgreBoneMemoryManager.h.


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