VR-Forces 4.7 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(int vertexCount,
65  int firstIndex, 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 

Document ID: Generated on Fri Apr 26 21:53:14 EDT 2019 from SVN revision 197883
Copyright © 2005-2019 VT MAK. All Rights Reserved (www.mak.com)