Browse Source

Added documentation on how to obtain the correct normal for CastShape and CollideShape

Jorrit Rouwe 3 years ago
parent
commit
573be49e0f

+ 1 - 1
Jolt/Physics/Collision/CollideShape.h

@@ -39,7 +39,7 @@ public:
 
 	Vec3					mContactPointOn1;			///< Contact point on shape 1 (in world space)
 	Vec3					mContactPointOn2;			///< Contact point on shape 2 (in world space)
-	Vec3					mPenetrationAxis;			///< Direction to move shape 2 out of collision along the shortest path (magnitude is meaningless, in world space)
+	Vec3					mPenetrationAxis;			///< Direction to move shape 2 out of collision along the shortest path (magnitude is meaningless, in world space). You can use -mPenetrationAxis.Normalized() as contact normal.
 	float					mPenetrationDepth;			///< Penetration depth (move shape 2 by this distance to resolve the collision)
 	SubShapeID				mSubShapeID1;				///< Sub shape ID that identifies the face on shape 1
 	SubShapeID				mSubShapeID2;				///< Sub shape ID that identifies the face on shape 2

+ 2 - 1
Jolt/Physics/Collision/Shape/Shape.h

@@ -199,7 +199,8 @@ public:
 	/// Get the material assigned to a particular sub shape ID
 	virtual const PhysicsMaterial *	GetMaterial(const SubShapeID &inSubShapeID) const = 0;
 
-	/// Get the surface normal of a particular sub shape ID and point on surface (all vectors are relative to center of mass for this shape)
+	/// Get the surface normal of a particular sub shape ID and point on surface (all vectors are relative to center of mass for this shape).
+	/// Note: When you have a CollideShapeResult or ShapeCastResult you should use -mPenetrationAxis.Normalized() as contact normal as GetSurfaceNormal will only return face normals (and not vertex or edge normals).
 	virtual Vec3					GetSurfaceNormal(const SubShapeID &inSubShapeID, Vec3Arg inLocalSurfacePosition) const = 0;
 
 	/// Get the user data of a particular sub shape ID

+ 2 - 1
Jolt/Physics/Collision/TransformedShape.h

@@ -116,7 +116,8 @@ public:
 		return sub_shape_id;
 	}
 
-	/// Get surface normal of a particular sub shape and its world space surface position on this body
+	/// Get surface normal of a particular sub shape and its world space surface position on this body.
+	/// Note: When you have a CollideShapeResult or ShapeCastResult you should use -mPenetrationAxis.Normalized() as contact normal as GetWorldSpaceSurfaceNormal will only return face normals (and not vertex or edge normals).
 	inline Vec3					GetWorldSpaceSurfaceNormal(const SubShapeID &inSubShapeID, Vec3Arg inPosition) const
 	{
 		Mat44 inv_com = GetInverseCenterOfMassTransform();