[Bf-blender-cvs] [30522238707] greasepencil-object: Fix: Add depsgraph relations from Palettes to GP data

Joshua Leung noreply at git.blender.org
Fri Dec 8 06:25:28 CET 2017


Commit: 305222387070911dd039094f0719db313681fac6
Author: Joshua Leung
Date:   Fri Dec 8 18:25:14 2017 +1300
Branches: greasepencil-object
https://developer.blender.org/rB305222387070911dd039094f0719db313681fac6

Fix: Add depsgraph relations from Palettes to GP data

This fixes problems where changing Palette setings (such as fill opacity)
should refresh the viewport (e.g. if there wasn't a fill before, changing
the slider should make it appear, instead of requiring a framechange to
make that happen).

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

M	source/blender/blenkernel/intern/gpencil.c
M	source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
M	source/blender/depsgraph/intern/builder/deg_builder_relations.cc
M	source/blender/depsgraph/intern/depsgraph_tag.cc
M	source/blender/makesrna/intern/rna_palette.c

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

diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index cd97513f1c5..32a43c5c312 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -2598,4 +2598,4 @@ void BKE_get_falloff_factor(bGPDframe *gpf, int actnum, int f_init, int f_end, C
 	else {
 		*r_value = 1.0f;
 	}
-}
\ No newline at end of file
+}
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
index 1d4d7874c45..f144b69bf7d 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
@@ -1377,7 +1377,12 @@ void DepsgraphNodeBuilder::build_palette(Palette *palette)
 {
 	ID *palette_id = &palette->id;
 
-	add_id_node(palette_id);
+	/* palette itself */
+	add_operation_node(palette_id,
+	                   DEG_NODE_TYPE_PARAMETERS,
+	                   NULL,
+	                   DEG_OPCODE_PARAMETERS_EVAL);
+	/* palette's animdata */
 	build_animdata(palette_id);
 }
 
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index 745574ab995..8fdad86722e 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -1717,6 +1717,8 @@ void DepsgraphRelationBuilder::build_obdata_geom(Object *object)
 		
 		case OB_GPENCIL: /* Grease Pencil */
 		{
+			bGPdata *gpd = (bGPdata *)obdata;
+			
 			/* Geometry cache needs to be recalculated on frame change
 			 * (e.g. to fix crashes after scrubbing the timeline when
 			 *  onion skinning is enabled, since the ghosts need to be
@@ -1725,6 +1727,18 @@ void DepsgraphRelationBuilder::build_obdata_geom(Object *object)
 			TimeSourceKey time_key;
 			ComponentKey geometry_key(obdata, DEG_NODE_TYPE_GEOMETRY);
 			add_relation(time_key, geometry_key, "GP Frame Change");
+			
+			/* Geometry cache also needs to be recalculated when Palette
+			 * settings change (e.g. when fill.opacity changes on/off,
+			 * we need to rebuild the bGPDstroke->triangles caches)
+			 */
+			LINKLIST_FOREACH (bGPDpaletteref *, palslot, &gpd->palette_slots) {
+				if (palslot->palette) {
+					printf("add paletteslot - %s.%s\n", gpd->id.name, palslot->palette->id.name);
+					ComponentKey palette_key(&palslot->palette->id, DEG_NODE_TYPE_PARAMETERS);
+					add_relation(palette_key, geometry_key, "Palette -> GP Data");
+				}
+			}
 			break;
 		}
 	}
diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc
index c6b8d4c93b3..37dde8eadad 100644
--- a/source/blender/depsgraph/intern/depsgraph_tag.cc
+++ b/source/blender/depsgraph/intern/depsgraph_tag.cc
@@ -174,7 +174,7 @@ void id_tag_update_object_data(Depsgraph *graph, IDDepsNode *id_node)
 		case ID_ME:
 			data_comp = id_node->find_component(DEG_NODE_TYPE_GEOMETRY);
 			break;
-		case ID_PA:
+		case ID_PA: /* Particles */
 			return;
 		case ID_LP:
 			data_comp = id_node->find_component(DEG_NODE_TYPE_PARAMETERS);
@@ -182,6 +182,9 @@ void id_tag_update_object_data(Depsgraph *graph, IDDepsNode *id_node)
 		case ID_GD:
 			data_comp = id_node->find_component(DEG_NODE_TYPE_GEOMETRY);
 			break;
+		case ID_PAL: /* Palettes */
+			data_comp = id_node->find_component(DEG_NODE_TYPE_PARAMETERS);
+			break;
 		default:
 			break;
 	}
diff --git a/source/blender/makesrna/intern/rna_palette.c b/source/blender/makesrna/intern/rna_palette.c
index 8a89e79d5f6..cb160c5d966 100644
--- a/source/blender/makesrna/intern/rna_palette.c
+++ b/source/blender/makesrna/intern/rna_palette.c
@@ -50,10 +50,15 @@
 #include "BKE_report.h"
 #include "BKE_gpencil.h"
 #include "BKE_library.h"
+ 
+#include "DEG_depsgraph.h"
+#include "DNA_object_types.h"
 
-static void rna_GPencil_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
+static void rna_Palette_dependency_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
 {
-	BKE_gpencil_batch_cache_alldirty_main(bmain);
+	DEG_id_tag_update(ptr->id.data, OB_RECALC_DATA);
+	
+	/* notifiers are for GPencil stuff, since only GPencil needs palettes to update the depsgraph */
 	WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL);
 }
 
@@ -244,7 +249,7 @@ static void rna_def_palettecolor(BlenderRNA *brna)
 	RNA_def_property_float_sdna(prop, NULL, "rgb");
 	RNA_def_property_array(prop, 3);
 	RNA_def_property_ui_text(prop, "Color", "");
-	RNA_def_property_update(prop, NC_SCREEN | NC_SCENE | ND_TOOLSETTINGS | ND_DATA | NC_GPENCIL, "rna_GPencil_update");
+	RNA_def_property_update(prop, NC_SCREEN | NC_SCENE | ND_TOOLSETTINGS | ND_DATA | NC_GPENCIL, "rna_Palette_dependency_update");
 
 	prop = RNA_def_property(srna, "strength", PROP_FLOAT, PROP_NONE);
 	RNA_def_property_range(prop, 0.0, 1.0);
@@ -262,7 +267,7 @@ static void rna_def_palettecolor(BlenderRNA *brna)
 	RNA_def_property_float_sdna(prop, NULL, "rgb[3]");
 	RNA_def_property_range(prop, 0.0, 1.0f);
 	RNA_def_property_ui_text(prop, "Opacity", "Color Opacity");
-	RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS | ND_DATA | NC_GPENCIL, "rna_GPencil_update");
+	RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS | ND_DATA | NC_GPENCIL, "rna_Palette_dependency_update");
 
 	/* Name */
 	prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
@@ -270,7 +275,7 @@ static void rna_def_palettecolor(BlenderRNA *brna)
 	RNA_def_struct_name_property(srna, prop);
 	RNA_def_property_string_funcs(prop, NULL, NULL, "rna_PaletteColor_info_set");
 	RNA_def_property_ui_text(prop, "Name", "Color name");
-	RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS | ND_DATA | NC_GPENCIL, "rna_GPencil_update");
+	RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS | ND_DATA | NC_GPENCIL, "rna_Palette_dependency_update");
 
 	/* Fill Drawing Color */
 	prop = RNA_def_property(srna, "fill_color", PROP_FLOAT, PROP_COLOR_GAMMA);
@@ -278,14 +283,14 @@ static void rna_def_palettecolor(BlenderRNA *brna)
 	RNA_def_property_array(prop, 3);
 	RNA_def_property_range(prop, 0.0f, 1.0f);
 	RNA_def_property_ui_text(prop, "Fill Color", "Color for filling region bounded by each stroke");
-	RNA_def_property_update(prop, NC_SCREEN | NC_SCENE | ND_TOOLSETTINGS | ND_DATA | NC_GPENCIL, "rna_GPencil_update");
+	RNA_def_property_update(prop, NC_SCREEN | NC_SCENE | ND_TOOLSETTINGS | ND_DATA | NC_GPENCIL, "rna_Palette_dependency_update");
 
 	/* Fill alpha */
 	prop = RNA_def_property(srna, "fill_alpha", PROP_FLOAT, PROP_NONE);
 	RNA_def_property_float_sdna(prop, NULL, "fill[3]");
 	RNA_def_property_range(prop, 0.0, 1.0f);
 	RNA_def_property_ui_text(prop, "Fill Opacity", "Opacity for filling region bounded by each stroke");
-	RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS | ND_DATA | NC_GPENCIL, "rna_GPencil_update");
+	RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS | ND_DATA | NC_GPENCIL, "rna_Palette_dependency_update");
 	
 	/* Secondary Drawing Color */
 	prop = RNA_def_property(srna, "mix_color", PROP_FLOAT, PROP_COLOR_GAMMA);
@@ -293,132 +298,132 @@ static void rna_def_palettecolor(BlenderRNA *brna)
 	RNA_def_property_array(prop, 4);
 	RNA_def_property_range(prop, 0.0f, 1.0f);
 	RNA_def_property_ui_text(prop, "Mix Color", "Color for mixing with primary filling color");
-	RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS | ND_DATA | NC_GPENCIL, "rna_GPencil_update");
+	RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS | ND_DATA | NC_GPENCIL, "rna_Palette_dependency_update");
 	
 	/* Mix factor */
 	prop = RNA_def_property(srna, "mix_factor", PROP_FLOAT, PROP_NONE);
 	RNA_def_property_float_sdna(prop, NULL, "mix_factor");
 	RNA_def_property_range(prop, 0.0f, 1.0f);
 	RNA_def_property_ui_text(prop, "Mix", "Mix Adjustment Factor");
-	RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS | ND_DATA | NC_GPENCIL, "rna_GPencil_update");
+	RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS | ND_DATA | NC_GPENCIL, "rna_Palette_dependency_update");
 
 	/* Scale factor for uv coordinates */
 	prop = RNA_def_property(srna, "pattern_scale", PROP_FLOAT, PROP_COORDS);
 	RNA_def_property_float_sdna(prop, NULL, "g_scale");
 	RNA_def_property_array(prop, 2);
 	RNA_def_property_ui_text(prop, "Scale", "Scale Factor for UV coordinates");
-	RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS | ND_DATA | NC_GPENCIL, "rna_GPencil_update");
+	RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS | ND_DATA | NC_GPENCIL, "rna_Palette_dependency_update");
 
 	/* Shift factor to move pattern filling in 2d space */
 	prop = RNA_def_property(srna, "pattern_shift", PROP_FLOAT, PROP_COORDS);
 	RNA_def_property_float_sdna(prop, NULL, "g_shift");
 	RNA_def_property_array(prop, 2);
 	RNA_def_property_ui_text(prop, "Shift", "Shift filling pattern in 2d space");
-	RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS | ND_DATA | NC_GPENCIL, "rna_GPencil_update");
+	RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS | ND_DATA | NC_GPENCIL, "rna_Palette_dependency_update");
 
 	/* Gradient angle */
 	prop = RNA_def_property(srna, "pattern_angle", PROP_FLOAT, PROP_ANGLE);
 	RNA_def_property_float_sdna(prop, NULL, "g_angle");
 	RNA_def_property_ui_text(prop, "Angle", "Pattern Orientation Angle");
-	RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS | ND_DATA | NC_GPENCIL, "rna_GPencil_update");
+	RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS | ND_DATA | NC_GPENCIL, "rna_Palette_dependency_update");
 
 	/* Gradient radius */
 	prop = RNA_def_property(srna, "pattern_radius", PROP_FLOAT, PROP_NONE);
 	RNA_def_property_float_sdna(prop, NULL, "g_radius");
 	RNA_def_property_range(prop, 0.0001f, 10.0f);
 	RNA_def_property_ui_text(prop, "Radius", "Pattern Radius");
-	RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS | ND_DATA | NC_GPENCIL, "rna_GPencil_update");
+	RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS | ND_DATA | NC_GPENCIL, "rna_Palette_dependency_update");
 
 	/* Box size */
 	prop = RNA_def_property(srna, "pattern_boxsize", PROP_FLOAT, PROP_NONE);
 	RNA_def_property_float_sdna(prop, NULL, "g_boxsize");
 	

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list