OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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-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 __VertexIndexData_H__
29 #define __VertexIndexData_H__
30 
31 #include "OgrePrerequisites.h"
34 #include "OgreId.h"
35 #include "OgreHeaderPrefix.h"
36 
37 namespace Ogre {
45  typedef vector<HardwareBuffer::Usage>::type BufferUsageList;
47 
48 
51  {
52  private:
54  VertexData(const VertexData& rhs); /* do nothing, should not use */
56  VertexData& operator=(const VertexData& rhs); /* do not use */
57 
59  public:
76  ~VertexData();
77 
89  size_t vertexStart;
91  size_t vertexCount;
92 
93 
96  {
97  unsigned short targetBufferIndex;
99  };
105 
111  VertexData* clone(bool copyData = true, HardwareBufferManagerBase* mgr = 0) const;
112 
132  void prepareForShadowVolume(void);
133 
148 
149 
168  void reorganiseBuffers(VertexDeclaration* newDeclaration, const BufferUsageList& bufferUsage,
169  HardwareBufferManagerBase* mgr = 0);
170 
188  void reorganiseBuffers(VertexDeclaration* newDeclaration, HardwareBufferManagerBase* mgr = 0);
189 
199  void closeGapsInBindings(void);
200 
209  void removeUnusedBuffers(void);
210 
218  void convertPackedColour(VertexElementType srcType, VertexElementType destType);
219 
220 
236  ushort allocateHardwareAnimationElements(ushort count, bool animateNormals);
237 
238 
239 
240  };
241 
244  {
245  protected:
247  IndexData(const IndexData& rhs); /* do nothing, should not use */
249  IndexData& operator=(const IndexData& rhs); /* do not use */
250  public:
251  IndexData();
252  ~IndexData();
255 
257  size_t indexStart;
258 
260  size_t indexCount;
261 
267  IndexData* clone(bool copyData = true, HardwareBufferManagerBase* mgr = 0) const;
268 
277  void optimiseVertexCacheTriList(void);
278 
279  };
280 
287  {
288  public:
289  enum CacheType {
290  FIFO, LRU
291  };
292 
293  VertexCacheProfiler(unsigned int cachesize = 16, CacheType cachetype = FIFO )
294  : size ( cachesize ), tail (0), buffersize (0), hit (0), miss (0)
295  {
296  cache = OGRE_ALLOC_T(uint32, size, MEMCATEGORY_GEOMETRY);
297  }
298 
300  {
302  }
303 
304  void profile(const HardwareIndexBufferSharedPtr& indexBuffer);
305  void reset() { hit = 0; miss = 0; tail = 0; buffersize = 0; }
306  void flush() { tail = 0; buffersize = 0; }
307 
308  unsigned int getHits() { return hit; }
309  unsigned int getMisses() { return miss; }
310  unsigned int getSize() { return size; }
311  private:
312  unsigned int size;
314 
315  unsigned int tail, buffersize;
316  unsigned int hit, miss;
317 
318  bool inCache(unsigned int index);
319  };
322 }
323 
324 #include "OgreHeaderSuffix.h"
325 
326 #endif
327 
vector< HardwareAnimationData >::type HardwareAnimationDataList
#define OGRE_ALLOC_T(T, count, category)
Allocate a block of memory for a primitive type, and indicate the category of usage.
float Real
Software floating point type.
unsigned int uint32
Definition: OgrePlatform.h:420
#define _OgreExport
Definition: OgrePlatform.h:255
Records the state of all the vertex buffer bindings required to provide a vertex declaration with the...
HardwareIndexBufferSharedPtr indexBuffer
Pointer to the HardwareIndexBuffer to use, must be specified if useIndexes = true.
HardwareAnimationDataList hwAnimationDataList
VertexElements used for hardware morph / pose animation.
size_t hwAnimDataItemsUsed
Number of hardware animation data items used.
Struct used to hold hardware morph / pose vertex data information.
Vertex cache profiler.
size_t indexStart
Index in the buffer to start from for this operation.
Shared pointer implementation used to share vertex buffers.
size_t vertexCount
The number of vertices used in this operation.
VertexCacheProfiler(unsigned int cachesize=16, CacheType cachetype=FIFO)
Shared pointer implementation used to share index buffers.
bool mDeleteDclBinding
Whether this class should delete the declaration and binding.
vector< HardwareBuffer::Usage >::type BufferUsageList
Define a list of usage flags.
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Summary class collecting together index data source information.
Base definition of a hardware buffer manager.
VertexElementType
Vertex element type, used to identify the base types of the vertex contents.
HardwareVertexBufferSharedPtr hardwareShadowVolWBuffer
Additional shadow volume vertex buffer storage.
unsigned short ushort
Summary class collecting together vertex source information.
This class declares the format of a set of vertex inputs, which can be issued to the rendering API th...
size_t indexCount
The number of indexes to use from the buffer.
Geometry held in main memory.
#define OGRE_FREE(ptr, category)
Free the memory allocated with OGRE_MALLOC or OGRE_ALLOC_T. Category is required to be restated to en...
HardwareBufferManagerBase * mMgr
size_t vertexStart
The base vertex index to start from.
VertexDeclaration * vertexDeclaration
Declaration of the vertex to be used in this operation.
VertexBufferBinding * vertexBufferBinding
The vertex buffer bindings to be used.