MCPcopy Create free account
hub / github.com/ValveSoftware/steam-audio / ProbeTree

Method ProbeTree

core/src/core/probe_tree.cpp:46–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44const int ProbeTree::kProbeLookupStackSize = 128;
45
46ProbeTree::ProbeTree(int numProbes,
47 const Probe* probes)
48{
49 if (numProbes <= 0)
50 return;
51
52 mNodes.resize(2 * numProbes - 1);
53
54 Array<int32_t> leafIndices(numProbes);
55 Array<Box> leafBounds(numProbes);
56 Array<Vector3f> leafBoxCenters(numProbes);
57 for (auto i = 0; i < numProbes; ++i)
58 {
59 leafIndices[i] = i;
60
61 const auto& sphere = probes[i].influence;
62 auto delta = sphere.radius * Vector3f(1, 1, 1);
63
64 leafBounds[i] = Box(sphere.center - delta, sphere.center + delta);
65
66 leafBoxCenters[i] = sphere.center;
67 }
68
69 Array<CentroidCoordinate, 2> centroids(3, numProbes);
70
71 Stack<ProbeTreeConstructionTask, kProbeLookupStackSize> stack;
72 ProbeTreeConstructionTask task{0, 0, numProbes - 1, 1};
73
74 while (true)
75 {
76 if (task.startIndex == task.endIndex)
77 {
78 mNodes[task.nodeIndex].box = leafBounds[leafIndices[task.startIndex]];
79 mNodes[task.nodeIndex].setProbeIndex(leafIndices[task.startIndex]);
80
81 if (stack.isEmpty())
82 break;
83
84 task = stack.pop();
85 }
86 else
87 {
88 alignas(float4_t) GrowableBox nodeBounds;
89 for (auto i = task.startIndex; i <= task.endIndex; ++i)
90 {
91 alignas(float4_t) GrowableBox bounds;
92 bounds.load(leafBounds[leafIndices[i]]);
93 nodeBounds.growToContain(bounds);
94 }
95 nodeBounds.store(mNodes[task.nodeIndex].box);
96
97 for (auto i = task.startIndex; i <= task.endIndex; ++i)
98 {
99 centroids[0][i].coordinate = leafBoxCenters[leafIndices[i]].x();
100 centroids[1][i].coordinate = leafBoxCenters[leafIndices[i]].y();
101 centroids[2][i].coordinate = leafBoxCenters[leafIndices[i]].z();
102 centroids[0][i].leafIndex = leafIndices[i];
103 centroids[1][i].leafIndex = leafIndices[i];

Callers

nothing calls this directly

Calls 13

setProbeIndexMethod · 0.80
popMethod · 0.80
growToContainMethod · 0.80
storeMethod · 0.80
indexOfMaxComponentMethod · 0.80
extentsMethod · 0.80
setSplitCoordinateMethod · 0.80
pushMethod · 0.80
BoxClass · 0.70
resizeMethod · 0.45
isEmptyMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected