[Bf-blender-cvs] [32a1cba5046] greasepencil-object: Calc UV data while painting

Antonio Vazquez noreply at git.blender.org
Tue Feb 20 17:02:11 CET 2018


Commit: 32a1cba504663e92549b8f126d03aca6377f7dca
Author: Antonio Vazquez
Date:   Mon Feb 19 19:07:06 2018 +0100
Branches: greasepencil-object
https://developer.blender.org/rB32a1cba504663e92549b8f126d03aca6377f7dca

Calc UV data while painting

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

M	source/blender/draw/engines/gpencil/gpencil_geom.c
M	source/blender/editors/gpencil/gpencil_paint.c

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

diff --git a/source/blender/draw/engines/gpencil/gpencil_geom.c b/source/blender/draw/engines/gpencil/gpencil_geom.c
index f307ad9dcea..433ab190813 100644
--- a/source/blender/draw/engines/gpencil/gpencil_geom.c
+++ b/source/blender/draw/engines/gpencil/gpencil_geom.c
@@ -210,6 +210,8 @@ static void gpencil_tpoint_to_point(Scene *scene, ARegion *ar, View3D *v3d, floa
 
 	pt->pressure = tpt->pressure;
 	pt->strength = tpt->strength;
+	pt->uv_fac = tpt->uv_fac;
+	pt->uv_rot = tpt->uv_rot;
 }
 
 /* create batch geometry data for current buffer stroke shader */
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 9faf89dd2a0..29f45298718 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -185,6 +185,8 @@ typedef struct tGPsdata {
 	short keymodifier;   /* key used for invoking the operator */
 	short shift;         /* shift modifier flag */
 
+	float totpixlen;     /* size in pixels for uv calculation */
+
 	ReportList *reports;
 } tGPsdata;
 
@@ -497,6 +499,8 @@ static short gp_stroke_addpoint(
 	tGPspoint *pt;
 	ToolSettings *ts = p->scene->toolsettings;
 	Object *obact = (Object *)p->ownerPtr.data;
+	RegionView3D *rv3d = p->ar->regiondata;
+	PaletteColor *palcolor = p->palettecolor;
 
 	/* check painting mode */
 	if (p->paintmode == GP_PAINTMODE_DRAW_STRAIGHT) {
@@ -604,6 +608,19 @@ static short gp_stroke_addpoint(
 		/* point time */
 		pt->time = (float)(curtime - p->inittime);
 		
+		/* point uv */
+		if (gpd->sbuffer_size > 1) {
+			tGPspoint *ptb = (tGPspoint *)gpd->sbuffer + gpd->sbuffer_size - 2;
+			p->totpixlen += (float) len_v2v2_int(&pt->x, &ptb->x);
+			pt->uv_fac = p->totpixlen;
+			if ((palcolor) && (palcolor->sima)) {
+				pt->uv_fac /= palcolor->sima->gen_x;
+			}
+		}
+		else {
+			pt->uv_fac = 0.0f;
+		}
+
 		/* increment counters */
 		gpd->sbuffer_size++;



More information about the Bf-blender-cvs mailing list