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