2#include "SampleVolumeTask.h"
16void EchoSounder::SampleVolumeTask2::runVanilla(TileValue * dstValues,
17 uint16_t * timeValues,
18 const EchoSounder::PingInfo* pinf,
19 const uint32_t upperFansToRemove,
20 const uint32_t numPings,
21 const uint32_t numSamples,
22 const uint32_t gridSizeX,
23 const uint32_t gridSizeY,
24 const float depthOffset,
25 const float depthStep,
26 const float sampleSpacing,
28 const std::vector<float>& beamAngleAlongship,
29 const std::vector<float>& beamAngleAthwartship,
30 const glm::ivec3& this_minIndex,
31 const glm::ivec3& this_maxIndex)
33 const auto time = pinf->time;
34 const auto weight = 1.f;
35 const auto numBeamsMajor =
static_cast<uint32_t
>(beamAngleAlongship.size());
36 const auto numBeamsMinor =
static_cast<uint32_t
>(beamAngleAthwartship.size());
37 const auto s = 1.f / sampleSpacing;
40 const vec3 minPolar(beamAngleAthwartship.front(),
41 beamAngleAlongship.front(),
43 const vec3 maxPolar(beamAngleAthwartship.back(),
44 beamAngleAlongship.back(),
45 depthOffset + (numSamples - 1)*depthStep);
48 const uvec3 maxTau(max(2u, numBeamsMinor) - 2,
49 max(2u + upperFansToRemove, numBeamsMajor) - 2 - upperFansToRemove,
50 max(2u, numSamples) - 2);
53 const vec3 polarToIndex = vec3(max(2u, numBeamsMinor) - 2,
54 max(2u, numBeamsMajor) - 2,
55 max(2u, numSamples) - 2) / (maxPolar - minPolar);
57 const auto * minorMu = beamAngleAthwartship.data();
58 const auto * majorMu = beamAngleAlongship.data();
60 for (uint32_t p = 0; p < numPings; p++) {
62 const auto minIndex = this_minIndex;
63 const auto maxIndex = this_maxIndex;
64 const auto * srcValues = pinf[p].field;
66 const auto rot = inverse(pinf[p].metaPing.arrayOrientationGlobal);
67 const auto shift = pinf[p].arrayPositionTile;
68 for (
int k = minIndex.z; k < maxIndex.z; k++) {
69 for (
int j = minIndex.y; j < maxIndex.y; j++) {
70 for (
int i = minIndex.x; i < maxIndex.x; i++) {
72 const auto samplePosGrid = sampleSpacing*vec3(i, j, k);
73 if (samplePosGrid.z < pinf[p].depthRestriction) {
77 const auto samplePosArray = (samplePosGrid - shift);
78 const auto r2 = glm::dot(samplePosArray, samplePosArray);
83 bool in_0 = 0.f <= glm::dot(pinf[p].boundingFrustumNormals[0], samplePosArray);
84 bool in_1 = 0.f <= glm::dot(pinf[p].boundingFrustumNormals[1], samplePosArray);
85 bool in_2 = 0.f <= glm::dot(pinf[p].boundingFrustumNormals[2], samplePosArray);
86 bool in_3 = 0.f <= glm::dot(pinf[p].boundingFrustumNormals[3], samplePosArray);
87 bool in_4 = pinf[p].minDepthSquared <= r2;
88 bool in_5 = r2 <= pinf[p].maxDepthSquared;
89 if (!in_0 || !in_1 || !in_2 || !in_3 || !in_4 || !in_5) {
92 const auto cartesianPos = rot * samplePosArray;
93 float r = std::sqrt(r2);
95 const float dirX = std::asin(cartesianPos.x / r);
96 const float dirY = std::asin(cartesianPos.y / r);
97 const auto polarPos = glm::vec3(dirY, dirX, r);
99 auto xi = polarToIndex*(polarPos - minPolar);
100 auto tau = uvec3(xi);
102 bool range_1_0 = tau.x <= maxTau.x;
103 bool range_1_1 = tau.y <= maxTau.y;
104 bool range_1_2 = tau.z <= maxTau.z;
105 if (!range_1_0 || !range_1_1 || !range_1_2) {
110 float bx = xi.x - tau.x;
111 float by = xi.y - tau.y;
113 const auto val00 = srcValues[((tau.y + 0)*numBeamsMinor + (tau.x + 0))*numSamples + tau.z];
114 const auto val01 = srcValues[((tau.y + 1)*numBeamsMinor + (tau.x + 0))*numSamples + tau.z];
115 const auto val0 = (1.f - by)*PingValue_Decode(val00) + by*PingValue_Decode(val01);
117 const auto val10 = srcValues[((tau.y + 0)*numBeamsMinor + (tau.x + 1))*numSamples + tau.z];
118 const auto val11 = srcValues[((tau.y + 1)*numBeamsMinor + (tau.x + 1))*numSamples + tau.z];
119 const auto val1 = (1.f - by)*PingValue_Decode(val10) + by*PingValue_Decode(val11);
121 const auto val = (1.f - bx)*val0 + bx*val1;
123 auto dstOffset = (k*gridSizeY + j)*gridSizeX + i;
125 auto oldValue = TileValue_Decode(dstValues[dstOffset]);
126 if (oldValue == 0.0) oldValue = val;
128 dstValues[dstOffset] = TileValue_Encode(0.5f*oldValue + 0.5f*val);
130 timeValues[dstOffset] = time;
Contains the Engine, Renderer, resource managers and other systems needed to run Cogs....