Skip to content

Option for ShapeCasts to return only face normals #313

Open

Description

@cndheat

A limitation with Parry I've encountered while using Rapier3d to implement a character controller. Sometimes shapecasts will return the normal of a vertex or edge feature when a face normal is necessary for things like wall/ramp sliding logic.

Not sure what the best way to go about implementing this feature would be, somebody in the bevy physics channel suggested adding a force_face_normals field to ShapeCastOptions.

Possible related issue: #193

Activity

  1. atornity commented on Mar 16, 2025

    @atornity

    I need something like this as well for a character controller using avian.

    Unreal engine supports this, it returns the face normal which is the "most opposing" from the cast direction and exposes this as the ImpactNormal on FHitResult.

    /**
     * Normal of the hit in world space, for the object that was hit by the sweep, if any.
     * For example if a sphere hits a flat plane, this is a normalized vector pointing out from the plane.
     * In the case of impact with a corner or edge of a surface, usually the "most opposing" normal (opposed to the query direction) is chosen.
     */
    UPROPERTY()
    FVector_NetQuantizeNormal ImpactNormal;

    I think we should do the same and add it as a field on ShapeCastHit (rather than having a seperate mode as suggested) since a user might need access to both the face normal as well as the usual normal, and there's no reason to perform two casts in that case.

    There might also be times when users might want the normals of all the faces involved but I've personally never needed this myself and that would probably be more complicated to implement.

  2. ThierryBerger commented on Jun 27, 2025

    @ThierryBerger
    Contributor

    Can https://docs.rs/parry3d/latest/parry3d/shape/trait.Shape.html#method.feature_normal_at_point help with this ?

    The algorithms behind shapecasts don't always end up going through faces, which make it impractical to leak options onto ShapeCastOptions 🤔 ; it could be a bonus option not supported by all shapes, but such API is a bit unintuitive.

  3. cndheat commented on Jun 27, 2025

    @cndheat
    Author

    Shape casts don't return a FeatureID, additionally a FeatureID cannot be guaranteed to be a Face which complicates things.

  4. MinimalCpp commented on Nov 5, 2026

    @MinimalCpp

    #463 fixes part of this for heightfields: with HeightFieldFlags::FIX_INTERNAL_EDGES, a shape cast onto a heightfield no longer returns the normal of an internal edge between coplanar triangles; the hit's normal is projected into the normal cone of the surface around the witness point. It adds no option to ShapeCastOptions and leaves other shapes as they are.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-EnhancementNew feature or requestP-HighquestionFurther information is requested

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions