Skip to content

Heightfield collision events not triggered when scale.y is set to -1 #643

@lazystitan

Description

@lazystitan

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:
  3. Create a heightfield collider with scale.y = -1.0.
  4. Add a dynamic rigid body above the heightfield.
  5. Observe that no collision events are triggered when the body falls onto the heightfield.
  6. Change scale.y to a positive value (e.g., 1.0).
  7. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions