Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
ShapeCastResult Class Reference

Result of a shape cast test. More...

#include <ShapeCast.h>

Inheritance diagram for ShapeCastResult:
CollideShapeResult

Public Member Functions

JPH_OVERRIDE_NEW_DELETE ShapeCastResult ()=default
 Default constructor.
 
 ShapeCastResult (float inFraction, Vec3Arg inContactPoint1, Vec3Arg inContactPoint2, Vec3Arg inContactNormalOrPenetrationDepth, bool inBackFaceHit, const SubShapeID &inSubShapeID1, const SubShapeID &inSubShapeID2, const BodyID &inBodyID2)
 
float GetEarlyOutFraction () const
 Function required by the CollisionCollector. A smaller fraction is considered to be a 'better hit'. For rays/cast shapes we can just use the collision fraction. The fraction and penetration depth are combined in such a way that deeper hits at fraction 0 go first.
 
ShapeCastResult Reversed (Vec3Arg inWorldSpaceCastDirection) const
 
- Public Member Functions inherited from CollideShapeResult
JPH_OVERRIDE_NEW_DELETE CollideShapeResult ()=default
 Default constructor.
 
 CollideShapeResult (Vec3Arg inContactPointOn1, Vec3Arg inContactPointOn2, Vec3Arg inPenetrationAxis, float inPenetrationDepth, const SubShapeID &inSubShapeID1, const SubShapeID &inSubShapeID2, const BodyID &inBodyID2)
 Constructor.
 
float GetEarlyOutFraction () const
 Function required by the CollisionCollector. A smaller fraction is considered to be a 'better hit'. We use -penetration depth to get the hit with the biggest penetration depth.
 
CollideShapeResult Reversed () const
 Reverses the hit result, swapping contact point 1 with contact point 2 etc.
 

Public Attributes

float mFraction
 This is the fraction where the shape hit the other shape: CenterOfMassOnHit = Start + value * (End - Start)
 
bool mIsBackFaceHit
 True if the shape was hit from the back side.
 
- Public Attributes inherited from CollideShapeResult
Vec3 mContactPointOn1
 Contact point on the surface of shape 1 (in world space or relative to base offset)
 
Vec3 mContactPointOn2
 Contact point on the surface of shape 2 (in world space or relative to base offset). If the penetration depth is 0, this will be the same as mContactPointOn1.
 
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.
 
BodyID mBodyID2
 BodyID to which shape 2 belongs to.
 
Face mShape1Face
 Colliding face on shape 1 (optional result, in world space or relative to base offset)
 
Face mShape2Face
 Colliding face on shape 2 (optional result, in world space or relative to base offset)
 

Additional Inherited Members

- Public Types inherited from CollideShapeResult
using Face = StaticArray< Vec3, 32 >
 

Detailed Description

Result of a shape cast test.

Constructor & Destructor Documentation

◆ ShapeCastResult() [1/2]

JPH_OVERRIDE_NEW_DELETE ShapeCastResult::ShapeCastResult ( )
default

Default constructor.

◆ ShapeCastResult() [2/2]

ShapeCastResult::ShapeCastResult ( float  inFraction,
Vec3Arg  inContactPoint1,
Vec3Arg  inContactPoint2,
Vec3Arg  inContactNormalOrPenetrationDepth,
bool  inBackFaceHit,
const SubShapeID inSubShapeID1,
const SubShapeID inSubShapeID2,
const BodyID inBodyID2 
)
inline

Constructor

Parameters
inFractionFraction at which the cast hit
inContactPoint1Contact point on shape 1
inContactPoint2Contact point on shape 2
inContactNormalOrPenetrationDepthContact normal pointing from shape 1 to 2 or penetration depth vector when the objects are penetrating (also from 1 to 2)
inBackFaceHitIf this hit was a back face hit
inSubShapeID1Sub shape id for shape 1
inSubShapeID2Sub shape id for shape 2
inBodyID2BodyID that was hit

Member Function Documentation

◆ GetEarlyOutFraction()

float ShapeCastResult::GetEarlyOutFraction ( ) const
inline

Function required by the CollisionCollector. A smaller fraction is considered to be a 'better hit'. For rays/cast shapes we can just use the collision fraction. The fraction and penetration depth are combined in such a way that deeper hits at fraction 0 go first.

◆ Reversed()

ShapeCastResult ShapeCastResult::Reversed ( Vec3Arg  inWorldSpaceCastDirection) const
inline

Reverses the hit result, swapping contact point 1 with contact point 2 etc.

Parameters
inWorldSpaceCastDirectionDirection of the shape cast in world space

Member Data Documentation

◆ mFraction

float ShapeCastResult::mFraction

This is the fraction where the shape hit the other shape: CenterOfMassOnHit = Start + value * (End - Start)

◆ mIsBackFaceHit

bool ShapeCastResult::mIsBackFaceHit

True if the shape was hit from the back side.


The documentation for this class was generated from the following file: