[Bf-blender-cvs] [fec9615ea06] master: Masks: Properly port to Copy-on-Write concept
Sergey Sharybin
noreply at git.blender.org
Thu May 23 09:53:28 CEST 2019
Commit: fec9615ea06c94b5224c14479c31c55c567fb7ee
Author: Sergey Sharybin
Date: Tue May 21 17:29:58 2019 +0200
Branches: master
https://developer.blender.org/rBfec9615ea06c94b5224c14479c31c55c567fb7ee
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
===================================================================
M source/blender/blenkernel/BKE_mask.h
M source/blender/blenkernel/intern/mask.c
M source/blender/blenkernel/intern/mask_evaluate.c
M source/blender/depsgraph/DEG_depsgraph_query.h
M source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
M source/blender/depsgraph/intern/depsgraph_tag.cc
M source/blender/editors/include/ED_mask.h
M source/blender/editors/mask/mask_add.c
M source/blender/editors/mask/mask_draw.c
M source/blender/editors/mask/mask_ops.c
M source/blender/editors/mask/mask_select.c
M source/blender/editors/space_clip/space_clip.c
M source/blender/editors/space_image/space_image.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_mask.h b/source/blender/blenkernel/BKE_mask.h
index 042463dc7b0..bfdeadc7f60 100644
--- a/source/blender/blenkernel/BKE_mask.h
+++ b/source/blender/blenkernel/BKE_mask.h
@@ -171,8 +171,6 @@ void BKE_mask_coord_to_image(struct Image *image,
/* parenting */
-void BKE_mask_update_display(struct Mask *mask, float ctime);
-
void BKE_mask_evaluate_all_masks(struct Main *bmain, float ctime, const bool do_newframe);
void BKE_mask_evaluate(struct Mask *mask, const float ctime, const bool do_newframe);
void BKE_mask_layer_evaluate(struct MaskLayer *masklay, const float ctime, const bool do_newframe);
diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c
index 43fc8152c7b..bb93d068bef 100644
--- a/source/blender/blenkernel/intern/mask.c
+++ b/source/blender/blenkernel/intern/mask.c
@@ -1469,13 +1469,6 @@ void BKE_mask_evaluate(Mask *mask, const float ctime, const bool do_newframe)
}
}
-/* the purpose of this function is to ensure spline->points_deform is never out of date.
- * for now re-evaluate all. eventually this might work differently */
-void BKE_mask_update_display(Mask *mask, float ctime)
-{
- BKE_mask_evaluate(mask, ctime, false);
-}
-
void BKE_mask_evaluate_all_masks(Main *bmain, float ctime, const bool do_newframe)
{
Mask *mask;
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;
+ }
+ }
+ }
+ }
}
diff --git a/source/blender/depsgraph/DEG_depsgraph_query.h b/source/blender/depsgraph/DEG_depsgraph_query.h
index a7b5535d11a..9b7e5b95fdc 100644
--- a/source/blender/depsgraph/DEG_depsgraph_query.h
+++ b/source/blender/depsgraph/DEG_depsgraph_query.h
@@ -29,6 +29,9 @@
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
+/* Needed for the instance iterator. */
+#include "DNA_object_types.h"
+
struct ID;
struct BLI_Iterator;
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
index 0d10bd1d3dc..a203bfdb81d 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
@@ -1492,7 +1492,7 @@ void DepsgraphNodeBuilder::build_mask(Mask *mask)
return;
}
ID *mask_id = &mask->id;
- Mask *mask_cow = get_cow_datablock(mask);
+ Mask *mask_cow = (Mask *)ensure_cow_id(mask_id);
/* F-Curve based animation. */
build_animdata(mask_id);
build_parameters(mask_id);
diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc
index 7dcba8b7655..88f1130b7fb 100644
--- a/source/blender/depsgraph/intern/depsgraph_tag.cc
+++ b/source/blender/depsgraph/intern/depsgraph_tag.cc
@@ -540,6 +540,8 @@ NodeType geometry_tag_to_component(const ID *id)
return NodeType::GEOMETRY;
case ID_PAL: /* Palettes */
return NodeType::PARAMETERS;
+ case ID_MSK:
+ return NodeType::PARAMETERS;
default:
break;
}
diff --git a/source/blender/editors/include/ED_mask.h b/source/blender/editors/include/ED_mask.h
index c3883de0722..3322cf0a863 100644
--- a/source/blender/editors/include/ED_mask.h
+++ b/source/blender/editors/include/ED_mask.h
@@ -24,6 +24,7 @@
#ifndef __ED_MASK_H__
#define __ED_MASK_H__
+struct Depsgraph;
struct KeyframeEditData;
struct MaskLayer;
struct MaskLayerShape;
@@ -55,7 +56,8 @@ void ED_operatormacros_mask(void);
/* mask_draw.c */
void ED_mask_draw(const struct bContext *C, const char draw_flag, const char draw_type);
-void ED_mask_draw_region(struct Mask *mask,
+void ED_mask_draw_region(struct Depsgraph *depsgraph,
+ struct Mask *mask,
struct ARegion *ar,
const char draw_flag,
const char draw_type,
diff --git a/source/blender/editors/mask/mask_add.c b/source/blender/editors/mask/mask_add.c
index 3c456f9e2e2..fc85eab6e66 100644
--- a/source/blender/editors/mask/mask_add.c
+++ b/source/blender/editors/mask/mask_add.c
@@ -29,6 +29,7 @@
#include "BKE_mask.h"
#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
@@ -47,7 +48,7 @@
#include "mask_intern.h" /* own include */
bool ED_mask_find_nearest_diff_point(const bContext *C,
- struct Mask *mask,
+ struct Mask *mask_orig,
const float normal_co[2],
int threshold,
bool feather,
@@ -63,7 +64,7 @@ bool ED_mask_find_nearest_diff_point(const bContext *C,
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
- MaskLayer *masklay, *point_masklay;
+ MaskLayer *point_masklay;
MaskSpline *point_spline;
MaskSplinePoint *point = NULL;
float dist_best_sq = FLT_MAX, co[2];
@@ -71,31 +72,36 @@ bool ED_mask_find_nearest_diff_point(const bContext *C,
float u = 0.0f;
float scalex, scaley;
+ Depsgraph *depsgraph = CTX_data_evaluated_depsgraph(C);
+ Mask *mask_eval = (Mask *)DEG_get_evaluated_id(depsgraph, &mask_orig->id);
+
ED_mask_get_size(sa, &width, &height);
ED_mask_pixelspace_factor(sa, ar, &scalex, &scaley);
co[0] = normal_co[0] * scalex;
co[1] = normal_co[1] * scaley;
- for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
- MaskSpline *spline;
-
- if (masklay->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
+ for (MaskLayer *masklay_orig = mask_orig->masklayers.first,
+ *masklay_eval = mask_eval->masklayers.first;
+ masklay_orig != NULL;
+ masklay_orig = masklay_orig->next, masklay_eval = masklay_eval->next) {
+ if (masklay_orig->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
continue;
}
- for (spline = masklay->splines.first; spline; spline = spline->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) {
int i;
- MaskSplinePoint *cur_point;
+ MaskSplinePoint *cur_point_eval;
- for (i = 0, cur_point = use_deform ? spline->points_deform : spline->points;
- i < spline->tot_point;
- i++, cur_point++) {
- float *diff_points;
+ for (i = 0, cur_point_eval = use_deform ? spline_eval->points_deform : spline_eval->points;
+ i < spline_eval->tot_point;
+ i++, cur_point_eval++) {
unsigned int tot_diff_point;
-
- diff_points = BKE_mask_point_segment_diff(
- spline, cur_point, width, height, &tot_diff_point);
+ float *diff_points = BKE_mask_point_segment_diff(
+ spline_eval, cur_point_eval, width, height, &tot_diff_point);
if (diff_points) {
int j, tot_point;
@@ -104,7 +110,7 @@ bool ED_mask_find_nearest_diff_point(const bContext *C,
if (feather) {
feather_points = BKE_mask_point_segment_feather_diff(
- spline, cur_point, width, height, &tot_feather_point);
+ spline_eval, cur_point_eval, width, height, &tot_feather_point);
points = feather_points;
tot_point = tot_feather_point;
@@ -130,19 +136,19 @@ bool ED_mask_find_nearest_diff_point(const bContext *C,
sub_v2_v2v2(tangent, &diff_points[2 * j + 2], &diff_points[2 * j]);
}
- point_masklay = masklay;
- point_spline = spline;
- point = use_deform ? &spline->points[(cur_point - spline->points_deform)] :
- cur_point;
+ point_masklay = masklay_orig;
+ point_spline = spline_orig;
+ point = use_deform ?
+ &spline_orig->points[(cur_point_eval - spline_eval->points_deform)] :
+ &spline_orig->points[(cur_point_eval - spline_eval->points)];
dist_best_sq = dist_sq;
u = (float)j / tot_point;
}
}
- if (feather_points) {
+ if (feather_points != NULL) {
MEM_freeN(feather_points);
}
-
MEM_freeN(diff_points);
}
}
@@ -580,7 +586,6 @@ static bool add_vertex_new(const bContext *C, Mask *mask, MaskLayer *masklay, co
static int add_vertex_exec(bContext *C, wmOperator *op)
{
- Scene *scene = CTX_data_scene(C);
Mask *mask = CTX_data_edit_mask(C);
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list