Merge branch 'master' into blender2.8
[blender.git] / source / blender / editors / curve / editcurve.c
index 139034a..ab6586d 100644 (file)
 
 #include "BKE_context.h"
 #include "BKE_curve.h"
-#include "BKE_depsgraph.h"
 #include "BKE_displist.h"
 #include "BKE_fcurve.h"
 #include "BKE_global.h"
 #include "BKE_key.h"
+#include "BKE_layer.h"
 #include "BKE_library.h"
 #include "BKE_main.h"
 #include "BKE_report.h"
@@ -57,6 +57,9 @@
 #include "BKE_action.h"
 #include "BKE_modifier.h"
 
+#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_build.h"
+
 #include "WM_api.h"
 #include "WM_types.h"
 
@@ -1278,6 +1281,7 @@ static int separate_exec(bContext *C, wmOperator *op)
 {
        Main *bmain = CTX_data_main(C);
        Scene *scene = CTX_data_scene(C);
+       ViewLayer *view_layer = CTX_data_view_layer(C);
        Object *oldob, *newob;
        Base *oldbase, *newbase;
        Curve *oldcu, *newcu;
@@ -1305,8 +1309,8 @@ static int separate_exec(bContext *C, wmOperator *op)
        }
 
        /* 2. duplicate the object and data */
-       newbase = ED_object_add_duplicate(bmain, scene, oldbase, 0); /* 0 = fully linked */
-       DAG_relations_tag_update(bmain);
+       newbase = ED_object_add_duplicate(bmain, scene, view_layer, oldbase, 0); /* 0 = fully linked */
+       DEG_relations_tag_update(bmain);
 
        newob = newbase->object;
        newcu = newob->data = BKE_curve_copy(bmain, oldcu);
@@ -1325,8 +1329,8 @@ static int separate_exec(bContext *C, wmOperator *op)
        ED_curve_editnurb_free(newob);
        curve_delete_segments(oldob, true);
 
-       DAG_id_tag_update(&oldob->id, OB_RECALC_DATA);  /* this is the original one */
-       DAG_id_tag_update(&newob->id, OB_RECALC_DATA);  /* this is the separated one */
+       DEG_id_tag_update(&oldob->id, OB_RECALC_DATA);  /* this is the original one */
+       DEG_id_tag_update(&newob->id, OB_RECALC_DATA);  /* this is the separated one */
 
        WM_event_add_notifier(C, NC_GEOM | ND_DATA, oldob->data);
        WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, newob);
@@ -1374,7 +1378,7 @@ static int curve_split_exec(bContext *C, wmOperator *op)
                        WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, obedit);
 
                WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
-               DAG_id_tag_update(obedit->data, 0);
+               DEG_id_tag_update(obedit->data, 0);
        }
        else {
                BKE_report(op->reports, RPT_ERROR, "Cannot split current selection");
@@ -2320,7 +2324,7 @@ static int switch_direction_exec(bContext *C, wmOperator *UNUSED(op))
        if (ED_curve_updateAnimPaths(obedit->data))
                WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, obedit);
 
-       DAG_id_tag_update(obedit->data, 0);
+       DEG_id_tag_update(obedit->data, 0);
        WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
 
        return OPERATOR_FINISHED;
@@ -2368,7 +2372,7 @@ static int set_goal_weight_exec(bContext *C, wmOperator *op)
                }
        }
 
-       DAG_id_tag_update(obedit->data, 0);
+       DEG_id_tag_update(obedit->data, 0);
        WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
 
        return OPERATOR_FINISHED;
@@ -2421,7 +2425,7 @@ static int set_radius_exec(bContext *C, wmOperator *op)
        }
 
        WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
-       DAG_id_tag_update(obedit->data, 0);
+       DEG_id_tag_update(obedit->data, 0);
 
        return OPERATOR_FINISHED;
 }
@@ -2573,7 +2577,7 @@ static int smooth_exec(bContext *C, wmOperator *UNUSED(op))
        }
 
        WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
-       DAG_id_tag_update(obedit->data, 0);
+       DEG_id_tag_update(obedit->data, 0);
 
        return OPERATOR_FINISHED;
 }
@@ -2764,7 +2768,7 @@ static int curve_smooth_weight_exec(bContext *C, wmOperator *UNUSED(op))
        curve_smooth_value(editnurb, offsetof(BezTriple, weight), offsetof(BPoint, weight));
 
        WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
-       DAG_id_tag_update(obedit->data, 0);
+       DEG_id_tag_update(obedit->data, 0);
 
        return OPERATOR_FINISHED;
 }
@@ -2792,7 +2796,7 @@ static int curve_smooth_radius_exec(bContext *C, wmOperator *UNUSED(op))
        curve_smooth_value(editnurb, offsetof(BezTriple, radius), offsetof(BPoint, radius));
 
        WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
-       DAG_id_tag_update(obedit->data, 0);
+       DEG_id_tag_update(obedit->data, 0);
 
        return OPERATOR_FINISHED;
 }
@@ -2820,7 +2824,7 @@ static int curve_smooth_tilt_exec(bContext *C, wmOperator *UNUSED(op))
        curve_smooth_value(editnurb, offsetof(BezTriple, alfa), offsetof(BPoint, alfa));
 
        WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
-       DAG_id_tag_update(obedit->data, 0);
+       DEG_id_tag_update(obedit->data, 0);
 
        return OPERATOR_FINISHED;
 }
@@ -2892,7 +2896,7 @@ static int hide_exec(bContext *C, wmOperator *op)
                }
        }
 
-       DAG_id_tag_update(obedit->data, 0);
+       DEG_id_tag_update(obedit->data, 0);
        WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
        BKE_curve_nurb_vert_active_validate(obedit->data);
 
@@ -2955,7 +2959,7 @@ static int reveal_exec(bContext *C, wmOperator *op)
                }
        }
 
-       DAG_id_tag_update(obedit->data, 0);
+       DEG_id_tag_update(obedit->data, 0);
        WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
 
        return OPERATOR_FINISHED;
@@ -3367,16 +3371,29 @@ static void subdividenurb(Object *obedit, int number_cuts)
 
 static int subdivide_exec(bContext *C, wmOperator *op)
 {
-       Object *obedit = CTX_data_edit_object(C);
-       int number_cuts = RNA_int_get(op->ptr, "number_cuts");
+       const int number_cuts = RNA_int_get(op->ptr, "number_cuts");
 
-       subdividenurb(obedit, number_cuts);
+       ViewLayer *view_layer = CTX_data_view_layer(C);
 
-       if (ED_curve_updateAnimPaths(obedit->data))
-               WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, obedit);
+       uint objects_len = 0;
+       Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+       for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+               Object *obedit = objects[ob_index];
+               Curve *cu = obedit->data;
 
-       WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
-       DAG_id_tag_update(obedit->data, 0);
+               if (!ED_curve_select_check(cu, cu->editnurb)) {
+                       continue;
+               }
+
+               subdividenurb(obedit, number_cuts);
+
+               if (ED_curve_updateAnimPaths(cu))
+                       WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, obedit);
+
+               WM_event_add_notifier(C, NC_GEOM | ND_DATA, cu);
+               DEG_id_tag_update(obedit->data, 0);
+       }
+       MEM_freeN(objects);
 
        return OPERATOR_FINISHED;
 }
@@ -3571,7 +3588,7 @@ static int set_spline_type_exec(bContext *C, wmOperator *op)
                if (ED_curve_updateAnimPaths(obedit->data))
                        WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, obedit);
 
-               DAG_id_tag_update(obedit->data, 0);
+               DEG_id_tag_update(obedit->data, 0);
                WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
 
                if (changed_size) {
@@ -3625,7 +3642,7 @@ static int set_handle_type_exec(bContext *C, wmOperator *op)
        BKE_nurbList_handles_set(editnurb, RNA_enum_get(op->ptr, "type"));
 
        WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
-       DAG_id_tag_update(obedit->data, 0);
+       DEG_id_tag_update(obedit->data, 0);
 
        return OPERATOR_FINISHED;
 }
@@ -3670,7 +3687,7 @@ static int curve_normals_make_consistent_exec(bContext *C, wmOperator *op)
        BKE_nurbList_handles_recalculate(editnurb, calc_length, SELECT);
 
        WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
-       DAG_id_tag_update(obedit->data, 0);
+       DEG_id_tag_update(obedit->data, 0);
 
        return OPERATOR_FINISHED;
 }
@@ -4058,7 +4075,7 @@ static int merge_nurb(bContext *C, wmOperator *op)
        BKE_curve_nurb_active_set(obedit->data, NULL);
 
        WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
-       DAG_id_tag_update(obedit->data, 0);
+       DEG_id_tag_update(obedit->data, 0);
 
        return OPERATOR_FINISHED;
 }
@@ -4265,7 +4282,7 @@ static int make_segment_exec(bContext *C, wmOperator *op)
                WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, obedit);
 
        WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
-       DAG_id_tag_update(obedit->data, 0);
+       DEG_id_tag_update(obedit->data, 0);
 
        return OPERATOR_FINISHED;
 }
@@ -4509,7 +4526,7 @@ static int spin_exec(bContext *C, wmOperator *op)
                WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, obedit);
 
        WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
-       DAG_id_tag_update(obedit->data, 0);
+       DEG_id_tag_update(obedit->data, 0);
 
        return OPERATOR_FINISHED;
 }
@@ -4524,7 +4541,7 @@ static int spin_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)
        if (rv3d)
                copy_v3_v3(axis, rv3d->viewinv[2]);
 
-       RNA_float_set_array(op->ptr, "center", ED_view3d_cursor3d_get(scene, v3d));
+       RNA_float_set_array(op->ptr, "center", ED_view3d_cursor3d_get(scene, v3d)->location);
        RNA_float_set_array(op->ptr, "axis", axis);
 
        return spin_exec(C, op);
@@ -4964,7 +4981,7 @@ static int add_vertex_exec(bContext *C, wmOperator *op)
                }
 
                WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
-               DAG_id_tag_update(obedit->data, 0);
+               DEG_id_tag_update(obedit->data, 0);
 
                return OPERATOR_FINISHED;
        }
@@ -5000,7 +5017,7 @@ static int add_vertex_invoke(bContext *C, wmOperator *op, const wmEvent *event)
                        mul_v3_m4v3(location, vc.obedit->obmat, bp->vec);
                }
                else {
-                       copy_v3_v3(location, ED_view3d_cursor3d_get(vc.scene, vc.v3d));
+                       copy_v3_v3(location, ED_view3d_cursor3d_get(vc.scene, vc.v3d)->location);
                }
 
                ED_view3d_win_to_3d_int(vc.v3d, vc.ar, location, event->mval, location);
@@ -5009,17 +5026,16 @@ static int add_vertex_invoke(bContext *C, wmOperator *op, const wmEvent *event)
                        const float mval[2] = {UNPACK2(event->mval)};
 
                        struct SnapObjectContext *snap_context = ED_transform_snap_object_context_create_view3d(
-                               CTX_data_main(C), vc.scene, 0,
-                               vc.ar, vc.v3d);
+                               vc.scene, CTX_data_depsgraph(C), 0, vc.ar, vc.v3d);
 
-                       ED_transform_snap_object_project_view3d_mixed(
+                       ED_transform_snap_object_project_view3d(
                                snap_context,
-                               SCE_SELECT_FACE,
+                               SCE_SNAP_MODE_FACE,
                                &(const struct SnapObjectParams){
-                                   .snap_select = (vc.scene->obedit != NULL) ? SNAP_NOT_ACTIVE : SNAP_ALL,
+                                   .snap_select = (vc.obedit != NULL) ? SNAP_NOT_ACTIVE : SNAP_ALL,
                                    .use_object_edit_cage = false,
                                },
-                               mval, NULL, true,
+                               mval, NULL,
                                location, NULL);
 
 
@@ -5119,7 +5135,7 @@ static int curve_extrude_exec(bContext *C, wmOperator *UNUSED(op))
                }
 
                WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
-               DAG_id_tag_update(obedit->data, 0);
+               DEG_id_tag_update(obedit->data, 0);
        }
 
        return OPERATOR_FINISHED;
@@ -5218,7 +5234,7 @@ static int toggle_cyclic_exec(bContext *C, wmOperator *op)
        }
 
        WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
-       DAG_id_tag_update(obedit->data, 0);
+       DEG_id_tag_update(obedit->data, 0);
 
        return OPERATOR_FINISHED;
 }
@@ -5736,7 +5752,7 @@ static int curve_delete_exec(bContext *C, wmOperator *op)
                if (ED_curve_updateAnimPaths(obedit->data)) WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, obedit);
 
                WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
-               DAG_id_tag_update(obedit->data, 0);
+               DEG_id_tag_update(obedit->data, 0);
 
                return retval;
        }
@@ -5880,7 +5896,7 @@ static int curve_dissolve_exec(bContext *C, wmOperator *UNUSED(op))
                if (ED_curve_updateAnimPaths(obedit->data)) WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, obedit);
 
                WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
-               DAG_id_tag_update(obedit->data, 0);
+               DEG_id_tag_update(obedit->data, 0);
        }
 
        return OPERATOR_FINISHED;
@@ -5956,7 +5972,7 @@ static int curve_decimate_exec(bContext *C, wmOperator *op)
                }
 
                WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
-               DAG_id_tag_update(obedit->data, 0);
+               DEG_id_tag_update(obedit->data, 0);
        }
 
        return OPERATOR_FINISHED;
@@ -6001,7 +6017,7 @@ static int shade_smooth_exec(bContext *C, wmOperator *op)
        }
 
        WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
-       DAG_id_tag_update(obedit->data, 0);
+       DEG_id_tag_update(obedit->data, 0);
 
        return OPERATOR_FINISHED;
 }
@@ -6115,7 +6131,7 @@ int join_curve_exec(bContext *C, wmOperator *op)
                                        }
                                }
 
-                               ED_base_object_free_and_unlink(bmain, scene, base);
+                               ED_object_base_free_and_unlink(bmain, scene, base->object);
                        }
                }
        }
@@ -6129,9 +6145,9 @@ int join_curve_exec(bContext *C, wmOperator *op)
                BKE_curve_curve_dimension_update(cu);
        }
 
-       DAG_relations_tag_update(bmain);   // because we removed object(s), call before editmode!
+       DEG_relations_tag_update(bmain);   // because we removed object(s), call before editmode!
 
-       DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA);
+       DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA);
 
        WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
 
@@ -6171,7 +6187,7 @@ static int clear_tilt_exec(bContext *C, wmOperator *UNUSED(op))
        }
 
        WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
-       DAG_id_tag_update(obedit->data, 0);
+       DEG_id_tag_update(obedit->data, 0);
 
        return OPERATOR_FINISHED;
 }
@@ -6234,6 +6250,7 @@ static int match_texture_space_poll(bContext *C)
 
 static int match_texture_space_exec(bContext *C, wmOperator *UNUSED(op))
 {
+       Depsgraph *depsgraph = CTX_data_depsgraph(C);
        Scene *scene = CTX_data_scene(C);
        Object *object = CTX_data_active_object(C);
        Curve *curve = (Curve *) object->data;
@@ -6241,7 +6258,7 @@ static int match_texture_space_exec(bContext *C, wmOperator *UNUSED(op))
        int a;
 
        if (object->curve_cache == NULL) {
-               BKE_displist_make_curveTypes(scene, object, false);
+               BKE_displist_make_curveTypes(depsgraph, scene, object, false);
        }
 
        INIT_MINMAX(min, max);