@@ -366,7 +366,7 @@ static bool appendMeshlet(meshopt_Meshlet& meshlet, unsigned int a, unsigned int
366
366
return result;
367
367
}
368
368
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)
370
370
{
371
371
unsigned int best_triangle = ~0u ;
372
372
int best_priority = 5 ;
@@ -406,24 +406,13 @@ static unsigned int getNeighborTriangle(const meshopt_Meshlet& meshlet, const Co
406
406
if (priority > best_priority)
407
407
continue ;
408
408
409
- float score = 0 ;
409
+ const Cone& tri_cone = triangles[triangle] ;
410
410
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 ;
419
414
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);
427
416
428
417
// note that topology-based priority is always more important than the score
429
418
// 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
822
811
if (meshlet_offset == 0 && meshlet.triangle_count == 0 )
823
812
best_triangle = initial_seed;
824
813
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);
826
815
827
816
bool split = false ;
828
817
0 commit comments