BGE: Cleaning up the BGE's physics code and removing KX_IPhysicsController and KX_Bul...
authorMitchell Stokes <mogurijin@gmail.com>
Mon, 4 Nov 2013 19:22:47 +0000 (19:22 +0000)
committerMitchell Stokes <mogurijin@gmail.com>
Mon, 4 Nov 2013 19:22:47 +0000 (19:22 +0000)
This is a squashed commit of the following:
    BGE Physics Cleanup: Fix crashes with LibLoading and replication. Also fixing some memory leaks.
    BGE Physics Cleanup: Removing KX_IPhysicsController and KX_BulletPhysicsController.
    BGE Physics Cleanup: Moving the replication code outside of KX_BlenderBulletController and switching KX_ConvertPhysicsObjects to create a CcdPhysicsController instead of a KX_BlenderBulletController.
    BGE Physics Cleanup: Getting rid of an unsued KX_BulletPhysicsController.h include in KX_Scene.cpp.
    BGE Physics Cleanup: Removing unused KX_IPhysicsController and KX_BulletPhysicsController includes.
    BGE Physics Cleanup: Removing m_pPhysicsController1 and GetPhysicsController1() from KX_GameObject.
    BGE Physics Cleanup: Remove SetRigidBody() from KX_IPhysicsController and remove GetName() from CcdPhysicsController.
    BGE Physics Cleanup: Moving Add/RemoveCompoundChild() from KX_IPhysicsController to PHY_IPhysicsController.
    BGE Physics Cleanup: Removing GetLocalInertia() from KX_IPhysicsController.
    BGE Physics Cleanup: Making BlenderBulletCharacterController derive from PHY_ICharacter and removing CharacterWrapper from CcdPhysicsEnvironment.cpp. Also removing the character functions from KX_IPhysicsController.
    BGE Physics Cleanup: Removing GetOrientation(), SetOrientation(), SetPosition(), SetScaling(), and GetRadius() from KX_IPhysicsController.
    BGE Physics Cleanup: Removing GetReactionForce() since all implementations returned (0, 0, 0). The Python interface for KX_GameObject still has reaction force code, but it still also returns (0, 0, 0). This can probably be removed as well, but removing it can break scripts, so I'll leave it for now.
    BGE Physics Cleanup: Removing Get/SetLinVelocityMin() and Get/SetLinVelocityMax() from KX_IPhysicsController.
    BGE Physics Cleanup: Removing SetMargin(), RelativeTranslate(), and RelativeRotate() from KX_IPhysicsController.
    BGE Physics Cleanup: Using constant references for function arguments in PHY_IPhysicsController where appropriate.
    BGE Physics Cleanup: Removing ApplyImpulse() from KX_IPhysicsController.
    BGE Physics Cleanup: Removing ResolveCombinedVelocities() from KX_IPhysicsController.
    BGE Physics Cleanup: Accidently removed a return when cleaning up KX_GameObject::PyGetVelocity().
    BGE Physics Cleanup: Remove GetLinearVelocity(), GetAngularVelocity() and GetVelocity() from KX_IPhysicsController. The corresponding PHY_IPhysicsController functions now also take Moto types instead of scalars to match the KX_IPhysicsController interface.
    BGE Physics Cleanup: Moving SuspendDynamics, RestoreDynamics, SetMass, GetMass, and SetTransform from KX_IPhysicsController to PHY_IPhysicsController.
    BGE Physics Cleanup: PHY_IPhysicsEnvironment and derived classes now use the same naming scheme as PHY_IController.
    BGE Physics Cleanup: PHY_IMotionState and derived classes now use the same naming convention as PHY_IController.
    BGE Phsyics Cleanup: Making PHY_IController and its derived classes follow a consistent naming scheme for member functions. They now all start with capital letters (e.g., setWorldOrientation becomes SetWorldOrientation).
    BGE Physics Cleanup: Getting rid of KX_GameObject::SuspendDynamics() and KX_GameObject::RestoreDynamics(). Instead, use the functions from the physics controller.
    BGE: Some first steps in trying to cleanup the KX_IPhysicsController mess. KX_GameObject now has a GetPhysicsController() and a GetPhysicsController1(). The former returns a PHY_IPhysicsController* while the latter returns a KX_IPhysicsController. The goal is to get everything using GetPhysicsController() instead of GetPhysicsController1().

48 files changed:
source/gameengine/Converter/BL_BlenderDataConversion.cpp
source/gameengine/Converter/BL_ModifierDeformer.cpp
source/gameengine/Converter/KX_BlenderSceneConverter.cpp
source/gameengine/Converter/KX_SoftBodyDeformer.cpp
source/gameengine/Ketsji/BL_Action.cpp
source/gameengine/Ketsji/CMakeLists.txt
source/gameengine/Ketsji/KX_BulletPhysicsController.cpp [deleted file]
source/gameengine/Ketsji/KX_BulletPhysicsController.h [deleted file]
source/gameengine/Ketsji/KX_CharacterWrapper.cpp
source/gameengine/Ketsji/KX_ConstraintActuator.cpp
source/gameengine/Ketsji/KX_ConstraintWrapper.cpp
source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
source/gameengine/Ketsji/KX_GameObject.cpp
source/gameengine/Ketsji/KX_GameObject.h
source/gameengine/Ketsji/KX_IPO_SGController.cpp
source/gameengine/Ketsji/KX_IPhysicsController.cpp [deleted file]
source/gameengine/Ketsji/KX_IPhysicsController.h [deleted file]
source/gameengine/Ketsji/KX_KetsjiEngine.cpp
source/gameengine/Ketsji/KX_MotionState.cpp
source/gameengine/Ketsji/KX_MotionState.h
source/gameengine/Ketsji/KX_MouseFocusSensor.cpp
source/gameengine/Ketsji/KX_NearSensor.cpp
source/gameengine/Ketsji/KX_ObjectActuator.cpp
source/gameengine/Ketsji/KX_PyConstraintBinding.cpp
source/gameengine/Ketsji/KX_PythonInit.cpp
source/gameengine/Ketsji/KX_RadarSensor.cpp
source/gameengine/Ketsji/KX_RayCast.cpp
source/gameengine/Ketsji/KX_RayCast.h
source/gameengine/Ketsji/KX_RaySensor.cpp
source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp
source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp
source/gameengine/Ketsji/KX_SCA_DynamicActuator.h
source/gameengine/Ketsji/KX_Scene.cpp
source/gameengine/Ketsji/KX_TouchEventManager.cpp
source/gameengine/Ketsji/KX_TouchSensor.cpp
source/gameengine/Physics/Bullet/CcdGraphicController.cpp
source/gameengine/Physics/Bullet/CcdGraphicController.h
source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
source/gameengine/Physics/Bullet/CcdPhysicsController.h
source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h
source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp
source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h
source/gameengine/Physics/common/PHY_IController.h
source/gameengine/Physics/common/PHY_IGraphicController.h
source/gameengine/Physics/common/PHY_IMotionState.h
source/gameengine/Physics/common/PHY_IPhysicsController.h
source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h

index b753f667e708e5a8680ad81848a62e4bbb65a361..1b27fde4fa43bbb2901c2c0493452550d4455559 100644 (file)
@@ -1419,12 +1419,12 @@ static void BL_CreateGraphicObjectNew(KX_GameObject* gameobj,
                                PHY_IMotionState* motionstate = new KX_MotionState(gameobj->GetSGNode());
                                CcdGraphicController* ctrl = new CcdGraphicController(env, motionstate);
                                gameobj->SetGraphicController(ctrl);
-                               ctrl->setNewClientInfo(gameobj->getClientInfo());
-                               ctrl->setLocalAabb(localAabbMin, localAabbMax);
+                               ctrl->SetNewClientInfo(gameobj->getClientInfo());
+                               ctrl->SetLocalAabb(localAabbMin, localAabbMax);
                                if (isActive) {
                                        // add first, this will create the proxy handle, only if the object is visible
                                        if (gameobj->GetVisible())
-                                               env->addCcdGraphicController(ctrl);
+                                               env->AddCcdGraphicController(ctrl);
                                        // update the mesh if there is a deformer, this will also update the bounding box for modifiers
                                        RAS_Deformer* deformer = gameobj->GetDeformer();
                                        if (deformer)
@@ -2027,22 +2027,8 @@ static void UNUSED_FUNCTION(RBJconstraints)(Object *ob)//not used
 }
 
 #include "PHY_IPhysicsEnvironment.h"
-#include "KX_IPhysicsController.h"
 #include "PHY_DynamicTypes.h"
 
-#if 0  /* UNUSED */
-static KX_IPhysicsController* getPhId(CListValue* sumolist,STR_String busc) {//not used
-
-       for (int j=0;j<sumolist->GetCount();j++)
-       {
-               KX_GameObject* gameobje = (KX_GameObject*) sumolist->GetValue(j);
-               if (gameobje->GetName()==busc)
-                       return gameobje->GetPhysicsController();
-       }
-
-       return 0;
-}
-#endif
 
 static KX_GameObject* getGameOb(STR_String busc,CListValue* sumolist)
 {
@@ -2585,7 +2571,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
                        kxscene->SetDbvtOcclusionRes(blenderscene->gm.occlusionRes);
        }
        if (blenderscene->world)
-               kxscene->GetPhysicsEnvironment()->setNumTimeSubSteps(blenderscene->gm.physubstep);
+               kxscene->GetPhysicsEnvironment()->SetNumTimeSubSteps(blenderscene->gm.physubstep);
 
        // now that the scenegraph is complete, let's instantiate the deformers.
        // We need that to create reusable derived mesh and physic shapes
@@ -2676,12 +2662,12 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
                                                {
                                                        KX_GameObject *gotar=getGameOb(dat->tar->id.name+2,sumolist);
                                                        if (gotar && ((gotar->GetLayer()&activeLayerBitInfo)!=0) && gotar->GetPhysicsController())
-                                                               physctr2 = (PHY_IPhysicsController*) gotar->GetPhysicsController()->GetUserData();
+                                                               physctr2 = gotar->GetPhysicsController();
                                                }
 
                                                if (gameobj->GetPhysicsController())
                                                {
-                                                       PHY_IPhysicsController* physctrl = (PHY_IPhysicsController*) gameobj->GetPhysicsController()->GetUserData();
+                                                       PHY_IPhysicsController* physctrl = gameobj->GetPhysicsController();
                                                        //we need to pass a full constraint frame, not just axis
 
                                                        //localConstraintFrameBasis
@@ -2690,7 +2676,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
                                                        MT_Vector3 axis1 = localCFrame.getColumn(1);
                                                        MT_Vector3 axis2 = localCFrame.getColumn(2);
                                                                
-                                                       int constraintId = kxscene->GetPhysicsEnvironment()->createConstraint(physctrl,physctr2,(PHY_ConstraintType)dat->type,(float)dat->pivX,
+                                                       int constraintId = kxscene->GetPhysicsEnvironment()->CreateConstraint(physctrl,physctr2,(PHY_ConstraintType)dat->type,(float)dat->pivX,
                                                                (float)dat->pivY,(float)dat->pivZ,
                                                                (float)axis0.x(),(float)axis0.y(),(float)axis0.z(),
                                                                (float)axis1.x(),(float)axis1.y(),(float)axis1.z(),
@@ -2706,11 +2692,11 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
                                                                        {
                                                                                if (dat->flag & dofbit)
                                                                                {
-                                                                                       kxscene->GetPhysicsEnvironment()->setConstraintParam(constraintId,dof,dat->minLimit[dof],dat->maxLimit[dof]);
+                                                                                       kxscene->GetPhysicsEnvironment()->SetConstraintParam(constraintId,dof,dat->minLimit[dof],dat->maxLimit[dof]);
                                                                                } else
                                                                                {
                                                                                        //minLimit > maxLimit means free(disabled limit) for this degree of freedom
-                                                                                       kxscene->GetPhysicsEnvironment()->setConstraintParam(constraintId,dof,1,-1);
+                                                                                       kxscene->GetPhysicsEnvironment()->SetConstraintParam(constraintId,dof,1,-1);
                                                                                }
                                                                                dofbit<<=1;
                                                                        }
@@ -2724,12 +2710,12 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
                                                                        {
                                                                                if (dat->flag & dofbit)
                                                                                {
-                                                                                       kxscene->GetPhysicsEnvironment()->setConstraintParam(constraintId,dof,dat->minLimit[dof],dat->maxLimit[dof]);
+                                                                                       kxscene->GetPhysicsEnvironment()->SetConstraintParam(constraintId,dof,dat->minLimit[dof],dat->maxLimit[dof]);
                                                                                }
                                                                                else
                                                                                {
                                                                                        //maxLimit < 0 means free(disabled limit) for this degree of freedom
-                                                                                       kxscene->GetPhysicsEnvironment()->setConstraintParam(constraintId,dof,1,-1);
+                                                                                       kxscene->GetPhysicsEnvironment()->SetConstraintParam(constraintId,dof,1,-1);
                                                                                }
                                                                                dofbit<<=1;
                                                                        }
@@ -2741,12 +2727,12 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
                                                                        
                                                                        if (dat->flag & dofbit)
                                                                        {
-                                                                               kxscene->GetPhysicsEnvironment()->setConstraintParam(constraintId,dof,
+                                                                               kxscene->GetPhysicsEnvironment()->SetConstraintParam(constraintId,dof,
                                                                                                dat->minLimit[dof],dat->maxLimit[dof]);
                                                                        } else
                                                                        {
                                                                                //minLimit > maxLimit means free(disabled limit) for this degree of freedom
-                                                                               kxscene->GetPhysicsEnvironment()->setConstraintParam(constraintId,dof,1,-1);
+                                                                               kxscene->GetPhysicsEnvironment()->SetConstraintParam(constraintId,dof,1,-1);
                                                                        }
                                                                }
                                                        }
index ec52eaac6373f9ca50d6e90f9c5c2298f870637a..82f49ad52275d4df53aa7e94a76abb58247094be 100644 (file)
@@ -192,7 +192,7 @@ bool BL_ModifierDeformer::Update(void)
                                float min_r[3], max_r[3];
                                INIT_MINMAX(min_r, max_r);
                                m_dm->getMinMax(m_dm, min_r, max_r);
-                               ctrl->setLocalAabb(min_r, max_r);
+                               ctrl->SetLocalAabb(min_r, max_r);
                        }
                }
                m_lastModifierUpdate=m_gameobj->GetLastFrame();
index f642fd43aef8f8131f8330121f958a885a2b1c98..e682f3356086ed40ac267fa6fe15a28cd7b06fcf 100644 (file)
@@ -42,7 +42,6 @@
 #include "PHY_IPhysicsEnvironment.h"
 #include "KX_KetsjiEngine.h"
 #include "KX_PythonInit.h" // So we can handle adding new text datablocks for Python to import
-#include "KX_IPhysicsController.h"
 #include "BL_Material.h"
 #include "BL_ActionActuator.h"
 #include "KX_BlenderMaterial.h"
@@ -355,15 +354,15 @@ void KX_BlenderSceneConverter::ConvertScene(class KX_Scene* destinationscene,
                case UseBullet:
                        {
                                CcdPhysicsEnvironment* ccdPhysEnv = new CcdPhysicsEnvironment(useDbvtCulling);
-                               ccdPhysEnv->setDebugDrawer(new BlenderDebugDraw());
-                               ccdPhysEnv->setDeactivationLinearTreshold(blenderscene->gm.lineardeactthreshold);
-                               ccdPhysEnv->setDeactivationAngularTreshold(blenderscene->gm.angulardeactthreshold);
-                               ccdPhysEnv->setDeactivationTime(blenderscene->gm.deactivationtime);
+                               ccdPhysEnv->SetDebugDrawer(new BlenderDebugDraw());
+                               ccdPhysEnv->SetDeactivationLinearTreshold(blenderscene->gm.lineardeactthreshold);
+                               ccdPhysEnv->SetDeactivationAngularTreshold(blenderscene->gm.angulardeactthreshold);
+                               ccdPhysEnv->SetDeactivationTime(blenderscene->gm.deactivationtime);
 
                                SYS_SystemHandle syshandle = SYS_GetSystem(); /*unused*/
                                int visualizePhysics = SYS_GetCommandLineInt(syshandle,"show_physics",0);
                                if (visualizePhysics)
-                                       ccdPhysEnv->setDebugMode(btIDebugDraw::DBG_DrawWireframe|btIDebugDraw::DBG_DrawAabb|btIDebugDraw::DBG_DrawContactPoints|btIDebugDraw::DBG_DrawText|btIDebugDraw::DBG_DrawConstraintLimits|btIDebugDraw::DBG_DrawConstraints);
+                                       ccdPhysEnv->SetDebugMode(btIDebugDraw::DBG_DrawWireframe|btIDebugDraw::DBG_DrawAabb|btIDebugDraw::DBG_DrawContactPoints|btIDebugDraw::DBG_DrawText|btIDebugDraw::DBG_DrawConstraintLimits|btIDebugDraw::DBG_DrawConstraints);
                
                                //todo: get a button in blender ?
                                //disable / enable debug drawing (contact points, aabb's etc)
@@ -709,7 +708,6 @@ void        KX_BlenderSceneConverter::ResetPhysicsObjectsAnimationIpo(bool clearIpo)
                        KX_GameObject* gameObj = (KX_GameObject*)parentList->GetValue(g);
                        if (gameObj->IsDynamic())
                        {
-                               //KX_IPhysicsController* physCtrl = gameObj->GetPhysicsController();
                                
                                Object* blenderObject = gameObj->GetBlenderObject();
                                if (blenderObject)
@@ -825,7 +823,6 @@ void        KX_BlenderSceneConverter::WritePhysicsObjectToAnimationIpo(int frameNumber)
                        Object* blenderObject = gameObj->GetBlenderObject();
                        if (blenderObject && blenderObject->parent==NULL && gameObj->IsDynamic())
                        {
-                               //KX_IPhysicsController* physCtrl = gameObj->GetPhysicsController();
 
                                if (blenderObject->adt==NULL)
                                        BKE_id_add_animdata(&blenderObject->id);
@@ -944,7 +941,6 @@ void        KX_BlenderSceneConverter::TestHandlesPhysicsObjectToAnimationIpo()
                        KX_GameObject* gameObj = (KX_GameObject*)parentList->GetValue(g);
                        if (gameObj->IsDynamic())
                        {
-                               //KX_IPhysicsController* physCtrl = gameObj->GetPhysicsController();
                                
 #if 0
                                Object* blenderObject = gameObj->GetBlenderObject();
index d860b2ee6943702e242da255b7c4b8c0c5625f26..fcdaaaa761aacd162fbf618c10c23245eb8740cf 100644 (file)
@@ -48,7 +48,6 @@
 #include "CcdPhysicsController.h"
 #include "BulletSoftBody/btSoftBody.h"
 
-#include "KX_BulletPhysicsController.h"
 #include "btBulletDynamicsCommon.h"
 
 void KX_SoftBodyDeformer::Relink(CTR_Map<class CTR_HashedPtr, void*>*map)
@@ -66,7 +65,7 @@ void KX_SoftBodyDeformer::Relink(CTR_Map<class CTR_HashedPtr, void*>*map)
 
 bool KX_SoftBodyDeformer::Apply(class RAS_IPolyMaterial *polymat)
 {
-       KX_BulletPhysicsController* ctrl = (KX_BulletPhysicsController*) m_gameobj->GetPhysicsController();
+       CcdPhysicsController* ctrl = (CcdPhysicsController*) m_gameobj->GetPhysicsController();
        if (!ctrl)
                return false;
 
index 6d9b22eed91d1a11ffe2a8c49f8e7a3b1dea4b6e..a974ffbf672c51f9cb646ed9ae4eafe081181794 100644 (file)
@@ -34,6 +34,8 @@
 #include "KX_IpoConvert.h"
 #include "KX_GameObject.h"
 
+#include "SG_Controller.h"
+
 // These three are for getting the action from the logic manager
 #include "KX_Scene.h"
 #include "SCA_LogicManager.h"
index c3c733c66ba03b09bfad0179f7e3d289e6173606..141dd5e25f3bca612497287b54d6f8148bfcd8fd 100644 (file)
@@ -71,7 +71,6 @@ set(SRC
        BL_Texture.cpp
        KX_ArmatureSensor.cpp
        KX_BlenderMaterial.cpp
-       KX_BulletPhysicsController.cpp
        KX_Camera.cpp
        KX_CameraActuator.cpp
        KX_CameraIpoSGController.cpp
@@ -86,7 +85,6 @@ set(SRC
        KX_GameObject.cpp
        KX_IpoConvert.cpp
        KX_IPO_SGController.cpp
-       KX_IPhysicsController.cpp
        KX_IpoActuator.cpp
        KX_KetsjiEngine.cpp
        KX_Light.cpp
@@ -146,7 +144,6 @@ set(SRC
        BL_Texture.h
        KX_ArmatureSensor.h
        KX_BlenderMaterial.h
-       KX_BulletPhysicsController.h
        KX_Camera.h
        KX_CameraActuator.h
        KX_CameraIpoSGController.h
@@ -164,7 +161,6 @@ set(SRC
        KX_IpoConvert.h
        KX_IPOTransform.h
        KX_IPO_SGController.h
-       KX_IPhysicsController.h
        KX_IScalarInterpolator.h
        KX_ISceneConverter.h
        KX_ISystem.h
diff --git a/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp b/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp
deleted file mode 100644 (file)
index e990974..0000000
+++ /dev/null
@@ -1,577 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/Ketsji/KX_BulletPhysicsController.cpp
- *  \ingroup ketsji
- */
-
-//under visual studio the #define in KX_ConvertPhysicsObject.h is quicker for recompilation
-#include "KX_ConvertPhysicsObject.h"
-
-#ifdef WITH_BULLET
-
-#include "KX_BulletPhysicsController.h"
-
-#include "btBulletDynamicsCommon.h"
-#include "SG_Spatial.h"
-
-#include "KX_GameObject.h"
-#include "KX_MotionState.h"
-#include "KX_ClientObjectInfo.h"
-
-#include "PHY_IPhysicsEnvironment.h"
-#include "CcdPhysicsEnvironment.h"
-#include "BulletSoftBody/btSoftBody.h"
-
-
-KX_BulletPhysicsController::KX_BulletPhysicsController (const CcdConstructionInfo& ci, bool dyna, bool sensor, bool character, bool compound)
-: KX_IPhysicsController(dyna,sensor,character,compound,(PHY_IPhysicsController*)this),
-CcdPhysicsController(ci),
-m_savedCollisionFlags(0),
-m_savedCollisionFilterGroup(0),
-m_savedCollisionFilterMask(0),
-m_savedMass(0.0),
-m_savedDyna(false),
-m_suspended(false),
-m_bulletChildShape(NULL)
-{
-}
-       
-KX_BulletPhysicsController::~KX_BulletPhysicsController ()
-{
-       // The game object has a direct link to 
-       if (m_pObject)
-       {
-               // If we cheat in SetObject, we must also cheat here otherwise the 
-               // object will still things it has a physical controller
-               // Note that it requires that m_pObject is reset in case the object is deleted
-               // before the controller (usual case, see KX_Scene::RemoveNodeDestructObjec)
-               // The non usual case is when the object is not deleted because its reference is hanging
-               // in a AddObject actuator but the node is deleted. This case is covered here.
-               KX_GameObject* gameobj = (KX_GameObject*)       m_pObject->GetSGClientObject();
-               gameobj->SetPhysicsController(NULL,false);
-       }
-}
-
-void   KX_BulletPhysicsController::resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ)
-{
-       CcdPhysicsController::resolveCombinedVelocities(linvelX,linvelY,linvelZ,angVelX,angVelY,angVelZ);
-
-}
-
-
-       ///////////////////////////////////
-       //      KX_IPhysicsController interface
-       ////////////////////////////////////
-
-void   KX_BulletPhysicsController::applyImpulse(const MT_Point3& attach, const MT_Vector3& impulse)
-{
-               CcdPhysicsController::applyImpulse(attach[0],attach[1],attach[2],impulse[0],impulse[1],impulse[2]);
-
-}
-
-float KX_BulletPhysicsController::GetLinVelocityMin()
-{
-       return (float)CcdPhysicsController::GetLinVelocityMin();
-}
-void  KX_BulletPhysicsController::SetLinVelocityMin(float val)
-{
-       CcdPhysicsController::SetLinVelocityMin(val);
-}
-
-void KX_BulletPhysicsController::Jump()
-{
-       CcdPhysicsController::Jump();
-}
-
-float KX_BulletPhysicsController::GetLinVelocityMax()
-{
-       return (float)CcdPhysicsController::GetLinVelocityMax();
-}
-void  KX_BulletPhysicsController::SetLinVelocityMax(float val)
-{
-       CcdPhysicsController::SetLinVelocityMax(val);
-}
-
-void   KX_BulletPhysicsController::SetObject (SG_IObject* object)
-{
-       SG_Controller::SetObject(object);
-
-       // cheating here...
-       //should not be necessary, is it for duplicates ?
-
-       KX_GameObject* gameobj = (KX_GameObject*)       object->GetSGClientObject();
-       gameobj->SetPhysicsController(this,gameobj->IsDynamic());
-       CcdPhysicsController::setNewClientInfo(gameobj->getClientInfo());
-
-       if (m_bSensor)
-       {
-               // use a different callback function for sensor object, 
-               // bullet will not synchronize, we must do it explicitly
-               SG_Callbacks& callbacks = gameobj->GetSGNode()->GetCallBackFunctions();
-               callbacks.m_updatefunc = KX_GameObject::SynchronizeTransformFunc;
-       } 
-}
-
-MT_Scalar KX_BulletPhysicsController::GetRadius()
-{
-       return MT_Scalar(CcdPhysicsController::GetRadius());
-}
-
-void   KX_BulletPhysicsController::setMargin (float collisionMargin)
-{
-       CcdPhysicsController::SetMargin(collisionMargin);
-}
-void   KX_BulletPhysicsController::RelativeTranslate(const MT_Vector3& dloc,bool local)
-{
-       CcdPhysicsController::RelativeTranslate(dloc[0],dloc[1],dloc[2],local);
-
-}
-
-void   KX_BulletPhysicsController::SetWalkDirection(const MT_Vector3& dloc,bool local)
-{
-       CcdPhysicsController::SetWalkDirection(dloc[0],dloc[1],dloc[2],local);
-}
-
-void   KX_BulletPhysicsController::RelativeRotate(const MT_Matrix3x3& drot,bool local)
-{
-       float   rotval[9];
-       drot.getValue3x3(rotval);
-       CcdPhysicsController::RelativeRotate(rotval,local);
-}
-
-void   KX_BulletPhysicsController::ApplyTorque(const MT_Vector3& torque,bool local)
-{
-               CcdPhysicsController::ApplyTorque(torque.x(),torque.y(),torque.z(),local);
-}
-void   KX_BulletPhysicsController::ApplyForce(const MT_Vector3& force,bool local)
-{
-       CcdPhysicsController::ApplyForce(force.x(),force.y(),force.z(),local);
-}
-MT_Vector3 KX_BulletPhysicsController::GetLinearVelocity()
-{
-       float angVel[3];
-       //CcdPhysicsController::GetAngularVelocity(angVel[0],angVel[1],angVel[2]);
-       CcdPhysicsController::GetLinearVelocity(angVel[0],angVel[1],angVel[2]);//rcruiz
-       return MT_Vector3(angVel[0],angVel[1],angVel[2]);
-}
-MT_Vector3 KX_BulletPhysicsController::GetAngularVelocity()
-{
-       float angVel[3];
-       //CcdPhysicsController::GetAngularVelocity(angVel[0],angVel[1],angVel[2]);
-       CcdPhysicsController::GetAngularVelocity(angVel[0],angVel[1],angVel[2]);//rcruiz
-       return MT_Vector3(angVel[0],angVel[1],angVel[2]);
-}
-MT_Vector3 KX_BulletPhysicsController::GetVelocity(const MT_Point3& pos)
-{
-       float linVel[3];
-       CcdPhysicsController::GetVelocity(pos[0], pos[1], pos[2], linVel[0],linVel[1],linVel[2]);
-       return MT_Vector3(linVel[0],linVel[1],linVel[2]);
-}
-
-MT_Vector3 KX_BulletPhysicsController::GetWalkDirection()
-{
-       float dir[3];
-       CcdPhysicsController::GetWalkDirection(dir[0], dir[1], dir[2]);
-       return MT_Vector3(dir[0], dir[1], dir[2]);
-}
-
-void   KX_BulletPhysicsController::SetAngularVelocity(const MT_Vector3& ang_vel,bool local)
-{
-       CcdPhysicsController::SetAngularVelocity(ang_vel.x(),ang_vel.y(),ang_vel.z(),local);
-
-}
-void   KX_BulletPhysicsController::SetLinearVelocity(const MT_Vector3& lin_vel,bool local)
-{
-       CcdPhysicsController::SetLinearVelocity(lin_vel.x(),lin_vel.y(),lin_vel.z(),local);
-}
-void   KX_BulletPhysicsController::getOrientation(MT_Quaternion& orn)
-{
-       float myorn[4];
-       CcdPhysicsController::getOrientation(myorn[0],myorn[1],myorn[2],myorn[3]);
-       orn = MT_Quaternion(myorn[0],myorn[1],myorn[2],myorn[3]);
-}
-void KX_BulletPhysicsController::setOrientation(const MT_Matrix3x3& orn)
-{
-       btMatrix3x3 btmat(orn[0][0], orn[0][1], orn[0][2], orn[1][0], orn[1][1], orn[1][2], orn[2][0], orn[2][1], orn[2][2]);
-       CcdPhysicsController::setWorldOrientation(btmat);
-}
-void KX_BulletPhysicsController::setPosition(const MT_Point3& pos)
-{
-       CcdPhysicsController::setPosition(pos.x(),pos.y(),pos.z());
-}
-void KX_BulletPhysicsController::setScaling(const MT_Vector3& scaling)
-{
-       CcdPhysicsController::setScaling(scaling.x(),scaling.y(),scaling.z());
-}
-void KX_BulletPhysicsController::SetTransform()
-{
-       btVector3 pos;
-       btVector3 scale;
-       float ori[12];
-       m_MotionState->getWorldPosition(pos.m_floats[0],pos.m_floats[1],pos.m_floats[2]);
-       m_MotionState->getWorldScaling(scale.m_floats[0],scale.m_floats[1],scale.m_floats[2]);
-       m_MotionState->getWorldOrientation(ori);
-       btMatrix3x3 rot(ori[0], ori[4], ori[8],
-                                       ori[1], ori[5], ori[9],
-                                       ori[2], ori[6], ori[10]);
-       CcdPhysicsController::forceWorldTransform(rot, pos);
-}
-
-MT_Scalar      KX_BulletPhysicsController::GetMass()
-{
-       if (GetSoftBody())
-               return GetSoftBody()->getTotalMass();
-       
-       MT_Scalar invmass = 0.f;
-       if (GetRigidBody())
-               invmass = GetRigidBody()->getInvMass();
-       if (invmass)
-               return 1.f/invmass;
-       return 0.f;
-
-}
-
-MT_Vector3 KX_BulletPhysicsController::GetLocalInertia()
-{
-       MT_Vector3 inertia(0.f, 0.f, 0.f);
-       btVector3 inv_inertia;
-       if (GetRigidBody()) {
-               inv_inertia = GetRigidBody()->getInvInertiaDiagLocal();
-               if (!btFuzzyZero(inv_inertia.getX()) &&
-                       !btFuzzyZero(inv_inertia.getY()) &&
-                       !btFuzzyZero(inv_inertia.getZ()))
-                       inertia = MT_Vector3(1.f/inv_inertia.getX(), 1.f/inv_inertia.getY(), 1.f/inv_inertia.getZ());
-       }
-       return inertia;
-}
-
-MT_Vector3     KX_BulletPhysicsController::getReactionForce()
-{
-       assert(0);
-       return MT_Vector3(0.f,0.f,0.f);
-}
-void   KX_BulletPhysicsController::setRigidBody(bool rigid)
-{
-       CcdPhysicsController::setRigidBody(rigid);
-}
-
-/* This function dynamically adds the collision shape of another controller to
- * the current controller shape provided it is a compound shape.
- * The idea is that dynamic parenting on a compound object will dynamically extend the shape
- */
-void    KX_BulletPhysicsController::AddCompoundChild(KX_IPhysicsController* child)
-{ 
-       if (child == NULL || !IsCompound())
-               return;
-       // other controller must be a bullet controller too
-       // verify that body and shape exist and match
-       KX_BulletPhysicsController* childCtrl = dynamic_cast<KX_BulletPhysicsController*>(child);
-       btRigidBody* rootBody = GetRigidBody();
-       btRigidBody* childBody = childCtrl->GetRigidBody();
-       if (!rootBody || !childBody)
-               return;
-       const btCollisionShape* rootShape = rootBody->getCollisionShape();
-       const btCollisionShape* childShape = childBody->getCollisionShape();
-       if (!rootShape || 
-               !childShape || 
-               rootShape->getShapeType() != COMPOUND_SHAPE_PROXYTYPE ||
-               childShape->getShapeType() == COMPOUND_SHAPE_PROXYTYPE)
-               return;
-       btCompoundShape* compoundShape = (btCompoundShape*)rootShape;
-       // compute relative transformation between parent and child
-       btTransform rootTrans;
-       btTransform childTrans;
-       rootBody->getMotionState()->getWorldTransform(rootTrans);
-       childBody->getMotionState()->getWorldTransform(childTrans);
-       btVector3 rootScale = rootShape->getLocalScaling();
-       rootScale[0] = 1.0/rootScale[0];
-       rootScale[1] = 1.0/rootScale[1];
-       rootScale[2] = 1.0/rootScale[2];
-       // relative scale = child_scale/parent_scale
-       btVector3 relativeScale = childShape->getLocalScaling()*rootScale;
-       btMatrix3x3 rootRotInverse = rootTrans.getBasis().transpose();
-       // relative pos = parent_rot^-1 * ((parent_pos-child_pos)/parent_scale)
-       btVector3 relativePos = rootRotInverse*((childTrans.getOrigin()-rootTrans.getOrigin())*rootScale);
-       // relative rot = parent_rot^-1 * child_rot
-       btMatrix3x3 relativeRot = rootRotInverse*childTrans.getBasis();
-       // create a proxy shape info to store the transformation
-       CcdShapeConstructionInfo* proxyShapeInfo = new CcdShapeConstructionInfo();
-       // store the transformation to this object shapeinfo
-       proxyShapeInfo->m_childTrans.setOrigin(relativePos);
-       proxyShapeInfo->m_childTrans.setBasis(relativeRot);
-       proxyShapeInfo->m_childScale.setValue(relativeScale[0], relativeScale[1], relativeScale[2]);
-       // we will need this to make sure that we remove the right proxy later when unparenting
-       proxyShapeInfo->m_userData = childCtrl;
-       proxyShapeInfo->SetProxy(childCtrl->GetShapeInfo()->AddRef());
-       // add to parent compound shapeinfo (increments ref count)
-       GetShapeInfo()->AddShape(proxyShapeInfo);
-       // create new bullet collision shape from the object shapeinfo and set scaling
-       btCollisionShape* newChildShape = proxyShapeInfo->CreateBulletShape(childCtrl->GetMargin(), childCtrl->getConstructionInfo().m_bGimpact, true);
-       newChildShape->setLocalScaling(relativeScale);
-       // add bullet collision shape to parent compound collision shape
-       compoundShape->addChildShape(proxyShapeInfo->m_childTrans,newChildShape);
-       // proxyShapeInfo is not needed anymore, release it
-       proxyShapeInfo->Release();
-       // remember we created this shape
-       childCtrl->m_bulletChildShape = newChildShape;
-       // recompute inertia of parent
-       if (!rootBody->isStaticOrKinematicObject())
-       {
-               btVector3 localInertia;
-               float mass = 1.f/rootBody->getInvMass();
-               compoundShape->calculateLocalInertia(mass,localInertia);
-               rootBody->setMassProps(mass,localInertia);
-       }
-       // must update the broadphase cache,
-       GetPhysicsEnvironment()->refreshCcdPhysicsController(this);
-       // remove the children
-       GetPhysicsEnvironment()->disableCcdPhysicsController(childCtrl);
-}
-
-/* Reverse function of the above, it will remove a shape from a compound shape
- * provided that the former was added to the later using  AddCompoundChild()
- */
-void    KX_BulletPhysicsController::RemoveCompoundChild(KX_IPhysicsController* child)
-{ 
-       if (child == NULL || !IsCompound())
-               return;
-       // other controller must be a bullet controller too
-       // verify that body and shape exist and match
-       KX_BulletPhysicsController* childCtrl = dynamic_cast<KX_BulletPhysicsController*>(child);
-       btRigidBody* rootBody = GetRigidBody();
-       btRigidBody* childBody = childCtrl->GetRigidBody();
-       if (!rootBody || !childBody)
-               return;
-       const btCollisionShape* rootShape = rootBody->getCollisionShape();
-       if (!rootShape || 
-               rootShape->getShapeType() != COMPOUND_SHAPE_PROXYTYPE)
-               return;
-       btCompoundShape* compoundShape = (btCompoundShape*)rootShape;
-       // retrieve the shapeInfo
-       CcdShapeConstructionInfo* childShapeInfo = childCtrl->GetShapeInfo();
-       CcdShapeConstructionInfo* rootShapeInfo = GetShapeInfo();
-       // and verify that the child is part of the parent
-       int i = rootShapeInfo->FindChildShape(childShapeInfo, childCtrl);
-       if (i < 0)
-               return;
-       rootShapeInfo->RemoveChildShape(i);
-       if (childCtrl->m_bulletChildShape)
-       {
-               int numChildren = compoundShape->getNumChildShapes();
-               for (i=0; i<numChildren; i++)
-               {
-                       if (compoundShape->getChildShape(i) == childCtrl->m_bulletChildShape)
-                       {
-                               compoundShape->removeChildShapeByIndex(i);
-                               compoundShape->recalculateLocalAabb();
-                               break;
-                       }
-               }
-               delete childCtrl->m_bulletChildShape;
-               childCtrl->m_bulletChildShape = NULL;
-       }
-       // recompute inertia of parent
-       if (!rootBody->isStaticOrKinematicObject())
-       {
-               btVector3 localInertia;
-               float mass = 1.f/rootBody->getInvMass();
-               compoundShape->calculateLocalInertia(mass,localInertia);
-               rootBody->setMassProps(mass,localInertia);
-       }
-       // must update the broadphase cache,
-       GetPhysicsEnvironment()->refreshCcdPhysicsController(this);
-       // reactivate the children
-       GetPhysicsEnvironment()->enableCcdPhysicsController(childCtrl);
-}
-
-void KX_BulletPhysicsController::SetMass(MT_Scalar newmass)
-{
-       btRigidBody *body = GetRigidBody();
-       if (body && !m_suspended && newmass>MT_EPSILON && GetMass()>MT_EPSILON)
-       {
-               btVector3 grav = body->getGravity();
-               btVector3 accel = grav / GetMass();
-               
-               btBroadphaseProxy* handle = body->getBroadphaseHandle();
-               GetPhysicsEnvironment()->updateCcdPhysicsController(this, 
-                       newmass,
-                       body->getCollisionFlags(),
-                       handle->m_collisionFilterGroup, 
-                       handle->m_collisionFilterMask);
-               body->setGravity(accel);
-       }
-}
-
-void   KX_BulletPhysicsController::SuspendDynamics(bool ghost)
-{
-       btRigidBody *body = GetRigidBody();
-       if (body && !m_suspended && !IsSensor())
-       {
-               btBroadphaseProxy* handle = body->getBroadphaseHandle();
-               m_savedCollisionFlags = body->getCollisionFlags();
-               m_savedMass = GetMass();
-               m_savedDyna = m_bDyna;
-               m_savedCollisionFilterGroup = handle->m_collisionFilterGroup;
-               m_savedCollisionFilterMask = handle->m_collisionFilterMask;
-               m_suspended = true;
-               GetPhysicsEnvironment()->updateCcdPhysicsController(this, 
-                       0.0,
-                       btCollisionObject::CF_STATIC_OBJECT|((ghost)?btCollisionObject::CF_NO_CONTACT_RESPONSE:(m_savedCollisionFlags&btCollisionObject::CF_NO_CONTACT_RESPONSE)),
-                       btBroadphaseProxy::StaticFilter, 
-                       btBroadphaseProxy::AllFilter ^ btBroadphaseProxy::StaticFilter);
-               m_bDyna = false;
-       }
-}
-
-void   KX_BulletPhysicsController::RestoreDynamics()
-{
-       btRigidBody *body = GetRigidBody();
-       if (body && m_suspended)
-       {
-               // before make sure any position change that was done in this logic frame are accounted for
-               SetTransform();
-               GetPhysicsEnvironment()->updateCcdPhysicsController(this, 
-                       m_savedMass,
-                       m_savedCollisionFlags,
-                       m_savedCollisionFilterGroup,
-                       m_savedCollisionFilterMask);
-               body->activate();
-               m_bDyna = m_savedDyna;
-               m_suspended = false;
-       }
-}
-
-SG_Controller* KX_BulletPhysicsController::GetReplica(class SG_Node* destnode)
-{
-       PHY_IMotionState* motionstate = new KX_MotionState(destnode);
-
-       KX_BulletPhysicsController* physicsreplica = new KX_BulletPhysicsController(*this);
-
-       //parentcontroller is here be able to avoid collisions between parent/child
-
-       PHY_IPhysicsController* parentctrl = NULL;
-       KX_BulletPhysicsController* parentKxCtrl = NULL;
-       CcdPhysicsController* ccdParent = NULL;
-
-       
-       if (destnode != destnode->GetRootSGParent())
-       {
-               KX_GameObject* clientgameobj = (KX_GameObject*) destnode->GetRootSGParent()->GetSGClientObject();
-               if (clientgameobj)
-               {
-                       parentctrl = (KX_BulletPhysicsController*)clientgameobj->GetPhysicsController();
-               } else
-               {
-                       // it could be a false node, try the children
-                       NodeList::const_iterator childit;
-                       for (
-                               childit = destnode->GetSGChildren().begin();
-                       childit!= destnode->GetSGChildren().end();
-                       ++childit
-                               ) {
-                               KX_GameObject *clientgameobj_child = static_cast<KX_GameObject*>( (*childit)->GetSGClientObject());
-                               if (clientgameobj_child)
-                               {
-                                       parentKxCtrl = (KX_BulletPhysicsController*)clientgameobj_child->GetPhysicsController();
-                                       parentctrl = parentKxCtrl;
-                                       ccdParent = parentKxCtrl;
-                               }
-                       }
-               }
-       }
-
-       physicsreplica->setParentCtrl(ccdParent);
-       physicsreplica->PostProcessReplica(motionstate,parentctrl);
-       physicsreplica->m_userdata = (PHY_IPhysicsController*)physicsreplica;
-       physicsreplica->m_bulletChildShape = NULL;
-       return physicsreplica;
-       
-}
-
-
-
-void   KX_BulletPhysicsController::SetSumoTransform(bool nondynaonly)
-{
-
-       if (!m_bDyna && !m_bSensor && !m_bCharacter)
-       {
-               btCollisionObject* object = GetRigidBody();
-               object->setActivationState(ACTIVE_TAG);
-               object->setCollisionFlags(object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
-       } else
-       {
-               if (!nondynaonly)
-               {
-                       /*
-                       btTransform worldTrans;
-                       if (GetRigidBody())
-                       {
-                               GetRigidBody()->getMotionState()->getWorldTransform(worldTrans);
-                               GetRigidBody()->setCenterOfMassTransform(worldTrans);
-                       }
-                       */
-                       /*
-                       scaling?
-                       if (m_bDyna)
-                       {
-                               m_sumoObj->setScaling(MT_Vector3(1,1,1));
-                       } else
-                       {
-                               MT_Vector3 scale;
-                               GetWorldScaling(scale);
-                               m_sumoObj->setScaling(scale);
-                       }
-                       */
-
-               }
-       }
-}
-
-// todo: remove next line !
-void   KX_BulletPhysicsController::SetSimulatedTime(double time)
-{
-}
-       
-// call from scene graph to update
-bool KX_BulletPhysicsController::Update(double time)
-{
-       return false;
-
-       // todo: check this code
-       //if (GetMass())
-       //{
-       //      return false;//true;
-//     }
-//     return false;
-}
-
-
-const char* KX_BulletPhysicsController::getName()
-{
-       if (m_pObject)
-       {
-               KX_GameObject* gameobj = (KX_GameObject*)       m_pObject->GetSGClientObject();
-               return gameobj->GetName();
-       }
-       return 0;
-}
-
-#endif // WITH_BULLET
diff --git a/source/gameengine/Ketsji/KX_BulletPhysicsController.h b/source/gameengine/Ketsji/KX_BulletPhysicsController.h
deleted file mode 100644 (file)
index 3d13744..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-
-/** \file KX_BulletPhysicsController.h
- *  \ingroup ketsji
- */
-
-#ifndef __KX_BULLETPHYSICSCONTROLLER_H__
-#define __KX_BULLETPHYSICSCONTROLLER_H__
-
-
-#include "KX_IPhysicsController.h"
-#ifdef WITH_BULLET
-#include "CcdPhysicsController.h"
-#endif
-
-class KX_BulletPhysicsController : public KX_IPhysicsController, public CcdPhysicsController
-{
-private:
-       int m_savedCollisionFlags;
-       int m_savedActivationState;
-       short int m_savedCollisionFilterGroup;
-       short int m_savedCollisionFilterMask;
-       MT_Scalar m_savedMass;
-       bool m_savedDyna;
-       bool m_suspended;
-       btCollisionShape* m_bulletChildShape;
-
-public:
-#ifdef WITH_BULLET
-       KX_BulletPhysicsController (const CcdConstructionInfo& ci, bool dyna, bool sensor, bool character, bool compound);
-       virtual ~KX_BulletPhysicsController ();
-#endif
-       ///////////////////////////////////
-       //      KX_IPhysicsController interface
-       ////////////////////////////////////
-
-       virtual void    applyImpulse(const MT_Point3& attach, const MT_Vector3& impulse);
-       virtual void    SetObject (SG_IObject* object);
-       virtual void    setMargin (float collisionMargin);
-       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 void    SetWalkDirection(const MT_Vector3& dir,bool local);
-       virtual MT_Vector3 GetLinearVelocity();
-       virtual MT_Vector3 GetAngularVelocity();
-       virtual MT_Vector3 GetVelocity(const MT_Point3& pos);
-       virtual MT_Vector3 GetWalkDirection();
-       virtual void    SetAngularVelocity(const MT_Vector3& ang_vel,bool local);
-       virtual void    SetLinearVelocity(const MT_Vector3& lin_vel,bool local);
-       virtual void    Jump();
-       virtual void    getOrientation(MT_Quaternion& orn);
-       virtual void setOrientation(const MT_Matrix3x3& orn);
-       virtual void setPosition(const MT_Point3& pos);
-       virtual void setScaling(const MT_Vector3& scaling);
-       virtual void SetTransform();
-       virtual MT_Scalar       GetMass();
-       virtual void    SetMass(MT_Scalar newmass);
-       virtual MT_Vector3      GetLocalInertia();
-       virtual MT_Vector3      getReactionForce();
-       virtual void    setRigidBody(bool rigid);
-       virtual void    AddCompoundChild(KX_IPhysicsController* child);
-       virtual void    RemoveCompoundChild(KX_IPhysicsController* child);
-
-       virtual void    resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ);
-
-       virtual void    SuspendDynamics(bool ghost);
-       virtual void    RestoreDynamics();
-
-       virtual SG_Controller*  GetReplica(class SG_Node* destnode);
-
-       virtual MT_Scalar GetRadius();
-       
-       virtual float GetLinVelocityMin();
-       virtual void  SetLinVelocityMin(float val);
-       virtual float GetLinVelocityMax();
-       virtual void  SetLinVelocityMax(float val);
-
-       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;}
-       
-       virtual const char* getName();
-
-       void
-       SetOption(
-               int option,
-               int value
-       ) {
-               // intentionally empty
-       };
-
-       
-#ifdef WITH_CXX_GUARDEDALLOC
-       MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_BulletPhysicsController")
-#endif
-};
-
-#endif  /* __KX_BULLETPHYSICSCONTROLLER_H__ */
index 899a153d80fb3cb84ab303b26b81b6b8a4803668..fdf4fa01b03098cf6cf1e93cc46b78241bb27efd 100644 (file)
@@ -34,8 +34,6 @@ KX_CharacterWrapper::KX_CharacterWrapper(PHY_ICharacter* character) :
 
 KX_CharacterWrapper::~KX_CharacterWrapper()
 {
-       if (m_character)
-               delete m_character; // We're responsible for the character object!
 }
 
 #ifdef WITH_PYTHON
index a3059317d3638d073e856bc3be8cb7ad55917313..0c5e21322dfc0529098f0c06f722075dfe2cace9 100644 (file)
@@ -331,7 +331,7 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame)
                        {
                                MT_Point3 topoint = position + (m_maximumBound) * direction;
                                PHY_IPhysicsEnvironment* pe = KX_GetActiveScene()->GetPhysicsEnvironment();
-                               KX_IPhysicsController *spc = obj->GetPhysicsController();
+                               PHY_IPhysicsController *spc = obj->GetPhysicsController();
 
                                if (!pe) {
                                        std::cout << "WARNING: Constraint actuator " << GetName() << ":  There is no physics environment!" << std::endl;
@@ -345,7 +345,7 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame)
                                                parent->Release();
                                        }
                                }
-                               KX_RayCast::Callback<KX_ConstraintActuator> callback(this,spc);
+                               KX_RayCast::Callback<KX_ConstraintActuator> callback(this,dynamic_cast<PHY_IPhysicsController*>(spc));
                                result = KX_RayCast::RayTest(pe, position, topoint, callback);
                                if (result)     {
                                        MT_Vector3 newnormal = callback.m_hitNormal;
@@ -379,7 +379,7 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame)
                                                // logically we should cancel the speed along the ray direction as we set the
                                                // position along that axis
                                                spc = obj->GetPhysicsController();
-                                               if (spc && spc->IsDyna()) {
+                                               if (spc && spc->IsDynamic()) {
                                                        MT_Vector3 linV = spc->GetLinearVelocity();
                                                        // cancel the projection along the ray direction
                                                        MT_Scalar fallspeed = linV.dot(direction);
@@ -444,20 +444,20 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame)
                        normal.normalize();
                        {
                                PHY_IPhysicsEnvironment* pe = KX_GetActiveScene()->GetPhysicsEnvironment();
-                               KX_IPhysicsController *spc = obj->GetPhysicsController();
+                               PHY_IPhysicsController *spc = obj->GetPhysicsController();
 
                                if (!pe) {
                                        std::cout << "WARNING: Constraint actuator " << GetName() << ":  There is no physics environment!" << std::endl;
                                        goto CHECK_TIME;
                                }        
-                               if (!spc || !spc->IsDyna()) {
+                               if (!spc || !spc->IsDynamic()) {
                                        // the object is not dynamic, it won't support setting speed
                                        goto CHECK_TIME;
                                }
                                m_hitObject = NULL;
                                // distance of Fh area is stored in m_minimum
                                MT_Point3 topoint = position + (m_minimumBound+spc->GetRadius()) * direction;
-                               KX_RayCast::Callback<KX_ConstraintActuator> callback(this,spc);
+                               KX_RayCast::Callback<KX_ConstraintActuator> callback(this, spc);
                                result = KX_RayCast::RayTest(pe, position, topoint, callback);
                                // we expect a hit object
                                if (!m_hitObject)
index e09449c4f1d4237016fd94c8ef2c82a7419c11a5..793324fab75d0acffddfeaf08425e425515b174d 100644 (file)
@@ -64,7 +64,7 @@ PyObject *KX_ConstraintWrapper::PyGetParam(PyObject *args, PyObject *kwds)
        if (!PyArg_ParseTuple(args,"i:getParam",&dof))
                return NULL;
        
-       value = m_physenv->getConstraintParam(m_constraintId,dof);
+       value = m_physenv->GetConstraintParam(m_constraintId,dof);
        return PyFloat_FromDouble(value);
        
 }
@@ -77,7 +77,7 @@ PyObject *KX_ConstraintWrapper::PySetParam(PyObject *args, PyObject *kwds)
        if (!PyArg_ParseTuple(args,"iff:setParam",&dof,&minLimit,&maxLimit))
                return NULL;
        
-       m_physenv->setConstraintParam(m_constraintId,dof,minLimit,maxLimit);
+       m_physenv->SetConstraintParam(m_constraintId,dof,minLimit,maxLimit);
        Py_RETURN_NONE;
 }
 
index ece6abc944719b4f91fa9d57c775dc9496583066..bde50588fd38a942056bf67fdb97f22c79501c3b 100644 (file)
@@ -65,7 +65,6 @@ extern "C"{
 #include "CcdPhysicsController.h"
 #include "BulletCollision/BroadphaseCollision/btBroadphaseInterface.h"
 
-#include "KX_BulletPhysicsController.h"
 #include "btBulletDynamicsCommon.h"
 
 #ifdef WIN32
@@ -255,7 +254,7 @@ void        KX_ConvertBulletObject( class   KX_GameObject* gameobj,
                {
                        //find parent, compound shape and add to it
                        //take relative transform into account!
-                       KX_BulletPhysicsController* parentCtrl = (KX_BulletPhysicsController*)objprop->m_dynamic_parent->GetPhysicsController();
+                       CcdPhysicsController* parentCtrl = (CcdPhysicsController*)objprop->m_dynamic_parent->GetPhysicsController();
                        assert(parentCtrl);
                        CcdShapeConstructionInfo* parentShapeInfo = parentCtrl->GetShapeInfo();
                        btRigidBody* rigidbody = parentCtrl->GetRigidBody();
@@ -424,12 +423,13 @@ void      KX_ConvertBulletObject( class   KX_GameObject* gameobj,
        
        ci.m_contactProcessingThreshold = objprop->m_contactProcessingThreshold;//todo: expose this in advanced settings, just like margin, default to 10000 or so
        ci.m_bSoft = objprop->m_softbody;
+       ci.m_bDyna = isbulletdyna;
        ci.m_bSensor = isbulletsensor;
        ci.m_bCharacter = isbulletchar;
        ci.m_bGimpact = useGimpact;
        MT_Vector3 scaling = gameobj->NodeGetWorldScaling();
        ci.m_scaling.setValue(scaling[0], scaling[1], scaling[2]);
-       KX_BulletPhysicsController* physicscontroller = new KX_BulletPhysicsController(ci,isbulletdyna,isbulletsensor,isbulletchar,objprop->m_hasCompoundChildren);
+       CcdPhysicsController* physicscontroller = new CcdPhysicsController(ci);
        // shapeInfo is reference counted, decrement now as we don't use it anymore
        if (shapeInfo)
                shapeInfo->Release();
@@ -438,9 +438,9 @@ void        KX_ConvertBulletObject( class   KX_GameObject* gameobj,
        // don't add automatically sensor object, they are added when a collision sensor is registered
        if (!isbulletsensor && objprop->m_in_active_layer)
        {
-               env->addCcdPhysicsController( physicscontroller);
+               env->AddCcdPhysicsController( physicscontroller);
        }
-       physicscontroller->setNewClientInfo(gameobj->getClientInfo());
+       physicscontroller->SetNewClientInfo(gameobj->getClientInfo());
        {
                btRigidBody* rbody = physicscontroller->GetRigidBody();
 
@@ -459,8 +459,8 @@ void        KX_ConvertBulletObject( class   KX_GameObject* gameobj,
                }
        }
 
-       CcdPhysicsController* parentCtrl = objprop->m_dynamic_parent ? (KX_BulletPhysicsController*)objprop->m_dynamic_parent->GetPhysicsController() : 0;
-       physicscontroller->setParentCtrl(parentCtrl);
+       CcdPhysicsController* parentCtrl = objprop->m_dynamic_parent ? (CcdPhysicsController*)objprop->m_dynamic_parent->GetPhysicsController() : 0;
+       physicscontroller->SetParentCtrl(parentCtrl);
 
        
        //Now done directly in ci.m_collisionFlags so that it propagates to replica
@@ -504,13 +504,11 @@ void      KX_ConvertBulletObject( class   KX_GameObject* gameobj,
        }
 
 
-       gameobj->GetSGNode()->AddSGController(physicscontroller);
 
        STR_String materialname;
        if (meshobj)
                materialname = meshobj->GetMaterialName(0);
 
-       physicscontroller->SetObject(gameobj->GetSGNode());
 
 #if 0
        ///test for soft bodies
@@ -546,7 +544,7 @@ void        KX_ClearBulletSharedShapes()
  */
 bool KX_ReInstanceBulletShapeFromMesh(KX_GameObject *gameobj, KX_GameObject *from_gameobj, RAS_MeshObject* from_meshobj)
 {
-       KX_BulletPhysicsController      *spc= static_cast<KX_BulletPhysicsController*>((gameobj->GetPhysicsController()));
+       CcdPhysicsController    *spc= static_cast<CcdPhysicsController*>(gameobj->GetPhysicsController());
        CcdShapeConstructionInfo        *shapeInfo;
 
        /* if this is the child of a compound shape this can happen
@@ -568,7 +566,7 @@ bool KX_ReInstanceBulletShapeFromMesh(KX_GameObject *gameobj, KX_GameObject *fro
        shapeInfo->UpdateMesh(from_gameobj, from_meshobj);
 
        /* create the new bullet mesh */
-       CcdConstructionInfo& cci = spc->getConstructionInfo();
+       CcdConstructionInfo& cci = spc->GetConstructionInfo();
        btCollisionShape* bm= shapeInfo->CreateBulletShape(cci.m_margin, cci.m_bGimpact, !cci.m_bSoft);
 
        spc->ReplaceControllerShape(bm);
index e06f7ab66335f08a29bebe3d6fa038a001384edd..96f76ff21b1a0e736df48a467f7a13ceb310f872 100644 (file)
@@ -55,7 +55,6 @@ typedef unsigned long uint_ptr;
 #include "KX_PolyProxy.h"
 #include <stdio.h> // printf
 #include "SG_Controller.h"
-#include "KX_IPhysicsController.h"
 #include "PHY_IGraphicController.h"
 #include "SG_Node.h"
 #include "SG_Controller.h"
@@ -105,7 +104,7 @@ KX_GameObject::KX_GameObject(
       m_bVisible(true),
       m_bCulled(true),
       m_bOccluder(false),
-      m_pPhysicsController1(NULL),
+      m_pPhysicsController(NULL),
       m_pGraphicController(NULL),
       m_xray(false),
       m_pHitObject(NULL),
@@ -177,6 +176,11 @@ KX_GameObject::~KX_GameObject()
                delete m_pGraphicController;
        }
 
+       if (m_pPhysicsController)
+       {
+               delete m_pPhysicsController;
+       }
+
        if (m_pObstacleSimulation)
        {
                m_pObstacleSimulation->DestroyObstacleForObj(this);
@@ -245,9 +249,9 @@ void KX_GameObject::SetName(const char *name)
        m_name = name;
 }
 
-KX_IPhysicsController* KX_GameObject::GetPhysicsController()
+PHY_IPhysicsController* KX_GameObject::GetPhysicsController()
 {
-       return m_pPhysicsController1;
+       return m_pPhysicsController;
 }
 
 KX_GameObject* KX_GameObject::GetDupliGroupObject()
@@ -333,9 +337,9 @@ void KX_GameObject::SetParent(KX_Scene *scene, KX_GameObject* obj, bool addToCom
                RemoveParent(scene);
                obj->GetSGNode()->AddChild(GetSGNode());
 
-               if (m_pPhysicsController1) 
+               if (m_pPhysicsController)
                {
-                       m_pPhysicsController1->SuspendDynamics(ghost);
+                       m_pPhysicsController->SuspendDynamics(ghost);
                }
                // Set us to our new scale, position, and orientation
                scale2[0] = 1.0/scale2[0];
@@ -356,16 +360,16 @@ void KX_GameObject::SetParent(KX_Scene *scene, KX_GameObject* obj, bool addToCom
                        Release();
                // if the new parent is a compound object, add this object shape to the compound shape.
                // step 0: verify this object has physical controller
-               if (m_pPhysicsController1 && addToCompound)
+               if (m_pPhysicsController && addToCompound)
                {
                        // step 1: find the top parent (not necessarily obj)
                        KX_GameObject* rootobj = (KX_GameObject*)obj->GetSGNode()->GetRootSGParent()->GetSGClientObject();
                        // step 2: verify it has a physical controller and compound shape
                        if (rootobj != NULL && 
-                               rootobj->m_pPhysicsController1 != NULL &&
-                               rootobj->m_pPhysicsController1->IsCompound())
+                               rootobj->m_pPhysicsController != NULL &&
+                               rootobj->m_pPhysicsController->IsCompound())
                        {
-                               rootobj->m_pPhysicsController1->AddCompoundChild(m_pPhysicsController1);
+                               rootobj->m_pPhysicsController->AddCompoundChild(m_pPhysicsController);
                        }
                }
                // graphically, the object hasn't change place, no need to update m_pGraphicController
@@ -392,27 +396,27 @@ void KX_GameObject::RemoveParent(KX_Scene *scene)
                if (!rootlist->SearchValue(this))
                        // object was not in root list, add it now and increment ref count
                        rootlist->Add(AddRef());
-               if (m_pPhysicsController1) 
+               if (m_pPhysicsController)
                {
                        // in case this controller was added as a child shape to the parent
                        if (rootobj != NULL && 
-                               rootobj->m_pPhysicsController1 != NULL &&
-                               rootobj->m_pPhysicsController1->IsCompound())
+                               rootobj->m_pPhysicsController != NULL &&
+                               rootobj->m_pPhysicsController->IsCompound())
                        {
-                               rootobj->m_pPhysicsController1->RemoveCompoundChild(m_pPhysicsController1);
+                               rootobj->m_pPhysicsController->RemoveCompoundChild(m_pPhysicsController);
                        }
-                       m_pPhysicsController1->RestoreDynamics();
-                       if (m_pPhysicsController1->IsDyna() && (rootobj != NULL && rootobj->m_pPhysicsController1))
+                       m_pPhysicsController->RestoreDynamics();
+                       if (m_pPhysicsController->IsDynamic() && (rootobj != NULL && rootobj->m_pPhysicsController))
                        {
                                // dynamic object should remember the velocity they had while being parented
                                MT_Point3 childPoint = GetSGNode()->GetWorldPosition();
                                MT_Point3 rootPoint = rootobj->GetSGNode()->GetWorldPosition();
                                MT_Point3 relPoint;
                                relPoint = (childPoint-rootPoint);
-                               MT_Vector3 linVel = rootobj->m_pPhysicsController1->GetVelocity(relPoint);
-                               MT_Vector3 angVel = rootobj->m_pPhysicsController1->GetAngularVelocity();
-                               m_pPhysicsController1->SetLinearVelocity(linVel, false);
-                               m_pPhysicsController1->SetAngularVelocity(angVel, false);
+                               MT_Vector3 linVel = rootobj->m_pPhysicsController->GetVelocity(relPoint);
+                               MT_Vector3 angVel = rootobj->m_pPhysicsController->GetAngularVelocity();
+                               m_pPhysicsController->SetLinearVelocity(linVel, false);
+                               m_pPhysicsController->SetAngularVelocity(angVel, false);
                        }
                }
                // graphically, the object hasn't change place, no need to update m_pGraphicController
@@ -488,9 +492,9 @@ void KX_GameObject::SetTimes(short layer, float start, float end)
 void KX_GameObject::ProcessReplica()
 {
        SCA_IObject::ProcessReplica();
-       
-       m_pPhysicsController1 = NULL;
+
        m_pGraphicController = NULL;
+       m_pPhysicsController = NULL;
        m_pSGNode = NULL;
        m_pClient_info = new KX_ClientObjectInfo(*m_pClient_info);
        m_pClient_info->m_gameobject = this;
@@ -570,16 +574,16 @@ CValue* KX_GameObject::GetReplica()
 
 void KX_GameObject::ApplyForce(const MT_Vector3& force,bool local)
 {
-       if (m_pPhysicsController1)
-               m_pPhysicsController1->ApplyForce(force,local);
+       if (m_pPhysicsController)
+               m_pPhysicsController->ApplyForce(force,local);
 }
 
 
 
 void KX_GameObject::ApplyTorque(const MT_Vector3& torque,bool local)
 {
-       if (m_pPhysicsController1)
-               m_pPhysicsController1->ApplyTorque(torque,local);
+       if (m_pPhysicsController)
+               m_pPhysicsController->ApplyTorque(torque,local);
 }
 
 
@@ -588,9 +592,9 @@ void KX_GameObject::ApplyMovement(const MT_Vector3& dloc,bool local)
 {
        if (GetSGNode()) 
        {
-               if (m_pPhysicsController1) // (IsDynamic())
+               if (m_pPhysicsController) // (IsDynamic())
                {
-                       m_pPhysicsController1->RelativeTranslate(dloc,local);
+                       m_pPhysicsController->RelativeTranslate(dloc,local);
                }
                GetSGNode()->RelativeTranslate(dloc,GetSGNode()->GetSGParent(),local);
        }
@@ -605,8 +609,8 @@ void KX_GameObject::ApplyRotation(const MT_Vector3& drot,bool local)
        if (GetSGNode()) {
                GetSGNode()->RelativeRotate(rotmat,local);
 
-               if (m_pPhysicsController1) { // (IsDynamic())
-                       m_pPhysicsController1->RelativeRotate(rotmat,local); 
+               if (m_pPhysicsController) { // (IsDynamic())
+                       m_pPhysicsController->RelativeRotate(rotmat,local);
                }
        }
 }
@@ -730,11 +734,8 @@ void KX_GameObject::RemoveMeshes()
 void KX_GameObject::UpdateTransform()
 {
        // HACK: saves function call for dynamic object, they are handled differently
-       if (m_pPhysicsController1 && !m_pPhysicsController1->IsDyna())
-               // Note that for Bullet, this does not even update the transform of static object
-               // but merely sets there collision flag to "kinematic" because the synchronization is 
-               // done during physics simulation
-               m_pPhysicsController1->SetSumoTransform(true);
+       if (m_pPhysicsController && !m_pPhysicsController->IsDynamic())
+               m_pPhysicsController->SetTransform();
        if (m_pGraphicController)
                // update the culling tree
                m_pGraphicController->SetGraphicTransform();
@@ -749,8 +750,8 @@ void KX_GameObject::UpdateTransformFunc(SG_IObject* node, void* gameobj, void* s
 void KX_GameObject::SynchronizeTransform()
 {
        // only used for sensor object, do full synchronization as bullet doesn't do it
-       if (m_pPhysicsController1)
-               m_pPhysicsController1->SetTransform();
+       if (m_pPhysicsController)
+               m_pPhysicsController->SetTransform();
        if (m_pGraphicController)
                m_pGraphicController->SetGraphicTransform();
 }
@@ -935,10 +936,10 @@ KX_GameObject::GetLayer(
 
 void KX_GameObject::addLinearVelocity(const MT_Vector3& lin_vel,bool local)
 {
-       if (m_pPhysicsController1) 
+       if (m_pPhysicsController)
        {
                MT_Vector3 lv = local ? NodeGetWorldOrientation() * lin_vel : lin_vel;
-               m_pPhysicsController1->SetLinearVelocity(lv + m_pPhysicsController1->GetLinearVelocity(), 0);
+               m_pPhysicsController->SetLinearVelocity(lv + m_pPhysicsController->GetLinearVelocity(), 0);
        }
 }
 
@@ -946,16 +947,16 @@ void KX_GameObject::addLinearVelocity(const MT_Vector3& lin_vel,bool local)
 
 void KX_GameObject::setLinearVelocity(const MT_Vector3& lin_vel,bool local)
 {
-       if (m_pPhysicsController1)
-               m_pPhysicsController1->SetLinearVelocity(lin_vel,local);
+       if (m_pPhysicsController)
+               m_pPhysicsController->SetLinearVelocity(lin_vel,local);
 }
 
 
 
 void KX_GameObject::setAngularVelocity(const MT_Vector3& ang_vel,bool local)
 {
-       if (m_pPhysicsController1)
-               m_pPhysicsController1->SetAngularVelocity(ang_vel,local);
+       if (m_pPhysicsController)
+               m_pPhysicsController->SetAngularVelocity(ang_vel,local);
 }
 
 
@@ -965,12 +966,12 @@ void KX_GameObject::ResolveCombinedVelocities(
        bool lin_vel_local,
        bool ang_vel_local
 ) {
-       if (m_pPhysicsController1)
+       if (m_pPhysicsController)
        {
 
                MT_Vector3 lv = lin_vel_local ? NodeGetWorldOrientation() * lin_vel : lin_vel;
                MT_Vector3 av = ang_vel_local ? NodeGetWorldOrientation() * ang_vel : ang_vel;
-               m_pPhysicsController1->resolveCombinedVelocities(
+               m_pPhysicsController->ResolveCombinedVelocities(
                        lv.x(),lv.y(),lv.z(),av.x(),av.y(),av.z());
        }
 }
@@ -1082,9 +1083,9 @@ void KX_GameObject::AlignAxisToVect(const MT_Vector3& dir, int axis, float fac)
 
 MT_Scalar KX_GameObject::GetMass()
 {
-       if (m_pPhysicsController1)
+       if (m_pPhysicsController)
        {
-               return m_pPhysicsController1->GetMass();
+               return m_pPhysicsController->GetMass();
        }
        return 0.0;
 }
@@ -1092,9 +1093,9 @@ MT_Scalar KX_GameObject::GetMass()
 MT_Vector3 KX_GameObject::GetLocalInertia()
 {
        MT_Vector3 local_inertia(0.0,0.0,0.0);
-       if (m_pPhysicsController1)
+       if (m_pPhysicsController)
        {
-               local_inertia = m_pPhysicsController1->GetLocalInertia();
+               local_inertia = m_pPhysicsController->GetLocalInertia();
        }
        return local_inertia;
 }
@@ -1103,9 +1104,9 @@ MT_Vector3 KX_GameObject::GetLinearVelocity(bool local)
 {
        MT_Vector3 velocity(0.0,0.0,0.0), locvel;
        MT_Matrix3x3 ori;
-       if (m_pPhysicsController1)
+       if (m_pPhysicsController)
        {
-               velocity = m_pPhysicsController1->GetLinearVelocity();
+               velocity = m_pPhysicsController->GetLinearVelocity();
                
                if (local)
                {
@@ -1122,9 +1123,9 @@ MT_Vector3 KX_GameObject::GetAngularVelocity(bool local)
 {
        MT_Vector3 velocity(0.0,0.0,0.0), locvel;
        MT_Matrix3x3 ori;
-       if (m_pPhysicsController1)
+       if (m_pPhysicsController)
        {
-               velocity = m_pPhysicsController1->GetAngularVelocity();
+               velocity = m_pPhysicsController->GetAngularVelocity();
                
                if (local)
                {
@@ -1139,9 +1140,9 @@ MT_Vector3 KX_GameObject::GetAngularVelocity(bool local)
 
 MT_Vector3 KX_GameObject::GetVelocity(const MT_Point3& point)
 {
-       if (m_pPhysicsController1)
+       if (m_pPhysicsController)
        {
-               return m_pPhysicsController1->GetVelocity(point);
+               return m_pPhysicsController->GetVelocity(point);
        }
        return MT_Vector3(0.0,0.0,0.0);
 }
@@ -1154,13 +1155,13 @@ void KX_GameObject::NodeSetLocalPosition(const MT_Point3& trans)
        if (!GetSGNode())
                return;
 
-       if (m_pPhysicsController1 && !GetSGNode()->GetSGParent())
+       if (m_pPhysicsController && !GetSGNode()->GetSGParent())
        {
                // don't update physic controller if the object is a child:
                // 1) the transformation will not be right
                // 2) in this case, the physic controller is necessarily a static object
                //    that is updated from the normal kinematic synchronization
-               m_pPhysicsController1->setPosition(trans);
+               m_pPhysicsController->SetPosition(trans);
        }
 
        GetSGNode()->SetLocalPosition(trans);
@@ -1175,10 +1176,10 @@ void KX_GameObject::NodeSetLocalOrientation(const MT_Matrix3x3& rot)
        if (!GetSGNode())
                return;
 
-       if (m_pPhysicsController1 && !GetSGNode()->GetSGParent())
+       if (m_pPhysicsController && !GetSGNode()->GetSGParent())
        {
                // see note above
-               m_pPhysicsController1->setOrientation(rot);
+               m_pPhysicsController->SetOrientation(rot);
        }
        GetSGNode()->SetLocalOrientation(rot);
 }
@@ -1201,10 +1202,10 @@ void KX_GameObject::NodeSetLocalScale(const MT_Vector3& scale)
        if (!GetSGNode())
                return;
 
-       if (m_pPhysicsController1 && !GetSGNode()->GetSGParent())
+       if (m_pPhysicsController && !GetSGNode()->GetSGParent())
        {
                // see note above
-               m_pPhysicsController1->setScaling(scale);
+               m_pPhysicsController->SetScaling(scale);
        }
        GetSGNode()->SetLocalScale(scale);
 }
@@ -1216,13 +1217,13 @@ void KX_GameObject::NodeSetRelativeScale(const MT_Vector3& scale)
        if (GetSGNode())
        {
                GetSGNode()->RelativeScale(scale);
-               if (m_pPhysicsController1 && (!GetSGNode()->GetSGParent()))
+               if (m_pPhysicsController && (!GetSGNode()->GetSGParent()))
                {
                        // see note above
                        // we can use the local scale: it's the same thing for a root object 
                        // and the world scale is not yet updated
                        MT_Vector3 newscale = GetSGNode()->GetLocalScale();
-                       m_pPhysicsController1->setScaling(newscale);
+                       m_pPhysicsController->SetScaling(newscale);
                }
        }
 }
@@ -1355,13 +1356,13 @@ void KX_GameObject::UnregisterCollisionCallbacks()
        // Unregister from callbacks
        KX_Scene* scene = GetScene();
        PHY_IPhysicsEnvironment* pe = scene->GetPhysicsEnvironment();
-       PHY_IPhysicsController* spc = static_cast<PHY_IPhysicsController*> (GetPhysicsController()->GetUserData());
+       PHY_IPhysicsController* spc = GetPhysicsController();
        // If we are the last to unregister on this physics controller
-       if (pe->removeCollisionCallback(spc)){
+       if (pe->RemoveCollisionCallback(spc)){
                // If we are a sensor object
                if (m_pClient_info->isSensor())
                        // Remove sensor body from physics world
-                       pe->removeSensor(spc);
+                       pe->RemoveSensor(spc);
        }
 }
 
@@ -1375,13 +1376,13 @@ void KX_GameObject::RegisterCollisionCallbacks()
        // Register from callbacks
        KX_Scene* scene = GetScene();
        PHY_IPhysicsEnvironment* pe = scene->GetPhysicsEnvironment();
-       PHY_IPhysicsController* spc = static_cast<PHY_IPhysicsController*> (GetPhysicsController()->GetUserData());
+       PHY_IPhysicsController* spc = GetPhysicsController();
        // If we are the first to register on this physics controller
-       if (pe->requestCollisionCallback(spc)){
+       if (pe->RequestCollisionCallback(spc)){
                // If we are a sensor object
                if (m_pClient_info->isSensor())
                        // Add sensor body to physics world
-                       pe->addSensor(spc);
+                       pe->AddSensor(spc);
        }
 }
 void KX_GameObject::RunCollisionCallbacks(KX_GameObject *collider)
@@ -2170,14 +2171,14 @@ PyObject *KX_GameObject::pyattr_get_life(void *self_v, const KX_PYATTRIBUTE_DEF
 PyObject *KX_GameObject::pyattr_get_mass(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
 {
        KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
-       KX_IPhysicsController *spc = self->GetPhysicsController();
+       PHY_IPhysicsController *spc = self->GetPhysicsController();
        return PyFloat_FromDouble(spc ? spc->GetMass() : 0.0);
 }
 
 int KX_GameObject::pyattr_set_mass(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
 {
        KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
-       KX_IPhysicsController *spc = self->GetPhysicsController();
+       PHY_IPhysicsController *spc = self->GetPhysicsController();
        MT_Scalar val = PyFloat_AsDouble(value);
        if (val < 0.0) { /* also accounts for non float */
                PyErr_SetString(PyExc_AttributeError, "gameOb.mass = float: KX_GameObject, expected a float zero or above");
@@ -2193,14 +2194,14 @@ int KX_GameObject::pyattr_set_mass(void *self_v, const KX_PYATTRIBUTE_DEF *attrd
 PyObject *KX_GameObject::pyattr_get_lin_vel_min(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
 {
        KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
-       KX_IPhysicsController *spc = self->GetPhysicsController();
+       PHY_IPhysicsController *spc = self->GetPhysicsController();
        return PyFloat_FromDouble(spc ? spc->GetLinVelocityMin() : 0.0f);
 }
 
 int KX_GameObject::pyattr_set_lin_vel_min(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
 {
        KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
-       KX_IPhysicsController *spc = self->GetPhysicsController();
+       PHY_IPhysicsController *spc = self->GetPhysicsController();
        MT_Scalar val = PyFloat_AsDouble(value);
        if (val < 0.0) { /* also accounts for non float */
                PyErr_SetString(PyExc_AttributeError, "gameOb.linVelocityMin = float: KX_GameObject, expected a float zero or above");
@@ -2216,14 +2217,14 @@ int KX_GameObject::pyattr_set_lin_vel_min(void *self_v, const KX_PYATTRIBUTE_DEF
 PyObject *KX_GameObject::pyattr_get_lin_vel_max(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
 {
        KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
-       KX_IPhysicsController *spc = self->GetPhysicsController();
+       PHY_IPhysicsController *spc = self->GetPhysicsController();
        return PyFloat_FromDouble(spc ? spc->GetLinVelocityMax() : 0.0f);
 }
 
 int KX_GameObject::pyattr_set_lin_vel_max(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
 {
        KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
-       KX_IPhysicsController *spc = self->GetPhysicsController();
+       PHY_IPhysicsController *spc = self->GetPhysicsController();
        MT_Scalar val = PyFloat_AsDouble(value);
        if (val < 0.0) { /* also accounts for non float */
                PyErr_SetString(PyExc_AttributeError, "gameOb.linVelocityMax = float: KX_GameObject, expected a float zero or above");
@@ -2307,8 +2308,8 @@ PyObject *KX_GameObject::pyattr_get_localInertia(void *self_v, const KX_PYATTRIB
        return Vector_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_INERTIA_LOCAL);
 #else
        KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
-       if (self->GetPhysicsController())
-               return PyObjectFrom(self->GetPhysicsController()->GetLocalInertia());
+       if (self->GetPhysicsController1())
+               return PyObjectFrom(self->GetPhysicsController1()->GetLocalInertia());
        return Py_BuildValue("fff", 0.0f, 0.0f, 0.0f);
 #endif
 }
@@ -2854,14 +2855,8 @@ PyObject *KX_GameObject::PyGetVelocity(PyObject *args)
        
        if (!PyArg_ParseTuple(args, "|O:getVelocity", &pypos) || (pypos && !PyVecTo(pypos, point)))
                return NULL;
-       
-       if (m_pPhysicsController1)
-       {
-               return PyObjectFrom(m_pPhysicsController1->GetVelocity(point));
-       }
-       else {
-               return PyObjectFrom(MT_Vector3(0.0,0.0,0.0));
-       }
+
+       return PyObjectFrom(GetVelocity(point));
 }
 
 PyObject *KX_GameObject::PyGetReactionForce()
@@ -2870,8 +2865,8 @@ PyObject *KX_GameObject::PyGetReactionForce()
        
        // XXX - Currently not working with bullet intergration, see KX_BulletPhysicsController.cpp's getReactionForce
 #if 0
-       if (GetPhysicsController())
-               return PyObjectFrom(GetPhysicsController()->getReactionForce());
+       if (GetPhysicsController1())
+               return PyObjectFrom(GetPhysicsController1()->getReactionForce());
        return PyObjectFrom(dummy_point);
 #endif
        
@@ -2884,7 +2879,7 @@ PyObject *KX_GameObject::PyGetReactionForce()
 PyObject *KX_GameObject::PyEnableRigidBody()
 {
        if (GetPhysicsController())
-               GetPhysicsController()->setRigidBody(true);
+               GetPhysicsController()->SetRigidBody(true);
 
        Py_RETURN_NONE;
 }
@@ -2894,7 +2889,7 @@ PyObject *KX_GameObject::PyEnableRigidBody()
 PyObject *KX_GameObject::PyDisableRigidBody()
 {
        if (GetPhysicsController())
-               GetPhysicsController()->setRigidBody(false);
+               GetPhysicsController()->SetRigidBody(false);
 
        Py_RETURN_NONE;
 }
@@ -2935,9 +2930,9 @@ PyObject *KX_GameObject::PySetCollisionMargin(PyObject *value)
                return NULL;
        }
        
-       if (m_pPhysicsController1)
+       if (m_pPhysicsController)
        {
-               m_pPhysicsController1->setMargin(collisionMargin);
+               m_pPhysicsController->SetMargin(collisionMargin);
                Py_RETURN_NONE;
        }
        PyErr_SetString(PyExc_RuntimeError, "This object has no physics controller");
@@ -2951,7 +2946,7 @@ PyObject *KX_GameObject::PyApplyImpulse(PyObject *args)
        PyObject *pyattach;
        PyObject *pyimpulse;
        
-       if (!m_pPhysicsController1)     {
+       if (!m_pPhysicsController     {
                PyErr_SetString(PyExc_RuntimeError, "This object has no physics controller");
                return NULL;
        }
@@ -2962,7 +2957,7 @@ PyObject *KX_GameObject::PyApplyImpulse(PyObject *args)
                MT_Vector3 impulse;
                if (PyVecTo(pyattach, attach) && PyVecTo(pyimpulse, impulse))
                {
-                       m_pPhysicsController1->applyImpulse(attach, impulse);
+                       m_pPhysicsController->ApplyImpulse(attach, impulse);
                        Py_RETURN_NONE;
                }
 
@@ -2975,7 +2970,7 @@ PyObject *KX_GameObject::PyApplyImpulse(PyObject *args)
 
 PyObject *KX_GameObject::PySuspendDynamics()
 {
-       SuspendDynamics();
+       GetPhysicsController()->SuspendDynamics();
        Py_RETURN_NONE;
 }
 
@@ -2983,7 +2978,7 @@ PyObject *KX_GameObject::PySuspendDynamics()
 
 PyObject *KX_GameObject::PyRestoreDynamics()
 {
-       RestoreDynamics();
+       GetPhysicsController()->RestoreDynamics();
        Py_RETURN_NONE;
 }
 
@@ -3023,11 +3018,11 @@ PyObject *KX_GameObject::PyGetAxisVect(PyObject *value)
 
 PyObject *KX_GameObject::PyGetPhysicsId()
 {
-       KX_IPhysicsController* ctrl = GetPhysicsController();
+       PHY_IPhysicsController* ctrl = GetPhysicsController();
        uint_ptr physid=0;
        if (ctrl)
        {
-               physid= (uint_ptr)ctrl->GetUserData();
+               physid= (uint_ptr)ctrl;
        }
        return PyLong_FromLong((long)physid);
 }
@@ -3190,7 +3185,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCastTo,
                toPoint = fromPoint + dist * (toPoint-fromPoint).safe_normalized();
        
        PHY_IPhysicsEnvironment* pe = GetScene()->GetPhysicsEnvironment();
-       KX_IPhysicsController *spc = GetPhysicsController();
+       PHY_IPhysicsController *spc = GetPhysicsController();
        KX_GameObject *parent = GetParent();
        if (!spc && parent)
                spc = parent->GetPhysicsController();
@@ -3336,7 +3331,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCast,
        }
        
        PHY_IPhysicsEnvironment* pe = GetScene()->GetPhysicsEnvironment();
-       KX_IPhysicsController *spc = GetPhysicsController();
+       PHY_IPhysicsController *spc = GetPhysicsController();
        KX_GameObject *parent = GetParent();
        if (!spc && parent)
                spc = parent->GetPhysicsController();
index dde3ff532990678fcf593898e6afaac245b2ce30..55e2b31c5bfaec90a97e3ce20c7b87660349a340 100644 (file)
@@ -49,7 +49,6 @@
 #include "CTR_HashedPtr.h"
 #include "KX_Scene.h"
 #include "KX_KetsjiEngine.h" /* for m_anim_framerate */
-#include "KX_IPhysicsController.h" /* for suspend/resume */
 #include "DNA_object_types.h"
 #include "SCA_LogicManager.h" /* for ConvertPythonToGameObject to search object names */
 
@@ -57,9 +56,9 @@
 struct KX_ClientObjectInfo;
 class KX_RayCast;
 class RAS_MeshObject;
-class KX_IPhysicsController;
 class PHY_IGraphicController;
 class PHY_IPhysicsEnvironment;
+class PHY_IPhysicsController;
 class BL_ActionManager;
 struct Object;
 class KX_ObstacleSimulation;
@@ -107,7 +106,7 @@ protected:
        bool                                                            m_bCulled; 
        bool                                                            m_bOccluder;
 
-       KX_IPhysicsController*                          m_pPhysicsController1;
+       PHY_IPhysicsController*                         m_pPhysicsController;
        PHY_IGraphicController*                         m_pGraphicController;
        STR_String                                                      m_testPropName;
        bool                                                            m_xray;
@@ -465,12 +464,12 @@ public:
         * \return a pointer to the physics controller owned by this class.
         */
 
-       KX_IPhysicsController* GetPhysicsController();
+       PHY_IPhysicsController* GetPhysicsController();
 
-       void    SetPhysicsController(KX_IPhysicsController*     physicscontroller,bool isDynamic) 
+       void    SetPhysicsController(PHY_IPhysicsController*    physicscontroller,bool isDynamic)
        { 
                m_bDyna = isDynamic;
-               m_pPhysicsController1 = physicscontroller;
+               m_pPhysicsController = physicscontroller;
        }
 
        virtual class RAS_Deformer* GetDeformer()
@@ -885,32 +884,6 @@ public:
         * Resume making progress
         */
        void Resume(void);
-       
-       void SuspendDynamics(void) {
-               if (m_bSuspendDynamics)
-               {
-                       return;
-               }
-       
-               if (m_pPhysicsController1)
-               {
-                       m_pPhysicsController1->SuspendDynamics();
-               }
-               m_bSuspendDynamics = true;
-       }
-       
-       void RestoreDynamics(void) {
-               if (!m_bSuspendDynamics)
-               {
-                       return;
-               }
-       
-               if (m_pPhysicsController1)
-               {
-                       m_pPhysicsController1->RestoreDynamics();
-               }
-               m_bSuspendDynamics = false;
-       }
 
        void RegisterObstacle(KX_ObstacleSimulation* obstacleSimulation)
        {
index f221b7c6cd48f498d11b7ffcfbe63343116fdb37..f75633659ffb2fd5a31472648704365900471e5a 100644 (file)
@@ -48,7 +48,7 @@ typedef unsigned long uint_ptr;
 #include "KX_IPO_SGController.h"
 #include "KX_ScalarInterpolator.h"
 #include "KX_GameObject.h"
-#include "KX_IPhysicsController.h"
+#include "PHY_IPhysicsController.h"
 #include "DNA_ipo_types.h"
 #include "BLI_math.h"
 
@@ -154,9 +154,10 @@ bool KX_IpoSGController::Update(double currentTime)
                        {
                                if (m_game_object && ob && m_game_object->GetPhysicsController()) 
                                {
-                                       m_game_object->GetPhysicsController()->ApplyForce(m_ipo_local ?
-                                               ob->GetWorldOrientation() * m_ipo_xform.GetPosition() :
-                                               m_ipo_xform.GetPosition(), false);
+                                       MT_Vector3 vec = m_ipo_local ?
+                                                            ob->GetWorldOrientation() * m_ipo_xform.GetPosition() :
+                                                                                m_ipo_xform.GetPosition();
+                                       m_game_object->GetPhysicsController()->ApplyForce(vec, false);
                                }
                        } 
                        else
diff --git a/source/gameengine/Ketsji/KX_IPhysicsController.cpp b/source/gameengine/Ketsji/KX_IPhysicsController.cpp
deleted file mode 100644 (file)
index f0e57ce..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/Ketsji/KX_IPhysicsController.cpp
- *  \ingroup ketsji
- */
-
-#include "KX_IPhysicsController.h"
-
-#include "PHY_DynamicTypes.h"
-
-KX_IPhysicsController::KX_IPhysicsController(bool dyna, bool sensor, bool character, bool compound, void* userdata)
-
-:      m_bDyna(dyna),
-       m_bSensor(sensor),
-       m_bCharacter(character),
-       m_bCompound(compound),
-       m_suspendDynamics(false),
-       m_userdata(userdata)
-{
-}
-
-KX_IPhysicsController::~KX_IPhysicsController()
-{
-}
diff --git a/source/gameengine/Ketsji/KX_IPhysicsController.h b/source/gameengine/Ketsji/KX_IPhysicsController.h
deleted file mode 100644 (file)
index 2019be5..0000000
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file KX_IPhysicsController.h
- *  \ingroup ketsji
- */
-
-#ifndef __KX_IPHYSICSCONTROLLER_H__
-#define __KX_IPHYSICSCONTROLLER_H__
-
-#include "SG_Controller.h"
-#include "MT_Vector3.h"
-#include "MT_Point3.h"
-#include "MT_Transform.h"
-#include "MT_Matrix3x3.h"
-
-struct KX_ClientObjectInfo;
-
-/**
- * Physics Controller, a special kind of Scene Graph Transformation Controller.
- * It get's callbacks from Physics in case a transformation change took place.
- * Each time the scene graph get's updated, the controller get's a chance
- * in the 'Update' method to reflect changed.
- */
-
-class KX_IPhysicsController : public SG_Controller
-                                                        
-{
-protected:
-       bool            m_bDyna;
-       bool            m_bSensor;
-       bool            m_bCharacter;
-       bool            m_bCompound;
-       bool            m_suspendDynamics;
-       void*           m_userdata;
-public:
-       KX_IPhysicsController(bool dyna,bool sensor,bool character,bool compound, void* userdata);
-       virtual ~KX_IPhysicsController();
-
-
-       virtual void    applyImpulse(const MT_Point3& attach, const MT_Vector3& impulse)=0;
-       virtual void    SetObject (SG_IObject* object)=0;
-       virtual void    setMargin (float collisionMargin)=0;
-
-       virtual void    RelativeTranslate(const MT_Vector3& dloc,bool local)=0;
-       virtual void    RelativeRotate(const MT_Matrix3x3& drot,bool local)=0;
-       virtual void    ApplyTorque(const MT_Vector3& torque,bool local)=0;
-       virtual void    ApplyForce(const MT_Vector3& force,bool local)=0;
-       virtual void    SetWalkDirection(const MT_Vector3& dir,bool local)=0;
-       virtual MT_Vector3 GetLinearVelocity()=0;
-       virtual MT_Vector3 GetAngularVelocity()=0;
-       virtual MT_Vector3 GetVelocity(const MT_Point3& pos)=0;
-       virtual MT_Vector3 GetWalkDirection()=0;
-       virtual void    SetAngularVelocity(const MT_Vector3& ang_vel,bool local)=0;
-       virtual void    SetLinearVelocity(const MT_Vector3& lin_vel,bool local)=0;
-       virtual void    Jump()=0;
-       virtual void    resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ) = 0;
-
-       virtual void    getOrientation(MT_Quaternion& orn)=0;
-       virtual void setOrientation(const MT_Matrix3x3& orn)=0;
-       virtual void SetTransform()=0;
-       //virtual       void setOrientation(const MT_Quaternion& orn)=0;
-       virtual void setPosition(const MT_Point3& pos)=0;
-       virtual void setScaling(const MT_Vector3& scaling)=0;
-       virtual MT_Scalar       GetMass()=0;
-       virtual void    SetMass(MT_Scalar newmass)=0;
-       
-       virtual float GetLinVelocityMin()=0;
-       virtual void    SetLinVelocityMin(float newmass)=0;
-       virtual float GetLinVelocityMax()=0;
-       virtual void    SetLinVelocityMax(float newmass)=0;
-       
-       virtual MT_Vector3      GetLocalInertia()=0;
-       virtual MT_Vector3      getReactionForce()=0;
-       virtual void    setRigidBody(bool rigid)=0;
-       virtual void    AddCompoundChild(KX_IPhysicsController* child) = 0;
-       virtual void    RemoveCompoundChild(KX_IPhysicsController* child) = 0;
-
-       virtual void    SuspendDynamics(bool ghost=false)=0;
-       virtual void    RestoreDynamics()=0;
-
-       virtual SG_Controller*  GetReplica(class SG_Node* destnode)=0;
-
-       void    SetDyna(bool isDynamic) {
-               m_bDyna = isDynamic;
-       }
-
-       void    SetSensor(bool isSensor) {
-               m_bSensor = isSensor;
-       }
-
-       void    SetCharacter(bool isCharacter) {
-               m_bCharacter = isCharacter;
-       }
-
-       bool    IsDyna(void) {
-               return m_bDyna;
-       }
-
-       bool    IsSensor(void) {
-               return m_bSensor;
-       }
-
-       bool    IsCharacter(void) {
-               return m_bCharacter;
-       }
-
-       bool    IsCompound(void) {
-               return m_bCompound;
-       }
-
-       virtual MT_Scalar GetRadius()=0;
-       virtual void    SetSumoTransform(bool nondynaonly)=0;
-       // todo: remove next line !
-       virtual void    SetSimulatedTime(double time)=0;
-       
-       // call from scene graph to update
-       virtual bool Update(double time)=0;
-       void*   GetUserData() { return m_userdata;}
-       
-       
-#ifdef WITH_CXX_GUARDEDALLOC
-       MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_IPhysicsController")
-#endif
-};
-
-#endif  /* __KX_IPHYSICSCONTROLLER_H__ */
index 48ef8cdd50d4b5e7ff2d801ee85f82e6bd176ef9..0e9e2cd832871e7f44b003ee92534529042ae277 100644 (file)
@@ -646,7 +646,7 @@ bool KX_KetsjiEngine::NextFrame()
 #endif
                                KX_SetActiveScene(scene);
        
-                               scene->GetPhysicsEnvironment()->endFrame();
+                               scene->GetPhysicsEnvironment()->EndFrame();
                                
                                // Update scenegraph after physics step. This maps physics calculations
                                // into node positions.
@@ -688,11 +688,11 @@ bool KX_KetsjiEngine::NextFrame()
 
                                m_logger->StartLog(tc_physics, m_kxsystem->GetTimeInSeconds(), true);
                                SG_SetActiveStage(SG_STAGE_PHYSICS2);
-                               scene->GetPhysicsEnvironment()->beginFrame();
+                               scene->GetPhysicsEnvironment()->BeginFrame();
                
                                // Perform physics calculations on the scene. This can involve 
                                // many iterations of the physics solver.
-                               scene->GetPhysicsEnvironment()->proceedDeltaTime(m_frameTime,timestep,framestep);//m_deltatimerealDeltaTime);
+                               scene->GetPhysicsEnvironment()->ProceedDeltaTime(m_frameTime,timestep,framestep);//m_deltatimerealDeltaTime);
 
                                m_logger->StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds(), true);
                                SG_SetActiveStage(SG_STAGE_PHYSICS2_UPDATE);
@@ -762,7 +762,7 @@ bool KX_KetsjiEngine::NextFrame()
                                // Perform physics calculations on the scene. This can involve 
                                // many iterations of the physics solver.
                                m_logger->StartLog(tc_physics, m_kxsystem->GetTimeInSeconds(), true);
-                               scene->GetPhysicsEnvironment()->proceedDeltaTime(m_clockTime,timestep,timestep);
+                               scene->GetPhysicsEnvironment()->ProceedDeltaTime(m_clockTime,timestep,timestep);
                                // Update scenegraph after physics step. This maps physics calculations
                                // into node positions.
                                m_logger->StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds(), true);
@@ -1329,7 +1329,7 @@ void KX_KetsjiEngine::RenderFrame(KX_Scene* scene, KX_Camera* cam)
        scene->RenderFonts();
        
        if (scene->GetPhysicsEnvironment())
-               scene->GetPhysicsEnvironment()->debugDrawWorld();
+               scene->GetPhysicsEnvironment()->DebugDrawWorld();
 }
 
 /*
index 3ca01e7af74d051abb92d032a27a8eecb5a8b125..4728f71a6eafa51a6b27f2f816bd25b1031b0928 100644 (file)
@@ -41,7 +41,7 @@ KX_MotionState::~KX_MotionState()
 {
 }
 
-void   KX_MotionState::getWorldPosition(float& posX,float& posY,float& posZ)
+void   KX_MotionState::GetWorldPosition(float& posX,float& posY,float& posZ)
 {
        const MT_Point3& pos = m_node->GetWorldPosition();
        posX = pos[0];
@@ -49,7 +49,7 @@ void  KX_MotionState::getWorldPosition(float& posX,float& posY,float& posZ)
        posZ = pos[2];
 }
 
-void   KX_MotionState::getWorldScaling(float& scaleX,float& scaleY,float& scaleZ)
+void   KX_MotionState::GetWorldScaling(float& scaleX,float& scaleY,float& scaleZ)
 {
        const MT_Vector3& scale = m_node->GetWorldScaling();
        scaleX = scale[0];
@@ -57,7 +57,7 @@ void  KX_MotionState::getWorldScaling(float& scaleX,float& scaleY,float& scaleZ)
        scaleZ = scale[2];
 }
 
-void   KX_MotionState::getWorldOrientation(float& quatIma0,float& quatIma1,float& quatIma2,float& quatReal)
+void   KX_MotionState::GetWorldOrientation(float& quatIma0,float& quatIma1,float& quatIma2,float& quatReal)
 {
        MT_Quaternion orn = m_node->GetWorldOrientation().getRotation();
        quatIma0 = orn[0];
@@ -66,24 +66,24 @@ void        KX_MotionState::getWorldOrientation(float& quatIma0,float& quatIma1,float&
        quatReal = orn[3];
 }
        
-void   KX_MotionState::getWorldOrientation(float* ori)
+void   KX_MotionState::GetWorldOrientation(float* ori)
 {
        const MT_Matrix3x3& mat = m_node->GetWorldOrientation();
        mat.getValue(ori);
 }
        
-void   KX_MotionState::setWorldOrientation(const float* ori)
+void   KX_MotionState::SetWorldOrientation(const float* ori)
 {
        m_node->SetLocalOrientation(ori);
 }
        
-void   KX_MotionState::setWorldPosition(float posX,float posY,float posZ)
+void   KX_MotionState::SetWorldPosition(float posX,float posY,float posZ)
 {
        m_node->SetLocalPosition(MT_Point3(posX,posY,posZ));
        //m_node->SetWorldPosition(MT_Point3(posX,posY,posZ));
 }
 
-void   KX_MotionState::setWorldOrientation(float quatIma0,float quatIma1,float quatIma2,float quatReal)
+void   KX_MotionState::SetWorldOrientation(float quatIma0,float quatIma1,float quatIma2,float quatReal)
 {
        MT_Quaternion orn;
        orn[0] = quatIma0;
@@ -96,7 +96,7 @@ void  KX_MotionState::setWorldOrientation(float quatIma0,float quatIma1,float qua
 
 }
 
-void   KX_MotionState::calculateWorldTransformations()
+void   KX_MotionState::CalculateWorldTransformations()
 {
        //Not needed, will be done in KX_Scene::UpdateParents() after the physics simulation
        //bool parentUpdated = false;
index 116e62f408fabc1f3165d6970e3182cfe8bd8c23..38046fe4ff934d6fb96eb5fdc85e7f66ece39399 100644 (file)
@@ -46,15 +46,15 @@ public:
        KX_MotionState(class SG_Spatial* spatial);
        virtual ~KX_MotionState();
 
-       virtual void    getWorldPosition(float& posX,float& posY,float& posZ);
-       virtual void    getWorldScaling(float& scaleX,float& scaleY,float& scaleZ);
-       virtual void    getWorldOrientation(float& quatIma0,float& quatIma1,float& quatIma2,float& quatReal);
-       virtual void    setWorldPosition(float posX,float posY,float posZ);
-       virtual void    setWorldOrientation(float quatIma0,float quatIma1,float quatIma2,float quatReal);
-       virtual void    getWorldOrientation(float* ori);
-       virtual void    setWorldOrientation(const float* ori);
+       virtual void    GetWorldPosition(float& posX,float& posY,float& posZ);
+       virtual void    GetWorldScaling(float& scaleX,float& scaleY,float& scaleZ);
+       virtual void    GetWorldOrientation(float& quatIma0,float& quatIma1,float& quatIma2,float& quatReal);
+       virtual void    SetWorldPosition(float posX,float posY,float posZ);
+       virtual void    SetWorldOrientation(float quatIma0,float quatIma1,float quatIma2,float quatReal);
+       virtual void    GetWorldOrientation(float* ori);
+       virtual void    SetWorldOrientation(const float* ori);
 
-       virtual void    calculateWorldTransformations();
+       virtual void    CalculateWorldTransformations();
 
 
 #ifdef WITH_CXX_GUARDEDALLOC
index 82ae8c13633ee3ff03f0b892c4a6add2da9d9242..2dbafdad3d9295fa45b13706fa44db8aed1b5b72 100644 (file)
@@ -47,7 +47,6 @@
 #include "KX_PyMath.h"
 
 #include "KX_RayCast.h"
-#include "KX_IPhysicsController.h"
 #include "PHY_IPhysicsController.h"
 #include "PHY_IPhysicsEnvironment.h"
 
@@ -280,7 +279,7 @@ bool KX_MouseFocusSensor::ParentObjectHasFocusCamera(KX_Camera *cam)
        /* 2. Get the object from PhysicsEnvironment */
        /* Shoot! Beware that the first argument here is an
         * ignore-object. We don't ignore anything... */
-       KX_IPhysicsController* physics_controller = cam->GetPhysicsController();
+       PHY_IPhysicsController* physics_controller = cam->GetPhysicsController();
        PHY_IPhysicsEnvironment* physics_environment = m_kxscene->GetPhysicsEnvironment();
 
        // get UV mapping
index cbb4e77d1659686b76400553ee52513391c3aa10..6459f35192d2eb1af870694ec6ee8faa4d18bb55 100644 (file)
@@ -68,7 +68,7 @@ KX_NearSensor::KX_NearSensor(SCA_EventManager* eventmgr,
        if (m_physCtrl)
        {
                m_physCtrl->SetMargin(m_Margin);
-               m_physCtrl->setNewClientInfo(m_client_info);
+               m_physCtrl->SetNewClientInfo(m_client_info);
        }
        SynchronizeTransform();
 }
@@ -84,8 +84,8 @@ void KX_NearSensor::SynchronizeTransform()
                const MT_Point3& pos = parent->NodeGetWorldPosition();
                float ori[12];
                parent->NodeGetWorldOrientation().getValue(ori);
-               motionState->setWorldPosition(pos[0], pos[1], pos[2]);
-               motionState->setWorldOrientation(ori);
+               motionState->SetWorldPosition(pos[0], pos[1], pos[2]);
+               motionState->SetWorldOrientation(ori);
                m_physCtrl->WriteMotionStateToDynamics(true);
        }
 }
@@ -105,12 +105,12 @@ void KX_NearSensor::ProcessReplica()
        
        if (m_physCtrl)
        {
-               m_physCtrl = m_physCtrl->GetReplica();
+               m_physCtrl = m_physCtrl->GetReplicaForSensors();
                if (m_physCtrl)
                {
                        //static_cast<KX_TouchEventManager*>(m_eventmgr)->GetPhysicsEnvironment()->addSensor(replica->m_physCtrl);
                        m_physCtrl->SetMargin(m_Margin);
-                       m_physCtrl->setNewClientInfo(m_client_info);
+                       m_physCtrl->SetNewClientInfo(m_client_info);
                }
                
        }
@@ -186,7 +186,7 @@ bool        KX_NearSensor::BroadPhaseFilterCollision(void*obj1,void*obj2)
        
        // need the mapping from PHY_IPhysicsController to gameobjects now
        assert(obj1==m_physCtrl && obj2);
-       KX_ClientObjectInfo *client_info = static_cast<KX_ClientObjectInfo*>((static_cast<PHY_IPhysicsController*>(obj2))->getNewClientInfo());
+       KX_ClientObjectInfo *client_info = static_cast<KX_ClientObjectInfo*>((static_cast<PHY_IPhysicsController*>(obj2))->GetNewClientInfo());
 
        KX_GameObject* gameobj = ( client_info ? 
                        client_info->m_gameobject :
@@ -216,8 +216,8 @@ bool        KX_NearSensor::NewHandleCollision(void *obj1, void *obj2, const PHY_CollDat
        // need the mapping from PHY_IPhysicsController to gameobjects now
        
        KX_ClientObjectInfo *client_info = static_cast<KX_ClientObjectInfo*> (obj1 == m_physCtrl?
-                                       ((PHY_IPhysicsController*)obj2)->getNewClientInfo() : 
-                                       ((PHY_IPhysicsController*)obj1)->getNewClientInfo());
+                                       ((PHY_IPhysicsController*)obj2)->GetNewClientInfo() :
+                                       ((PHY_IPhysicsController*)obj1)->GetNewClientInfo());
 
        KX_GameObject* gameobj = ( client_info ? 
                        client_info->m_gameobject :
index 2965faba8f47f0498d28798b5168eef0cb19c252..2f85453dd23fd3ca7b44571caa1160765c2d9d56 100644 (file)
@@ -36,7 +36,9 @@
 #include "KX_ObjectActuator.h"
 #include "KX_GameObject.h"
 #include "KX_PyMath.h" // For PyVecTo - should this include be put in PyObjectPlus?
-#include "KX_IPhysicsController.h"
+#include "PHY_IPhysicsController.h"
+#include "PHY_ICharacter.h"
+#include "PHY_IPhysicsEnvironment.h"
 
 /* ------------------------------------------------------------------------- */
 /* Native functions                                                          */
@@ -84,8 +86,9 @@ KX_ObjectActuator(
        if (m_bitLocalFlag.CharacterMotion)
        {
                KX_GameObject *parent = static_cast<KX_GameObject *>(GetParent());
+               PHY_ICharacter *character = parent->GetScene()->GetPhysicsEnvironment()->GetCharacterController(parent);
 
-               if (!parent->GetPhysicsController() || !parent->GetPhysicsController()->IsCharacter())
+               if (!character)
                {
                        printf("Character motion enabled on non-character object (%s), falling back to simple motion.\n", parent->GetName().Ptr());
                        m_bitLocalFlag.CharacterMotion = false;
@@ -109,6 +112,7 @@ bool KX_ObjectActuator::Update()
        RemoveAllEvents();
                
        KX_GameObject *parent = static_cast<KX_GameObject *>(GetParent()); 
+       PHY_ICharacter *character = parent->GetScene()->GetPhysicsEnvironment()->GetCharacterController(parent);
 
        if (bNegativeEvent) {
                // If we previously set the linear velocity we now have to inform
@@ -128,8 +132,7 @@ bool KX_ObjectActuator::Update()
 
                // Explicitly stop the movement if we're using character motion
                if (m_bitLocalFlag.CharacterMotion) {
-                       MT_Vector3 vec(0.0, 0.0, 0.0);
-                       parent->GetPhysicsController()->SetWalkDirection(vec, true);
+                       character->SetWalkDirection(MT_Vector3 (0.0, 0.0, 0.0));
                }
 
                m_linear_damping_active = false;
@@ -220,7 +223,7 @@ bool KX_ObjectActuator::Update()
                        MT_Vector3 dir = m_dloc;
 
                        if (m_bitLocalFlag.AddOrSetCharLoc) {
-                               MT_Vector3 old_dir = parent->GetPhysicsController()->GetWalkDirection();
+                               MT_Vector3 old_dir = character->GetWalkDirection();
 
                                if (!old_dir.fuzzyZero()) {
                                        MT_Scalar mag = old_dir.length();
@@ -232,7 +235,12 @@ bool KX_ObjectActuator::Update()
                        }
 
                        // We always want to set the walk direction since a walk direction of (0, 0, 0) should stop the character
-                       parent->GetPhysicsController()->SetWalkDirection(dir, (m_bitLocalFlag.DLoc) != 0);
+                       if (m_bitLocalFlag.DLoc)
+                       {
+                               MT_Matrix3x3 basis = parent->GetPhysicsController()->GetOrientation();
+                               dir = basis*dir;
+                       }
+                       character->SetWalkDirection(dir/parent->GetScene()->GetPhysicsEnvironment()->GetNumTimeSubSteps());
 
                        if (!m_bitLocalFlag.ZeroDRot)
                        {
@@ -240,7 +248,8 @@ bool KX_ObjectActuator::Update()
                        }
                        if (m_bitLocalFlag.CharacterJump)
                        {
-                               parent->GetPhysicsController()->Jump();
+
+                               character->Jump();
                        }
                }
                else {
index 2e9b988dff1f23fc287cdc0bd4d6d082724356de..e9843b0af5bee4875dea62e4fda1ae66388514ff 100644 (file)
@@ -100,7 +100,7 @@ static PyObject *gPySetGravity(PyObject *self,
        if (PyArg_ParseTuple(args,"fff",&x,&y,&z))
        {
                if (PHY_GetActiveEnvironment())
-                       PHY_GetActiveEnvironment()->setGravity(x,y,z);
+                       PHY_GetActiveEnvironment()->SetGravity(x,y,z);
        }
        else {
                return NULL;
@@ -118,7 +118,7 @@ static PyObject *gPySetDebugMode(PyObject *self,
        {
                if (PHY_GetActiveEnvironment())
                {
-                       PHY_GetActiveEnvironment()->setDebugMode(mode);
+                       PHY_GetActiveEnvironment()->SetDebugMode(mode);
                        
                }
                
@@ -141,7 +141,7 @@ static PyObject *gPySetNumTimeSubSteps(PyObject *self,
        {
                if (PHY_GetActiveEnvironment())
                {
-                       PHY_GetActiveEnvironment()->setNumTimeSubSteps(substep);
+                       PHY_GetActiveEnvironment()->SetNumTimeSubSteps(substep);
                }
        }
        else {
@@ -160,7 +160,7 @@ static PyObject *gPySetNumIterations(PyObject *self,
        {
                if (PHY_GetActiveEnvironment())
                {
-                       PHY_GetActiveEnvironment()->setNumIterations(iter);
+                       PHY_GetActiveEnvironment()->SetNumIterations(iter);
                }
        }
        else {
@@ -179,7 +179,7 @@ static PyObject *gPySetDeactivationTime(PyObject *self,
        {
                if (PHY_GetActiveEnvironment())
                {
-                       PHY_GetActiveEnvironment()->setDeactivationTime(deactive_time);
+                       PHY_GetActiveEnvironment()->SetDeactivationTime(deactive_time);
                }
        }
        else {
@@ -198,7 +198,7 @@ static PyObject *gPySetDeactivationLinearTreshold(PyObject *self,
        {
                if (PHY_GetActiveEnvironment())
                {
-                       PHY_GetActiveEnvironment()->setDeactivationLinearTreshold( linearDeactivationTreshold);
+                       PHY_GetActiveEnvironment()->SetDeactivationLinearTreshold( linearDeactivationTreshold);
                }
        }
        else {
@@ -217,7 +217,7 @@ static PyObject *gPySetDeactivationAngularTreshold(PyObject *self,
        {
                if (PHY_GetActiveEnvironment())
                {
-                       PHY_GetActiveEnvironment()->setDeactivationAngularTreshold( angularDeactivationTreshold);
+                       PHY_GetActiveEnvironment()->SetDeactivationAngularTreshold( angularDeactivationTreshold);
                }
        }
        else {
@@ -235,7 +235,7 @@ static PyObject *gPySetContactBreakingTreshold(PyObject *self,
        {
                if (PHY_GetActiveEnvironment())
                {
-                       PHY_GetActiveEnvironment()->setContactBreakingTreshold( contactBreakingTreshold);
+                       PHY_GetActiveEnvironment()->SetContactBreakingTreshold( contactBreakingTreshold);
                }
        }
        else {
@@ -254,7 +254,7 @@ static PyObject *gPySetCcdMode(PyObject *self,
        {
                if (PHY_GetActiveEnvironment())
                {
-                       PHY_GetActiveEnvironment()->setCcdMode( ccdMode);
+                       PHY_GetActiveEnvironment()->SetCcdMode( ccdMode);
                }
        }
        else {
@@ -272,7 +272,7 @@ static PyObject *gPySetSorConstant(PyObject *self,
        {
                if (PHY_GetActiveEnvironment())
                {
-                       PHY_GetActiveEnvironment()->setSolverSorConstant( sor);
+                       PHY_GetActiveEnvironment()->SetSolverSorConstant( sor);
                }
        }
        else {
@@ -290,7 +290,7 @@ static PyObject *gPySetSolverTau(PyObject *self,
        {
                if (PHY_GetActiveEnvironment())
                {
-                       PHY_GetActiveEnvironment()->setSolverTau( tau);
+                       PHY_GetActiveEnvironment()->SetSolverTau( tau);
                }
        }
        else {
@@ -309,7 +309,7 @@ static PyObject *gPySetSolverDamping(PyObject *self,
        {
                if (PHY_GetActiveEnvironment())
                {
-                       PHY_GetActiveEnvironment()->setSolverDamping( damping);
+                       PHY_GetActiveEnvironment()->SetSolverDamping( damping);
                }
        }
        else {
@@ -327,7 +327,7 @@ static PyObject *gPySetLinearAirDamping(PyObject *self,
        {
                if (PHY_GetActiveEnvironment())
                {
-                       PHY_GetActiveEnvironment()->setLinearAirDamping( damping);
+                       PHY_GetActiveEnvironment()->SetLinearAirDamping( damping);
                }
        }
        else {
@@ -346,7 +346,7 @@ static PyObject *gPySetUseEpa(PyObject *self,
        {
                if (PHY_GetActiveEnvironment())
                {
-                       PHY_GetActiveEnvironment()->setUseEpa(epa);
+                       PHY_GetActiveEnvironment()->SetUseEpa(epa);
                }
        }
        else {
@@ -363,7 +363,7 @@ static PyObject *gPySetSolverType(PyObject *self,
        {
                if (PHY_GetActiveEnvironment())
                {
-                       PHY_GetActiveEnvironment()->setSolverType(solverType);
+                       PHY_GetActiveEnvironment()->SetSolverType(solverType);
                }
        }
        else {
@@ -389,7 +389,7 @@ static PyObject *gPyGetVehicleConstraint(PyObject *self,
                if (PHY_GetActiveEnvironment())
                {
                        
-                       PHY_IVehicle* vehicle = PHY_GetActiveEnvironment()->getVehicleConstraint(constraintid);
+                       PHY_IVehicle* vehicle = PHY_GetActiveEnvironment()->GetVehicleConstraint(constraintid);
                        if (vehicle)
                        {
                                KX_VehicleWrapper* pyWrapper = new KX_VehicleWrapper(vehicle,PHY_GetActiveEnvironment());
@@ -421,7 +421,7 @@ static PyObject* gPyGetCharacter(PyObject* self,
        if (PHY_GetActiveEnvironment())
        {
                        
-               PHY_ICharacter* character= PHY_GetActiveEnvironment()->getCharacterController(ob);
+               PHY_ICharacter* character= PHY_GetActiveEnvironment()->GetCharacterController(ob);
                if (character)
                {
                        KX_CharacterWrapper* pyWrapper = new KX_CharacterWrapper(character);
@@ -523,14 +523,14 @@ static PyObject *gPyCreateConstraint(PyObject *self,
                                        MT_Vector3 axis1 = localCFrame.getColumn(1);
                                        MT_Vector3 axis2 = localCFrame.getColumn(2);
 
-                                       constraintid = PHY_GetActiveEnvironment()->createConstraint(physctrl,physctrl2,(enum PHY_ConstraintType)constrainttype,
+                                       constraintid = PHY_GetActiveEnvironment()->CreateConstraint(physctrl,physctrl2,(enum PHY_ConstraintType)constrainttype,
                                                                                                    pivotX,pivotY,pivotZ,
                                                                                                    (float)axis0.x(),(float)axis0.y(),(float)axis0.z(),
                                                                                                    (float)axis1.x(),(float)axis1.y(),(float)axis1.z(),
                                                                                                    (float)axis2.x(),(float)axis2.y(),(float)axis2.z(),flag);
                                }
                                else {
-                                       constraintid = PHY_GetActiveEnvironment()->createConstraint(physctrl,physctrl2,(enum PHY_ConstraintType)constrainttype,pivotX,pivotY,pivotZ,axisX,axisY,axisZ,0);
+                                       constraintid = PHY_GetActiveEnvironment()->CreateConstraint(physctrl,physctrl2,(enum PHY_ConstraintType)constrainttype,pivotX,pivotY,pivotZ,axisX,axisY,axisZ,0);
                                }
                                
                                KX_ConstraintWrapper* wrap = new KX_ConstraintWrapper((enum PHY_ConstraintType)constrainttype,constraintid,PHY_GetActiveEnvironment());
@@ -567,7 +567,7 @@ static PyObject *gPyGetAppliedImpulse(PyObject *self,
        {
                if (PHY_GetActiveEnvironment())
                {
-                       appliedImpulse = PHY_GetActiveEnvironment()->getAppliedImpulse(constraintid);
+                       appliedImpulse = PHY_GetActiveEnvironment()->GetAppliedImpulse(constraintid);
                }
        }
        else {
@@ -592,7 +592,7 @@ static PyObject *gPyRemoveConstraint(PyObject *self,
        {
                if (PHY_GetActiveEnvironment())
                {
-                       PHY_GetActiveEnvironment()->removeConstraint(constraintid);
+                       PHY_GetActiveEnvironment()->RemoveConstraint(constraintid);
                }
        }
        else {
@@ -610,7 +610,7 @@ static PyObject *gPyExportBulletFile(PyObject *, PyObject *args)
 
        if (PHY_GetActiveEnvironment())
        {
-               PHY_GetActiveEnvironment()->exportFile(filename);
+               PHY_GetActiveEnvironment()->ExportFile(filename);
        }
        Py_RETURN_NONE;
 }
index 311653e72e7bc0cfbebe8f9050ebfdb11f9ff5ce..08e240903d19e2cc36103d62b403db8442c849e1 100644 (file)
@@ -480,7 +480,7 @@ static PyObject *gPySetPhysicsTicRate(PyObject *, PyObject *args)
        if (!PyArg_ParseTuple(args, "f:setPhysicsTicRate", &ticrate))
                return NULL;
        
-       PHY_GetActiveEnvironment()->setFixedTimeStep(true,ticrate);
+       PHY_GetActiveEnvironment()->SetFixedTimeStep(true,ticrate);
        Py_RETURN_NONE;
 }
 #if 0 // unused
@@ -498,7 +498,7 @@ static PyObject *gPySetPhysicsDebug(PyObject *, PyObject *args)
 
 static PyObject *gPyGetPhysicsTicRate(PyObject *)
 {
-       return PyFloat_FromDouble(PHY_GetActiveEnvironment()->getFixedTimeStep());
+       return PyFloat_FromDouble(PHY_GetActiveEnvironment()->GetFixedTimeStep());
 }
 
 static PyObject *gPyGetAverageFrameRate(PyObject *)
index 04d67fc73e12ce5bafabb99c87e51b62981c6c37..732bcdc3773d1023c5cea7212456a1271b6a864b 100644 (file)
@@ -166,8 +166,8 @@ void KX_RadarSensor::SynchronizeTransform()
                const MT_Point3& pos = trans.getOrigin();
                float ori[12];
                trans.getBasis().getValue(ori);
-               motionState->setWorldPosition(pos[0], pos[1], pos[2]);
-               motionState->setWorldOrientation(ori);
+               motionState->SetWorldPosition(pos[0], pos[1], pos[2]);
+               motionState->SetWorldOrientation(ori);
                m_physCtrl->WriteMotionStateToDynamics(true);
        }
 
index f1bfb10220a8173f96024f826ac28abce378da6a..333e7b57d679c979e1da3fd5b6dd09932b726451 100644 (file)
 #include "MT_Point3.h"
 #include "MT_Vector3.h"
 
-#include "KX_IPhysicsController.h"
 #include "PHY_IPhysicsEnvironment.h"
 #include "PHY_IPhysicsController.h"
 
-KX_RayCast::KX_RayCast(KX_IPhysicsController* ignoreController, bool faceNormal, bool faceUV)
-       :PHY_IRayCastFilterCallback(dynamic_cast<PHY_IPhysicsController*>(ignoreController), faceNormal, faceUV) 
+KX_RayCast::KX_RayCast(PHY_IPhysicsController* ignoreController, bool faceNormal, bool faceUV)
+       :PHY_IRayCastFilterCallback(ignoreController, faceNormal, faceUV)
 {
 }
 
@@ -76,11 +75,11 @@ bool KX_RayCast::RayTest(PHY_IPhysicsEnvironment* physics_environment, const MT_
        
        PHY_IPhysicsController* hit_controller;
 
-       while ((hit_controller = physics_environment->rayTest(callback,
+       while ((hit_controller = physics_environment->RayTest(callback,
                                                              frompoint.x(),frompoint.y(),frompoint.z(),
                                                              topoint.x(),topoint.y(),topoint.z())) != NULL)
        {
-               KX_ClientObjectInfo *info = static_cast<KX_ClientObjectInfo*>(hit_controller->getNewClientInfo());
+               KX_ClientObjectInfo *info = static_cast<KX_ClientObjectInfo*>(hit_controller->GetNewClientInfo());
                
                if (!info)
                {
index 544080f31d01ddb65b0b952cf78c79e943af245b..e47ac676eb1d0234cdcd7f642a89bc677f4036c5 100644 (file)
@@ -40,7 +40,6 @@
 
 class RAS_MeshObject; 
 struct KX_ClientObjectInfo;
-class KX_IPhysicsController;
 
 /**
  *  Defines a function for doing a ray cast.
@@ -65,7 +64,7 @@ public:
        int                     m_hitUVOK;              // !=0 if UV coordinate in m_hitUV is valid
        MT_Vector2                              m_hitUV;
 
-       KX_RayCast(KX_IPhysicsController* ignoreController, bool faceNormal, bool faceUV);
+       KX_RayCast(PHY_IPhysicsController* ignoreController, bool faceNormal, bool faceUV);
        virtual ~KX_RayCast() {}
 
        /**
@@ -105,7 +104,7 @@ template<class T> class KX_RayCast::Callback : public KX_RayCast
        T *self;
        void *data;
 public:
-       Callback(T *_self, KX_IPhysicsController* controller=NULL, void *_data = NULL, bool faceNormal=false, bool faceUV=false)
+       Callback(T *_self, PHY_IPhysicsController* controller=NULL, void *_data = NULL, bool faceNormal=false, bool faceUV=false)
                : KX_RayCast(controller, faceNormal, faceUV),
                self(_self),
                data(_data)
@@ -121,7 +120,7 @@ public:
 
        virtual bool needBroadphaseRayCast(PHY_IPhysicsController* controller)
        {
-               KX_ClientObjectInfo* info = static_cast<KX_ClientObjectInfo*>(controller->getNewClientInfo());
+               KX_ClientObjectInfo* info = static_cast<KX_ClientObjectInfo*>(controller->GetNewClientInfo());
                
                if (!info)
                {
index 3fbce690a9f26c4d393ff2ddceacb1e28194a1c0..afd395571306c4964e0b4fb10bf158f5850ea965 100644 (file)
@@ -44,7 +44,6 @@
 #include "KX_RayCast.h"
 #include "KX_PyMath.h"
 #include "PHY_IPhysicsEnvironment.h"
-#include "KX_IPhysicsController.h"
 #include "PHY_IPhysicsController.h"
 #include "DNA_sensor_types.h"
 
@@ -261,7 +260,7 @@ bool KX_RaySensor::Evaluate()
                return false;
        } 
 
-       KX_IPhysicsController *spc = obj->GetPhysicsController();
+       PHY_IPhysicsController *spc = obj->GetPhysicsController();
        KX_GameObject *parent = obj->GetParent();
        if (!spc && parent)
                spc = parent->GetPhysicsController();
index 56dccc1d04542c271abe29665d54adbf08f425ae..f8f79269eaa080d34cfcb13466060df69539b10e 100644 (file)
@@ -38,7 +38,6 @@
 #include "KX_SCA_AddObjectActuator.h"
 #include "SCA_IScene.h"
 #include "KX_GameObject.h"
-#include "KX_IPhysicsController.h"
 #include "PyObjectPlus.h" 
 
 /* ------------------------------------------------------------------------- */
index 5dc67a4cff36af70e788419a6ccd096083fb8cfb..e02eca3db6324e6f0c39bd400c3751af62da95a0 100644 (file)
@@ -35,6 +35,7 @@
  * Please look here for revision history. */
 
 #include "KX_SCA_DynamicActuator.h"
+#include "PHY_IPhysicsController.h"
 
 #ifdef WITH_PYTHON
 
@@ -105,7 +106,7 @@ bool KX_SCA_DynamicActuator::Update()
        // bool result = false; /*unused*/
        KX_GameObject *obj = (KX_GameObject*) GetParent();
        bool bNegativeEvent = IsNegativeEvent();
-       KX_IPhysicsController* controller;
+       PHY_IPhysicsController* controller;
        RemoveAllEvents();
 
        if (bNegativeEvent)
@@ -120,16 +121,16 @@ bool KX_SCA_DynamicActuator::Update()
        switch (m_dyn_operation)
        {
                case 0:
-                       obj->RestoreDynamics();
+                       controller->RestoreDynamics();
                        break;
                case 1:
-                       obj->SuspendDynamics();
+                       controller->SuspendDynamics();
                        break;
                case 2:
-                       controller->setRigidBody(true);
+                       controller->SetRigidBody(true);
                        break;
                case 3:
-                       controller->setRigidBody(false);
+                       controller->SetRigidBody(false);
                        break;
                case 4:
                        controller->SetMass(m_setmass);
index 01a91624c41bd38b91c51ac7be7a8067ac7a8db9..4eb337c54f521cc460f67b297c76df29594b08f1 100644 (file)
@@ -38,7 +38,6 @@
 #include "SCA_LogicManager.h"
 
 #include "KX_GameObject.h"
-#include "KX_IPhysicsController.h"
 
 class KX_SCA_DynamicActuator : public SCA_IActuator
 {
index a34764d7d175434452d8b4dadce942c983332e40..1d95beed6e954697b88d6ff7e763e7e3f08f809d 100644 (file)
@@ -82,7 +82,6 @@
 #include "KX_NetworkEventManager.h"
 #include "NG_NetworkScene.h"
 #include "PHY_IPhysicsEnvironment.h"
-#include "KX_IPhysicsController.h"
 #include "PHY_IGraphicController.h"
 #include "KX_BlenderSceneConverter.h"
 #include "KX_MotionState.h"
@@ -545,7 +544,7 @@ KX_GameObject* KX_Scene::AddNodeReplicaObject(class SG_IObject* node, class CVal
        for (cit = scenegraphcontrollers.begin();!(cit==scenegraphcontrollers.end());++cit)
        {
                // controller replication is quite complicated
-               // only replicate ipo and physics controller for now
+               // only replicate ipo controller for now
 
                SG_Controller* replicacontroller = (*cit)->GetReplica((SG_Node*) replicanode);
                if (replicacontroller)
@@ -559,9 +558,21 @@ KX_GameObject* KX_Scene::AddNodeReplicaObject(class SG_IObject* node, class CVal
        {
                PHY_IMotionState* motionstate = new KX_MotionState(newobj->GetSGNode());
                PHY_IGraphicController* newctrl = orgobj->GetGraphicController()->GetReplica(motionstate);
-               newctrl->setNewClientInfo(newobj->getClientInfo());
+               newctrl->SetNewClientInfo(newobj->getClientInfo());
                newobj->SetGraphicController(newctrl);
        }
+
+       // replicate physics controller
+       if (orgobj->GetPhysicsController())
+       {
+               PHY_IMotionState* motionstate = new KX_MotionState(newobj->GetSGNode());
+               PHY_IPhysicsController* newctrl = orgobj->GetPhysicsController()->GetReplica();
+               PHY_IPhysicsController* parentctrl = (newobj->GetParent()) ? newobj->GetParent()->GetPhysicsController() : NULL;
+
+               newctrl->SetNewClientInfo(newobj->getClientInfo());
+               newobj->SetPhysicsController(newctrl, newobj->IsDynamic());
+               newctrl->PostProcessReplica(motionstate, parentctrl);
+       }
        return newobj;
 }
 
@@ -1525,7 +1536,7 @@ void KX_Scene::CalculateVisibleMeshes(RAS_IRasterizer* rasty,KX_Camera* cam, int
                double pmat[16] = {0};
                cam->GetProjectionMatrix().getValue(pmat);
 
-               dbvt_culling = m_physicsEnvironment->cullingTest(PhysicsCullingCallback,&info,planes,5,m_dbvt_occlusion_res,
+               dbvt_culling = m_physicsEnvironment->CullingTest(PhysicsCullingCallback,&info,planes,5,m_dbvt_occlusion_res,
                                                                 KX_GetActiveEngine()->GetCanvas()->GetViewPort(),
                                                                 mvmat, pmat);
        }
@@ -1755,14 +1766,14 @@ void KX_Scene::SetNetworkScene(NG_NetworkScene *newScene)
 
 void   KX_Scene::SetGravity(const MT_Vector3& gravity)
 {
-       GetPhysicsEnvironment()->setGravity(gravity[0],gravity[1],gravity[2]);
+       GetPhysicsEnvironment()->SetGravity(gravity[0],gravity[1],gravity[2]);
 }
 
 MT_Vector3 KX_Scene::GetGravity()
 {
        MT_Vector3 gravity;
 
-       GetPhysicsEnvironment()->getGravity(gravity);
+       GetPhysicsEnvironment()->GetGravity(gravity);
 
        return gravity;
 }
@@ -1803,10 +1814,6 @@ short KX_Scene::GetAnimationFPS()
        return m_blenderScene->r.frs_sec;
 }
 
-#ifdef WITH_BULLET
-#include "KX_BulletPhysicsController.h"
-#endif
-
 static void MergeScene_LogicBrick(SCA_ILogicBrick* brick, KX_Scene *to)
 {
        SCA_LogicManager *logicmgr= to->GetLogicManager();
@@ -1839,7 +1846,6 @@ static void MergeScene_LogicBrick(SCA_ILogicBrick* brick, KX_Scene *to)
 #ifdef WITH_BULLET
 #include "CcdGraphicController.h" // XXX  ctrl->SetPhysicsEnvironment(to->GetPhysicsEnvironment());
 #include "CcdPhysicsEnvironment.h" // XXX  ctrl->SetPhysicsEnvironment(to->GetPhysicsEnvironment());
-#include "KX_BulletPhysicsController.h"
 #endif
 
 static void MergeScene_GameObject(KX_GameObject* gameobj, KX_Scene *to, KX_Scene *from)
@@ -1888,12 +1894,17 @@ static void MergeScene_GameObject(KX_GameObject* gameobj, KX_Scene *to, KX_Scene
        }
 
        /* graphics controller */
-       PHY_IGraphicController *ctrl = gameobj->GetGraphicController();
+       PHY_IController *ctrl = gameobj->GetGraphicController();
        if (ctrl) {
                /* SHOULD update the m_cullingTree */
                ctrl->SetPhysicsEnvironment(to->GetPhysicsEnvironment());
        }
 
+       ctrl = gameobj->GetPhysicsController();
+       if (ctrl) {
+               ctrl->SetPhysicsEnvironment(to->GetPhysicsEnvironment());
+       }
+
        /* SG_Node can hold a scene reference */
        SG_Node *sg= gameobj->GetSGNode();
        if (sg) {
@@ -1905,16 +1916,6 @@ static void MergeScene_GameObject(KX_GameObject* gameobj, KX_Scene *to, KX_Scene
                        for (int i=0; i<children.size(); i++)
                                        children[i]->SetSGClientInfo(to);
                }
-#ifdef WITH_BULLET
-               SGControllerList::iterator contit;
-               SGControllerList& controllers = sg->GetSGControllerList();
-               for (contit = controllers.begin();contit!=controllers.end();++contit)
-               {
-                       KX_BulletPhysicsController *phys_ctrl= dynamic_cast<KX_BulletPhysicsController *>(*contit);
-                       if (phys_ctrl)
-                               phys_ctrl->SetPhysicsEnvironment(to->GetPhysicsEnvironment());
-               }
-#endif // WITH_BULLET
        }
        /* If the object is a light, update it's scene */
        if (gameobj->GetGameObjectType() == SCA_IObject::OBJ_LIGHT)
index 1a9e1442cc83be1eda8780a98b38177ba5f9a96e..d010d3d50a037342b1d6ee50760224c56bb1f712 100644 (file)
@@ -48,9 +48,9 @@ KX_TouchEventManager::KX_TouchEventManager(class SCA_LogicManager* logicmgr,
        //m_scene->addTouchCallback(OBJECT_RESPONSE, KX_TouchEventManager::collisionResponse, this);
        //m_scene->addTouchCallback(SENSOR_RESPONSE, KX_TouchEventManager::collisionResponse, this);
 
-       m_physEnv->addTouchCallback(PHY_OBJECT_RESPONSE, KX_TouchEventManager::newCollisionResponse, this);
-       m_physEnv->addTouchCallback(PHY_SENSOR_RESPONSE, KX_TouchEventManager::newCollisionResponse, this);
-       m_physEnv->addTouchCallback(PHY_BROADPH_RESPONSE, KX_TouchEventManager::newBroadphaseResponse, this);
+       m_physEnv->AddTouchCallback(PHY_OBJECT_RESPONSE, KX_TouchEventManager::newCollisionResponse, this);
+       m_physEnv->AddTouchCallback(PHY_SENSOR_RESPONSE, KX_TouchEventManager::newCollisionResponse, this);
+       m_physEnv->AddTouchCallback(PHY_BROADPH_RESPONSE, KX_TouchEventManager::newBroadphaseResponse, this);
 
 }
 
@@ -84,8 +84,8 @@ bool   KX_TouchEventManager::newBroadphaseResponse(void *client_data,
        PHY_IPhysicsController* ctrl1 = static_cast<PHY_IPhysicsController*>(object1);
        PHY_IPhysicsController* ctrl2 = static_cast<PHY_IPhysicsController*>(object2);
 
-       KX_ClientObjectInfo *info1 = (ctrl1) ? static_cast<KX_ClientObjectInfo*>(ctrl1->getNewClientInfo()) : NULL;
-       KX_ClientObjectInfo *info2 = (ctrl1) ? static_cast<KX_ClientObjectInfo*>(ctrl2->getNewClientInfo()) : NULL;
+       KX_ClientObjectInfo *info1 = (ctrl1) ? static_cast<KX_ClientObjectInfo*>(ctrl1->GetNewClientInfo()) : NULL;
+       KX_ClientObjectInfo *info2 = (ctrl1) ? static_cast<KX_ClientObjectInfo*>(ctrl2->GetNewClientInfo()) : NULL;
 
        // This call back should only be called for controllers of Near and Radar sensor
        if (!info1)
@@ -184,7 +184,7 @@ void KX_TouchEventManager::NextFrame()
                        list<SCA_ISensor*>::iterator sit;
 
                        // First client info
-                       KX_ClientObjectInfo *client_info = static_cast<KX_ClientObjectInfo*>(ctrl1->getNewClientInfo());
+                       KX_ClientObjectInfo *client_info = static_cast<KX_ClientObjectInfo*>(ctrl1->GetNewClientInfo());
                        // First gameobject
                        KX_GameObject *kxObj1 = KX_GameObject::GetClientObject(client_info);
                        // Invoke sensor response for each object
@@ -195,7 +195,7 @@ void KX_TouchEventManager::NextFrame()
                        }
 
                        // Second client info
-                       client_info = static_cast<KX_ClientObjectInfo *>(ctrl2->getNewClientInfo());
+                       client_info = static_cast<KX_ClientObjectInfo *>(ctrl2->GetNewClientInfo());
                        // Second gameobject
                        KX_GameObject *kxObj2 = KX_GameObject::GetClientObject(client_info);
                        if (client_info) {
index 9d87da48fae6b478e279d31d03085e1107e813f3..b231a2191ed3801270ccdfefb6fb35e1d29f58fb 100644 (file)
@@ -117,7 +117,7 @@ m_bTouchPulse(bTouchPulse)
        //client_info->m_auxilary_info = NULL;
        client_info->m_sensors.push_back(this);
        
-       m_physCtrl = dynamic_cast<PHY_IPhysicsController*>(gameobj->GetPhysicsController());
+       m_physCtrl = gameobj->GetPhysicsController();
        MT_assert( !gameobj->GetPhysicsController() || m_physCtrl );
        Init();
 }
@@ -156,7 +156,7 @@ void KX_TouchSensor::ProcessReplica()
 void   KX_TouchSensor::ReParent(SCA_IObject* parent)
 {
        KX_GameObject *gameobj = static_cast<KX_GameObject *>(parent);
-       PHY_IPhysicsController *sphy = dynamic_cast<PHY_IPhysicsController*>(((KX_GameObject*)parent)->GetPhysicsController());
+       PHY_IPhysicsController *sphy = ((KX_GameObject*)parent)->GetPhysicsController();
        if (sphy)
                m_physCtrl = sphy;
        
@@ -173,11 +173,11 @@ void KX_TouchSensor::RegisterSumo(KX_TouchEventManager *touchman)
 {
        if (m_physCtrl)
        {
-               if (touchman->GetPhysicsEnvironment()->requestCollisionCallback(m_physCtrl))
+               if (touchman->GetPhysicsEnvironment()->RequestCollisionCallback(m_physCtrl))
                {
-                       KX_ClientObjectInfo *client_info = static_cast<KX_ClientObjectInfo*>(m_physCtrl->getNewClientInfo());
+                       KX_ClientObjectInfo *client_info = static_cast<KX_ClientObjectInfo*>(m_physCtrl->GetNewClientInfo());
                        if (client_info->isSensor())
-                               touchman->GetPhysicsEnvironment()->addSensor(m_physCtrl);
+                               touchman->GetPhysicsEnvironment()->AddSensor(m_physCtrl);
                }
        }
 }
@@ -185,12 +185,12 @@ void KX_TouchSensor::UnregisterSumo(KX_TouchEventManager* touchman)
 {
        if (m_physCtrl)
        {
-               if (touchman->GetPhysicsEnvironment()->removeCollisionCallback(m_physCtrl))
+               if (touchman->GetPhysicsEnvironment()->RemoveCollisionCallback(m_physCtrl))
                {
                        // no more sensor on the controller, can remove it if it is a sensor object
-                       KX_ClientObjectInfo *client_info = static_cast<KX_ClientObjectInfo*>(m_physCtrl->getNewClientInfo());
+                       KX_ClientObjectInfo *client_info = static_cast<KX_ClientObjectInfo*>(m_physCtrl->GetNewClientInfo());
                        if (client_info->isSensor())
-                               touchman->GetPhysicsEnvironment()->removeSensor(m_physCtrl);
+                               touchman->GetPhysicsEnvironment()->RemoveSensor(m_physCtrl);
                }
        }
 }
@@ -203,8 +203,8 @@ bool        KX_TouchSensor::BroadPhaseSensorFilterCollision(void*obj1,void*obj2)
 
        KX_GameObject* myobj = (KX_GameObject*)GetParent();
        KX_GameObject* myparent = myobj->GetParent();
-       KX_ClientObjectInfo *client_info = static_cast<KX_ClientObjectInfo*>(((PHY_IPhysicsController*)obj2)->getNewClientInfo());
-       KX_ClientObjectInfo *my_client_info = static_cast<KX_ClientObjectInfo*>(m_physCtrl->getNewClientInfo());
+       KX_ClientObjectInfo *client_info = static_cast<KX_ClientObjectInfo*>(((PHY_IPhysicsController*)obj2)->GetNewClientInfo());
+       KX_ClientObjectInfo *my_client_info = static_cast<KX_ClientObjectInfo*>(m_physCtrl->GetNewClientInfo());
        KX_GameObject* otherobj = ( client_info ? client_info->m_gameobject : NULL);
 
        // first, decrement refcount as GetParent() increases it
@@ -244,8 +244,8 @@ bool        KX_TouchSensor::NewHandleCollision(void*object1,void*object2,const PHY_Coll
        // need the mapping from PHY_IPhysicsController to gameobjects now
        
        KX_ClientObjectInfo *client_info = static_cast<KX_ClientObjectInfo*> (object1 == m_physCtrl? 
-                                       ((PHY_IPhysicsController*)object2)->getNewClientInfo(): 
-                                       ((PHY_IPhysicsController*)object1)->getNewClientInfo());
+                                       ((PHY_IPhysicsController*)object2)->GetNewClientInfo():
+                                       ((PHY_IPhysicsController*)object1)->GetNewClientInfo());
 
        KX_GameObject* gameobj = ( client_info ? 
                        client_info->m_gameobject : 
index 3cb80e53e12b250dfe0ae256fe543cf2a3aa8125..fdafc4e507deb26fef740b3dd6f2c66a8f06982c 100644 (file)
@@ -35,48 +35,48 @@ CcdGraphicController::CcdGraphicController (CcdPhysicsEnvironment* phyEnv, PHY_I
 CcdGraphicController::~CcdGraphicController()
 {
        if (m_phyEnv)
-               m_phyEnv->removeCcdGraphicController(this);
+               m_phyEnv->RemoveCcdGraphicController(this);
 
        if (m_motionState)
                delete m_motionState;
 }
 
-void CcdGraphicController::setLocalAabb(const btVector3& aabbMin,const btVector3& aabbMax)
+void CcdGraphicController::SetLocalAabb(const btVector3& aabbMin,const btVector3& aabbMax)
 {
        m_localAabbMin = aabbMin;
        m_localAabbMax = aabbMax;
        SetGraphicTransform();
 }
 
-void CcdGraphicController::setLocalAabb(const MT_Point3& aabbMin,const MT_Point3& aabbMax)
+void CcdGraphicController::SetLocalAabb(const MT_Point3& aabbMin,const MT_Point3& aabbMax)
 {
        m_localAabbMin.setValue(aabbMin[0],aabbMin[1],aabbMin[2]);
        m_localAabbMax.setValue(aabbMax[0],aabbMax[1],aabbMax[2]);
        SetGraphicTransform();
 }
 
-void CcdGraphicController::setLocalAabb(const MT_Vector3& aabbMin,const MT_Vector3& aabbMax)
+void CcdGraphicController::SetLocalAabb(const MT_Vector3& aabbMin,const MT_Vector3& aabbMax)
 {
        m_localAabbMin.setValue(aabbMin[0],aabbMin[1],aabbMin[2]);
        m_localAabbMax.setValue(aabbMax[0],aabbMax[1],aabbMax[2]);
        SetGraphicTransform();
 }
 
-void CcdGraphicController::setLocalAabb(const float* aabbMin,const float* aabbMax)
+void CcdGraphicController::SetLocalAabb(const float* aabbMin,const float* aabbMax)
 {
        m_localAabbMin.setValue(aabbMin[0],aabbMin[1],aabbMin[2]);
        m_localAabbMax.setValue(aabbMax[0],aabbMax[1],aabbMax[2]);
        SetGraphicTransform();
 }
 
-void CcdGraphicController::getAabb(btVector3& aabbMin, btVector3& aabbMax)
+void CcdGraphicController::GetAabb(btVector3& aabbMin, btVector3& aabbMax)
 {
        btVector3 pos;
        btVector3 scale;
        float ori[12];
-       m_motionState->getWorldPosition(pos.m_floats[0],pos.m_floats[1],pos.m_floats[2]);
-       m_motionState->getWorldScaling(scale.m_floats[0],scale.m_floats[1],scale.m_floats[2]);
-       m_motionState->getWorldOrientation(ori);
+       m_motionState->GetWorldPosition(pos.m_floats[0],pos.m_floats[1],pos.m_floats[2]);
+       m_motionState->GetWorldScaling(scale.m_floats[0],scale.m_floats[1],scale.m_floats[2]);
+       m_motionState->GetWorldOrientation(ori);
        btMatrix3x3 rot(ori[0], ori[4], ori[8],
                                        ori[1], ori[5], ori[9],
                                        ori[2], ori[6], ori[10]);
@@ -109,9 +109,9 @@ bool CcdGraphicController::SetGraphicTransform()
                return false;
        btVector3 aabbMin;
        btVector3 aabbMax;
-       getAabb(aabbMin, aabbMax);
+       GetAabb(aabbMin, aabbMax);
        // update Aabb in broadphase
-       m_phyEnv->getCullingTree()->setAabb(m_handle,aabbMin,aabbMax,NULL);
+       m_phyEnv->GetCullingTree()->setAabb(m_handle,aabbMin,aabbMax,NULL);
        return true;
 }
 
@@ -131,7 +131,7 @@ void CcdGraphicController::SetPhysicsEnvironment(class PHY_IPhysicsEnvironment*
 {
        CcdPhysicsEnvironment* phyEnv = static_cast<CcdPhysicsEnvironment*>(env);
        /* Updates the m_phyEnv's m_cullingTree & m_cullingCache */
-       if (getBroadphaseHandle()) {
+       if (GetBroadphaseHandle()) {
                /* insert into the new physics scene */
                Activate(false);
                m_phyEnv= phyEnv;
@@ -145,8 +145,8 @@ void CcdGraphicController::SetPhysicsEnvironment(class PHY_IPhysicsEnvironment*
 void CcdGraphicController::Activate(bool active)
 {
        if (active)
-               m_phyEnv->addCcdGraphicController(this);
+               m_phyEnv->AddCcdGraphicController(this);
        else
-               m_phyEnv->removeCcdGraphicController(this);
+               m_phyEnv->RemoveCcdGraphicController(this);
 
 }
index 064f86040f63141472468c265616656be2bfcc6b..e76ad86301eb28f446a2b95e91306fc12f01cd00 100644 (file)
@@ -40,16 +40,16 @@ public:
 
        virtual ~CcdGraphicController();
 
-       void setLocalAabb(const btVector3& aabbMin,const btVector3& aabbMax);
-       void setLocalAabb(const MT_Point3& aabbMin,const MT_Point3& aabbMax);
-       virtual void setLocalAabb(const MT_Vector3& aabbMin,const MT_Vector3& aabbMax);
-       virtual void setLocalAabb(const float aabbMin[3],const float aabbMax[3]);
+       void SetLocalAabb(const btVector3& aabbMin,const btVector3& aabbMax);
+       void SetLocalAabb(const MT_Point3& aabbMin,const MT_Point3& aabbMax);
+       virtual void SetLocalAabb(const MT_Vector3& aabbMin,const MT_Vector3& aabbMax);
+       virtual void SetLocalAabb(const float aabbMin[3],const float aabbMax[3]);
 
        PHY_IMotionState* GetMotionState() { return m_motionState; }
-       void getAabb(btVector3& aabbMin, btVector3& aabbMax);
+       void GetAabb(btVector3& aabbMin, btVector3& aabbMax);
 
-       virtual void setBroadphaseHandle(btBroadphaseProxy* handle) { m_handle = handle; }
-       virtual btBroadphaseProxy* getBroadphaseHandle() { return m_handle; }
+       virtual void SetBroadphaseHandle(btBroadphaseProxy* handle) { m_handle = handle; }
+       virtual btBroadphaseProxy* GetBroadphaseHandle() { return m_handle; }
 
        virtual void SetPhysicsEnvironment(class PHY_IPhysicsEnvironment* env);
 
@@ -67,8 +67,8 @@ public:
        virtual void Activate(bool active);
 
        // client info for culling
-       virtual void* getNewClientInfo() { return m_newClientInfo; }
-       virtual void setNewClientInfo(void* clientinfo) { m_newClientInfo = clientinfo; }
+       virtual void* GetNewClientInfo() { return m_newClientInfo; }
+       virtual void SetNewClientInfo(void* clientinfo) { m_newClientInfo = clientinfo; }
        virtual PHY_IGraphicController* GetReplica(class PHY_IMotionState* motionstate);
                
 private:
index 8a3ad82d17933bdd12f9fde1eb4f34be81e9e0e5..a3838a148e11a34d322a6d8d33971ae838955b77 100644 (file)
@@ -139,9 +139,14 @@ CcdPhysicsController::CcdPhysicsController (const CcdConstructionInfo& ci)
        m_shapeInfo = ci.m_shapeInfo;
        if (m_shapeInfo)
                m_shapeInfo->AddRef();
+
+       m_bulletChildShape = NULL;
        
        m_bulletMotionState = 0;
        m_characterController = 0;
+       m_savedCollisionFlags = 0;
+       m_savedMass = 0.0;
+       m_suspended = false;
        
        CreateRigidbody();
 }
@@ -150,11 +155,11 @@ btTransform&      CcdPhysicsController::GetTransformFromMotionState(PHY_IMotionState*
 {
        static btTransform trans;
        btVector3 tmp;
-       motionState->getWorldPosition(tmp.m_floats[0], tmp.m_floats[1], tmp.m_floats[2]);
+       motionState->GetWorldPosition(tmp.m_floats[0], tmp.m_floats[1], tmp.m_floats[2]);
        trans.setOrigin(tmp);
 
        float ori[12];
-       motionState->getWorldOrientation(ori);
+       motionState->GetWorldOrientation(ori);
        trans.getBasis().setFromOpenGLSubMatrix(ori);
        //btQuaternion orn;
        //motionState->getWorldOrientation(orn[0],orn[1],orn[2],orn[3]);
@@ -180,18 +185,18 @@ public:
                btVector3 pos;
                float ori[12];
 
-               m_blenderMotionState->getWorldPosition(pos.m_floats[0],pos.m_floats[1],pos.m_floats[2]);
-               m_blenderMotionState->getWorldOrientation(ori);
+               m_blenderMotionState->GetWorldPosition(pos.m_floats[0],pos.m_floats[1],pos.m_floats[2]);
+               m_blenderMotionState->GetWorldOrientation(ori);
                worldTrans.setOrigin(pos);
                worldTrans.getBasis().setFromOpenGLSubMatrix(ori);
        }
 
        void    setWorldTransform(const btTransform& worldTrans)
        {
-               m_blenderMotionState->setWorldPosition(worldTrans.getOrigin().getX(),worldTrans.getOrigin().getY(),worldTrans.getOrigin().getZ());
+               m_blenderMotionState->SetWorldPosition(worldTrans.getOrigin().getX(),worldTrans.getOrigin().getY(),worldTrans.getOrigin().getZ());
                btQuaternion rotQuat = worldTrans.getRotation();
-               m_blenderMotionState->setWorldOrientation(rotQuat[0],rotQuat[1],rotQuat[2],rotQuat[3]);
-               m_blenderMotionState->calculateWorldTransformations();
+               m_blenderMotionState->SetWorldOrientation(rotQuat[0],rotQuat[1],rotQuat[2],rotQuat[3]);
+               m_blenderMotionState->CalculateWorldTransformations();
        }
 
 };
@@ -238,7 +243,7 @@ bool CcdPhysicsController::CreateSoftbody()
        btVector3 p(0,0,0);// = getOrigin();
        //btSoftBody*   psb=btSoftBodyHelpers::CreateRope(worldInfo,    btVector3(-10,0,i*0.25),btVector3(10,0,i*0.25), 16,1+2);
        btSoftBody* psb  = 0;
-       btSoftBodyWorldInfo& worldInfo = m_cci.m_physicsEnv->getDynamicsWorld()->getWorldInfo();
+       btSoftBodyWorldInfo& worldInfo = m_cci.m_physicsEnv->GetDynamicsWorld()->getWorldInfo();
 
        if (m_cci.m_collisionShape->getShapeType() == CONVEX_HULL_SHAPE_PROXYTYPE) {
                btConvexHullShape* convexHull = (btConvexHullShape* )m_cci.m_collisionShape;
@@ -456,8 +461,8 @@ bool CcdPhysicsController::CreateSoftbody()
        btTransform startTrans;
        rbci.m_motionState->getWorldTransform(startTrans);
 
-       m_MotionState->setWorldPosition(startTrans.getOrigin().getX(),startTrans.getOrigin().getY(),startTrans.getOrigin().getZ());
-       m_MotionState->setWorldOrientation(0,0,0,1);
+       m_MotionState->SetWorldPosition(startTrans.getOrigin().getX(),startTrans.getOrigin().getY(),startTrans.getOrigin().getZ());
+       m_MotionState->SetWorldOrientation(0,0,0,1);
 
        if (!m_prototypeTransformInitialized)
        {
@@ -609,7 +614,7 @@ bool CcdPhysicsController::ReplaceControllerShape(btCollisionShape *newShape)
        
        if (GetSoftBody()) {
                // soft body must be recreated
-               m_cci.m_physicsEnv->removeCcdPhysicsController(this);
+               m_cci.m_physicsEnv->RemoveCcdPhysicsController(this);
                delete m_object;
                m_object = NULL;
                // force complete reinitialization
@@ -619,14 +624,14 @@ bool CcdPhysicsController::ReplaceControllerShape(btCollisionShape *newShape)
                CreateSoftbody();
                assert(m_object);
                // reinsert the new body
-               m_cci.m_physicsEnv->addCcdPhysicsController(this);
+               m_cci.m_physicsEnv->AddCcdPhysicsController(this);
        }
        
        /* Copied from CcdPhysicsEnvironment::addCcdPhysicsController() */
        
        /* without this, an object can rest on the old physics mesh
         * and not move to account for the physics mesh, even with 'nosleep' */ 
-       btSoftRigidDynamicsWorld* dw= GetPhysicsEnvironment()->getDynamicsWorld();
+       btSoftRigidDynamicsWorld* dw= GetPhysicsEnvironment()->GetDynamicsWorld();
        btCollisionObjectArray &obarr= dw->getCollisionObjectArray();
        btCollisionObject *ob;
        btBroadphaseProxy* proxy;
@@ -648,7 +653,7 @@ CcdPhysicsController::~CcdPhysicsController()
 {
        //will be reference counted, due to sharing
        if (m_cci.m_physicsEnv)
-               m_cci.m_physicsEnv->removeCcdPhysicsController(this);
+               m_cci.m_physicsEnv->RemoveCcdPhysicsController(this);
 
        if (m_MotionState)
                delete m_MotionState;
@@ -683,17 +688,17 @@ bool              CcdPhysicsController::SynchronizeMotionStates(float time)
                        btQuaternion worldquat;
                        btMatrix3x3     trs = sb->m_pose.m_rot*sb->m_pose.m_scl;
                        trs.getRotation(worldquat);
-                       m_MotionState->setWorldPosition(worldPos[0],worldPos[1],worldPos[2]);
-                       m_MotionState->setWorldOrientation(worldquat[0],worldquat[1],worldquat[2],worldquat[3]);
+                       m_MotionState->SetWorldPosition(worldPos[0],worldPos[1],worldPos[2]);
+                       m_MotionState->SetWorldOrientation(worldquat[0],worldquat[1],worldquat[2],worldquat[3]);
                }
                else 
                {
                        btVector3 aabbMin,aabbMax;
                        sb->getAabb(aabbMin,aabbMax);
                        btVector3 worldPos  = (aabbMax+aabbMin)*0.5f;
-                       m_MotionState->setWorldPosition(worldPos[0],worldPos[1],worldPos[2]);
+                       m_MotionState->SetWorldPosition(worldPos[0],worldPos[1],worldPos[2]);
                }
-               m_MotionState->calculateWorldTransformations();
+               m_MotionState->CalculateWorldTransformations();
                return true;
        }
 
@@ -719,12 +724,12 @@ bool              CcdPhysicsController::SynchronizeMotionStates(float time)
                const btVector3& worldPos = xform.getOrigin();
                float ori[12];
                worldOri.getOpenGLSubMatrix(ori);
-               m_MotionState->setWorldOrientation(ori);
-               m_MotionState->setWorldPosition(worldPos[0],worldPos[1],worldPos[2]);
-               m_MotionState->calculateWorldTransformations();
+               m_MotionState->SetWorldOrientation(ori);
+               m_MotionState->SetWorldPosition(worldPos[0],worldPos[1],worldPos[2]);
+               m_MotionState->CalculateWorldTransformations();
 
                float scale[3];
-               m_MotionState->getWorldScaling(scale[0],scale[1],scale[2]);
+               m_MotionState->GetWorldScaling(scale[0],scale[1],scale[2]);
                btVector3 scaling(scale[0],scale[1],scale[2]);
                GetCollisionShape()->setLocalScaling(scaling);
        } else
@@ -743,7 +748,7 @@ bool                CcdPhysicsController::SynchronizeMotionStates(float time)
                m_MotionState->calculateWorldTransformations();
 */
                float scale[3];
-               m_MotionState->getWorldScaling(scale[0],scale[1],scale[2]);
+               m_MotionState->GetWorldScaling(scale[0],scale[1],scale[2]);
                btVector3 scaling(scale[0],scale[1],scale[2]);
                GetCollisionShape()->setLocalScaling(scaling);
        }
@@ -767,7 +772,7 @@ void                CcdPhysicsController::WriteDynamicsToMotionState()
                // controller replication
 void           CcdPhysicsController::PostProcessReplica(class PHY_IMotionState* motionstate,class PHY_IPhysicsController* parentctrl)
 {
-       
+       SetParentCtrl((CcdPhysicsController*)parentctrl);
        m_softBodyTransformInitialized=false;
        m_MotionState = motionstate;
        m_registerCount = 0;
@@ -812,7 +817,7 @@ void                CcdPhysicsController::PostProcessReplica(class PHY_IMotionState* motionsta
        }
        // sensor object are added when needed
        if (!m_cci.m_bSensor)
-               m_cci.m_physicsEnv->addCcdPhysicsController(this);
+               m_cci.m_physicsEnv->AddCcdPhysicsController(this);
 
 
 /*     SM_Object* dynaparent=0;
@@ -857,9 +862,9 @@ void        CcdPhysicsController::SetPhysicsEnvironment(class PHY_IPhysicsEnvironment *
                // since the environment is changing, we must also move the controler to the
                // new environment. Note that we don't handle sensor explicitly: this
                // function can be called on sensor but only when they are not registered
-               if (m_cci.m_physicsEnv->removeCcdPhysicsController(this))
+               if (m_cci.m_physicsEnv->RemoveCcdPhysicsController(this))
                {
-                       physicsEnv->addCcdPhysicsController(this);
+                       physicsEnv->AddCcdPhysicsController(this);
 
                        // Set the object to be active so it can at least by evaluated once.
                        // This fixes issues with static objects not having their physics meshes
@@ -904,7 +909,7 @@ void        CcdPhysicsController::SetCenterOfMassTransform(btTransform& xform)
 }
 
                // kinematic methods
-void           CcdPhysicsController::RelativeTranslate(float dlocX,float dlocY,float dlocZ,bool local)
+void           CcdPhysicsController::RelativeTranslate(const MT_Vector3& dlocin,bool local)
 {
        if (m_object)
        {
@@ -917,7 +922,7 @@ void                CcdPhysicsController::RelativeTranslate(float dlocX,float dlocY,float dloc
                        return;
                }
 
-               btVector3 dloc(dlocX,dlocY,dlocZ);
+               btVector3 dloc(dlocin.x(), dlocin.y(), dlocin.z());
                btTransform xform = m_object->getWorldTransform();
        
                if (local)
@@ -929,22 +934,7 @@ void               CcdPhysicsController::RelativeTranslate(float dlocX,float dlocY,float dloc
 
 }
 
-void           CcdPhysicsController::SetWalkDirection(float dirX,float dirY,float dirZ,bool local)
-{
-
-       if (m_object && m_characterController)
-       {
-               btVector3 dir(dirX,dirY,dirZ);
-               btTransform xform = m_object->getWorldTransform();
-
-               if (local)
-                       dir = xform.getBasis()*dir;
-
-               m_characterController->setWalkDirection(dir/GetPhysicsEnvironment()->getNumTimeSubSteps());
-       }
-}
-
-void           CcdPhysicsController::RelativeRotate(const float rotval[9],bool local)
+void           CcdPhysicsController::RelativeRotate(const MT_Matrix3x3& rotval,bool local)
 {
        if (m_object)
        {
@@ -957,9 +947,9 @@ void                CcdPhysicsController::RelativeRotate(const float rotval[9],bool local)
                        return;
                }
 
-               btMatrix3x3 drotmat(rotval[0], rotval[3], rotval[6],
-                                   rotval[1], rotval[4], rotval[7],
-                                   rotval[2], rotval[5], rotval[8]);
+               btMatrix3x3 drotmat(rotval[0].x(), rotval[1].x(), rotval[2].x(),
+                       rotval[0].y(), rotval[1].y(), rotval[2].y(),
+                       rotval[0].z(), rotval[1].z(), rotval[2].z());
 
 
                btMatrix3x3 currentOrn;
@@ -978,45 +968,23 @@ void              CcdPhysicsController::RelativeRotate(const float rotval[9],bool local)
 void CcdPhysicsController::GetWorldOrientation(btMatrix3x3& mat)
 {
        float ori[12];
-       m_MotionState->getWorldOrientation(ori);
+       m_MotionState->GetWorldOrientation(ori);
        mat.setFromOpenGLSubMatrix(ori);
 }
 
-void           CcdPhysicsController::getOrientation(float &quatImag0,float &quatImag1,float &quatImag2,float &quatReal)
+MT_Matrix3x3 CcdPhysicsController::GetOrientation()
 {
-       btQuaternion q = m_object->getWorldTransform().getRotation();
-       quatImag0 = q[0];
-       quatImag1 = q[1];
-       quatImag2 = q[2];
-       quatReal = q[3];
+       btMatrix3x3 orn = m_object->getWorldTransform().getBasis();
+       return MT_Matrix3x3(orn[0][0], orn[0][1], orn[0][2], orn[1][0], orn[1][1], orn[1][2], orn[2][0], orn[2][1], orn[2][2]);
 }
-void           CcdPhysicsController::setOrientation(float quatImag0,float quatImag1,float quatImag2,float quatReal)
-{
-       if (m_object)
-       {
-               m_object->activate(true);
-               if (m_object->isStaticObject())
-               {
-                       if (!m_cci.m_bSensor)
-                               m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
-                       // kinematic object should not set the transform, it disturbs the velocity interpolation
-                       return;
-               }
-               // not required
-               //m_MotionState->setWorldOrientation(quatImag0,quatImag1,quatImag2,quatReal);
-               btTransform xform  = m_object->getWorldTransform();
-               xform.setRotation(btQuaternion(quatImag0,quatImag1,quatImag2,quatReal));
-               SetCenterOfMassTransform(xform);
-               // not required
-               //m_bulletMotionState->setWorldTransform(xform);
-               
-               
-
-       }
 
+void           CcdPhysicsController::SetOrientation(const MT_Matrix3x3& orn)
+{
+       btMatrix3x3 btmat(orn[0][0], orn[0][1], orn[0][2], orn[1][0], orn[1][1], orn[1][2], orn[2][0], orn[2][1], orn[2][2]);
+       SetWorldOrientation(btmat);
 }
 
-void CcdPhysicsController::setWorldOrientation(const btMatrix3x3& orn)
+void CcdPhysicsController::SetWorldOrientation(const btMatrix3x3& orn)
 {
        if (m_object)
        {
@@ -1045,7 +1013,7 @@ void CcdPhysicsController::setWorldOrientation(const btMatrix3x3& orn)
 
 }
 
-void           CcdPhysicsController::setPosition(float posX,float posY,float posZ)
+void           CcdPhysicsController::SetPosition(const MT_Vector3& pos)
 {
        if (m_object)
        {
@@ -1060,7 +1028,7 @@ void              CcdPhysicsController::setPosition(float posX,float posY,float posZ)
                // not required, this function is only used to update the physic controller
                //m_MotionState->setWorldPosition(posX,posY,posZ);
                btTransform xform  = m_object->getWorldTransform();
-               xform.setOrigin(btVector3(posX,posY,posZ));
+               xform.setOrigin(btVector3(pos.x(), pos.y(), pos.z()));
                SetCenterOfMassTransform(xform);
                if (!m_softBodyTransformInitialized)
                        m_softbodyStartTrans.setOrigin(xform.getOrigin());
@@ -1069,7 +1037,7 @@ void              CcdPhysicsController::setPosition(float posX,float posY,float posZ)
        }
 }
 
-void CcdPhysicsController::forceWorldTransform(const btMatrix3x3& mat, const btVector3& pos)
+void CcdPhysicsController::ForceWorldTransform(const btMatrix3x3& mat, const btVector3& pos)
 {
        if (m_object)
        {
@@ -1080,11 +1048,44 @@ void CcdPhysicsController::forceWorldTransform(const btMatrix3x3& mat, const btV
 }
 
 
-void           CcdPhysicsController::resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ)
+void           CcdPhysicsController::ResolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ)
 {
 }
 
-void           CcdPhysicsController::getPosition(MT_Vector3&   pos) const
+void   CcdPhysicsController::SuspendDynamics(bool ghost)
+{
+       btRigidBody *body = GetRigidBody();
+       if (body && !m_suspended && !GetConstructionInfo().m_bSensor)
+       {
+               m_savedCollisionFlags = body->getCollisionFlags();
+               m_savedMass = GetMass();
+               m_suspended = true;
+               GetPhysicsEnvironment()->UpdateCcdPhysicsController(this,
+                       0.0,
+                       btCollisionObject::CF_STATIC_OBJECT|((ghost)?btCollisionObject::CF_NO_CONTACT_RESPONSE:(m_savedCollisionFlags&btCollisionObject::CF_NO_CONTACT_RESPONSE)),
+                       btBroadphaseProxy::StaticFilter,
+                       btBroadphaseProxy::AllFilter ^ btBroadphaseProxy::StaticFilter);
+       }
+}
+
+void   CcdPhysicsController::RestoreDynamics()
+{
+       btRigidBody *body = GetRigidBody();
+       if (body && m_suspended)
+       {
+               // before make sure any position change that was done in this logic frame are accounted for
+               SetTransform();
+               GetPhysicsEnvironment()->UpdateCcdPhysicsController(this,
+                       m_savedMass,
+                       m_savedCollisionFlags,
+                       GetConstructionInfo().m_collisionFilterGroup,
+                       GetConstructionInfo().m_collisionFilterMask);
+               body->activate();
+               m_suspended = false;
+       }
+}
+
+void           CcdPhysicsController::GetPosition(MT_Vector3&   pos) const
 {
        const btTransform& xform = m_object->getWorldTransform();
        pos[0] = xform.getOrigin().x();
@@ -1092,13 +1093,13 @@ void            CcdPhysicsController::getPosition(MT_Vector3&   pos) const
        pos[2] = xform.getOrigin().z();
 }
 
-void           CcdPhysicsController::setScaling(float scaleX,float scaleY,float scaleZ)
+void           CcdPhysicsController::SetScaling(const MT_Vector3& scale)
 {
-       if (!btFuzzyZero(m_cci.m_scaling.x()-scaleX) ||
-               !btFuzzyZero(m_cci.m_scaling.y()-scaleY) ||
-               !btFuzzyZero(m_cci.m_scaling.z()-scaleZ))
+       if (!btFuzzyZero(m_cci.m_scaling.x()-scale.x()) ||
+           !btFuzzyZero(m_cci.m_scaling.y()-scale.y()) ||
+           !btFuzzyZero(m_cci.m_scaling.z()-scale.z()))
        {
-               m_cci.m_scaling = btVector3(scaleX,scaleY,scaleZ);
+               m_cci.m_scaling = btVector3(scale.x(),scale.y(),scale.z());
 
                if (m_object && m_object->getCollisionShape())
                {
@@ -1116,11 +1117,64 @@ void            CcdPhysicsController::setScaling(float scaleX,float scaleY,float scaleZ)
                }
        }
 }
+
+void CcdPhysicsController::SetTransform()
+{
+       btVector3 pos;
+       btVector3 scale;
+       float ori[12];
+       m_MotionState->GetWorldPosition(pos.m_floats[0],pos.m_floats[1],pos.m_floats[2]);
+       m_MotionState->GetWorldScaling(scale.m_floats[0],scale.m_floats[1],scale.m_floats[2]);
+       m_MotionState->GetWorldOrientation(ori);
+       btMatrix3x3 rot(ori[0], ori[4], ori[8],
+                                       ori[1], ori[5], ori[9],
+                                       ori[2], ori[6], ori[10]);
+       ForceWorldTransform(rot, pos);
+
+       if (!IsDynamic() && !GetConstructionInfo().m_bSensor && !GetCharacterController())
+       {
+               btCollisionObject* object = GetRigidBody();
+               object->setActivationState(ACTIVE_TAG);
+               object->setCollisionFlags(object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
+       }
+}
+
+MT_Scalar      CcdPhysicsController::GetMass()
+{
+       if (GetSoftBody())
+               return GetSoftBody()->getTotalMass();
+
+       MT_Scalar invmass = 0.f;
+       if (GetRigidBody())
+               invmass = GetRigidBody()->getInvMass();
+       if (invmass)
+               return 1.f/invmass;
+       return 0.f;
+
+}
+
+void CcdPhysicsController::SetMass(MT_Scalar newmass)
+{
+       btRigidBody *body = GetRigidBody();
+       if (body && !m_suspended && newmass>MT_EPSILON && GetMass()>MT_EPSILON)
+       {
+               btVector3 grav = body->getGravity();
+               btVector3 accel = grav / GetMass();
+
+               btBroadphaseProxy* handle = body->getBroadphaseHandle();
+               GetPhysicsEnvironment()->UpdateCcdPhysicsController(this,
+                       newmass,
+                       body->getCollisionFlags(),
+                       handle->m_collisionFilterGroup,
+                       handle->m_collisionFilterMask);
+               body->setGravity(accel);
+       }
+}
                
                // physics methods
-void           CcdPhysicsController::ApplyTorque(float torqueX,float torqueY,float torqueZ,bool local)
+void           CcdPhysicsController::ApplyTorque(const MT_Vector3&  torquein,bool local)
 {
-       btVector3 torque(torqueX,torqueY,torqueZ);
+       btVector3 torque(torquein.x(),torquein.y(),torquein.z());
        btTransform xform = m_object->getWorldTransform();
        
 
@@ -1158,9 +1212,9 @@ void              CcdPhysicsController::ApplyTorque(float torqueX,float torqueY,float torque
        }
 }
 
-void           CcdPhysicsController::ApplyForce(float forceX,float forceY,float forceZ,bool local)
+void           CcdPhysicsController::ApplyForce(const MT_Vector3& forcein,bool local)
 {
-       btVector3 force(forceX,forceY,forceZ);
+       btVector3 force(forcein.x(),forcein.y(),forcein.z());
        
 
        if (m_object && force.length2() > (SIMD_EPSILON*SIMD_EPSILON))
@@ -1191,9 +1245,9 @@ void              CcdPhysicsController::ApplyForce(float forceX,float forceY,float forceZ,bo
                }
        }
 }
-void           CcdPhysicsController::SetAngularVelocity(float ang_velX,float ang_velY,float ang_velZ,bool local)
+void           CcdPhysicsController::SetAngularVelocity(const MT_Vector3& ang_vel,bool local)
 {
-       btVector3 angvel(ang_velX,ang_velY,ang_velZ);
+       btVector3 angvel(ang_vel.x(),ang_vel.y(),ang_vel.z());
        if (m_object && angvel.length2() > (SIMD_EPSILON*SIMD_EPSILON))
        {
                m_object->activate(true);
@@ -1214,10 +1268,10 @@ void            CcdPhysicsController::SetAngularVelocity(float ang_velX,float ang_velY,flo
        }
 
 }
-void           CcdPhysicsController::SetLinearVelocity(float lin_velX,float lin_velY,float lin_velZ,bool local)
+void           CcdPhysicsController::SetLinearVelocity(const MT_Vector3& lin_vel,bool local)
 {
 
-       btVector3 linVel(lin_velX,lin_velY,lin_velZ);
+       btVector3 linVel(lin_vel.x(),lin_vel.y(),lin_vel.z());
        if (m_object/* && linVel.length2() > (SIMD_EPSILON*SIMD_EPSILON)*/)
        {
                m_object->activate(true);
@@ -1249,9 +1303,9 @@ void              CcdPhysicsController::SetLinearVelocity(float lin_velX,float lin_velY,floa
                }
        }
 }
-void           CcdPhysicsController::applyImpulse(float attachX,float attachY,float attachZ, float impulseX,float impulseY,float impulseZ)
+void           CcdPhysicsController::ApplyImpulse(const MT_Point3& attach, const MT_Vector3& impulsein)
 {
-       btVector3 impulse(impulseX,impulseY,impulseZ);
+       btVector3 impulse(impulsein.x(), impulsein.y(), impulsein.z());
 
        if (m_object && impulse.length2() > (SIMD_EPSILON*SIMD_EPSILON))
        {
@@ -1263,7 +1317,7 @@ void              CcdPhysicsController::applyImpulse(float attachX,float attachY,float attac
                        return;
                }
                
-               btVector3 pos(attachX,attachY,attachZ);
+               btVector3 pos(attach.x(), attach.y(), attach.z());
                btRigidBody* body = GetRigidBody();
                if (body)
                        body->applyImpulse(impulse,pos);
@@ -1282,82 +1336,59 @@ void            CcdPhysicsController::SetActive(bool active)
 {
 }
                // reading out information from physics
-void           CcdPhysicsController::GetLinearVelocity(float& linvX,float& linvY,float& linvZ)
+MT_Vector3             CcdPhysicsController::GetLinearVelocity()
 {
        btRigidBody* body = GetRigidBody();
        if (body)
        {
                const btVector3& linvel = body->getLinearVelocity();
-               linvX = linvel.x();
-               linvY = linvel.y();
-               linvZ = linvel.z();
-       } else
-       {
-               linvX = 0.f;
-               linvY = 0.f;
-               linvZ = 0.f;
+               return MT_Vector3(linvel.x(), linvel.y(), linvel.z());
        }
 
+       return MT_Vector3(0.f, 0.f, 0.f);
 }
 
-void           CcdPhysicsController::GetAngularVelocity(float& angVelX,float& angVelY,float& angVelZ)
+MT_Vector3             CcdPhysicsController::GetAngularVelocity()
 {
        btRigidBody* body = GetRigidBody();
        if (body)
        {
                const btVector3& angvel= body->getAngularVelocity();
-               angVelX = angvel.x();
-               angVelY = angvel.y();
-               angVelZ = angvel.z();
-       } else
-       {
-               angVelX = 0.f;
-               angVelY = 0.f;
-               angVelZ = 0.f;
+               return MT_Vector3(angvel.x(), angvel.y(), angvel.z());
        }
+
+       return MT_Vector3(0.f, 0.f, 0.f);
 }
 
-void           CcdPhysicsController::GetVelocity(const float posX,const float posY,const float posZ,float& linvX,float& linvY,float& linvZ)
+MT_Vector3             CcdPhysicsController::GetVelocity(const MT_Point3 &posin)
 {
-       btVector3 pos(posX,posY,posZ);
+       btVector3 pos(pos.x(), pos.y(), pos.z());
        btRigidBody* body = GetRigidBody();
        if (body)
        {
                btVector3 linvel = body->getVelocityInLocalPoint(pos);
-               linvX = linvel.x();
-               linvY = linvel.y();
-               linvZ = linvel.z();
-       } else
-       {
-               linvX = 0.f;
-               linvY = 0.f;
-               linvZ = 0.f;
+               return MT_Vector3(linvel.x(), linvel.y(), linvel.z());
        }
-}
 
-void           CcdPhysicsController::GetWalkDirection(float& dirX,float& dirY,float& dirZ)
-{
-       if (m_object && m_characterController)
-       {
-               const btVector3 dir = m_characterController->getWalkDirection();
-               dirX = dir.x();
-               dirY = dir.y();
-               dirZ = dir.z();
-       }
-       else
-       {
-               dirX = 0.f;
-               dirY = 0.f;
-               dirZ = 0.f;
-       }
+       return MT_Vector3(0.f, 0.f, 0.f);
 }
 
-void           CcdPhysicsController::getReactionForce(float& forceX,float& forceY,float& forceZ)
+MT_Vector3 CcdPhysicsController::GetLocalInertia()
 {
+       MT_Vector3 inertia(0.f, 0.f, 0.f);
+       btVector3 inv_inertia;
+       if (GetRigidBody()) {
+               inv_inertia = GetRigidBody()->getInvInertiaDiagLocal();
+               if (!btFuzzyZero(inv_inertia.getX()) &&
+                       !btFuzzyZero(inv_inertia.getY()) &&
+                       !btFuzzyZero(inv_inertia.getZ()))
+                       inertia = MT_Vector3(1.f/inv_inertia.getX(), 1.f/inv_inertia.getY(), 1.f/inv_inertia.getZ());
+       }
+       return inertia;
 }
 
                // dyna's that are rigidbody are free in orientation, dyna's with non-rigidbody are restricted 
-void           CcdPhysicsController::setRigidBody(bool rigid)
+void           CcdPhysicsController::SetRigidBody(bool rigid)
 {
        btRigidBody* body = GetRigidBody();
        if (body)
@@ -1373,13 +1404,21 @@ void            CcdPhysicsController::setRigidBody(bool rigid)
 }
 
                // clientinfo for raycasts for example
-void*          CcdPhysicsController::getNewClientInfo()
+void*          CcdPhysicsController::GetNewClientInfo()
 {
        return m_newClientInfo;
 }
-void           CcdPhysicsController::setNewClientInfo(void* clientinfo)
+void           CcdPhysicsController::SetNewClientInfo(void* clientinfo)
 {
        m_newClientInfo = clientinfo;
+
+       if (m_cci.m_bSensor)
+       {
+               // use a different callback function for sensor object,
+               // bullet will not synchronize, we must do it explicitly
+               SG_Callbacks& callbacks = KX_GameObject::GetClientObject((KX_ClientObjectInfo*)clientinfo)->GetSGNode()->GetCallBackFunctions();
+               callbacks.m_updatefunc = KX_GameObject::SynchronizeTransformFunc;
+       }
 }
 
 
@@ -1392,7 +1431,7 @@ void      CcdPhysicsController::UpdateDeactivation(float timeStep)
        }
 }
 
-bool CcdPhysicsController::wantsSleeping()
+bool CcdPhysicsController::WantsSleeping()
 {
        btRigidBody* body = GetRigidBody();
        if (body)
@@ -1402,8 +1441,143 @@ bool CcdPhysicsController::wantsSleeping()
        //check it out
        return true;
 }
+/* This function dynamically adds the collision shape of another controller to
+ * the current controller shape provided it is a compound shape.
+ * The idea is that dynamic parenting on a compound object will dynamically extend the shape
+ */
+void    CcdPhysicsController::AddCompoundChild(PHY_IPhysicsController* child)
+{
+       if (child == NULL || !IsCompound())
+               return;
+       // other controller must be a bullet controller too
+       // verify that body and shape exist and match
+       CcdPhysicsController* childCtrl = dynamic_cast<CcdPhysicsController*>(child);
+       btRigidBody* rootBody = GetRigidBody();
+       btRigidBody* childBody = childCtrl->GetRigidBody();
+       if (!rootBody || !childBody)
+               return;
+       const btCollisionShape* rootShape = rootBody->getCollisionShape();
+       const btCollisionShape* childShape = childBody->getCollisionShape();
+       if (!rootShape ||
+               !childShape ||
+               rootShape->getShapeType() != COMPOUND_SHAPE_PROXYTYPE ||
+               childShape->getShapeType() == COMPOUND_SHAPE_PROXYTYPE)
+               return;
+       btCompoundShape* compoundShape = (btCompoundShape*)rootShape;
+       // compute relative transformation between parent and child
+       btTransform rootTrans;
+       btTransform childTrans;
+       rootBody->getMotionState()->getWorldTransform(rootTrans);
+       childBody->getMotionState()->getWorldTransform(childTrans);
+       btVector3 rootScale = rootShape->getLocalScaling();
+       rootScale[0] = 1.0/rootScale[0];
+       rootScale[1] = 1.0/rootScale[1];
+       rootScale[2] = 1.0/rootScale[2];
+       // relative scale = child_scale/parent_scale
+       btVector3 relativeScale = childShape->getLocalScaling()*rootScale;
+       btMatrix3x3 rootRotInverse = rootTrans.getBasis().transpose();
+       // relative pos = parent_rot^-1 * ((parent_pos-child_pos)/parent_scale)
+       btVector3 relativePos = rootRotInverse*((childTrans.getOrigin()-rootTrans.getOrigin())*rootScale);
+       // relative rot = parent_rot^-1 * child_rot
+       btMatrix3x3 relativeRot = rootRotInverse*childTrans.getBasis();
+       // create a proxy shape info to store the transformation
+       CcdShapeConstructionInfo* proxyShapeInfo = new CcdShapeConstructionInfo();
+       // store the transformation to this object shapeinfo
+       proxyShapeInfo->m_childTrans.setOrigin(relativePos);
+       proxyShapeInfo->m_childTrans.setBasis(relativeRot);
+       proxyShapeInfo->m_childScale.setValue(relativeScale[0], relativeScale[1], relativeScale[2]);
+       // we will need this to make sure that we remove the right proxy later when unparenting
+       proxyShapeInfo->m_userData = childCtrl;
+       proxyShapeInfo->SetProxy(childCtrl->GetShapeInfo()->AddRef());
+       // add to parent compound shapeinfo (increments ref count)
+       GetShapeInfo()->AddShape(proxyShapeInfo);
+       // create new bullet collision shape from the object shapeinfo and set scaling
+       btCollisionShape* newChildShape = proxyShapeInfo->CreateBulletShape(childCtrl->GetMargin(), childCtrl->GetConstructionInfo().m_bGimpact, true);
+       newChildShape->setLocalScaling(relativeScale);
+       // add bullet collision shape to parent compound collision shape
+       compoundShape->addChildShape(proxyShapeInfo->m_childTrans,newChildShape);
+       // proxyShapeInfo is not needed anymore, release it
+       proxyShapeInfo->Release();
+       // remember we created this shape
+       childCtrl->m_bulletChildShape = newChildShape;
+       // recompute inertia of parent
+       if (!rootBody->isStaticOrKinematicObject())
+       {
+               btVector3 localInertia;
+               float mass = 1.f/rootBody->getInvMass();
+               compoundShape->calculateLocalInertia(mass,localInertia);
+               rootBody->setMassProps(mass,localInertia);
+       }
+       // must update the broadphase cache,
+       GetPhysicsEnvironment()->RefreshCcdPhysicsController(this);
+       // remove the children
+       GetPhysicsEnvironment()->DisableCcdPhysicsController(childCtrl);
+}
+
+/* Reverse function of the above, it will remove a shape from a compound shape
+ * provided that the former was added to the later using  AddCompoundChild()
+ */
+void    CcdPhysicsController::RemoveCompoundChild(PHY_IPhysicsController* child)
+{
+       if (child == NULL || !IsCompound())
+               return;
+       // other controller must be a bullet controller too
+       // verify that body and shape exist and match
+       CcdPhysicsController* childCtrl = dynamic_cast<CcdPhysicsController*>(child);
+       btRigidBody* rootBody = GetRigidBody();
+       btRigidBody* childBody = childCtrl->GetRigidBody();
+       if (!rootBody || !childBody)
+               return;
+       const btCollisionShape* rootShape = rootBody->getCollisionShape();
+       if (!rootShape ||
+               rootShape->getShapeType() != COMPOUND_SHAPE_PROXYTYPE)
+               return;
+       btCompoundShape* compoundShape = (btCompoundShape*)rootShape;
+       // retrieve the shapeInfo
+       CcdShapeConstructionInfo* childShapeInfo = childCtrl->GetShapeInfo();
+       CcdShapeConstructionInfo* rootShapeInfo = GetShapeInfo();
+       // and verify that the child is part of the parent
+       int i = rootShapeInfo->FindChildShape(childShapeInfo, childCtrl);
+       if (i < 0)
+               return;
+       rootShapeInfo->RemoveChildShape(i);
+       if (childCtrl->m_bulletChildShape)
+       {
+               int numChildren = compoundShape->getNumChildShapes();
+               for (i=0; i<numChildren; i++)
+               {
+                       if (compoundShape->getChildShape(i) == childCtrl->m_bulletChildShape)
+                       {
+                               compoundShape->removeChildShapeByIndex(i);
+                               compoundShape->recalculateLocalAabb();
+                               break;
+                       }
+               }
+               delete childCtrl->m_bulletChildShape;
+               childCtrl->m_bulletChildShape = NULL;
+       }
+       // recompute inertia of parent
+       if (!rootBody->isStaticOrKinematicObject())
+       {
+               btVector3 localInertia;
+               float mass = 1.f/rootBody->getInvMass();
+               compoundShape->calculateLocalInertia(mass,localInertia);
+               rootBody->setMassProps(mass,localInertia);
+       }
+       // must update the broadphase cache,
+       GetPhysicsEnvironment()->RefreshCcdPhysicsController(this);
+       // reactivate the children
+       GetPhysicsEnvironment()->EnableCcdPhysicsController(childCtrl);
+}
+
+PHY_IPhysicsController* CcdPhysicsController::GetReplica()
+{
+       CcdPhysicsController* replica = new CcdPhysicsController(*this);
+       return replica;
+}
 
-PHY_IPhysicsController*        CcdPhysicsController::GetReplica()
+// Keeping this separate for now, maybe we can combine it with GetReplica()...
+PHY_IPhysicsController*        CcdPhysicsController::GetReplicaForSensors()
 {
        // This is used only to replicate Near and Radar sensor controllers
        // The replication of object physics controller is done in KX_BulletPhysicsController::GetReplica()
@@ -1462,21 +1636,21 @@ DefaultMotionState::~DefaultMotionState()
 
 }
 
-void   DefaultMotionState::getWorldPosition(float& posX,float& posY,float& posZ)
+void   DefaultMotionState::GetWorldPosition(float& posX,float& posY,float& posZ)
 {
        posX = m_worldTransform.getOrigin().x();
        posY = m_worldTransform.getOrigin().y();
        posZ = m_worldTransform.getOrigin().z();
 }
 
-void   DefaultMotionState::getWorldScaling(float& scaleX,float& scaleY,float& scaleZ)
+void   DefaultMotionState::GetWorldScaling(float& scaleX,float& scaleY,float& scaleZ)
 {
        scaleX = m_localScaling.getX();
        scaleY = m_localScaling.getY();
        scaleZ = m_localScaling.getZ();
 }
 
-void   DefaultMotionState::getWorldOrientation(float& quatIma0,float& quatIma1,float& quatIma2,float& quatReal)
+void   DefaultMotionState::GetWorldOrientation(float& quatIma0,float& quatIma1,float& quatIma2,float& quatReal)
 {
        btQuaternion quat = m_worldTransform.getRotation();
        quatIma0 = quat.x();
@@ -1485,28 +1659,28 @@ void    DefaultMotionState::getWorldOrientation(float& quatIma0,float& quatIma1,flo
        quatReal = quat[3];
 }
                
-void   DefaultMotionState::getWorldOrientation(float* ori)
+void   DefaultMotionState::GetWorldOrientation(float* ori)
 {
        m_worldTransform.getBasis().getOpenGLSubMatrix(ori);
 }
 
-void   DefaultMotionState::setWorldOrientation(const float* ori)
+void   DefaultMotionState::SetWorldOrientation(const float* ori)
 {
        m_worldTransform.getBasis().setFromOpenGLSubMatrix(ori);
 }
-void   DefaultMotionState::setWorldPosition(float posX,float posY,float posZ)
+void   DefaultMotionState::SetWorldPosition(float posX,float posY,float posZ)
 {
        btVector3 pos(posX,posY,posZ);
        m_worldTransform.setOrigin( pos );
 }
 
-void   DefaultMotionState::setWorldOrientation(float quatIma0,float quatIma1,float quatIma2,float quatReal)
+void   DefaultMotionState::SetWorldOrientation(float quatIma0,float quatIma1,float quatIma2,float quatReal)
 {
        btQuaternion orn(quatIma0,quatIma1,quatIma2,quatReal);
        m_worldTransform.setRotation( orn );
 }
                
-void   DefaultMotionState::calculateWorldTransformations()
+void   DefaultMotionState::CalculateWorldTransformations()
 {
 
 }
index f1f0ca31419a7d453731b4648fbf983a10484d78..ecb894c1e8df3cfbebc90c54fc56fc851224c6a7 100644 (file)
@@ -33,6 +33,7 @@ subject to the following restrictions:
 #include "LinearMath/btTransform.h"
 
 #include "PHY_IMotionState.h"
+#include "PHY_ICharacter.h"
 
 extern float gDeactivationTime;
 extern float gLinearSleepingTreshold;
@@ -266,6 +267,7 @@ struct CcdConstructionInfo
                m_soft_kSHR(1.0f),
                m_soft_kAHR(0.7f),
                m_collisionFlags(0),
+           m_bDyna(false),
                m_bRigid(false),
                m_bSoft(false),
                m_bSensor(false),
@@ -349,6 +351,7 @@ struct CcdConstructionInfo
 
 
        int                     m_collisionFlags;
+       bool            m_bDyna;
        bool            m_bRigid;
        bool            m_bSoft;
        bool            m_bSensor;
@@ -396,7 +399,7 @@ class btCollisionObject;
 class btSoftBody;
 class btPairCachingGhostObject;
 
-class BlenderBulletCharacterController : public btKinematicCharacterController
+class BlenderBulletCharacterController : public btKinematicCharacterController, public PHY_ICharacter
 {
 private:
        btMotionState* m_motionState;
@@ -419,6 +422,25 @@ public:
        virtual void jump();
 
        const btVector3& getWalkDirection();
+
+       // PHY_ICharacter interface
+       virtual void Jump()     { jump(); }
+       virtual bool OnGround(){ return onGround(); }
+       virtual float GetGravity() { return getGravity(); }
+       virtual void SetGravity(float gravity) { setGravity(gravity); }
+       virtual int GetMaxJumps() { return getMaxJumps(); }
+       virtual void SetMaxJumps(int maxJumps) { setMaxJumps(maxJumps); }
+       virtual int GetJumpCount() { return getJumpCount(); }
+       virtual void SetWalkDirection(const MT_Vector3& dir)
+       {
+               btVector3 vec = btVector3(dir[0], dir[1], dir[2]);
+               setWalkDirection(vec);
+       }
+       virtual MT_Vector3 GetWalkDirection()
+       {
+               btVector3 vec = getWalkDirection();
+               return MT_Vector3(vec[0], vec[1], vec[2]);
+       }
 };
 
 ///CcdPhysicsController is a physics object that supports continuous collision detection and time of impact based physics resolution.
@@ -433,6 +455,7 @@ protected:
        btMotionState*  m_bulletMotionState;
        class btCollisionShape* m_collisionShape;
        class CcdShapeConstructionInfo* m_shapeInfo;
+       btCollisionShape* m_bulletChildShape;
 
        friend class CcdPhysicsEnvironment;     // needed when updating the controller
 
@@ -449,6 +472,10 @@ protected:
 
        CcdPhysicsController* m_parentCtrl;
 
+       int m_savedCollisionFlags;
+       MT_Scalar m_savedMass;
+       bool m_suspended;
+
        void GetWorldOrientation(btMatrix3x3& mat);
 
        void CreateRigidbody();
@@ -462,8 +489,8 @@ protected:
                return (--m_registerCount == 0) ? true : false;
        }
 
-       void setWorldOrientation(const btMatrix3x3& mat);
-       void forceWorldTransform(const btMatrix3x3& mat, const btVector3& pos);
+       void SetWorldOrientation(const btMatrix3x3& mat);
+       void ForceWorldTransform(const btMatrix3x3& mat, const btVector3& pos);
 
        public:
        
@@ -477,11 +504,11 @@ protected:
 
                virtual ~CcdPhysicsController();
 
-               CcdConstructionInfo& getConstructionInfo()
+               CcdConstructionInfo& GetConstructionInfo()
                {
                        return m_cci;
                }
-               const CcdConstructionInfo& getConstructionInfo() const
+               const CcdConstructionInfo& GetConstructionInfo() const
                {
                        return m_cci;
                }
@@ -518,42 +545,51 @@ protected:
                virtual void            SetPhysicsEnvironment(class PHY_IPhysicsEnvironment *env);
 
                // kinematic methods
-               virtual void            RelativeTranslate(float dlocX,float dlocY,float dlocZ,bool local);
-               virtual void            SetWalkDirection(float dirX,float dirY,float dirZ,bool local);
-               virtual void            RelativeRotate(const float drot[9],bool local);
-               virtual void            getOrientation(float &quatImag0,float &quatImag1,float &quatImag2,float &quatReal);
-               virtual void            setOrientation(float quatImag0,float quatImag1,float quatImag2,float quatReal);
-               virtual void            setPosition(float posX,float posY,float posZ);
-               virtual void            getPosition(MT_Vector3& pos) const;
-
-               virtual void            setScaling(float scaleX,float scaleY,float scaleZ);
+               virtual void            RelativeTranslate(const MT_Vector3& dloc,bool local);
+               virtual void            RelativeRotate(const MT_Matrix3x3&rotval, bool local);
+               virtual MT_Matrix3x3    GetOrientation();
+               virtual void            SetOrientation(const MT_Matrix3x3& orn);
+               virtual void            SetPosition(const MT_Vector3& pos);
+               virtual void            GetPosition(MT_Vector3& pos) const;
+               virtual void            SetScaling(const MT_Vector3& scale);
+               virtual void            SetTransform();
+
+               virtual MT_Scalar       GetMass();
+               virtual void    SetMass(MT_Scalar newmass);
                
                // physics methods
-               virtual void            ApplyTorque(float torqueX,float torqueY,float torqueZ,bool local);
-               virtual void            ApplyForce(float forceX,float forceY,float forceZ,bool local);
-               virtual void            SetAngularVelocity(float ang_velX,float ang_velY,float ang_velZ,bool local);
-               virtual void            SetLinearVelocity(float lin_velX,float lin_velY,float lin_velZ,bool local);
-               virtual void            applyImpulse(float attachX,float attachY,float attachZ, float impulseX,float impulseY,float impulseZ);
+               virtual void            ApplyImpulse(const MT_Point3& attach, const MT_Vector3& impulsein);
+               virtual void            ApplyTorque(const MT_Vector3& torque,bool local);
+               virtual void            ApplyForce(const MT_Vector3& force,bool local);
+               virtual void            SetAngularVelocity(const MT_Vector3& ang_vel,bool local);
+               virtual void            SetLinearVelocity(const MT_Vector3& lin_vel,bool local);
                virtual void            Jump();
                virtual void            SetActive(bool active);
 
                // reading out information from physics
-               virtual void            GetLinearVelocity(float& linvX,float& linvY,float& linvZ);
-               virtual void            GetAngularVelocity(float& angVelX,float& angVelY,float& angVelZ);
-               virtual void            GetVelocity(const float posX,const float posY,const float posZ,float& linvX,float& linvY,float& linvZ); 
-               virtual void            getReactionForce(float& forceX,float& forceY,float& forceZ);
-               virtual void            GetWalkDirection(float& dirX,float& dirY,float& dirZ);
+               virtual MT_Vector3      GetLinearVelocity();
+               virtual MT_Vector3      GetAngularVelocity();
+               virtual MT_Vector3      GetVelocity(const MT_Point3& posin);
+               virtual MT_Vector3      GetLocalInertia();
 
                // dyna's that are rigidbody are free in orientation, dyna's with non-rigidbody are restricted 
-               virtual void            setRigidBody(bool rigid);
+               virtual void            SetRigidBody(bool rigid);
 
                
-               virtual void            resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ);
+               virtual void            ResolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ);
+
+               virtual void            SuspendDynamics(bool ghost);
+               virtual void            RestoreDynamics();
+
+               // Shape control
+               virtual void    AddCompoundChild(PHY_IPhysicsController* child);
+               virtual void    RemoveCompoundChild(PHY_IPhysicsController* child);
 
                // clientinfo for raycasts for example
-               virtual void*                           getNewClientInfo();
-               virtual void                            setNewClientInfo(void* clientinfo);
+               virtual void*                           GetNewClientInfo();
+               virtual void                            SetNewClientInfo(void* clientinfo);
                virtual PHY_IPhysicsController* GetReplica();
+               virtual PHY_IPhysicsController* GetReplicaForSensors();
                
                ///There should be no 'SetCollisionFilterGroup' method, as changing this during run-time is will result in errors
                short int       GetCollisionFilterGroup() const
@@ -566,7 +602,7 @@ protected:
                        return m_cci.m_collisionFilterMask;
                }
 
-               virtual void calcXform() {}
+               virtual void CalcXform() {}
                virtual void SetMargin(float margin) 
                {
                        if (m_collisionShape)
@@ -609,7 +645,7 @@ protected:
                        return m_cci.m_clamp_vel_max;
                }
 
-               bool    wantsSleeping();
+               bool    WantsSleeping();
 
                void    UpdateDeactivation(float timeStep);
 
@@ -635,24 +671,29 @@ protected:
                        return m_cci.m_physicsEnv;
                }
 
-               void    setParentCtrl(CcdPhysicsController* parentCtrl)
+               void    SetParentCtrl(CcdPhysicsController* parentCtrl)
                {
                        m_parentCtrl = parentCtrl;
                }
 
-               CcdPhysicsController*   getParentCtrl()
+               CcdPhysicsController*   GetParentCtrl()
                {
                        return m_parentCtrl;
                }
 
-               const CcdPhysicsController*     getParentCtrl() const
+               const CcdPhysicsController*     GetParentCtrl() const
                {
                        return m_parentCtrl;
                }
 
-               virtual const char* getName()
+               virtual bool IsDynamic()
+               {
+                       return GetConstructionInfo().m_bDyna;
+               }
+
+               virtual bool IsCompound()
                {
-                       return 0;
+                       return GetConstructionInfo().m_shapeInfo->m_shapeType == PHY_SHAPE_COMPOUND;
                }
 
 #ifdef WITH_CXX_GUARDEDALLOC
@@ -672,16 +713,16 @@ class     DefaultMotionState : public PHY_IMotionState
 
                virtual ~DefaultMotionState();
 
-               virtual void    getWorldPosition(float& posX,float& posY,float& posZ);
-               virtual void    getWorldScaling(float& scaleX,float& scaleY,float& scaleZ);
-               virtual void    getWorldOrientation(float& quatIma0,float& quatIma1,float& quatIma2,float& quatReal);
+               virtual void    GetWorldPosition(float& posX,float& posY,float& posZ);
+               virtual void    GetWorldScaling(float& scaleX,float& scaleY,float& scaleZ);
+               virtual void    GetWorldOrientation(float& quatIma0,float& quatIma1,float& quatIma2,float& quatReal);
                
-               virtual void    setWorldPosition(float posX,float posY,float posZ);
-               virtual void    setWorldOrientation(float quatIma0,float quatIma1,float quatIma2,float quatReal);
-               virtual void    getWorldOrientation(float* ori);
-               virtual void    setWorldOrientation(const float* ori);
+               virtual void    SetWorldPosition(float posX,float posY,float posZ);
+               virtual void    SetWorldOrientation(float quatIma0,float quatIma1,float quatIma2,float quatReal);
+               virtual void    GetWorldOrientation(float* ori);
+               virtual void    SetWorldOrientation(const float* ori);
                
-               virtual void    calculateWorldTransformations();
+               virtual void    CalculateWorldTransformations();
                
                btTransform     m_worldTransform;
                btVector3               m_localScaling;
index e01530f2b118476d4763a161857faf0343c94d9d..10be1876e41d1c73475ca504592e2d068d4cb66f 100644 (file)
@@ -127,8 +127,8 @@ public:
                        btTransform trans = m_vehicle->getWheelInfo(i).m_worldTransform;
                        btQuaternion orn = trans.getRotation();
                        const btVector3& pos = trans.getOrigin();
-                       motionState->setWorldOrientation(orn.x(),orn.y(),orn.z(),orn[3]);
-                       motionState->setWorldPosition(pos.x(),pos.y(),pos.z());
+                       motionState->SetWorldOrientation(orn.x(),orn.y(),orn.z(),orn[3]);
+                       motionState->SetWorldPosition(pos.x(),pos.y(),pos.z());
 
                }
        }
@@ -265,63 +265,6 @@ public:
 };
 #endif //NEW_BULLET_VEHICLE_SUPPORT
 
-class CharacterWrapper : public PHY_ICharacter
-{
-private:
-       BlenderBulletCharacterController* m_controller;
-
-public:
-       CharacterWrapper(BlenderBulletCharacterController* cont)
-               : m_controller(cont)
-       {}
-
-       virtual void Jump()
-       {
-               m_controller->jump();
-       }
-
-       virtual bool OnGround()
-       {
-               return m_controller->onGround();
-       }
-
-       virtual float GetGravity()
-       {
-               return m_controller->getGravity();
-       }
-       virtual void SetGravity(float gravity)
-       {
-               m_controller->setGravity(gravity);
-       }
-
-       virtual int GetMaxJumps()
-       {
-               return m_controller->getMaxJumps();
-       }
-
-       virtual void SetMaxJumps(int maxJumps)
-       {
-               m_controller->setMaxJumps(maxJumps);
-       }
-
-       virtual int GetJumpCount()
-       {
-               return m_controller->getJumpCount();
-       }
-
-       virtual void SetWalkDirection(const MT_Vector3& dir)
-       {
-               btVector3 vec = btVector3(dir[0], dir[1], dir[2]);
-               m_controller->setWalkDirection(vec);
-       }
-
-       virtual MT_Vector3 GetWalkDirection()
-       {
-               btVector3 vec = m_controller->getWalkDirection();
-               return MT_Vector3(vec[0], vec[1], vec[2]);
-       }
-};
-
 class CcdOverlapFilterCallBack : public btOverlapFilterCallback
 {
 private:
@@ -339,7 +282,7 @@ public:
 };
 
 
-void CcdPhysicsEnvironment::setDebugDrawer(btIDebugDraw* debugDrawer)
+void CcdPhysicsEnvironment::SetDebugDrawer(btIDebugDraw* debugDrawer)
 {
        if (debugDrawer && m_dynamicsWorld)
                m_dynamicsWorld->setDebugDrawer(debugDrawer);
@@ -429,17 +372,17 @@ m_scalingPropagated(false)
        m_broadphase->getOverlappingPairCache()->setOverlapFilterCallback(m_filterCallback);
        m_broadphase->getOverlappingPairCache()->setInternalGhostPairCallback(m_ghostPairCallback);
 
-       setSolverType(1);//issues with quickstep and memory allocations
+       SetSolverType(1);//issues with quickstep and memory allocations
 //     m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,m_broadphase,m_solver,m_collisionConfiguration);
        m_dynamicsWorld = new btSoftRigidDynamicsWorld(dispatcher,m_broadphase,m_solver,m_collisionConfiguration);
        //m_dynamicsWorld->getSolverInfo().m_linearSlop = 0.01f;
        //m_dynamicsWorld->getSolverInfo().m_solverMode=        SOLVER_USE_WARMSTARTING +       SOLVER_USE_2_FRICTION_DIRECTIONS +      SOLVER_RANDMIZE_ORDER + SOLVER_USE_FRICTION_WARMSTARTING;
 
        m_debugDrawer = 0;
-       setGravity(0.f,0.f,-9.81f);
+       SetGravity(0.f,0.f,-9.81f);
 }
 
-void   CcdPhysicsEnvironment::addCcdPhysicsController(CcdPhysicsController* ctrl)
+void   CcdPhysicsEnvironment::AddCcdPhysicsController(CcdPhysicsController* ctrl)
 {
        btRigidBody* body = ctrl->GetRigidBody();
        btCollisionObject* obj = ctrl->GetCollisionObject();
@@ -483,7 +426,7 @@ void        CcdPhysicsEnvironment::addCcdPhysicsController(CcdPhysicsController* ctrl)
 
                
 
-bool   CcdPhysicsEnvironment::removeCcdPhysicsController(CcdPhysicsController* ctrl)
+bool   CcdPhysicsEnvironment::RemoveCcdPhysicsController(CcdPhysicsController* ctrl)
 {
        //also remove constraint
        btRigidBody* body = ctrl->GetRigidBody();
@@ -522,7 +465,7 @@ bool        CcdPhysicsEnvironment::removeCcdPhysicsController(CcdPhysicsController* ctr
        return (m_controllers.erase(ctrl) != 0);
 }
 
-void   CcdPhysicsEnvironment::updateCcdPhysicsController(CcdPhysicsController* ctrl, btScalar newMass, int newCollisionFlags, short int newCollisionGroup, short int newCollisionMask)
+void   CcdPhysicsEnvironment::UpdateCcdPhysicsController(CcdPhysicsController* ctrl, btScalar newMass, int newCollisionFlags, short int newCollisionGroup, short int newCollisionMask)
 {
        // this function is used when the collisionning group of a controller is changed
        // remove and add the collistioning object
@@ -551,7 +494,7 @@ void        CcdPhysicsEnvironment::updateCcdPhysicsController(CcdPhysicsController* ctr
        ctrl->m_cci.m_collisionFlags = newCollisionFlags;
 }
 
-void CcdPhysicsEnvironment::enableCcdPhysicsController(CcdPhysicsController* ctrl)
+void CcdPhysicsEnvironment::EnableCcdPhysicsController(CcdPhysicsController* ctrl)
 {
        if (m_controllers.insert(ctrl).second)
        {
@@ -568,7 +511,7 @@ void CcdPhysicsEnvironment::enableCcdPhysicsController(CcdPhysicsController* ctr
        }
 }
 
-void CcdPhysicsEnvironment::disableCcdPhysicsController(CcdPhysicsController* ctrl)
+void CcdPhysicsEnvironment::DisableCcdPhysicsController(CcdPhysicsController* ctrl)
 {
        if (m_controllers.erase(ctrl))
        {
@@ -588,7 +531,7 @@ void CcdPhysicsEnvironment::disableCcdPhysicsController(CcdPhysicsController* ct
        }
 }
 
-void CcdPhysicsEnvironment::refreshCcdPhysicsController(CcdPhysicsController* ctrl)
+void CcdPhysicsEnvironment::RefreshCcdPhysicsController(CcdPhysicsController* ctrl)
 {
        btCollisionObject* obj = ctrl->GetCollisionObject();
        if (obj)
@@ -601,15 +544,15 @@ void CcdPhysicsEnvironment::refreshCcdPhysicsController(CcdPhysicsController* ct
        }
 }
 
-void CcdPhysicsEnvironment::addCcdGraphicController(CcdGraphicController* ctrl)
+void CcdPhysicsEnvironment::AddCcdGraphicController(CcdGraphicController* ctrl)
 {
-       if (m_cullingTree && !ctrl->getBroadphaseHandle())
+       if (m_cullingTree && !ctrl->GetBroadphaseHandle())
        {
                btVector3       minAabb;
                btVector3       maxAabb;
-               ctrl->getAabb(minAabb, maxAabb);
+               ctrl->GetAabb(minAabb, maxAabb);
 
-               ctrl->setBroadphaseHandle(m_cullingTree->createProxy(
+               ctrl->SetBroadphaseHandle(m_cullingTree->createProxy(
                                minAabb,
                                maxAabb,
                                INVALID_SHAPE_PROXYTYPE,        // this parameter is not used
@@ -619,35 +562,35 @@ void CcdPhysicsEnvironment::addCcdGraphicController(CcdGraphicController* ctrl)
                                NULL,                                           // dispatcher => this parameter is not used
                                0));
 
-               assert(ctrl->getBroadphaseHandle());
+               assert(ctrl->GetBroadphaseHandle());
        }
 }
 
-void CcdPhysicsEnvironment::removeCcdGraphicController(CcdGraphicController* ctrl)
+void CcdPhysicsEnvironment::RemoveCcdGraphicController(CcdGraphicController* ctrl)
 {
        if (m_cullingTree)
        {
-               btBroadphaseProxy* bp = ctrl->getBroadphaseHandle();
+               btBroadphaseProxy* bp = ctrl->GetBroadphaseHandle();
                if (bp)
                {
                        m_cullingTree->destroyProxy(bp,NULL);
-                       ctrl->setBroadphaseHandle(0);
+                       ctrl->SetBroadphaseHandle(0);
                }
        }
 }
 
-void   CcdPhysicsEnvironment::beginFrame()
+void   CcdPhysicsEnvironment::BeginFrame()
 {
 
 }
 
-void CcdPhysicsEnvironment::debugDrawWorld()
+void CcdPhysicsEnvironment::DebugDrawWorld()
 {
        if (m_dynamicsWorld->getDebugDrawer() &&  m_dynamicsWorld->getDebugDrawer()->getDebugMode() >0)
                        m_dynamicsWorld->debugDrawWorld();
 }
 
-bool   CcdPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep,float interval)
+bool   CcdPhysicsEnvironment::ProceedDeltaTime(double curTime,float timeStep,float interval)
 {
        std::set<CcdPhysicsController*>::iterator it;
        int i;
@@ -662,7 +605,7 @@ bool        CcdPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep,float
 //uncomment next line to see where Bullet spend its time (printf in console)
 //CProfileManager::dumpAll();
 
-       processFhSprings(curTime,i*subStep);
+       ProcessFhSprings(curTime,i*subStep);
 
        for (it=m_controllers.begin(); it!=m_controllers.end(); it++)
        {
@@ -714,7 +657,7 @@ public:
 
 };
 
-void   CcdPhysicsEnvironment::processFhSprings(double curTime,float interval)
+void   CcdPhysicsEnvironment::ProcessFhSprings(double curTime,float interval)
 {
        std::set<CcdPhysicsController*>::iterator it;
        // dynamic of Fh spring is based on a timestep of 1/60
@@ -725,12 +668,12 @@ void      CcdPhysicsEnvironment::processFhSprings(double curTime,float interval)
                CcdPhysicsController* ctrl = (*it);
                btRigidBody* body = ctrl->GetRigidBody();
 
-               if (body && (ctrl->getConstructionInfo().m_do_fh || ctrl->getConstructionInfo().m_do_rot_fh))
+               if (body && (ctrl->GetConstructionInfo().m_do_fh || ctrl->GetConstructionInfo().m_do_rot_fh))
                {
                        //printf("has Fh or RotFh\n");
                        //re-implement SM_FhObject.cpp using btCollisionWorld::rayTest and info from ctrl->getConstructionInfo()
                        //send a ray from {0.0, 0.0, 0.0} towards {0.0, 0.0, -10.0}, in local coordinates
-                       CcdPhysicsController* parentCtrl = ctrl->getParentCtrl();
+                       CcdPhysicsController* parentCtrl = ctrl->GetParentCtrl();
                        btRigidBody* parentBody = parentCtrl?parentCtrl->GetRigidBody() : 0;
                        btRigidBody* cl_object = parentBody ? parentBody : body;
 
@@ -756,16 +699,16 @@ void      CcdPhysicsEnvironment::processFhSprings(double curTime,float interval)
 
                                if (controller)
                                {
-                                       if (controller->getConstructionInfo().m_fh_distance < SIMD_EPSILON)
+                                       if (controller->GetConstructionInfo().m_fh_distance < SIMD_EPSILON)
                                                continue;
 
                                        btRigidBody* hit_object = controller->GetRigidBody();
                                        if (!hit_object)
                                                continue;
 
-                                       CcdConstructionInfo& hitObjShapeProps = controller->getConstructionInfo();
+                                       CcdConstructionInfo& hitObjShapeProps = controller->GetConstructionInfo();
 
-                                       float distance = resultCallback.m_closestHitFraction*rayDirLocal.length()-ctrl->getConstructionInfo().m_radius;
+                                       float distance = resultCallback.m_closestHitFraction*rayDirLocal.length()-ctrl->GetConstructionInfo().m_radius;
                                        if (distance >= hitObjShapeProps.m_fh_distance)
                                                continue;
                                        
@@ -778,7 +721,7 @@ void        CcdPhysicsEnvironment::processFhSprings(double curTime,float interval)
 
                                        for (int i=0; i<numIter; i++)
                                        {
-                                               if (ctrl->getConstructionInfo().m_do_fh) 
+                                               if (ctrl->GetConstructionInfo().m_do_fh)
                                                {
                                                        btVector3 lspot = cl_object->getCenterOfMassPosition() +
                                                                rayDirLocal * resultCallback.m_closestHitFraction;
@@ -790,7 +733,7 @@ void        CcdPhysicsEnvironment::processFhSprings(double curTime,float interval)
                                                        btVector3 rel_vel = cl_object->getLinearVelocity() - hit_object->getVelocityInLocalPoint(lspot);
                                                        btScalar rel_vel_ray = ray_dir.dot(rel_vel);
                                                        btScalar spring_extent = 1.0 - distance / hitObjShapeProps.m_fh_distance; 
-                                                       
+
                                                        btScalar i_spring = spring_extent * hitObjShapeProps.m_fh_spring;
                                                        btScalar i_damp =   rel_vel_ray * hitObjShapeProps.m_fh_damping;
                                                        
@@ -803,7 +746,7 @@ void        CcdPhysicsEnvironment::processFhSprings(double curTime,float interval)
                                                        btVector3 lateral = rel_vel - rel_vel_ray * ray_dir;
                                                        
                                                        
-                                                       if (ctrl->getConstructionInfo().m_do_anisotropic) {
+                                                       if (ctrl->GetConstructionInfo().m_do_anisotropic) {
                                                                //Bullet basis contains no scaling/shear etc.
                                                                const btMatrix3x3& lcs = cl_object->getCenterOfMassTransform().getBasis();
                                                                btVector3 loc_lateral = lateral * lcs;
@@ -830,7 +773,7 @@ void        CcdPhysicsEnvironment::processFhSprings(double curTime,float interval)
                                                }
 
                                                
-                                               if (ctrl->getConstructionInfo().m_do_rot_fh) {
+                                               if (ctrl->GetConstructionInfo().m_do_rot_fh) {
                                                        btVector3 up2 = cl_object->getWorldTransform().getBasis().getColumn(2);
 
                                                        btVector3 t_spring = up2.cross(normal) * hitObjShapeProps.m_fh_spring;
@@ -850,69 +793,69 @@ void      CcdPhysicsEnvironment::processFhSprings(double curTime,float interval)
        }
 }
 
-void           CcdPhysicsEnvironment::setDebugMode(int debugMode)
+void           CcdPhysicsEnvironment::SetDebugMode(int debugMode)
 {
        if (m_debugDrawer) {
                m_debugDrawer->setDebugMode(debugMode);
        }
 }
 
-void           CcdPhysicsEnvironment::setNumIterations(int numIter)
+void           CcdPhysicsEnvironment::SetNumIterations(int numIter)
 {
        m_numIterations = numIter;
 }
-void           CcdPhysicsEnvironment::setDeactivationTime(float dTime)
+void           CcdPhysicsEnvironment::SetDeactivationTime(float dTime)
 {
        gDeactivationTime = dTime;
 }
-void           CcdPhysicsEnvironment::setDeactivationLinearTreshold(float linTresh)
+void           CcdPhysicsEnvironment::SetDeactivationLinearTreshold(float linTresh)
 {
        gLinearSleepingTreshold = linTresh;
 }
-void           CcdPhysicsEnvironment::setDeactivationAngularTreshold(float angTresh) 
+void           CcdPhysicsEnvironment::SetDeactivationAngularTreshold(float angTresh)
 {
        gAngularSleepingTreshold = angTresh;
 }
 
-void           CcdPhysicsEnvironment::setContactBreakingTreshold(float contactBreakingTreshold)
+void           CcdPhysicsEnvironment::SetContactBreakingTreshold(float contactBreakingTreshold)
 {
        gContactBreakingThreshold = contactBreakingTreshold;
 
 }
 
 
-void           CcdPhysicsEnvironment::setCcdMode(int ccdMode)
+void           CcdPhysicsEnvironment::SetCcdMode(int ccdMode)
 {
        m_ccdMode = ccdMode;
 }
 
 
-void           CcdPhysicsEnvironment::setSolverSorConstant(float sor)
+void           CcdPhysicsEnvironment::SetSolverSorConstant(float sor)
 {
        m_dynamicsWorld->getSolverInfo().m_sor = sor;
 }
 
-void           CcdPhysicsEnvironment::setSolverTau(float tau)
+void           CcdPhysicsEnvironment::SetSolverTau(float tau)
 {
        m_dynamicsWorld->getSolverInfo().m_tau = tau;
 }
-void           CcdPhysicsEnvironment::setSolverDamping(float damping)
+void           CcdPhysicsEnvironment::SetSolverDamping(float damping)
 {
        m_dynamicsWorld->getSolverInfo().m_damping = damping;
 }
 
 
-void           CcdPhysicsEnvironment::setLinearAirDamping(float damping)
+void           CcdPhysicsEnvironment::SetLinearAirDamping(float damping)
 {
        //gLinearAirDamping = damping;
 }
 
-void           CcdPhysicsEnvironment::setUseEpa(bool epa)
+void           CcdPhysicsEnvironment::SetUseEpa(bool epa)
 {
        //gUseEpa = epa;
 }
 
-void           CcdPhysicsEnvironment::setSolverType(int solverType)
+void           CcdPhysicsEnvironment::SetSolverType(int solverType)
 {
 
        switch (solverType)
@@ -945,7 +888,7 @@ void                CcdPhysicsEnvironment::setSolverType(int solverType)
 
 
 
-void           CcdPhysicsEnvironment::getGravity(MT_Vector3& grav)
+void           CcdPhysicsEnvironment::GetGravity(MT_Vector3& grav)
 {
                const btVector3& gravity = m_dynamicsWorld->getGravity();
                grav[0] = gravity.getX();
@@ -954,7 +897,7 @@ void                CcdPhysicsEnvironment::getGravity(MT_Vector3& grav)
 }
 
 
-void           CcdPhysicsEnvironment::setGravity(float x,float y,float z)
+void           CcdPhysicsEnvironment::SetGravity(float x,float y,float z)
 {
        m_gravity = btVector3(x,y,z);
        m_dynamicsWorld->setGravity(m_gravity);
@@ -967,7 +910,7 @@ void                CcdPhysicsEnvironment::setGravity(float x,float y,float z)
 static int gConstraintUid = 1;
 
 //Following the COLLADA physics specification for constraints
-int                    CcdPhysicsEnvironment::createUniversalD6Constraint(
+int                    CcdPhysicsEnvironment::CreateUniversalD6Constraint(
                                                class PHY_IPhysicsController* ctrlRef,class PHY_IPhysicsController* ctrlOther,
                                                btTransform& frameInA,
                                                btTransform& frameInB,
@@ -1025,7 +968,7 @@ int                        CcdPhysicsEnvironment::createUniversalD6Constraint(
 
 
 
-void           CcdPhysicsEnvironment::removeConstraint(int     constraintId)
+void           CcdPhysicsEnvironment::RemoveConstraint(int     constraintId)
 {
        
        int i;
@@ -1144,7 +1087,7 @@ static bool GetHitTriangle(btCollisionShape* shape, CcdShapeConstructionInfo* sh
        return true;
 }
 
-PHY_IPhysicsController* CcdPhysicsEnvironment::rayTest(PHY_IRayCastFilterCallback &filterCallback, float fromX,float fromY,float fromZ, float toX,float toY,float toZ)
+PHY_IPhysicsController* CcdPhysicsEnvironment::RayTest(PHY_IRayCastFilterCallback &filterCallback, float fromX,float fromY,float fromZ, float toX,float toY,float toZ)
 {
        btVector3 rayFrom(fromX,fromY,fromZ);
        btVector3 rayTo(toX,toY,toZ);
@@ -1798,7 +1741,7 @@ struct    DbvtCullingCallback : btDbvt::ICollide
                btBroadphaseProxy*      proxy=(btBroadphaseProxy*)leaf->data;
                // the client object is a graphic controller
                CcdGraphicController* ctrl = static_cast<CcdGraphicController*>(proxy->m_clientObject);
-               KX_ClientObjectInfo *info = (KX_ClientObjectInfo*)ctrl->getNewClientInfo();
+               KX_ClientObjectInfo *info = (KX_ClientObjectInfo*)ctrl->GetNewClientInfo();
                if (m_ocb)
                {
                        // means we are doing occlusion culling. Check if this object is an occluders
@@ -1846,7 +1789,7 @@ struct    DbvtCullingCallback : btDbvt::ICollide
 };
 
 static OcclusionBuffer gOcb;
-bool CcdPhysicsEnvironment::cullingTest(PHY_CullingCallback callback, void* userData, MT_Vector4 *planes, int nplanes, int occlusionRes, const int *viewport, double modelview[16], double projection[16])
+bool CcdPhysicsEnvironment::CullingTest(PHY_CullingCallback callback, void* userData, MT_Vector4 *planes, int nplanes, int occlusionRes, const int *viewport, double modelview[16], double projection[16])
 {
        if (!m_cullingTree)
                return false;
@@ -1876,12 +1819,12 @@ bool CcdPhysicsEnvironment::cullingTest(PHY_CullingCallback callback, void* user
        return true;
 }
 
-int    CcdPhysicsEnvironment::getNumContactPoints()
+int    CcdPhysicsEnvironment::GetNumContactPoints()
 {
        return 0;
 }
 
-void CcdPhysicsEnvironment::getContactPoint(int i,float& hitX,float& hitY,float& hitZ,float& normalX,float& normalY,float& normalZ)
+void CcdPhysicsEnvironment::GetContactPoint(int i,float& hitX,float& hitY,float& hitZ,float& normalX,float& normalY,float& normalZ)
 {
 
 }
@@ -1889,12 +1832,12 @@ void CcdPhysicsEnvironment::getContactPoint(int i,float& hitX,float& hitY,float&
 
 
 
-btBroadphaseInterface* CcdPhysicsEnvironment::getBroadphase()
+btBroadphaseInterface* CcdPhysicsEnvironment::GetBroadphase()
 { 
        return m_dynamicsWorld->getBroadphase(); 
 }
 
-btDispatcher*  CcdPhysicsEnvironment::getDispatcher()
+btDispatcher*  CcdPhysicsEnvironment::GetDispatcher()
 { 
        return m_dynamicsWorld->getDispatcher();
 }
@@ -1908,8 +1851,8 @@ void CcdPhysicsEnvironment::MergeEnvironment(CcdPhysicsEnvironment *other)
                it= other->m_controllers.begin();
                CcdPhysicsController* ctrl= (*it);
 
-               other->removeCcdPhysicsController(ctrl);
-               this->addCcdPhysicsController(ctrl);
+               other->RemoveCcdPhysicsController(ctrl);
+               this->AddCcdPhysicsController(ctrl);
        }
 }
 
@@ -1961,9 +1904,9 @@ CcdPhysicsEnvironment::~CcdPhysicsEnvironment()
 }
 
 
-float  CcdPhysicsEnvironment::getConstraintParam(int constraintId,int param)
+float  CcdPhysicsEnvironment::GetConstraintParam(int constraintId,int param)
 {
-       btTypedConstraint* typedConstraint = getConstraintById(constraintId);
+       btTypedConstraint* typedConstraint = GetConstraintById(constraintId);
        switch (typedConstraint->getUserConstraintType())
        {
        case PHY_GENERIC_6DOF_CONSTRAINT:
@@ -2000,9 +1943,9 @@ float     CcdPhysicsEnvironment::getConstraintParam(int constraintId,int param)
        return 0.f;
 }
 
-void   CcdPhysicsEnvironment::setConstraintParam(int constraintId,int param,float value0,float value1)
+void   CcdPhysicsEnvironment::SetConstraintParam(int constraintId,int param,float value0,float value1)
 {
-       btTypedConstraint* typedConstraint = getConstraintById(constraintId);
+       btTypedConstraint* typedConstraint = GetConstraintById(constraintId);
        switch (typedConstraint->getUserConstraintType())
        {
        case PHY_GENERIC_6DOF_CONSTRAINT:
@@ -2110,7 +2053,7 @@ void      CcdPhysicsEnvironment::setConstraintParam(int constraintId,int param,float
        };
 }
 
-btTypedConstraint*     CcdPhysicsEnvironment::getConstraintById(int constraintId)
+btTypedConstraint*     CcdPhysicsEnvironment::GetConstraintById(int constraintId)
 {
 
        int numConstraints = m_dynamicsWorld->getNumConstraints();
@@ -2127,7 +2070,7 @@ btTypedConstraint*        CcdPhysicsEnvironment::getConstraintById(int constraintId)
 }
 
 
-void CcdPhysicsEnvironment::addSensor(PHY_IPhysicsController* ctrl)
+void CcdPhysicsEnvironment::AddSensor(PHY_IPhysicsController* ctrl)
 {
 
        CcdPhysicsController* ctrl1 = (CcdPhysicsController* )ctrl;
@@ -2137,10 +2080,10 @@ void CcdPhysicsEnvironment::addSensor(PHY_IPhysicsController* ctrl)
        //{
        //      addCcdPhysicsController(ctrl1);
        //}
-       enableCcdPhysicsController(ctrl1);
+       EnableCcdPhysicsController(ctrl1);
 }
 
-bool CcdPhysicsEnvironment::removeCollisionCallback(PHY_IPhysicsController* ctrl)
+bool CcdPhysicsEnvironment::RemoveCollisionCallback(PHY_IPhysicsController* ctrl)
 {
        CcdPhysicsController* ccdCtrl = (CcdPhysicsController*)ctrl;
        if (!ccdCtrl->Unregister())
@@ -2150,12 +2093,12 @@ bool CcdPhysicsEnvironment::removeCollisionCallback(PHY_IPhysicsController* ctrl
 }
 
 
-void CcdPhysicsEnvironment::removeSensor(PHY_IPhysicsController* ctrl)
+void CcdPhysicsEnvironment::RemoveSensor(PHY_IPhysicsController* ctrl)
 {
-       disableCcdPhysicsController((CcdPhysicsController*)ctrl);
+       DisableCcdPhysicsController((CcdPhysicsController*)ctrl);
 }
 
-void CcdPhysicsEnvironment::addTouchCallback(int response_class, PHY_ResponseCallback callback, void *user)
+void CcdPhysicsEnvironment::AddTouchCallback(int response_class, PHY_ResponseCallback callback, void *user)
 {
        /*      printf("addTouchCallback\n(response class = %i)\n",response_class);
 
@@ -2187,7 +2130,7 @@ void CcdPhysicsEnvironment::addTouchCallback(int response_class, PHY_ResponseCal
        m_triggerCallbacksUserPtrs[response_class] = user;
 
 }
-bool CcdPhysicsEnvironment::requestCollisionCallback(PHY_IPhysicsController* ctrl)
+bool CcdPhysicsEnvironment::RequestCollisionCallback(PHY_IPhysicsController* ctrl)
 {
        CcdPhysicsController* ccdCtrl = static_cast<CcdPhysicsController*>(ctrl);
 
@@ -2270,12 +2213,12 @@ bool CcdOverlapFilterCallBack::needBroadphaseCollision(btBroadphaseProxy* proxy0
                        (KX_ClientObjectInfo*)
                        ((CcdPhysicsController*)
                                        (((btCollisionObject*)proxy0->m_clientObject)->getUserPointer()))
-                       ->getNewClientInfo());
+                       ->GetNewClientInfo());
        KX_GameObject *kxObj1 = KX_GameObject::GetClientObject(
                        (KX_ClientObjectInfo*)
                        ((CcdPhysicsController*)
                                        (((btCollisionObject*)proxy1->m_clientObject)->getUserPointer()))
-                       ->getNewClientInfo());
+                       ->GetNewClientInfo());
 
        // First check the filters. Note that this is called during scene
        // conversion, so we can't assume the KX_GameObject instances exist. This
@@ -2324,7 +2267,7 @@ bool CcdOverlapFilterCallBack::needBroadphaseCollision(btBroadphaseProxy* proxy0
 #ifdef NEW_BULLET_VEHICLE_SUPPORT
 
 //complex constraint for vehicles
-PHY_IVehicle*  CcdPhysicsEnvironment::getVehicleConstraint(int constraintId)
+PHY_IVehicle*  CcdPhysicsEnvironment::GetVehicleConstraint(int constraintId)
 {
        int i;
 
@@ -2342,13 +2285,10 @@ PHY_IVehicle*   CcdPhysicsEnvironment::getVehicleConstraint(int constraintId)
 #endif //NEW_BULLET_VEHICLE_SUPPORT
 
 
-PHY_ICharacter* CcdPhysicsEnvironment::getCharacterController(KX_GameObject *ob)
+PHY_ICharacter* CcdPhysicsEnvironment::GetCharacterController(KX_GameObject *ob)
 {
-       CcdPhysicsController* controller = (CcdPhysicsController*)ob->GetPhysicsController()->GetUserData();
-       if (controller->GetCharacterController())
-               return new CharacterWrapper((BlenderBulletCharacterController*)controller->GetCharacterController());
-
-       return NULL;
+       CcdPhysicsController* controller = (CcdPhysicsController*)ob->GetPhysicsController();
+       return dynamic_cast<BlenderBulletCharacterController*>(controller->GetCharacterController());
 }
 
 
@@ -2398,7 +2338,7 @@ int findClosestNode(btSoftBody* sb,const btVector3& worldPoint)
        return node;
 }
 
-int                    CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl0,class PHY_IPhysicsController* ctrl1,PHY_ConstraintType type,
+int                    CcdPhysicsEnvironment::CreateConstraint(class PHY_IPhysicsController* ctrl0,class PHY_IPhysicsController* ctrl1,PHY_ConstraintType type,
                                                                                                        float pivotX,float pivotY,float pivotZ,
                                                                                                        float axisX,float axisY,float axisZ,
                                                                                                        float axis1X,float axis1Y,float axis1Z,
@@ -2891,7 +2831,7 @@ float             CcdPhysicsEnvironment::getAppliedImpulse(int    constraintid)
        return 0.f;
 }
 
-void   CcdPhysicsEnvironment::exportFile(const char* filename)
+void   CcdPhysicsEnvironment::ExportFile(const char* filename)
 {
        btDefaultSerializer*    serializer = new btDefaultSerializer();
        
@@ -2904,7 +2844,7 @@ void      CcdPhysicsEnvironment::exportFile(const char* filename)
                CcdPhysicsController* controller = static_cast<CcdPhysicsController*>(colObj->getUserPointer());
                if (controller)
                {
-                       const char* name = controller->getName();
+                       const char* name = KX_GameObject::GetClientObject((KX_ClientObjectInfo*)controller->GetNewClientInfo())->GetName();
                        if (name)
                        {
                                serializer->registerNameForPointer(colObj,name);
index 8cf88526969a39879833c8b3ff93cd624a1cb7b5..0e8ac9417f0b8ac75489801626c54b879ad50bcc 100644 (file)
@@ -24,6 +24,7 @@ subject to the following restrictions:
 #include "PHY_IPhysicsEnvironment.h"
 #include <vector>
 #include <set>
+#include <map>
 class CcdPhysicsController;
 class CcdGraphicController;
 #include "LinearMath/btVector3.h"
@@ -83,7 +84,7 @@ protected:
        int     m_profileTimings;
        bool m_enableSatCollisionDetection;
 
-       void    processFhSprings(double curTime,float timeStep);
+       void    ProcessFhSprings(double curTime,float timeStep);
 
        public:
                CcdPhysicsEnvironment(bool useDbvtCulling, btDispatcher* dispatcher=0, btOverlappingPairCache* pairCache=0);
@@ -96,54 +97,54 @@ protected:
 
                /// Perform an integration step of duration 'timeStep'.
 
-               virtual void setDebugDrawer(btIDebugDraw* debugDrawer);
+               virtual void SetDebugDrawer(btIDebugDraw* debugDrawer);
 
-               virtual void            setNumIterations(int numIter);
-               virtual void            setNumTimeSubSteps(int numTimeSubSteps)
+               virtual void            SetNumIterations(int numIter);
+               virtual void            SetNumTimeSubSteps(int numTimeSubSteps)
                {
                        m_numTimeSubSteps = numTimeSubSteps;
                }
-               virtual void            setDeactivationTime(float dTime);
-               virtual void            setDeactivationLinearTreshold(float linTresh);
-               virtual void            setDeactivationAngularTreshold(float angTresh);
-               virtual void            setContactBreakingTreshold(float contactBreakingTreshold);
-               virtual void            setCcdMode(int ccdMode);
-               virtual void            setSolverType(int solverType);
-               virtual void            setSolverSorConstant(float sor);
-               virtual void            setSolverTau(float tau);
-               virtual void            setSolverDamping(float damping);
-               virtual void            setLinearAirDamping(float damping);
-               virtual void            setUseEpa(bool epa);
-
-               int                                     getNumTimeSubSteps()
+               virtual void            SetDeactivationTime(float dTime);
+               virtual void            SetDeactivationLinearTreshold(float linTresh);
+               virtual void            SetDeactivationAngularTreshold(float angTresh);
+               virtual void            SetContactBreakingTreshold(float contactBreakingTreshold);
+               virtual void            SetCcdMode(int ccdMode);
+               virtual void            SetSolverType(int solverType);
+               virtual void            SetSolverSorConstant(float sor);
+               virtual void            SetSolverTau(float tau);
+               virtual void            SetSolverDamping(float damping);
+               virtual void            SetLinearAirDamping(float damping);
+               virtual void            SetUseEpa(bool epa);
+
+               virtual int                     GetNumTimeSubSteps()
                {
                        return m_numTimeSubSteps;
                }
 
-               virtual void            beginFrame();
-               virtual void            endFrame() {}
+               virtual void            BeginFrame();
+               virtual void            EndFrame() {}
                /// Perform an integration step of duration 'timeStep'.
-               virtual bool            proceedDeltaTime(double curTime,float timeStep,float interval);
-               
-               virtual void            debugDrawWorld();
+               virtual bool            ProceedDeltaTime(double curTime,float timeStep,float interval);
+
+               virtual void            DebugDrawWorld();
 //             virtual bool            proceedDeltaTimeOneStep(float timeStep);
 
-               virtual void            setFixedTimeStep(bool useFixedTimeStep,float fixedTimeStep)
+               virtual void            SetFixedTimeStep(bool useFixedTimeStep,float fixedTimeStep)
                {
                        //based on DEFAULT_PHYSICS_TIC_RATE of 60 hertz
-                       setNumTimeSubSteps((int)(fixedTimeStep / 60.f));
+                       SetNumTimeSubSteps((int)(fixedTimeStep / 60.f));
                }
                //returns 0.f if no fixed timestep is used
 
-               virtual float           getFixedTimeStep() { return 0.f; }
+               virtual float           GetFixedTimeStep() { return 0.f; }
 
-               virtual void            setDebugMode(int debugMode);
+               virtual void            SetDebugMode(int debugMode);
 
-               virtual void            setGravity(float x,float y,float z);
-               virtual void            getGravity(MT_Vector3& grav);
+               virtual void            SetGravity(float x,float y,float z);
+               virtual void            GetGravity(MT_Vector3& grav);
 
 
-               virtual int                     createConstraint(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsController* ctrl2,PHY_ConstraintType type,
+               virtual int                     CreateConstraint(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsController* ctrl2,PHY_ConstraintType type,
                        float pivotX,float pivotY,float pivotZ,
                        float axisX,float axisY,float axisZ,
                        float axis1X=0,float axis1Y=0,float axis1Z=0,
@@ -152,7 +153,7 @@ protected:
 
 
                //Following the COLLADA physics specification for constraints
-               virtual int                     createUniversalD6Constraint(
+               virtual int                     CreateUniversalD6Constraint(
                class PHY_IPhysicsController* ctrlRef,class PHY_IPhysicsController* ctrlOther,
                        btTransform& localAttachmentFrameRef,
                        btTransform& localAttachmentOther,
@@ -163,11 +164,11 @@ protected:
                        );
 
                
-               virtual void    setConstraintParam(int constraintId,int param,float value,float value1);
+               virtual void    SetConstraintParam(int constraintId,int param,float value,float value1);
                
-               virtual float   getConstraintParam(int constraintId,int param);
+               virtual float   GetConstraintParam(int constraintId,int param);
 
-               virtual void            removeConstraint(int    constraintid);
+               virtual void            RemoveConstraint(int    constraintid);
 
                virtual float           getAppliedImpulse(int   constraintid);
 
@@ -177,61 +178,61 @@ protected:
 
 #ifdef NEW_BULLET_VEHICLE_SUPPORT
                //complex constraint for vehicles
-               virtual PHY_IVehicle*   getVehicleConstraint(int constraintId);
+               virtual PHY_IVehicle*   GetVehicleConstraint(int constraintId);
 #else
-               virtual class PHY_IVehicle*     getVehicleConstraint(int constraintId)
+               virtual class PHY_IVehicle*     GetVehicleConstraint(int constraintId)
                {
                        return 0;
                }
 #endif  /* NEW_BULLET_VEHICLE_SUPPORT */
                // Character physics wrapper
-               virtual PHY_ICharacter* getCharacterController(class KX_GameObject* ob);
+               virtual PHY_ICharacter* GetCharacterController(class KX_GameObject* ob);
 
-               btTypedConstraint*      getConstraintById(int constraintId);
+               btTypedConstraint*      GetConstraintById(int constraintId);
 
-               virtual PHY_IPhysicsController* rayTest(PHY_IRayCastFilterCallback &filterCallback, float fromX,float fromY,float fromZ, float toX,float toY,float toZ);
-               virtual bool cullingTest(PHY_CullingCallback callback, void* userData, MT_Vector4* planes, int nplanes, int occlusionRes, const int *viewport, double modelview[16], double projection[16]);
+               virtual PHY_IPhysicsController* RayTest(PHY_IRayCastFilterCallback &filterCallback, float fromX,float fromY,float fromZ, float toX,float toY,float toZ);
+               virtual bool CullingTest(PHY_CullingCallback callback, void* userData, MT_Vector4* planes, int nplanes, int occlusionRes, const int *viewport, double modelview[16], double projection[16]);
 
 
                //Methods for gamelogic collision/physics callbacks
-               virtual void addSensor(PHY_IPhysicsController* ctrl);
-               virtual void removeSensor(PHY_IPhysicsController* ctrl);
-               virtual void addTouchCallback(int response_class, PHY_ResponseCallback callback, void *user);
-               virtual bool requestCollisionCallback(PHY_IPhysicsController* ctrl);
-               virtual bool removeCollisionCallback(PHY_IPhysicsController* ctrl);
+               virtual void AddSensor(PHY_IPhysicsController* ctrl);
+               virtual void RemoveSensor(PHY_IPhysicsController* ctrl);
+               virtual void AddTouchCallback(int response_class, PHY_ResponseCallback callback, void *user);
+               virtual bool RequestCollisionCallback(PHY_IPhysicsController* ctrl);
+               virtual bool RemoveCollisionCallback(PHY_IPhysicsController* ctrl);
                //These two methods are used *solely* to create controllers for Near/Radar sensor! Don't use for anything else
                virtual PHY_IPhysicsController* CreateSphereController(float radius,const MT_Vector3& position);
                virtual PHY_IPhysicsController* CreateConeController(float coneradius,float coneheight);
        
 
-               virtual int     getNumContactPoints();
+               virtual int     GetNumContactPoints();
 
-               virtual void getContactPoint(int i,float& hitX,float& hitY,float& hitZ,float& normalX,float& normalY,float& normalZ);
+               virtual void GetContactPoint(int i,float& hitX,float& hitY,float& hitZ,float& normalX,float& normalY,float& normalZ);
 
                //////////////////////
                //CcdPhysicsEnvironment interface
                ////////////////////////
        
-               void    addCcdPhysicsController(CcdPhysicsController* ctrl);
+               void    AddCcdPhysicsController(CcdPhysicsController* ctrl);
 
-               bool    removeCcdPhysicsController(CcdPhysicsController* ctrl);
+               bool    RemoveCcdPhysicsController(CcdPhysicsController* ctrl);
 
-               void    updateCcdPhysicsController(CcdPhysicsController* ctrl, btScalar newMass, int newCollisionFlags, short int newCollisionGroup, short int newCollisionMask);
+               void    UpdateCcdPhysicsController(CcdPhysicsController* ctrl, btScalar newMass, int newCollisionFlags, short int newCollisionGroup, short int newCollisionMask);
 
-               void    disableCcdPhysicsController(CcdPhysicsController* ctrl);
+               void    DisableCcdPhysicsController(CcdPhysicsController* ctrl);
 
-               void    enableCcdPhysicsController(CcdPhysicsController* ctrl);
+               void    EnableCcdPhysicsController(CcdPhysicsController* ctrl);
 
-               void    refreshCcdPhysicsController(CcdPhysicsController* ctrl);
+               void    RefreshCcdPhysicsController(CcdPhysicsController* ctrl);
 
-               void    addCcdGraphicController(CcdGraphicController* ctrl);
+               void    AddCcdGraphicController(CcdGraphicController* ctrl);
 
-               void    removeCcdGraphicController(CcdGraphicController* ctrl);
+               void    RemoveCcdGraphicController(CcdGraphicController* ctrl);
 
-               btBroadphaseInterface*  getBroadphase();
-               btDbvtBroadphase*       getCullingTree() { return m_cullingTree; }
+               btBroadphaseInterface*  GetBroadphase();
+               btDbvtBroadphase*       GetCullingTree() { return m_cullingTree; }
 
-               btDispatcher*   getDispatcher();
+               btDispatcher*   GetDispatcher();
                
 
                bool    IsSatCollisionDetectionEnabled() const
@@ -250,7 +251,7 @@ protected:
        
                void    SyncMotionStates(float timeStep);
 
-               class   btSoftRigidDynamicsWorld*       getDynamicsWorld()
+               class   btSoftRigidDynamicsWorld*       GetDynamicsWorld()
                {
                        return m_dynamicsWorld;
                }
@@ -291,7 +292,7 @@ protected:
 
                bool    m_scalingPropagated;
 
-               virtual void    exportFile(const char* filename);
+               virtual void    ExportFile(const char* filename);
 
                
 #ifdef WITH_CXX_GUARDEDALLOC
index 72450e4307ce42a31caf3e5b596f1728285349ba..1bb5431c749103e78b5e6b8f54631a1a35e36eb4 100644 (file)
@@ -47,19 +47,19 @@ DummyPhysicsEnvironment::~DummyPhysicsEnvironment()
        //destroy physicsengine data
 }
 
-void DummyPhysicsEnvironment::beginFrame()
+void DummyPhysicsEnvironment::BeginFrame()
 {
        // beginning of logic frame: apply forces
 }
 
-void DummyPhysicsEnvironment::endFrame()
+void DummyPhysicsEnvironment::EndFrame()
 {
        // end of logic frame: clear forces
 }
 
 
 
-bool           DummyPhysicsEnvironment::proceedDeltaTime(double  curTime,float timeStep,float interval)
+bool           DummyPhysicsEnvironment::ProceedDeltaTime(double  curTime,float timeStep,float interval)
 {
        //step physics simulation, typically perform
        
@@ -69,11 +69,11 @@ bool                DummyPhysicsEnvironment::proceedDeltaTime(double  curTime,float timeStep,f
        // return true if an update was done.
        return true;
 }
-void           DummyPhysicsEnvironment::setFixedTimeStep(bool useFixedTimeStep,float fixedTimeStep)
+void           DummyPhysicsEnvironment::SetFixedTimeStep(bool useFixedTimeStep,float fixedTimeStep)
 {
 }
  
-float          DummyPhysicsEnvironment::getFixedTimeStep()
+float          DummyPhysicsEnvironment::GetFixedTimeStep()
 {
        return 0.f;
 }
@@ -81,18 +81,18 @@ float               DummyPhysicsEnvironment::getFixedTimeStep()
 
 
 
-void DummyPhysicsEnvironment::setGravity(float x,float y,float z)
+void DummyPhysicsEnvironment::SetGravity(float x,float y,float z)
 {
 }
 
-void DummyPhysicsEnvironment::getGravity(class MT_Vector3& grav)
+void DummyPhysicsEnvironment::GetGravity(class MT_Vector3& grav)
 {
 }
 
 
 
 
-int                    DummyPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsController* ctrl2,PHY_ConstraintType type,
+int                    DummyPhysicsEnvironment::CreateConstraint(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsController* ctrl2,PHY_ConstraintType type,
                float pivotX,float pivotY,float pivotZ,float axisX,float axisY,float axisZ,
                        float axis1X,float axis1Y,float axis1Z,
                        float axis2X,float axis2Y,float axis2Z,int flag
@@ -104,14 +104,14 @@ int                       DummyPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ct
 
 }
 
-void           DummyPhysicsEnvironment::removeConstraint(int   constraintid)
+void           DummyPhysicsEnvironment::RemoveConstraint(int   constraintid)
 {
        if (constraintid)
        {
        }
 }
 
-PHY_IPhysicsController* DummyPhysicsEnvironment::rayTest(PHY_IRayCastFilterCallback &filterCallback,float fromX,float fromY,float fromZ, float toX,float toY,float toZ)
+PHY_IPhysicsController* DummyPhysicsEnvironment::RayTest(PHY_IRayCastFilterCallback &filterCallback,float fromX,float fromY,float fromZ, float toX,float toY,float toZ)
 {
        //collision detection / raytesting
        return NULL;
index 9f6bc85fced5e4d8fd28b753fad76872d187df13..41462f918408b46a014e663446a97db78adde061 100644 (file)
@@ -48,57 +48,57 @@ class DummyPhysicsEnvironment  : public PHY_IPhysicsEnvironment
 public:
        DummyPhysicsEnvironment ();
        virtual         ~DummyPhysicsEnvironment ();
-       virtual void            beginFrame();
-       virtual void            endFrame();
+       virtual void            BeginFrame();
+       virtual void            EndFrame();
 // Perform an integration step of duration 'timeStep'.
-       virtual bool            proceedDeltaTime(double  curTime,float timeStep,float interval);
-       virtual void            setFixedTimeStep(bool useFixedTimeStep,float fixedTimeStep);
-       virtual float           getFixedTimeStep();
+       virtual bool            ProceedDeltaTime(double  curTime,float timeStep,float interval);
+       virtual void            SetFixedTimeStep(bool useFixedTimeStep,float fixedTimeStep);
+       virtual float           GetFixedTimeStep();
 
-       virtual void            setGravity(float x,float y,float z);
-       virtual void            getGravity(class MT_Vector3& grav);
+       virtual void            SetGravity(float x,float y,float z);
+       virtual void            GetGravity(class MT_Vector3& grav);
 
-       virtual int                     createConstraint(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsController* ctrl2,PHY_ConstraintType type,
+       virtual int                     CreateConstraint(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsController* ctrl2,PHY_ConstraintType type,
                        float pivotX,float pivotY,float pivotZ,
                        float axisX,float axisY,float axisZ,
                        float axis1X=0,float axis1Y=0,float axis1Z=0,
                        float axis2X=0,float axis2Y=0,float axis2Z=0,int flag=0
                        );
 
-       virtual void            removeConstraint(int    constraintid);
+       virtual void            RemoveConstraint(int    constraintid);
 
                //complex constraint for vehicles
-       virtual PHY_IVehicle*   getVehicleConstraint(int constraintId)
+       virtual PHY_IVehicle*   GetVehicleConstraint(int constraintId)
        {
                return 0;
        }
 
                // Character physics wrapper
-       virtual PHY_ICharacter* getCharacterController(class KX_GameObject* ob)
+       virtual PHY_ICharacter* GetCharacterController(class KX_GameObject* ob)
        {
                return 0;
        }
 
-       virtual PHY_IPhysicsController* rayTest(PHY_IRayCastFilterCallback &filterCallback, float fromX,float fromY,float fromZ, float toX,float toY,float toZ);
-       virtual bool cullingTest(PHY_CullingCallback callback, void* userData, class MT_Vector4* planes, int nplanes, int occlusionRes, const int *viewport, double modelview[16], double projection[16]) { return false; }
+       virtual PHY_IPhysicsController* RayTest(PHY_IRayCastFilterCallback &filterCallback, float fromX,float fromY,float fromZ, float toX,float toY,float toZ);
+       virtual bool CullingTest(PHY_CullingCallback callback, void* userData, class MT_Vector4* planes, int nplanes, int occlusionRes, const int *viewport, double modelview[16], double projection[16]) { return false; }
 
 
        //gamelogic callbacks
-               virtual void addSensor(PHY_IPhysicsController* ctrl) {}
-               virtual void removeSensor(PHY_IPhysicsController* ctrl) {}
-               virtual void addTouchCallback(int response_class, PHY_ResponseCallback callback, void *user)
+               virtual void AddSensor(PHY_IPhysicsController* ctrl) {}
+               virtual void RemoveSensor(PHY_IPhysicsController* ctrl) {}
+               virtual void AddTouchCallback(int response_class, PHY_ResponseCallback callback, void *user)
                {
                }
-               virtual bool requestCollisionCallback(PHY_IPhysicsController* ctrl) { return false; }
-               virtual bool removeCollisionCallback(PHY_IPhysicsController* ctrl) { return false;}
+               virtual bool RequestCollisionCallback(PHY_IPhysicsController* ctrl) { return false; }
+               virtual bool RemoveCollisionCallback(PHY_IPhysicsController* ctrl) { return false;}
                virtual PHY_IPhysicsController* CreateSphereController(float radius,const class MT_Vector3& position) {return 0;}
                virtual PHY_IPhysicsController* CreateConeController(float coneradius,float coneheight) { return 0;}
 
-               virtual void    setConstraintParam(int constraintId,int param,float value,float value1)
+               virtual void    SetConstraintParam(int constraintId,int param,float value,float value1)
                {
                }
 
-               virtual float   getConstraintParam(int constraintId,int param)
+               virtual float   GetConstraintParam(int constraintId,int param)
                {
                        return 0.f;
                }
index ae1b2d9ad5325f438e5695ef3a4b398f6ca86fa7..284d77ca22122682b53dab6f6d3fd257ce35775d 100644 (file)
@@ -50,8 +50,8 @@ class PHY_IController
        public:
                virtual ~PHY_IController(){};
                // clientinfo for raycasts for example
-               virtual void*   getNewClientInfo()=0;
-               virtual void    setNewClientInfo(void* clientinfo)=0;
+               virtual void*   GetNewClientInfo()=0;
+               virtual void    SetNewClientInfo(void* clientinfo)=0;
                virtual void    SetPhysicsEnvironment(class PHY_IPhysicsEnvironment *env)=0;
 
        
index 5f64e7ccc80904a80c6dbc2fe963705cada29b05..b047edd93ebb8a8a77b00ee66a5f1be38ad112c9 100644 (file)
@@ -47,8 +47,8 @@ class PHY_IGraphicController : public PHY_IController
                 */
                virtual bool SetGraphicTransform()=0;
                virtual void Activate(bool active=true)=0;
-               virtual void setLocalAabb(const class MT_Vector3& aabbMin,const class MT_Vector3& aabbMax)=0;
-               virtual void setLocalAabb(const float* aabbMin,const float* aabbMax)=0;
+               virtual void SetLocalAabb(const class MT_Vector3& aabbMin,const class MT_Vector3& aabbMax)=0;
+               virtual void SetLocalAabb(const float* aabbMin,const float* aabbMax)=0;
 
                virtual PHY_IGraphicController* GetReplica(class PHY_IMotionState* motionstate) {return 0;}
 
index be5b2b54907ef4e529651e9e97360ac215a375a7..d40b8da945154107f00073daec5631d22f4f48e4 100644 (file)
@@ -46,18 +46,18 @@ class       PHY_IMotionState
        public:
                virtual ~PHY_IMotionState(){};
 
-               virtual void    getWorldPosition(float& posX,float& posY,float& posZ)=0;
-               virtual void    getWorldScaling(float& scaleX,float& scaleY,float& scaleZ)=0;
-               virtual void    getWorldOrientation(float& quatIma0,float& quatIma1,float& quatIma2,float& quatReal)=0;
+               virtual void    GetWorldPosition(float& posX,float& posY,float& posZ)=0;
+               virtual void    GetWorldScaling(float& scaleX,float& scaleY,float& scaleZ)=0;
+               virtual void    GetWorldOrientation(float& quatIma0,float& quatIma1,float& quatIma2,float& quatReal)=0;
                // ori = array 12 floats, [0..3] = first column + 0, [4..7] = second column, [8..11] = third column
-               virtual void    getWorldOrientation(float* ori)=0;
-               virtual void    setWorldOrientation(const float* ori)=0;
+               virtual void    GetWorldOrientation(float* ori)=0;
+               virtual void    SetWorldOrientation(const float* ori)=0;
                
-               virtual void    setWorldPosition(float posX,float posY,float posZ)=0;
-               virtual void    setWorldOrientation(float quatIma0,float quatIma1,float quatIma2,float quatReal)=0;
+               virtual void    SetWorldPosition(float posX,float posY,float posZ)=0;
+               virtual void    SetWorldOrientation(float quatIma0,float quatIma1,float quatIma2,float quatReal)=0;
 
 
-               virtual void    calculateWorldTransformations()=0;
+               virtual void    CalculateWorldTransformations()=0;
        
        
 #ifdef WITH_CXX_GUARDEDALLOC
index 18af42adc1574817ae03a27d3de50b19bf16480c..a1d0972a950dc9ad622c45fc87fb64d3912b9369 100644 (file)
 class PHY_IMotionState;
 class PHY_IPhysicsEnvironment;
 
+class MT_Vector3;
+class MT_Point3;
+class MT_Matrix3x3;
+
 /**
  * PHY_IPhysicsController is the abstract simplified Interface to a physical object.
  * It contains the IMotionState and IDeformableMesh Interfaces.
@@ -59,37 +63,47 @@ class PHY_IPhysicsController : public PHY_IController
                virtual class PHY_IMotionState* GetMotionState() = 0;
                // controller replication
                virtual void            PostProcessReplica(class PHY_IMotionState* motionstate,class PHY_IPhysicsController* parentctrl)=0;
+               virtual void            SetPhysicsEnvironment(class PHY_IPhysicsEnvironment *env)=0;
 
                // kinematic methods
-               virtual void            RelativeTranslate(float dlocX,float dlocY,float dlocZ,bool local)=0;
-               virtual void            RelativeRotate(const float drot[12],bool local)=0;
-               virtual void            getOrientation(float &quatImag0,float &quatImag1,float &quatImag2,float &quatReal)=0;
-               virtual void            setOrientation(float quatImag0,float quatImag1,float quatImag2,float quatReal)=0;
-               virtual void            setPosition(float posX,float posY,float posZ)=0;
-               virtual void            getPosition(class MT_Vector3&   pos) const=0;
-               virtual void            setScaling(float scaleX,float scaleY,float scaleZ)=0;
-               
+               virtual void            RelativeTranslate(const MT_Vector3& dloc,bool local)=0;
+               virtual void            RelativeRotate(const MT_Matrix3x3&,bool local)=0;
+               virtual MT_Matrix3x3    GetOrientation()=0;
+               virtual void            SetOrientation(const MT_Matrix3x3& orn)=0;
+               virtual void            SetPosition(const MT_Vector3& pos)=0;
+               virtual void            GetPosition(MT_Vector3& pos) const=0;
+               virtual void            SetScaling(const MT_Vector3& scale)=0;
+               virtual void            SetTransform()=0;
+
+               virtual MT_Scalar       GetMass()=0;
+               virtual void            SetMass(MT_Scalar newmass)=0;
+
                // physics methods
-               virtual void            ApplyTorque(float torqueX,float torqueY,float torqueZ,bool local)=0;
-               virtual void            ApplyForce(float forceX,float forceY,float forceZ,bool local)=0;
-               virtual void            SetAngularVelocity(float ang_velX,float ang_velY,float ang_velZ,bool local)=0;
-               virtual void            SetLinearVelocity(float lin_velX,float lin_velY,float lin_velZ,bool local)=0;
-               virtual void            resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ) = 0;
+               virtual void            ApplyImpulse(const MT_Point3& attach, const MT_Vector3& impulse)=0;
+               virtual void            ApplyTorque(const MT_Vector3& torque,bool local)=0;
+               virtual void            ApplyForce(const MT_Vector3& force,bool local)=0;
+               virtual void            SetAngularVelocity(const MT_Vector3& ang_vel,bool local)=0;
+               virtual void            SetLinearVelocity(const MT_Vector3& lin_vel,bool local)=0;
+               virtual void            ResolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ) = 0;
+
+               virtual void            SuspendDynamics(bool ghost=false)=0;
+               virtual void            RestoreDynamics()=0;
 
-               virtual void            applyImpulse(float attachX,float attachY,float attachZ, float impulseX,float impulseY,float impulseZ)=0;
                virtual void            SetActive(bool active)=0;
 
                // reading out information from physics
-               virtual void            GetLinearVelocity(float& linvX,float& linvY,float& linvZ)=0;
-               virtual void            GetVelocity(const float posX,const float posY,const float posZ,float& linvX,float& linvY,float& linvZ)=0; 
-               virtual void            getReactionForce(float& forceX,float& forceY,float& forceZ)=0;
+               virtual MT_Vector3      GetLinearVelocity()=0;
+               virtual MT_Vector3      GetAngularVelocity()=0;
+               virtual MT_Vector3      GetVelocity(const MT_Point3& pos)=0;
+               virtual MT_Vector3      GetLocalInertia()=0;
 
                // dyna's that are rigidbody are free in orientation, dyna's with non-rigidbody are restricted 
-               virtual void            setRigidBody(bool rigid)=0;
+               virtual void            SetRigidBody(bool rigid)=0;
 
                virtual PHY_IPhysicsController* GetReplica() {return 0;}
+               virtual PHY_IPhysicsController* GetReplicaForSensors() {return 0;}
 
-               virtual void    calcXform() =0;
+               virtual void    CalcXform() =0;
                virtual void SetMargin(float margin) =0;
                virtual float GetMargin() const=0;
                virtual float GetRadius() const=0;
@@ -100,7 +114,15 @@ class PHY_IPhysicsController : public PHY_IController
                virtual float GetLinVelocityMax() const=0;
                virtual void  SetLinVelocityMax(float val) = 0;
                
-               class MT_Vector3        GetWorldPosition(class MT_Vector3& localpos);
+               MT_Vector3      GetWorldPosition(MT_Vector3& localpos);
+
+               // Shape control
+               virtual void    AddCompoundChild(PHY_IPhysicsController* child) = 0;
+               virtual void    RemoveCompoundChild(PHY_IPhysicsController* child) = 0;
+
+
+               virtual bool IsDynamic() = 0;
+               virtual bool IsCompound() = 0;
 
 
 #ifdef WITH_CXX_GUARDEDALLOC
index 14904a70553cdc205b0d743fa980e0c98dd272f6..b1a0480ab14ce94363905767e7f54aba54d71c44 100644 (file)
@@ -105,87 +105,88 @@ public:
 class PHY_IPhysicsEnvironment
 {
        public:
-               virtual         ~PHY_IPhysicsEnvironment(){};
-               virtual void            beginFrame() = 0;
-               virtual void            endFrame() = 0;
+               virtual         ~PHY_IPhysicsEnvironment(){}
+               virtual void            BeginFrame() = 0;
+               virtual void            EndFrame() = 0;
                /// Perform an integration step of duration 'timeStep'.
-               virtual bool            proceedDeltaTime(double curTime,float timeStep,float interval)=0;
+               virtual bool            ProceedDeltaTime(double curTime,float timeStep,float interval)=0;
                ///draw debug lines (make sure to call this during the render phase, otherwise lines are not drawn properly)
-               virtual void            debugDrawWorld() {}
-               virtual void            setFixedTimeStep(bool useFixedTimeStep,float fixedTimeStep)=0;
+               virtual void            DebugDrawWorld() {}
+               virtual void            SetFixedTimeStep(bool useFixedTimeStep,float fixedTimeStep)=0;
                //returns 0.f if no fixed timestep is used
-               virtual float           getFixedTimeStep()=0;
+               virtual float           GetFixedTimeStep()=0;
 
                ///setDebugMode is used to support several ways of debug lines, contact point visualization
-               virtual void            setDebugMode(int debugMode) {}
+               virtual void            SetDebugMode(int debugMode) {}
                ///setNumIterations set the number of iterations for iterative solvers
-               virtual void            setNumIterations(int numIter) {}
+               virtual void            SetNumIterations(int numIter) {}
                ///setNumTimeSubSteps set the number of divisions of the timestep. Tradeoff quality versus performance.
-               virtual void            setNumTimeSubSteps(int numTimeSubSteps) {}
+               virtual void            SetNumTimeSubSteps(int numTimeSubSteps) {}
+               virtual int                     GetNumTimeSubSteps() {return 0; }
                ///setDeactivationTime sets the minimum time that an objects has to stay within the velocity tresholds until it gets fully deactivated
-               virtual void            setDeactivationTime(float dTime) {}
+               virtual void            SetDeactivationTime(float dTime) {}
                ///setDeactivationLinearTreshold sets the linear velocity treshold, see setDeactivationTime
-               virtual void            setDeactivationLinearTreshold(float linTresh) {}
+               virtual void            SetDeactivationLinearTreshold(float linTresh) {}
                ///setDeactivationAngularTreshold sets the angular velocity treshold, see setDeactivationTime
-               virtual void            setDeactivationAngularTreshold(float angTresh) {}
+               virtual void            SetDeactivationAngularTreshold(float angTresh) {}
                ///setContactBreakingTreshold sets tresholds to do with contact point management
-               virtual void            setContactBreakingTreshold(float contactBreakingTreshold) {}
+               virtual void            SetContactBreakingTreshold(float contactBreakingTreshold) {}
                ///continuous collision detection mode, very experimental for Bullet
-               virtual void            setCcdMode(int ccdMode) {}
+               virtual void            SetCcdMode(int ccdMode) {}
                ///successive overrelaxation constant, in case PSOR is used, values in between 1 and 2 guarantee converging behavior
-               virtual void            setSolverSorConstant(float sor) {}
+               virtual void            SetSolverSorConstant(float sor) {}
                ///setSolverType, internal setting, chooses solvertype, PSOR, Dantzig, impulse based, penalty based
-               virtual void            setSolverType(int solverType) {}
+               virtual void            SetSolverType(int solverType) {}
                ///setTau sets the spring constant of a penalty based solver
-               virtual void            setSolverTau(float tau) {}
+               virtual void            SetSolverTau(float tau) {}
                ///setDamping sets the damper constant of a penalty based solver
-               virtual void            setSolverDamping(float damping) {}
+               virtual void            SetSolverDamping(float damping) {}
                ///linear air damping for rigidbodies
-               virtual void            setLinearAirDamping(float damping) {}
+               virtual void            SetLinearAirDamping(float damping) {}
                /// penetrationdepth setting
-               virtual void            setUseEpa(bool epa) {}
+               virtual void            SetUseEpa(bool epa) {}
 
-               virtual void            setGravity(float x,float y,float z)=0;
-               virtual void            getGravity(MT_Vector3& grav) = 0;
+               virtual void            SetGravity(float x,float y,float z)=0;
+               virtual void            GetGravity(MT_Vector3& grav) = 0;
 
-               virtual int                     createConstraint(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsController* ctrl2,PHY_ConstraintType type,
+               virtual int                     CreateConstraint(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsController* ctrl2,PHY_ConstraintType type,
                        float pivotX,float pivotY,float pivotZ,
                        float axis0X,float axis0Y,float axis0Z,
                        float axis1X=0,float axis1Y=0,float axis1Z=0,
                        float axis2X=0,float axis2Y=0,float axis2Z=0,int flag=0
                )=0;
-               virtual void            removeConstraint(int    constraintid)=0;
-               virtual float           getAppliedImpulse(int   constraintid) { return 0.0f; }
+               virtual void            RemoveConstraint(int    constraintid)=0;
+               virtual float           GetAppliedImpulse(int   constraintid) { return 0.0f; }
 
 
                //complex constraint for vehicles
-               virtual PHY_IVehicle*   getVehicleConstraint(int constraintId) =0;
+               virtual PHY_IVehicle*   GetVehicleConstraint(int constraintId) =0;
 
                // Character physics wrapper
-               virtual PHY_ICharacter* getCharacterController(class KX_GameObject* ob) =0;
+               virtual PHY_ICharacter* GetCharacterController(class KX_GameObject* ob) =0;
 
-               virtual PHY_IPhysicsController* rayTest(PHY_IRayCastFilterCallback &filterCallback, float fromX,float fromY,float fromZ, float toX,float toY,float toZ)=0;
+               virtual PHY_IPhysicsController* RayTest(PHY_IRayCastFilterCallback &filterCallback, float fromX,float fromY,float fromZ, float toX,float toY,float toZ)=0;
 
                //culling based on physical broad phase
                // the plane number must be set as follow: near, far, left, right, top, botton
                // the near plane must be the first one and must always be present, it is used to get the direction of the view
-               virtual bool cullingTest(PHY_CullingCallback callback, void *userData, MT_Vector4* planeNormals, int planeNumber, int occlusionRes, const int *viewport, double modelview[16], double projection[16]) = 0;
+               virtual bool CullingTest(PHY_CullingCallback callback, void *userData, MT_Vector4* planeNormals, int planeNumber, int occlusionRes, const int *viewport, double modelview[16], double projection[16]) = 0;
 
                //Methods for gamelogic collision/physics callbacks
                //todo:
-               virtual void addSensor(PHY_IPhysicsController* ctrl)=0;
-               virtual void removeSensor(PHY_IPhysicsController* ctrl)=0;
-               virtual void addTouchCallback(int response_class, PHY_ResponseCallback callback, void *user)=0;
-               virtual bool requestCollisionCallback(PHY_IPhysicsController* ctrl)=0;
-               virtual bool removeCollisionCallback(PHY_IPhysicsController* ctrl)=0;
+               virtual void AddSensor(PHY_IPhysicsController* ctrl)=0;
+               virtual void RemoveSensor(PHY_IPhysicsController* ctrl)=0;
+               virtual void AddTouchCallback(int response_class, PHY_ResponseCallback callback, void *user)=0;
+               virtual bool RequestCollisionCallback(PHY_IPhysicsController* ctrl)=0;
+               virtual bool RemoveCollisionCallback(PHY_IPhysicsController* ctrl)=0;
                //These two methods are *solely* used to create controllers for sensor! Don't use for anything else
                virtual PHY_IPhysicsController* CreateSphereController(float radius,const MT_Vector3& position) =0;
                virtual PHY_IPhysicsController* CreateConeController(float coneradius,float coneheight)=0;
                
-               virtual void    setConstraintParam(int constraintId,int param,float value,float value1) = 0;
-               virtual float   getConstraintParam(int constraintId,int param) = 0;
+               virtual void    SetConstraintParam(int constraintId,int param,float value,float value1) = 0;
+               virtual float   GetConstraintParam(int constraintId,int param) = 0;
                
-               virtual void    exportFile(const char* filename) {};
+               virtual void    ExportFile(const char* filename) {};
 
 
 #ifdef WITH_CXX_GUARDEDALLOC