Class MutableCompoundShape

All Implemented Interfaces:
ConstJoltPhysicsObject, ConstShape, RefTarget, AutoCloseable, Comparable<JoltPhysicsObject>

public class MutableCompoundShape extends CompoundShape
A CompoundShape whose sub-shapes can be modified after the shape is constructed.
  • Constructor Details

    • MutableCompoundShape

      public MutableCompoundShape()
      Instantiate an empty compound shape with no sub-shapes.
  • Method Details

    • addShape

      public int addShape(Vec3Arg offset, QuatArg rotation, ConstShape subshape)
      Add a sub-shape in the specified position.
      Parameters:
      offset - the desired offset (not null, unaffected)
      rotation - the desired rotation (not null, not zero, unaffected)
      subshape - the desired sub-shape (not null)
      Returns:
      the index of the added sub-shape
    • adjustCenterOfMass

      public void adjustCenterOfMass()
      Recalculate the center of mass and shift the sub-shapes accordingly.
    • modifyShapes

      public void modifyShapes(int startIndex, int numSubshapes, ByteBuffer offsets, ByteBuffer rotations, int offsetStride, int rotationStride)
      Reposition multiple sub-shapes.
      Parameters:
      startIndex - index of the first shape to reposition (≥0)
      numSubshapes - the number of sub-shapes to reposition (≥0)
      offsets - the desired offsets (not null, unaffected, length≥numSubShapes)
      rotations - the desired rotations (not null, unaffected, length≥numSubShapes)
      offsetStride - the number of bytes between the starting positions of sequential offsets (>0)
      rotationStride - the number of bytes between the starting positions of sequential rotations (>0)
    • removeShape

      public void removeShape(int index)
      Remove the specified sub-shape.
      Parameters:
      index - the index (not the ID) of the sub-shape to remove (≥0)