Class TransformedShape

java.lang.Object
com.github.stephengold.joltjni.JoltPhysicsObject
com.github.stephengold.joltjni.TransformedShape
All Implemented Interfaces:
ConstJoltPhysicsObject, ConstTransformedShape, AutoCloseable, Comparable<JoltPhysicsObject>

public class TransformedShape extends JoltPhysicsObject implements ConstTransformedShape
A collision shape and a coordinate transform, typically extracted from a Body or Character.
  • Method Details

    • castRay

      public boolean castRay(RRayCast raycast, RayCastResult storeResult)
      Cast a ray and find the closest hit. The shape is unaffected.
      Specified by:
      castRay in interface ConstTransformedShape
      Parameters:
      raycast - the test ray (not null, unaffected)
      storeResult - storage for the result (not null, modified)
      Returns:
      true if a hit was found, otherwise false
    • castRay

      public void castRay(RRayCast raycast, RayCastSettings settings, CastRayCollector collector, ShapeFilter shapeFilter)
      Cast a narrow-phase ray and collect any hits. The shape is unaffected.
      Specified by:
      castRay in interface ConstTransformedShape
      Parameters:
      raycast - the test ray (not null, unaffected)
      settings - the raycast configuration options to use (not null, unaffected)
      collector - the hit collector to use (not null)
      shapeFilter - the shape filter to apply (not null, unaffected)
    • castShape

      public void castShape(RShapeCast shapeCast, ShapeCastSettings settings, RVec3Arg base, CastShapeCollector collector, ShapeFilter shapeFilter)
      Cast a narrow-phase shape and collect any hits. The shape is unaffected.
      Specified by:
      castShape in interface ConstTransformedShape
      Parameters:
      shapeCast - the desired shape cast (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)
      shapeFilter - the shape filter to apply (not null, unaffected)
    • collectTransformedShapes

      public void collectTransformedShapes(ConstAaBox box, TransformedShapeCollector collector, ShapeFilter shapeFilter)
      Collect transformed shapes for all leaf shapes of the current shape that collide with the specified bounding box. The shape is unaffected.
      Specified by:
      collectTransformedShapes in interface ConstTransformedShape
      Parameters:
      box - the region of interest (in system coordinates)
      collector - the hit collector to use (not null)
      shapeFilter - the shape filter to apply (not null, unaffected)
    • collidePoint

      public void collidePoint(RVec3Arg point, CollidePointCollector collector, ShapeFilter shapeFilter)
      Collect collisions with the specified point. The shape is unaffected.
      Specified by:
      collidePoint in interface ConstTransformedShape
      Parameters:
      point - the location of the point to test (not null, unaffected)
      collector - the hit collector to use (not null)
      shapeFilter - the shape filter to apply (not null, unaffected)
    • collideShape

      public void collideShape(ConstShape testShape, Vec3Arg shapeScale, RMat44Arg comTransform, CollideShapeSettings settings, RVec3Arg base, CollideShapeCollector collector)
      Collect collisions with the specified shape. The shape is unaffected.
      Specified by:
      collideShape in interface ConstTransformedShape
      Parameters:
      testShape - the shape to test (not null, unaffected)
      shapeScale - the scaling vector for the test shape (not null, unaffected)
      comTransform - the coordinate transform to apply to the test 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 testShape, Vec3Arg shapeScale, RMat44Arg comTransform, CollideShapeSettings settings, RVec3Arg base, CollideShapeCollector collector, ShapeFilter shapeFilter)
      Collect collisions with the specified shape. The shape is unaffected.
      Specified by:
      collideShape in interface ConstTransformedShape
      Parameters:
      testShape - the shape to test (not null, unaffected)
      shapeScale - the scaling vector for the test shape (not null, unaffected)
      comTransform - the coordinate transform to apply to the test 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)
      shapeFilter - the shape filter to apply (not null, unaffected)
    • copyDebugTriangles

      public void copyDebugTriangles(FloatBuffer storeBuffer)
      Copy the vertex coordinates of the shape's debug mesh to the specified buffer. The shape is unaffected.
      Specified by:
      copyDebugTriangles in interface ConstTransformedShape
      Parameters:
      storeBuffer - the buffer to fill with vertex coordinates (not null, modified)
    • countDebugTriangles

      public int countDebugTriangles()
      Count the triangles in the shape's debug mesh. The shape is unaffected.
      Specified by:
      countDebugTriangles in interface ConstTransformedShape
      Returns:
      the count (>0)
    • getCenterOfMassTransform

      public RMat44Arg getCenterOfMassTransform()
      Access the underlying coordinate transform. The shape is unaffected.
      Specified by:
      getCenterOfMassTransform in interface ConstTransformedShape
      Returns:
      a new JVM object with the pre-existing native object assigned
    • getShape

      public ConstShape getShape()
      Access the underlying collision shape. The shape is unaffected. (native member: mShape)
      Specified by:
      getShape in interface ConstTransformedShape
      Returns:
      a new JVM object with the pre-existing native object assigned
    • getShapePositionCom

      public RVec3 getShapePositionCom()
      Copy the location of the center of mass. The shape is unaffected. (native member: mShapePositionCOM)
      Specified by:
      getShapePositionCom in interface ConstTransformedShape
      Returns:
      a new object
    • getShapeRotation

      public Quat getShapeRotation()
      Copy the rotation of the shape. The shape is unaffected. (native member: mShapeRotation)
      Specified by:
      getShapeRotation in interface ConstTransformedShape
      Returns:
      a new object
    • getShapeScale

      public Float3 getShapeScale()
      Copy the scale factors of the shape. The shape is unaffected.
      Specified by:
      getShapeScale in interface ConstTransformedShape
      Returns:
      a new object
    • getSupportingFace

      public void getSupportingFace(int subShapeId, Vec3Arg direction, RVec3Arg base, SupportingFace storeFace)
      Get the vertices of the face that provides support in the specified direction. The shape is unaffected.
      Specified by:
      getSupportingFace in interface ConstTransformedShape
      Parameters:
      subShapeId - which sub-shape to use (not null, unaffected)
      direction - the test direction (in world coordinates, not null, unaffected)
      base - the base location for reporting face vertices (not null, unaffected, (0,0,0)→world coordinates)
      storeFace - storage for face vertices (not null)
    • getTrianglesNext

      public int getTrianglesNext(GetTrianglesContext storeContext, int maxTriangles, FloatBuffer storeVertices)
      Collect triangles for debug visualization. The shape is unaffected.
      Specified by:
      getTrianglesNext in interface ConstTransformedShape
      Parameters:
      storeContext - storage for communication with getTrianglesStart()
      maxTriangles - the maximum number of triangles to collect
      storeVertices - storage for triangle vertices
      Returns:
      the number of triangles collected, or 0 if no more triangles are available
    • getTrianglesStart

      public void getTrianglesStart(GetTrianglesContext storeContext, ConstAaBox box, RVec3Arg base)
      Prepare to collect triangles in the specified box for debug visualization. The shape is unaffected.
      Specified by:
      getTrianglesStart in interface ConstTransformedShape
      Parameters:
      storeContext - storage for communication with getTrianglesNext()
      box - the region of interest (in system coordinates, not null, unaffected)
      base - the base location for reporting triangle vertices (not null, unaffected, (0,0,0)→world coordinates)
    • getWorldSpaceBounds

      public AaBox getWorldSpaceBounds()
      Return the bounding box including convex radius. The shape is unaffected.
      Specified by:
      getWorldSpaceBounds in interface ConstTransformedShape
      Returns:
      a new, mutable box (in system coordinates)