MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / hasTriangleFlips

Function hasTriangleFlips

Source/ThirdParty/meshoptimizer/simplifier.cpp:1196–1228  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1194}
1195
1196static bool hasTriangleFlips(const EdgeAdjacency& adjacency, const Vector3* vertex_positions, const unsigned int* collapse_remap, unsigned int i0, unsigned int i1)
1197{
1198 assert(collapse_remap[i0] == i0);
1199 assert(collapse_remap[i1] == i1);
1200
1201 const Vector3& v0 = vertex_positions[i0];
1202 const Vector3& v1 = vertex_positions[i1];
1203
1204 const EdgeAdjacency::Edge* edges = &adjacency.data[adjacency.offsets[i0]];
1205 size_t count = adjacency.offsets[i0 + 1] - adjacency.offsets[i0];
1206
1207 for (size_t i = 0; i < count; ++i)
1208 {
1209 unsigned int a = collapse_remap[edges[i].next];
1210 unsigned int b = collapse_remap[edges[i].prev];
1211
1212 // skip triangles that will get collapsed by i0->i1 collapse or already got collapsed previously
1213 if (a == i1 || b == i1 || a == b)
1214 continue;
1215
1216 // early-out when at least one triangle flips due to a collapse
1217 if (hasTriangleFlip(vertex_positions[a], vertex_positions[b], v0, v1))
1218 {
1219#if TRACE >= 2
1220 printf("edge block %d -> %d: flip welded %d %d %d\n", i0, i1, a, i0, b);
1221#endif
1222
1223 return true;
1224 }
1225 }
1226
1227 return false;
1228}
1229
1230static bool hasTriangleFlips(const EdgeAdjacency& adjacency, const Vector3* vertex_positions, unsigned int i0, const Vector3& v1)
1231{

Callers 2

performEdgeCollapsesFunction · 0.85
solvePositionsFunction · 0.85

Calls 1

hasTriangleFlipFunction · 0.85

Tested by

no test coverage detected