VR-Forces 5.0.1 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtIndirectGeometryRegistrar.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2022 VT-MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvOsg/vrvOsg.h>
13 
21 
23 
24 #include <vrvUtil/signalslib.h>
25 
26 #include <osg/Node>
27 #include <osg/Geometry>
28 #include <osg/Texture>
29 #include <osg/Referenced>
30 
31 #include <tbb/concurrent_queue.h>
32 #include <tbb/atomic.h>
33 #include <tbb/task.h>
34 
35 #include <string>
36 #include <vector>
37 #include <unordered_set>
38 
39 #define INDIRECTGEOMETRYREGISTRAR_DEBUG 0
40 
41 namespace osgUtil{
42  class CullVisitor;
43 };
44 
45 namespace osgEarth {
46  class VirtualProgram;
47 };
48 
49 namespace makVrv
50 {
51  class DtGlBuffer;
52 
53  class DtIndirectGeometryRegistrar;
54 
55  class DtIndirectTextureCollectionPolicy;
56  class DtIndirectModelInfoContainer;
57 
58  class DtOsgShaderManager;
59 
60  class DtIndirectModelInfo;
61 
64 
67 
69  template <>
70  inline const char* creatorTypeName<DtIndirectGeometryRegistrar>(void) { return "DtIndirectGeometryRegistrarCreator"; }
71 
81 
85 
94 
106  class DT_DLL_VRVOSG DtIndirectGeometryRegistrar : public osg::Referenced
107  {
108  protected:
111 
112  protected:
115  , const std::string& textureCollectionPolicyName
116  , const DtIndirectLimitTextureStrategy& limitTextureStrategy
117  , bool supportsPartialTextureUnloading
118  , bool supportsPartialBuffersUnloading
119  );
120 
122  virtual ~DtIndirectGeometryRegistrar();
123 
124  private:
126  DtIndirectGeometryRegistrar() = delete;
127 
130 
132  DtIndirectGeometryRegistrar(const DtIndirectGeometryRegistrar& lhs, const osg::CopyOp& copyop) = delete;
133 
135  DtIndirectGeometryRegistrar& operator=(const DtIndirectGeometryRegistrar& other) = delete;
136  public:
138  virtual void setName(const std::string& name);
139 
140  // ! Thread safe method - can be called in any paging thread or the main render thread
141  // ! This needs to be 'queued' up because the actual registration can happen when rebuild rebuildIfNeeded
142  // ! is called from somewhere in the main thread (e.g. via the drawImplementation of DtIndirectGeometry)
143  // \param modelId: The model id
144  // \param modelFileName is used only for debugging messages for the aggregator
145  virtual void queueUpRegisterModel(int modelId, osg::ref_ptr<const osg::Node> model
146  , const std::string& modelFileName, const std::string& modelDefName
147  , bool cullFaceEnabled = false, const DtIndirectPolygonOffset& polygonOffset = DtIndirectPolygonOffset(0.0f,0.0f), bool daylightControlled = false);
148 
151  virtual void processRegisterModelQueue(DtOsgRenderer* renderer);
152 
154  virtual bool beingProcessed();
155 
157  virtual unsigned int rebuildIfNeeded(const osg::GraphicsContext* gc);
158 
160  virtual unsigned int numModelsInQueue() const;
161 
163  virtual int numModels(void) const;
164 
166  virtual int modelId(int index) const;
167 
169  virtual int numGeometriesForModelID(int modelId) const;
170 
172  virtual bool isModelDownloaded(int modelId) const;
173 
176  virtual const DtIndirectModelInfo* findModelInfoForModelId(int modelId) const;
177 
179  virtual const DtIndirectModelInfoContainer* aggregatedGeometry() const;
180 
182  virtual DtIndirectModelInfoContainer* aggregatedGeometry();
183 
185  virtual const DtIndirectTextureCollectionPolicy& textureCollectionPolicy(void) const;
186 
188  virtual DtIndirectTextureProcessor& textureProcessor();
189 
192  virtual const DtIndirectEffectTexturesTemplate& effectTexturesState(void) const;
193 
195  virtual DtIndirectGeometryStateManager& stateManager(void) const;
196 
198  virtual GLenum indicesType(void) const;
199 
203  virtual void releaseGLObjects(osg::State* state) const;
204 
207  virtual bool registeredModelsDirty() const;
208 
210  virtual void drainModelQueue(DtOsgRenderer* renderer);
211 
213  virtual void setPagerHandlesModelLoading(bool value);
214  virtual bool pagerHandlesModelLoading();
215 
217  virtual int numTexCoordArrays(void) const;
218 
220  virtual boost::mutex& addingModelsMutex();
221 
223  virtual bool supportsPartialTextureUnloading(void) const;
224 
226  virtual bool supportsPartialBuffersUnloading(void) const;
227 
233  virtual void modelsToBeReloaded(const std::unordered_set<int>& models);
234 
242  virtual void unloadUnreferencedTextures(void);
243 
245  virtual void trackTexturesAndModels(const std::unordered_set<int>& models, bool reloading);
246 
248  virtual void findModelInfosThatUseThisImageFileForItsTextures(std::set<DtIndirectModelInfo*>& modelInfos, const std::string& absoluteFileName) const;
249  protected:
252  virtual void registerModel(int modelId
253  , osg::ref_ptr<const osg::Node> model, const std::string& modelFileName, const std::string& modelDefName
254  , bool daylightControlled, bool cullFaceEnabled = true, const DtIndirectPolygonOffset& polygonOffset = DtIndirectPolygonOffset(0.0f, 0.0f));
255 
256  protected:
257 
259 
261 
263 
265  {
266  public:
268  RegisterModelOp();
270  RegisterModelOp(const RegisterModelOp& rhs);
272  RegisterModelOp& operator=(const RegisterModelOp& rhs);
274  ~RegisterModelOp();
275  public:
278  // used only for debugging messages
279  std::string myModelFileName;
280  std::string myModelDefName;
284  };
285 
286  typedef tbb::concurrent_queue<RegisterModelOp> QueueRegisterModelOps;
288 
290 
292 
294  unsigned int myLastRebuildNumber;
295 
297  tbb::atomic<bool> myBeingProcessed;
298  boost::mutex myAddingModelsMutex;
299 
303 
306 
308 
310  std::map< osg::ref_ptr<osg::Texture>, std::set<int> > myTextureToModelsThatAreUsingIt;
311 
313  std::unordered_map< std::string, std::set<int> > myImagesToModelsThatAreUsingIt;
314 
317  };
318 
319 }
Definition: DtIndirectGeometryRegistrar.h:264
The DtOsgRenderer is the component responsible for rendering 3D images onto the screen via OpenSceneG...
Definition: DtOsgRenderer.h:87
DtIndirectPolygonOffset myPolygonOffset
Definition: DtIndirectGeometryRegistrar.h:282
QueueRegisterModelOps myQueueRegisterModelOps
Definition: DtIndirectGeometryRegistrar.h:287
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
Contains the DtIndirectTextureProcessor class declaration.
bool myDaylightControlled
Definition: DtIndirectGeometryRegistrar.h:283
Indirect geometry can have multiple models and their corresponding ids registered in it...
Definition: DtIndirectGeometryRegistrar.h:106
Class that loads and contains a bunch of models registered with the registrar. It is owned by the Ind...
Definition: DtIndirectModelInfoContainer.h:76
Abstract class to look in the stateset and collect textures specified via its template The effect tex...
Definition: DtIndirectTextureCollectionPolicy.h:38
std::string myModelFileName
Definition: DtIndirectGeometryRegistrar.h:279
std::unordered_map< std::string, std::set< int > > myImagesToModelsThatAreUsingIt
map of absolute image file names to models that use it
Definition: DtIndirectGeometryRegistrar.h:313
bool myCullFaceEnabled
Definition: DtIndirectGeometryRegistrar.h:281
Indirect rendering works because we are able to combine multiple geometries into a single &#39;aggregated...
Definition: DtIndirectGeometryAggregator.h:85
osg::ref_ptr< const osg::Node > myModel
Definition: DtIndirectGeometryRegistrar.h:277
std::string myModelDefName
Definition: DtIndirectGeometryRegistrar.h:280
Variadic templated creator class for defining a DtVirtualBaseClass creator that is automatically regi...
Definition: DtVirtualBaseClassCreator.h:22
Contains the DtIndirectEffectTexturesTemplate class declaration.
const bool mySupportsPartialTextureUnloading
Definition: DtIndirectGeometryRegistrar.h:315
std::map< osg::ref_ptr< osg::Texture >, std::set< int > > myTextureToModelsThatAreUsingIt
map of texture to the set of models that refer to the texture
Definition: DtIndirectGeometryRegistrar.h:310
DtIndirectEffectTexturesTemplate myEffectTexturesState
Definition: DtIndirectGeometryRegistrar.h:260
unsigned int myLastRebuildNumber
Definition: DtIndirectGeometryRegistrar.h:294
Simple state/glmodes class for handling setting up modes It can now handle generic state modes and at...
Definition: DtIndirectGeometryStateManager.h:31
osg::ref_ptr< DtIndirectTextureProcessor > myTextureProcessor
Definition: DtIndirectGeometryRegistrar.h:291
tbb::atomic< bool > myBeingProcessed
Definition: DtIndirectGeometryRegistrar.h:297
DtIndirectGeometryAggregator * myAggregator
Definition: DtIndirectGeometryRegistrar.h:296
Contains the DtIndirectGeometryStateManager class declaration.
DtDe & myDe
DtDe reference.
Definition: DtIndirectGeometryRegistrar.h:305
bool myPagerHandlesModelLoading
Definition: DtIndirectGeometryRegistrar.h:262
Definition: DtIndirectTextureProcessor.h:42
bool myRegisteredModelsDirty
Definition: DtIndirectGeometryRegistrar.h:293
This class is passed as a pointer to DtIndirectTextureProcessor. The processor then uses this in conj...
Definition: DtIndirectLimitTextureStrategy.h:65
boost::mutex myAddingModelsMutex
Definition: DtIndirectGeometryRegistrar.h:298
Contains makVrv::DtIndirectSwitchManager class.
DtOsgShaderManager injects custom shaders into the scenes, and keeps their uniform parameters set to ...
Definition: DtOsgShaderManager.h:41
unsigned int GLenum
Definition: DtGlTextureBufferObject.h:18
DtVirtualBaseClassCreator< DtIndirectGeometryRegistrar, const std::string &, const DtIndirectLimitTextureStrategy &, const bool &, const bool & > DtIndirectGeometryRegistrarCreator
creator
Definition: DtIndirectGeometryRegistrar.h:63
Contains makVrv::DtIndirectLodManager class.
DtIndirectGeometryStateManager myMutableStateContainer
mutable since it is needed to be used in drawImplementaion for the indirect geometry not private so i...
Definition: DtIndirectGeometryRegistrar.h:302
non virtual container class for defining a polygon offset state
Definition: DtIndirectPolygonOffset.h:18
Contains DLL export macros.
int myModelId
Definition: DtIndirectGeometryRegistrar.h:276
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
tbb::concurrent_queue< RegisterModelOp > QueueRegisterModelOps
Definition: DtIndirectGeometryRegistrar.h:286
Contains the DtIndirectGeometryAggregator class declaration.
DtIndirectTextureCollectionPolicy * myTextureCollectionPolicy
Definition: DtIndirectGeometryRegistrar.h:289
const bool mySupportsPartialBuffersUnloading
Definition: DtIndirectGeometryRegistrar.h:316
DtOsgShaderManager & myShaderManager
Definition: DtIndirectGeometryRegistrar.h:307
friend DtIndirectGeometryRegistrarCreator
friend class creator so that DtIndirectGeometryRegistrar can only be created by the creator ...
Definition: DtIndirectGeometryRegistrar.h:110
Class that allows you to abstractly register effect texture types the effect texture types are client...
Definition: DtIndirectEffectTexturesTemplate.h:40
DtIndirectModelInfoContainer * myModelInfoContainer
Definition: DtIndirectGeometryRegistrar.h:258
Contains the per Model info which the indirect module needs It is owned by the Indirect geometry regi...
Definition: DtIndirectModelInfo.h:44
const char * creatorTypeName< DtIndirectGeometryRegistrar >(void)
template specialization for the creator (pass the class being created to the creatorTypeName template...
Definition: DtIndirectGeometryRegistrar.h:70

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)