Rename 'Object Center' to 'Centroid'. This makes the Center/Center Cursor etc popup...
[blender.git] / source / blender / editors / object / object_group.c
index c83f3022c7c629461b244e464a2ad718c3019702..1e5b93aa6dc1946747ae2b6bb0cf756282b860b2 100644 (file)
@@ -60,7 +60,7 @@
 static int objects_add_active_exec(bContext *C, wmOperator *op)
 {
        Scene *scene= CTX_data_scene(C);
-       Object *ob= OBACT, *obt;
+       Object *ob= OBACT;
        Group *group;
        int ok = 0;
        
@@ -73,11 +73,7 @@ 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) {
-                               obt= base->object;
-                               add_to_group(group, obt);
-                               obt->flag |= OB_FROMGROUP;
-                               base->flag |= OB_FROMGROUP;
-                               base->object->recalc= OB_RECALC_OB;
+                               add_to_group(group, base->object, scene, base);
                                ok = 1;
                        }
                        CTX_DATA_END;
@@ -110,7 +106,7 @@ void GROUP_OT_objects_add_active(wmOperatorType *ot)
 static int objects_remove_active_exec(bContext *C, wmOperator *op)
 {
        Scene *scene= CTX_data_scene(C);
-       Object *ob= OBACT, *obt;
+       Object *ob= OBACT;
        Group *group;
        int ok = 0;
        
@@ -123,11 +119,7 @@ static int objects_remove_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) {
-                               obt= base->object;
-                               rem_from_group(group, obt);
-                               obt->flag &= ~OB_FROMGROUP;
-                               base->flag &= ~OB_FROMGROUP;
-                               base->object->recalc= OB_RECALC_OB;
+                               rem_from_group(group, base->object, scene, base);
                                ok = 1;
                        }
                        CTX_DATA_END;
@@ -165,11 +157,7 @@ static int group_objects_remove_exec(bContext *C, wmOperator *op)
        CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) {
                group = NULL;
                while((group = find_group(base->object, group)))
-                       rem_from_group(group, base->object);
-
-               base->object->flag &= ~OB_FROMGROUP;
-               base->flag &= ~OB_FROMGROUP;
-               base->object->recalc= OB_RECALC_OB;
+                       rem_from_group(group, base->object, scene, base);
        }
        CTX_DATA_END;
 
@@ -198,17 +186,14 @@ static int group_create_exec(bContext *C, wmOperator *op)
 {
        Scene *scene= CTX_data_scene(C);
        Group *group= NULL;
-       char gid[32]; //group id
+       char name[32]; /* id name */
        
-       RNA_string_get(op->ptr, "GID", gid);
+       RNA_string_get(op->ptr, "name", name);
        
-       group= add_group(gid);
+       group= add_group(name);
                
        CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) {
-               add_to_group(group, base->object);
-               base->object->flag |= OB_FROMGROUP;
-               base->flag |= OB_FROMGROUP;
-               base->object->recalc= OB_RECALC_OB;
+               add_to_group(group, base->object, scene, base);
        }
        CTX_DATA_END;
 
@@ -218,12 +203,12 @@ static int group_create_exec(bContext *C, wmOperator *op)
        return OPERATOR_FINISHED;
 }
 
-void GROUP_OT_group_create(wmOperatorType *ot)
+void GROUP_OT_create(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Create New Group";
-       ot->description = "Create an object group.";
-       ot->idname= "GROUP_OT_group_create";
+       ot->description = "Create an object group from selected objects.";
+       ot->idname= "GROUP_OT_create";
        
        /* api callbacks */
        ot->exec= group_create_exec;    
@@ -232,7 +217,7 @@ void GROUP_OT_group_create(wmOperatorType *ot)
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
        
-       RNA_def_string(ot->srna, "GID", "Group", 32, "Name", "Name of the new group");
+       RNA_def_string(ot->srna, "name", "Group", 32, "Name", "Name of the new group");
 }
 
 /****************** properties window operators *********************/
@@ -259,9 +244,7 @@ static int group_add_exec(bContext *C, wmOperator *op)
                group= BLI_findlink(&bmain->group, value);
 
        if(group) {
-               add_to_group(group, ob);
-               ob->flag |= OB_FROMGROUP;
-               base->flag |= OB_FROMGROUP;
+               add_to_group(group, ob, scene, NULL); /* base will be used if found */
        }
 
        WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
@@ -275,18 +258,14 @@ static EnumPropertyItem group_items[]= {
 
 static EnumPropertyItem *group_itemf(bContext *C, PointerRNA *ptr, int *free)
 {      
+       Main *bmain= CTX_data_main(C);
+       Group *group;
        EnumPropertyItem tmp = {0, "", 0, "", ""};
        EnumPropertyItem *item= NULL;
-       Main *bmain;
-       Group *group;
        int a, totitem= 0;
        
-       if(!C) /* needed for docs */
-               return group_items;
-       
        RNA_enum_items_add_value(&item, &totitem, group_items, -1);
 
-       bmain= CTX_data_main(C);
        if(bmain->group.first)
                RNA_enum_item_add_separator(&item, &totitem);
 
@@ -298,7 +277,6 @@ static EnumPropertyItem *group_itemf(bContext *C, PointerRNA *ptr, int *free)
        }
 
        RNA_enum_item_end(&item, &totitem);
-
        *free= 1;
 
        return item;
@@ -328,21 +306,11 @@ static int group_remove_exec(bContext *C, wmOperator *op)
        Scene *scene= CTX_data_scene(C);
        Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
        Group *group= CTX_data_pointer_get_type(C, "group", &RNA_Group).data;
-       Base *base;
 
        if(!ob || !group)
                return OPERATOR_CANCELLED;
 
-       base= object_in_scene(ob, scene);
-       if(!base)
-               return OPERATOR_CANCELLED;
-
-       rem_from_group(group, ob);
-
-       if(find_group(ob, NULL) == NULL) {
-               ob->flag &= ~OB_FROMGROUP;
-               base->flag &= ~OB_FROMGROUP;
-       }
+       rem_from_group(group, ob, scene, NULL); /* base will be used if found */
 
        WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);