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

#include <NarrowPhaseQuery.h>

Inheritance diagram for NarrowPhaseQuery:
NonCopyable

Public Member Functions

void Init (BodyLockInterface &inBodyLockInterface, BroadPhaseQuery &inBroadPhaseQuery)
 Initialize the interface (should only be called by PhysicsSystem)
 
bool CastRay (const RRayCast &inRay, RayCastResult &ioHit, const BroadPhaseLayerFilter &inBroadPhaseLayerFilter={ }, const ObjectLayerFilter &inObjectLayerFilter={ }, const BodyFilter &inBodyFilter={ }) const
 
void CastRay (const RRayCast &inRay, const RayCastSettings &inRayCastSettings, CastRayCollector &ioCollector, const BroadPhaseLayerFilter &inBroadPhaseLayerFilter={ }, const ObjectLayerFilter &inObjectLayerFilter={ }, const BodyFilter &inBodyFilter={ }, const ShapeFilter &inShapeFilter={ }) const
 
void CollidePoint (RVec3Arg inPoint, CollidePointCollector &ioCollector, const BroadPhaseLayerFilter &inBroadPhaseLayerFilter={ }, const ObjectLayerFilter &inObjectLayerFilter={ }, const BodyFilter &inBodyFilter={ }, const ShapeFilter &inShapeFilter={ }) const
 
void CollideShape (const Shape *inShape, Vec3Arg inShapeScale, RMat44Arg inCenterOfMassTransform, const CollideShapeSettings &inCollideShapeSettings, RVec3Arg inBaseOffset, CollideShapeCollector &ioCollector, const BroadPhaseLayerFilter &inBroadPhaseLayerFilter={ }, const ObjectLayerFilter &inObjectLayerFilter={ }, const BodyFilter &inBodyFilter={ }, const ShapeFilter &inShapeFilter={ }) const
 
void CollideShapeWithInternalEdgeRemoval (const Shape *inShape, Vec3Arg inShapeScale, RMat44Arg inCenterOfMassTransform, const CollideShapeSettings &inCollideShapeSettings, RVec3Arg inBaseOffset, CollideShapeCollector &ioCollector, const BroadPhaseLayerFilter &inBroadPhaseLayerFilter={ }, const ObjectLayerFilter &inObjectLayerFilter={ }, const BodyFilter &inBodyFilter={ }, const ShapeFilter &inShapeFilter={ }) const
 Same as CollideShape, but uses InternalEdgeRemovingCollector to remove internal edges from the collision results (a.k.a. ghost collisions)
 
void CastShape (const RShapeCast &inShapeCast, const ShapeCastSettings &inShapeCastSettings, RVec3Arg inBaseOffset, CastShapeCollector &ioCollector, const BroadPhaseLayerFilter &inBroadPhaseLayerFilter={ }, const ObjectLayerFilter &inObjectLayerFilter={ }, const BodyFilter &inBodyFilter={ }, const ShapeFilter &inShapeFilter={ }) const
 
void CollectTransformedShapes (const AABox &inBox, TransformedShapeCollector &ioCollector, const BroadPhaseLayerFilter &inBroadPhaseLayerFilter={ }, const ObjectLayerFilter &inObjectLayerFilter={ }, const BodyFilter &inBodyFilter={ }, const ShapeFilter &inShapeFilter={ }) const
 Collect all leaf transformed shapes that fall inside world space box inBox.
 
- Public Member Functions inherited from NonCopyable
 NonCopyable ()=default
 
 NonCopyable (const NonCopyable &)=delete
 
void operator= (const NonCopyable &)=delete
 

Detailed Description

Class that provides an interface for doing precise collision detection against the broad and then the narrow phase. Unlike a BroadPhaseQuery, the NarrowPhaseQuery will test against shapes and will return collision information against triangles, spheres etc.

Member Function Documentation

◆ CastRay() [1/2]

void NarrowPhaseQuery::CastRay ( const RRayCast inRay,
const RayCastSettings inRayCastSettings,
CastRayCollector ioCollector,
const BroadPhaseLayerFilter inBroadPhaseLayerFilter = { },
const ObjectLayerFilter inObjectLayerFilter = { },
const BodyFilter inBodyFilter = { },
const ShapeFilter inShapeFilter = { } 
) const

Cast a ray, allows collecting multiple hits. Note that this version is more flexible but also slightly slower than the CastRay function that returns only a single hit. If you want the surface normal of the hit use Body::GetWorldSpaceSurfaceNormal(collected sub shape ID, inRay.GetPointOnRay(collected fraction)) on body with collected body ID.

◆ CastRay() [2/2]

JPH_NAMESPACE_BEGIN bool NarrowPhaseQuery::CastRay ( const RRayCast inRay,
RayCastResult ioHit,
const BroadPhaseLayerFilter inBroadPhaseLayerFilter = { },
const ObjectLayerFilter inObjectLayerFilter = { },
const BodyFilter inBodyFilter = { } 
) const

Cast a ray and find the closest hit. Returns true if it finds a hit. Hits further than ioHit.mFraction will not be considered and in this case ioHit will remain unmodified (and the function will return false). Convex objects will be treated as solid (meaning if the ray starts inside, you'll get a hit fraction of 0) and back face hits against triangles are returned. If you want the surface normal of the hit use Body::GetWorldSpaceSurfaceNormal(ioHit.mSubShapeID2, inRay.GetPointOnRay(ioHit.mFraction)) on body with ID ioHit.mBodyID.

◆ CastShape()

void NarrowPhaseQuery::CastShape ( const RShapeCast inShapeCast,
const ShapeCastSettings inShapeCastSettings,
RVec3Arg  inBaseOffset,
CastShapeCollector ioCollector,
const BroadPhaseLayerFilter inBroadPhaseLayerFilter = { },
const ObjectLayerFilter inObjectLayerFilter = { },
const BodyFilter inBodyFilter = { },
const ShapeFilter inShapeFilter = { } 
) const

Cast a shape and report any hits to ioCollector

Parameters
inShapeCastThe shape cast and its position and direction
inShapeCastSettingsSettings for the shape cast
inBaseOffsetAll hit results will be returned relative to this offset, can be zero to get results in world position, but when you're testing far from the origin you get better precision by picking a position that's closer e.g. inShapeCast.mCenterOfMassStart.GetTranslation() since floats are most accurate near the origin
ioCollectorCollector that receives the hits
inBroadPhaseLayerFilterFilter that filters at broadphase level
inObjectLayerFilterFilter that filters at layer level
inBodyFilterFilter that filters at body level
inShapeFilterFilter that filters at shape level

◆ CollectTransformedShapes()

void NarrowPhaseQuery::CollectTransformedShapes ( const AABox inBox,
TransformedShapeCollector ioCollector,
const BroadPhaseLayerFilter inBroadPhaseLayerFilter = { },
const ObjectLayerFilter inObjectLayerFilter = { },
const BodyFilter inBodyFilter = { },
const ShapeFilter inShapeFilter = { } 
) const

Collect all leaf transformed shapes that fall inside world space box inBox.

◆ CollidePoint()

void NarrowPhaseQuery::CollidePoint ( RVec3Arg  inPoint,
CollidePointCollector ioCollector,
const BroadPhaseLayerFilter inBroadPhaseLayerFilter = { },
const ObjectLayerFilter inObjectLayerFilter = { },
const BodyFilter inBodyFilter = { },
const ShapeFilter inShapeFilter = { } 
) const

Check if inPoint is inside any shapes. For this tests all shapes are treated as if they were solid. For a mesh shape, this test will only provide sensible information if the mesh is a closed manifold. For each shape that collides, ioCollector will receive a hit

◆ CollideShape()

void NarrowPhaseQuery::CollideShape ( const Shape inShape,
Vec3Arg  inShapeScale,
RMat44Arg  inCenterOfMassTransform,
const CollideShapeSettings inCollideShapeSettings,
RVec3Arg  inBaseOffset,
CollideShapeCollector ioCollector,
const BroadPhaseLayerFilter inBroadPhaseLayerFilter = { },
const ObjectLayerFilter inObjectLayerFilter = { },
const BodyFilter inBodyFilter = { },
const ShapeFilter inShapeFilter = { } 
) const

Collide a shape with the system

Parameters
inShapeShape to test
inShapeScaleScale in local space of shape
inCenterOfMassTransformCenter of mass transform for the shape
inCollideShapeSettingsSettings
inBaseOffsetAll hit results will be returned relative to this offset, can be zero to get results in world position, but when you're testing far from the origin you get better precision by picking a position that's closer e.g. inCenterOfMassTransform.GetTranslation() since floats are most accurate near the origin
ioCollectorCollector that receives the hits
inBroadPhaseLayerFilterFilter that filters at broadphase level
inObjectLayerFilterFilter that filters at layer level
inBodyFilterFilter that filters at body level
inShapeFilterFilter that filters at shape level

◆ CollideShapeWithInternalEdgeRemoval()

void NarrowPhaseQuery::CollideShapeWithInternalEdgeRemoval ( const Shape inShape,
Vec3Arg  inShapeScale,
RMat44Arg  inCenterOfMassTransform,
const CollideShapeSettings inCollideShapeSettings,
RVec3Arg  inBaseOffset,
CollideShapeCollector ioCollector,
const BroadPhaseLayerFilter inBroadPhaseLayerFilter = { },
const ObjectLayerFilter inObjectLayerFilter = { },
const BodyFilter inBodyFilter = { },
const ShapeFilter inShapeFilter = { } 
) const

Same as CollideShape, but uses InternalEdgeRemovingCollector to remove internal edges from the collision results (a.k.a. ghost collisions)

◆ Init()

void NarrowPhaseQuery::Init ( BodyLockInterface inBodyLockInterface,
BroadPhaseQuery inBroadPhaseQuery 
)
inline

Initialize the interface (should only be called by PhysicsSystem)


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