btHfFluidBuoyantShapeCollisionAlgorithm.cpp
Go to the documentation of this file.
00001 /*
00002  Bullet Continuous Collision Detection and Physics Library
00003  Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.com
00004 
00005  This software is provided 'as-is', without any express or implied warranty.
00006  In no event will the authors be held liable for any damages arising from the use of this software.
00007  Permission is granted to anyone to use this software for any purpose,
00008  including commercial applications, and to alter it and redistribute it freely,
00009  subject to the following restrictions:
00010 
00011  1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
00012  2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
00013  3. This notice may not be removed or altered from any source distribution.
00014 
00015  Experimental Buoyancy fluid demo written by John McCutchan
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 }


uwsim
Author(s): Mario Prats
autogenerated on Mon Oct 6 2014 08:24:07