OGRE-Next
4.0.0unstable
Object-Oriented Graphics Rendering Engine
|
Wrap-around class that contains multiple ArrayMemoryManager, one per hierarchy depth. More...
#include <OgreNodeMemoryManager.h>
Public Member Functions | |
NodeMemoryManager () | |
virtual | ~NodeMemoryManager () |
SceneNode * | _getDummyNode () const |
void | _setTwin (SceneMemoryMgrTypes memoryManagerType, NodeMemoryManager *twinMemoryManager) |
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... | |
void | defragment () |
Triggers on demand a defragmentation of the pools, so that all slots become contiguous in memory. More... | |
size_t | getFirstNode (Transform &outTransform, size_t depth) |
Retrieves a Transform pointing to the first Node in the given depth. More... | |
SceneMemoryMgrTypes | getMemoryManagerType () const |
size_t | getNumDepths () const |
Retrieves the number of depth levels that have been created. More... | |
NodeMemoryManager * | getTwin () const |
Note the return value can be null. More... | |
void | migrateTo (Transform &inOutTransform, size_t depth, NodeMemoryManager *dstNodeMemoryManager) |
Releases memory belonging to us, not before copying it into another manager. More... | |
void | migrateTo (Transform &inOutTransform, size_t oldDepth, size_t newDepth, NodeMemoryManager *dstNodeMemoryManager) |
Releases memory belonging to us, not before copying it into another manager. More... | |
void | migrateToAndAttach (Transform &inOutTransform, size_t depth, NodeMemoryManager *dstNodeMemoryManager) |
It's the same as calling: this->nodeAttached( transform, depth ); this->migrateTo( transform, depth, dstNodeMemoryManager ); Without unnecessary transfers. More... | |
void | migrateToAndDetach (Transform &inOutTransform, size_t depth, NodeMemoryManager *dstNodeMemoryManager) |
It's almost the same as calling: this->nodeDettached( transform, depth ); this->migrateTo( transform, 0, dstNodeMemoryManager ); Without unnecessary transfers and setting the correct dstNodeMemoryManager->mDummyNode. More... | |
void | neverDefragment () |
Prevent defragmentation from ever happening. More... | |
void | nodeAttached (Transform &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 (Transform &outTransform, size_t depth) |
Requests memory for the given transform for the first, initializing values. More... | |
void | nodeDestroyed (Transform &outTransform, size_t depth) |
Releases current memory. More... | |
void | nodeDettached (Transform &outTransform, size_t depth) |
Releases current memory and requests memory from the root level. More... | |
void | nodeMoved (Transform &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 | shrinkToFit () |
Defragments memory, then reallocates a smaller pool that tightly fits the current number of objects. More... | |
Wrap-around class that contains multiple ArrayMemoryManager, one per hierarchy depth.
Ogre::NodeMemoryManager::NodeMemoryManager | ( | ) |
|
virtual |
|
inline |
void Ogre::NodeMemoryManager::_setTwin | ( | SceneMemoryMgrTypes | memoryManagerType, |
NodeMemoryManager * | twinMemoryManager | ||
) |
|
overridevirtual |
Called when the manager already grew it's memory pool to honour more node requests.
level | The hierarchy depth level |
newBasePtrs | The new base ptr. |
diffsList | The list built in buildDiffList |
Implements Ogre::ArrayMemoryManager::RebaseListener.
|
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)
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.
void Ogre::NodeMemoryManager::defragment | ( | ) |
Triggers on demand a defragmentation of the pools, so that all slots become contiguous in memory.
ArrayMemoryManager::destroySlot already does this when the number of fragmented slots reaches mCleanupThreshold
size_t Ogre::NodeMemoryManager::getFirstNode | ( | Transform & | outTransform, |
size_t | depth | ||
) |
|
inline |
size_t Ogre::NodeMemoryManager::getNumDepths | ( | ) | const |
Retrieves the number of depth levels that have been created.
|
inline |
Note the return value can be null.
void Ogre::NodeMemoryManager::migrateTo | ( | Transform & | inOutTransform, |
size_t | depth, | ||
NodeMemoryManager * | dstNodeMemoryManager | ||
) |
Releases memory belonging to us, not before copying it into another manager.
inOutTransform | Valid Transform that belongs to us. Output will belong to the other memory mgr. |
depth | Current hierarchy level depth it belongs to. |
dstNodeMemoryManager | NodeMemoryManager that will now own the transform. |
void Ogre::NodeMemoryManager::migrateTo | ( | Transform & | inOutTransform, |
size_t | oldDepth, | ||
size_t | newDepth, | ||
NodeMemoryManager * | dstNodeMemoryManager | ||
) |
Releases memory belonging to us, not before copying it into another manager.
inOutTransform | Valid Transform that belongs to us. Output will belong to the other memory mgr. |
oldDepth | Current hierarchy level depth it belongs to in this manager. |
newDepth | New hierarchy level depth it will belong belongs in dstNodeMemoryManager. If this value is zero, then oldDepth must be zero as well. Otherwise use migrateToAndDetach instead. |
dstNodeMemoryManager | NodeMemoryManager that will now own the transform. |
void Ogre::NodeMemoryManager::migrateToAndAttach | ( | Transform & | inOutTransform, |
size_t | depth, | ||
NodeMemoryManager * | dstNodeMemoryManager | ||
) |
It's the same as calling: this->nodeAttached( transform, depth ); this->migrateTo( transform, depth, dstNodeMemoryManager ); Without unnecessary transfers.
void Ogre::NodeMemoryManager::migrateToAndDetach | ( | Transform & | inOutTransform, |
size_t | depth, | ||
NodeMemoryManager * | dstNodeMemoryManager | ||
) |
It's almost the same as calling: this->nodeDettached( transform, depth ); this->migrateTo( transform, 0, dstNodeMemoryManager ); Without unnecessary transfers and setting the correct dstNodeMemoryManager->mDummyNode.
instead of this->mDummyNode.
void Ogre::NodeMemoryManager::neverDefragment | ( | ) |
Prevent defragmentation from ever happening.
void Ogre::NodeMemoryManager::nodeAttached | ( | Transform & | outTransform, |
size_t | depth | ||
) |
Requests memory for the given transform to be attached, transferring existing values inside to the new memory block.
outTransform | Transform with filled pointers |
depth | Hierarchy level depth the node belongs to. If 0, nothing happens. |
void Ogre::NodeMemoryManager::nodeCreated | ( | Transform & | outTransform, |
size_t | depth | ||
) |
Requests memory for the given transform for the first, initializing values.
outTransform | Transform with filled pointers |
depth | Hierarchy level depth. 0 if not connected. |
void Ogre::NodeMemoryManager::nodeDestroyed | ( | Transform & | outTransform, |
size_t | depth | ||
) |
Releases current memory.
outTransform | Transform with nullified pointers |
depth | Current hierarchy level depth it belongs to. |
void Ogre::NodeMemoryManager::nodeDettached | ( | Transform & | outTransform, |
size_t | depth | ||
) |
Releases current memory and requests memory from the root level.
outTransform | Transform with filled pointers |
depth | Current hierarchy level depth it belongs to. If 0, nothing happens. |
void Ogre::NodeMemoryManager::nodeMoved | ( | Transform & | inOutTransform, |
size_t | oldDepth, | ||
size_t | newDepth | ||
) |
|
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.
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).
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.
void Ogre::NodeMemoryManager::shrinkToFit | ( | ) |
Defragments memory, then reallocates a smaller pool that tightly fits the current number of objects.
Useful when you know you won't be creating more slots and you need to reclaim memory.