btHfFluidRigidCollisionAlgorithm.h
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 
00018 #ifndef HF_FLUID_RIGID_COLLISION_ALGORITHM_H
00019 #define HF_FLUID_RIGID_COLLISION_ALGORITHM_H
00020 
00021 #include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h"
00022 #include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
00023 #include "BulletCollision/CollisionDispatch/btCollisionCreateFunc.h"
00024 #include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h"
00025 #include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h"
00026 #include "BulletCollision/CollisionShapes/btTriangleCallback.h"
00027 #include "BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.h"
00028 
00029 #include "LinearMath/btVector3.h"
00030 class btHfFluid;
00031 
00034 class btHfFluidRigidCollisionAlgorithm : public btCollisionAlgorithm
00035 {
00036   btPersistentManifold* m_manifoldPtr;
00037 
00038   btHfFluid* m_hfFluid;
00039   btCollisionObject* m_rigidCollisionObject;
00040 
00042   bool m_isSwapped;
00043 
00044   btConvexTriangleCallback m_convexTrianglecallback;
00045 
00046   void processGround(const btDispatcherInfo& dispatchInfo, btManifoldResult* resultOut);
00047   void applyFluidFriction(btScalar mu, btScalar submerged_percentage);
00048   btScalar processFluid(const btDispatcherInfo& dispatchInfo, btScalar density, btScalar floatyness);
00049 public:
00050 
00051   btHfFluidRigidCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* col0,
00052                                    btCollisionObject* col1, bool isSwapped);
00053 
00054   virtual ~btHfFluidRigidCollisionAlgorithm();
00055 
00056   virtual void processCollision(btCollisionObject* body0, btCollisionObject* body1,
00057                                 const btDispatcherInfo& dispatchInfo, btManifoldResult* resultOut);
00058 
00059   virtual btScalar calculateTimeOfImpact(btCollisionObject* body0, btCollisionObject* body1,
00060                                          const btDispatcherInfo& dispatchInfo, btManifoldResult* resultOut);
00061 
00062   virtual void getAllContactManifolds(btManifoldArray& manifoldArray)
00063   {
00064     manifoldArray.push_back(m_manifoldPtr);
00065   }
00066 
00067   struct CreateFunc : public btCollisionAlgorithmCreateFunc
00068   {
00069     virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci,
00070                                                            btCollisionObject* body0, btCollisionObject* body1)
00071     {
00072       void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btHfFluidRigidCollisionAlgorithm));
00073       if (!m_swapped)
00074       {
00075         return new (mem) btHfFluidRigidCollisionAlgorithm(ci, body0, body1, false);
00076       }
00077       else
00078       {
00079         return new (mem) btHfFluidRigidCollisionAlgorithm(ci, body0, body1, true);
00080       }
00081     }
00082   };
00083 };
00084 
00085 #endif //HF_FLUID_RIGID_COLLISION_ALGORITHM_H


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