FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
VisualFieldVolume.h
1#pragma once
2
8#include "VisualField.h"
9
10#include <memory>
11#include <string>
12
13#ifdef FH_VISUALIZATION
14# include "visual/ScalarVolume.h"
15
16# include <atomic>
17# include <thread>
18#endif
19
20class FhCamera;
21
22namespace environmentmodels
23{
24
102{
103public:
111 VisualFieldVolume(std::string SimObjectName, ISimObjectCreator* Creator);
112
115
116#ifdef FH_VISUALIZATION
125 void RenderInit(Ogre::Root* const ogreRoot, ISimObjectCreator* Creator) override;
126
136 void RenderUpdate(const double T, const double* const X) override;
137#endif
138
139private:
140#ifdef FH_VISUALIZATION
142 void JoinWorker();
143
149 void FollowCamera(double T, const double cameraPos[3]);
150
157 void SampleAt(double T, const double centre[3]);
158
162 void MoveBox(const double centre[3]);
163
169 void StartBake(const double centre[3]);
170
178 void AdoptFinishedBake();
179
187 void RecordFailedTarget(const double centre[3]);
188
195 [[nodiscard]] bool MovedFarEnough(const double cameraPos[3], const double centre[3]) const;
196
201 void ApplyVolumeUniforms(const double centre[3]) const;
202
212 [[nodiscard]] bool CameraIsInsideBox(const double cameraPos[3]) const;
213
215 [[nodiscard]] util::SamplingBox MakeBox(const double centre[3]) const;
216#endif
217
218 double m_boxCentre[3];
219 double m_boxSize[3];
220 double m_referenceLength;
221 double m_rebakeFraction;
222 bool m_centreOnCamera;
223
224 int m_counts[3];
225
226#ifdef FH_VISUALIZATION
227 std::unique_ptr<visual::ScalarVolume> m_scalarVolume;
228
229 FhCamera* m_fhCamera;
230
231 bool m_hasPendingCentre;
232 double m_pendingCentre[3];
233
234 std::thread m_worker;
235 std::atomic_bool m_bakeFinished;
236 bool m_bakeRunning;
237
238 util::BakedField m_bakeResult;
239 double m_bakeResultCentre[3];
240 double m_bakeClampedFraction;
241 std::string m_bakeError;
242
243 bool m_hasFailedCentre;
244 double m_failedCentre[3];
245
246 bool m_cullingInside;
247#endif
248};
249
250} // namespace environmentmodels
Definition VisualFieldVolume.h:102
~VisualFieldVolume() override
Joins any re-bake worker and releases the box; the base releases material and textures.
VisualFieldVolume(std::string SimObjectName, ISimObjectCreator *Creator)
Definition VisualField.h:53
Environment SimObjects.
Definition Environment.h:25
A scalar field evaluated over a SamplingBox and encoded to 16-bit codes.
Definition ScalarFieldBake.h:52
Definition ScalarFieldBake.h:44