Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include <stdio.h>
00018
00019 #include <uwsim/BulletHfFluid/btHfFluidBuoyantShapeCollisionAlgorithm.h>
00020 #include <uwsim/BulletHfFluid/btHfFluidBuoyantConvexShape.h>
00021 #include <BulletCollision/CollisionDispatch/btCollisionDispatcher.h>
00022 #include <BulletCollision/CollisionShapes/btSphereShape.h>
00023 #include <BulletCollision/CollisionShapes/btBoxShape.h>
00024
00025 #include <BulletCollision/CollisionDispatch/btCollisionObject.h>
00026 #include <BulletDynamics/Dynamics/btRigidBody.h>
00027 #include <uwsim/BulletHfFluid/btHfFluid.h>
00028
00029 btHfFluidBuoyantShapeCollisionAlgorithm::btHfFluidBuoyantShapeCollisionAlgorithm(
00030 const btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* col0, btCollisionObject* col1,
00031 btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver) :
00032 btCollisionAlgorithm(ci), m_convexConvexAlgorithm(NULL, ci, col0, col1, simplexSolver, pdSolver, 0, 0)
00033 {
00034 m_collisionObject0 = col0;
00035 m_collisionObject1 = col1;
00036 }
00037
00038 btHfFluidBuoyantShapeCollisionAlgorithm::~btHfFluidBuoyantShapeCollisionAlgorithm()
00039 {
00040 }
00041
00042 void btHfFluidBuoyantShapeCollisionAlgorithm::processCollision(btCollisionObject* body0, btCollisionObject* body1,
00043 const btDispatcherInfo& dispatchInfo,
00044 btManifoldResult* resultOut)
00045 {
00046 btHfFluidBuoyantConvexShape* tmpShape0 = (btHfFluidBuoyantConvexShape*)body0->getCollisionShape();
00047 btHfFluidBuoyantConvexShape* tmpShape1 = (btHfFluidBuoyantConvexShape*)body1->getCollisionShape();
00048 btConvexShape* convexShape0 = tmpShape0->getConvexShape();
00049 btConvexShape* convexShape1 = tmpShape1->getConvexShape();
00050
00051 body0->setCollisionShape(convexShape0);
00052 body1->setCollisionShape(convexShape1);
00053
00054 m_convexConvexAlgorithm.processCollision(body0, body1, dispatchInfo, resultOut);
00055
00056 body0->setCollisionShape(tmpShape0);
00057 body1->setCollisionShape(tmpShape1);
00058
00059 }
00060
00061 btScalar btHfFluidBuoyantShapeCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* body0,
00062 btCollisionObject* body1,
00063 const btDispatcherInfo& dispatchInfo,
00064 btManifoldResult* resultOut)
00065 {
00066 btHfFluidBuoyantConvexShape* tmpShape0 = (btHfFluidBuoyantConvexShape*)body0->getCollisionShape();
00067 btHfFluidBuoyantConvexShape* tmpShape1 = (btHfFluidBuoyantConvexShape*)body1->getCollisionShape();
00068 btConvexShape* convexShape0 = tmpShape0->getConvexShape();
00069 btConvexShape* convexShape1 = tmpShape1->getConvexShape();
00070
00071 body0->setCollisionShape(convexShape0);
00072 body1->setCollisionShape(convexShape1);
00073
00074 btScalar toi = btScalar(0.0f);
00075
00076 toi = m_convexConvexAlgorithm.calculateTimeOfImpact(body0, body1, dispatchInfo, resultOut);
00077
00078 body0->setCollisionShape(tmpShape0);
00079 body1->setCollisionShape(tmpShape1);
00080
00081 return toi;
00082 }