Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
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