Merge branch 'master' into blender2.8
[blender.git] / source / blender / editors / object / object_edit.c
index 7b90a52..9bc0189 100644 (file)
@@ -499,16 +499,16 @@ static int editmode_toggle_poll(bContext *C)
 
 void OBJECT_OT_editmode_toggle(wmOperatorType *ot)
 {
-       
+
        /* identifiers */
        ot->name = "Toggle Editmode";
        ot->description = "Toggle object's editmode";
        ot->idname = "OBJECT_OT_editmode_toggle";
-       
+
        /* api callbacks */
        ot->exec = editmode_toggle_exec;
        ot->poll = editmode_toggle_poll;
-       
+
        /* flags */
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
@@ -522,7 +522,7 @@ static int posemode_exec(bContext *C, wmOperator *op)
        Object *obact = base->object;
        const int mode_flag = OB_MODE_POSE;
        bool is_mode_set = (obact->mode & mode_flag) != 0;
-       
+
        if (!is_mode_set) {
                if (!ED_object_mode_compat_set(C, obact, mode_flag, op->reports)) {
                        return OPERATOR_CANCELLED;
@@ -581,17 +581,17 @@ static int posemode_exec(bContext *C, wmOperator *op)
        return OPERATOR_FINISHED;
 }
 
-void OBJECT_OT_posemode_toggle(wmOperatorType *ot) 
+void OBJECT_OT_posemode_toggle(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name = "Toggle Pose Mode";
        ot->idname = "OBJECT_OT_posemode_toggle";
        ot->description = "Enable or disable posing/selecting bones";
-       
+
        /* api callbacks */
        ot->exec = posemode_exec;
        ot->poll = ED_operator_object_active_editable;
-       
+
        /* flag */
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
@@ -601,7 +601,7 @@ static void copy_texture_space(Object *to, Object *ob)
 {
        float *poin1 = NULL, *poin2 = NULL;
        short texflag = 0;
-       
+
        if (ob->type == OB_MESH) {
                texflag = ((Mesh *)ob->data)->texflag;
                poin2 = ((Mesh *)ob->data)->loc;
@@ -616,7 +616,7 @@ static void copy_texture_space(Object *to, Object *ob)
        }
        else
                return;
-               
+
        if (to->type == OB_MESH) {
                ((Mesh *)to->data)->texflag = texflag;
                poin1 = ((Mesh *)to->data)->loc;
@@ -631,9 +631,9 @@ static void copy_texture_space(Object *to, Object *ob)
        }
        else
                return;
-       
+
        memcpy(poin1, poin2, 9 * sizeof(float));  /* this was noted in DNA_mesh, curve, mball */
-       
+
        if (to->type == OB_MESH) {
                /* pass */
        }
@@ -643,7 +643,7 @@ static void copy_texture_space(Object *to, Object *ob)
        else {
                BKE_curve_texspace_calc(to->data);
        }
-       
+
 }
 
 /* UNUSED, keep in case we want to copy functionality for use elsewhere */
@@ -654,11 +654,11 @@ static void copy_attr(Main *bmain, Scene *scene, ViewLayer *view_layer, short ev
        Curve *cu, *cu1;
        Nurb *nu;
        bool do_depgraph_update = false;
-       
+
        if (ID_IS_LINKED(scene)) return;
 
        if (!(ob = OBACT(view_layer))) return;
-       
+
        if (BKE_object_is_in_editmode(ob)) {
                /* obedit_copymenu(); */
                return;
@@ -674,7 +674,7 @@ static void copy_attr(Main *bmain, Scene *scene, ViewLayer *view_layer, short ev
                if (base != BASACT(view_layer)) {
                        if (TESTBASELIB(base)) {
                                DEG_id_tag_update(&base->object->id, OB_RECALC_DATA);
-                               
+
                                if (event == 1) {  /* loc */
                                        copy_v3_v3(base->object->loc, ob->loc);
                                        copy_v3_v3(base->object->dloc, ob->dloc);
@@ -704,7 +704,7 @@ static void copy_attr(Main *bmain, Scene *scene, ViewLayer *view_layer, short ev
                                        base->object->dupoff = ob->dupoff;
                                        base->object->dupsta = ob->dupsta;
                                        base->object->dupend = ob->dupend;
-                                       
+
                                        base->object->transflag &= ~OB_DUPLI;
                                        base->object->transflag |= (ob->transflag & OB_DUPLI);
 
@@ -716,7 +716,7 @@ static void copy_attr(Main *bmain, Scene *scene, ViewLayer *view_layer, short ev
                                        copy_texture_space(base->object, ob);
                                }
                                else if (event == 18) {   /* font settings */
-                                       
+
                                        if (base->object->type == ob->type) {
                                                cu = ob->data;
                                                cu1 = base->object->data;
@@ -749,25 +749,25 @@ static void copy_attr(Main *bmain, Scene *scene, ViewLayer *view_layer, short ev
                                                        id_us_min(&cu1->vfontbi->id);
                                                cu1->vfontbi = cu->vfontbi;
                                                id_us_plus((ID *)cu1->vfontbi);
-                                               
+
                                                BLI_strncpy(cu1->family, cu->family, sizeof(cu1->family));
-                                               
+
                                                DEG_id_tag_update(&base->object->id, OB_RECALC_DATA);
                                        }
                                }
                                else if (event == 19) {   /* bevel settings */
-                                       
+
                                        if (ELEM(base->object->type, OB_CURVE, OB_FONT)) {
                                                cu = ob->data;
                                                cu1 = base->object->data;
-                                               
+
                                                cu1->bevobj = cu->bevobj;
                                                cu1->taperobj = cu->taperobj;
                                                cu1->width = cu->width;
                                                cu1->bevresol = cu->bevresol;
                                                cu1->ext1 = cu->ext1;
                                                cu1->ext2 = cu->ext2;
-                                               
+
                                                DEG_id_tag_update(&base->object->id, OB_RECALC_DATA);
                                        }
                                }
@@ -776,17 +776,17 @@ static void copy_attr(Main *bmain, Scene *scene, ViewLayer *view_layer, short ev
                                        if (ELEM(base->object->type, OB_CURVE, OB_FONT)) {
                                                cu = ob->data;
                                                cu1 = base->object->data;
-                                               
+
                                                cu1->resolu = cu->resolu;
                                                cu1->resolu_ren = cu->resolu_ren;
-                                               
+
                                                nu = cu1->nurb.first;
-                                               
+
                                                while (nu) {
                                                        nu->resolu = cu1->resolu;
                                                        nu = nu->next;
                                                }
-                                               
+
                                                DEG_id_tag_update(&base->object->id, OB_RECALC_DATA);
                                        }
                                }
@@ -810,13 +810,13 @@ static void copy_attr(Main *bmain, Scene *scene, ViewLayer *view_layer, short ev
                                else if (event == 22) {
                                        /* Copy the constraint channels over */
                                        BKE_constraints_copy(&base->object->constraints, &ob->constraints, true);
-                                       
+
                                        do_depgraph_update = true;
                                }
                                else if (event == 23) {
                                        base->object->softflag = ob->softflag;
                                        if (base->object->soft) sbFree(base->object->soft);
-                                       
+
                                        base->object->soft = copy_softbody(ob->soft, 0);
 
                                        if (!modifiers_findByType(base->object, eModifierType_Softbody)) {
@@ -843,7 +843,7 @@ static void copy_attr(Main *bmain, Scene *scene, ViewLayer *view_layer, short ev
                                        if (ELEM(base->object->type, OB_CURVE, OB_SURF)) {
                                                cu = ob->data;
                                                cu1 = base->object->data;
-                                               
+
                                                if (cu->flag & CU_UV_ORCO)
                                                        cu1->flag |= CU_UV_ORCO;
                                                else
@@ -862,7 +862,7 @@ static void copy_attr(Main *bmain, Scene *scene, ViewLayer *view_layer, short ev
                        }
                }
        }
-       
+
        if (do_depgraph_update)
                DEG_relations_tag_update(bmain);
 }
@@ -872,36 +872,36 @@ static void UNUSED_FUNCTION(copy_attr_menu) (Main *bmain, Scene *scene, ViewLaye
        Object *ob;
        short event;
        char str[512];
-       
+
        if (!(ob = OBACT(view_layer))) return;
-       
+
        if (obedit) {
 /*             if (ob->type == OB_MESH) */
 /* XXX                 mesh_copy_menu(); */
                return;
        }
-       
+
        /* Object Mode */
-       
+
        /* If you change this menu, don't forget to update the menu in header_view3d.c
         * view3d_edit_object_copyattrmenu() and in toolbox.c
         */
-       
+
        strcpy(str,
               "Copy Attributes %t|Location %x1|Rotation %x2|Size %x3|Draw Options %x4|"
               "Time Offset %x5|Dupli %x6|Object Color %x31|%l|Mass %x7|Damping %x8|All Physical Attributes %x11|Properties %x9|"
               "Logic Bricks %x10|Protected Transform %x29|%l");
-       
+
        strcat(str, "|Object Constraints %x22");
        strcat(str, "|NLA Strips %x26");
-       
+
 /* XXX if (OB_TYPE_SUPPORT_MATERIAL(ob->type)) { */
 /*             strcat(str, "|Texture Space %x17"); */
 /*     } */
-       
+
        if (ob->type == OB_FONT) strcat(str, "|Font Settings %x18|Bevel Settings %x19");
        if (ob->type == OB_CURVE) strcat(str, "|Bevel Settings %x19|UV Orco %x28");
-       
+
        if ((ob->type == OB_FONT) || (ob->type == OB_CURVE)) {
                strcat(str, "|Curve Resolution %x25");
        }
@@ -911,16 +911,16 @@ static void UNUSED_FUNCTION(copy_attr_menu) (Main *bmain, Scene *scene, ViewLaye
        }
 
        if (ob->soft) strcat(str, "|Soft Body Settings %x23");
-       
+
        strcat(str, "|Pass Index %x30");
-       
+
        if (ob->type == OB_MESH || ob->type == OB_CURVE || ob->type == OB_LATTICE || ob->type == OB_SURF) {
                strcat(str, "|Modifiers ... %x24");
        }
 
        event = pupmenu(str);
        if (event <= 0) return;
-       
+
        copy_attr(bmain, scene, view_layer, event);
 }
 
@@ -966,16 +966,16 @@ static int forcefield_toggle_exec(bContext *C, wmOperator *UNUSED(op))
 
 void OBJECT_OT_forcefield_toggle(wmOperatorType *ot)
 {
-       
+
        /* identifiers */
        ot->name = "Toggle Force Field";
        ot->description = "Toggle object's force field";
        ot->idname = "OBJECT_OT_forcefield_toggle";
-       
+
        /* api callbacks */
        ot->exec = forcefield_toggle_exec;
        ot->poll = ED_operator_object_active_editable;
-       
+
        /* flags */
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
@@ -993,7 +993,7 @@ void ED_objects_recalculate_paths(bContext *C, Scene *scene)
        struct Main *bmain = CTX_data_main(C);
        Depsgraph *depsgraph = CTX_data_depsgraph(C);
        ListBase targets = {NULL, NULL};
-       
+
        /* loop over objects in scene */
        CTX_DATA_BEGIN(C, Object *, ob, selected_editable_objects)
        {
@@ -1002,11 +1002,11 @@ void ED_objects_recalculate_paths(bContext *C, Scene *scene)
                animviz_get_object_motionpaths(ob, &targets);
        }
        CTX_DATA_END;
-       
+
        /* recalculate paths, then free */
        animviz_calc_motionpaths(depsgraph, bmain, scene, &targets);
        BLI_freelistN(&targets);
-       
+
        /* tag objects for copy on write - so paths will draw/redraw */
        CTX_DATA_BEGIN(C, Object *, ob, selected_editable_objects)
        {
@@ -1022,18 +1022,18 @@ void ED_objects_recalculate_paths(bContext *C, Scene *scene)
 static int object_calculate_paths_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
 {
        Object *ob = CTX_data_active_object(C);
-       
+
        if (ob == NULL)
                return OPERATOR_CANCELLED;
-       
+
        /* set default settings from existing/stored settings */
        {
                bAnimVizSettings *avs = &ob->avs;
-               
+
                RNA_int_set(op->ptr, "start_frame", avs->path_sf);
                RNA_int_set(op->ptr, "end_frame", avs->path_ef);
        }
-       
+
        /* show popup dialog to allow editing of range... */
        /* FIXME: hardcoded dimensions here are just arbitrary */
        return WM_operator_props_dialog_popup(C, op, 10 * UI_UNIT_X, 10 * UI_UNIT_Y);
@@ -1045,28 +1045,28 @@ static int object_calculate_paths_exec(bContext *C, wmOperator *op)
        Scene *scene = CTX_data_scene(C);
        int start = RNA_int_get(op->ptr, "start_frame");
        int end = RNA_int_get(op->ptr, "end_frame");
-       
+
        /* set up path data for bones being calculated */
        CTX_DATA_BEGIN(C, Object *, ob, selected_editable_objects)
        {
                bAnimVizSettings *avs = &ob->avs;
-               
+
                /* grab baking settings from operator settings */
                avs->path_sf = start;
                avs->path_ef = end;
-               
+
                /* verify that the selected object has the appropriate settings */
                animviz_verify_motionpaths(op->reports, scene, ob, NULL);
        }
        CTX_DATA_END;
-       
+
        /* calculate the paths for objects that have them (and are tagged to get refreshed) */
        ED_objects_recalculate_paths(C, scene);
-       
+
        /* notifiers for updates */
        WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
-       
-       return OPERATOR_FINISHED; 
+
+       return OPERATOR_FINISHED;
 }
 
 void OBJECT_OT_paths_calculate(wmOperatorType *ot)
@@ -1075,19 +1075,19 @@ void OBJECT_OT_paths_calculate(wmOperatorType *ot)
        ot->name = "Calculate Object Paths";
        ot->idname = "OBJECT_OT_paths_calculate";
        ot->description = "Calculate motion paths for the selected objects";
-       
+
        /* api callbacks */
        ot->invoke = object_calculate_paths_invoke;
        ot->exec = object_calculate_paths_exec;
        ot->poll = ED_operator_object_active_editable;
-       
+
        /* flags */
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-       
+
        /* properties */
-       RNA_def_int(ot->srna, "start_frame", 1, MINAFRAME, MAXFRAME, "Start", 
+       RNA_def_int(ot->srna, "start_frame", 1, MINAFRAME, MAXFRAME, "Start",
                    "First frame to calculate object paths on", MINFRAME, MAXFRAME / 2.0);
-       RNA_def_int(ot->srna, "end_frame", 250, MINAFRAME, MAXFRAME, "End", 
+       RNA_def_int(ot->srna, "end_frame", 250, MINAFRAME, MAXFRAME, "End",
                    "Last frame to calculate object paths on", MINFRAME, MAXFRAME / 2.0);
 }
 
@@ -1099,23 +1099,23 @@ static int object_update_paths_poll(bContext *C)
                Object *ob = ED_object_active_context(C);
                return (ob->avs.path_bakeflag & MOTIONPATH_BAKE_HAS_PATHS) != 0;
        }
-       
+
        return false;
 }
 
 static int object_update_paths_exec(bContext *C, wmOperator *UNUSED(op))
 {
        Scene *scene = CTX_data_scene(C);
-       
+
        if (scene == NULL)
                return OPERATOR_CANCELLED;
-               
+
        /* calculate the paths for objects that have them (and are tagged to get refreshed) */
        ED_objects_recalculate_paths(C, scene);
-       
+
        /* notifiers for updates */
        WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
-       
+
        return OPERATOR_FINISHED;
 }
 
@@ -1125,11 +1125,11 @@ void OBJECT_OT_paths_update(wmOperatorType *ot)
        ot->name = "Update Object Paths";
        ot->idname = "OBJECT_OT_paths_update";
        ot->description = "Recalculate paths for selected objects";
-       
+
        /* api callbakcs */
        ot->exec = object_update_paths_exec;
        ot->poll = object_update_paths_poll;
-       
+
        /* flags */
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
@@ -1171,14 +1171,14 @@ void ED_objects_clear_paths(bContext *C, bool only_selected)
 static int object_clear_paths_exec(bContext *C, wmOperator *op)
 {
        bool only_selected = RNA_boolean_get(op->ptr, "only_selected");
-       
+
        /* use the backend function for this */
        ED_objects_clear_paths(C, only_selected);
-       
+
        /* notifiers for updates */
        WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
-       
-       return OPERATOR_FINISHED; 
+
+       return OPERATOR_FINISHED;
 }
 
 /* operator callback/wrapper */
@@ -1196,15 +1196,15 @@ void OBJECT_OT_paths_clear(wmOperatorType *ot)
        ot->name = "Clear Object Paths";
        ot->idname = "OBJECT_OT_paths_clear";
        ot->description = "Clear path caches for all objects, hold Shift key for selected objects only";
-       
+
        /* api callbacks */
        ot->invoke = object_clear_paths_invoke;
        ot->exec = object_clear_paths_exec;
        ot->poll = ED_operator_object_active_editable;
-       
+
        /* flags */
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-       
+
        /* properties */
        ot->prop = RNA_def_boolean(ot->srna, "only_selected", false, "Only Selected",
                                   "Only clear paths from selected objects");
@@ -1273,7 +1273,7 @@ void OBJECT_OT_shade_flat(wmOperatorType *ot)
        ot->name = "Shade Flat";
        ot->description = "Render and display faces uniform, using Face Normals";
        ot->idname = "OBJECT_OT_shade_flat";
-       
+
        /* api callbacks */
        ot->poll = shade_poll;
        ot->exec = shade_smooth_exec;
@@ -1288,11 +1288,11 @@ void OBJECT_OT_shade_smooth(wmOperatorType *ot)
        ot->name = "Shade Smooth";
        ot->description = "Render and display faces smooth, using interpolated Vertex Normals";
        ot->idname = "OBJECT_OT_shade_smooth";
-       
+
        /* api callbacks */
        ot->poll = shade_poll;
        ot->exec = shade_smooth_exec;
-       
+
        /* flags */
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
@@ -1333,7 +1333,7 @@ static const EnumPropertyItem *object_mode_set_itemsf(
                /* We need at least this one! */
                RNA_enum_items_add_value(&item, &totitem, input, OB_MODE_OBJECT);
        }
-       
+
        /* On top of all the rest, GPencil Stroke Edit Mode
         * is available if there's a valid gp datablock...
         */
@@ -1403,7 +1403,7 @@ static int object_mode_set_exec(bContext *C, wmOperator *op)
                        WM_operator_name_call(C, "GPENCIL_OT_editmode_toggle", WM_OP_EXEC_REGION_WIN, NULL);
                }
        }
-       
+
        if (!ob || !ED_object_mode_compat_test(ob, mode))
                return OPERATOR_PASS_THROUGH;
 
@@ -1438,20 +1438,20 @@ static int object_mode_set_exec(bContext *C, wmOperator *op)
 void OBJECT_OT_mode_set(wmOperatorType *ot)
 {
        PropertyRNA *prop;
-       
+
        /* identifiers */
        ot->name = "Set Object Mode";
        ot->description = "Sets the object interaction mode";
        ot->idname = "OBJECT_OT_mode_set";
-       
+
        /* api callbacks */
        ot->exec = object_mode_set_exec;
-       
+
        ot->poll = object_mode_set_poll; //ED_operator_object_active_editable;
-       
+
        /* flags */
        ot->flag = 0; /* no register/undo here, leave it to operators being called */
-       
+
        ot->prop = RNA_def_enum(ot->srna, "mode", rna_enum_object_mode_items, OB_MODE_OBJECT, "Mode", "");
        RNA_def_enum_funcs(ot->prop, object_mode_set_itemsf);
        RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE);