Class BoundingValueHierarchy
java.lang.Object
com.jme3.bullet.NativePhysicsObject
com.jme3.bullet.collision.shapes.infos.BoundingValueHierarchy
- All Implemented Interfaces:
Comparable<NativePhysicsObject>
A Bounding-Value Hierarchy (BVH) generated for a MeshCollisionShape, based on
Bullet's
btOptimizedBvh
.-
Field Summary
Fields inherited from class com.jme3.bullet.NativePhysicsObject
loggerN
-
Constructor Summary
ConstructorDescriptionBoundingValueHierarchy
(byte[] bytes) Instantiate a (tracked) hierarchy from serialized bytes.BoundingValueHierarchy
(MeshCollisionShape meshShape) Instantiate an (untracked) reference to the hierarchy of the specifiedMeshCollisionShape
. -
Method Summary
Modifier and TypeMethodDescriptioncopyAabb
(BoundingBox storeResult) Copy the bounds of the hierarchy.copyQuantization
(Vector3f storeResult) Copy the quantization vector of the hierarchy.int
Count the leaf nodes in the hierarchy.int
Count all nodes in the hierarchy.int
Count the subtree headers in the hierarchy (native field: m_SubtreeHeaders).int
escapeIndex
(int nodeIndex) Return the escape index of the specified node.boolean
Test whether the hierarchy uses quantized AABB compression.boolean
isLeafNode
(int nodeIndex) Test whether the specified node is a leaf.int
partId
(int nodeIndex) Return the part index of the specified node.byte[]
Serialize the hierarchy to a byte array.void
setTraversalMode
(int mode) Alter the traversal mode (native field: m_traversalMode).int
Return the traversal mode (native field: m_traversalMode).int
triangleIndex
(int nodeIndex) Return the triangle index of the specified node.Methods inherited from class com.jme3.bullet.NativePhysicsObject
compareTo, countTrackers, dumpTrackers, equals, freeUnusedObjects, hasAssignedNativeObject, hashCode, nativeId, reassignNativeId, setNativeId, setNativeIdNotTracked, toString, unassignNativeObject
-
Field Details
-
logger
message logger for this class
-
-
Constructor Details
-
BoundingValueHierarchy
Instantiate an (untracked) reference to the hierarchy of the specifiedMeshCollisionShape
.- 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
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
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
-