dimforge / dimforge/bevy_rapier
Heightfield collision events not triggered when scale.y is set to -1
- Dominant language
- Rust
- Stars
- 1.6k
- Forks
- 282
- PR merge metrics
- No merged PRs in 30d
Description
**Description:**
When using `Collider::heightfield` with a negative Y-axis scale (e.g., `Vec3::new(9., -1., 9.)`), collision events are not triggered. However, setting `scale.y` to a positive value (e.g., `1.0`) works as expected. This raises two questions:
1. Is this behavior intentional, or is it a bug?
2. What is the semantic meaning of the Y-component in the heightfield's `scale` parameter? Does a negative value invert the collision normal or flip the collision surface?
**Reproduction Steps:**
1. Create a heightfield collider with `scale.y = -1.0`.
2. Add a dynamic rigid body above the heightfield.
3. Observe that no collision events are triggered when the body falls onto the heightfield.
4. Change `scale.y` to a positive value (e.g., `1.0`).
5. Collision events are now triggered as expected.
**Code Example:**
```rust
// No collision events when scale.y = -1
commands.spawn((
Transform::from_xyz(0f32, 0f32, 0f32),
RigidBody::Fixed,
)).with_child((
Collider::heightfield(heights, noise_width, noise_long, Vec3::new(9., -1., 9.)),
Transform::from_isometry(
Isometry3d::new(
Vec3::new(4.5, 0., 4.5),
Quat::from_axis_angle(Vec3::new(1.0, 0., 1.0).normalize(), PI),
)
),
));
// Collision events work when scale.y = 1
commands.spawn((
Transform::from_xyz(0f32, 0f32, 0f32),
RigidBody::Fixed,
)).with_child((
Collider::heightfield(heights, noise_width, noise_long, Vec3::new(9., 1., 9.)),
Transform::from_isometry(
Isometry3d::new(
Vec3::new(4.5, 0., 4.5),
Quat::from_axis_angle(Vec3::new(1.0, 0., 1.0).normalize(), PI),
)
),
));
```
**Expected Behavior:**
Collision events should trigger regardless of the sign of `scale.y`, or the documentation should explicitly state if negative scaling is unsupported for heightfields.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.