OGRE-Next  4.0.0unstable
Object-Oriented Graphics Rendering Engine
Ogre::BoneMemoryManager Class Referencefinal

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

#include <OgreBoneMemoryManager.h>

+ Inheritance 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...
 
void applyRebase (uint16 level, const MemoryPoolVec &newBasePtrs, const ArrayMemoryManager::PtrdiffVec &diffsList) override
 Called when the manager already grew it's memory pool to honour more node requests. More...
 
void buildDiffList (uint16 level, const MemoryPoolVec &basePtrs, ArrayMemoryManager::PtrdiffVec &outDiffsList) override
 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...
 
void performCleanup (uint16 level, const MemoryPoolVec &basePtrs, size_t const *elementsMemSizes, size_t startInstance, size_t diffInstances) override
 Called when too many nodes were destroyed in a non-LIFO fashion. More...
 
void setBoneRebaseListener (BySkeletonDef *l)
 

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.

Constructor & Destructor Documentation

◆ BoneMemoryManager()

Ogre::BoneMemoryManager::BoneMemoryManager ( )

◆ ~BoneMemoryManager()

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

Member Function Documentation

◆ _growToDepth()

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.

◆ applyRebase()

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

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
levelThe hierarchy depth level
newBasePtrsThe new base ptr.
diffsListThe list built in buildDiffList

Implements Ogre::ArrayMemoryManager::RebaseListener.

◆ buildDiffList()

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

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
levelThe hierarchy depth level
basePtrsThe base pointers from each pool so we can calculate the differences
outDiffsListThe list we'll generate. "outDiffsList" already has enough reserved space

Implements Ogre::ArrayMemoryManager::RebaseListener.

◆ getFirstNode()

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

◆ getNumDepths()

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.

◆ migrateTo()

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.

◆ nodeAttached()

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.

◆ nodeCreated()

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.

◆ nodeDestroyed()

void Ogre::BoneMemoryManager::nodeDestroyed ( BoneTransform outTransform,
size_t  depth 
)

Releases current memory.

Parameters
outTransformTransform with nullified pointers
depthCurrent hierarchy level depth it belongs to.

◆ nodeDettached()

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.

◆ nodeMoved()

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.

◆ performCleanup()

void Ogre::BoneMemoryManager::performCleanup ( uint16  level,
const MemoryPoolVec basePtrs,
size_t const *  elementsMemSizes,
size_t  startInstance,
size_t  diffInstances 
)
overridevirtual

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
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.

◆ setBoneRebaseListener()

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

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