[Bf-blender-cvs] [3721b857c69] greasepencil-object: GP Branch: Update gpl->actframe in depsgraph callbacks (fixes COW-related issues)

Joshua Leung noreply at git.blender.org
Tue Jun 12 13:39:29 CEST 2018


Commit: 3721b857c697e3b9bc369f3b3afa0a6894e0584b
Author: Joshua Leung
Date:   Tue Jun 12 23:37:25 2018 +1200
Branches: greasepencil-object
https://developer.blender.org/rB3721b857c697e3b9bc369f3b3afa0a6894e0584b

GP Branch: Update gpl->actframe in depsgraph callbacks (fixes COW-related issues)

This commit fixes various problems across the codebase
caused by the fact that the gpl->actframe pointers no longer
get updated on redraw, meaning that various editing tools
were not working.

Applying a similar solution to 59a516913e599ce29754d361246a0d8cb92bd314
here: On the exit node for GP data evaluation, we flush the changed
actframe pointers back to main database, so that the main db
is consistent with the displayed time.

Notes:
- For now, we just reuse the BKE_gpencil_eval_geometry() callback,
  since it's the only one there and nothing else was happening there.
  In future, when we do convert the GP modifier stack evaluation away
  from its drawing-engine based approach, we should split this out into
  its own function.

- We also do the actframe update in the COW domain here. While it's
  not strictly needed for anything right now, this is something that
  should really have been happening, so let's do it the proper way now.

- The alternative approach would've been to modify all GP related
  context functions to set this whenever they were called. But that
  carries performance penalties, and isn't such a nice solution,
  as context getters should really not have side-effects.

===================================================================

M	source/blender/blenkernel/BKE_gpencil.h
M	source/blender/blenkernel/intern/gpencil_modifier.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_gpencil.h b/source/blender/blenkernel/BKE_gpencil.h
index da3f8efcb8c..e84fc380f78 100644
--- a/source/blender/blenkernel/BKE_gpencil.h
+++ b/source/blender/blenkernel/BKE_gpencil.h
@@ -156,7 +156,7 @@ bool BKE_gpencil_vgroup_remove_point_weight(struct MDeformVert *dvert, int index
 void BKE_gpencil_stroke_weights_duplicate(struct bGPDstroke *gps_src, struct bGPDstroke *gps_dst);
 
 /* GPencil geometry evaluation */
-void BKE_gpencil_eval_geometry(const struct Depsgraph *depsgraph, struct bGPdata *gpd);
+void BKE_gpencil_eval_geometry(struct Depsgraph *depsgraph, struct bGPdata *gpd);
 
 /* modifiers */
 bool BKE_gpencil_has_geometry_modifiers(struct Object *ob);
diff --git a/source/blender/blenkernel/intern/gpencil_modifier.c b/source/blender/blenkernel/intern/gpencil_modifier.c
index 9cde674c1cd..9af55adfa79 100644
--- a/source/blender/blenkernel/intern/gpencil_modifier.c
+++ b/source/blender/blenkernel/intern/gpencil_modifier.c
@@ -48,8 +48,9 @@
 #include "BKE_lattice.h"
 #include "BKE_modifier.h"
 #include "BKE_object.h"
- 
+
 #include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
 
 /* *************************************************** */
 /* Geometry Utilities */
@@ -417,13 +418,36 @@ void BKE_gpencil_geometry_modifiers(Depsgraph *depsgraph, Object *ob, bGPDlayer
 
 /* *************************************************** */
 
-void BKE_gpencil_eval_geometry(const Depsgraph *UNUSED(depsgraph),
-                               bGPdata *UNUSED(gpd))
+void BKE_gpencil_eval_geometry(Depsgraph *depsgraph,
+                               bGPdata *gpd)
 {
+	DEG_debug_print_eval(depsgraph, __func__, gpd->id.name, gpd);
+	int ctime = (int)DEG_get_ctime(depsgraph);
+
+	/* update active frame */
+	for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
+		gpl->actframe = BKE_gpencil_layer_getframe(gpl, ctime, GP_GETFRAME_USE_PREV);
+	}
+
 	/* TODO: Move "derived_gpf" logic here from DRW_gpencil_populate_datablock()?
-	 * This way, we wouldn't have to mess around trying to figure out how to pass
-	 * an EvaluationContext to each of the modifiers.
+	 * This would be better than inventing our own logic for this stuff...
 	 */
+
+	/* TODO: Move the following code to "BKE_gpencil_eval_done()" (marked as an exit node)
+	 * later when there's more happening here. For now, let's just keep this in here to avoid
+	 * needing to have one more node slowing down evaluation...
+	 */
+	if (DEG_is_active(depsgraph)) {
+		bGPdata *gpd_orig = (bGPdata *)DEG_get_original_id(&gpd->id);
+
+		/* sync "actframe" changes back to main-db too,
+		 * so that editing tools work with copy-on-write
+		 * when the current frame changes
+		 */
+		for (bGPDlayer *gpl = gpd_orig->layers.first; gpl; gpl = gpl->next) {
+			gpl->actframe = BKE_gpencil_layer_getframe(gpl, ctime, GP_GETFRAME_USE_PREV);
+		}
+	}
 }



More information about the Bf-blender-cvs mailing list