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>2012-10-07 04:09:02 +0400
committerMitchell Stokes <mogurijin@gmail.com>2012-10-07 04:09:02 +0400
commit7beff06950a9811a9689ab2d04f8ca4d573d1436 (patch)
tree28c1d83d556c4af2fa1adece16c15f544bcccaa4 /source/gameengine/Ketsji/KX_Scene.cpp
parente7db06ad9db5a1a05b00fc835038d4366d637851 (diff)
BGE: Committing patch [#31442] "API improvements: Group references python api, for better control over groups and instances" by Martin Sell (moerdn). This patch adds a member and a group property to KX_GameObject:
* KX_GameObject.member returns the list of group members if the object is a group object, otherwise None is returned * KX_GameObject.group returns the group object that the object belongs to or None if the object is not part of a group
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;