From fec9615ea06c94b5224c14479c31c55c567fb7ee Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 21 May 2019 17:29:58 +0200 Subject: Masks: Properly port to Copy-on-Write concept Masks were not really covered by Copy-on-Write due to mistake in the dependency graph. After correcting that mistake a lot of tools became broken, so majority of the patch is related on making it so access to evaluated/tessellated masks is done. When accessing evaluated mask state make sure access to an evaluated dependency graph is done. This solves possible access to NULL data on redo. Fixes T64899: Re-doing new point addition causes crash Reviewers: brecht Reviewed By: brecht Maniphest Tasks: T64899 Differential Revision: https://developer.blender.org/D4918 --- source/blender/blenkernel/intern/mask_evaluate.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'source/blender/blenkernel/intern/mask_evaluate.c') diff --git a/source/blender/blenkernel/intern/mask_evaluate.c b/source/blender/blenkernel/intern/mask_evaluate.c index 4e6ca878b7a..f4f93fcb698 100644 --- a/source/blender/blenkernel/intern/mask_evaluate.c +++ b/source/blender/blenkernel/intern/mask_evaluate.c @@ -954,10 +954,30 @@ void BKE_mask_eval_animation(struct Depsgraph *depsgraph, Mask *mask) void BKE_mask_eval_update(struct Depsgraph *depsgraph, Mask *mask) { + const bool is_depsgraph_active = DEG_is_active(depsgraph); float ctime = DEG_get_ctime(depsgraph); DEG_debug_print_eval(depsgraph, __func__, mask->id.name, mask); for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer != NULL; mask_layer = mask_layer->next) { BKE_mask_layer_evaluate_deform(mask_layer, ctime); } + + if (is_depsgraph_active) { + Mask *mask_orig = (Mask *)DEG_get_original_id(&mask->id); + for (MaskLayer *masklay_orig = mask_orig->masklayers.first, + *masklay_eval = mask->masklayers.first; + masklay_orig != NULL; + masklay_orig = masklay_orig->next, masklay_eval = masklay_eval->next) { + for (MaskSpline *spline_orig = masklay_orig->splines.first, + *spline_eval = masklay_eval->splines.first; + spline_orig != NULL; + spline_orig = spline_orig->next, spline_eval = spline_eval->next) { + for (int i = 0; i < spline_eval->tot_point; i++) { + MaskSplinePoint *point_eval = &spline_eval->points[i]; + MaskSplinePoint *point_orig = &spline_orig->points[i]; + point_orig->bezt = point_eval->bezt; + } + } + } + } } -- cgit v1.2.3