From 61c66a996ca5e590097e8864df027602493f58f4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 6 Feb 2015 18:10:46 +1100 Subject: Outliner: DragDrop objects to groups Support drag&drop objects to groups in the outliner. D989 by @lichtwerk --- source/blender/editors/object/object_group.c | 53 +++------------------------- 1 file changed, 4 insertions(+), 49 deletions(-) (limited to 'source/blender/editors/object/object_group.c') diff --git a/source/blender/editors/object/object_group.c b/source/blender/editors/object/object_group.c index 20e2e22cdf8..3c43f2729bd 100644 --- a/source/blender/editors/object/object_group.c +++ b/source/blender/editors/object/object_group.c @@ -61,47 +61,6 @@ /********************* 3d view operators ***********************/ -static bool group_link_early_exit_check(Group *group, Object *object) -{ - GroupObject *group_object; - - for (group_object = group->gobject.first; group_object; group_object = group_object->next) { - if (group_object->ob == object) { - return true; - } - } - - return false; -} - -static bool check_object_instances_group_recursive(Object *object, Group *group) -{ - if (object->dup_group) { - Group *dup_group = object->dup_group; - if ((dup_group->id.flag & LIB_DOIT) == 0) { - /* Cycle already exists in groups, let's prevent further crappyness */ - return true; - } - /* flag the object to identify cyclic dependencies in further dupli groups */ - dup_group->id.flag &= ~LIB_DOIT; - - if (dup_group == group) - return true; - else { - GroupObject *gob; - for (gob = dup_group->gobject.first; gob; gob = gob->next) { - if (check_object_instances_group_recursive(gob->ob, group)) - return true; - } - } - - /* un-flag the object, it's allowed to have the same group multiple times in parallel */ - dup_group->id.flag |= LIB_DOIT; - } - - return false; -} - /* can be called with C == NULL */ static EnumPropertyItem *group_object_active_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) { @@ -185,15 +144,12 @@ static int objects_add_active_exec(bContext *C, wmOperator *op) if (!BKE_group_object_exists(group, ob)) continue; - /* for recursive check */ - BKE_main_id_tag_listbase(&bmain->group, true); - CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) { - if (group_link_early_exit_check(group, base->object)) + if (BKE_group_object_exists(group, base->object)) continue; - if (!check_object_instances_group_recursive(base->object, group)) { + if (!BKE_group_object_cyclic_check(bmain, base->object, group)) { BKE_group_object_add(group, base->object, scene, base); updated = true; } @@ -486,7 +442,7 @@ static int group_link_exec(bContext *C, wmOperator *op) * we could sckip all the dependency check and just consider * operator is finished. */ - if (group_link_early_exit_check(group, ob)) { + if (BKE_group_object_exists(group, ob)) { return OPERATOR_FINISHED; } @@ -495,8 +451,7 @@ static int group_link_exec(bContext *C, wmOperator *op) * It is also bad idea to add object to group which is in group which * contains our current object. */ - BKE_main_id_tag_listbase(&bmain->group, true); - if (check_object_instances_group_recursive(ob, group)) { + if (BKE_group_object_cyclic_check(bmain, ob, group)) { BKE_report(op->reports, RPT_ERROR, "Could not add the group because of dependency cycle detected"); return OPERATOR_CANCELLED; } -- cgit v1.2.3