OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreObjectMemoryManager.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 __ObjectMemoryManager_H__
29 #define __ObjectMemoryManager_H__
30 
33 
35 
36 namespace Ogre
37 {
39  class NullEntity;
40 
57  {
61 
63  size_t mTotalObjects;
64 
69 
76 
81  void growToDepth( size_t newDepth );
82 
83  public:
85  virtual ~ObjectMemoryManager();
86 
88  void _setTwin( SceneMemoryMgrTypes memoryManagerType, ObjectMemoryManager *twinMemoryManager );
89 
91  ObjectMemoryManager* getTwin() const { return mTwinMemoryManager; }
92  SceneMemoryMgrTypes getMemoryManagerType() const { return mMemoryManagerType; }
93 
100  void objectCreated( ObjectData &outObjectData, size_t renderQueue );
101 
111  void objectMoved( ObjectData &inOutObjectData, size_t oldRenderQueue, size_t newRenderQueue );
112 
119  void objectDestroyed( ObjectData &outObjectData, size_t renderQueue );
120 
132  void migrateTo( ObjectData &inOutTransform, size_t renderQueue,
133  ObjectMemoryManager *dstObjectMemoryManager );
134 
140  size_t getNumRenderQueues() const;
141 
142  size_t _getTotalRenderQueues() const { return mMemoryManagers.size(); }
143 
155  size_t getTotalNumObjects() const { return mTotalObjects; }
156 
158  SceneNode* _getDummyNode() const { return mDummyNode; }
159 
168  size_t getFirstObjectData( ObjectData &outObjectData, size_t renderQueue );
169 
170  //Derived from ArrayMemoryManager::RebaseListener
171  virtual void buildDiffList( ArrayMemoryManager::ManagerType managerType, uint16 level,
172  const MemoryPoolVec &basePtrs,
173  ArrayMemoryManager::PtrdiffVec &outDiffsList );
174  virtual void applyRebase( ArrayMemoryManager::ManagerType managerType, uint16 level,
175  const MemoryPoolVec &newBasePtrs,
176  const ArrayMemoryManager::PtrdiffVec &diffsList );
177  virtual void performCleanup( ArrayMemoryManager::ManagerType managerType, uint16 level,
178  const MemoryPoolVec &basePtrs, size_t const *elementsMemSizes,
179  size_t startInstance, size_t diffInstances );
180  };
181 
184 }
185 
186 #endif
size_t getTotalNumObjects() const
Retrieves the sum of the number of objects in all render queues.
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) ...
SceneMemoryMgrTypes getMemoryManagerType() const
SceneNode * mDummyNode
Dummy node where to point ObjectData::mParents[i] when they're unused slots.
Represents the transform of a single object, arranged in SoA (Structure of Arrays) ...
Definition: OgreTransform.h:37
#define _OgreExport
Definition: OgrePlatform.h:255
Wrap-around class that contains multiple ArrayMemoryManager, one per render queue.
Class representing a node in the scene graph.
Definition: OgreSceneNode.h:53
ArrayMemoryManagerVec mMemoryManagers
ArrayMemoryManagers grouped by hierarchy depth.
ObjectMemoryManager * getTwin() const
Note the return value can be null.
size_t mTotalObjects
Tracks total number of objects in all render queues.
vector< ObjectDataArrayMemoryManager >::type ArrayMemoryManagerVec
SceneMemoryMgrTypes mMemoryManagerType
Memory managers can have a 'twin' (optional).
SceneMemoryMgrTypes
The types of NodeMemoryManager & ObjectMemoryManagers.
Definition: OgreCommon.h:318
SceneNode * _getDummyNode() const
Returns the pointer to the dummy node (useful when detaching)
vector< char * >::type MemoryPoolVec
unsigned short uint16
Definition: OgrePlatform.h:421
ObjectMemoryManager * mTwinMemoryManager