Revision: 16404
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16404
Author:   ben2610
Date:     2008-09-07 12:47:33 +0200 (Sun, 07 Sep 2008)

Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/blender/source/gameengine/Converter/BL_BlenderDataConversion.cpp
    trunk/blender/source/gameengine/Converter/KX_BlenderSceneConverter.cpp

Modified: trunk/blender/source/gameengine/Converter/BL_BlenderDataConversion.cpp
===================================================================
--- trunk/blender/source/gameengine/Converter/BL_BlenderDataConversion.cpp      
2008-09-07 10:24:02 UTC (rev 16403)
+++ trunk/blender/source/gameengine/Converter/BL_BlenderDataConversion.cpp      
2008-09-07 10:47:33 UTC (rev 16404)
@@ -2218,11 +2218,28 @@
                {
                        // 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;
                }
 

Modified: trunk/blender/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
===================================================================
--- trunk/blender/source/gameengine/Converter/KX_BlenderSceneConverter.cpp      
2008-09-07 10:24:02 UTC (rev 16403)
+++ trunk/blender/source/gameengine/Converter/KX_BlenderSceneConverter.cpp      
2008-09-07 10:47:33 UTC (rev 16404)
@@ -496,7 +496,17 @@
 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);
+       }
 }
 
 


_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to