VR-Forces 4.10 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtIndirectLodManager.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright (c) 2020 MAK Technologies, Inc.
3  * All rights reserved.
4  *****************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvOsg/vrvOsg.h>
14 
16 
19 
20 #include <osg/Vec3>
21 #include <osg/Matrix>
22 #include <osg/Camera>
23 #include <osg/observer_ptr>
24 
25 #include <deque>
26 #include <vector>
27 #include <map>
28 
29 namespace makVrv
30 {
31  class DtDe;
32  class DtGlBuffer;
33  class DtIndirectViewParameters;
34  class DtIndirectLodProgram;
35  class DtInstanceContainer;
36 
39 
42 
44  template <>
45  inline const char* creatorTypeName<DtIndirectLodManager>(void) { return "DtIndirectLodManagerCreator"; }
46 
53  {
54  public:
55 
59  #define CPU_SIDE_COMPILATION 1
60  #include <../data/shaders/indirect/LodInfoBuffer.h>
61  #undef CPU_SIDE_COMPILATION
62 
63  typedef osg::observer_ptr<osg::Node> NodeObserverPtr;
64  typedef std::pair<NodeObserverPtr, IndirectLodInfo> NodeLodInfoPair;
65  typedef std::deque<IndirectLodInfo> DequeIndirectLodInfos;
66  typedef std::deque<NodeLodInfoPair> DequeIndirectLodInfoPairs;
67  typedef std::vector<DequeIndirectLodInfos> DequeIndirectLodInfoArray;
68 
71  {
72  public:
73  void operator()(IndirectLodInfo& info);
74  };
75 
78  {
79  public:
80  IndirectLodInfoRemovalPredicate(int start, int end);
81  bool operator()(const IndirectLodInfo& info) const;
82 
85  };
86 
88 
89  public:
92 
94  virtual ~DtIndirectLodManager();
95  protected:
98 
99  private:
101  DtIndirectLodManager() = delete;
103  DtIndirectLodManager(const DtIndirectLodManager &other) = delete;
105  DtIndirectLodManager &operator=(const DtIndirectLodManager &other) = delete;
106 
107  public:
108 
110  virtual void releaseGLObjects(osg::State* state) const;
111 
113  virtual void addLodStacks(int perGeomInstanceIndex, int numGeoms, const DequeIndirectLodInfos& parentLodStack, const DequeIndirectLodInfoArray& lodStacks, const osg::Matrix& inverselocalOriginMatrix, int instanceId);
114 
116  virtual void removeLodStacks(int instanceId);
117 
120  virtual void processLods(const DtIndirectViewParameters& viewParameters
121  , const DtGlBuffer* gpuDofTransformBuffer
122  , const DtGlBuffer* gpuDofModelScaleBuffer
123  , const DtGlBuffer* gpuInputPerGeomInstancesBuffer
124  , const osg::Camera* currentCamera);
125 
128  virtual const DtGlBuffer* gpuLodVisibleBuffer(const osg::Camera* currentCamera) const;
129 
131  virtual void reloadShaders() const;
132 
134  virtual void printInfo();
135 
136  protected:
137 
141  virtual void addLodStack(int perGeomInstanceIndex, int& indexIntoVectorIndirectLodInfos, const DequeIndirectLodInfos& parentLodStack, const DequeIndirectLodInfos& lodStack, const osg::Matrix& inverselocalOriginMatrix);
142 
144  virtual void updateLodBuffersIfNecessary();
145 
147  virtual void deleteShaders() const;
148 
150  virtual void deleteBuffers(void);
151 
153  virtual void tearDownBuffers(void) const;
154 
157  virtual void flushGpuLodVisibleBuffers();
158 
159  protected:
160 
162 
165 
167  typedef std::map<osg::observer_ptr<const osg::Camera>, DtGlBuffer*> CameraToBufferMap;
169 
170  typedef std::vector<osg::observer_ptr<const osg::Camera> > CameraVector;
172 
173  mutable bool myMutableLodInfoDirty;
174 
176 
178 
179  std::map<int, std::pair<int, int> > myInstanceIdToPairIndices;
180 
181  };
182 
183 }
initializer/invalidator for lod info
Definition: DtIndirectLodManager.h:70
VectorIndirectLodInfos myIndirectLodInfos
Definition: DtIndirectLodManager.h:161
parent manager class for all Indirect managers.
Definition: DtIndirectManager.h:26
const char * creatorTypeName< DtIndirectLodManager >(void)
template specialization for the creator (pass the class being created to the creatorTypeName template...
Definition: DtIndirectLodManager.h:45
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
Contains makVrv::DtIndirectManager class.
DtVirtualBaseClassCreator< DtIndirectLodManager, DtInstanceContainer & > DtIndirectLodManagerCreator
creator
Definition: DtIndirectLodManager.h:38
DtIndirectLodProgram * myMutableLodProgram
Definition: DtIndirectLodManager.h:175
osg::observer_ptr< osg::Node > NodeObserverPtr
Definition: DtIndirectLodManager.h:63
CameraToBufferMap myGpuLodVisibleBufferMap
Definition: DtIndirectLodManager.h:168
handles the lods for all the indirect geometry.
Definition: DtIndirectLodManager.h:52
std::vector< DequeIndirectLodInfos > DequeIndirectLodInfoArray
Definition: DtIndirectLodManager.h:67
3 dimensional vector
bool myMutableLodInfoDirty
Definition: DtIndirectLodManager.h:173
CameraVector myActiveCameras
Definition: DtIndirectLodManager.h:171
Variadic templated creator class for defining a DtVirtualBaseClass creator that is automatically regi...
Definition: DtVirtualBaseClassCreator.h:22
singleton class that wraps indirect lod gpu shader.
Definition: DtIndirectLodProgram.h:72
unsigned int myMaxPerGeomInstanceId
Definition: DtIndirectLodManager.h:177
const int myStartPerGeomInstanceIndex
Definition: DtIndirectLodManager.h:83
std::vector< osg::observer_ptr< const osg::Camera > > CameraVector
Definition: DtIndirectLodManager.h:170
const int myEndPerGeomInstanceIndex
Definition: DtIndirectLodManager.h:84
DtGlBuffer * myGpuLodInfoBuffer
The buffer containing all the lod infos for all instances managed by this manager.
Definition: DtIndirectLodManager.h:164
friend DtIndirectLodManagerCreator
only creator can create
Definition: DtIndirectLodManager.h:91
removal predicate for lod infos (checks to see if the model ids match.
Definition: DtIndirectLodManager.h:77
A generic OpenGL buffer.
Definition: DtGlBuffer.h:27
The class that is used to communicate the camera viewing parameters to the DtICullingAndLOD interface...
Definition: DtIndirectViewParameters.h:26
Contains makVrv::DtReusableMemoryVector class.
std::map< int, std::pair< int, int > > myInstanceIdToPairIndices
Definition: DtIndirectLodManager.h:179
DtReusableMemoryVector< IndirectLodInfo, IndirectLodInfoInvalidator, IndirectLodInfoRemovalPredicate > VectorIndirectLodInfos
Definition: DtIndirectLodManager.h:87
Contains DLL export macros.
The DtDe is the core component of any VR-Vantage application.
Definition: DtDe.h:69
std::deque< NodeLodInfoPair > DequeIndirectLodInfoPairs
Definition: DtIndirectLodManager.h:66
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
std::map< osg::observer_ptr< const osg::Camera >, DtGlBuffer * > CameraToBufferMap
The buffer containing a bool for each instance to know if it should be drawn or not.
Definition: DtIndirectLodManager.h:167
std::deque< IndirectLodInfo > DequeIndirectLodInfos
Definition: DtIndirectLodManager.h:65
std::pair< NodeObserverPtr, IndirectLodInfo > NodeLodInfoPair
Definition: DtIndirectLodManager.h:64

Document ID: Generated on Tue Sep 21 17:42:52 EDT 2021 from SVN revision 234861
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)