fix for crash when a parent compound object didn't get a physics controller.
authorCampbell Barton <ideasman42@gmail.com>
Thu, 27 Aug 2009 23:29:07 +0000 (23:29 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 27 Aug 2009 23:29:07 +0000 (23:29 +0000)
also show this in the UI.

source/blender/src/buttons_logic.c
source/gameengine/Converter/BL_BlenderDataConversion.cpp

index 0412aa72b37f5391b6dc82a636eb0a94e57eb576..6117c10c718859218101b07cf13ddbe1ef94c8f7 100644 (file)
@@ -3513,14 +3513,20 @@ static void buttons_bullet(uiBlock *block, Object *ob)
                        }
                        if (ob->body_type!=OB_BODY_TYPE_SOFT)
                        {
-                               if (ob->parent)
-                                       uiDefButBitI(block, TOG, OB_CHILD, B_REDR, "Add to parent", 240,105,110,19, 
-                                                       &ob->gameflag, 0, 0, 0, 0, 
-                                                       "Add this shape to the parent compound shape");
-                               else
-                                       uiDefButBitI(block, TOG, OB_CHILD, B_REDR, "Compound", 240,105,110,19, 
-                                                       &ob->gameflag, 0, 0, 0, 0, 
-                                                       "Create a compound shape with the children's shape that are tagged for addition");
+                               if (ob->parent) {
+                                       if(ob->parent->gameflag & (OB_DYNAMIC|OB_COLLISION)) {
+                                               uiDefButBitI(block, TOG, OB_CHILD, B_REDR, "Add to parent", 240,105,110,19, 
+                                                               &ob->gameflag, 0, 0, 0, 0, 
+                                                               "Add this shape to the parent compound shape");
+                                       }
+                               }
+                               else {
+                                       if(ob->gameflag & (OB_DYNAMIC|OB_COLLISION)) {
+                                               uiDefButBitI(block, TOG, OB_CHILD, B_REDR, "Compound", 240,105,110,19, 
+                                                               &ob->gameflag, 0, 0, 0, 0, 
+                                                               "Create a compound shape with the children's shape that are tagged for addition");
+                                       }
+                               }
                        }
                }
                uiBlockEndAlign(block);
index d2e6bbb43f7d4b86ade1c6bd0602392c09bbdf47..c2566caba1e78e265131dcf84da727e671f43d04 100644 (file)
@@ -1381,7 +1381,9 @@ void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj,
        bool isCompoundChild = false;
        bool hasCompoundChildren = !parent && (blenderobject->gameflag & OB_CHILD);
 
-       if (parent/* && (parent->gameflag & OB_DYNAMIC)*/) {
+       /* When the parent is not OB_DYNAMIC and has no OB_COLLISION then it gets no bullet controller
+        * and cant be apart of the parents compound shape */
+       if (parent && (parent->gameflag & (OB_DYNAMIC | OB_COLLISION))) {
                
                if ((parent->gameflag & OB_CHILD) != 0 && (blenderobject->gameflag & OB_CHILD))
                {