com.bulletphysics.collision.shapes
Class BvhTriangleMeshShape

java.lang.Object
  extended by com.bulletphysics.collision.shapes.CollisionShape
      extended by com.bulletphysics.collision.shapes.ConcaveShape
          extended by com.bulletphysics.collision.shapes.TriangleMeshShape
              extended by com.bulletphysics.collision.shapes.BvhTriangleMeshShape

public class BvhTriangleMeshShape
extends TriangleMeshShape

BvhTriangleMeshShape is a static-triangle mesh shape with several optimizations, such as bounding volume hierarchy. It is recommended to enable useQuantizedAabbCompression for better memory usage.

It takes a triangle mesh as input, for example a TriangleMesh or TriangleIndexVertexArray. The BvhTriangleMeshShape class allows for triangle mesh deformations by a refit or partialRefit method.

Instead of building the bounding volume hierarchy acceleration structure, it is also possible to serialize (save) and deserialize (load) the structure from disk. See ConcaveDemo for an example.


Constructor Summary
BvhTriangleMeshShape()
           
BvhTriangleMeshShape(StridingMeshInterface meshInterface, boolean useQuantizedAabbCompression)
           
BvhTriangleMeshShape(StridingMeshInterface meshInterface, boolean useQuantizedAabbCompression, boolean buildBvh)
           
BvhTriangleMeshShape(StridingMeshInterface meshInterface, boolean useQuantizedAabbCompression, Vector3f bvhAabbMin, Vector3f bvhAabbMax)
          Optionally pass in a larger bvh aabb, used for quantization.
BvhTriangleMeshShape(StridingMeshInterface meshInterface, boolean useQuantizedAabbCompression, Vector3f bvhAabbMin, Vector3f bvhAabbMax, boolean buildBvh)
          Optionally pass in a larger bvh aabb, used for quantization.
 
Method Summary
 String getName()
           
 OptimizedBvh getOptimizedBvh()
           
 boolean getOwnsBvh()
           
 BroadphaseNativeType getShapeType()
           
 void partialRefitTree(Vector3f aabbMin, Vector3f aabbMax)
          For a fast incremental refit of parts of the tree.
 void performConvexcast(TriangleCallback callback, Vector3f raySource, Vector3f rayTarget, Vector3f aabbMin, Vector3f aabbMax)
           
 void performRaycast(TriangleCallback callback, Vector3f raySource, Vector3f rayTarget)
           
 void processAllTriangles(TriangleCallback callback, Vector3f aabbMin, Vector3f aabbMax)
          Perform bvh tree traversal and report overlapping triangles to 'callback'.
 void refitTree(Vector3f aabbMin, Vector3f aabbMax)
           
 void setLocalScaling(Vector3f scaling)
           
 void setOptimizedBvh(OptimizedBvh bvh)
           
 void setOptimizedBvh(OptimizedBvh bvh, Vector3f scaling)
           
 boolean usesQuantizedAabbCompression()
           
 
Methods inherited from class com.bulletphysics.collision.shapes.TriangleMeshShape
calculateLocalInertia, getAabb, getLocalAabbMax, getLocalAabbMin, getLocalScaling, getMeshInterface, localGetSupportingVertex, localGetSupportingVertexWithoutMargin, recalcLocalAabb
 
Methods inherited from class com.bulletphysics.collision.shapes.ConcaveShape
getMargin, setMargin
 
Methods inherited from class com.bulletphysics.collision.shapes.CollisionShape
calculateTemporalAabb, getAngularMotionDisc, getBoundingSphere, getUserPointer, isCompound, isConcave, isConvex, isInfinite, isPolyhedral, setUserPointer
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BvhTriangleMeshShape

public BvhTriangleMeshShape()

BvhTriangleMeshShape

public BvhTriangleMeshShape(StridingMeshInterface meshInterface,
                            boolean useQuantizedAabbCompression)

BvhTriangleMeshShape

public BvhTriangleMeshShape(StridingMeshInterface meshInterface,
                            boolean useQuantizedAabbCompression,
                            boolean buildBvh)

BvhTriangleMeshShape

public BvhTriangleMeshShape(StridingMeshInterface meshInterface,
                            boolean useQuantizedAabbCompression,
                            Vector3f bvhAabbMin,
                            Vector3f bvhAabbMax)
Optionally pass in a larger bvh aabb, used for quantization. This allows for deformations within this aabb.


BvhTriangleMeshShape

public BvhTriangleMeshShape(StridingMeshInterface meshInterface,
                            boolean useQuantizedAabbCompression,
                            Vector3f bvhAabbMin,
                            Vector3f bvhAabbMax,
                            boolean buildBvh)
Optionally pass in a larger bvh aabb, used for quantization. This allows for deformations within this aabb.

Method Detail

getOwnsBvh

public boolean getOwnsBvh()

getShapeType

public BroadphaseNativeType getShapeType()
Specified by:
getShapeType in class CollisionShape

performRaycast

public void performRaycast(TriangleCallback callback,
                           Vector3f raySource,
                           Vector3f rayTarget)

performConvexcast

public void performConvexcast(TriangleCallback callback,
                              Vector3f raySource,
                              Vector3f rayTarget,
                              Vector3f aabbMin,
                              Vector3f aabbMax)

processAllTriangles

public void processAllTriangles(TriangleCallback callback,
                                Vector3f aabbMin,
                                Vector3f aabbMax)
Perform bvh tree traversal and report overlapping triangles to 'callback'.

Overrides:
processAllTriangles in class TriangleMeshShape

refitTree

public void refitTree(Vector3f aabbMin,
                      Vector3f aabbMax)

partialRefitTree

public void partialRefitTree(Vector3f aabbMin,
                             Vector3f aabbMax)
For a fast incremental refit of parts of the tree. Note: the entire AABB of the tree will become more conservative, it never shrinks.


getName

public String getName()
Overrides:
getName in class TriangleMeshShape

setLocalScaling

public void setLocalScaling(Vector3f scaling)
Overrides:
setLocalScaling in class TriangleMeshShape

getOptimizedBvh

public OptimizedBvh getOptimizedBvh()

setOptimizedBvh

public void setOptimizedBvh(OptimizedBvh bvh)

setOptimizedBvh

public void setOptimizedBvh(OptimizedBvh bvh,
                            Vector3f scaling)

usesQuantizedAabbCompression

public boolean usesQuantizedAabbCompression()