Skip to content

Commit 62b992b

Browse files
committed
clusterizer: Remove live triangle scoring from getNeighborTriangle
The liveness based scoring is now part of the seed selection, so we no longer need special cases in getNeighborTriangle.
1 parent b8094a3 commit 62b992b

File tree

1 file changed

+7
-18
lines changed

1 file changed

+7
-18
lines changed

src/clusterizer.cpp

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ static bool appendMeshlet(meshopt_Meshlet& meshlet, unsigned int a, unsigned int
366366
return result;
367367
}
368368

369-
static unsigned int getNeighborTriangle(const meshopt_Meshlet& meshlet, const Cone* meshlet_cone, const unsigned int* meshlet_vertices, const unsigned int* indices, const TriangleAdjacency2& adjacency, const Cone* triangles, const unsigned int* live_triangles, const unsigned char* used, float meshlet_expected_radius, float cone_weight)
369+
static unsigned int getNeighborTriangle(const meshopt_Meshlet& meshlet, const Cone& meshlet_cone, const unsigned int* meshlet_vertices, const unsigned int* indices, const TriangleAdjacency2& adjacency, const Cone* triangles, const unsigned int* live_triangles, const unsigned char* used, float meshlet_expected_radius, float cone_weight)
370370
{
371371
unsigned int best_triangle = ~0u;
372372
int best_priority = 5;
@@ -406,24 +406,13 @@ static unsigned int getNeighborTriangle(const meshopt_Meshlet& meshlet, const Co
406406
if (priority > best_priority)
407407
continue;
408408

409-
float score = 0;
409+
const Cone& tri_cone = triangles[triangle];
410410

411-
// caller selects one of two scoring functions: geometrical (based on meshlet cone) or topological (based on remaining triangles)
412-
if (meshlet_cone)
413-
{
414-
const Cone& tri_cone = triangles[triangle];
415-
416-
float dx = tri_cone.px - meshlet_cone->px, dy = tri_cone.py - meshlet_cone->py, dz = tri_cone.pz - meshlet_cone->pz;
417-
float distance = getDistance(dx, dy, dz, cone_weight < 0);
418-
float spread = tri_cone.nx * meshlet_cone->nx + tri_cone.ny * meshlet_cone->ny + tri_cone.nz * meshlet_cone->nz;
411+
float dx = tri_cone.px - meshlet_cone.px, dy = tri_cone.py - meshlet_cone.py, dz = tri_cone.pz - meshlet_cone.pz;
412+
float distance = getDistance(dx, dy, dz, cone_weight < 0);
413+
float spread = tri_cone.nx * meshlet_cone.nx + tri_cone.ny * meshlet_cone.ny + tri_cone.nz * meshlet_cone.nz;
419414

420-
score = getMeshletScore(distance, spread, cone_weight, meshlet_expected_radius);
421-
}
422-
else
423-
{
424-
// each live_triangles entry is >= 1 since it includes the current triangle we're processing
425-
score = float(live_triangles[a] + live_triangles[b] + live_triangles[c] - 3);
426-
}
415+
float score = getMeshletScore(distance, spread, cone_weight, meshlet_expected_radius);
427416

428417
// note that topology-based priority is always more important than the score
429418
// this helps maintain reasonable effectiveness of meshlet data and reduces scoring cost
@@ -822,7 +811,7 @@ size_t meshopt_buildMeshletsFlex(meshopt_Meshlet* meshlets, unsigned int* meshle
822811
if (meshlet_offset == 0 && meshlet.triangle_count == 0)
823812
best_triangle = initial_seed;
824813
else
825-
best_triangle = getNeighborTriangle(meshlet, &meshlet_cone, meshlet_vertices, indices, adjacency, triangles, live_triangles, used, meshlet_expected_radius, cone_weight);
814+
best_triangle = getNeighborTriangle(meshlet, meshlet_cone, meshlet_vertices, indices, adjacency, triangles, live_triangles, used, meshlet_expected_radius, cone_weight);
826815

827816
bool split = false;
828817

0 commit comments

Comments
 (0)