VR-Forces 4.8 Class Documentation
 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 /******************************************************************************
6 ** $RCSfile: $ $Revision: $ $State: $
7 ******************************************************************************/
8 
12 
13 #pragma once
14 #include <vrvOsg/vrvOsg.h>
16 #include <osg/ref_ptr>
17 #include <osg/PrimitiveSet>
18 #include <boost/unordered_map.hpp>
19 #include <functional>
20 
21 namespace osg
22 {
23  class Drawable;
24 }
25 
26 namespace makVrv
27 {
28 
33  {
34  public:
35 
37  static DtOsgShapeCache& instance(DtDe& de);
38 
41 
43  virtual ~DtOsgShapeCache();
44 
45  enum ShapeType
46  {
49  };
50 
52  void releaseResources();
53 
55  void ts_clearInstancingCache();
56 
58  osg::Drawable* getShapeInstance(ShapeType,unsigned int faceCount);
59 
64  osg::DrawElementsUInt* getCircularIndexBuffer(unsigned int vertexCount,
65  unsigned int firstIndex, unsigned int indexStep);
66 
67  protected:
68 
70  virtual osg::Drawable* createShapeInstance(ShapeType,unsigned int faceCount);
71 
72  struct ShapeKey
73  {
75  unsigned int faceCount;
76 
77  bool operator == (const ShapeKey& other) const
78  {
79  return type == other.type && faceCount == other.faceCount;
80  }
81  };
82 
83  struct ShapeKey_hash : std::unary_function<ShapeKey, std::size_t>
84  {
85  std::size_t operator()(ShapeKey const& p) const
86  {
87  std::size_t seed = 0;
88  boost::hash_combine(seed, p.type);
89  boost::hash_combine(seed, p.faceCount);
90  return seed;
91  }
92  };
93 
94  //Use map rather than unordered_map due to hash difficulties.
95  typedef boost::unordered_map<ShapeKey, osg::ref_ptr<osg::Drawable>,
98 
99 
101  {
102  unsigned int count;
103  unsigned int initial;
104  unsigned int step;
105 
106  bool operator == (const IndexBufferKey& other) const
107  {
108  return count == other.count && initial == other.initial &&
109  step == other.step;
110  }
111  };
112 
113 
114  struct IndexBufferKey_hash : std::unary_function<IndexBufferKey, std::size_t>
115  {
116  std::size_t operator()(IndexBufferKey const& p) const
117  {
118  std::size_t seed = 0;
119  boost::hash_combine(seed, p.count);
120  boost::hash_combine(seed, p.initial);
121  boost::hash_combine(seed, p.step);
122  return seed;
123  }
124  };
125 
126  typedef boost::unordered_map<IndexBufferKey, osg::ref_ptr<osg::DrawElementsUInt>,
129 
130  };
131 }
132 
std::size_t operator()(IndexBufferKey const &p) const
Definition: DtOsgShapeCache.h:116
unsigned int step
Definition: DtOsgShapeCache.h:104
Definition: DtOsgShapeCache.h:100
Virtual base class.
Definition: DtVirtualBaseClass.h:22
ShapeType type
Definition: DtOsgShapeCache.h:74
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
unsigned int initial
Definition: DtOsgShapeCache.h:103
std::size_t operator()(ShapeKey const &p) const
Definition: DtOsgShapeCache.h:85
Definition: DtOsgShapeCache.h:114
boost::unordered_map< IndexBufferKey, osg::ref_ptr< osg::DrawElementsUInt >, IndexBufferKey_hash > IndexBufferMap
Definition: DtOsgShapeCache.h:127
Definition: DtOsgShapeCache.h:83
Contains makVrv::DtVirtualBaseClass class.
Definition: DtOsgShapeCache.h:72
unsigned int faceCount
Definition: DtOsgShapeCache.h:75
boost::unordered_map< ShapeKey, osg::ref_ptr< osg::Drawable >, ShapeKey_hash > ShapeMap
Definition: DtOsgShapeCache.h:96
ShapeMap myShapeMap
Definition: DtOsgShapeCache.h:97
A cache responsible for storing osg shape geodes.
Definition: DtOsgShapeCache.h:32
unsigned int count
Definition: DtOsgShapeCache.h:102
bool operator==(const DtTextureAtlasIndexParser::StringOrFloatAttrib &lhs, const DtTextureAtlasIndexParser::StringOrFloatAttrib &rhs)
needed for search comparison code
Definition: DtTextureAtlasIndexParser.h:153
Definition: DtOsgShapeCache.h:47
Contains DLL export macros.
IndexBufferMap myIndexBufferMap
Definition: DtOsgShapeCache.h:128
The DtDe is the core component of any VR-Vantage application.
Definition: DtDe.h:69
ShapeType
Definition: DtOsgShapeCache.h:45
Definition: DtOsgShapeCache.h:48

Document ID: Generated on Thu Aug 27 10:56:05 EDT 2020 from SVN revision 217100
Copyright © 2005-2020 MAK Technologies. All Rights Reserved (www.mak.com)