You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Switch LOD generation to use iterative simplification
Instead of simplifying every LOD from the original down to an
increasing number of triangles, we simplify each LOD from the previous
LOD and stop when the simplification can't proceed further.
This has a few benefits:
- It's significantly faster; using sparse flag helps ensure that
subsequent simplifications after the first one are increasingly
cheaper.
- It results in higher quality attributes on generated LODs; attribute
quadrics reduce the quality of attribute preservation the more they
are accumulated, so recomputing them from intermediate geometry helps.
- It results in monotonic appearance: if a feature is reduced in a
higher LOD, it will stay reduced or get reduced more significantly in
lower LODs. This is not a significant problem right now, but can be
helpful to ensure if the number of LODs increases or some newer
features get enabled.
print_verbose(" LOD stop: got " + itos(new_index_count / 3) + " triangles when asking for " + itos(target_index_count / 3));
517
526
break;
518
527
}
519
-
if (new_index_count > 5000000) {
520
-
// This limit theoretically shouldn't be needed, but it's here
521
-
// as an ad-hoc fix to prevent a crash with complex meshes.
522
-
// The crash still happens with limit of 6000000, but 5000000 works.
523
-
// In the future, identify what's causing that crash and fix it.
524
-
WARN_PRINT("Mesh LOD generation failed for mesh " + get_name() + " surface " + itos(i) + ", mesh is too complex. Some automatic LODs were not generated.");
// We need to remap the LOD indices back to the original vertex array; note that we already copied new_indices into current_indices for subsequent iteration.
529
535
{
530
536
int *ptrw = new_indices.ptrw();
531
537
for (unsignedint j = 0; j < new_index_count; j++) {
0 commit comments