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/KX_Scene.cpp')
-rw-r--r--source/gameengine/Ketsji/KX_Scene.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp
index 652ed2ab2dd..a4237f9fabe 100644
--- a/source/gameengine/Ketsji/KX_Scene.cpp
+++ b/source/gameengine/Ketsji/KX_Scene.cpp
@@ -769,6 +769,13 @@ void KX_Scene::DupliGroupRecurse(CValue* obj, int level)
// we can now add the graphic controller to the physic engine
replica->ActivateGraphicController(true);
+ // set references for dupli-group
+ // groupobj holds a list of all objects, that belongs to this group
+ groupobj->AddInstanceObjects(replica);
+
+ // every object gets the reference to its dupli-group object
+ replica->SetDupliGroupObject(groupobj);
+
// done with replica
replica->Release();
}
@@ -1017,6 +1024,20 @@ int KX_Scene::NewRemoveObject(class CValue* gameobj)
m_timemgr->RemoveTimeProperty(propval);
}
}
+
+ // if the object is the dupligroup proxy, you have to cleanup all m_pDupliGroupObject's in all
+ // instances refering to this group
+ if(newobj->GetInstanceObjects()) {
+ for (int i = 0; i < newobj->GetInstanceObjects()->GetCount(); i++) {
+ KX_GameObject* instance = (KX_GameObject*)newobj->GetInstanceObjects()->GetValue(i);
+ instance->RemoveDupliGroupObject();
+ }
+ }
+
+ // if this object was part of a group, make sure to remove it from that group's instance list
+ KX_GameObject* group = newobj->GetDupliGroupObject();
+ if (group)
+ group->RemoveInstanceObject(newobj);
newobj->RemoveMeshes();
ret = 1;