diff options
author | Benoit Bolsee <benoit.bolsee@online.be> | 2008-09-07 14:47:33 +0400 |
---|---|---|
committer | Benoit Bolsee <benoit.bolsee@online.be> | 2008-09-07 14:47:33 +0400 |
commit | 0bf03ef2f16870aa7a86c33accb4ba69de50c256 (patch) | |
tree | 2f7255b570c3f7d23d4c003d97c4509d456cab90 /source | |
parent | 7666666992d312143a4ca44aaa334daf6ff26040 (diff) |
BGE patch: Simulate dupligroup operation when parent and child are not active/inactive at the same time: don't convert the child. This unusual situation is used in Apricot for testing.
Diffstat (limited to 'source')
-rw-r--r-- | source/gameengine/Converter/BL_BlenderDataConversion.cpp | 23 | ||||
-rw-r--r-- | source/gameengine/Converter/KX_BlenderSceneConverter.cpp | 12 |
2 files changed, 31 insertions, 4 deletions
diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 15e65ac9fe5..05d4f45b634 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -2218,11 +2218,28 @@ void BL_ConvertBlenderObjects(struct Main* maggie, { // special case: the parent and child object are not in the same layer. // This weird situation is used in Apricot for test purposes. - // Resolve it by breaking the parent relationship + // Resolve it by not converting the child childobj->GetSGNode()->DisconnectFromParent(); delete pcit->m_gamechildnode; - // This leave the child object is an incorrect position: its local position becomes - // the global position but we don't care: the child should be in an invisble layer + // Now destroy the child object but also all its descendent that may already be linked + // Remove the child reference in the local list! + // Note: there may be descendents already if the children of the child were processed + // by this loop before the child. In that case, we must remove the children also + CListValue* childrenlist = (CListValue*)childobj->PyGetChildrenRecursive(childobj); + childrenlist->Add(childobj->AddRef()); + for ( i=0;i<childrenlist->GetCount();i++) + { + KX_GameObject* obj = static_cast<KX_GameObject*>(childrenlist->GetValue(i)); + if (templist->RemoveValue(obj)) + obj->Release(); + if (sumolist->RemoveValue(obj)) + obj->Release(); + if (logicbrick_conversionlist->RemoveValue(obj)) + obj->Release(); + } + childrenlist->Release(); + // now destroy recursively + kxscene->RemoveObject(childobj); continue; } diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp index 1f5b578d441..4734b84de54 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp @@ -496,7 +496,17 @@ void KX_BlenderSceneConverter::RegisterGameObject( void KX_BlenderSceneConverter::UnregisterGameObject( KX_GameObject *gameobject) { - m_map_gameobject_to_blender.remove(CHashedPtr(gameobject)); + CHashedPtr gptr(gameobject); + struct Object **bobp= m_map_gameobject_to_blender[gptr]; + if (bobp) { + CHashedPtr bptr(*bobp); + KX_GameObject **gobp= m_map_blender_to_gameobject[bptr]; + if (gobp && *gobp == gameobject) + // also maintain m_map_blender_to_gameobject if the gameobject + // being removed is matching the blender object + m_map_blender_to_gameobject.remove(bptr); + m_map_gameobject_to_blender.remove(gptr); + } } |