FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
TailRenderer.h
1#pragma once
2#ifdef FH_VISUALIZATION
3
4# include "OceanOptics.h"
5# include "SpectralTail.h"
6
7# include <OgreTexture.h>
8# include <array>
9# include <cstdint>
10# include <future>
11# include <memory>
12# include <vector>
13
14namespace visual
15{
16
34class TailRenderer
35{
36public:
38 static constexpr int kSize = 128;
40 static constexpr int kCascades = 2;
42 static constexpr double kCascadeTurn = 0.65;
43
45 explicit TailRenderer(std::uint32_t seed);
46 ~TailRenderer();
47
48 TailRenderer(const TailRenderer&) = delete;
49 TailRenderer& operator=(const TailRenderer&) = delete;
50
57 bool Configure(double kCut, double meanDirection);
58
64 void Update(double time, double targetCoverage);
65
67 Ogre::TexturePtr Moments(int i) const { return m_moments[i]; }
68 Ogre::TexturePtr Extra(int i) const { return m_extra[i]; }
69 Ogre::TexturePtr Displacement(int i) const { return m_displacement[i]; }
70
72 double PatchSize(int i) const;
73
75 double TileAngle(int i) const;
76
78 optics::SlopeCovariance SlopeCovariance() const { return m_slopeCov; }
79
81 double FoamCoverage() const { return m_coverage; }
83 double ResidualFoam() const { return m_residualMean; }
84 double FoamThreshold() const { return m_threshold; }
85
87 double ComputeMilliseconds() const { return m_computeMs; }
88 double UploadMilliseconds() const { return m_uploadMs; }
89
90private:
91 struct Result
92 {
93 double time = 0.0;
95 std::array<std::array<std::vector<float>, 3>, kCascades> packed;
96 std::vector<float> foam;
97 std::vector<float> residual; // residual foam (stage B), in the extra texture's alpha
98 double coverage = 0.0;
99 double residualMean = 0.0;
100 double computeMs = 0.0;
101 };
102
103 void Upload(const Result& result);
104 Result Compute(double time, double dt, double threshold, std::vector<float> foam, std::vector<float> residual) const;
105
106 std::uint32_t m_seed;
107 double m_kCut = 0.0;
108 double m_meanDirection = 0.0;
109 std::array<std::shared_ptr<const tail::TailCascade>, kCascades> m_cascades;
110 std::array<Ogre::TexturePtr, kCascades> m_moments, m_extra, m_displacement;
111 optics::SlopeCovariance m_slopeCov;
112 std::future<Result> m_pending;
113 std::vector<float> m_foam;
114 std::vector<float> m_residual;
115 double m_residualMean = 0.0;
116 double m_lastTime = 0.0;
117 double m_coverage = 0.0;
118 double m_threshold = 0.6;
119 double m_computeMs = 0.0;
120 double m_uploadMs = 0.0;
121};
122
123} // namespace visual
124#endif
Visualization utilities.
Definition VisualDomain.h:12