VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtIndirectSwitchManager.h
Go to the documentation of this file.
1 /*****************************************************************************
2 * Copyright (c) 2025 MAK Technologies, Inc.
3 * All rights reserved.
4 *****************************************************************************/
5 
9 
10 #pragma once
11 
13 
14 #include <vrvOsg/vrvOsg.h>
18 
20 
22 
25 
26 #include <osgSim/MultiSwitch>
27 #include <osg/Node>
28 #include <osg/ref_ptr>
29 #include <osg/observer_ptr>
30 #include <osg/Switch>
31 
32 #include <list>
33 #include <deque>
34 
35 namespace osg
36 {
37  class Sequence;
38  class RenderInfo;
39  class FrameStamp;
40 }
41 
42 namespace osgSim
43 {
44  class MultiSwitch;
45 }
46 
47 namespace makVrv
48 {
49  struct PerGeomInstance;
50  class DtDynamicTerrainSwitchNode;
51  class DtSwitchInstanceState;
52  class DtDe;
53  class DtGlBuffer;
54 
57 
60 
62  template <>
63  inline const char* creatorTypeName<DtIndirectSwitchManager>(void) { return "DtIndirectSwitchManagerCreator"; }
64 
72  {
73  public:
74 
75  typedef osg::observer_ptr<osg::Node> NodeObserverPtr;
76  typedef std::pair<NodeObserverPtr, DtIndirectSwitchInfo> NodeSwitchInfoPair;
77  typedef std::deque<NodeSwitchInfoPair> DequeNodeSwitchInfoPairs;
78  typedef std::vector<DequeNodeSwitchInfoPairs> DequeNodeSwitchInfoPairsArray;
79 
80  typedef std::vector<DtIndirectSwitchInfo> VectorIndirectSwitchInfos;
81  typedef std::map<int, VectorIndirectSwitchInfos> MapIntToVectorIndirectSwitchInfos;
82  typedef std::map<NodeObserverPtr, MapIntToVectorIndirectSwitchInfos > MapNodeToMapIntToVectorIndirectSwitchInfos;
83 
84  public:
87 
89  virtual ~DtIndirectSwitchManager();
90  protected:
93 
94  private:
96  DtIndirectSwitchManager() = delete;
98  DtIndirectSwitchManager(const DtIndirectSwitchManager& other) = delete;
100  DtIndirectSwitchManager& operator=(const DtIndirectSwitchManager& other) = delete;
101 
102  public:
104  virtual void addSwitchPaths(std::vector<PerGeomInstance*>& perGeomInstances, int containerInstanceId,
105  const DequeNodeSwitchInfoPairs& parentSwitchPaths, const DequeNodeSwitchInfoPairsArray& switchPaths,
106  const osg::NodePath& parentNodePath);
107 
108  virtual void removeSwitchPaths(int containerInstanceId);
109 
112  virtual void slot_setSwitch(osgSim::MultiSwitch* clone, osgSim::MultiSwitch* master, int containerInstanceId);
113 
115  virtual bool slot_setSequence(osg::Sequence* clone, osg::Sequence* master, int containerInstanceId);
116 
118  virtual void slot_setSwitchDynamicTerrainSwitchNode(DtDynamicTerrainSwitchNode* switchNode, DynamicTerrain::NodePathHash nodePathHash, int childIdx);
119 
122  virtual void update(const osg::FrameStamp* frameStamp);
123 
125  virtual void processSwitches();
126 
128  virtual void releaseGLObjects(osg::State* state) const;
129 
131  virtual const DtGlBuffer* gpuSwitchStateBuffer() const;
132 
133  protected:
134 
136  virtual void addSwitchPath(PerGeomInstance& perGeomInstance, int vectorSwitchesOffBitMaskIdx,
137  const DequeNodeSwitchInfoPairs& parentSwitchPaths, const DequeNodeSwitchInfoPairs& switchPath,
138  const osg::NodePath& parentNodePath, int containerInstanceId);
139 
141  virtual void addSwitch(NodeSwitchInfoPair& switchChildPair, int bitMaskId, int vectorSwitchesOffBitMaskIdx,
142  const osg::NodePath& parentNodePath, int containerInstanceId);
143 
145  virtual bool checkSwitchChildActive(osg::ref_ptr<osg::Node> nodeRefPtr, int childIndex, DynamicTerrain::NodePathHash pathHash);
146 
148  virtual void updateSwitches();
149 
151  virtual void updateMultiSwitches();
152 
154  virtual void updateSequences(const osg::FrameStamp* frameStamp);
155 
157  virtual void updateSwitchStateBufferIfNecessary();
158 
160  virtual void deleteBuffers();
161 
163  virtual void tearDownBuffers() const;
164 
166  virtual void updateSwitch(const DtIndirectSwitchInfo& info, bool isSwitchChildActive);
167 
169  virtual void addSequence(osg::Sequence* sequence, int containerInstanceId);
170 
172  virtual void printInfo() const;
173 
175  virtual void printInfoSwitchInfos() const;
176 
178  virtual void printInfoMapsSize() const;
179 
181  virtual void printInfoBitMask() const;
182 
183  protected:
184 
186 
187  std::set<DtDynamicTerrainSwitchNode*> mySetDynamicTerrainSwitchNodes;
188 
189  // These are the 'master' sequences
190  typedef std::map<osg::Sequence*, unsigned int> MapSequenceToValue;
192 
193  // These are the 'master' switches
194  typedef std::map<osg::Switch*, osg::Switch::ValueList> MapSwitchToValueList;
196 
197  // These are the 'master' multi-switches
198  typedef std::map<osgSim::MultiSwitch*, osgSim::MultiSwitch::ValueList> MapMultiSwitchToValueList;
200 
201 
204 
206  {
207  void operator()(int& info);
208  };
209 
210  // Memory pool for which parent switches of this geometry are turned off.
211  // (so if this is 0 then all switches are turned on and the geometry should be visible)
214 
217  std::map<int, std::pair<int, int> > myInstanceIdToPairIndices;
218 
220  };
221 
222 }
std::map< int, std::pair< int, int > > myInstanceIdToPairIndices
This maps from instance container instance id to the start and end indices in the myVectorSwitchesOff...
Definition: DtIndirectSwitchManager.h:217
Contains makVrv::DtIndirectSwitchInfo struct.
parent manager class for all Indirect managers. Managers handle information about a specific feature ...
Definition: DtIndirectManager.h:25
DtDynamicTerrainSwitchNode replaces an osgSim::multiswitch in a terrain patch (or page) that is tagge...
Definition: DtDynamicTerrainSwitchNode.h:74
size_t NodePathHash
Typedef used to represent a hash of an OSG Node path to a referenced node.
Definition: DtMultiReferencedNodeContainer.h:26
std::set< DtDynamicTerrainSwitchNode * > mySetDynamicTerrainSwitchNodes
Definition: DtIndirectSwitchManager.h:187
std::map< int, VectorIndirectSwitchInfos > MapIntToVectorIndirectSwitchInfos
Definition: DtIndirectSwitchManager.h:81
#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:71
Contains makVrv::DtIndirectManager class.
friend DtIndirectSwitchManagerCreator
only creator can create
Definition: DtIndirectSwitchManager.h:86
std::deque< NodeSwitchInfoPair > DequeNodeSwitchInfoPairs
Definition: DtIndirectSwitchManager.h:77
const char * creatorTypeName< DtIndirectSwitchManager >(void)
template specialization for the creator (pass the class being created to the creatorTypeName template...
Definition: DtIndirectSwitchManager.h:63
DtGlBuffer * myGpuSwitchStateBuffer
Definition: DtIndirectSwitchManager.h:219
MapSequenceToValue myMapSequenceToValue
Definition: DtIndirectSwitchManager.h:191
std::map< NodeObserverPtr, MapIntToVectorIndirectSwitchInfos > MapNodeToMapIntToVectorIndirectSwitchInfos
Definition: DtIndirectSwitchManager.h:82
VectorSwitchesOffBitMask myVectorSwitchesOffBitMask
Definition: DtIndirectSwitchManager.h:213
DtSignalConnectionManager myConnections
Definition: DtIndirectSwitchManager.h:202
MapSwitchToValueList myMapSwitchToValueList
Definition: DtIndirectSwitchManager.h:195
Variadic templated creator class for defining a DtVirtualBaseClass creator that is automatically regi...
Definition: DtVirtualBaseClassCreator.h:23
MapMultiSwitchToValueList myMapMultiSwitchToValueList
Definition: DtIndirectSwitchManager.h:199
osg::observer_ptr< osg::Node > NodeObserverPtr
Definition: DtIndirectSwitchManager.h:75
Contains makVrv::DtVirtualBaseClass class.
MapNodeToMapIntToVectorIndirectSwitchInfos myMapNodeToVectorIndirectSwitchInfos
Definition: DtIndirectSwitchManager.h:185
bool myMutableSwitchesDirty
Definition: DtIndirectSwitchManager.h:203
std::map< osg::Sequence *, unsigned int > MapSequenceToValue
Definition: DtIndirectSwitchManager.h:190
Class to manage disconnection of boost connections on deletion.
Definition: DtSignalConnectionManager.h:20
std::map< osg::Switch *, osg::Switch::ValueList > MapSwitchToValueList
Definition: DtIndirectSwitchManager.h:194
std::pair< NodeObserverPtr, DtIndirectSwitchInfo > NodeSwitchInfoPair
Definition: DtIndirectSwitchManager.h:76
std::vector< DequeNodeSwitchInfoPairs > DequeNodeSwitchInfoPairsArray
Definition: DtIndirectSwitchManager.h:78
A generic OpenGL buffer. This can be: -&gt; a vertex buffer -&gt; an index buffer -&gt; a shader storage buffe...
Definition: DtGlBuffer.h:29
Contains makVrv::DtMultiReferencedNodeContainer class.
std::map< osgSim::MultiSwitch *, osgSim::MultiSwitch::ValueList > MapMultiSwitchToValueList
Definition: DtIndirectSwitchManager.h:198
Base class to provide boost signal/slot management.
Contains makVrv::DtReusableMemoryVector class.
std::vector< DtIndirectSwitchInfo > VectorIndirectSwitchInfos
Definition: DtIndirectSwitchManager.h:80
structure for holding the information about a particular instance of a particular switch...
Definition: DtIndirectSwitchInfo.h:25
Contains DLL export macros.
DtReusableMemoryVector< int, SwitchesOffBitMaskInvalidator > VectorSwitchesOffBitMask
Definition: DtIndirectSwitchManager.h:212
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:76
DtPerGeomInstance class declaration.
DtVirtualBaseClassCreator< DtIndirectSwitchManager > DtIndirectSwitchManagerCreator
creator
Definition: DtIndirectSwitchManager.h:56

Document ID: Generated on Thu Oct 15 21:27:02 EDT 2026 from SVN revision 296421
Copyright © 2005-2026 MAK Technologies. All Rights Reserved (www.mak.com)