[Bf-blender-cvs] [20573fbdc01] greasepencil-object: Cleanup: Define camera view type for pixel size

Antonio Vazquez noreply at git.blender.org
Mon Jun 12 16:56:23 CEST 2017


Commit: 20573fbdc0115ead5853b090bcbf7d2364c328fd
Author: Antonio Vazquez
Date:   Mon Jun 12 16:56:11 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rB20573fbdc0115ead5853b090bcbf7d2364c328fd

Cleanup: Define camera view type for pixel size

New define to make more clear and separate the perspective and camera view modes for pixel size calculation

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

M	source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
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 a85632fec12..882031a94bf 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -43,6 +43,10 @@
 
 #include "gpencil_engine.h"
 
+#define PIX_PERSPECTIVE 1
+#define PIX_ORTHOGRAPHIC 2
+#define PIX_CAMERAVIEW 3
+
 /* allocate cache to store GP objects */
 tGPencilObjectCache *gpencil_object_cache_allocate(tGPencilObjectCache *cache, int *gp_cache_size, int *gp_cache_used)
 {
@@ -311,7 +315,15 @@ DRWShadingGroup *DRW_gpencil_shgroup_stroke_create(GPENCIL_Data *vedata, DRWPass
 	DRW_shgroup_uniform_float(grp, "pixsize", &rv3d->pixsize, 1);
 	DRW_shgroup_uniform_float(grp, "pixelsize", &U.pixelsize, 1);
 
-	stl->storage->is_persp = rv3d->is_persp ? 1 : 2;
+	if (rv3d->is_persp) {
+		stl->storage->is_persp = PIX_PERSPECTIVE;
+		if (rv3d->persp == RV3D_CAMOB) {
+			stl->storage->is_persp = PIX_CAMERAVIEW;
+		}
+	}
+	else {
+		stl->storage->is_persp = PIX_ORTHOGRAPHIC;
+	}
 	/* If disable zoom for strokes, disable scale */
 	if ((gpd) && (gpd->flag & GP_DATA_STROKE_KEEPTHICKNESS)) {
 		stl->storage->is_persp = 0;
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 d01fd3b6297..1caed680c2c 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_vert.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_vert.glsl
@@ -2,7 +2,7 @@ uniform mat4 ModelViewProjectionMatrix;
 
 uniform float pixsize;   /* rv3d->pixsize */
 uniform float pixelsize; /* U.pixelsize */
-uniform int is_persp;    /* rv3d->is_persp (1-yes, 2->Orto), 0: No scale_thickness */
+uniform int is_persp;    /* rv3d->is_persp (1-Persp, 2->Orto, 3->Cameraview), 0: No scale */
 
 in vec3 pos;
 in vec4 color;
@@ -12,6 +12,9 @@ out vec4 finalColor;
 out float finalThickness;
 
 #define TRUE 1
+#define PIX_PERSPECTIVE 1
+#define PIX_ORTHOGRAPHIC 2
+#define PIX_CAMERAVIEW 3
 
 /* port of c code function */
 float mul_project_m4_v3_zfac(mat4 mat, vec3 co)
@@ -31,11 +34,11 @@ void main(void)
 	float pixsize = mul_project_m4_v3_zfac(ModelViewProjectionMatrix, pos) * defaultpixsize;
 	float scale_thickness = 1.0f;
 	
-	if (is_persp == 1) {
+	if ((is_persp == PIX_PERSPECTIVE) || (is_persp == PIX_CAMERAVIEW)) {
 		/* need a factor to mimmic old glLine size, 10.0f works fine */
 		scale_thickness = (defaultpixsize / pixsize) * 10.0f;
 	}
-	if (is_persp == 2) {
+	if (is_persp == PIX_ORTHOGRAPHIC) {
 		scale_thickness = (1.0f / pixsize) / 100.0f;
 	}




More information about the Bf-blender-cvs mailing list