BGE fix: Parenting the object to itself crashes BGE + stubs update
authorDalai Felinto <dfelinto@gmail.com>
Wed, 31 Mar 2010 22:49:59 +0000 (22:49 +0000)
committerDalai Felinto <dfelinto@gmail.com>
Wed, 31 Mar 2010 22:49:59 +0000 (22:49 +0000)
it may happen if you start doing exec, setParent, ... in Python
not a big deal, but to crash Blender is always bad

source/blenderplayer/bad_level_call_stubs/stubs.c
source/gameengine/Ketsji/KX_GameObject.cpp

index f4ac79841c697e38c4b0f9283603c7b676a46c63..f0d532f4356f56348807d49d29211afaeea228e4 100644 (file)
@@ -186,6 +186,8 @@ int WM_keymap_item_compare(struct wmKeyMapItem *k1, struct wmKeyMapItem *k2){ret
 
 
 /* rna editors */
+int insert_vert_fcurve(struct FCurve *fcu, float x, float y, short flag){return 0;}
+void delete_fcurve_key(struct FCurve *fcu, int index, short do_recalc){}
 struct KeyingSetInfo *ANIM_keyingset_info_find_named (const char name[]){return (struct KeyingSetInfo *) NULL;}
 struct KeyingSet *ANIM_scene_get_active_keyingset (struct Scene *scene){return (struct KeyingSet *) NULL;}
 int ANIM_scene_get_keyingset_index(struct Scene *scene, struct KeyingSet *ks){return 0;}
index 9cb7e80223574570106c738f208991260bb44730..637b874ef5e68967d9d153437ef583e7d1965847 100644 (file)
@@ -238,7 +238,8 @@ void KX_GameObject::SetParent(KX_Scene *scene, KX_GameObject* obj, bool addToCom
                GetSGNode() &&                  // object is not zombi
                obj->GetSGNode() &&             // object is not zombi
                GetSGNode()->GetSGParent() != obj->GetSGNode() &&       // not already parented to same object
-               !GetSGNode()->IsAncessor(obj->GetSGNode()))                     // no parenting loop
+               !GetSGNode()->IsAncessor(obj->GetSGNode()) &&           // no parenting loop
+               this != obj)                                                                            // not the object itself
        {
                // Make sure the objects have some scale
                MT_Vector3 scale1 = NodeGetWorldScaling();