Option for ShapeCasts to return only face normals
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: https://github.com/dimforge/parry/issues/193
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.
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.
Shape casts don't return a FeatureID, additionally a FeatureID cannot be guaranteed to be a Face which complicates things.