2011-02-22 10:33:14 +00:00
|
|
|
|
|
|
|
/** \file KX_BulletPhysicsController.h
|
|
|
|
* \ingroup ketsji
|
|
|
|
*/
|
|
|
|
|
2005-07-16 21:47:54 +00:00
|
|
|
#ifndef KX_BULLET2PHYSICS_CONTROLLER
|
|
|
|
#define KX_BULLET2PHYSICS_CONTROLLER
|
|
|
|
|
|
|
|
|
|
|
|
#include "KX_IPhysicsController.h"
|
2010-10-10 07:01:56 +00:00
|
|
|
#ifdef USE_BULLET
|
2005-07-16 21:47:54 +00:00
|
|
|
#include "CcdPhysicsController.h"
|
2010-10-10 07:01:56 +00:00
|
|
|
#endif
|
2005-07-16 21:47:54 +00:00
|
|
|
|
|
|
|
class KX_BulletPhysicsController : public KX_IPhysicsController ,public CcdPhysicsController
|
|
|
|
{
|
2008-07-18 14:40:24 +00:00
|
|
|
private:
|
|
|
|
int m_savedCollisionFlags;
|
2008-12-14 17:32:24 +00:00
|
|
|
int m_savedActivationState;
|
2008-07-19 10:27:52 +00:00
|
|
|
short int m_savedCollisionFilterGroup;
|
|
|
|
short int m_savedCollisionFilterMask;
|
2008-07-20 15:40:03 +00:00
|
|
|
MT_Scalar m_savedMass;
|
2009-06-08 20:08:19 +00:00
|
|
|
bool m_savedDyna;
|
|
|
|
bool m_suspended;
|
2009-01-26 08:34:40 +00:00
|
|
|
btCollisionShape* m_bulletChildShape;
|
2008-07-20 15:40:03 +00:00
|
|
|
|
2005-07-16 21:47:54 +00:00
|
|
|
public:
|
2010-10-10 07:01:56 +00:00
|
|
|
#ifdef USE_BULLET
|
2009-06-08 20:08:19 +00:00
|
|
|
KX_BulletPhysicsController (const CcdConstructionInfo& ci, bool dyna, bool sensor, bool compound);
|
2005-07-16 21:47:54 +00:00
|
|
|
virtual ~KX_BulletPhysicsController ();
|
2010-10-10 07:01:56 +00:00
|
|
|
#endif
|
2005-07-16 21:47:54 +00:00
|
|
|
///////////////////////////////////
|
|
|
|
// KX_IPhysicsController interface
|
|
|
|
////////////////////////////////////
|
|
|
|
|
|
|
|
virtual void applyImpulse(const MT_Point3& attach, const MT_Vector3& impulse);
|
|
|
|
virtual void SetObject (SG_IObject* object);
|
2006-11-21 00:53:40 +00:00
|
|
|
virtual void setMargin (float collisionMargin);
|
2005-07-16 21:47:54 +00:00
|
|
|
virtual void RelativeTranslate(const MT_Vector3& dloc,bool local);
|
|
|
|
virtual void RelativeRotate(const MT_Matrix3x3& drot,bool local);
|
|
|
|
virtual void ApplyTorque(const MT_Vector3& torque,bool local);
|
|
|
|
virtual void ApplyForce(const MT_Vector3& force,bool local);
|
|
|
|
virtual MT_Vector3 GetLinearVelocity();
|
2008-06-24 19:37:43 +00:00
|
|
|
virtual MT_Vector3 GetAngularVelocity();
|
2005-07-16 21:47:54 +00:00
|
|
|
virtual MT_Vector3 GetVelocity(const MT_Point3& pos);
|
|
|
|
virtual void SetAngularVelocity(const MT_Vector3& ang_vel,bool local);
|
|
|
|
virtual void SetLinearVelocity(const MT_Vector3& lin_vel,bool local);
|
|
|
|
virtual void getOrientation(MT_Quaternion& orn);
|
2008-07-21 12:37:27 +00:00
|
|
|
virtual void setOrientation(const MT_Matrix3x3& orn);
|
2005-07-16 21:47:54 +00:00
|
|
|
virtual void setPosition(const MT_Point3& pos);
|
|
|
|
virtual void setScaling(const MT_Vector3& scaling);
|
2009-06-08 20:08:19 +00:00
|
|
|
virtual void SetTransform();
|
2005-07-16 21:47:54 +00:00
|
|
|
virtual MT_Scalar GetMass();
|
2009-01-26 08:34:40 +00:00
|
|
|
virtual void SetMass(MT_Scalar newmass);
|
2009-04-20 15:06:46 +00:00
|
|
|
virtual MT_Vector3 GetLocalInertia();
|
2005-07-16 21:47:54 +00:00
|
|
|
virtual MT_Vector3 getReactionForce();
|
|
|
|
virtual void setRigidBody(bool rigid);
|
2009-01-26 08:34:40 +00:00
|
|
|
virtual void AddCompoundChild(KX_IPhysicsController* child);
|
|
|
|
virtual void RemoveCompoundChild(KX_IPhysicsController* child);
|
2005-07-16 21:47:54 +00:00
|
|
|
|
|
|
|
virtual void resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ);
|
|
|
|
|
2008-07-18 14:40:24 +00:00
|
|
|
virtual void SuspendDynamics(bool ghost);
|
2005-07-16 21:47:54 +00:00
|
|
|
virtual void RestoreDynamics();
|
|
|
|
|
|
|
|
virtual SG_Controller* GetReplica(class SG_Node* destnode);
|
|
|
|
|
2008-10-01 07:55:02 +00:00
|
|
|
virtual MT_Scalar GetRadius();
|
2009-04-20 15:06:46 +00:00
|
|
|
|
|
|
|
virtual float GetLinVelocityMin();
|
|
|
|
virtual void SetLinVelocityMin(float val);
|
|
|
|
virtual float GetLinVelocityMax();
|
|
|
|
virtual void SetLinVelocityMax(float val);
|
2005-07-16 21:47:54 +00:00
|
|
|
|
|
|
|
virtual void SetSumoTransform(bool nondynaonly);
|
|
|
|
// todo: remove next line !
|
|
|
|
virtual void SetSimulatedTime(double time);
|
|
|
|
|
|
|
|
// call from scene graph to update
|
|
|
|
virtual bool Update(double time);
|
|
|
|
void* GetUserData() { return m_userdata;}
|
|
|
|
|
2011-03-16 21:20:24 +00:00
|
|
|
virtual const char* getName();
|
|
|
|
|
2005-07-16 21:47:54 +00:00
|
|
|
void
|
|
|
|
SetOption(
|
|
|
|
int option,
|
|
|
|
int value
|
|
|
|
){
|
|
|
|
// intentionally empty
|
|
|
|
};
|
|
|
|
|
2009-08-18 15:37:31 +00:00
|
|
|
|
|
|
|
#ifdef WITH_CXX_GUARDEDALLOC
|
|
|
|
public:
|
2010-06-06 01:15:44 +00:00
|
|
|
void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_BulletPhysicsController"); }
|
2009-08-18 15:37:31 +00:00
|
|
|
void operator delete( void *mem ) { MEM_freeN(mem); }
|
|
|
|
#endif
|
2005-07-16 21:47:54 +00:00
|
|
|
};
|
|
|
|
|
2006-01-05 23:10:54 +00:00
|
|
|
#endif //KX_BULLET2PHYSICS_CONTROLLER
|
|
|
|
|