NarrowPhaseQuery

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.

C++ JPH::NarrowPhaseQuery.

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
fun castRay(ray: RRayCast, hit: RayCastResult, broadPhaseLayerFilter: BroadPhaseLayerFilter, objectLayerFilter: ObjectLayerFilter, bodyFilter: BodyFilter): Boolean

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.

fun castRay(ray: RRayCast, rayCastSettings: RayCastSettings, collector: CastRayCollector, broadPhaseLayerFilter: BroadPhaseLayerFilter, objectLayerFilter: ObjectLayerFilter, bodyFilter: BodyFilter, shapeFilter: ShapeFilter)

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.

Link copied to clipboard
fun castShape(shapeCast: RShapeCast, shapeCastSettings: ShapeCastSettings, baseOffset: Vec3, collector: CastShapeCollector, broadPhaseLayerFilter: BroadPhaseLayerFilter, objectLayerFilter: ObjectLayerFilter, bodyFilter: BodyFilter, shapeFilter: ShapeFilter)

Cast a shape and report any hits to ioCollector

Link copied to clipboard
open override fun close()
Link copied to clipboard
fun collectTransformedShapes(box: AABox, collector: TransformedShapeCollector, broadPhaseLayerFilter: BroadPhaseLayerFilter, objectLayerFilter: ObjectLayerFilter, bodyFilter: BodyFilter, shapeFilter: ShapeFilter)

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

Link copied to clipboard
fun collidePoint(point: Vec3, collector: CollidePointCollector, broadPhaseLayerFilter: BroadPhaseLayerFilter, objectLayerFilter: ObjectLayerFilter, bodyFilter: BodyFilter, shapeFilter: ShapeFilter)

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

Link copied to clipboard
fun collideShape(shape: Shape?, shapeScale: Vec3, centerOfMassTransform: Mat44, collideShapeSettings: CollideShapeSettings, baseOffset: Vec3, collector: CollideShapeCollector, broadPhaseLayerFilter: BroadPhaseLayerFilter, objectLayerFilter: ObjectLayerFilter, bodyFilter: BodyFilter, shapeFilter: ShapeFilter)

Collide a shape with the system

Link copied to clipboard
fun collideShapeWithInternalEdgeRemoval(shape: Shape?, shapeScale: Vec3, centerOfMassTransform: Mat44, collideShapeSettings: CollideShapeSettings, baseOffset: Vec3, collector: CollideShapeCollector, broadPhaseLayerFilter: BroadPhaseLayerFilter, objectLayerFilter: ObjectLayerFilter, bodyFilter: BodyFilter, shapeFilter: ShapeFilter)

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

Link copied to clipboard
fun init(bodyLockInterface: BodyLockInterface, broadPhaseQuery: BroadPhaseQuery)

Initialize the interface (should only be called by PhysicsSystem)