Preserve model bounding radius and write sequence bounding spheres on export - #14
Open
Talvbot wants to merge 2 commits into
Open
Preserve model bounding radius and write sequence bounding spheres on export#14Talvbot wants to merge 2 commits into
Talvbot wants to merge 2 commits into
Conversation
Import discarded MODL.boundings.radius and export recomputed it as half the bounding box diagonal, inflating it by ~sqrt(3) on every round trip (e.g. Carrier.m3: 2.60467 -> 4.51142). Store the imported radius in a new BoundingProperties.radius property and write it back on export, keeping the computed half-diagonal as a fallback when no radius is stored (0), so scenes authored from scratch behave as before.
SEQS.bounding_sphere was declared in structures.xml but never assigned by the exporter, so every exported sequence carried an all-zero bounding sphere, while all of Blizzard's own models populate it. Write the model boundings into each sequence, which matches Blizzard's output exactly for models whose sequences share the model bounds, and is a conservative approximation for those with genuinely per-sequence bounds.
Talvbot
marked this pull request as ready for review
August 1, 2026 17:37
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed fix for #13 — see that issue for the full evidence (root cause, stock-model survey, and what remains a design call). If you'd rather take one of the other approaches listed there (per-sequence properties, or reusing the SDMB animated-bounds data), happy to rework this accordingly.
Two commits, deliberately separable:
radiusfloat property toBoundingProperties(not surfaced in the UI), reads it increate_bounding, and writes it back on export. The computed half-diagonal remains the fallback whenever the stored radius is 0 — which covers scenes authored from scratch and every existing user scene (the new property deserialises to 0 there), so nothing changes for them.model.boundingsto eachSEQSrecord increate_sequences. This matches Blizzard's output exactly for the (majority) class of stock models whose sequences all share the model bounds, and is a conservative over-approximation for models with genuinely per-sequence animated bounds. Making those exact — either per-sequence properties or reuse of the SDMB animated-bounds data — is left as a possible follow-up rather than done here unasked (see the alternatives in Exported sequence bounding spheres are always zero; model bounding radius is not preserved on round trip #13).Verification
All on Blender 4.5.4 LTS, headless (
--factory-startup --background, withgpu.shader.from_builtinstubbed as described in #13):Carrier_Taldarim.m3: all 9 sequence spheres and the model sphere now come out equal to stock (radius 2.60467 in and out; previously sequences were all-zero and the model radius became 4.51142).Marine.m3,Battlecruiser.m3,SiegeTank.m3,Zergling.m3: model-level BNDS (min/max/radius) preserved exactly in all four; sequence spheres populated with the model bounds.