OGRE-Next
2.3
Object-Oriented Graphics Rendering Engine
|
Wrap-around class that contains multiple ArrayMemoryManager, one per render queue. More...
#include <OgreObjectMemoryManager.h>
Public Member Functions | |
ObjectMemoryManager () | |
virtual | ~ObjectMemoryManager () |
SceneNode * | _getDummyNode () const |
Returns the pointer to the dummy node (useful when detaching) More... | |
size_t | _getTotalRenderQueues () const |
void | _setTwin (SceneMemoryMgrTypes memoryManagerType, ObjectMemoryManager *twinMemoryManager) |
@See mMemoryManagerType 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 | calculateTotalNumObjectDataIncludingFragmentedSlots () const |
This is the opposite of getTotalNumObjects. More... | |
void | defragment () |
Triggers on demand a defragmentation of the pools, so that all slots become contiguous in memory. More... | |
size_t | getFirstObjectData (ObjectData &outObjectData, size_t renderQueue) |
Retrieves a ObjectData pointing to the first MovableObject in the given render queue. More... | |
SceneMemoryMgrTypes | getMemoryManagerType () const |
size_t | getNumRenderQueues () const |
Retrieves the number of render queues that have been created. More... | |
size_t | getTotalNumObjects () const |
Retrieves the sum of the number of objects in all render queues. More... | |
ObjectMemoryManager * | getTwin () const |
Note the return value can be null. More... | |
void | migrateTo (ObjectData &inOutTransform, size_t renderQueue, ObjectMemoryManager *dstObjectMemoryManager) |
Releases memory belonging to us, not before copying it into another manager. More... | |
void | objectCreated (ObjectData &outObjectData, size_t renderQueue) |
Requests memory for the given ObjectData, initializing values. More... | |
void | objectDestroyed (ObjectData &outObjectData, size_t renderQueue) |
Releases current memory. More... | |
void | objectMoved (ObjectData &inOutObjectData, size_t oldRenderQueue, size_t newRenderQueue) |
Requests memory for the given ObjectData to be moved to a different render queue, 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 render queue.
Ogre::ObjectMemoryManager::ObjectMemoryManager | ( | ) |
|
virtual |
|
inline |
Returns the pointer to the dummy node (useful when detaching)
|
inline |
void Ogre::ObjectMemoryManager::_setTwin | ( | SceneMemoryMgrTypes | memoryManagerType, |
ObjectMemoryManager * | twinMemoryManager | ||
) |
@See mMemoryManagerType
|
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 |
utDiffsList | The list we'll generate. "outDiffsList" already has enough reserved space |
Implements Ogre::ArrayMemoryManager::RebaseListener.
size_t Ogre::ObjectMemoryManager::calculateTotalNumObjectDataIncludingFragmentedSlots | ( | ) | const |
This is the opposite of getTotalNumObjects.
This function returns the sum of the return values of getFirstObjectData
void Ogre::ObjectMemoryManager::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::ObjectMemoryManager::getFirstObjectData | ( | ObjectData & | outObjectData, |
size_t | renderQueue | ||
) |
Retrieves a ObjectData pointing to the first MovableObject in the given render queue.
outObjectData | [out] ObjectData with filled pointers to the first MovableObject in this depth |
renderQueue | Current render queue it belongs to. |
|
inline |
size_t Ogre::ObjectMemoryManager::getNumRenderQueues | ( | ) | const |
Retrieves the number of render queues that have been created.
|
inline |
Retrieves the sum of the number of objects in all render queues.
|
inline |
Note the return value can be null.
void Ogre::ObjectMemoryManager::migrateTo | ( | ObjectData & | inOutTransform, |
size_t | renderQueue, | ||
ObjectMemoryManager * | dstObjectMemoryManager | ||
) |
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. |
dstObjectMemoryManager | ObjectMemoryManager that will now own the transform. |
void Ogre::ObjectMemoryManager::objectCreated | ( | ObjectData & | outObjectData, |
size_t | renderQueue | ||
) |
Requests memory for the given ObjectData, initializing values.
outObjectData | ObjectData with filled pointers |
renderQueue | RenderQueue ID. |
void Ogre::ObjectMemoryManager::objectDestroyed | ( | ObjectData & | outObjectData, |
size_t | renderQueue | ||
) |
Releases current memory.
outObjectData | ObjectData whose pointers will be nullified. |
renderQueue | Current render queue it belongs to. |
void Ogre::ObjectMemoryManager::objectMoved | ( | ObjectData & | inOutObjectData, |
size_t | oldRenderQueue, | ||
size_t | newRenderQueue | ||
) |
Requests memory for the given ObjectData to be moved to a different render queue, transferring existing values inside to the new memory slot.
inOutObjectData | ObjectData with filled pointers |
oldRenderQueue | RenderQueue it's living now. |
newRenderQueue | RenderQueue it wants to live in. |
|
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::ObjectMemoryManager::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.