VR-Forces 5.0.1 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtOsgShapeCache.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2010 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 #include <vrvOsg/vrvOsg.h>
13 #include <osg/ref_ptr>
14 #include <osg/PrimitiveSet>
15 #include <boost/unordered_map.hpp>
16 #include <functional>
17 
18 namespace osg
19 {
20  class Drawable;
21 }
22 
23 namespace makVrv
24 {
25 
30  {
31  public:
32 
34  static DtOsgShapeCache& instance(DtDe& de);
35 
38 
40  virtual ~DtOsgShapeCache();
41 
42  enum ShapeType
43  {
46  };
47 
49  void releaseResources();
50 
52  void ts_clearInstancingCache();
53 
55  osg::Drawable* getShapeInstance(ShapeType,unsigned int faceCount);
56 
61  osg::DrawElementsUInt* getCircularIndexBuffer(unsigned int vertexCount,
62  unsigned int firstIndex, unsigned int indexStep);
63 
64  protected:
65 
67  virtual osg::Drawable* createShapeInstance(ShapeType,unsigned int faceCount);
68 
69  struct ShapeKey
70  {
72  unsigned int faceCount;
73 
74  bool operator == (const ShapeKey& other) const
75  {
76  return type == other.type && faceCount == other.faceCount;
77  }
78  };
79 
80  struct ShapeKey_hash : std::unary_function<ShapeKey, std::size_t>
81  {
82  std::size_t operator()(ShapeKey const& p) const
83  {
84  std::size_t seed = 0;
85  boost::hash_combine(seed, p.type);
86  boost::hash_combine(seed, p.faceCount);
87  return seed;
88  }
89  };
90 
91  //Use map rather than unordered_map due to hash difficulties.
92  typedef boost::unordered_map<ShapeKey, osg::ref_ptr<osg::Drawable>,
95 
96 
98  {
99  unsigned int count;
100  unsigned int initial;
101  unsigned int step;
102 
103  bool operator == (const IndexBufferKey& other) const
104  {
105  return count == other.count && initial == other.initial &&
106  step == other.step;
107  }
108  };
109 
110 
111  struct IndexBufferKey_hash : std::unary_function<IndexBufferKey, std::size_t>
112  {
113  std::size_t operator()(IndexBufferKey const& p) const
114  {
115  std::size_t seed = 0;
116  boost::hash_combine(seed, p.count);
117  boost::hash_combine(seed, p.initial);
118  boost::hash_combine(seed, p.step);
119  return seed;
120  }
121  };
122 
123  typedef boost::unordered_map<IndexBufferKey, osg::ref_ptr<osg::DrawElementsUInt>,
126 
127  };
128 }
129 
std::size_t operator()(IndexBufferKey const &p) const
Definition: DtOsgShapeCache.h:113
unsigned int step
Definition: DtOsgShapeCache.h:101
Definition: DtOsgShapeCache.h:97
Virtual base class. Allows for RTTI and proper virtual destruction. Used by Creators, Factories, Providers, Assemblers and User Interfaces.
Definition: DtVirtualBaseClass.h:19
ShapeType type
Definition: DtOsgShapeCache.h:71
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
unsigned int initial
Definition: DtOsgShapeCache.h:100
std::size_t operator()(ShapeKey const &p) const
Definition: DtOsgShapeCache.h:82
Definition: DtOsgShapeCache.h:111
boost::unordered_map< IndexBufferKey, osg::ref_ptr< osg::DrawElementsUInt >, IndexBufferKey_hash > IndexBufferMap
Definition: DtOsgShapeCache.h:124
Definition: DtOsgShapeCache.h:80
Contains makVrv::DtVirtualBaseClass class.
Definition: DtOsgShapeCache.h:69
unsigned int faceCount
Definition: DtOsgShapeCache.h:72
boost::unordered_map< ShapeKey, osg::ref_ptr< osg::Drawable >, ShapeKey_hash > ShapeMap
Definition: DtOsgShapeCache.h:93
ShapeMap myShapeMap
Definition: DtOsgShapeCache.h:94
A cache responsible for storing osg shape geodes. Each shape is a unit size (1x1x1).
Definition: DtOsgShapeCache.h:29
unsigned int count
Definition: DtOsgShapeCache.h:99
bool operator==(const DtTextureAtlasIndexParser::StringOrFloatAttrib &lhs, const DtTextureAtlasIndexParser::StringOrFloatAttrib &rhs)
needed for search comparison code
Definition: DtTextureAtlasIndexParser.h:153
Definition: DtOsgShapeCache.h:44
Contains DLL export macros.
IndexBufferMap myIndexBufferMap
Definition: DtOsgShapeCache.h:125
The DtDe is the core component of any VR-Vantage application. It owns a DtRenderer, DtDeCommunicator, as well as a DtDisplay and other things.
Definition: DtDe.h:70
ShapeType
Definition: DtOsgShapeCache.h:42
Definition: DtOsgShapeCache.h:45

Document ID: Generated on Mon Jun 20 00:38:30 EDT 2022 from SVN revision 244029
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)