Repository navigation
fix(physics): collider auto-fit no longer inflates rotated shapes on load - #113
Open
Drima-code wants to merge 1 commit into
Open
Drima-code wants to merge 1 commit into
Drima-code wants to merge 1 commit into
Conversation
…load Auto-fit runs for any default-valued CollisionShapeData, which includes every scene load of a unit-mesh object whose collider was never resized. The fit took a world-axis AABB of the mesh and mapped its corners back into local space, which is only exact without rotation: a 15 degree Y platform scaled (5, 0.5, 4) came back with half extents (0.70, 0.5, 0.81), so after reopening the scene its collision no longer matched its mesh, and the inflated values were then saved. Bounds are now accumulated per corner in the collider's own local space, and a fit that already matches the stored shape is not written, which also stops 0.5 drifting to 0.49999997 on unrotated objects. tests/auto_fit_rotated.rs fails on the old code with exactly the inflated extents above and passes with the fix. Also validated in a running editor: save, close, reopen and save again now produce a scene that is identical apart from session entity ids. Assisted-by: Claude Opus 5.5 (claude-opus-5-5)
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.
Summary
Auto-fit resizes any
CollisionShapeDatathat still has its default values, which includes every scene load of a unit-mesh object whose collider was never resized (a cube with a default box collider). The fit built a world-axis AABB of the mesh and mapped its corners back into local space, which is only exact without rotation. So reopening a scene silently grew the collider of every rotated object, and the inflated values were then saved.Example: a cube rotated 15 degrees about Y and scaled (5, 0.5, 4) reopened with half extents (0.70, 0.5, 0.8125) instead of (0.5, 0.5, 0.5), so its collision no longer matched its mesh. Unrotated objects also drifted from 0.5 to 0.49999997 on each load.
Changes
combined_world_aabbbecomescombined_local_aabb: each mesh AABB corner is transformed straight into the collider entity's local space (inverse(entity GlobalTransform) * child GlobalTransform * corner), so the bounds are exact under rotation and non-uniform scale.crates/renzora_physics/tests/auto_fit_rotated.rs.RELEASE_NOTES.mdline.Related Issues
None filed; found while evaluating the editor for a project.
AI Assistance
Checklist
renzora check): not run in the container; see Testingrenzora test): only the new test was run; see TestingmainAssisted-by:commit trailerTesting
Run natively on Linux (Rust 1.95.0) from an r1-alpha7 checkout carrying the same change (
auto_fit.rsis byte-identical between r1-alpha7 andmain).cargo test --profile dist -p renzora_physics --test auto_fit_rotated: passes. With the originalauto_fit.rsswapped back in, it fails withhalf extents changed to Vec3(0.70000005, 0.5, 0.8125), the same values seen in the editor.cargo clippy --profile dist --no-deps -p renzora_physics -- -D warnings -A clippy::too_many_arguments -A clippy::type_complexityreports nothing in the changed code (the only hit on r1-alpha7 is theunused_mutatlib.rs:255, already fixed onmain).