Bullet Collision Detection & Physics Library
|
Go to the documentation of this file.
54 equation[0] = normal[0];
55 equation[1] = normal[1];
56 equation[2] = normal[2];
62 #ifdef TRI_COLLISION_PROFILING
66 float g_accum_triangle_collision_time = 0;
67 int g_count_triangle_collision = 0;
69 void bt_begin_gim02_tri_time()
71 g_triangle_clock.
reset();
74 void bt_end_gim02_tri_time()
77 g_count_triangle_collision++;
79 #endif //TRI_COLLISION_PROFILING
159 #ifdef TRI_COLLISION_PROFILING
162 float btGImpactCollisionAlgorithm::getAverageTreeCollisionTime()
164 return btGImpactBoxSet::getAverageTreeCollisionTime();
168 float btGImpactCollisionAlgorithm::getAverageTriangleCollisionTime()
170 if (g_count_triangle_collision == 0)
return 0;
172 float avgtime = g_accum_triangle_collision_time;
173 avgtime /= (float)g_count_triangle_collision;
175 g_accum_triangle_collision_time = 0;
176 g_count_triangle_collision = 0;
181 #endif //TRI_COLLISION_PROFILING
317 const int* pairs,
int pair_count)
325 const int* pair_pointer = pairs;
351 const int* pairs,
int pair_count)
363 const int* pair_pointer = pairs;
374 #ifdef TRI_COLLISION_PROFILING
375 bt_begin_gim02_tri_time();
401 #ifdef TRI_COLLISION_PROFILING
402 bt_end_gim02_tri_time();
418 const btGImpactMeshShape* meshshape0 = static_cast<const btGImpactMeshShape*>(shape0);
431 const btGImpactMeshShape* meshshape1 = static_cast<const btGImpactMeshShape*>(shape1);
449 if (pairset.
size() == 0)
return;
457 #ifdef BULLET_TRIANGLE_COLLISION
477 int i = pairset.
size();
489 if (child_has_transform0)
494 if (child_has_transform1)
517 const btGImpactMeshShape* meshshape0 = static_cast<const btGImpactMeshShape*>(shape0);
532 #ifdef GIMPACT_VS_PLANE_COLLISION
537 const btStaticPlaneShape* planeshape = static_cast<const btStaticPlaneShape*>(shape1);
546 const btCompoundShape* compoundshape = static_cast<const btCompoundShape*>(shape1);
552 const btConcaveShape* concaveshape = static_cast<const btConcaveShape*>(shape1);
565 if (collided_results.
size() == 0)
return;
573 int i = collided_results.
size();
577 int child_index = collided_results[i];
587 if (child_has_transform0)
647 shape0, colshape1, swapped);
669 const btPlaneShape* planeshape = static_cast<const btPlaneShape*>(shape1);
690 vertex = orgtrans0(vertex);
692 btScalar distance = vertex.
dot(plane) - plane[3] - margin;
790 shape0->
getAabb(gimpactInConcaveSpace, minAABB, maxAABB);
806 gimpactshape0 = static_cast<const btGImpactShapeInterface*>(body0Wrap->
getCollisionShape());
810 gimpactshape1 = static_cast<const btGImpactShapeInterface*>(body1Wrap->
getCollisionShape());
821 gimpactshape1 = static_cast<const btGImpactShapeInterface*>(body1Wrap->
getCollisionShape());
void gimpact_vs_shape_find_pairs(const btTransform &trans0, const btTransform &trans1, const btGImpactShapeInterface *shape0, const btCollisionShape *shape1, btAlignedObjectArray< int > &collided_primitives)
virtual void setShapeIdentifiersB(int partId1, int index1)
void collide_gjk_triangles(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, const btGImpactMeshShapePart *shape0, const btGImpactMeshShapePart *shape1, const int *pairs, int pair_count)
Collision routines.
btCollisionObject can be used to manage collision detection objects.
btGImpactCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo &ci, const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap)
virtual void unlockChildShapes() const
virtual void getBulletTriangle(int prim_index, btTriangleShapeEx &triangle) const
const btCollisionShape * getChildShape(int index)
virtual bool needsRetrieveTriangles() const =0
Determines if this shape has triangles.
const btGImpactShapeInterface * m_gim_shape
void checkConvexAlgorithm(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap)
virtual ~btCollisionAlgorithm()
virtual void processTriangle(btVector3 *triangle, int partId, int triangleIndex)
btTransform & getChildTransform(int index)
btDispatcher * m_dispatcher
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
bool find_triangle_collision_clip_method(btPrimitiveTriangle &other, GIM_TRIANGLE_CONTACT &contacts)
Find collision using the clipping method.
unsigned long long int getTimeMicroseconds()
Returns the time in us since the last call to reset or since the Clock was created.
const btGImpactBoxSet * getBoxSet() const
gets boxset
The btConcaveShape class provides an interface for non-moving (static) concave shapes.
GIM_ShapeRetriever * m_parent
btManifoldResult * internalGetResultOut()
virtual void lockChildShapes() const
call when reading child shapes
void setBody1Wrap(const btCollisionObjectWrapper *obj1Wrap)
btTriangleShapeEx m_trishape
btManifoldResult * m_resultOut
This class manages a sub part of a mesh supplied by the btStridingMeshInterface interface.
virtual void getBulletTetrahedron(int prim_index, btTetrahedronShapeEx &tetrahedron) const =0
Retrieving shapes shapes.
virtual bool needsRetrieveTetrahedrons() const =0
Determines if this shape has tetrahedrons.
btScalar dot(const btVector3 &v) const
Return the dot product.
void gimpact_vs_gimpact_find_pairs(const btTransform &trans0, const btTransform &trans1, const btGImpactShapeInterface *shape0, const btGImpactShapeInterface *shape1, btPairSet &pairset)
const btTransform & getWorldTransform() const
void get_plane_equation_transformed(const btTransform &trans, btVector4 &equation) const
TetraShapeRetriever m_tetra_retriever
This class manages a mesh supplied by the btStridingMeshInterface interface.
void applyTransform(const btTransform &t)
btCollisionDispatcher supports algorithms that handle ConvexConvex and ConvexConcave collision pairs.
virtual void processCollision(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, const btDispatcherInfo &dispatchInfo, btManifoldResult *resultOut)=0
void getAabb(const btTransform &t, btVector3 &aabbMin, btVector3 &aabbMax) const
If the Bounding box is not updated, then this class attemps to calculate it.
Used for GIMPACT Trimesh integration.
virtual void freeCollisionAlgorithm(void *ptr)=0
btCollisionAlgorithm is an collision interface that is compatible with the Broadphase and btDispatche...
virtual eGIMPACT_SHAPE_TYPE getGImpactShapeType() const =0
Subshape member functions.
bool overlap_test_conservative(const btPrimitiveTriangle &other)
Test if triangles could collide.
virtual void getChildAabb(int child_index, const btTransform &t, btVector3 &aabbMin, btVector3 &aabbMax) const
Retrieves the bound from a child.
const btCollisionObjectWrapper * body1Wrap
const btCollisionObjectWrapper * getBody1Wrap() const
btGImpactCollisionAlgorithm * algorithm
The btCollisionShape class provides an interface for collision shapes that can be shared among btColl...
Helper class for colliding Bullet Triangle Shapes.
void setBody0Wrap(const btCollisionObjectWrapper *obj0Wrap)
void increment_margin(btScalar margin)
void get_plane_equation(btVector4 &equation)
btScalar calculateTimeOfImpact(btCollisionObject *body0, btCollisionObject *body1, const btDispatcherInfo &dispatchInfo, btManifoldResult *resultOut)
void gimpact_vs_shape(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, const btGImpactShapeInterface *shape0, const btCollisionShape *shape1, bool swapped)
bool boxQuery(const btAABB &box, btAlignedObjectArray< int > &collided_results) const
returns the indices of the primitives in the m_primitive_manager
btManifoldResult is a helper class to manage contact results.
void collide_sat_triangles(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, const btGImpactMeshShapePart *shape0, const btGImpactMeshShapePart *shape1, const int *pairs, int pair_count)
int getMeshPartCount() const
const btCollisionShape * getCollisionShape() const
void gimpact_vs_compoundshape(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, const btGImpactShapeInterface *shape0, const btCompoundShape *shape1, bool swapped)
void addContactPoint(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, const btVector3 &point, const btVector3 &normal, btScalar distance)
virtual ~btGImpactCollisionAlgorithm()
void setFace0(int value)
Accessor/Mutator pairs for Part and triangleID.
btCollisionAlgorithm * m_convex_algorithm
virtual ~ChildShapeRetriever()
const btGImpactShapeInterface * gimpactshape0
virtual void getAabb(const btTransform &t, btVector3 &aabbMin, btVector3 &aabbMax) const =0
getAabb returns the axis aligned bounding box in the coordinate frame of the given transform t.
static void registerAlgorithm(btCollisionDispatcher *dispatcher)
Use this function for register the algorithm externally.
int getVertexCount() const
btScalar getMargin() const
const btDispatcherInfo * m_dispatchInfo
The btTriangleCallback provides a callback for each overlapping triangle when calling processAllTrian...
virtual void processAllTriangles(btTriangleCallback *callback, const btVector3 &aabbMin, const btVector3 &aabbMax) const =0
virtual int getNumChildShapes() const =0
Gets the number of children.
const btCollisionObject * getCollisionObject() const
const btCollisionObjectWrapper * getBody0Wrap() const
void checkManifold(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap)
btCollisionAlgorithm * newAlgorithm(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap)
btVector3 can be used to represent 3D points and vectors.
virtual const btCollisionShape * getChildShape(int index)
btTetrahedronShapeEx m_tetrashape
Class for accessing the plane equation.
btGImpactMeshShapePart * getMeshPart(int index)
virtual btCollisionShape * getChildShape(int index)=0
Gets the children.
virtual void lockChildShapes() const
call when reading child shapes
void registerCollisionCreateFunc(int proxyType0, int proxyType1, btCollisionAlgorithmCreateFunc *createFunc)
registerCollisionCreateFunc allows registration of custom/alternative collision create functions
void gimpact_vs_concave(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, const btGImpactShapeInterface *shape0, const btConcaveShape *shape1, bool swapped)
virtual void processCollision(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, const btDispatcherInfo &dispatchInfo, btManifoldResult *resultOut)
virtual void unlockChildShapes() const
void reset()
Resets the initial reference time.
The btCompoundShape allows to store multiple other btCollisionShapes This allows for moving concave c...
virtual btTransform getChildTransform(int index) const =0
Gets the children transform.
virtual btCollisionShape * getChildShape(int index)
void gimpacttrimeshpart_vs_plane_collision(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, const btGImpactMeshShapePart *shape0, const btStaticPlaneShape *shape1, bool swapped)
virtual ~TriangleShapeRetriever()
Base class for gimpact shapes.
virtual void getBulletTriangle(int prim_index, btTriangleShapeEx &triangle) const =0
The btClock is a portable basic clock that measures accurate time in seconds, use for profiling.
The btStaticPlaneShape simulates an infinite non-moving (static) collision plane.
int getNumChildShapes() const
TriangleShapeRetriever m_tri_retriever
void refreshContactPoints()
void gimpact_vs_gimpact(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, const btGImpactShapeInterface *shape0, const btGImpactShapeInterface *shape1)
Collides two gimpact shapes.
virtual btCollisionShape * getChildShape(int index)
void getPrimitiveTriangle(int index, btPrimitiveTriangle &triangle) const
if this trimesh
This class is not enabled yet (work-in-progress) to more aggressively activate objects.
void convex_vs_convex_collision(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, const btCollisionShape *shape0, const btCollisionShape *shape1)
virtual void setMargin(btScalar margin)
btPlaneShape(const btVector3 &v, float f)
virtual btScalar getMargin() const
void getVertex(int vertex_index, btVector3 &vertex) const
btPersistentManifold * getLastManifold()
Collision Algorithm for GImpact Shapes.
virtual void addContactPoint(const btVector3 &normalOnBInWorld, const btVector3 &pointInWorld, btScalar depth)
eBT_PLANE_INTERSECTION_TYPE plane_classify(const btVector4 &plane) const
virtual bool childrenHasTransform() const =0
if true, then its children must get transforms.
void push_back(const T &_Val)
btPersistentManifold * m_manifoldPtr
virtual void setShapeIdentifiersA(int partId0, int index0)
setShapeIdentifiersA/B provides experimental support for per-triangle material / custom material comb...
bool hasBoxSet() const
Determines if this class has a hierarchy structure for sorting its primitives.
bool has_collision(const btAABB &other) const
btCollisionShape * getChildShape(int index)
ChildShapeRetriever m_child_retriever
ChildShapeRetriever * m_current_retriever
GIM_ShapeRetriever(const btGImpactShapeInterface *gim_shape)
static void find_collision(const btGImpactQuantizedBvh *boxset1, const btTransform &trans1, const btGImpactQuantizedBvh *boxset2, const btTransform &trans2, btPairSet &collision_pairs)
bool overlap_test_conservative(const btTriangleShapeEx &other)
class btTriangleShapeEx: public btTriangleShape
const btCollisionObjectWrapper * body0Wrap
void shape_vs_shape_collision(const btCollisionObjectWrapper *body0, const btCollisionObjectWrapper *body1, const btCollisionShape *shape0, const btCollisionShape *shape1)
int size() const
return the number of elements in the array
void push_pair(int index1, int index2)
Helper class for tetrahedrons.