13 :
16
17 auto estimatedTriangleCount = static_cast<std::size_t>(static_cast<float>(faceCount) * 2.5f);
18 triangles.reserve(estimatedTriangleCount);
19 bBoxes.reserve(estimatedTriangleCount);
20 for (std::uint32_t i = 0u; i < faceCount; i++) {
21 auto face = faceGetter(i);
22 while (face.size() > 2) {
23 const auto vertexLayoutIndex0 = face[0];
24 const auto vertexLayoutIndex1 = face[1];
25 const auto vertexLayoutIndex2 = face[face.size() - 1u];
26
27 const std::array<std::uint32_t, 3> positionIndices {vertexPositionIndices[vertexLayoutIndex0],
28 vertexPositionIndices[vertexLayoutIndex1],
29 vertexPositionIndices[vertexLayoutIndex2]};
30
31 const auto uvIndex0 = textureCoordinateUVIndices[vertexLayoutIndex0];
32 const auto uvIndex1 = textureCoordinateUVIndices[vertexLayoutIndex1];
33 const auto uvIndex2 = textureCoordinateUVIndices[vertexLayoutIndex2];
34
35 const std::array<fvec2, 3> UVs = {
fvec2{Us[uvIndex0], Vs[uvIndex0]},
36 fvec2{Us[uvIndex1], Vs[uvIndex1]},
37 fvec2{Us[uvIndex2], Vs[uvIndex2]}};
38
39 triangles.emplace_back(Triangle{UVs}, positionIndices);
40 bBoxes.emplace_back(BoundingBox{UVs});
41 face = face.last(face.size() - 1u);
42 }
43 }
46}
Vector< BoundingBox > bBoxes
Definition: UVBarycentricMapping.h:35
Vector< TrianglePositionIndicesPair > triangles
Definition: UVBarycentricMapping.h:34
fvec< 2 > fvec2
Definition: Types.h:50