File tree 2 files changed +12
-10
lines changed
2 files changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -345,13 +345,15 @@ namespace spartan::geometry_processing
345
345
346
346
// loop until the current triangle count is less than or equal to the target triangle count
347
347
std::vector<uint32_t > indices_simplified (index_count);
348
- uint32_t iteration_count = 0 ;
349
348
while (current_triangle_count > triangle_target)
350
349
{
351
350
float threshold = 1 .0f - reduction;
352
351
size_t target_index_count = static_cast <size_t >(index_count * threshold);
353
-
354
- index_count = meshopt_simplify (
352
+
353
+ if (target_index_count < 3 )
354
+ break ;
355
+
356
+ size_t index_count_new = meshopt_simplify (
355
357
indices_simplified.data (),
356
358
indices.data (),
357
359
index_count,
@@ -361,16 +363,16 @@ namespace spartan::geometry_processing
361
363
target_index_count,
362
364
error
363
365
);
364
-
366
+
367
+ // break if meshopt_simplify can't simplify further
368
+ if (index_count_new == index_count)
369
+ break ;
370
+
371
+ index_count = index_count_new;
365
372
indices.assign (indices_simplified.begin (), indices_simplified.begin () + index_count);
366
373
current_triangle_count = index_count / 3 ;
367
374
reduction = fmodf (reduction + 0 .1f , 1 .0f );
368
375
error = fmodf (error + 0 .1f , 1 .0f );
369
-
370
- // break if meshopt_simplify gives up
371
- iteration_count++;
372
- if (iteration_count > 10 )
373
- break ;
374
376
}
375
377
}
376
378
Original file line number Diff line number Diff line change @@ -946,7 +946,7 @@ namespace spartan
946
946
// create a btBvhTriangleMeshShape using the index-vertex array
947
947
btBvhTriangleMeshShape* shape_triangle_mesh = new btBvhTriangleMeshShape (
948
948
index_vertex_array,
949
- true // BVH for optimized collisions
949
+ true // bvh for optimized collisions
950
950
);
951
951
952
952
// we only need to set the scale as the rotation and position is set set in btMotionState
You can’t perform that action at this time.
0 commit comments