bevy_rapier
bevy_rapier copied to clipboard
Heightfield collision events not triggered when scale.y is set to -1
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:
- Is this behavior intentional, or is it a bug?
- What is the semantic meaning of the Y-component in the heightfield's
scaleparameter? Does a negative value invert the collision normal or flip the collision surface? Reproduction Steps: - Create a heightfield collider with
scale.y = -1.0. - Add a dynamic rigid body above the heightfield.
- Observe that no collision events are triggered when the body falls onto the heightfield.
- Change
scale.yto a positive value (e.g.,1.0). - Collision events are now triggered as expected. Code Example:
// 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.