Class HullCollisionShape

All Implemented Interfaces:
Comparable<NativePhysicsObject>

public class HullCollisionShape extends ConvexShape
A convex-hull collision shape based on Bullet's btConvexHullShape. For a 2-D convex hull, use Convex2dShape.
  • Field Details

    • logger2

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

    • HullCollisionShape

      public HullCollisionShape(Collection<Vector3f> locations)
      Instantiate a shape based on the specified collection of locations. For best performance and stability, the convex hull should have no more than 100 vertices.
      Parameters:
      locations - a collection of location vectors on which to base the shape (not null, not empty, unaffected)
    • HullCollisionShape

      public HullCollisionShape(float... points)
      Instantiate a shape based on an array containing coordinates. For best performance and stability, the convex hull should have no more than 100 vertices.
      Parameters:
      points - an array of coordinates on which to base the shape (not null, not empty, length a multiple of 3, unaffected)
    • HullCollisionShape

      public HullCollisionShape(FloatBuffer flippedBuffer)
      Instantiate a shape based on a flipped buffer containing coordinates. For best performance and stability, the convex hull should have no more than 100 vertices.
      Parameters:
      flippedBuffer - the coordinates on which to base the shape (not null, limit>0, limit a multiple of 3, unaffected)
    • HullCollisionShape

      public HullCollisionShape(RectangularSolid rectangularSolid)
      Instantiate an 8-vertex shape to match the specified rectangular solid.
      Parameters:
      rectangularSolid - the solid on which to base the shape (not null)
    • HullCollisionShape

      public HullCollisionShape(Vector3f... locations)
      Instantiate a shape based on an array of locations. For best performance and stability, the convex hull should have no more than 100 vertices.
      Parameters:
      locations - an array of location vectors (in shape coordinates, not null, not empty, unaffected)
    • HullCollisionShape

      public HullCollisionShape(Vhacd4Hull vhacd4Hull)
      Instantiate a shape based on a Vhacd4Hull. For best performance and stability, the convex hull should have no more than 100 vertices.
      Parameters:
      vhacd4Hull - (not null, unaffected)
    • HullCollisionShape

      public HullCollisionShape(VHACDHull vhacdHull)
      Instantiate a shape based on a VHACDHull. For best performance and stability, the convex hull should have no more than 100 vertices.
      Parameters:
      vhacdHull - (not null, unaffected)
  • Method Details

    • aabbVolume

      public float aabbVolume()
      Calculate a quick upper bound for the unscaled volume of the hull, based on its axis-aligned bounding box.
      Returns:
      the volume (in unscaled shape units cubed, ≥0)
    • copyHullVertices

      public float[] copyHullVertices()
      Copy the unscaled vertex locations of the optimized convex hull.
      Returns:
      a new array (not null)
    • countHullVertices

      public int countHullVertices()
      Count the number of vertices in the optimized convex hull.
      Returns:
      the count (≥0)
    • countMeshVertices

      public int countMeshVertices()
      Count the vertices used to generate the hull.
      Returns:
      the count (>0)
    • getHalfExtents

      public Vector3f getHalfExtents(Vector3f storeResult)
      Calculate the unscaled half extents of the hull.
      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)
    • split

      public ChildCollisionShape[] split(Triangle splittingTriangle)
      Attempt to divide this shape into 2 child shapes.
      Parameters:
      splittingTriangle - to define the splitting plane (in shape coordinates, not null, unaffected)
      Returns:
      a pair of hull-based children, the first child generated by the plane's minus side and the 2nd child generated by its plus side; either child may be null, indicating an empty shape
    • canSplit

      public boolean canSplit()
      Test whether the shape can be split by an arbitrary plane.
      Overrides:
      canSplit in class CollisionShape
      Returns:
      true
    • maxRadius

      public float maxRadius()
      Calculate how far this shape extends from its center, 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