Class BoundingValueHierarchy
java.lang.Object
com.jme3.bullet.NativePhysicsObject
com.jme3.bullet.collision.shapes.infos.BoundingValueHierarchy
- All Implemented Interfaces:
com.jme3.export.Savable
,com.jme3.util.clone.JmeCloneable
,Cloneable
,Comparable<NativePhysicsObject>
public class BoundingValueHierarchy
extends NativePhysicsObject
implements com.jme3.util.clone.JmeCloneable, com.jme3.export.Savable
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
ModifierConstructorDescriptionprotected
No-argument constructor needed by SavableClassUtil.BoundingValueHierarchy
(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 TypeMethodDescriptionvoid
cloneFields
(com.jme3.util.clone.Cloner cloner, Object original) Callback fromCloner
to convert this shallow-cloned hierarchy into a deep-cloned one, using the specified Cloner and original to resolve copied fields.com.jme3.bounding.BoundingBox
copyAabb
(com.jme3.bounding.BoundingBox storeResult) Copy the bounds of the hierarchy.com.jme3.math.Vector3f
copyQuantization
(com.jme3.math.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.jmeClone()
Create a shallow clone for the JME cloner.int
partId
(int nodeIndex) Return the part index of the specified node.void
read
(com.jme3.export.JmeImporter importer) De-serialize this mesh from the specified importer, for example when loading from a J3O file.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.void
write
(com.jme3.export.JmeExporter exporter) Serialize this mesh to the specified exporter, for example when saving to a J3O file.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
protected BoundingValueHierarchy()No-argument constructor needed by SavableClassUtil. -
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
public com.jme3.bounding.BoundingBox copyAabb(com.jme3.bounding.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 com.jme3.math.Vector3f copyQuantization(com.jme3.math.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
-
cloneFields
Callback fromCloner
to convert this shallow-cloned hierarchy into a deep-cloned one, using the specified Cloner and original to resolve copied fields.- Specified by:
cloneFields
in interfacecom.jme3.util.clone.JmeCloneable
- Parameters:
cloner
- the Cloner that's cloning this hierarchy (not null)original
- the instance from which this hierarchy was shallow-cloned (not null, unaffected)
-
jmeClone
Create a shallow clone for the JME cloner.- Specified by:
jmeClone
in interfacecom.jme3.util.clone.JmeCloneable
- Returns:
- a new instance
-
read
De-serialize this mesh from the specified importer, for example when loading from a J3O file.- Specified by:
read
in interfacecom.jme3.export.Savable
- Parameters:
importer
- (not null)- Throws:
IOException
- from the importer
-
write
Serialize this mesh to the specified exporter, for example when saving to a J3O file.- Specified by:
write
in interfacecom.jme3.export.Savable
- Parameters:
exporter
- (not null)- Throws:
IOException
- from the exporter
-