Generate the finest mesh level of detail instead of overshooting it


A level is kept when it is at least half again the size of the previous
one and still under three quarters of the mesh, so another one fits
whenever the last came out below half the index count. The target
doubles after every kept level though, and a target over the three
quarter limit only produces a level that is then thrown away, ending the
loop one short: a 12x12 height field of 864 indexes stopped at 384 with
room for a level up to 647.

Clamp the target to the largest value that can still produce a level and
stop once none can. Both bounds are integer expressions, and the two
comparisons that were already testing the same thresholds move to
integers with them, which drops the narrowing conversion clang-tidy
reported instead of making it explicit and leaves the loop with no float
conversions at all.

Pick-to: 6.12 6.11 6.8
Change-Id: Iffdf93b7cffeb958ab21f0bf9d4210f882efc5dd
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
commit082239e1ea290e859a783cb17371f8971a836bb1
parentfbcf9bb6f5859deb99a88ae7e628920e5783590d
authorAndy Nichols <andy.nichols@qt.io>
committerAndy Nichols <andy.nichols@qt.io>
commit timeFri, 4 Sep 2026 11:44:27 +0000