VR-Forces 5.0.3 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtIndirectGeometry.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 
20 
26 
28 
31 
32 #include <matrix/vlTaitBryan.h>
33 
34 #include <osg/Drawable>
35 #include <osg/Uniform>
36 #include <osg/StateSet>
37 #include <osg/OperationThread>
38 #include <osgSim/MultiSwitch>
39 
40 #include <tbb/concurrent_queue.h>
41 
42 #include <atomic>
43 #include <string>
44 #include <unordered_map>
45 #include <unordered_set>
46 #include <tuple>
47 
48 namespace osg
49 {
50  class NodeVisitor;
51  class State;
52 }
53 
54 namespace osgEarth {
55  class VirtualProgram;
56 };
57 
58 namespace makVrv
59 {
60  class DtIndirectGeometryRegistrar;
61  class DtCullShaderConfig;
62  class DtGpuCulling;
63  class DtGlBuffer;
64  class DtOsgCullVisitorParameters;
65 
66  class DtIndirectGeometryInitMainThreadJob;
67  class DtIndirectGeometryUpdateBuffersMainThreadJob;
68  class DtVirtualProgramCache;
69 
70  class DtIndirectDrawComponent;
71  class DtIndirectDefaultDrawComponent;
72  class DtIndirectLightPointDrawComponent;
73  class DtIndirectDebugCullComponent;
74 
75  class DtIndirectSwitchManager;
76  class DtIndirectDofManager;
77  class DtIndirectLodManager;
78  class DtIndirectUvOffsetManager;
79  class DtIndirectPerInstanceDataManager;
80  class DtIndirectShaderConstants;
81  class DtOsgLightPointManager;
82 
83  class DtIndirectVaoManager;
84 
85  class DtCoordinateSystem;
86 
89 
92 
94  template <>
95  inline const char* creatorTypeName<DtIndirectGeometry>(void) { return "DtIndirectGeometryCreator"; }
96 
115  class DT_DLL_VRVOSG DtIndirectGeometry : public osg::Drawable
116  {
117  public:
119 
120  protected:
124  DtIndirectGeometry(DtDe& de, const DtCullShaderConfig& cullShaderConfig, bool terrainPatch, bool managesIndividualInstances);
125 
127  virtual ~DtIndirectGeometry();
128 
129  private:
131  DtIndirectGeometry() = delete;
132 
134  DtIndirectGeometry(const DtIndirectGeometry& other) = delete;
136  DtIndirectGeometry& operator=(const DtIndirectGeometry& other) = delete;
137 
138  public:
139 
141  virtual void setName(const std::string& name) override;
142 
150  virtual void setRegistrar(DtIndirectGeometryRegistrar* registrar);
151 
153  virtual DtIndirectGeometryRegistrar* registrar();
154 
156  virtual const char* className() const;
157 
161  virtual void drawImplementation(osg::RenderInfo& renderInfo) const;
162 
164  virtual unsigned int rebuildRegistrar(osg::RenderInfo& renderInfo) const;
165 
171  virtual int addInstance(const DtIndirectGeometryInstance& instance);
172 
178  virtual int addInstance(int modelId, const osg::Matrixd& xForm, float modelScale, float modelRadius, int lightPointGroupId);
179 
183  virtual void accept(osg::NodeVisitor& nv);
184 
186  virtual void setParent(const osg::Group* parent);
187 
193  virtual void setRegistrarInvalid(void);
194 
196  virtual void releaseGLObjects(osg::State* state) const;
197 
199  virtual void accept(osg::PrimitiveFunctor& functor) const;
200 
204  virtual void setupIndirect();
205 
208  virtual void setupIndirectShadersOnly();
209 
212  virtual const osg::Geode* parentGeode(void) const;
213  virtual osg::Geode* parentGeode(void);
215 
219  virtual void setLocalOriginTransform(const osg::Matrixd& localOriginTransform);
220 
224  virtual const osg::Matrixd& localOriginTransform() const;
225 
227  virtual bool actuallyAddQueuedUpInstances(void);
228 
230  virtual void launchMainThreadJobAndWait(DtDe& de, DtOsgRenderer& renderer);
231 
233  virtual boost::condition_variable& waitCondition();
234 
236  virtual void updateGpuBuffers(osg::RenderInfo& renderInfo);
237 
238 
240  virtual void setFadeParameters(const DtIndirectFadeParameters& fadeParameters);
241 
243  virtual const DtIndirectFadeParameters& fadeParameters(void) const;
244 
246  virtual void perCameraUpdateAndCull(osg::RenderInfo& renderInfo, const osg::Camera* camera, const osg::Matrix& modelViewMatrix, const osg::FrameStamp* frameStamp);
247 
249  virtual void fillViewParameters(DtIndirectViewParameters& destViewParameters, const osg::Matrix& modelViewMatrix, const osg::Camera* camera, osg::RenderInfo& renderInfo) const;
250 
254  virtual void fillAltitude3d(DtIndirectViewParameters& destViewParameters, const Vector3_64& eye) const;
255 
257  virtual void setUpdateBuffersJobsRequiredCurrentFrame(bool requiredCurrentFrame);
264  virtual bool updateBuffersJobsRequiredCurrentFrame(void) const;
266 
268  virtual bool readyToRender(const int instanceIdInIndirect) const;
269 
270 
274  virtual bool instanceEverAdded(void) const;
275 
278  virtual int numValidInstances(void) const;
279 
280  public:
282  static void setTrackObjects(bool val);
284  static bool trackObjects(void);
286 
288  static int numIndirectGeometries(void);
289 
301  static void initializeDtDeKeyedInstances(DtDe& de);
302  protected:
303 
306  virtual bool addInstanceActual(const DtIndirectGeometryInstance& instance);
307 
311  virtual void setupShadersIfNecessary();
312 
315  virtual void setupDebugUniforms();
316 
319  virtual void installDefaultMaterial(osg::StateSet* ss);
320 
322  virtual void slot_reloadShaders();
323 
327  virtual void updateIndicesCount(const DtIndirectModelInfo& modelInfo, int instanceContainerIndex);
328 
330  virtual void updateModelIdsToInstances(int modelId, int instanceId, bool add);
331 
333  virtual void drawFromCommandBuffer(osg::RenderInfo& renderInfo, const DtIndirectViewParameters& viewParameters, const osg::Camera* camera) const;
334 
338 
340  virtual void updateInstancePositionOrientationAddedActual(const DtIndirectGeometryInstance& instance, int outInstanceIndex);
341 
343  virtual void updateInstanceSwitchesAddedActual(const DtIndirectGeometryInstance& instance, int outInstanceIndex);
344 
346  virtual void updateInstanceSequencesAddedActual(const DtIndirectGeometryInstance& instance, int outInstanceIndex);
347 
349  virtual void updateInstanceUvOffsetsAddedActual(const DtIndirectGeometryInstance& instance, int outInstanceIndex);
350 
352  virtual void updateInstanceColorAddedActual(const DtIndirectGeometryInstance& instance, int outInstanceIndex);
353 
355  virtual void updateInstanceOtherData0AddedActual(const DtIndirectGeometryInstance& instance, int outInstanceIndex);
356 
358  virtual void updateInstanceVisibilityLightPointMaxDistanceActual(const DtIndirectGeometryInstance& instance, int outInstanceIndex);
359 
361  virtual bool updateInstanceDeletionBeforeAddedActual(const DtIndirectGeometryInstance& instance);
362 
364  virtual void updateInstancesDofsAddedActual(const DtIndirectGeometryInstance& instance, int outInstanceIndex);
365 
368  virtual void reloadShadersIfNecessary(void) const;
369 
373  virtual void update(const osg::FrameStamp* frameStamp);
374 
376  virtual void adjustDofConstraintsIfNecessary(osgSim::DOFTransform* clone);
377 
379  virtual DtIndirectDrawComponent* drawComponent(int stateId) const;
380 
383  virtual bool hasLightPoints(void) const;
384 
386  virtual bool hasDepthOnly(void) const;
387 
389  virtual bool isDepthOnly(int stateId) const;
390 
391  // do debug drawing of bounding boxes of all geometries within each instance
392  virtual void debugDrawIfNecessary(osg::RenderInfo& renderInfo, const int maxCommands, const osg::Camera* camera);
393 
395  virtual void deleteDrawComponents(void);
396 
398  virtual void initDrawComponents(void);
399 
401  virtual const DtOsgCullVisitorParameters* findCullVisitorParameters(osg::RenderInfo& renderInfo) const;
402 
406  virtual void setPureSignalBasedUpdates(bool val);
407 
409  virtual void initializeUbosIfNecessary(osg::RenderInfo& renderInfo) const;
410 
412  virtual void slot_coordinateSystemChanged();
413 
414 
415  protected:
418 
420  tbb::concurrent_queue<DtIndirectGeometryInstance> myQueueInstancesToAdd;
421 
423 
425 
427 
428  const bool myIsTerrainPatch;
429 
431 
437  unsigned int myNumTextCoordArrays;
438 
440 
442 
447 
451 
454 
456  int myId;
457 
460 
466 
468  mutable unsigned int myMutableLastFrameTexturesUpdated;
469 
470  mutable bool myMutableShadersSetup;
471 
474 
477  typedef std::unordered_map<int, int> MapIndirectIdToInstanceContainerId;
479 
480  unsigned int myLastFrameUpdated;
481  const osg::Camera* myLastCamera;
482 
483  boost::condition_variable myWaitCondition;
484  boost::mutex myWaitMutex;
485 
488 
489  boost::mutex myInternalsMutex;
490 
494 
496 
497  // PPP: Is this large enough?
498  std::atomic<int> myRunningInstanceId;
499 
503 
504  // state set (bin) for the default components
506 
507  // state set (bin) for the light point components
509 
510  // state set (bin) for depth only components
512 
515 
517 
522 
523  DtGlBuffer* myGpuShaderUbo = nullptr;
524  mutable int myGpuShaderUboBinding = -1;
525  DtIndirectShaderConstants* myShaderConstants = nullptr;
526 
528 
530 
533  DtCoordinateSystem* myCoordinateSystem = nullptr;
534 
535 
536  protected:
537  static bool theTrackObjects;
538 
541  {
542  public:
544  TotalCounter();
546  virtual ~TotalCounter();
547  public:
548  std::atomic<int> myCount;
549  };
551  };
552 }
unsigned int myNumTextCoordArrays
Definition: DtIndirectGeometry.h:437
boost::condition_variable myWaitCondition
Definition: DtIndirectGeometry.h:483
Contains the DtCullShaderConfig class declaration.
MapIntToInt myInstancesToModelIds
Definition: DtIndirectGeometry.h:426
DtIndirectFadeParameters myFadeParameters
Definition: DtIndirectGeometry.h:495
The DtOsgRenderer is the component responsible for rendering 3D images onto the screen via OpenSceneG...
Definition: DtOsgRenderer.h:87
non virtual container class for holding the information needed to create an indirect geometry instanc...
Definition: DtIndirectGeometryInstance.h:26
int myId
a unique id for the geometry
Definition: DtIndirectGeometry.h:456
osg::ref_ptr< osg::StateSet > myDepthOnlyDrawStateSet
Definition: DtIndirectGeometry.h:511
structure to count total number of DtIndirectGeometrys in the system
Definition: DtIndirectGeometry.h:540
static TotalCounter theTotalCounter
Definition: DtIndirectGeometry.h:550
std::unordered_map< int, int > MapIndirectIdToInstanceContainerId
Map of instances&#39; id in indirect geometry to their id in the instance container.
Definition: DtIndirectGeometry.h:477
DtIndirectPerInstanceDataManager * myPerInstanceDataManager
Definition: DtIndirectGeometry.h:465
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
handles the switches for all the indirect geometry. Sets up the default state of osg::Switch, osgSim::MultiSwitch, and DtDynamicTerrainSwitchNode. Connects to a signal for the DtDynamicTerrainSwitchNode so it can update the indirect buffer when a switch changes. saves off the node path hash for every switch path that is added. Owned by a DtIndirectGeometry 1:1 This manager&#39;s switches get updated per frame via looking at the actual switches/multi-switches
Definition: DtIndirectSwitchManager.h:72
Definition: DtIndirectDebugCullComponent.h:45
DtIndirectLodManager * myLodManager
Definition: DtIndirectGeometry.h:463
This class is a component of the DtIndirectGeometry It inputs are: -&gt; the instances registered with Dt...
Definition: DtGpuCulling.h:82
bool myLastMissingTextureColorOn
Definition: DtIndirectGeometry.h:450
unsigned int myMutableLastRegistrarRebuildNumber
Definition: DtIndirectGeometry.h:467
Indirect geometry can have multiple models and their corresponding ids registered in it...
Definition: DtIndirectGeometryRegistrar.h:106
DtIndirectLightPointDrawComponent * myLightPointDrawComponent
Definition: DtIndirectGeometry.h:501
std::atomic< int > myRunningInstanceId
Definition: DtIndirectGeometry.h:498
osg::Matrixd myLocalOriginTransformMatrix
Definition: DtIndirectGeometry.h:441
DtOsgLightPointManager & myLightPointManager
Definition: DtIndirectGeometry.h:527
Contains makVrv::DtIndirectModelScalingAlgorithm enumeration.
Contains the DtIndirectGeometryUpdateBuffersMainThreadJob class declaration.
bool myUpdateBuffersJobsRequiredCurrentFrame
whether gpu buffers for instances are updated immediately
Definition: DtIndirectGeometry.h:514
std::atomic< int > myCount
Definition: DtIndirectGeometry.h:548
shader configuration storage class. Has 3 available options which are described in the constructor&#39;s ...
Definition: DtCullShaderConfig.h:21
DtOsgLightPointManager registers LightPoint nodes so their TBO can be created and updated in a single...
Definition: DtOsgLightPointManager.h:106
Contains the DtIndirectGeometryUpdateMainThreadJob class declaration.
std::map< int, int > MapIntToInt
Definition: DtCommonTypes.h:25
osg::ref_ptr< DtIndirectGeometryUpdateBuffersMainThreadJob > myMainThreadUpdateBuffersJob
Definition: DtIndirectGeometry.h:492
handles the lods for all the indirect geometry. sets up and runs a compute shader prepass for process...
Definition: DtIndirectLodManager.h:53
osg::ref_ptr< DtIndirectGeometryRegistrar > myRegistrar
pointer to the (external) registrar
Definition: DtIndirectGeometry.h:417
3 dimensional vector
unsigned int myLastFrameUpdateTraversed
Definition: DtIndirectGeometry.h:516
DtSignalConnectionManager myConnections
Definition: DtIndirectGeometry.h:439
osg::ref_ptr< osg::StateSet > myLightPointDrawStateSet
Definition: DtIndirectGeometry.h:508
DtDe & myDe
Definition: DtIndirectGeometry.h:529
osg::ref_ptr< DtIndirectGeometryInitMainThreadJob > myMainThreadInitJob
Definition: DtIndirectGeometry.h:491
bool myMutableOutputInstancesBuffersChanged
Internal variable that tracks whether the output instance buffers via the culling got changed (resize...
Definition: DtIndirectGeometry.h:521
const char * creatorTypeName< DtIndirectGeometry >(void)
template specialization for the creator (pass the class being created to the creatorTypeName template...
Definition: DtIndirectGeometry.h:95
Variadic templated creator class for defining a DtVirtualBaseClass creator that is automatically regi...
Definition: DtVirtualBaseClassCreator.h:22
DtIndirectGeometryInstance, which holds information for creating an indirect geometry instance...
DtGpuCulling * myGpuCulling
Definition: DtIndirectGeometry.h:422
static bool theTrackObjects
Definition: DtIndirectGeometry.h:537
friend DtIndirectGeometryCreator
Definition: DtIndirectGeometry.h:118
DtIndirectDebugCullComponent * myIndirectDebugCullComponent
Definition: DtIndirectGeometry.h:502
\ ::, which allows us to hook into our indirect engine to render using indirect rendering...
Definition: DtIndirectGeometry.h:115
MapIntToInt myModelIDsToInstances
Definition: DtIndirectGeometry.h:424
const osg::Camera * myLastCamera
Definition: DtIndirectGeometry.h:481
Contains the DtIndirectGeometryInitMainThreadJob class declaration.
unsigned int myLastFrameUpdated
Definition: DtIndirectGeometry.h:480
MapIndirectIdToInstanceContainerId myMapIndirectIdToInstanceContainerId
Definition: DtIndirectGeometry.h:478
handles the dof nodes for all the indirect geometry. Sets up the default state of osg::Dof...
Definition: DtIndirectDofManager.h:64
DtIndirectVaoManager & myVaoManager
This is de-referenced here for speed.
Definition: DtIndirectGeometry.h:453
Class to manage disconnection of boost connections on deletion.
Definition: DtSignalConnectionManager.h:20
The osg cull vistor parameters class provides additional culling and intersector parameters for choos...
Definition: DtOsgCullVisitorParameters.h:42
bool myLastDebugIndirectColorOn
Definition: DtIndirectGeometry.h:448
&#39;super&#39; class for managing the per gc vao for all indirect geometries There is only one vao per gl co...
Definition: DtIndirectVaoManager.h:35
boost::mutex myInternalsMutex
Definition: DtIndirectGeometry.h:489
const bool myManagesIndividualInstances
Definition: DtIndirectGeometry.h:430
struct for holding the fade parameters used by the indirect rendering cull compute shader ...
Definition: DtIndirectFadeParameters.h:17
std::map< int, int > myInstanceContainerIdToNumIndices
Definition: DtIndirectGeometry.h:446
int myNumIndicesAcrossAllModels
number of indices across all unique models across instances
Definition: DtIndirectGeometry.h:445
The DtCoordinateSystem is used to manage the current coordinate system of the scene.
Definition: DtCoordinateSystem.h:40
responsible for initializing the indirect buffers in the main thread
Definition: DtIndirectGeometryInitMainThreadJob.h:42
bool myLastColorizePerDrawableEnabled
Definition: DtIndirectGeometry.h:449
DtIndirectSwitchManager * mySwitchManager
Definition: DtIndirectGeometry.h:461
A generic OpenGL buffer. This can be: -&gt; a vertex buffer -&gt; an index buffer -&gt; a shader storage buffe...
Definition: DtGlBuffer.h:29
tbb::concurrent_queue< DtIndirectGeometryInstance > myQueueInstancesToAdd
addInstance may be called from multiple threads. Hence, concurrent queue
Definition: DtIndirectGeometry.h:420
Contains makVrv::DtIndirectAnnotationAndUvOffset class.
DtIndirectUvOffsetManager * myUvOffsetManager
Definition: DtIndirectGeometry.h:464
bool myMutableShadersSetup
Definition: DtIndirectGeometry.h:470
The class that is used to communicate the camera viewing parameters to the DtICullingAndLOD interface...
Definition: DtIndirectViewParameters.h:26
osg::ref_ptr< DtIndirectGeometryUpdateMainThreadJob > myMainThreadUpdateJob
Definition: DtIndirectGeometry.h:493
Base class to provide boost signal/slot management.
DtVirtualBaseClassCreator< DtIndirectGeometry, const DtCullShaderConfig &, const bool &, const bool & > DtIndirectGeometryCreator
creator
Definition: DtIndirectGeometry.h:88
handles the uv offsets for all the indirect geometry. Sets up the default state of the uv offset...
Definition: DtIndirectUvOffsetManager.h:49
unsigned int myMutableLastFrameTexturesUpdated
Definition: DtIndirectGeometry.h:468
DtInstanceContainer myInstanceContainer
container for all the instances registered here
Definition: DtIndirectGeometry.h:459
handles data that is specified per instance. Currently only the blend color from the DtOsgArticulated...
Definition: DtIndirectPerInstanceDataManager.h:59
osg::ref_ptr< osg::StateSet > myDefaultDrawStateSet
Definition: DtIndirectGeometry.h:505
Contains DLL export macros.
bool myMutableShouldReloadShaders
FIXME should be a static but currently the cull shader is per indirect.
Definition: DtIndirectGeometry.h:473
DtIndirectEffectTexturesTemplate myEffectTexturesState
the accumulated effect textures&#39; state which represents the superset of all effect textures cumulativ...
Definition: DtIndirectGeometry.h:436
Interface class to manage/configure drawing of a subset of rendering components within an indirect ge...
Definition: DtIndirectDrawComponent.h:32
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
class to draw a subset of items of an indirect geometry (everything except light points), the default way
Definition: DtIndirectDefaultDrawComponent.h:36
Helper class to manage instances This class allows you to add a DtInstance_64 Internally, however it stores this as a DtInstance (which the GPU can directly read)
Definition: DtInstanceContainer.h:31
boost::mutex myWaitMutex
Definition: DtIndirectGeometry.h:484
Definition: DtIndirectShaderConstants.h:42
const bool myIsTerrainPatch
Definition: DtIndirectGeometry.h:428
Contains the DtIndirectGeometryRegistrar class declaration.
Contains makVrv::DtIndirectViewParameters class.
Contains makVrv::DtInstanceContainer.
Class that allows you to abstractly register effect texture types the effect texture types are client...
Definition: DtIndirectEffectTexturesTemplate.h:40
DtIndirectDefaultDrawComponent * myDefaultDrawComponent
Definition: DtIndirectGeometry.h:500
Contains the per Model info which the indirect module needs It is owned by the Indirect geometry regi...
Definition: DtIndirectModelInfo.h:44
DtIndirectDofManager * myDofManager
Definition: DtIndirectGeometry.h:462
Contains makVrv::DtIndirectFadeParameters class.
class to draw a subset of light points of an indirect geometry
Definition: DtIndirectLightPointDrawComponent.h:49

Document ID: Generated on Thu Jun 1 17:58:13 EDT 2023 from SVN revision 255404
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)