Class NarrowPhaseQuery

All Implemented Interfaces:
ConstJoltPhysicsObject, ConstNarrowPhaseQuery, AutoCloseable, Comparable<JoltPhysicsObject>

public class NarrowPhaseQuery extends NonCopyable implements ConstNarrowPhaseQuery
Interface for precise collision detection against the bodies in a PhysicsSystem.
  • Method Details

    • getSystem

      public PhysicsSystem getSystem()
      Access the underlying PhysicsSystem.
      Returns:
      the pre-existing instance
    • castRay

      public boolean castRay(RRayCast raycast, RayCastResult hitResult)
      Cast a ray and obtain the nearest hit, if any.
      Specified by:
      castRay in interface ConstNarrowPhaseQuery
      Parameters:
      raycast - the desired ray (not null, unaffected)
      hitResult - storage for information about the hit, if any (not null, may be modified)
      Returns:
      true if a hit was found, otherwise false
    • castRay

      public boolean castRay(RRayCast raycast, RayCastResult hitResult, BroadPhaseLayerFilter bplFilter)
      Cast a ray and obtain the nearest hit, if any.
      Specified by:
      castRay in interface ConstNarrowPhaseQuery
      Parameters:
      raycast - the desired ray (not null, unaffected)
      hitResult - storage for information about the hit, if any (not null, may be modified)
      bplFilter - the broadphase-layer filter to apply (not null, unaffected)
      Returns:
      true if a hit was found, otherwise false
    • castRay

      public boolean castRay(RRayCast raycast, RayCastResult hitResult, BroadPhaseLayerFilter bplFilter, ObjectLayerFilter olFilter)
      Cast a ray and obtain the nearest hit, if any.
      Specified by:
      castRay in interface ConstNarrowPhaseQuery
      Parameters:
      raycast - the desired ray (not null, unaffected)
      hitResult - storage for information about the hit, if any (not null, may be modified)
      bplFilter - the broadphase-layer filter to apply (not null, unaffected)
      olFilter - the object-layer filter to apply (not null, unaffected)
      Returns:
      true if a hit was found, otherwise false
    • castRay

      public boolean castRay(RRayCast raycast, RayCastResult hitResult, BroadPhaseLayerFilter bplFilter, ObjectLayerFilter olFilter, BodyFilter bodyFilter)
      Cast a ray and obtain the nearest hit, if any.
      Specified by:
      castRay in interface ConstNarrowPhaseQuery
      Parameters:
      raycast - the desired ray (not null, unaffected)
      hitResult - storage for information about the hit, if any (not null, may be modified)
      bplFilter - the broadphase-layer filter to apply (not null, unaffected)
      olFilter - the object-layer filter to apply (not null, unaffected)
      bodyFilter - the body filter to apply (not null, unaffected)
      Returns:
      true if a hit was found, otherwise false
    • castRay

      public void castRay(RRayCast raycast, RayCastSettings settings, CastRayCollector collector)
      Cast a ray and collect the resulting hits.
      Specified by:
      castRay in interface ConstNarrowPhaseQuery
      Parameters:
      raycast - the desired ray (not null, unaffected)
      settings - the raycast configuration options to use (not null, unaffected)
      collector - the hit collector to use (not null)
    • castRay

      public void castRay(RRayCast raycast, RayCastSettings settings, CastRayCollector collector, BroadPhaseLayerFilter bplFilter)
      Cast a ray and collect the resulting hits.
      Specified by:
      castRay in interface ConstNarrowPhaseQuery
      Parameters:
      raycast - the desired ray (not null, unaffected)
      settings - the raycast configuration options to use (not null, unaffected)
      collector - the hit collector to use (not null)
      bplFilter - the broadphase-layer filter to apply (not null, unaffected)
    • castRay

      public void castRay(RRayCast raycast, RayCastSettings settings, CastRayCollector collector, BroadPhaseLayerFilter bplFilter, ObjectLayerFilter olFilter)
      Cast a ray and collect the resulting hits.
      Specified by:
      castRay in interface ConstNarrowPhaseQuery
      Parameters:
      raycast - the desired ray (not null, unaffected)
      settings - the raycast configuration options to use (not null, unaffected)
      collector - the hit collector to use (not null)
      bplFilter - the broadphase-layer filter to apply (not null, unaffected)
      olFilter - the object-layer filter to apply (not null, unaffected)
    • castRay

      public void castRay(RRayCast raycast, RayCastSettings settings, CastRayCollector collector, BroadPhaseLayerFilter bplFilter, ObjectLayerFilter olFilter, BodyFilter bodyFilter)
      Cast a ray and collect the resulting hits.
      Specified by:
      castRay in interface ConstNarrowPhaseQuery
      Parameters:
      raycast - the desired ray (not null, unaffected)
      settings - the raycast configuration options to use (not null, unaffected)
      collector - the hit collector to use (not null)
      bplFilter - the broadphase-layer filter to apply (not null, unaffected)
      olFilter - the object-layer filter to apply (not null, unaffected)
      bodyFilter - the body filter to apply (not null, unaffected)
    • castRay

      public void castRay(RRayCast raycast, RayCastSettings settings, CastRayCollector collector, BroadPhaseLayerFilter bplFilter, ObjectLayerFilter olFilter, BodyFilter bodyFilter, ShapeFilter shapeFilter)
      Cast a ray and collect the resulting hits.
      Specified by:
      castRay in interface ConstNarrowPhaseQuery
      Parameters:
      raycast - the desired ray (not null, unaffected)
      settings - the raycast configuration options to use (not null, unaffected)
      collector - the hit collector to use (not null)
      bplFilter - the broadphase-layer filter to apply (not null, unaffected)
      olFilter - the object-layer filter to apply (not null, unaffected)
      bodyFilter - the body filter to apply (not null, unaffected)
      shapeFilter - the shape filter to apply (not null, unaffected)
    • castShape

      public void castShape(RShapeCast shapeCast, ShapeCastSettings settings, RVec3Arg base, CastShapeCollector collector)
      Cast a shape and collect the resulting hits.
      Specified by:
      castShape in interface ConstNarrowPhaseQuery
      Parameters:
      shapeCast - the desired shape cast (not null, unaffected)
      settings - the shape-cast configuration options to use (not null, unaffected)
      base - the base location for reporting hits (not null, unaffected, (0,0,0)→world coordinates)
      collector - the hit collector to use (not null)
    • castShape

      public void castShape(RShapeCast shapeCast, ShapeCastSettings settings, RVec3Arg base, CastShapeCollector collector, BroadPhaseLayerFilter bplFilter)
      Cast a shape and collect the resulting hits.
      Specified by:
      castShape in interface ConstNarrowPhaseQuery
      Parameters:
      shapeCast - the desired shape cast (not null, unaffected)
      settings - the shape-cast configuration options to use (not null, unaffected)
      base - the base location for reporting hits (not null, unaffected, (0,0,0)→world coordinates)
      collector - the hit collector to use (not null)
      bplFilter - the broadphase-layer filter to apply (not null, unaffected)
    • castShape

      public void castShape(RShapeCast shapeCast, ShapeCastSettings settings, RVec3Arg base, CastShapeCollector collector, BroadPhaseLayerFilter bplFilter, ObjectLayerFilter olFilter)
      Cast a shape and collect the resulting hits.
      Specified by:
      castShape in interface ConstNarrowPhaseQuery
      Parameters:
      shapeCast - the desired shape cast (not null, unaffected)
      settings - the shape-cast configuration options to use (not null, unaffected)
      base - the base location for reporting hits (not null, unaffected, (0,0,0)→world coordinates)
      collector - the hit collector to use (not null)
      bplFilter - the broadphase-layer filter to apply (not null, unaffected)
      olFilter - the object-layer filter to apply (not null, unaffected)
    • castShape

      public void castShape(RShapeCast shapeCast, ShapeCastSettings settings, RVec3Arg base, CastShapeCollector collector, BroadPhaseLayerFilter bplFilter, ObjectLayerFilter olFilter, BodyFilter bodyFilter)
      Cast a shape and collect the resulting hits.
      Specified by:
      castShape in interface ConstNarrowPhaseQuery
      Parameters:
      shapeCast - the desired shape cast (not null, unaffected)
      settings - the shape-cast configuration options to use (not null, unaffected)
      base - the base location for reporting hits (not null, unaffected, (0,0,0)→world coordinates)
      collector - the hit collector to use (not null)
      bplFilter - the broadphase-layer filter to apply (not null, unaffected)
      olFilter - the object-layer filter to apply (not null, unaffected)
      bodyFilter - the body filter to apply (not null, unaffected)
    • castShape

      public void castShape(RShapeCast shapeCast, ShapeCastSettings settings, RVec3Arg base, CastShapeCollector collector, BroadPhaseLayerFilter bplFilter, ObjectLayerFilter olFilter, BodyFilter bodyFilter, ShapeFilter shapeFilter)
      Cast a shape and collect the resulting hits.
      Specified by:
      castShape in interface ConstNarrowPhaseQuery
      Parameters:
      shapeCast - the desired shape cast (not null, unaffected)
      settings - the shape-cast configuration options to use (not null, unaffected)
      base - the base location for reporting hits (not null, unaffected, (0,0,0)→world coordinates)
      collector - the hit collector to use (not null)
      bplFilter - the broadphase-layer filter to apply (not null, unaffected)
      olFilter - the object-layer filter to apply (not null, unaffected)
      bodyFilter - the body filter to apply (not null, unaffected)
      shapeFilter - the shape filter to apply (not null, unaffected)
    • collectTransformedShapes

      public void collectTransformedShapes(ConstAaBox box, TransformedShapeCollector collector)
      Collect leaf shapes that lie within the specified bounds.
      Specified by:
      collectTransformedShapes in interface ConstNarrowPhaseQuery
      Parameters:
      box - the bounds (in system coordinates, not null, unaffected)
      collector - the hit collector to use (not null)
    • collectTransformedShapes

      public void collectTransformedShapes(ConstAaBox box, TransformedShapeCollector collector, BroadPhaseLayerFilter bplFilter)
      Collect leaf shapes that lie within the specified bounds.
      Specified by:
      collectTransformedShapes in interface ConstNarrowPhaseQuery
      Parameters:
      box - the bounds (in system coordinates, not null, unaffected)
      collector - the hit collector to use (not null)
      bplFilter - the broadphase-layer filter to apply (not null, unaffected)
    • collectTransformedShapes

      public void collectTransformedShapes(ConstAaBox box, TransformedShapeCollector collector, BroadPhaseLayerFilter bplFilter, ObjectLayerFilter olFilter)
      Collect leaf shapes that lie within the specified bounds.
      Specified by:
      collectTransformedShapes in interface ConstNarrowPhaseQuery
      Parameters:
      box - the bounds (in system coordinates, not null, unaffected)
      collector - the hit collector to use (not null)
      bplFilter - the broadphase-layer filter to apply (not null, unaffected)
      olFilter - the object-layer filter to apply (not null, unaffected)
    • collectTransformedShapes

      public void collectTransformedShapes(ConstAaBox box, TransformedShapeCollector collector, BroadPhaseLayerFilter bplFilter, ObjectLayerFilter olFilter, BodyFilter bodyFilter)
      Collect leaf shapes that lie within the specified bounds.
      Specified by:
      collectTransformedShapes in interface ConstNarrowPhaseQuery
      Parameters:
      box - the bounds (in system coordinates, not null, unaffected)
      collector - the hit collector to use (not null)
      bplFilter - the broadphase-layer filter to apply (not null, unaffected)
      olFilter - the object-layer filter to apply (not null, unaffected)
      bodyFilter - the body filter to apply (not null, unaffected)
    • collectTransformedShapes

      public void collectTransformedShapes(ConstAaBox box, TransformedShapeCollector collector, BroadPhaseLayerFilter bplFilter, ObjectLayerFilter olFilter, BodyFilter bodyFilter, ShapeFilter shapeFilter)
      Collect leaf shapes that lie within the specified bounds.
      Specified by:
      collectTransformedShapes in interface ConstNarrowPhaseQuery
      Parameters:
      box - the bounds (in system coordinates, not null, unaffected)
      collector - the hit collector to use (not null)
      bplFilter - the broadphase-layer filter to apply (not null, unaffected)
      olFilter - the object-layer filter to apply (not null, unaffected)
      bodyFilter - the body filter to apply (not null, unaffected)
      shapeFilter - the shape filter to apply (not null, unaffected)
    • collidePoint

      public void collidePoint(RVec3Arg point, CollidePointCollector collector)
      Collect collisions with the specified point.
      Specified by:
      collidePoint in interface ConstNarrowPhaseQuery
      Parameters:
      point - the location of the point to test (not null, unaffected)
      collector - the hit collector to use (not null)
    • collidePoint

      public void collidePoint(RVec3Arg point, CollidePointCollector collector, BroadPhaseLayerFilter bplFilter)
      Collect collisions with the specified point.
      Specified by:
      collidePoint in interface ConstNarrowPhaseQuery
      Parameters:
      point - the location of the point to test (not null, unaffected)
      collector - the hit collector to use (not null)
      bplFilter - the broadphase-layer filter to apply (not null, unaffected)
    • collidePoint

      public void collidePoint(RVec3Arg point, CollidePointCollector collector, BroadPhaseLayerFilter bplFilter, ObjectLayerFilter olFilter)
      Collect collisions with the specified point.
      Specified by:
      collidePoint in interface ConstNarrowPhaseQuery
      Parameters:
      point - the location of the point to test (not null, unaffected)
      collector - the hit collector to use (not null)
      bplFilter - the broadphase-layer filter to apply (not null, unaffected)
      olFilter - the object-layer filter to apply (not null, unaffected)
    • collidePoint

      public void collidePoint(RVec3Arg point, CollidePointCollector collector, BroadPhaseLayerFilter bplFilter, ObjectLayerFilter olFilter, BodyFilter bodyFilter)
      Collect collisions with the specified point.
      Specified by:
      collidePoint in interface ConstNarrowPhaseQuery
      Parameters:
      point - the location of the point to test (not null, unaffected)
      collector - the hit collector to use (not null)
      bplFilter - the broadphase-layer filter to apply (not null, unaffected)
      olFilter - the object-layer filter to apply (not null, unaffected)
      bodyFilter - the body filter to apply (not null, unaffected)
    • collidePoint

      public void collidePoint(RVec3Arg point, CollidePointCollector collector, BroadPhaseLayerFilter bplFilter, ObjectLayerFilter olFilter, BodyFilter bodyFilter, ShapeFilter shapeFilter)
      Collect collisions with the specified point.
      Specified by:
      collidePoint in interface ConstNarrowPhaseQuery
      Parameters:
      point - the location of the point to test (not null, unaffected)
      collector - the hit collector to use (not null)
      bplFilter - the broadphase-layer filter to apply (not null, unaffected)
      olFilter - the object-layer filter to apply (not null, unaffected)
      bodyFilter - the body filter to apply (not null, unaffected)
      shapeFilter - the shape filter to apply (not null, unaffected)
    • collideShape

      public void collideShape(ConstShape shape, Vec3Arg shapeScale, RMat44Arg comTransform, CollideShapeSettings settings, RVec3Arg base, CollideShapeCollector collector)
      Collect collisions with the specified shape.
      Specified by:
      collideShape in interface ConstNarrowPhaseQuery
      Parameters:
      shape - the shape to test (not null, unaffected)
      shapeScale - the scaling vector for the shape (not null, unaffected)
      comTransform - the coordinate transform to apply to the shape's center of mass (not null, unaffected)
      settings - the collision settings to use (not null, unaffected)
      base - the base location for reporting hits (not null, unaffected, (0,0,0)→world coordinates)
      collector - the hit collector to use (not null)
    • collideShape

      public void collideShape(ConstShape shape, Vec3Arg shapeScale, RMat44Arg comTransform, CollideShapeSettings settings, RVec3Arg base, CollideShapeCollector collector, BroadPhaseLayerFilter bplFilter)
      Collect collisions with the specified shape.
      Specified by:
      collideShape in interface ConstNarrowPhaseQuery
      Parameters:
      shape - the shape to test (not null, unaffected)
      shapeScale - the scaling vector for the shape (not null, unaffected)
      comTransform - the coordinate transform to apply to the shape's center of mass (not null, unaffected)
      settings - the collision settings to use (not null, unaffected)
      base - the base location for reporting hits (not null, unaffected, (0,0,0)→world coordinates)
      collector - the hit collector to use (not null)
      bplFilter - the broadphase-layer filter to apply (not null, unaffected)
    • collideShape

      public void collideShape(ConstShape shape, Vec3Arg shapeScale, RMat44Arg comTransform, CollideShapeSettings settings, RVec3Arg base, CollideShapeCollector collector, BroadPhaseLayerFilter bplFilter, ObjectLayerFilter olFilter)
      Collect collisions with the specified shape.
      Specified by:
      collideShape in interface ConstNarrowPhaseQuery
      Parameters:
      shape - the shape to test (not null, unaffected)
      shapeScale - the scaling vector for the shape (not null, unaffected)
      comTransform - the coordinate transform to apply to the shape's center of mass (not null, unaffected)
      settings - the collision settings to use (not null, unaffected)
      base - the base location for reporting hits (not null, unaffected, (0,0,0)→world coordinates)
      collector - the hit collector to use (not null)
      bplFilter - the broadphase-layer filter to apply (not null, unaffected)
      olFilter - the object-layer filter to apply (not null, unaffected)
    • collideShape

      public void collideShape(ConstShape shape, Vec3Arg shapeScale, RMat44Arg comTransform, CollideShapeSettings settings, RVec3Arg base, CollideShapeCollector collector, BroadPhaseLayerFilter bplFilter, ObjectLayerFilter olFilter, BodyFilter bodyFilter)
      Collect collisions with the specified shape.
      Specified by:
      collideShape in interface ConstNarrowPhaseQuery
      Parameters:
      shape - the shape to test (not null, unaffected)
      shapeScale - the scaling vector for the shape (not null, unaffected)
      comTransform - the coordinate transform to apply to the shape's center of mass (not null, unaffected)
      settings - the collision settings to use (not null, unaffected)
      base - the base location for reporting hits (not null, unaffected, (0,0,0)→world coordinates)
      collector - the hit collector to use (not null)
      bplFilter - the broadphase-layer filter to apply (not null, unaffected)
      olFilter - the object-layer filter to apply (not null, unaffected)
      bodyFilter - the body filter to apply (not null, unaffected)
    • collideShape

      public void collideShape(ConstShape shape, Vec3Arg shapeScale, RMat44Arg comTransform, CollideShapeSettings settings, RVec3Arg base, CollideShapeCollector collector, BroadPhaseLayerFilter bplFilter, ObjectLayerFilter olFilter, BodyFilter bodyFilter, ShapeFilter shapeFilter)
      Collect collisions with the specified shape.
      Specified by:
      collideShape in interface ConstNarrowPhaseQuery
      Parameters:
      shape - the shape to test (not null, unaffected)
      shapeScale - the scaling vector for the shape (not null, unaffected)
      comTransform - the coordinate transform to apply to the shape's center of mass (not null, unaffected)
      settings - the collision settings to use (not null, unaffected)
      base - the base location for reporting hits (not null, unaffected, (0,0,0)→world coordinates)
      collector - the hit collector to use (not null)
      bplFilter - the broadphase-layer filter to apply (not null, unaffected)
      olFilter - the object-layer filter to apply (not null, unaffected)
      bodyFilter - the body filter to apply (not null, unaffected)
      shapeFilter - the shape filter to apply (not null, unaffected)