Class Shape

All Implemented Interfaces:
ConstJoltPhysicsObject, ConstShape, RefTarget, AutoCloseable, Comparable<ConstJoltPhysicsObject>
Direct Known Subclasses:
CompoundShape, ConvexShape, DecoratedShape, EmptyShape, HeightFieldShape, MeshShape, PlaneShape

public abstract class Shape extends NonCopyable implements ConstShape, RefTarget
The abstract base class for collision shapes.
  • Method Details

    • setUserData

      public void setUserData(long value)
      Alter the shape's user data.
      Parameters:
      value - the desired value (default=0)
    • 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
    • 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)
    • 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
    • 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)
    • getUserData

      public long getUserData()
      Return the shape's user data: can be used for anything. The shape is unaffected.
      Specified by:
      getUserData in interface ConstShape
      Returns:
      the value
    • 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)
    • 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
    • toRefC

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

      public int getRefCount()
      Count the active references to the native Shape. The shape is unaffected.
      Specified by:
      getRefCount in interface RefTarget
      Returns:
      the count (≥0)
    • setEmbedded

      public void setEmbedded()
      Mark the native Shape as embedded.
      Specified by:
      setEmbedded in interface RefTarget
    • toRef

      public ShapeRef toRef()
      Create a counted reference to the native Shape.
      Specified by:
      toRef in interface RefTarget
      Returns:
      a new JVM object with a new native object assigned