VR-Forces 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) 2023 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 <unordered_map>
16 #include <functional>
17 #include <boost/functional/hash.hpp>
18 
19 namespace osg
20 {
21  class Drawable;
22 }
23 
24 namespace makVrv
25 {
26 
31  {
32  public:
33 
35  static DtOsgShapeCache& instance(DtDe& de);
36 
39 
41  virtual ~DtOsgShapeCache();
42 
43  enum ShapeType
44  {
47  };
48 
50  void releaseResources();
51 
53  void ts_clearInstancingCache();
54 
56  osg::Drawable* getShapeInstance(ShapeType,unsigned int faceCount);
57 
62  osg::DrawElementsUInt* getCircularIndexBuffer(unsigned int vertexCount,
63  unsigned int firstIndex, unsigned int indexStep);
64 
65  protected:
66 
68  virtual osg::Drawable* createShapeInstance(ShapeType,unsigned int faceCount);
69 
70  struct ShapeKey
71  {
73  unsigned int faceCount;
74 
75  bool operator == (const ShapeKey& other) const
76  {
77  return type == other.type && faceCount == other.faceCount;
78  }
79  };
80 
81  struct ShapeKey_hash : std::unary_function<ShapeKey, std::size_t>
82  {
83  std::size_t operator()(ShapeKey const& p) const
84  {
85  std::size_t seed = 0;
86  boost::hash_combine(seed, p.type);
87  boost::hash_combine(seed, p.faceCount);
88  return seed;
89  }
90  };
91 
92  //Use map rather than unordered_map due to hash difficulties.
93  typedef std::unordered_map<ShapeKey, osg::ref_ptr<osg::Drawable>,
96 
97 
99  {
100  unsigned int count;
101  unsigned int initial;
102  unsigned int step;
103 
104  bool operator == (const IndexBufferKey& other) const
105  {
106  return count == other.count && initial == other.initial &&
107  step == other.step;
108  }
109  };
110 
111 
112  struct IndexBufferKey_hash : std::unary_function<IndexBufferKey, std::size_t>
113  {
114  std::size_t operator()(IndexBufferKey const& p) const
115  {
116  std::size_t seed = 0;
117  boost::hash_combine(seed, p.count);
118  boost::hash_combine(seed, p.initial);
119  boost::hash_combine(seed, p.step);
120  return seed;
121  }
122  };
123 
124  typedef std::unordered_map<IndexBufferKey, osg::ref_ptr<osg::DrawElementsUInt>,
127 
128  };
129 }
130 
std::size_t operator()(IndexBufferKey const &p) const
Definition: DtOsgShapeCache.h:114
unsigned int step
Definition: DtOsgShapeCache.h:102
Definition: DtOsgShapeCache.h:98
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:72
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
unsigned int initial
Definition: DtOsgShapeCache.h:101
std::size_t operator()(ShapeKey const &p) const
Definition: DtOsgShapeCache.h:83
Definition: DtOsgShapeCache.h:112
Definition: DtOsgShapeCache.h:81
Contains makVrv::DtVirtualBaseClass class.
std::unordered_map< IndexBufferKey, osg::ref_ptr< osg::DrawElementsUInt >, IndexBufferKey_hash > IndexBufferMap
Definition: DtOsgShapeCache.h:125
Definition: DtOsgShapeCache.h:70
unsigned int faceCount
Definition: DtOsgShapeCache.h:73
ShapeMap myShapeMap
Definition: DtOsgShapeCache.h:95
A cache responsible for storing osg shape geodes. Each shape is a unit size (1x1x1).
Definition: DtOsgShapeCache.h:30
unsigned int count
Definition: DtOsgShapeCache.h:100
bool operator==(const DtTextureAtlasIndexParser::StringOrFloatAttrib &lhs, const DtTextureAtlasIndexParser::StringOrFloatAttrib &rhs)
needed for search comparison code
Definition: DtTextureAtlasIndexParser.h:160
Definition: DtOsgShapeCache.h:45
Contains DLL export macros.
IndexBufferMap myIndexBufferMap
Definition: DtOsgShapeCache.h:126
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:72
ShapeType
Definition: DtOsgShapeCache.h:43
Definition: DtOsgShapeCache.h:46
std::unordered_map< ShapeKey, osg::ref_ptr< osg::Drawable >, ShapeKey_hash > ShapeMap
Definition: DtOsgShapeCache.h:94

Document ID: Generated on Wed Mar 27 22:49:11 EDT 2024 from SVN revision 264633
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)