Class BoundingValueHierarchy

java.lang.Object
com.jme3.bullet.NativePhysicsObject
com.jme3.bullet.collision.shapes.infos.BoundingValueHierarchy
All Implemented Interfaces:
Comparable<NativePhysicsObject>

public class BoundingValueHierarchy extends NativePhysicsObject
A Bounding-Value Hierarchy (BVH) generated for a MeshCollisionShape, based on Bullet's btOptimizedBvh.
  • Field Details

    • logger

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

    • BoundingValueHierarchy

      public BoundingValueHierarchy(MeshCollisionShape meshShape)
      Instantiate an (untracked) reference to the hierarchy of the specified MeshCollisionShape.
      Parameters:
      meshShape - the pre-existing shape (not null)
    • BoundingValueHierarchy

      public BoundingValueHierarchy(byte[] bytes)
      Instantiate a (tracked) hierarchy from serialized bytes.

      If the bytes weren't generated on the current Platform with the same floating-point precision, the results are undefined (likely a JVM crash).

      Parameters:
      bytes - the serialized bytes (not null, unaffected)
  • Method Details

    • copyAabb

      public BoundingBox copyAabb(BoundingBox storeResult)
      Copy the bounds of the hierarchy.
      Parameters:
      storeResult - storage for the result (modified if not null)
      Returns:
      an axis-aligned bounding box (either storeResult or a new instance)
    • copyQuantization

      public Vector3f copyQuantization(Vector3f storeResult)
      Copy the quantization vector of the hierarchy.
      Parameters:
      storeResult - storage for the result (modified if not null)
      Returns:
      an vector (either storeResult or a new vector)
    • countLeafNodes

      public int countLeafNodes()
      Count the leaf nodes in the hierarchy.
      Returns:
      the count (≥0)
    • countNodes

      public int countNodes()
      Count all nodes in the hierarchy.
      Returns:
      the count (≥0)
    • countSubtreeHeaders

      public int countSubtreeHeaders()
      Count the subtree headers in the hierarchy (native field: m_SubtreeHeaders).
      Returns:
      the count (≥0)
    • escapeIndex

      public int escapeIndex(int nodeIndex)
      Return the escape index of the specified node.
      Parameters:
      nodeIndex - the index of the node (≥0)
      Returns:
      the escape index (≥0) or -1 if the node is a leaf
    • isCompressed

      public boolean isCompressed()
      Test whether the hierarchy uses quantized AABB compression.
      Returns:
      true if compressed, otherwise false
    • isLeafNode

      public boolean isLeafNode(int nodeIndex)
      Test whether the specified node is a leaf.
      Parameters:
      nodeIndex - the index of the node (≥0)
      Returns:
      true if a leaf, false if an internal node
    • partId

      public int partId(int nodeIndex)
      Return the part index of the specified node.
      Parameters:
      nodeIndex - the index of the node (≥0)
      Returns:
      the part index (≥0) or -1 if the node isn't a leaf
    • serialize

      public byte[] serialize()
      Serialize the hierarchy to a byte array.

      Serialization can be used to avoid re-generating the BVH of a `MeshCollisionShape` each time it is instantiated. The resulting bytes are specific to a particular `MeshCollisionShape`. They are also specific to the current Platform and floating-point precision.

      Returns:
      a new array containing serialized bytes (not null)
    • setTraversalMode

      public void setTraversalMode(int mode)
      Alter the traversal mode (native field: m_traversalMode).
      Parameters:
      mode - 0 for "stackless" or 1 for "stackless cache-friendly" or 2 for "recursive" (default=0)
    • traversalMode

      public int traversalMode()
      Return the traversal mode (native field: m_traversalMode).
      Returns:
      0 for "stackless" or 1 for "stackless cache-friendly" or 2 for "recursive"
    • triangleIndex

      public int triangleIndex(int nodeIndex)
      Return the triangle index of the specified node.
      Parameters:
      nodeIndex - the index of the node (≥0)
      Returns:
      the triangle index (≥0) or -1 if the node isn't a leaf