OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreNodeMemoryManager.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4  (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2014 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 #ifndef __NodeMemoryManager_H__
29 #define __NodeMemoryManager_H__
30 
31 #include "OgreTransform.h"
32 #include "OgreArrayMemoryManager.h"
33 
34 namespace Ogre
35 {
37 
55  {
59 
63 
70 
75  void growToDepth( size_t newDepth );
76 
77  public:
79  virtual ~NodeMemoryManager();
80 
82  void _setTwin( SceneMemoryMgrTypes memoryManagerType, NodeMemoryManager *twinMemoryManager );
83 
87 
94  void nodeCreated( Transform &outTransform, size_t depth );
95 
106  void nodeAttached( Transform &outTransform, size_t depth );
107 
119  void nodeDettached( Transform &outTransform, size_t depth );
120 
127  void nodeDestroyed( Transform &outTransform, size_t depth );
128 
138  void nodeMoved( Transform &inOutTransform, size_t oldDepth, size_t newDepth );
139 
151  void migrateTo( Transform &inOutTransform, size_t depth,
152  NodeMemoryManager *dstNodeMemoryManager );
153 
159  size_t getNumDepths() const;
160 
169  size_t getFirstNode( Transform &outTransform, size_t depth );
170 
171  //Derived from ArrayMemoryManager::RebaseListener
172  virtual void buildDiffList( ArrayMemoryManager::ManagerType managerType, uint16 level,
173  const MemoryPoolVec &basePtrs,
174  ArrayMemoryManager::PtrdiffVec &outDiffsList );
175  virtual void applyRebase( ArrayMemoryManager::ManagerType managerType, uint16 level,
176  const MemoryPoolVec &newBasePtrs,
177  const ArrayMemoryManager::PtrdiffVec &diffsList );
178  virtual void performCleanup( ArrayMemoryManager::ManagerType managerType, uint16 level,
179  const MemoryPoolVec &basePtrs, size_t const *elementsMemSizes,
180  size_t startInstance, size_t diffInstances );
181  };
182 
185 }
186 
187 #endif
std::vector< ptrdiff_t > PtrdiffVec
When mUsedMemory >= mMaxMemory (that is, we've exhausted all our preallocated memory) ArrayMemoryMana...
Represents the transform of a single object, arranged in SoA (Structure of Arrays) ...
Definition: OgreTransform.h:37
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 valu...
Class representing a node in the scene graph.
Definition: OgreSceneNode.h:53
NodeMemoryManager * getTwin() const
Note the return value can be null.
void _setTwin(SceneMemoryMgrTypes memoryManagerType, NodeMemoryManager *twinMemoryManager)
mMemoryManagerType
size_t getFirstNode(Transform &outTransform, size_t depth)
Retrieves a Transform pointing to the first Node in the given depth.
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.
void migrateTo(Transform &inOutTransform, size_t depth, NodeMemoryManager *dstNodeMemoryManager)
Releases memory belonging to us, not before copying it into another manager.
ArrayMemoryManagerVec mMemoryManagers
ArrayMemoryManagers grouped by hierarchy depth.
void nodeAttached(Transform &outTransform, size_t depth)
Requests memory for the given transform to be attached, transferring existing values inside to the ne...
SceneMemoryMgrTypes mMemoryManagerType
Memory managers can have a 'twin' (optional).
void nodeDestroyed(Transform &outTransform, size_t depth)
Releases current memory.
NodeMemoryManager * mTwinMemoryManager
void nodeDettached(Transform &outTransform, size_t depth)
Releases current memory and requests memory from the root level.
size_t getNumDepths() const
Retrieves the number of depth levels that have been created.
SceneMemoryMgrTypes getMemoryManagerType() const
void growToDepth(size_t newDepth)
Makes mMemoryManagers big enough to be able to fulfill mMemoryManagers[newDepth]. ...
SceneMemoryMgrTypes
The types of NodeMemoryManager & ObjectMemoryManagers.
Definition: OgreCommon.h:318
SceneNode * mDummyNode
Dummy node where to point Transform::mParents[i] when they're unused slots.
vector< char * >::type MemoryPoolVec
vector< NodeArrayMemoryManager >::type ArrayMemoryManagerVec
unsigned short uint16
Definition: OgrePlatform.h:421
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.
void nodeCreated(Transform &outTransform, size_t depth)
Requests memory for the given transform for the first, initializing values.
Wrap-around class that contains multiple ArrayMemoryManager, one per hierarchy depth.
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.