Prevent adding objects to be added to a group which is used as dupli-group for this...
authorSergey Sharybin <sergey.vfx@gmail.com>
Tue, 24 Apr 2012 16:35:20 +0000 (16:35 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Tue, 24 Apr 2012 16:35:20 +0000 (16:35 +0000)
when using "Add Selected to Active Group" operator,

source/blender/editors/object/object_group.c

index 34410b87e794139ea25bd55ae282f6adb2b74a45..3867b1e34cb1e59902b35d223a4050bbc757633b 100644 (file)
@@ -65,7 +65,7 @@ static int objects_add_active_exec(bContext *C, wmOperator *op)
        Scene *scene= CTX_data_scene(C);
        Object *ob= OBACT;
        Group *group;
-       int ok = 0;
+       int ok = 0, cycle = 0;
        
        if (!ob) return OPERATOR_CANCELLED;
        
@@ -76,7 +76,10 @@ static int objects_add_active_exec(bContext *C, wmOperator *op)
                if (object_in_group(ob, group)) {
                        /* Assign groups to selected objects */
                        CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) {
-                               add_to_group(group, base->object, scene, base);
+                               if (base->object->dup_group != group)
+                                       add_to_group(group, base->object, scene, base);
+                               else
+                                       cycle = 1;
                                ok = 1;
                        }
                        CTX_DATA_END;
@@ -84,6 +87,8 @@ static int objects_add_active_exec(bContext *C, wmOperator *op)
        }
        
        if (!ok) BKE_report(op->reports, RPT_ERROR, "Active Object contains no groups");
+       if (cycle)
+               BKE_report(op->reports, RPT_WARNING, "Skipped some groups because of cycle detected");
        
        DAG_scene_sort(bmain, scene);
        WM_event_add_notifier(C, NC_GROUP|NA_EDITED, NULL);