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>2014-04-24 01:08:49 +0400
committerMitchell Stokes <mogurijin@gmail.com>2014-04-24 01:08:49 +0400
commit3442a658fc24267d0fd77da72eb7b254e7079c65 (patch)
treed8649018b7af808662672a4dab30c4d206b7f2b7
parent81e28b8802a65a3efd6410e75a3fb92a21ed69a3 (diff)
BGE Cleanup: Reducing KX_Scene's dependence on Bullet.
Instead, it now relies more on our physics abstractions (e.g., PHY_IPhysicsEnvironment).
-rw-r--r--source/gameengine/Ketsji/KX_Scene.cpp23
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp6
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h2
-rw-r--r--source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h5
-rw-r--r--source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h2
5 files changed, 17 insertions, 21 deletions
diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp
index 64ba17f49f6..50885515976 100644
--- a/source/gameengine/Ketsji/KX_Scene.cpp
+++ b/source/gameengine/Ketsji/KX_Scene.cpp
@@ -84,6 +84,7 @@
#include "NG_NetworkScene.h"
#include "PHY_IPhysicsEnvironment.h"
#include "PHY_IGraphicController.h"
+#include "PHY_IPhysicsController.h"
#include "KX_BlenderSceneConverter.h"
#include "KX_MotionState.h"
@@ -95,8 +96,6 @@
#ifdef WITH_BULLET
#include "KX_SoftBodyDeformer.h"
#include "KX_ConvertPhysicsObject.h"
-#include "CcdPhysicsEnvironment.h"
-#include "CcdPhysicsController.h"
#endif
#include "KX_Light.h"
@@ -565,7 +564,6 @@ KX_GameObject* KX_Scene::AddNodeReplicaObject(class SG_IObject* node, class CVal
newobj->SetGraphicController(newctrl);
}
-#ifdef WITH_BULLET
// replicate physics controller
if (orgobj->GetPhysicsController())
{
@@ -582,7 +580,6 @@ KX_GameObject* KX_Scene::AddNodeReplicaObject(class SG_IObject* node, class CVal
if (parent)
parent->Release();
}
-#endif
return newobj;
}
@@ -1882,12 +1879,10 @@ static void MergeScene_LogicBrick(SCA_ILogicBrick* brick, KX_Scene *to)
brick->Replace_NetworkScene(to->GetNetworkScene());
/* near sensors have physics controllers */
-#ifdef WITH_BULLET
KX_TouchSensor *touch_sensor = dynamic_cast<class KX_TouchSensor *>(brick);
if (touch_sensor) {
touch_sensor->GetPhysicsController()->SetPhysicsEnvironment(to->GetPhysicsEnvironment());
}
-#endif
// If we end up replacing a KX_TouchEventManager, we need to make sure
// physics controllers are properly in place. In other words, do this
@@ -1916,10 +1911,6 @@ static void MergeScene_LogicBrick(SCA_ILogicBrick* brick, KX_Scene *to)
#endif
}
-#ifdef WITH_BULLET
-#include "CcdGraphicController.h" // XXX ctrl->SetPhysicsEnvironment(to->GetPhysicsEnvironment());
-#endif
-
static void MergeScene_GameObject(KX_GameObject* gameobj, KX_Scene *to, KX_Scene *from)
{
{
@@ -1972,12 +1963,10 @@ static void MergeScene_GameObject(KX_GameObject* gameobj, KX_Scene *to, KX_Scene
ctrl->SetPhysicsEnvironment(to->GetPhysicsEnvironment());
}
-#ifdef WITH_BULLET
ctrl = gameobj->GetPhysicsController();
if (ctrl) {
ctrl->SetPhysicsEnvironment(to->GetPhysicsEnvironment());
}
-#endif
/* SG_Node can hold a scene reference */
SG_Node *sg= gameobj->GetSGNode();
@@ -2008,9 +1997,8 @@ static void MergeScene_GameObject(KX_GameObject* gameobj, KX_Scene *to, KX_Scene
bool KX_Scene::MergeScene(KX_Scene *other)
{
-#ifdef WITH_BULLET
- CcdPhysicsEnvironment *env= dynamic_cast<CcdPhysicsEnvironment *>(this->GetPhysicsEnvironment());
- CcdPhysicsEnvironment *env_other= dynamic_cast<CcdPhysicsEnvironment *>(other->GetPhysicsEnvironment());
+ PHY_IPhysicsEnvironment *env = this->GetPhysicsEnvironment();
+ PHY_IPhysicsEnvironment *env_other = other->GetPhysicsEnvironment();
if ((env==NULL) != (env_other==NULL)) /* TODO - even when both scenes have NONE physics, the other is loaded with bullet enabled, ??? */
{
@@ -2018,7 +2006,6 @@ bool KX_Scene::MergeScene(KX_Scene *other)
printf("\tsource %d, terget %d\n", (int)(env!=NULL), (int)(env_other!=NULL));
return false;
}
-#endif // WITH_BULLET
if (GetSceneConverter() != other->GetSceneConverter()) {
printf("KX_Scene::MergeScene: converters differ, aborting\n");
@@ -2060,10 +2047,8 @@ bool KX_Scene::MergeScene(KX_Scene *other)
GetLightList()->MergeList(other->GetLightList());
other->GetLightList()->ReleaseAndRemoveAll();
-#ifdef WITH_BULLET
- if (env) /* bullet scene? - dummy scenes don't need touching */
+ if (env)
env->MergeEnvironment(env_other);
-#endif
/* move materials across, assume they both use the same scene-converters
* Do this after lights are merged so materials can use the lights in shaders
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
index b6a46b4307e..dcd30ea1174 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
@@ -1871,8 +1871,12 @@ btDispatcher* CcdPhysicsEnvironment::GetDispatcher()
return m_dynamicsWorld->getDispatcher();
}
-void CcdPhysicsEnvironment::MergeEnvironment(CcdPhysicsEnvironment *other)
+void CcdPhysicsEnvironment::MergeEnvironment(PHY_IPhysicsEnvironment *other_env)
{
+ CcdPhysicsEnvironment *other = dynamic_cast<CcdPhysicsEnvironment*>(other_env);
+ printf("KX_Scene::MergeScene: Other scene is not using Bullet physics, not merging physics.\n");
+ return;
+
std::set<CcdPhysicsController*>::iterator it;
while (other->m_controllers.begin() != other->m_controllers.end())
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h
index 0e8ac9417f0..4e002f5ce3c 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h
@@ -258,7 +258,7 @@ protected:
class btConstraintSolver* GetConstraintSolver();
- void MergeEnvironment(CcdPhysicsEnvironment *other);
+ void MergeEnvironment(PHY_IPhysicsEnvironment *other_env);
protected:
diff --git a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h
index 41462f91840..c06a8d904b2 100644
--- a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h
+++ b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h
@@ -103,6 +103,11 @@ public:
return 0.f;
}
+ virtual void MergeEnvironment(PHY_IPhysicsEnvironment *other_env)
+ {
+ // Dummy, nothing to do here
+ }
+
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("GE:DummyPhysicsEnvironment")
diff --git a/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h b/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h
index b1a0480ab14..d2574b3ca3b 100644
--- a/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h
+++ b/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h
@@ -188,6 +188,8 @@ class PHY_IPhysicsEnvironment
virtual void ExportFile(const char* filename) {};
+ virtual void MergeEnvironment(PHY_IPhysicsEnvironment *other_env) = 0;
+
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("GE:PHY_IPhysicsEnvironment")