VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtGeom3dSpheresSystem.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 <vrvCore/vrvCore.h>
13 #include <vrvCore/DtJobSplitter.h>
15 
16 #include <vrvMath/DtCamera.h>
18 #include <vrvMath/DtVector4.h>
19 
22 
23 #include <matrix/vlVector.h>
24 
25 #include <array>
26 #include <unordered_map>
27 #include <vector>
28 #include <tbb/concurrent_vector.h>
29 
30 namespace makVrv
31 {
32  // forward Declarations
33  class DtCoordinateSystem;
34  class DtDe;
35  class Dt3dSpheresStagingBuffer;
36  class DtGeom3dSpheresComponent;
38 
41 
43  template <>
44  inline const char* creatorTypeName<DtGeom3dSpheresSystem>() { return "DtGeom3dSpheresSystemCreator"; }
45 
63  {
65 
66  public:
67 
68  virtual ~DtGeom3dSpheresSystem();
69 
71  DtGeom3dSpheresSystem() = delete;
72 
75  const DtGeom3dSpheresSystem& other) = delete;
76 
78  DtGeom3dSpheresSystem& operator=(
79  const DtGeom3dSpheresSystem& other) = delete;
80 
81  public:
82 
89  virtual DtGeom3dSpheresComponent* createComponent(DtModelSetId modelSet);
90 
95  virtual void registerComponent(DtGeom3dSpheresComponent* component);
96 
99  virtual void unregisterComponent(DtGeom3dSpheresComponent* component);
100 
103  virtual size_t registeredComponentCount(const DtModelSetId modelSetId) const;
104 
114  virtual bool cull(void* cameraContext, const DtModelSetId modelSetId,
115  const DtVector& cameraPos, const Frustum_64& frustum);
116 
122  virtual void submit3dSpheresForDraw(void* cameraContext,
123  std::vector<Dt3dSpheresStagingBuffer*>& buffers);
124 
125  protected:
126 
130 
132  virtual void slot_preTick();
133 
141  static bool isSphereVisible(
142  const std::array<DtVector4<double>, 6>& cullingPlanes,
143  const DtVector3<double>& center, double radiusSquared);
144 
147  static void theCullJob(void* data);
148 
149  protected:
150 
153  struct CullJobData
154  {
155  std::vector<DtGeom3dSpheresComponent*>* myComponents = nullptr;
156  size_t myBeginIndex = 0;
157  size_t myEndIndex = 0;
158  Dt3dSpheresStagingBuffer* myBuffer = nullptr;
159  const std::array<DtVector4<double>, 6>* myCullingPlanes = nullptr;
160  unsigned int myCategoryFlags = 0;
161  };
162 
166  struct Buffer
167  {
168  Dt3dSpheresStagingBuffer* myBuffer = nullptr;
171  };
172 
177  {
178  std::vector<Buffer*> myBuffers;
179  bool myCameraWasUsedDuringCull = true;
180  DtJobSplitter* myJobSplitter = nullptr;
181  };
182 
185  {
186  std::vector<DtGeom3dSpheresComponent*> myComponents;
187  };
188 
190 
192 
193  // Flags that determine what categories of components are active.
195 
196  // Components are registered with an associated DtModelSetId and this
197  // map is used to map the DtModelSetId to the components associated with it.
198  std::unordered_map<DtModelSetId, PerModelSetComponents*> myPerModelSetComponents;
199 
200  // This map is read only during cull and render.
201  // It maps a cameraContext to associated staging data.
202  std::unordered_map<void*, PerCameraStaging*> myPerCameraStagingMap;
203 
204  // This vector handles new camera's when they are encountered
205  // during cull. The contents of the vector are handed to
206  // myPerCameraStagingMap to be processed in a thread safe way
207  // during update.
208  tbb::concurrent_vector<void*> myPendingCameras;
209  };
210 }
A class which represents a component for a set of 3d spheres.
Definition: DtGeom3dSpheresComponent.h:48
std::vector< DtGeom3dSpheresComponent * > myComponents
Definition: DtGeom3dSpheresSystem.h:186
DtSignalConnectionManager myConnections
Definition: DtGeom3dSpheresSystem.h:191
A structure to hold per camera data for staging. There will be one of these for every active camera T...
Definition: DtGeom3dSpheresSystem.h:176
DtJobSplitterJob myCullJob
Definition: DtGeom3dSpheresSystem.h:170
this class is used to split work up between threads.
Definition: DtJobSplitter.h:64
4 dimensional vector
A class which represents a buffer used for staging 3d spheres. &quot;staging&quot; means collecting, formatting, prepping data to be handed to another process (usually a rendering process). Most likely, this staged data will be passed to a gpu buffer at when needed.
Definition: Dt3dSpheresStagingBuffer.h:34
A class responsible for processing DtGeom3dSpheresComponent objects.
Definition: DtGeom3dSpheresSystem.h:62
unsigned int myComponentCategoryFlags
Definition: DtGeom3dSpheresSystem.h:194
Camera forward declarations.
Variadic templated creator class for defining a DtVirtualBaseClass creator that is automatically regi...
Definition: DtVirtualBaseClassCreator.h:23
friend DtGeom3dSpheresSystemCreator
Definition: DtGeom3dSpheresSystem.h:64
DtDe & myDe
Definition: DtGeom3dSpheresSystem.h:189
Contains makVrv::DtJobSplitter class.
#define DT_DLL_VRVCORE
Definition: vrvCore.h:20
const char * creatorTypeName< DtGeom3dSpheresSystem >()
template specialization for the creator (pass the class being created to the creatorTypeName template...
Definition: DtGeom3dSpheresSystem.h:44
A structure to hold per model set components.
Definition: DtGeom3dSpheresSystem.h:184
std::unordered_map< DtModelSetId, PerModelSetComponents * > myPerModelSetComponents
Definition: DtGeom3dSpheresSystem.h:198
Class to manage disconnection of boost connections on deletion.
Definition: DtSignalConnectionManager.h:20
std::unordered_map< void *, PerCameraStaging * > myPerCameraStagingMap
Definition: DtGeom3dSpheresSystem.h:202
CullJobData myCullJobData
Definition: DtGeom3dSpheresSystem.h:169
Base class to provide boost signal/slot management.
A generic structure to hold data for a job for use with DtJobSplitter.
Definition: DtJobSplitter.h:26
A structure used to hold culling data per cull job. This is used in multithread culling tasks...
Definition: DtGeom3dSpheresSystem.h:153
DtVirtualBaseClassCreator< DtGeom3dSpheresSystem > DtGeom3dSpheresSystemCreator
creator
Definition: DtGeom3dSpheresSystem.h:37
Camera class.
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
std::vector< Buffer * > myBuffers
Definition: DtGeom3dSpheresSystem.h:178
tbb::concurrent_vector< void * > myPendingCameras
Definition: DtGeom3dSpheresSystem.h:208
DtModelSetId
Definition: DtModelSetEnums.h:19
Contains various enum classes relating to model sets.
A structure to hold buffer data to use for culling and rendering. This is used in internal job splitt...
Definition: DtGeom3dSpheresSystem.h:166
Contains DLL export macros.

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)