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:
authorPorteries Tristan <republicthunderbolt9@gmail.com>2015-08-10 23:42:52 +0300
committerPorteries Tristan <republicthunderbolt9@gmail.com>2015-08-11 12:30:23 +0300
commitbccc6c393c70cc6466f044917348fb50d43ef021 (patch)
tree8e86ea5bff17a3223adf6248a2bb37b9381f14d7 /source/gameengine/Ketsji/KX_Scene.cpp
parentc1506454ecb4630119ed7ce13b3f8cdfef6dcee0 (diff)
BGE: Fix T33187 constraints replication for libloaded objects.
Reviewers: Moguri
Diffstat (limited to 'source/gameengine/Ketsji/KX_Scene.cpp')
-rw-r--r--source/gameengine/Ketsji/KX_Scene.cpp25
1 files changed, 22 insertions, 3 deletions
diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp
index 83126e88ce5..37ef44dafe2 100644
--- a/source/gameengine/Ketsji/KX_Scene.cpp
+++ b/source/gameengine/Ketsji/KX_Scene.cpp
@@ -2064,6 +2064,28 @@ bool KX_Scene::MergeScene(KX_Scene *other)
MergeScene_GameObject(gameobj, this, other);
}
+ if (env) {
+ env->MergeEnvironment(env_other);
+ CListValue *otherObjects = other->GetObjectList();
+
+ // List of all physics objects to merge (needed by ReplicateConstraints).
+ std::vector<KX_GameObject *> physicsObjects;
+ for (unsigned int i = 0; i < otherObjects->GetCount(); ++i) {
+ KX_GameObject *gameobj = (KX_GameObject *)otherObjects->GetValue(i);
+ if (gameobj->GetPhysicsController()) {
+ physicsObjects.push_back(gameobj);
+ }
+ }
+
+ for (unsigned int i = 0; i < physicsObjects.size(); ++i) {
+ KX_GameObject *gameobj = physicsObjects[i];
+ // Replicate all constraints in the right physics environment.
+ gameobj->GetPhysicsController()->ReplicateConstraints(gameobj, physicsObjects);
+ gameobj->ClearConstraints();
+ }
+ }
+
+
GetTempObjectList()->MergeList(other->GetTempObjectList());
other->GetTempObjectList()->ReleaseAndRemoveAll();
@@ -2079,9 +2101,6 @@ bool KX_Scene::MergeScene(KX_Scene *other)
GetLightList()->MergeList(other->GetLightList());
other->GetLightList()->ReleaseAndRemoveAll();
- if (env)
- env->MergeEnvironment(env_other);
-
/* 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
*/