Class SimplexCollisionShape

All Implemented Interfaces:
Comparable<NativePhysicsObject>

public class SimplexCollisionShape extends ConvexShape
A simple point, line-segment, triangle, or tetrahedron collision shape based on Bullet's btBU_Simplex1to4. These shapes cannot be scaled.
  • Field Details

    • logger2

      public static final Logger logger2
      message logger for this class
  • Constructor Details

    • SimplexCollisionShape

      public SimplexCollisionShape(Vector3f location)
      Instantiate a point shape based on the specified location.
      Parameters:
      location - the location of the point (in shape coordinates, not null, unaffected)
    • SimplexCollisionShape

      public SimplexCollisionShape(Vector3f point1, Vector3f point2)
      Instantiate a line-segment shape based on the specified endpoints.
      Parameters:
      point1 - the location of first endpoint (in shape coordinates, not null, unaffected)
      point2 - the location of 2nd endpoint (in shape coordinates, not null, unaffected)
    • SimplexCollisionShape

      public SimplexCollisionShape(Vector3f vertex1, Vector3f vertex2, Vector3f vertex3)
      Instantiate a triangular shape based on the specified vertices.
      Parameters:
      vertex1 - the location of first vertex (in shape coordinates, not null, unaffected)
      vertex2 - the location of 2nd vertex (in shape coordinates, not null, unaffected)
      vertex3 - the location of 3rd vertex (in shape coordinates, not null, unaffected)
    • SimplexCollisionShape

      public SimplexCollisionShape(Vector3f vertex1, Vector3f vertex2, Vector3f vertex3, Vector3f vertex4)
      Instantiate a tetrahedral shape based on the specified vertices.
      Parameters:
      vertex1 - the location of first vertex (in shape coordinates, not null, unaffected)
      vertex2 - the location of 2nd vertex (in shape coordinates, not null, unaffected)
      vertex3 - the location of 3rd vertex (in shape coordinates, not null, unaffected)
      vertex4 - the location of 4th vertex (in shape coordinates, not null, unaffected)
    • SimplexCollisionShape

      public SimplexCollisionShape(FloatBuffer buffer, int startPosition, int endPosition)
      Instantiate a simplex shape based on the specified FloatBuffer range.
      Parameters:
      buffer - the buffer that contains the vertex locations (not null, unaffected)
      startPosition - the buffer position at which the vertex locations start (≥0, ≤endPosition-3)
      endPosition - the buffer position at which the vertex locations end (≥startPosition+3, ≤capacity)
    • SimplexCollisionShape

      public SimplexCollisionShape(Vector3f[] vertices)
      Instantiate a simplex shape based on the specified array.
      Parameters:
      vertices - an array of vertex locations (not null, not empty, unaffected)
  • Method Details

    • copyVertex

      public Vector3f copyVertex(int index, Vector3f storeResult)
      Copy the indexed vertex.
      Parameters:
      index - (≥0, <4)
      storeResult - storage for the result (modified if not null)
      Returns:
      the location of the vertex (either storeResult or a new instance)
    • copyVertices

      public float[] copyVertices()
      Copy the unscaled vertex locations.
      Returns:
      a new array (not null)
    • countMeshVertices

      public int countMeshVertices()
      Count the points used to generate the simplex.
      Returns:
      the count (≥1, ≤4)
    • getHalfExtents

      public Vector3f getHalfExtents(Vector3f storeResult)
      Calculate the unscaled half extents of the simplex.
      Parameters:
      storeResult - storage for the result (modified if not null)
      Returns:
      the unscaled half extent for each local axis (either storeResult or a new vector, not null, no negative component)
    • unscaledVolume

      public float unscaledVolume()
      Calculate the unscaled volume of the simplex.
      Returns:
      the volume (in shape units cubed, ≥0)
    • canScale

      public boolean canScale(Vector3f scale)
      Test whether the specified scale factors can be applied to the shape. For simplex shapes, scaling must be unity.
      Overrides:
      canScale in class CollisionShape
      Parameters:
      scale - the desired scale factor for each local axis (may be null, unaffected)
      Returns:
      true if applicable, otherwise false
    • maxRadius

      public float maxRadius()
      Calculate how far the shape extends from its origin, including margin.
      Overrides:
      maxRadius in class CollisionShape
      Returns:
      the distance (in physics-space units, ≥0)
    • recalculateAabb

      protected void recalculateAabb()
      Recalculate the shape's bounding box if necessary.
      Overrides:
      recalculateAabb in class CollisionShape
    • toHullShape

      public HullCollisionShape toHullShape()
      Approximate this shape with a HullCollisionShape.
      Overrides:
      toHullShape in class ConvexShape
      Returns:
      a new shape