Skip to content

Preserve model bounding radius and write sequence bounding spheres on export - #14

Open
Talvbot wants to merge 2 commits into
Solstice245:mainfrom
sc2-arcade-watcher:fix/sequence-bounding-sphere
Open

Preserve model bounding radius and write sequence bounding spheres on export#14
Talvbot wants to merge 2 commits into
Solstice245:mainfrom
sc2-arcade-watcher:fix/sequence-bounding-sphere

Conversation

@Talvbot

@Talvbot Talvbot commented Aug 1, 2026

Copy link
Copy Markdown

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:

  1. Preserve model boundings radius across import and export. Adds a radius float property to BoundingProperties (not surfaced in the UI), reads it in create_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.
  2. Write the bounding sphere of exported sequences. Assigns model.boundings to each SEQS record in create_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, with gpu.shader.from_builtin stubbed as described in #13):

  • Round trip of 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).
  • Round trips of 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.
  • Regression: a scene built from scratch (armature + animation group, no import) exports byte-identical output before vs after these commits.
  • The addon registers and both operators run on 4.5.4.

Talvbot added 2 commits August 1, 2026 19:12
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant