Add inertia tensor and angular collision impulses#152
Merged
Conversation
Replace scalar inertia with a diagonal inertia tensor in the Mass component. Extend narrowphase collision functions to return world-space contact points. Rewrite collision response to apply angular impulses from off-center contacts using the standard rigid-body impulse formula. - Mass struct gains inverse_inertia_tensor field (Vec3, body-local diagonal) - Factory methods: Mass::from_sphere, from_aabb, from_capsule with correct principal moments of inertia - All intersect_* functions now return (normal, depth, contact_point) - CollisionEvent gains contact_point field - apply_velocity_response uses full rotational impulse formula: effective mass denominator includes I^-1 cross terms, angular velocity changes from both normal and friction impulses - Backward compatible: Mass::new produces spherically symmetric tensor, head-on sphere collisions produce zero angular change Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Deploying euca-engine with
|
| Latest commit: |
762d80f
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://71eb512b.euca-engine.pages.dev |
| Branch Preview URL: | https://worktree-agent-a8e4aa45.euca-engine.pages.dev |
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
Masscomponent with a diagonalinverse_inertia_tensor(Vec3) and add factory methodsfrom_sphere,from_aabb,from_capsulefor accurate per-shape inertiaapply_velocity_responsewith the standard rigid-body impulse formula: off-center contacts produce angular velocity changes viar x Jtorques, and the effective mass denominator includes rotational inertia termsCollisionEventgains acontact_pointfieldBackward compatibility
Mass::new(mass, inertia)produces a spherically symmetric tensor identical to the previous scalar behaviorr x n == 0so angular impulse is zero (regression-tested)Test plan
Mass::newproduces correct splat tensorMass::from_sphere,from_aabb,from_capsuleproduce correct valuesMass::infiniteproduces zero tensor(Vec3, f32, Vec3)return typecargo check,cargo clippy -- -D warnings,cargo fmt --checkclean🤖 Generated with Claude Code