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.

This commit is contained in:
Benoit Bolsee 2008-09-07 10:47:33 +00:00
parent 7666666992
commit 0bf03ef2f1
2 changed files with 31 additions and 4 deletions

@ -2218,11 +2218,28 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
{ {
// special case: the parent and child object are not in the same layer. // special case: the parent and child object are not in the same layer.
// This weird situation is used in Apricot for test purposes. // 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(); childobj->GetSGNode()->DisconnectFromParent();
delete pcit->m_gamechildnode; delete pcit->m_gamechildnode;
// This leave the child object is an incorrect position: its local position becomes // Now destroy the child object but also all its descendent that may already be linked
// the global position but we don't care: the child should be in an invisble layer // 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; continue;
} }

@ -496,7 +496,17 @@ void KX_BlenderSceneConverter::RegisterGameObject(
void KX_BlenderSceneConverter::UnregisterGameObject( void KX_BlenderSceneConverter::UnregisterGameObject(
KX_GameObject *gameobject) 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);
}
} }