[Bf-blender-cvs] [7eb1d77a3db] greasepencil-object: Fix keep thicknees by object

Antonio Vazquez noreply at git.blender.org
Mon Jun 19 09:55:47 CEST 2017


Commit: 7eb1d77a3dbed89ea81d40929147484d8afca412
Author: Antonio Vazquez
Date:   Mon Jun 19 09:55:35 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rB7eb1d77a3dbed89ea81d40929147484d8afca412

Fix keep thicknees by object

This option must be by object, not by scene.

Cleanup some code too and rename to use better naming for variables.

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

M	source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
M	source/blender/draw/engines/gpencil/gpencil_engine.h
M	source/blender/draw/engines/gpencil/shaders/gpencil_stroke_vert.glsl

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

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 d4b14d23434..ac539ca359e 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -262,24 +262,18 @@ DRWShadingGroup *DRW_gpencil_shgroup_stroke_create(GPENCIL_Data *vedata, DRWPass
 		stl->shgroups[id].obj_zdepth = zdepth;
 		DRW_shgroup_uniform_float(grp, "objscale", &stl->shgroups[id].obj_scale, 1);
 		DRW_shgroup_uniform_float(grp, "obj_zdepth", &stl->shgroups[id].obj_zdepth, 1);
+		stl->shgroups[id].keep_size = (int)((gpd) && (gpd->flag & GP_DATA_STROKE_KEEPTHICKNESS));
+		DRW_shgroup_uniform_int(grp, "keep_size", &stl->shgroups[id].keep_size, 1);
 	}
 	else {
 		stl->storage->objscale = 1.0f;
 		stl->storage->zdepth = 0.0f;
+		stl->storage->keep_size = 0;
 		DRW_shgroup_uniform_float(grp, "objscale", &stl->storage->objscale, 1);
 		DRW_shgroup_uniform_float(grp, "obj_zdepth", &stl->storage->zdepth, 1);
+		DRW_shgroup_uniform_int(grp, "keep_size", &stl->storage->keep_size, 1);
 	}
 
-	/* If disable zoom for strokes, disable scale */
-	if ((gpd) && (gpd->flag & GP_DATA_STROKE_KEEPTHICKNESS)) {
-		stl->storage->is_persp = 0;
-	}
-	else {
-		stl->storage->is_persp = 1;
-	}
-
-	DRW_shgroup_uniform_int(grp, "is_persp", &stl->storage->is_persp, 1);
-
 	if (gpd) {
 		DRW_shgroup_uniform_int(grp, "xraymode", (const int *) &gpd->xray_mode, 1);
 	}
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h
index 4bf4ea8f275..928cab194e9 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -42,6 +42,7 @@ typedef struct GPENCIL_shgroup {
 	int t_clamp;
 	int fill_style;
 	int sort;
+	int keep_size;
 	float obj_zdepth;
 	float obj_scale;
 	struct DRWShadingGroup *shgrps_fill;
@@ -51,7 +52,7 @@ typedef struct GPENCIL_shgroup {
 typedef struct GPENCIL_Storage {
 	int pal_id; /* total elements */
 	float unit_matrix[4][4];
-	int is_persp;   /* rv3d->is_persp (1-yes) */
+	int keep_size;
 	int xray;
 	float objscale;
 	float zdepth;
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_vert.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_vert.glsl
index 813c784ee5e..205d5a02c7e 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_vert.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_vert.glsl
@@ -3,7 +3,7 @@ uniform mat4 ProjectionMatrix;
 
 uniform float pixsize;   /* rv3d->pixsize */
 uniform float pixelsize; /* U.pixelsize */
-uniform int is_persp;    /* 0: Keep Stroke size */
+uniform int keep_size;    
 uniform float objscale;
 
 in vec3 pos;
@@ -22,12 +22,12 @@ void main(void)
 	gl_Position = ModelViewProjectionMatrix * vec4( pos, 1.0 );
 	finalColor = color;
 
-	if (is_persp == TRUE) {
-		float size = (ProjectionMatrix[3][3] == 0.0) ? (thickness / (gl_Position.z * defaultpixsize)) : (thickness / defaultpixsize);
-		finalThickness = max(size * objscale, 1.0);
+	if (keep_size == TRUE) {
+		finalThickness = thickness;
 	}
 	else {
-		finalThickness = thickness;
+		float size = (ProjectionMatrix[3][3] == 0.0) ? (thickness / (gl_Position.z * defaultpixsize)) : (thickness / defaultpixsize);
+		finalThickness = max(size * objscale, 1.0);
 	}
 	
 } 
\ No newline at end of file




More information about the Bf-blender-cvs mailing list