You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Option for ShapeCasts to return only face normals #313
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.
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.
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.
#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.
Activity
atornity commentedon Mar 16, 2025
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
ImpactNormalonFHitResult.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.
ThierryBerger commentedon Jun 27, 2025
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.
cndheat commentedon Jun 27, 2025
Shape casts don't return a FeatureID, additionally a FeatureID cannot be guaranteed to be a Face which complicates things.
MinimalCpp commentedon Nov 5, 2026
#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 toShapeCastOptionsand leaves other shapes as they are.