Auto-fix for GEOMETRY_FAR_FROM_ORIGIN — relocates the offset
out of the geometry's quantisation range and into every
referencing mesh's matrix. Lighter than introducing a
SceneTransform: just two mutations per fix call (the
geometry's aabb and N mesh.matrix slots).
Why this preserves world positions. With centroid
c = (aabb_min + aabb_max) / 2, dequantisation gives
D = aabb_min + (aabb_max - aabb_min) · compressed/65535.
Shifting the AABB by -c shifts dequantised positions by -c
uniformly. To keep world positions unchanged, every referencing
mesh's matrix must apply +c:
M (D) = world position before
M' (D - c) = world position after
M' = M · T(c) makes them equal because
M' (D - c) = M T(c) (D - c) = M (D - c + c) = M D.
Where T(c) is a pure-translation Mat4 with c in its
translation column. Applied as a right-multiplication on each
mesh's local matrix, so any parent SceneTransform chain
upstream is left alone.
Idempotent: {fixed: false} when the centroid magnitude is
already below RECENTER_EPS (already centred or
sub-millimetre offset).
Sibling fix considered: stash the offset in a new
SceneTransform parented to every referencing mesh. Heavier
(one new transform allocation, plus parent-transform
re-wiring) but instances would share the offset rather than
repeating it on every mesh. Out of scope for this iteration.
Auto-fix for
GEOMETRY_FAR_FROM_ORIGIN— relocates the offset out of the geometry's quantisation range and into every referencing mesh's matrix. Lighter than introducing aSceneTransform: just two mutations per fix call (the geometry'saabband Nmesh.matrixslots).Why this preserves world positions. With centroid
c = (aabb_min + aabb_max) / 2, dequantisation givesD = aabb_min + (aabb_max - aabb_min) · compressed/65535. Shifting the AABB by-cshifts dequantised positions by-cuniformly. To keep world positions unchanged, every referencing mesh's matrix must apply+c:M (D) = world position before M' (D - c) = world position after M' = M · T(c) makes them equal because M' (D - c) = M T(c) (D - c) = M (D - c + c) = M D.
Where
T(c)is a pure-translation Mat4 withcin its translation column. Applied as a right-multiplication on each mesh's local matrix, so any parent SceneTransform chain upstream is left alone.Idempotent:
{fixed: false}when the centroid magnitude is already below RECENTER_EPS (already centred or sub-millimetre offset).Sibling fix considered: stash the offset in a new SceneTransform parented to every referencing mesh. Heavier (one new transform allocation, plus parent-transform re-wiring) but instances would share the offset rather than repeating it on every mesh. Out of scope for this iteration.