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
FieldsFields inherited from class com.jme3.bullet.NativePhysicsObject
loggerN -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedNo-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 TypeMethodDescriptionvoidcloneFields(com.jme3.util.clone.Cloner cloner, Object original) Callback fromClonerto convert this shallow-cloned hierarchy into a deep-cloned one, using the specified Cloner and original to resolve copied fields.com.jme3.bounding.BoundingBoxcopyAabb(com.jme3.bounding.BoundingBox storeResult) Copy the bounds of the hierarchy.com.jme3.math.Vector3fcopyQuantization(com.jme3.math.Vector3f storeResult) Copy the quantization vector of the hierarchy.intCount the leaf nodes in the hierarchy.intCount all nodes in the hierarchy.intCount the subtree headers in the hierarchy (native field: m_SubtreeHeaders).intescapeIndex(int nodeIndex) Return the escape index of the specified node.booleanTest whether the hierarchy uses quantized AABB compression.booleanisLeafNode(int nodeIndex) Test whether the specified node is a leaf.jmeClone()Create a shallow clone for the JME cloner.intpartId(int nodeIndex) Return the part index of the specified node.voidread(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.voidsetTraversalMode(int mode) Alter the traversal mode (native field: m_traversalMode).intReturn the traversal mode (native field: m_traversalMode).inttriangleIndex(int nodeIndex) Return the triangle index of the specified node.voidwrite(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
Platformwith 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
storeResultor 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
storeResultor 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
Platformand 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 fromClonerto convert this shallow-cloned hierarchy into a deep-cloned one, using the specified Cloner and original to resolve copied fields.- Specified by:
cloneFieldsin 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:
jmeClonein 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:
readin 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:
writein interfacecom.jme3.export.Savable- Parameters:
exporter- (not null)- Throws:
IOException- from the exporter
-