void btGImpactCollisionAlgorithm::processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut) { clearCache(); m_resultOut = resultOut; m_dispatchInfo = &dispatchInfo; btGImpactShapeInterface * gimpactshape0; btGImpactShapeInterface * gimpactshape1; if (body0->getCollisionShape()->getShapeType()==GIMPACT_SHAPE_PROXYTYPE) { gimpactshape0 = static_cast<btGImpactShapeInterface *>(body0->getCollisionShape()); if( body1->getCollisionShape()->getShapeType()==GIMPACT_SHAPE_PROXYTYPE ) { gimpactshape1 = static_cast<btGImpactShapeInterface *>(body1->getCollisionShape()); gimpact_vs_gimpact(body0,body1,gimpactshape0,gimpactshape1); } else { gimpact_vs_shape(body0,body1,gimpactshape0,body1->getCollisionShape(),false); } } else if (body1->getCollisionShape()->getShapeType()==GIMPACT_SHAPE_PROXYTYPE ) { gimpactshape1 = static_cast<btGImpactShapeInterface *>(body1->getCollisionShape()); gimpact_vs_shape(body1,body0,gimpactshape1,body0->getCollisionShape(),true); } }
void btGImpactCollisionAlgorithm::processCollision (const btCollisionProcessInfo& processInfo) { clearCache(processInfo.m_dispatcher); m_resultOut = processInfo.m_result; m_dispatchInfo = &processInfo.m_dispatchInfo; const btGImpactShapeInterface * gimpactshape0; const btGImpactShapeInterface * gimpactshape1; if (processInfo.m_body0.getCollisionShape()->getShapeType()==GIMPACT_SHAPE_PROXYTYPE) { gimpactshape0 = static_cast<const btGImpactShapeInterface *>(processInfo.m_body0.getCollisionShape()); if (processInfo.m_body1.getCollisionShape()->getShapeType()==GIMPACT_SHAPE_PROXYTYPE ) { gimpactshape1 = static_cast<const btGImpactShapeInterface *>(processInfo.m_body1.getCollisionShape()); gimpact_vs_gimpact( processInfo.m_dispatcher, &processInfo.m_body0, &processInfo.m_body1, gimpactshape0, gimpactshape1 ); } else { gimpact_vs_shape( processInfo.m_dispatcher, &processInfo.m_body0, &processInfo.m_body1, gimpactshape0, processInfo.m_body1.getCollisionShape(), false ); } } else if (processInfo.m_body1.getCollisionShape()->getShapeType()==GIMPACT_SHAPE_PROXYTYPE ) { gimpactshape1 = static_cast<const btGImpactShapeInterface *>(processInfo.m_body1.getCollisionShape()); gimpact_vs_shape( processInfo.m_dispatcher, &processInfo.m_body1, &processInfo.m_body0, gimpactshape1, processInfo.m_body0.getCollisionShape(), true ); } }
void btGImpactCollisionAlgorithm::processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut) { clearCache(); m_resultOut = resultOut; m_triface0 = m_resultOut->m_index0; m_part0 = m_resultOut->m_partId0; m_triface1 = m_resultOut->m_index1; m_part1 = m_resultOut->m_partId1; m_dispatchInfo = &dispatchInfo; btGImpactShapeInterface * gimpactshape0; btGImpactShapeInterface * gimpactshape1; // if the gimpact shape is nested in a compound shape, we can be given a swapped body0 and body1 // so ensure this is not the case if (m_resultOut->getBody0Internal() == body1) { swap(body0, body1); swap(m_triface0, m_triface1); swap(m_part0, m_part1); } if (body0->getCollisionShape()->getShapeType()==GIMPACT_SHAPE_PROXYTYPE) { gimpactshape0 = static_cast<btGImpactShapeInterface *>(body0->getCollisionShape()); if( body1->getCollisionShape()->getShapeType()==GIMPACT_SHAPE_PROXYTYPE ) { gimpactshape1 = static_cast<btGImpactShapeInterface *>(body1->getCollisionShape()); gimpact_vs_gimpact(body0,body1,gimpactshape0,gimpactshape1); } else { gimpact_vs_shape(body0,body1,gimpactshape0,body1->getCollisionShape(),false); } } else if (body1->getCollisionShape()->getShapeType()==GIMPACT_SHAPE_PROXYTYPE ) { gimpactshape1 = static_cast<btGImpactShapeInterface *>(body1->getCollisionShape()); // hack: swap the original values, they get swapped back again later swap(m_triface0, m_triface1); swap(m_part0, m_part1); gimpact_vs_shape(body1,body0,gimpactshape1,body0->getCollisionShape(),true); } }
void btGImpactCollisionAlgorithm::processCollision(const btCollisionObjectWrapper* body0Wrap, const btCollisionObjectWrapper* body1Wrap, const btDispatcherInfo& dispatchInfo, btManifoldResult* resultOut) { clearCache(); m_resultOut = resultOut; m_dispatchInfo = &dispatchInfo; const btGImpactShapeInterface* gimpactshape0; const btGImpactShapeInterface* gimpactshape1; if (body0Wrap->getCollisionShape()->getShapeType() == GIMPACT_SHAPE_PROXYTYPE) { gimpactshape0 = static_cast<const btGImpactShapeInterface*>(body0Wrap->getCollisionShape()); if (body1Wrap->getCollisionShape()->getShapeType() == GIMPACT_SHAPE_PROXYTYPE) { gimpactshape1 = static_cast<const btGImpactShapeInterface*>(body1Wrap->getCollisionShape()); gimpact_vs_gimpact(body0Wrap, body1Wrap, gimpactshape0, gimpactshape1); } else { gimpact_vs_shape(body0Wrap, body1Wrap, gimpactshape0, body1Wrap->getCollisionShape(), false); } } else if (body1Wrap->getCollisionShape()->getShapeType() == GIMPACT_SHAPE_PROXYTYPE) { gimpactshape1 = static_cast<const btGImpactShapeInterface*>(body1Wrap->getCollisionShape()); gimpact_vs_shape(body1Wrap, body0Wrap, gimpactshape1, body0Wrap->getCollisionShape(), true); } // Ensure that gContactProcessedCallback is called for concave shapes. if (getLastManifold()) { m_resultOut->refreshContactPoints(); } }
void btGImpactCollisionAlgorithm::gimpact_vs_gimpact( btCollisionObject * body0, btCollisionObject * body1, btGImpactShapeInterface * shape0, btGImpactShapeInterface * shape1) { if(shape0->getGImpactShapeType()==CONST_GIMPACT_TRIMESH_SHAPE) { btGImpactMeshShape * meshshape0 = static_cast<btGImpactMeshShape *>(shape0); m_part0 = meshshape0->getMeshPartCount(); while(m_part0--) { gimpact_vs_gimpact(body0,body1,meshshape0->getMeshPart(m_part0),shape1); } return; } if(shape1->getGImpactShapeType()==CONST_GIMPACT_TRIMESH_SHAPE) { btGImpactMeshShape * meshshape1 = static_cast<btGImpactMeshShape *>(shape1); m_part1 = meshshape1->getMeshPartCount(); while(m_part1--) { gimpact_vs_gimpact(body0,body1,shape0,meshshape1->getMeshPart(m_part1)); } return; } btTransform orgtrans0 = body0->getWorldTransform(); btTransform orgtrans1 = body1->getWorldTransform(); btPairSet pairset; gimpact_vs_gimpact_find_pairs(orgtrans0,orgtrans1,shape0,shape1,pairset); if(pairset.size()== 0) return; if(shape0->getGImpactShapeType() == CONST_GIMPACT_TRIMESH_SHAPE_PART && shape1->getGImpactShapeType() == CONST_GIMPACT_TRIMESH_SHAPE_PART) { btGImpactMeshShapePart * shapepart0 = static_cast<btGImpactMeshShapePart * >(shape0); btGImpactMeshShapePart * shapepart1 = static_cast<btGImpactMeshShapePart * >(shape1); //specialized function #ifdef BULLET_TRIANGLE_COLLISION collide_gjk_triangles(body0,body1,shapepart0,shapepart1,&pairset[0].m_index1,pairset.size()); #else collide_sat_triangles(body0,body1,shapepart0,shapepart1,&pairset[0].m_index1,pairset.size()); #endif return; } //general function shape0->lockChildShapes(); shape1->lockChildShapes(); GIM_ShapeRetriever retriever0(shape0); GIM_ShapeRetriever retriever1(shape1); bool child_has_transform0 = shape0->childrenHasTransform(); bool child_has_transform1 = shape1->childrenHasTransform(); int i = pairset.size(); while(i--) { GIM_PAIR * pair = &pairset[i]; m_triface0 = pair->m_index1; m_triface1 = pair->m_index2; btCollisionShape * colshape0 = retriever0.getChildShape(m_triface0); btCollisionShape * colshape1 = retriever1.getChildShape(m_triface1); if(child_has_transform0) { body0->setWorldTransform(orgtrans0*shape0->getChildTransform(m_triface0)); } if(child_has_transform1) { body1->setWorldTransform(orgtrans1*shape1->getChildTransform(m_triface1)); } //collide two convex shapes convex_vs_convex_collision(body0,body1,colshape0,colshape1); if(child_has_transform0) { body0->setWorldTransform(orgtrans0); } if(child_has_transform1) { body1->setWorldTransform(orgtrans1); } } shape0->unlockChildShapes(); shape1->unlockChildShapes(); }