OGRE-Next: Ogre::BoneMemoryManager Class Reference

| OGRE-Next 3.0.0 Object-Oriented Graphics Rendering Engine

Loading...
Searching...
No Matches
Public Member Functions | List of all members
Ogre::BoneMemoryManager Class Referencefinal
Core » Memory

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

`#include <OgreBoneMemoryManager.h>`

Inheritance diagram for Ogre::BoneMemoryManager:
[legend]

## 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.
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.
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.
size_t | getFirstNode (BoneTransform &outTransform, size_t depth)
| Retrieves a Transform pointing to the first Node in the given depth.
size_t | getNumDepths () const
| Retrieves the number of depth levels that have been created.
void | migrateTo (BoneTransform &inOutTransform, size_t depth, BoneMemoryManager *dstBoneMemoryManager)
| Releases memory belonging to us, not before copying it into another manager.
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.
void | nodeCreated (BoneTransform &outTransform, size_t depth)
| Requests memory for the given transform for the first, initializing values.
void | nodeDestroyed (BoneTransform &outTransform, size_t depth)
| Releases current memory.
void | nodeDettached (BoneTransform &outTransform, size_t depth)
| Releases current memory and requests memory from the root level.
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.
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.
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 | ( |  | ) |

Referenced by migrateTo().

## ◆ ~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

  level | The hierarchy depth level
  newBasePtrs | The new base ptr.
  diffsList | The 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

  level | The hierarchy depth level
  basePtrs | The base pointers from each pool so we can calculate the differences
  outDiffsList | The 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
  depth | Current 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

  inOutTransform | Valid Transform that belongs to us. Output will belong to the other memory mgr.
  depth | Current hierarchy level depth it belongs to.
  dstBoneMemoryManager | BoneMemoryManager that will now own the transform.

References BoneMemoryManager().

## ◆ 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

  outTransform | Transform with filled pointers
  depth | Hierarchy 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

  outTransform | Transform with filled pointers
  depth | Hierarchy level depth. 0 if not connected.

## ◆ nodeDestroyed()

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

Releases current memory.

Parameters

  outTransform | Transform with nullified pointers
  depth | Current 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

  outTransform | Transform with filled pointers
  depth | Current 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

  inOutTransform | Transform with filled pointers
  oldDepth | Current hierarchy level depth it belongs to.
  newDepth | Hierarchy 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

  level | The hierarchy depth level
  basePtrs | The base ptrs.
  startInstance | The instance to which past that we need to shift
  diffInstances | How 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:

- OgreBoneMemoryManager.h