Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/gameengine/Ketsji')
-rw-r--r--source/gameengine/Ketsji/BL_Action.cpp2
-rw-r--r--source/gameengine/Ketsji/CMakeLists.txt4
-rw-r--r--source/gameengine/Ketsji/KX_BulletPhysicsController.cpp577
-rw-r--r--source/gameengine/Ketsji/KX_BulletPhysicsController.h102
-rw-r--r--source/gameengine/Ketsji/KX_CharacterWrapper.cpp2
-rw-r--r--source/gameengine/Ketsji/KX_ConstraintActuator.cpp12
-rw-r--r--source/gameengine/Ketsji/KX_ConstraintWrapper.cpp4
-rw-r--r--source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp20
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.cpp193
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.h37
-rw-r--r--source/gameengine/Ketsji/KX_IPO_SGController.cpp9
-rw-r--r--source/gameengine/Ketsji/KX_IPhysicsController.cpp49
-rw-r--r--source/gameengine/Ketsji/KX_IPhysicsController.h151
-rw-r--r--source/gameengine/Ketsji/KX_KetsjiEngine.cpp10
-rw-r--r--source/gameengine/Ketsji/KX_MotionState.cpp16
-rw-r--r--source/gameengine/Ketsji/KX_MotionState.h16
-rw-r--r--source/gameengine/Ketsji/KX_MouseFocusSensor.cpp3
-rw-r--r--source/gameengine/Ketsji/KX_NearSensor.cpp16
-rw-r--r--source/gameengine/Ketsji/KX_ObjectActuator.cpp23
-rw-r--r--source/gameengine/Ketsji/KX_PyConstraintBinding.cpp44
-rw-r--r--source/gameengine/Ketsji/KX_PythonInit.cpp4
-rw-r--r--source/gameengine/Ketsji/KX_RadarSensor.cpp4
-rw-r--r--source/gameengine/Ketsji/KX_RayCast.cpp9
-rw-r--r--source/gameengine/Ketsji/KX_RayCast.h7
-rw-r--r--source/gameengine/Ketsji/KX_RaySensor.cpp3
-rw-r--r--source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp1
-rw-r--r--source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp11
-rw-r--r--source/gameengine/Ketsji/KX_SCA_DynamicActuator.h1
-rw-r--r--source/gameengine/Ketsji/KX_Scene.cpp45
-rw-r--r--source/gameengine/Ketsji/KX_TouchEventManager.cpp14
-rw-r--r--source/gameengine/Ketsji/KX_TouchSensor.cpp24
31 files changed, 251 insertions, 1162 deletions
diff --git a/source/gameengine/Ketsji/BL_Action.cpp b/source/gameengine/Ketsji/BL_Action.cpp
index 6d9b22eed91..a974ffbf672 100644
--- a/source/gameengine/Ketsji/BL_Action.cpp
+++ b/source/gameengine/Ketsji/BL_Action.cpp
@@ -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"
diff --git a/source/gameengine/Ketsji/CMakeLists.txt b/source/gameengine/Ketsji/CMakeLists.txt
index c3c733c66ba..141dd5e25f3 100644
--- a/source/gameengine/Ketsji/CMakeLists.txt
+++ b/source/gameengine/Ketsji/CMakeLists.txt
@@ -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
index e990974a646..00000000000
--- a/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp
+++ /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
index 3d13744567b..00000000000
--- a/source/gameengine/Ketsji/KX_BulletPhysicsController.h
+++ /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__ */
diff --git a/source/gameengine/Ketsji/KX_CharacterWrapper.cpp b/source/gameengine/Ketsji/KX_CharacterWrapper.cpp
index 899a153d80f..fdf4fa01b03 100644
--- a/source/gameengine/Ketsji/KX_CharacterWrapper.cpp
+++ b/source/gameengine/Ketsji/KX_CharacterWrapper.cpp
@@ -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
diff --git a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp
index a3059317d36..0c5e21322df 100644
--- a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp
+++ b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp
@@ -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)
diff --git a/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp b/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp
index e09449c4f1d..793324fab75 100644
--- a/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp
+++ b/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp
@@ -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;
}
diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
index ece6abc9447..bde50588fd3 100644
--- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
+++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
@@ -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);
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp
index e06f7ab6633..96f76ff21b1 100644
--- a/source/gameengine/Ketsji/KX_GameObject.cpp
+++ b/source/gameengine/Ketsji/KX_GameObject.cpp
@@ -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();
diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h
index dde3ff53299..55e2b31c5bf 100644
--- a/source/gameengine/Ketsji/KX_GameObject.h
+++ b/source/gameengine/Ketsji/KX_GameObject.h
@@ -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)
{
diff --git a/source/gameengine/Ketsji/KX_IPO_SGController.cpp b/source/gameengine/Ketsji/KX_IPO_SGController.cpp
index f221b7c6cd4..f75633659ff 100644
--- a/source/gameengine/Ketsji/KX_IPO_SGController.cpp
+++ b/source/gameengine/Ketsji/KX_IPO_SGController.cpp
@@ -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
index f0e57ceac02..00000000000
--- a/source/gameengine/Ketsji/KX_IPhysicsController.cpp
+++ /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
index 2019be57679..00000000000
--- a/source/gameengine/Ketsji/KX_IPhysicsController.h
+++ /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__ */
diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
index 48ef8cdd50d..0e9e2cd8328 100644
--- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
+++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
@@ -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();
}
/*
diff --git a/source/gameengine/Ketsji/KX_MotionState.cpp b/source/gameengine/Ketsji/KX_MotionState.cpp
index 3ca01e7af74..4728f71a6ea 100644
--- a/source/gameengine/Ketsji/KX_MotionState.cpp
+++ b/source/gameengine/Ketsji/KX_MotionState.cpp
@@ -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;
diff --git a/source/gameengine/Ketsji/KX_MotionState.h b/source/gameengine/Ketsji/KX_MotionState.h
index 116e62f408f..38046fe4ff9 100644
--- a/source/gameengine/Ketsji/KX_MotionState.h
+++ b/source/gameengine/Ketsji/KX_MotionState.h
@@ -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
diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp
index 82ae8c13633..2dbafdad3d9 100644
--- a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp
+++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp
@@ -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
diff --git a/source/gameengine/Ketsji/KX_NearSensor.cpp b/source/gameengine/Ketsji/KX_NearSensor.cpp
index cbb4e77d165..6459f35192d 100644
--- a/source/gameengine/Ketsji/KX_NearSensor.cpp
+++ b/source/gameengine/Ketsji/KX_NearSensor.cpp
@@ -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 :
diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.cpp b/source/gameengine/Ketsji/KX_ObjectActuator.cpp
index 2965faba8f4..2f85453dd23 100644
--- a/source/gameengine/Ketsji/KX_ObjectActuator.cpp
+++ b/source/gameengine/Ketsji/KX_ObjectActuator.cpp
@@ -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 {
diff --git a/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp b/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp
index 2e9b988dff1..e9843b0af5b 100644
--- a/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp
+++ b/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp
@@ -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;
}
diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp
index 311653e72e7..08e240903d1 100644
--- a/source/gameengine/Ketsji/KX_PythonInit.cpp
+++ b/source/gameengine/Ketsji/KX_PythonInit.cpp
@@ -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 *)
diff --git a/source/gameengine/Ketsji/KX_RadarSensor.cpp b/source/gameengine/Ketsji/KX_RadarSensor.cpp
index 04d67fc73e1..732bcdc3773 100644
--- a/source/gameengine/Ketsji/KX_RadarSensor.cpp
+++ b/source/gameengine/Ketsji/KX_RadarSensor.cpp
@@ -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);
}
diff --git a/source/gameengine/Ketsji/KX_RayCast.cpp b/source/gameengine/Ketsji/KX_RayCast.cpp
index f1bfb10220a..333e7b57d67 100644
--- a/source/gameengine/Ketsji/KX_RayCast.cpp
+++ b/source/gameengine/Ketsji/KX_RayCast.cpp
@@ -39,12 +39,11 @@
#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)
{
diff --git a/source/gameengine/Ketsji/KX_RayCast.h b/source/gameengine/Ketsji/KX_RayCast.h
index 544080f31d0..e47ac676eb1 100644
--- a/source/gameengine/Ketsji/KX_RayCast.h
+++ b/source/gameengine/Ketsji/KX_RayCast.h
@@ -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)
{
diff --git a/source/gameengine/Ketsji/KX_RaySensor.cpp b/source/gameengine/Ketsji/KX_RaySensor.cpp
index 3fbce690a9f..afd39557130 100644
--- a/source/gameengine/Ketsji/KX_RaySensor.cpp
+++ b/source/gameengine/Ketsji/KX_RaySensor.cpp
@@ -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();
diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp
index 56dccc1d045..f8f79269eaa 100644
--- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp
+++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp
@@ -38,7 +38,6 @@
#include "KX_SCA_AddObjectActuator.h"
#include "SCA_IScene.h"
#include "KX_GameObject.h"
-#include "KX_IPhysicsController.h"
#include "PyObjectPlus.h"
/* ------------------------------------------------------------------------- */
diff --git a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp
index 5dc67a4cff3..e02eca3db63 100644
--- a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp
+++ b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp
@@ -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);
diff --git a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.h b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.h
index 01a91624c41..4eb337c54f5 100644
--- a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.h
+++ b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.h
@@ -38,7 +38,6 @@
#include "SCA_LogicManager.h"
#include "KX_GameObject.h"
-#include "KX_IPhysicsController.h"
class KX_SCA_DynamicActuator : public SCA_IActuator
{
diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp
index a34764d7d17..1d95beed6e9 100644
--- a/source/gameengine/Ketsji/KX_Scene.cpp
+++ b/source/gameengine/Ketsji/KX_Scene.cpp
@@ -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)
diff --git a/source/gameengine/Ketsji/KX_TouchEventManager.cpp b/source/gameengine/Ketsji/KX_TouchEventManager.cpp
index 1a9e1442cc8..d010d3d50a0 100644
--- a/source/gameengine/Ketsji/KX_TouchEventManager.cpp
+++ b/source/gameengine/Ketsji/KX_TouchEventManager.cpp
@@ -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) {
diff --git a/source/gameengine/Ketsji/KX_TouchSensor.cpp b/source/gameengine/Ketsji/KX_TouchSensor.cpp
index 9d87da48fae..b231a2191ed 100644
--- a/source/gameengine/Ketsji/KX_TouchSensor.cpp
+++ b/source/gameengine/Ketsji/KX_TouchSensor.cpp
@@ -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 :