[Bf-blender-cvs] [e471663da6b] greasepencil-object: Move bGPDstroke runtime data to bGPDstroke_runtime struct

Antonio Vazquez noreply at git.blender.org
Sat May 12 18:51:53 CEST 2018


Commit: e471663da6b4492eea32032a7dc6b1ccb6058fec
Author: Antonio Vazquez
Date:   Sat May 12 18:43:26 2018 +0200
Branches: greasepencil-object
https://developer.blender.org/rBe471663da6b4492eea32032a7dc6b1ccb6058fec

Move bGPDstroke runtime data to bGPDstroke_runtime struct

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

M	source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
M	source/blender/draw/engines/gpencil/gpencil_draw_utils.c
M	source/blender/editors/gpencil/gpencil_edit.c
M	source/blender/editors/transform/transform.c
M	source/blender/editors/transform/transform_conversions.c
M	source/blender/makesdna/DNA_gpencil_types.h
M	source/blender/modifiers/intern/MOD_gpencilcolor.c
M	source/blender/modifiers/intern/MOD_gpenciltint.c

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

diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
index aea6a995ac9..35de2cde774 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -512,7 +512,7 @@ Gwn_Batch *DRW_gpencil_get_edit_geom(bGPDstroke *gps, float alpha, short dflag)
 				fsize = vsize;
 			}
 			else {
-				copy_v4_v4(fcolor, gps->tmp_rgb);
+				copy_v4_v4(fcolor, gps->runtime.tmp_rgb);
 				fsize = bsize;
 			}
 		}
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
index 45ad52c3afa..a7bd28a79e2 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
@@ -510,8 +510,8 @@ static void gpencil_add_fill_shgroup(GpencilBatchCache *cache, DRWShadingGroup *
 	if (gps->totpoints >= 3) {
 		float tfill[4];
 		/* set color using material, tint color and opacity */
-		interp_v3_v3v3(tfill, gps->tmp_fill, tintcolor, tintcolor[3]);
-		tfill[3] = gps->tmp_fill[3] * gpl->opacity;
+		interp_v3_v3v3(tfill, gps->runtime.tmp_fill, tintcolor, tintcolor[3]);
+		tfill[3] = gps->runtime.tmp_fill[3] * gpl->opacity;
 		if ((tfill[3] > GPENCIL_ALPHA_OPACITY_THRESH) || (gp_style->fill_style > 0)) {
 			const float *color;
 			if (!onion) {
@@ -522,7 +522,7 @@ static void gpencil_add_fill_shgroup(GpencilBatchCache *cache, DRWShadingGroup *
 					color = tintcolor;
 				}
 				else {
-					ARRAY_SET_ITEMS(tfill, UNPACK3(gps->tmp_fill), tintcolor[3]);
+					ARRAY_SET_ITEMS(tfill, UNPACK3(gps->runtime.tmp_fill), tintcolor[3]);
 					color = tfill;
 				}
 			}
@@ -549,12 +549,12 @@ static void gpencil_add_stroke_shgroup(GpencilBatchCache *cache, DRWShadingGroup
 	if (!onion) {
 		/* if special stroke, use fill color as stroke color */
 		if (gps->flag & GP_STROKE_NOFILL) {
-			interp_v3_v3v3(tcolor, gps->tmp_fill, tintcolor, tintcolor[3]);
-			tcolor[3] = gps->tmp_fill[3] * opacity;
+			interp_v3_v3v3(tcolor, gps->runtime.tmp_fill, tintcolor, tintcolor[3]);
+			tcolor[3] = gps->runtime.tmp_fill[3] * opacity;
 		}
 		else {
-			interp_v3_v3v3(tcolor, gps->tmp_rgb, tintcolor, tintcolor[3]);
-			tcolor[3] = gps->tmp_rgb[3] * opacity;
+			interp_v3_v3v3(tcolor, gps->runtime.tmp_rgb, tintcolor, tintcolor[3]);
+			tcolor[3] = gps->runtime.tmp_rgb[3] * opacity;
 		}
 		copy_v4_v4(ink, tcolor);
 	}
@@ -563,7 +563,7 @@ static void gpencil_add_stroke_shgroup(GpencilBatchCache *cache, DRWShadingGroup
 			copy_v4_v4(ink, tintcolor);
 		}
 		else {
-			ARRAY_SET_ITEMS(tcolor, gps->tmp_rgb[0], gps->tmp_rgb[1], gps->tmp_rgb[2], opacity);
+			ARRAY_SET_ITEMS(tcolor, gps->runtime.tmp_rgb[0], gps->runtime.tmp_rgb[1], gps->runtime.tmp_rgb[2], opacity);
 			copy_v4_v4(ink, tcolor);
 		}
 	}
@@ -640,8 +640,8 @@ static void gpencil_draw_onion_strokes(GpencilBatchCache *cache, GPENCIL_e_data
 	for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
 		
 		MaterialGPencilStyle *gp_style = BKE_material_gpencil_settings_get(ob, gps->mat_nr + 1);
-		copy_v4_v4(gps->tmp_rgb, gp_style->rgb);
-		copy_v4_v4(gps->tmp_fill, gp_style->fill);
+		copy_v4_v4(gps->runtime.tmp_rgb, gp_style->rgb);
+		copy_v4_v4(gps->runtime.tmp_fill, gp_style->fill);
 
 		int id = stl->storage->shgroup_id;
 		/* check if stroke can be drawn */
@@ -768,8 +768,8 @@ static void gpencil_draw_strokes(GpencilBatchCache *cache, GPENCIL_e_data *e_dat
 			strokegrp = stl->shgroups[id].shgrps_stroke;
 
 			/* copy color to temp fields to apply temporal changes in the stroke */
-			copy_v4_v4(gps->tmp_rgb, gp_style->rgb);
-			copy_v4_v4(gps->tmp_fill, gp_style->fill);
+			copy_v4_v4(gps->runtime.tmp_rgb, gp_style->rgb);
+			copy_v4_v4(gps->runtime.tmp_fill, gp_style->fill);
 
 			/* apply modifiers (only modify geometry, but not create ) */
 			if ((cache->is_dirty) && (ob->modifiers.first) && (!is_multiedit)) {
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index afda13304f5..75b99952ffc 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -558,7 +558,7 @@ static void gp_duplicate_points(const bGPDstroke *gps, ListBase *new_strokes, co
 				
 				/* make a stupid copy first of the entire stroke (to get the flags too) */
 				gpsd = MEM_dupallocN(gps);
-				BLI_strncpy(gpsd->tmp_layerinfo, layername, sizeof(gpsd->tmp_layerinfo)); /* saves original layer name */
+				BLI_strncpy(gpsd->runtime.tmp_layerinfo, layername, sizeof(gpsd->runtime.tmp_layerinfo)); /* saves original layer name */
 				
 				/* initialize triangle memory - will be calculated on next redraw */
 				gpsd->triangles = NULL;
@@ -630,7 +630,7 @@ static int gp_duplicate_exec(bContext *C, wmOperator *op)
 					
 					/* make direct copies of the stroke and its points */
 					gpsd = MEM_dupallocN(gps);
-					BLI_strncpy(gpsd->tmp_layerinfo, gpl->info, sizeof(gpsd->tmp_layerinfo));
+					BLI_strncpy(gpsd->runtime.tmp_layerinfo, gpl->info, sizeof(gpsd->runtime.tmp_layerinfo));
 					gpsd->points = MEM_dupallocN(gps->points);
 					BKE_gpencil_stroke_weights_duplicate(gps, gpsd);
 
@@ -804,7 +804,7 @@ static int gp_strokes_copy_exec(bContext *C, wmOperator *op)
 					
 					/* make direct copies of the stroke and its points */
 					gpsd = MEM_dupallocN(gps);
-					BLI_strncpy(gpsd->tmp_layerinfo, gpl->info, sizeof(gpsd->tmp_layerinfo)); /* saves original layer name */
+					BLI_strncpy(gpsd->runtime.tmp_layerinfo, gpl->info, sizeof(gpsd->runtime.tmp_layerinfo)); /* saves original layer name */
 					gpsd->points = MEM_dupallocN(gps->points);
 					BKE_gpencil_stroke_weights_duplicate(gps, gpsd);
 
@@ -960,7 +960,7 @@ static int gp_strokes_paste_exec(bContext *C, wmOperator *op)
 		if (ED_gpencil_stroke_can_use(C, gps)) {
 			/* Need to verify if layer exists */
 			if (type != GP_COPY_MERGE) {
-				gpl = BLI_findstring(&gpd->layers, gps->tmp_layerinfo, offsetof(bGPDlayer, info));
+				gpl = BLI_findstring(&gpd->layers, gps->runtime.tmp_layerinfo, offsetof(bGPDlayer, info));
 				if (gpl == NULL) {
 					/* no layer - use active (only if layer deleted before paste) */
 					gpl = CTX_data_active_gpencil_layer(C);
@@ -976,7 +976,7 @@ static int gp_strokes_paste_exec(bContext *C, wmOperator *op)
 			if (gpf) {
 				/* Create new stroke */
 				bGPDstroke *new_stroke = MEM_dupallocN(gps);
-				new_stroke->tmp_layerinfo[0] = '\0';
+				new_stroke->runtime.tmp_layerinfo[0] = '\0';
 				
 				new_stroke->points = MEM_dupallocN(gps->points);
 				BKE_gpencil_stroke_weights_duplicate(gps, new_stroke);
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 272135243e6..8a1661cf9f5 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -3501,7 +3501,7 @@ static void ElementResize(TransInfo *t, TransDataContainer *tc, TransData *td, f
 	/* grease pencil falloff */
 	if (t->options & CTX_GPENCIL_STROKES) {
 		bGPDstroke *gps = (bGPDstroke *)td->extra;
-		mul_v3_fl(vec, td->factor * gps->multi_frame_falloff);
+		mul_v3_fl(vec, td->factor * gps->runtime.multi_frame_falloff);
 
 		/* scale stroke thickness */
 		if (td->val) {
@@ -3509,7 +3509,7 @@ static void ElementResize(TransInfo *t, TransDataContainer *tc, TransData *td, f
 			applyNumInput(&t->num, t->values);
 
 			float ratio = t->values[0];
-			*td->val = td->ival * ratio * gps->multi_frame_falloff;
+			*td->val = td->ival * ratio * gps->runtime.multi_frame_falloff;
 			CLAMP_MIN(*td->val, 0.001f);
 		}
 
@@ -3877,7 +3877,7 @@ static void ElementRotation_ex(TransInfo *t, TransDataContainer *tc, TransData *
 			float sy = smat[1][1];
 			float sz = smat[2][2];
 
-			mul_m3_fl(smat, gps->multi_frame_falloff);
+			mul_m3_fl(smat, gps->runtime.multi_frame_falloff);
 			/* fix scale */
 			smat[0][0] = sx;
 			smat[1][1] = sy;
@@ -4561,7 +4561,7 @@ static void applyTranslationValue(TransInfo *t, const float vec[3])
 			if (t->options & CTX_GPENCIL_STROKES) {
 				/* grease pencil multiframe falloff */
 				bGPDstroke *gps = (bGPDstroke *)td->extra;
-				mul_v3_fl(tvec, td->factor * gps->multi_frame_falloff);
+				mul_v3_fl(tvec, td->factor * gps->runtime.multi_frame_falloff);
 			}
 			else {
 				/* proportional editing falloff */
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index c3414eda6e1..7669e38c468 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -8240,7 +8240,7 @@ static void createTransGPencil(bContext *C, TransInfo *t)
 							}
 #endif
 							/* save falloff factor */
-							gps->multi_frame_falloff = falloff;
+							gps->runtime.multi_frame_falloff = falloff;
 
 							/* add all necessary points... */
 							for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h
index 634709676c0..00478c8d85c 100644
--- a/source/blender/makesdna/DNA_gpencil_types.h
+++ b/source/blender/makesdna/DNA_gpencil_types.h
@@ -152,6 +152,17 @@ typedef enum eGPDpalette_Flag {
  * 	-> A stroke represents a (simplified version) of the curve
  *	   drawn by the user in one 'mousedown'->'mouseup' operation
  */
+typedef struct bGPDstroke_runtime {
+	/* runtime final colors (result of original colors and modifiers) */
+	float tmp_rgb[4];
+	float tmp_fill[4];
+
+	/* temporary layer name only used during copy/paste to put the stroke in the original layer */
+	char tmp_layerinfo[128];
+
+	float multi_frame_falloff; /* runtime falloff factor (only for transform) */
+} bGPDstroke_runtime;
+
 typedef struct bGPDstroke {
 	struct bGPDstroke *next, *prev;
 
@@ -167,15 +178,11 @@ typedef struct bGPDstroke {
 
 	char colorname[128] DNA_DEPRECATED;    /* color name */
 
-	/* runtime final colors (result of original colors and modifiers) */
-	float tmp_rgb[4];
-	float tmp_fill[4];
-
-	/* temporary layer name only used during copy/paste to put the strok

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list