OgreVertexIndexData.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-2013 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 __VertexIndexData_H__
29 #define __VertexIndexData_H__
30 
31 #include "OgrePrerequisites.h"
34 #include "OgreHeaderPrefix.h"
35 
36 namespace Ogre {
44  typedef vector<HardwareBuffer::Usage>::type BufferUsageList;
46 
47 
50  {
51  private:
53  VertexData(const VertexData& rhs); /* do nothing, should not use */
55  VertexData& operator=(const VertexData& rhs); /* do not use */
56 
58  public:
75  ~VertexData();
76 
88  size_t vertexStart;
90  size_t vertexCount;
91 
92 
95  {
96  unsigned short targetBufferIndex;
98  };
104 
110  VertexData* clone(bool copyData = true, HardwareBufferManagerBase* mgr = 0) const;
111 
131  void prepareForShadowVolume(void);
132 
147 
148 
167  void reorganiseBuffers(VertexDeclaration* newDeclaration, const BufferUsageList& bufferUsage,
168  HardwareBufferManagerBase* mgr = 0);
169 
187  void reorganiseBuffers(VertexDeclaration* newDeclaration, HardwareBufferManagerBase* mgr = 0);
188 
198  void closeGapsInBindings(void);
199 
208  void removeUnusedBuffers(void);
209 
217  void convertPackedColour(VertexElementType srcType, VertexElementType destType);
218 
219 
235  ushort allocateHardwareAnimationElements(ushort count, bool animateNormals);
236 
237 
238 
239  };
240 
243  {
244  protected:
246  IndexData(const IndexData& rhs); /* do nothing, should not use */
248  IndexData& operator=(const IndexData& rhs); /* do not use */
249  public:
250  IndexData();
251  ~IndexData();
254 
256  size_t indexStart;
257 
259  size_t indexCount;
260 
266  IndexData* clone(bool copyData = true, HardwareBufferManagerBase* mgr = 0) const;
267 
276  void optimiseVertexCacheTriList(void);
277 
278  };
279 
286  {
287  public:
288  enum CacheType {
289  FIFO, LRU
290  };
291 
292  VertexCacheProfiler(unsigned int cachesize = 16, CacheType cachetype = FIFO )
293  : size ( cachesize ), tail (0), buffersize (0), hit (0), miss (0)
294  {
295  cache = OGRE_ALLOC_T(uint32, size, MEMCATEGORY_GEOMETRY);
296  }
297 
299  {
301  }
302 
303  void profile(const HardwareIndexBufferSharedPtr& indexBuffer);
304  void reset() { hit = 0; miss = 0; tail = 0; buffersize = 0; }
305  void flush() { tail = 0; buffersize = 0; }
306 
307  unsigned int getHits() { return hit; }
308  unsigned int getMisses() { return miss; }
309  unsigned int getSize() { return size; }
310  private:
311  unsigned int size;
313 
314  unsigned int tail, buffersize;
315  unsigned int hit, miss;
316 
317  bool inCache(unsigned int index);
318  };
321 }
322 
323 #include "OgreHeaderSuffix.h"
324 
325 #endif
326 

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Wed Oct 23 2013 06:57:26