Overview/Examples/3. Building a level-of-detail chain
worked example 3 of 6
Building a level-of-detail chain
One decimator, three targets: call run three times with falling triangle budgets and write each result. Nothing survives between runs, so reuse is free.
Example 3 of six - the program sits on the examples page, and this page takes it from the running end: the console it produces, the Status values that end it early, and the options worth changing.
What it prints
in 620400 tris
lod1 160000 tris err 0.0021
lod2 40000 tris err 0.0137
lod3 10000 tris err 0.0719
max_applied_error climbs as the budget falls; on the turbine blade it stays small until the last step, where the thin trailing edges start to cost.
When it goes wrong
- No target was set
- With all three of
target_triangles,target_ratioandmax_errorleft at zero,runreturnsStatus::InvalidOptionand the mesh is untouched. - The target is below what locks allow
target_reachedcomes backfalsewith statusOk: the mesh is valid, just larger than asked, because sharp edges were pinned.- Ridges round off
- Set
preserve_ridges=trueand aridge_angle_degthat matches the part, or the collapse metric will trade a sharp arris for error it is allowed to spend.
Variations
- By ratio, not count
- Set
target_ratio=0.1fto keep a tenth of whatever came in, independent of the input size. - Hard error ceiling
- Set
max_errorand leave the count targets zero to decimate only as far as a deviation budget permits.