diff options
-rw-r--r-- | source/blender/blenkernel/BKE_object.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 8 | ||||
-rw-r--r-- | source/blender/editors/object/object_relations.c | 16 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_buttons.c | 11 |
4 files changed, 15 insertions, 22 deletions
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index b5a5090a5eb..828b0b47e3a 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -120,6 +120,8 @@ void BKE_scene_foreach_display_point( const short flag, void (*func_cb)(const float[3], void *), void *user_data); +int BKE_object_parent_loop_check(const struct Object *parent, const struct Object *ob); + void solve_tracking (struct Object *ob, float targetmat[][4]); int ray_hit_boundbox(struct BoundBox *bb, float ray_start[3], float ray_normal[3]); diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 13b6919683c..29494f02d10 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2473,6 +2473,14 @@ void object_tfm_restore(Object *ob, void *obtfm_pt) copy_m4_m4(ob->imat, obtfm->imat); } +int BKE_object_parent_loop_check(const Object *par, const Object *ob) +{ + /* test if 'ob' is a parent somewhere in par's parents */ + if(par == NULL) return 0; + if(ob == par) return 1; + return BKE_object_parent_loop_check(par->parent, ob); +} + /* proxy rule: lib_object->proxy_from == the one we borrow from, only set temporal and cleared here */ /* local_object->proxy == pointer to library object, saved in files and read */ diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 6b517b6eeb0..1ba0157e8d3 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -512,19 +512,9 @@ static EnumPropertyItem prop_make_parent_types[] = { {0, NULL, 0, NULL, NULL} }; -static int test_parent_loop(Object *par, Object *ob) -{ - /* test if 'ob' is a parent somewhere in par's parents */ - - if(par == NULL) return 0; - if(ob == par) return 1; - - return test_parent_loop(par->parent, ob); -} - void ED_object_parent(Object *ob, Object *par, int type, const char *substr) { - if(!par || test_parent_loop(par, ob)) { + if (!par || BKE_object_parent_loop_check(par, ob)) { ob->parent= NULL; ob->partype= PAROBJECT; ob->parsubstr[0]= 0; @@ -593,7 +583,7 @@ static int parent_set_exec(bContext *C, wmOperator *op) if(ob!=par) { - if( test_parent_loop(par, ob) ) { + if (BKE_object_parent_loop_check(par, ob)) { BKE_report(op->reports, RPT_ERROR, "Loop in parents"); } else { @@ -766,7 +756,7 @@ static int parent_noinv_set_exec(bContext *C, wmOperator *op) /* context iterator */ CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { if (ob != par) { - if (test_parent_loop(par, ob)) { + if (BKE_object_parent_loop_check(par, ob)) { BKE_report(op->reports, RPT_ERROR, "Loop in parents"); } else { diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index d2689fad8c2..1b923c7a0cd 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -59,6 +59,7 @@ #include "BKE_mesh.h" #include "BKE_screen.h" #include "BKE_deform.h" +#include "BKE_object.h" #include "WM_api.h" #include "WM_types.h" @@ -1105,14 +1106,6 @@ static void v3d_editmetaball_buts(uiLayout *layout, Object *ob) } } -/* test if 'ob' is a parent somewhere in par's parents */ -static int test_parent_loop(Object *par, Object *ob) -{ - if(par == NULL) return 0; - if(ob == par) return 1; - return test_parent_loop(par->parent, ob); -} - static void do_view3d_region_buttons(bContext *C, void *UNUSED(index), int event) { Main *bmain= CTX_data_main(C); @@ -1144,7 +1137,7 @@ static void do_view3d_region_buttons(bContext *C, void *UNUSED(index), int event /* note; this case also used for parbone */ case B_OBJECTPANELPARENT: if(ob) { - if(ob->id.lib || test_parent_loop(ob->parent, ob) ) + if (ob->id.lib || BKE_object_parent_loop_check(ob->parent, ob)) ob->parent= NULL; else { DAG_scene_sort(bmain, scene); |