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

public final class ShapeRefC extends JoltPhysicsObject implements ConstShape
A counted reference to a ConstShape. (native type: RefConst<Shape>)
  • Constructor Details

    • ShapeRefC

      public ShapeRefC()
      Instantiate an empty reference.
  • Method Details

    • getPtr

      public ConstShape getPtr()
      Temporarily access the referenced ConstShape.
      Returns:
      a new JVM object with the pre-existing native object assigned
    • 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 ConstShape
      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 ConstShape
      Returns:
      the count (>0)
    • draw

      public void draw(DebugRenderer renderer, RMat44Arg comTransform, Vec3Arg scale, ConstColor color, boolean useMaterialColors, boolean wireframe)
      Draw the shape using the specified renderer. The shape is unaffected.
      Specified by:
      draw in interface ConstShape
      Parameters:
      renderer - the renderer to use (not null)
      comTransform - the coordinate transform from the shape's center of mass to system coordinates (not null, unaffected)
      scale - the desired scaling (not null, unaffected)
      color - the desired color if useMaterialColors is false (not null, unaffected)
      useMaterialColors - true to use the color in the shape's material
      wireframe - true to draw a wire frame, false for solid triangles
    • drawGetSupportFunction

      public void drawGetSupportFunction(DebugRenderer renderer, RMat44Arg comTransform, Vec3Arg scale, ConstColor color, boolean drawSupportDirection)
      Draw the support function with the convex radius added back on. The shape is unaffected.
      Specified by:
      drawGetSupportFunction in interface ConstShape
      Parameters:
      renderer - the renderer to use (not null)
      comTransform - transform to apply (not null, unaffected)
      scale - scaling to apply (not null, unaffected)
      color - the color using for drawing (not null, unaffected)
      drawSupportDirection - the direction to draw
    • getCenterOfMass

      public Vec3 getCenterOfMass()
      Locate the shape's center of mass. The shape is unaffected.
      Specified by:
      getCenterOfMass in interface ConstShape
      Returns:
      a new location vector
    • getInnerRadius

      public float getInnerRadius()
      Return the radius of the largest sphere that fits inside the shape. The shape is unaffected.
      Specified by:
      getInnerRadius in interface ConstShape
      Returns:
      the radius (≥0)
    • getLeafShape

      public ConstShape getLeafShape(int subShapeId, int[] storeRemainderId)
      Access the leaf shape for the specified sub-shape ID.
      Specified by:
      getLeafShape in interface ConstShape
      Parameters:
      subShapeId - an ID that indicates the path to the desired leaf shape (not null, unaffected)
      storeRemainderId - storage for the remainder of the ID after removing the path to the leaf shape (not null, modified)
      Returns:
      a new JVM object with the pre-existing native object assigned, or null if the ID is invalid
    • getLocalBounds

      public AaBox getLocalBounds()
      Return a bounding box that includes the convex radius. The shape is unaffected.
      Specified by:
      getLocalBounds in interface ConstShape
      Returns:
      a new, mutable box (relative to the shape's center of mass)
    • getMassProperties

      public MassProperties getMassProperties()
      Copy the shape's mass properties. The shape is unaffected.
      Specified by:
      getMassProperties in interface ConstShape
      Returns:
      a new, mutable properties object
    • getMaterial

      public ConstPhysicsMaterial getMaterial(int subShapeId)
      Access the material of the specified sub-shape. The shape is unaffected.
      Specified by:
      getMaterial in interface ConstShape
      Parameters:
      subShapeId - which sub-shape
      Returns:
      a new JVM object with the pre-existing native object assigned
    • getRevisionCount

      public long getRevisionCount()
      Return the shape's revision count, which is automatically incremented each time the shape is altered. The shape is unaffected.
      Specified by:
      getRevisionCount in interface ConstShape
      Returns:
      the count
    • getStats

      public Stats getStats()
      Copy the statistics. The shape is unaffected.
      Specified by:
      getStats in interface ConstShape
      Returns:
      a new object
    • getSubShapeIdBitsRecursive

      public int getSubShapeIdBitsRecursive()
      Count how many bits are used to address leaf shapes. The shape is unaffected.
      Specified by:
      getSubShapeIdBitsRecursive in interface ConstShape
      Returns:
      the number of bits (≥0)
    • getSubType

      public EShapeSubType getSubType()
      Return the shape's subtype. The shape is unaffected.
      Specified by:
      getSubType in interface ConstShape
      Returns:
      an enum value (not null)
    • getType

      public EShapeType getType()
      Return the shape's type. The shape is unaffected.
      Specified by:
      getType in interface ConstShape
      Returns:
      an enum value (not null)
    • getWorldSpaceBounds

      public AaBox getWorldSpaceBounds(Mat44Arg comTransform, Vec3Arg scale)
      Return the bounding box including convex radius. The shape is unaffected.
      Specified by:
      getWorldSpaceBounds in interface ConstShape
      Parameters:
      comTransform - the center-of-mass transform to apply to the shape (not null, unaffected)
      scale - the scale factors to apply to the shape (not null, unaffected)
      Returns:
      a new, mutable box (in system coordinates)
    • getWorldSpaceBounds

      public AaBox getWorldSpaceBounds(RMat44Arg comTransform, Vec3Arg scale)
      Return the bounding box including convex radius. The shape is unaffected.
      Specified by:
      getWorldSpaceBounds in interface ConstShape
      Parameters:
      comTransform - the center-of-mass transform to apply to the shape (not null, unaffected)
      scale - the scale factors to apply to the shape (not null, unaffected)
      Returns:
      a new, mutable box (in system coordinates)
    • isValidScale

      public boolean isValidScale(Vec3Arg scale)
      Test whether the specified scale vector is valid for wrapping the current shape in a ScaledShape. The current shape is unaffected.
      Specified by:
      isValidScale in interface ConstShape
      Parameters:
      scale - the proposed scale vector (not null, unaffected)
      Returns:
      true if valid, otherwise false
    • makeScaleValid

      public Vec3 makeScaleValid(Vec3Arg scale)
      Transform the specified scale vector such that it will be valid for wrapping the current shape in a ScaledShape. The current shape is unaffected.
      Specified by:
      makeScaleValid in interface ConstShape
      Parameters:
      scale - the proposed scale vector (not null, unaffected)
      Returns:
      a new scale vector
    • mustBeStatic

      public boolean mustBeStatic()
      Test whether the shape can be used in a dynamic/kinematic body. The shape is unaffected.
      Specified by:
      mustBeStatic in interface ConstShape
      Returns:
      true if it can be only be static, otherwise false
    • saveBinaryState

      public void saveBinaryState(StreamOut stream)
      Save the shape to the specified binary stream. The shape is unaffected.
      Specified by:
      saveBinaryState in interface ConstShape
      Parameters:
      stream - the stream to write to (not null)
    • targetVa

      public long targetVa()
      Return the address of the native Shape. No objects are affected.
      Specified by:
      targetVa in interface ConstJoltPhysicsObject
      Overrides:
      targetVa in class JoltPhysicsObject
      Returns:
      a virtual address (not zero)
    • toRefC

      public ShapeRefC toRefC()
      Create another counted reference to the native Shape.
      Specified by:
      toRefC in interface ConstShape
      Returns:
      a new JVM object with a new native object assigned