diff options
Diffstat (limited to 'source/blender/editors/curve')
-rw-r--r-- | source/blender/editors/curve/CMakeLists.txt | 2 | ||||
-rw-r--r-- | source/blender/editors/curve/editcurve.c | 118 | ||||
-rw-r--r-- | source/blender/editors/curve/editcurve_add.c | 7 | ||||
-rw-r--r-- | source/blender/editors/curve/editcurve_paint.c | 103 | ||||
-rw-r--r-- | source/blender/editors/curve/editcurve_select.c | 123 | ||||
-rw-r--r-- | source/blender/editors/curve/editcurve_undo.c | 80 | ||||
-rw-r--r-- | source/blender/editors/curve/editfont.c | 17 | ||||
-rw-r--r-- | source/blender/editors/curve/editfont_undo.c | 5 |
8 files changed, 309 insertions, 146 deletions
diff --git a/source/blender/editors/curve/CMakeLists.txt b/source/blender/editors/curve/CMakeLists.txt index 13f12f62d95..301d333ebdb 100644 --- a/source/blender/editors/curve/CMakeLists.txt +++ b/source/blender/editors/curve/CMakeLists.txt @@ -23,10 +23,12 @@ set(INC ../../blenkernel ../../blenlib ../../blentranslation + ../../depsgraph ../../gpu ../../makesdna ../../makesrna ../../windowmanager + ../../../../intern/clog ../../../../intern/guardedalloc ../../../../intern/glew-mx ../../../../extern/curve_fit_nd diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index b0efc2ddc50..aa50916f5e0 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -45,11 +45,11 @@ #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, DEG_TAG_COPY_ON_WRITE | DEG_TAG_SELECT_UPDATE); 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, DEG_TAG_COPY_ON_WRITE | DEG_TAG_SELECT_UPDATE); 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; } @@ -4396,6 +4413,7 @@ bool ED_curve_editnurb_select_pick(bContext *C, const int mval[2], bool extend, BKE_curve_nurb_active_set(cu, nu); } + DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); return true; @@ -4509,7 +4527,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 +4542,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 +4982,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 +5018,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 +5027,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.bmain, vc.scene, vc.depsgraph, 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 +5136,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 +5235,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; } @@ -5284,6 +5301,7 @@ static int duplicate_exec(bContext *C, wmOperator *op) if (BLI_listbase_is_empty(&newnurb) == false) { BLI_movelisttolist(object_editcurve_get(obedit), &newnurb); + DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); } else { @@ -5736,7 +5754,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; } @@ -5787,7 +5805,7 @@ void CURVE_OT_delete(wmOperatorType *ot) /* properties */ prop = RNA_def_enum(ot->srna, "type", curve_delete_type_items, 0, "Type", "Which elements to delete"); RNA_def_enum_funcs(prop, rna_curve_delete_type_itemf); - + RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); ot->prop = prop; } @@ -5880,7 +5898,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 +5974,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 +6019,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 +6133,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 +6147,10 @@ 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); + DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE); WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene); @@ -6171,7 +6190,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 +6253,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 +6261,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); diff --git a/source/blender/editors/curve/editcurve_add.c b/source/blender/editors/curve/editcurve_add.c index a91b58f1e65..7f788b447f6 100644 --- a/source/blender/editors/curve/editcurve_add.c +++ b/source/blender/editors/curve/editcurve_add.c @@ -42,9 +42,10 @@ #include "BKE_context.h" #include "BKE_curve.h" -#include "BKE_depsgraph.h" #include "BKE_library.h" +#include "DEG_depsgraph.h" + #include "RNA_access.h" #include "WM_api.h" @@ -502,7 +503,7 @@ static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf) cu->flag |= CU_PATH | CU_3D; } else { - DAG_id_tag_update(&obedit->id, OB_RECALC_DATA); + DEG_id_tag_update(&obedit->id, OB_RECALC_DATA); } } else { /* adding surface */ @@ -512,7 +513,7 @@ static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf) newob = true; } else { - DAG_id_tag_update(&obedit->id, OB_RECALC_DATA); + DEG_id_tag_update(&obedit->id, OB_RECALC_DATA); } } diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c index 325c39d7f38..887f3dd13da 100644 --- a/source/blender/editors/curve/editcurve_paint.c +++ b/source/blender/editors/curve/editcurve_paint.c @@ -33,11 +33,12 @@ #include "BKE_context.h" #include "BKE_curve.h" -#include "BKE_depsgraph.h" #include "BKE_fcurve.h" #include "BKE_main.h" #include "BKE_report.h" +#include "DEG_depsgraph.h" + #include "WM_api.h" #include "WM_types.h" @@ -47,7 +48,11 @@ #include "ED_curve.h" #include "BIF_gl.h" -#include "BIF_glutil.h" + +#include "GPU_batch.h" +#include "GPU_immediate.h" +#include "GPU_immediate_util.h" +#include "GPU_matrix.h" #include "curve_intern.h" @@ -89,6 +94,8 @@ struct StrokeElem { }; struct CurveDrawData { + Depsgraph *depsgraph; + short init_event_type; short curve_type; @@ -129,7 +136,6 @@ struct CurveDrawData { } prev; ViewContext vc; - bglMats mats; enum { CURVE_DRAW_IDLE = 0, CURVE_DRAW_PAINTING = 1, @@ -196,7 +202,7 @@ static bool stroke_elem_project( if (cdd->project.use_plane) { /* get the view vector to 'location' */ float ray_origin[3], ray_direction[3]; - ED_view3d_win_to_ray(cdd->vc.ar, v3d, mval_fl, ray_origin, ray_direction, false); + ED_view3d_win_to_ray(cdd->depsgraph, cdd->vc.ar, v3d, mval_fl, ray_origin, ray_direction, false); float lambda; if (isect_ray_plane_v3(ray_origin, ray_direction, cdd->project.plane, &lambda, true)) { @@ -215,7 +221,7 @@ static bool stroke_elem_project( { const double depth = (double)ED_view3d_depth_read_cached(&cdd->vc, mval_i); if ((depth > depths->depth_range[0]) && (depth < depths->depth_range[1])) { - if (ED_view3d_depth_unproject(ar, &cdd->mats, mval_i, depth, r_location_world)) { + if (ED_view3d_depth_unproject(ar, mval_i, depth, r_location_world)) { is_location_world_set = true; if (r_normal_world) { zero_v3(r_normal_world); @@ -224,7 +230,7 @@ static bool stroke_elem_project( if (surface_offset != 0.0f) { const float offset = cdd->project.use_surface_offset_absolute ? 1.0f : radius; float normal[3]; - if (ED_view3d_depth_read_cached_normal(&cdd->vc, &cdd->mats, mval_i, normal)) { + if (ED_view3d_depth_read_cached_normal(&cdd->vc, mval_i, normal)) { madd_v3_v3fl(r_location_world, normal, offset * surface_offset); if (r_normal_world) { copy_v3_v3(r_normal_world, normal); @@ -370,39 +376,43 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C), ARegion *UNUS Object *obedit = cdd->vc.obedit; Curve *cu = obedit->data; - UI_ThemeColor(TH_WIRE); - if (cu->ext2 > 0.0f) { - GLUquadricObj *qobj = gluNewQuadric(); - - gluQuadricDrawStyle(qobj, GLU_FILL); - BLI_mempool_iter iter; const struct StrokeElem *selem; const float location_zero[3] = {0}; const float *location_prev = location_zero; + float color[3]; + UI_GetThemeColor3fv(TH_WIRE, color); + + Gwn_Batch *sphere = GPU_batch_preset_sphere(0); + GWN_batch_program_set_builtin(sphere, GPU_SHADER_3D_UNIFORM_COLOR); + GWN_batch_uniform_3fv(sphere, "color", color); + /* scale to edit-mode space */ - glPushMatrix(); - glMultMatrixf(obedit->obmat); + gpuPushMatrix(); + gpuMultMatrix(obedit->obmat); BLI_mempool_iternew(cdd->stroke_elem_pool, &iter); for (selem = BLI_mempool_iterstep(&iter); selem; selem = BLI_mempool_iterstep(&iter)) { - glTranslatef( + gpuTranslate3f( selem->location_local[0] - location_prev[0], selem->location_local[1] - location_prev[1], selem->location_local[2] - location_prev[2]); location_prev = selem->location_local; + const float radius = stroke_elem_radius(cdd, selem); - gluSphere(qobj, radius, 12, 8); + + gpuPushMatrix(); + gpuScaleUniform(radius); + GWN_batch_draw(sphere); + gpuPopMatrix(); location_prev = selem->location_local; } - glPopMatrix(); - - gluDeleteQuadric(qobj); + gpuPopMatrix(); } if (stroke_len > 1) { @@ -419,30 +429,45 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C), ARegion *UNUS } { + Gwn_VertFormat *format = immVertexFormat(); + unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); + glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); - glEnableClientState(GL_VERTEX_ARRAY); - glVertexPointer(3, GL_FLOAT, 0, coord_array); - - cpack(0x0); + imm_cpack(0x0); + immBegin(GWN_PRIM_LINE_STRIP, stroke_len); glLineWidth(3.0f); - glDrawArrays(GL_LINE_STRIP, 0, stroke_len); - if (v3d->zbuf) + if (v3d->zbuf) { glDisable(GL_DEPTH_TEST); + } + + for (int i = 0; i < stroke_len; i++) { + immVertex3fv(pos, coord_array[i]); + } + + immEnd(); - cpack(0xffffffff); + imm_cpack(0xffffffff); + immBegin(GWN_PRIM_LINE_STRIP, stroke_len); glLineWidth(1.0f); - glDrawArrays(GL_LINE_STRIP, 0, stroke_len); - if (v3d->zbuf) - glEnable(GL_DEPTH_TEST); + for (int i = 0; i < stroke_len; i++) { + immVertex3fv(pos, coord_array[i]); + } - glDisableClientState(GL_VERTEX_ARRAY); + immEnd(); + + if (v3d->zbuf) { + glEnable(GL_DEPTH_TEST); + } glDisable(GL_BLEND); glDisable(GL_LINE_SMOOTH); + + immUnbindProgram(); } MEM_freeN(coord_array); @@ -532,7 +557,7 @@ static void curve_draw_event_add_first(wmOperator *op, const wmEvent *event) CURVE_PAINT_SURFACE_PLANE_NORMAL_VIEW, CURVE_PAINT_SURFACE_PLANE_NORMAL_SURFACE)) { - if (ED_view3d_depth_read_cached_normal(&cdd->vc, &cdd->mats, event->mval, normal)) { + if (ED_view3d_depth_read_cached_normal(&cdd->vc, event->mval, normal)) { if (cps->surface_plane == CURVE_PAINT_SURFACE_PLANE_NORMAL_VIEW) { float cross_a[3], cross_b[3]; cross_v3_v3v3(cross_a, rv3d->viewinv[2], normal); @@ -581,6 +606,8 @@ static bool curve_draw_init(bContext *C, wmOperator *op, bool is_invoke) struct CurveDrawData *cdd = MEM_callocN(sizeof(*cdd), __func__); + cdd->depsgraph = CTX_data_depsgraph(C); + if (is_invoke) { ED_view3d_viewcontext_init(C, &cdd->vc); if (ELEM(NULL, cdd->vc.ar, cdd->vc.rv3d, cdd->vc.v3d, cdd->vc.win, cdd->vc.scene)) { @@ -591,7 +618,9 @@ static bool curve_draw_init(bContext *C, wmOperator *op, bool is_invoke) } else { cdd->vc.bmain = CTX_data_main(C); + cdd->vc.depsgraph = CTX_data_depsgraph(C); cdd->vc.scene = CTX_data_scene(C); + cdd->vc.view_layer = CTX_data_view_layer(C); cdd->vc.obedit = CTX_data_edit_object(C); } @@ -684,7 +713,7 @@ static void curve_draw_exec_precalc(wmOperator *op) const struct StrokeElem *selem, *selem_first, *selem_last; BLI_mempool_iternew(cdd->stroke_elem_pool, &iter); - selem_first = BLI_mempool_iterstep(&iter); + selem_first = selem_last = BLI_mempool_iterstep(&iter); for (selem = BLI_mempool_iterstep(&iter); selem; selem = BLI_mempool_iterstep(&iter)) { selem_last = selem; } @@ -761,7 +790,7 @@ static int curve_draw_exec(bContext *C, wmOperator *op) struct CurveDrawData *cdd = op->customdata; const CurvePaintSettings *cps = &cdd->vc.scene->toolsettings->curve_paint_settings; - Object *obedit = cdd->vc.scene->obedit; + Object *obedit = cdd->vc.obedit; Curve *cu = obedit->data; ListBase *nurblist = object_editcurve_get(obedit); @@ -1020,7 +1049,7 @@ static int curve_draw_exec(bContext *C, wmOperator *op) cu->actvert = nu->pntsu - 1; 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); curve_draw_exit(op); @@ -1075,12 +1104,10 @@ static int curve_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event) if ((cps->depth_mode == CURVE_PAINT_PROJECT_SURFACE) && (v3d->drawtype > OB_WIRE)) { - view3d_get_transformation(cdd->vc.ar, cdd->vc.rv3d, NULL, &cdd->mats); - /* needed or else the draw matrix can be incorrect */ view3d_operator_needs_opengl(C); - ED_view3d_autodist_init(cdd->vc.bmain, cdd->vc.scene, cdd->vc.ar, cdd->vc.v3d, 0); + ED_view3d_autodist_init(cdd->vc.depsgraph, cdd->vc.ar, cdd->vc.v3d, 0); if (cdd->vc.rv3d->depths) { cdd->vc.rv3d->depths->damaged = true; @@ -1099,7 +1126,7 @@ static int curve_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event) /* use view plane (when set or as fallback when surface can't be found) */ if (cdd->project.use_depth == false) { - plane_co = ED_view3d_cursor3d_get(cdd->vc.scene, v3d); + plane_co = ED_view3d_cursor3d_get(cdd->vc.scene, v3d)->location; plane_no = rv3d->viewinv[2]; cdd->project.use_plane = true; } diff --git a/source/blender/editors/curve/editcurve_select.c b/source/blender/editors/curve/editcurve_select.c index 673faa37f2a..0fae39776a9 100644 --- a/source/blender/editors/curve/editcurve_select.c +++ b/source/blender/editors/curve/editcurve_select.c @@ -42,6 +42,7 @@ #include "BKE_context.h" #include "BKE_curve.h" #include "BKE_fcurve.h" +#include "BKE_layer.h" #include "BKE_report.h" #include "WM_api.h" @@ -54,10 +55,10 @@ #include "curve_intern.h" - #include "RNA_access.h" #include "RNA_define.h" +#include "DEG_depsgraph.h" /* returns 1 in case (de)selection was successful */ bool select_beztriple(BezTriple *bezt, bool selstatus, short flag, eVisible_Types hidden) @@ -403,6 +404,7 @@ static int de_select_first_exec(bContext *C, wmOperator *UNUSED(op)) Object *obedit = CTX_data_edit_object(C); selectend_nurb(obedit, FIRST, true, DESELECT); + DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); BKE_curve_nurb_vert_active_validate(obedit->data); @@ -429,6 +431,7 @@ static int de_select_last_exec(bContext *C, wmOperator *UNUSED(op)) Object *obedit = CTX_data_edit_object(C); selectend_nurb(obedit, LAST, true, DESELECT); + DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); BKE_curve_nurb_vert_active_validate(obedit->data); @@ -452,32 +455,47 @@ void CURVE_OT_de_select_last(wmOperatorType *ot) static int de_select_all_exec(bContext *C, wmOperator *op) { - Object *obedit = CTX_data_edit_object(C); - Curve *cu = obedit->data; int action = RNA_enum_get(op->ptr, "action"); + ViewLayer *view_layer = CTX_data_view_layer(C); + uint objects_len = 0; + Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len); + if (action == SEL_TOGGLE) { action = SEL_SELECT; - if (ED_curve_select_check(cu, cu->editnurb)) { - action = SEL_DESELECT; + for (uint ob_index = 0; ob_index < objects_len; ob_index++) { + Object *obedit = objects[ob_index]; + Curve *cu = obedit->data; + + if (ED_curve_select_check(cu, cu->editnurb)) { + action = SEL_DESELECT; + break; + } } } - switch (action) { - case SEL_SELECT: - ED_curve_select_all(cu->editnurb); - break; - case SEL_DESELECT: - ED_curve_deselect_all(cu->editnurb); - break; - case SEL_INVERT: - ED_curve_select_swap(cu->editnurb, (cu->drawflag & CU_HIDE_HANDLES) != 0); - break; - } + for (uint ob_index = 0; ob_index < objects_len; ob_index++) { + Object *obedit = objects[ob_index]; + Curve *cu = obedit->data; + + switch (action) { + case SEL_SELECT: + ED_curve_select_all(cu->editnurb); + break; + case SEL_DESELECT: + ED_curve_deselect_all(cu->editnurb); + break; + case SEL_INVERT: + ED_curve_select_swap(cu->editnurb, (cu->drawflag & CU_HIDE_HANDLES) != 0); + break; + } - WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); - BKE_curve_nurb_vert_active_validate(cu); + DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); + BKE_curve_nurb_vert_active_validate(cu); + } + MEM_freeN(objects); return OPERATOR_FINISHED; } @@ -505,19 +523,31 @@ void CURVE_OT_select_all(wmOperatorType *ot) static int select_linked_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit = CTX_data_edit_object(C); - Curve *cu = (Curve *)obedit->data; - EditNurb *editnurb = cu->editnurb; - ListBase *nurbs = &editnurb->nurbs; - Nurb *nu; + ViewLayer *view_layer = CTX_data_view_layer(C); + + 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; + EditNurb *editnurb = cu->editnurb; + ListBase *nurbs = &editnurb->nurbs; + Nurb *nu; + bool changed = false; + + for (nu = nurbs->first; nu; nu = nu->next) { + if (ED_curve_nurb_select_check(cu, nu)) { + ED_curve_nurb_select_all(nu); + changed = true; + } + } - for (nu = nurbs->first; nu; nu = nu->next) { - if (ED_curve_nurb_select_check(cu, nu)) { - ED_curve_nurb_select_all(nu); + if (changed) { + DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); } } - - WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); + MEM_freeN(objects); return OPERATOR_FINISHED; } @@ -532,7 +562,7 @@ void CURVE_OT_select_linked(wmOperatorType *ot) /* identifiers */ ot->name = "Select Linked All"; ot->idname = "CURVE_OT_select_linked"; - ot->description = "Select all control points linked to active one"; + ot->description = "Select all control points linked to the current selection"; /* api callbacks */ ot->exec = select_linked_exec; @@ -582,6 +612,7 @@ static int select_linked_pick_invoke(bContext *C, wmOperator *op, const wmEvent } } + DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); if (!select) { BKE_curve_nurb_vert_active_validate(obedit->data); @@ -644,6 +675,7 @@ static int select_row_exec(bContext *C, wmOperator *UNUSED(op)) } } + DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); return OPERATOR_FINISHED; @@ -672,6 +704,7 @@ static int select_next_exec(bContext *C, wmOperator *UNUSED(op)) ListBase *editnurb = object_editcurve_get(obedit); select_adjacent_cp(editnurb, 1, 0, SELECT); + DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); return OPERATOR_FINISHED; @@ -700,6 +733,7 @@ static int select_previous_exec(bContext *C, wmOperator *UNUSED(op)) ListBase *editnurb = object_editcurve_get(obedit); select_adjacent_cp(editnurb, -1, 0, SELECT); + DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); return OPERATOR_FINISHED; @@ -788,6 +822,7 @@ static int select_more_exec(bContext *C, wmOperator *UNUSED(op)) select_adjacent_cp(editnurb, -1, 0, SELECT); } + DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); return OPERATOR_FINISHED; @@ -975,6 +1010,7 @@ static int select_less_exec(bContext *C, wmOperator *UNUSED(op)) } } + DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); BKE_curve_nurb_vert_active_validate(obedit->data); @@ -1040,17 +1076,32 @@ static void curve_select_random(ListBase *editnurb, float randfac, int seed, boo static int curve_select_random_exec(bContext *C, wmOperator *op) { - Object *obedit = CTX_data_edit_object(C); - ListBase *editnurb = object_editcurve_get(obedit); const bool select = (RNA_enum_get(op->ptr, "action") == SEL_SELECT); const float randfac = RNA_float_get(op->ptr, "percent") / 100.0f; const int seed = WM_operator_properties_select_random_seed_increment_get(op); - curve_select_random(editnurb, randfac, seed, select); - BKE_curve_nurb_vert_active_validate(obedit->data); + ViewLayer *view_layer = CTX_data_view_layer(C); + uint objects_len = 0; + Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len); - WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); + for (uint ob_index = 0; ob_index < objects_len; ob_index++) { + Object *obedit = objects[ob_index]; + ListBase *editnurb = object_editcurve_get(obedit); + int seed_iter = seed; + + /* This gives a consistent result regardless of object order. */ + if (ob_index) { + seed_iter += BLI_ghashutil_strhash_p(obedit->id.name); + } + + curve_select_random(editnurb, randfac, seed_iter, select); + BKE_curve_nurb_vert_active_validate(obedit->data); + + DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); + } + MEM_freeN(objects); return OPERATOR_FINISHED; } @@ -1157,6 +1208,7 @@ static int select_nth_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } + DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); return OPERATOR_FINISHED; @@ -1463,6 +1515,7 @@ static int curve_select_similar_exec(bContext *C, wmOperator *op) } if (changed) { + DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); return OPERATOR_FINISHED; } @@ -1599,6 +1652,7 @@ static void curve_select_shortest_path_surf(Nurb *nu, int vert_src, int vert_dst /* init heap */ heap = BLI_heap_new(); + vert_curr = data[vert_src].vert; BLI_heap_insert(heap, 0.0f, &data[vert_src].vert); data[vert_src].cost = 0.0f; data[vert_src].vert_prev = vert_src; /* nop */ @@ -1703,6 +1757,7 @@ static int edcu_shortest_path_pick_invoke(bContext *C, wmOperator *op, const wmE BKE_curve_nurb_vert_active_set(cu, nu_dst, vert_dst_p); + DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/curve/editcurve_undo.c b/source/blender/editors/curve/editcurve_undo.c index 4ced6ce506c..ad17331853b 100644 --- a/source/blender/editors/curve/editcurve_undo.c +++ b/source/blender/editors/curve/editcurve_undo.c @@ -22,12 +22,14 @@ * \ingroup edcurve */ +#include "MEM_guardedalloc.h" + +#include "CLG_log.h" + #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_anim_types.h" -#include "MEM_guardedalloc.h" - #include "BLI_blenlib.h" #include "BLI_ghash.h" #include "BLI_array_utils.h" @@ -35,12 +37,15 @@ #include "BKE_context.h" #include "BKE_curve.h" #include "BKE_fcurve.h" +#include "BKE_layer.h" #include "BKE_library.h" #include "BKE_animsys.h" -#include "BKE_depsgraph.h" #include "BKE_undo_system.h" +#include "DEG_depsgraph.h" + #include "ED_object.h" +#include "ED_undo.h" #include "ED_util.h" #include "ED_curve.h" @@ -49,6 +54,9 @@ #include "curve_intern.h" +/** We only need this locally. */ +static CLG_LogRef LOG = {"ed.undo.curve"}; + /* -------------------------------------------------------------------- */ /** \name Undo Conversion * \{ */ @@ -186,13 +194,19 @@ static Object *editcurve_object_from_context(bContext *C) /* -------------------------------------------------------------------- */ /** \name Implements ED Undo System + * + * \note This is similar for all edit-mode types. * \{ */ -typedef struct CurveUndoStep { - UndoStep step; - /* note: will split out into list for multi-object-editmode. */ +typedef struct CurveUndoStep_Elem { UndoRefID_Object obedit_ref; UndoCurve data; +} CurveUndoStep_Elem; + +typedef struct CurveUndoStep { + UndoStep step; + CurveUndoStep_Elem *elems; + uint elems_len; } CurveUndoStep; static bool curve_undosys_poll(bContext *C) @@ -204,9 +218,23 @@ static bool curve_undosys_poll(bContext *C) static bool curve_undosys_step_encode(struct bContext *C, UndoStep *us_p) { CurveUndoStep *us = (CurveUndoStep *)us_p; - us->obedit_ref.ptr = editcurve_object_from_context(C); - undocurve_from_editcurve(&us->data, us->obedit_ref.ptr->data, us->obedit_ref.ptr->shapenr); - us->step.data_size = us->data.undo_size; + + ViewLayer *view_layer = CTX_data_view_layer(C); + uint objects_len = 0; + Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len); + + us->elems = MEM_callocN(sizeof(*us->elems) * objects_len, __func__); + us->elems_len = objects_len; + + for (uint i = 0; i < objects_len; i++) { + Object *ob = objects[i]; + CurveUndoStep_Elem *elem = &us->elems[i]; + + elem->obedit_ref.ptr = ob; + undocurve_from_editcurve(&elem->data, ob->data, ob->shapenr); + us->step.data_size += elem->data.undo_size; + } + MEM_freeN(objects); return true; } @@ -217,23 +245,47 @@ static void curve_undosys_step_decode(struct bContext *C, UndoStep *us_p, int UN BLI_assert(curve_undosys_poll(C)); CurveUndoStep *us = (CurveUndoStep *)us_p; - Object *obedit = us->obedit_ref.ptr; - undocurve_to_editcurve(&us->data, obedit->data, &obedit->shapenr); - DAG_id_tag_update(&obedit->id, OB_RECALC_DATA); + + for (uint i = 0; i < us->elems_len; i++) { + CurveUndoStep_Elem *elem = &us->elems[i]; + Object *obedit = elem->obedit_ref.ptr; + Curve *cu = obedit->data; + if (cu->editnurb == NULL) { + /* Should never fail, may not crash but can give odd behavior. */ + CLOG_ERROR(&LOG, "name='%s', failed to enter edit-mode for object '%s', undo state invalid", + us_p->name, obedit->id.name); + continue; + } + undocurve_to_editcurve(&elem->data, obedit->data, &obedit->shapenr); + DEG_id_tag_update(&obedit->id, OB_RECALC_DATA); + } + + /* The first element is always active */ + ED_undo_object_set_active_or_warn(CTX_data_view_layer(C), us->elems[0].obedit_ref.ptr, us_p->name, &LOG); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, NULL); } static void curve_undosys_step_free(UndoStep *us_p) { CurveUndoStep *us = (CurveUndoStep *)us_p; - undocurve_free_data(&us->data); + + for (uint i = 0; i < us->elems_len; i++) { + CurveUndoStep_Elem *elem = &us->elems[i]; + undocurve_free_data(&elem->data); + } + MEM_freeN(us->elems); } static void curve_undosys_foreach_ID_ref( UndoStep *us_p, UndoTypeForEachIDRefFn foreach_ID_ref_fn, void *user_data) { CurveUndoStep *us = (CurveUndoStep *)us_p; - foreach_ID_ref_fn(user_data, ((UndoRefID *)&us->obedit_ref)); + + for (uint i = 0; i < us->elems_len; i++) { + CurveUndoStep_Elem *elem = &us->elems[i]; + foreach_ID_ref_fn(user_data, ((UndoRefID *)&elem->obedit_ref)); + } } /* Export for ED_undo_sys. */ diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c index bc4a4d0105d..75efdec3dd2 100644 --- a/source/blender/editors/curve/editfont.c +++ b/source/blender/editors/curve/editfont.c @@ -49,13 +49,14 @@ #include "BKE_context.h" #include "BKE_curve.h" -#include "BKE_depsgraph.h" #include "BKE_font.h" #include "BKE_library.h" #include "BKE_main.h" #include "BKE_object.h" #include "BKE_report.h" +#include "DEG_depsgraph.h" + #include "RNA_access.h" #include "RNA_define.h" @@ -253,7 +254,7 @@ static void text_update_edited(bContext *C, Object *obedit, int mode) /* run update first since it can move the cursor */ if (mode == FO_EDIT) { /* re-tesselllate */ - DAG_id_tag_update(obedit->data, 0); + DEG_id_tag_update(obedit->data, 0); } else { /* depsgraph runs above, but since we're not tagging for update, call direct */ @@ -272,6 +273,8 @@ static void text_update_edited(bContext *C, Object *obedit, int mode) } } + BKE_curve_batch_cache_dirty(cu, BKE_CURVE_BATCH_DIRTY_SELECT); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); } @@ -418,7 +421,9 @@ void FONT_OT_text_paste_from_file(wmOperatorType *ot) static void txt_add_object(bContext *C, TextLine *firstline, int totline, const float offset[3]) { Main *bmain = CTX_data_main(C); + Depsgraph *depsgraph = CTX_data_depsgraph(C); Scene *scene = CTX_data_scene(C); + ViewLayer *view_layer = CTX_data_view_layer(C); Curve *cu; Object *obedit; Base *base; @@ -428,13 +433,13 @@ static void txt_add_object(bContext *C, TextLine *firstline, int totline, const int a; float rot[3] = {0.f, 0.f, 0.f}; - obedit = BKE_object_add(bmain, scene, OB_FONT, NULL); - base = scene->basact; + obedit = BKE_object_add(bmain, scene, view_layer, OB_FONT, NULL); + base = view_layer->basact; /* seems to assume view align ? TODO - look into this, could be an operator option */ ED_object_base_init_transform(C, base, NULL, rot); - BKE_object_where_is_calc(scene, obedit); + BKE_object_where_is_calc(depsgraph, scene, obedit); add_v3_v3(obedit->loc, offset); @@ -581,7 +586,7 @@ static int set_style(bContext *C, const int style, const bool clear) ef->textbufinfo[i].flag |= style; } - 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; diff --git a/source/blender/editors/curve/editfont_undo.c b/source/blender/editors/curve/editfont_undo.c index 3a76d0333f9..d4d48e93f43 100644 --- a/source/blender/editors/curve/editfont_undo.c +++ b/source/blender/editors/curve/editfont_undo.c @@ -38,9 +38,10 @@ #include "BKE_context.h" #include "BKE_font.h" -#include "BKE_depsgraph.h" #include "BKE_undo_system.h" +#include "DEG_depsgraph.h" + #include "ED_object.h" #include "ED_curve.h" #include "ED_util.h" @@ -358,7 +359,7 @@ static void font_undosys_step_decode(struct bContext *C, UndoStep *us_p, int UNU Object *obedit = us->obedit_ref.ptr; Curve *cu = obedit->data; undofont_to_editfont(&us->data, cu); - DAG_id_tag_update(&obedit->id, OB_RECALC_DATA); + DEG_id_tag_update(&obedit->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_GEOM | ND_DATA, NULL); } |