VR-Forces 5.0.3 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) 2023 MAK Technologies, Inc.
3 * All rights reserved.
4 *****************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvOsg/vrvOsg.h>
16 
18 
20 
23 
24 #include <osgSim/MultiSwitch>
25 #include <osg/Node>
26 #include <osg/ref_ptr>
27 #include <osg/observer_ptr>
28 #include <osg/Switch>
29 
30 #include <list>
31 #include <deque>
32 
33 namespace osg
34 {
35  class Group;
36  class Node;
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 DtInstanceContainer;
51  class DtDynamicTerrainSwitchNode;
52  class DtSwitchInstanceState;
53  class DtDe;
54  class DtGlBuffer;
55 
58 
61 
63  template <>
64  inline const char* creatorTypeName<DtIndirectSwitchManager>(void) { return "DtIndirectSwitchManagerCreator"; }
65 
73  {
74  public:
75 
76  typedef osg::observer_ptr<osg::Node> NodeObserverPtr;
77  typedef std::pair<NodeObserverPtr, DtIndirectSwitchInfo> NodeSwitchInfoPair;
78  typedef std::deque<NodeSwitchInfoPair> DequeNodeSwitchInfoPairs;
79  typedef std::vector<DequeNodeSwitchInfoPairs> DequeNodeSwitchInfoPairsArray;
80 
81  typedef std::vector<DtIndirectSwitchInfo> VectorIndirectSwitchInfos;
82  typedef std::map<int, VectorIndirectSwitchInfos> MapIntToVectorIndirectSwitchInfos;
83  typedef std::map<NodeObserverPtr, MapIntToVectorIndirectSwitchInfos > MapNodeToMapIntToVectorIndirectSwitchInfos;
84 
85  public:
88 
90  virtual ~DtIndirectSwitchManager();
91  protected:
94 
95  private:
97  DtIndirectSwitchManager() = delete;
99  DtIndirectSwitchManager(const DtIndirectSwitchManager& other) = delete;
101  DtIndirectSwitchManager& operator=(const DtIndirectSwitchManager& other) = delete;
102 
103  public:
105  virtual void addSwitchPaths(int perGeomInstanceIndex, int size, const DequeNodeSwitchInfoPairs& parentSwitchPaths, const DequeNodeSwitchInfoPairsArray& switchPaths, const osg::NodePath& parentNodePath, int instanceId);
106 
108  virtual void slot_setSwitchDynamicTerrainSwitchNode(DtDynamicTerrainSwitchNode* switchNode, DynamicTerrain::NodePathHash nodePathHash, int childIdx);
109 
112  virtual void update(const osg::FrameStamp* frameStamp);
113 
115  virtual void processSwitches(void);
116 
118  virtual void releaseGLObjects(osg::State* state) const;
119 
121  virtual const DtGlBuffer* gpuSwitchStateBuffer(void) const;
122 
125  virtual void removeMultiSwitchNode(osg::Node* node);
126 
127  protected:
128 
130  virtual void addSwitchPath(int perGeomInstanceIndex, const DequeNodeSwitchInfoPairs& parentSwitchPaths, const DequeNodeSwitchInfoPairs& switchPath, const osg::NodePath& parentNodePath, int instanceId);
131 
133  virtual void addSwitch(NodeSwitchInfoPair& switchChildPair, int bitMaskId, int perGeomInstanceIndex, const osg::NodePath& parentNodePath, int uniqueId);
134 
136  virtual bool checkSwitchChildActive(osg::ref_ptr<osg::Node> nodeRefPtr, int childIndex, DynamicTerrain::NodePathHash pathHash);
137 
139  virtual void updateSwitches(void);
140 
142  virtual void updateMultiSwitches(void);
143 
145  virtual void updateSequences(const osg::FrameStamp* frameStamp);
146 
148  virtual void updateSwitchStateBufferIfNecessary(void);
149 
151  virtual void deleteBuffers(void);
152 
154  virtual void tearDownBuffers(void) const;
155 
157  virtual void updateSwitch(const DtIndirectSwitchInfo& info, bool isSwitchChildActive);
158 
160  virtual void addSequence(osg::Sequence* sequence, int instanceId);
161 
162  protected:
163 
165 
166  std::set<DtDynamicTerrainSwitchNode*> mySetDynamicTerrainSwitchNodes;
167 
168  // These are the 'master' sequences
169  typedef std::map<osg::Sequence*, unsigned int> MapSequenceToValue;
171 
172  // These are the 'master' switches
173  typedef std::map<osg::Switch*, osg::Switch::ValueList> MapSwitchToValueList;
175 
176  // These are the 'master' multi-switches
177  typedef std::map<osgSim::MultiSwitch*, osgSim::MultiSwitch::ValueList> MapMultiSwitchToValueList;
179 
180 
183 
185  {
186  void operator()(int& info);
187  };
188 
189  //which parent switches of this geometry are turned off
190  //(so if this is 0 then all switches are turned on and the geometry should be visible)
193 
195 
196  // This group node is set as a parent node to all registered multiswitch
197  // nodes. This is needed for tracking because the DtDynamicTerrainParser
198  // can swap out a regular osgSim::MultiSwitch with a DtDynamicTerrainSwitchNode
199  // and this DtIndirectSwitchManager has no way of knowing that.
200  // By using this parent node, we can track when that happens and remove the
201  // osgSim::MultiSwitch from tracking in this manager.
203  };
204 
205 
206 
207  // The DtIndirectMultiSwitchTrackingNode is used to track a replacement of
208  // a osgSim::MultiSwitch node from DtDynamicTerrainParser.
209  // This is used by DtIndirectSwitchManager.
210  // This group node is set as a parent node to all registered multiswitch
211  // nodes. This is needed for tracking because the DtDynamicTerrainParser
212  // can swap out a regular osgSim::MultiSwitch with a DtDynamicTerrainSwitchNode
213  // and DtIndirectSwitchManager has no way of knowing that.
214  // By using this parent node, we can track when that happens and remove the
215  // osgSim::MultiSwitch from tracking in the DtIndirectSwitchManager.
217  : public osg::Group
218  {
219  public:
220 
221  META_Node(vrvOsg, DtIndirectMultiSwitchTrackingNode);
222 
223  public:
224 
226 
228  const DtIndirectMultiSwitchTrackingNode & rhs, const osg::CopyOp& copyop);
229 
231 
234  bool replaceChild(osg::Node *origNode, osg::Node *newNode) override;
235 
236  protected:
237 
239 
240  virtual void setManager(DtIndirectSwitchManager* manager);
241 
242  protected:
243 
245  };
246 
249  {
250  public:
251 
254  static DtIndirectMultiSwitchTrackingNodeCreator& instance(DtDe& de);
255 
257  static void registerInstance(DtDe& de,
259 
262  };
263 }
Contains makVrv::DtIndirectSwitchInfo struct.
Virtual base class. Allows for RTTI and proper virtual destruction. Used by Creators, Factories, Providers, Assemblers and User Interfaces.
Definition: DtVirtualBaseClass.h:19
parent manager class for all Indirect managers. Managers handle information about a specific feature ...
Definition: DtIndirectManager.h:26
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:25
std::set< DtDynamicTerrainSwitchNode * > mySetDynamicTerrainSwitchNodes
Definition: DtIndirectSwitchManager.h:166
std::map< int, VectorIndirectSwitchInfos > MapIntToVectorIndirectSwitchInfos
Definition: DtIndirectSwitchManager.h:82
DtIndirectSwitchManager * myIndirectSwitchManager
Definition: DtIndirectSwitchManager.h:244
#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
Contains makVrv::DtIndirectManager class.
voidpf void uLong size
Definition: ioapi.h:39
friend DtIndirectSwitchManagerCreator
only creator can create
Definition: DtIndirectSwitchManager.h:87
std::deque< NodeSwitchInfoPair > DequeNodeSwitchInfoPairs
Definition: DtIndirectSwitchManager.h:78
const char * creatorTypeName< DtIndirectSwitchManager >(void)
template specialization for the creator (pass the class being created to the creatorTypeName template...
Definition: DtIndirectSwitchManager.h:64
DtGlBuffer * myGpuSwitchStateBuffer
Definition: DtIndirectSwitchManager.h:194
MapSequenceToValue myMapSequenceToValue
Definition: DtIndirectSwitchManager.h:170
std::map< NodeObserverPtr, MapIntToVectorIndirectSwitchInfos > MapNodeToMapIntToVectorIndirectSwitchInfos
Definition: DtIndirectSwitchManager.h:83
VectorSwitchesOffBitMask myVectorSwitchesOffBitMask
Definition: DtIndirectSwitchManager.h:192
DtSignalConnectionManager myConnections
Definition: DtIndirectSwitchManager.h:181
MapSwitchToValueList myMapSwitchToValueList
Definition: DtIndirectSwitchManager.h:174
Creator that is used to create the DtIndirectMultiSwitchTrackingNode.
Definition: DtIndirectSwitchManager.h:248
Definition: DtIndirectSwitchManager.h:216
Variadic templated creator class for defining a DtVirtualBaseClass creator that is automatically regi...
Definition: DtVirtualBaseClassCreator.h:22
MapMultiSwitchToValueList myMapMultiSwitchToValueList
Definition: DtIndirectSwitchManager.h:178
osg::observer_ptr< osg::Node > NodeObserverPtr
Definition: DtIndirectSwitchManager.h:76
Contains makVrv::DtVirtualBaseClass class.
MapNodeToMapIntToVectorIndirectSwitchInfos myMapNodeToVectorIndirectSwitchInfos
Definition: DtIndirectSwitchManager.h:164
bool myMutableSwitchesDirty
Definition: DtIndirectSwitchManager.h:182
std::map< osg::Sequence *, unsigned int > MapSequenceToValue
Definition: DtIndirectSwitchManager.h:169
Class to manage disconnection of boost connections on deletion.
Definition: DtSignalConnectionManager.h:20
std::map< osg::Switch *, osg::Switch::ValueList > MapSwitchToValueList
Definition: DtIndirectSwitchManager.h:173
DtVirtualBaseClassCreator< DtIndirectSwitchManager, DtInstanceContainer & > DtIndirectSwitchManagerCreator
creator
Definition: DtIndirectSwitchManager.h:57
std::pair< NodeObserverPtr, DtIndirectSwitchInfo > NodeSwitchInfoPair
Definition: DtIndirectSwitchManager.h:77
std::vector< DequeNodeSwitchInfoPairs > DequeNodeSwitchInfoPairsArray
Definition: DtIndirectSwitchManager.h:79
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.
osg::ref_ptr< osg::Group > myMultiSwitchTrackingNode
Definition: DtIndirectSwitchManager.h:202
std::map< osgSim::MultiSwitch *, osgSim::MultiSwitch::ValueList > MapMultiSwitchToValueList
Definition: DtIndirectSwitchManager.h:177
Base class to provide boost signal/slot management.
Contains makVrv::DtReusableMemoryVector class.
std::vector< DtIndirectSwitchInfo > VectorIndirectSwitchInfos
Definition: DtIndirectSwitchManager.h:81
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:191
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
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

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)