| 141 | |
| 142 | private: |
| 143 | void BuildTree(size_t maxTrisPerLeaf, bool storeInteriorTris, |
| 144 | std::vector<Vector3<float>> const& centroids, size_t i0, |
| 145 | size_t i1, std::vector<int32_t>& inSplit, |
| 146 | std::vector<int32_t>& outSplit) |
| 147 | { |
| 148 | LogAssert( |
| 149 | i0 <= i1, |
| 150 | "Invalid index ordering."); |
| 151 | |
| 152 | Vector3<float> origin{}, direction{}; |
| 153 | CreateModelBound(i0, i1, inSplit, origin, direction); |
| 154 | |
| 155 | if (i1 - i0 < maxTrisPerLeaf) |
| 156 | { |
| 157 | // At a leaf node. |
| 158 | size_t numTriangles = i1 - i0 + 1; |
| 159 | mTriangles.resize(numTriangles); |
| 160 | for (size_t t0 = 0, t1 = i0; t0 < numTriangles; ++t0, ++t1) |
| 161 | { |
| 162 | mTriangles[t0] = inSplit[t1]; |
| 163 | } |
| 164 | |
| 165 | mLChild.reset(); |
| 166 | mRChild.reset(); |
| 167 | } |
| 168 | else |
| 169 | { |
| 170 | // At an interior node. |
| 171 | if (storeInteriorTris) |
| 172 | { |
| 173 | size_t numTriangles = i1 - i0 + 1; |
| 174 | mTriangles.resize(numTriangles); |
| 175 | for (size_t t0 = 0, t1 = i0; t0 < numTriangles; ++t0, ++t1) |
| 176 | { |
| 177 | mTriangles[t0] = inSplit[t1]; |
| 178 | } |
| 179 | } |
| 180 | else |
| 181 | { |
| 182 | mTriangles.clear(); |
| 183 | } |
| 184 | |
| 185 | size_t j0{}, j1{}; |
| 186 | SplitTriangles(centroids, i0, i1, inSplit, j0, j1, outSplit, |
| 187 | origin, direction); |
| 188 | |
| 189 | mLChild = std::make_shared<BoundTree<Mesh, Bound>>(mMesh, 0, false); |
| 190 | mLChild->BuildTree(maxTrisPerLeaf, storeInteriorTris, |
| 191 | centroids, i0, j0, outSplit, inSplit); |
| 192 | |
| 193 | mRChild = std::make_shared<BoundTree<Mesh, Bound>>(mMesh, 0, false); |
| 194 | mRChild->BuildTree(maxTrisPerLeaf, storeInteriorTris, |
| 195 | centroids, j1, i1, outSplit, inSplit); |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | // Compute the model bound for the subset of triangles. Return a |
| 200 | // line used for splitting the projections of the triangle centroids. |
nothing calls this directly
no outgoing calls
no test coverage detected