Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Take entity bevy transform scale into account on writeback #510

Merged
merged 5 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
- Derive `Debug` for `LockedAxes`.
- Expose `is_sliding_down_slope` to both `MoveShapeOutput` and `KinematicCharacterControllerOutput`.

### Fix

- Fix rigidbodies never going to sleep when a scale was applied to their `Transform`.

## v0.26.0 (05 May 2024)

**This is an update to Rapier 0.19 which includes several stability improvements
Expand Down
5 changes: 5 additions & 0 deletions src/plugin/systems/rigid_body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,11 @@ pub fn writeback_rigid_bodies(
}

if let Some(mut transform) = transform {
// NOTE: Rapier's `RigidBody` doesn't know its own scale as it is encoded
// directly within its collider, so we have to retrieve it from
// the scale of its bevy transform.
interpolated_pos = interpolated_pos.with_scale(transform.scale);

// NOTE: we query the parent’s global transform here, which is a bit
// unfortunate (performance-wise). An alternative would be to
// deduce the parent’s global transform from the current entity’s
Expand Down