[Bf-blender-cvs] [f6bafef1e1a] master: GPencil: Move Object Depth Order to Object

Antonioya noreply at git.blender.org
Mon Mar 4 17:06:06 CET 2019


Commit: f6bafef1e1a84ce5b5fcdbc1e53e3341d4433f3b
Author: Antonioya
Date:   Mon Mar 4 17:05:44 2019 +0100
Branches: master
https://developer.blender.org/rBf6bafef1e1a84ce5b5fcdbc1e53e3341d4433f3b

GPencil: Move Object Depth Order to Object

There was a conflict between Object "In Front" and how the strokes were managed in Stroke panel for grease pencil datablock.

In order to keep consistency, the order of the object has been moved to Object level and now it's using the standard "In Front" flag. As all it is 3D, the option "Back" has been removed.

This also fixes the problem with task T62137.

Also related to commit 54ffc4e19dc4 and D4405

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

M	release/scripts/startup/bl_ui/properties_data_gpencil.py
M	source/blender/blenkernel/intern/gpencil.c
M	source/blender/draw/engines/gpencil/gpencil_draw_utils.c
M	source/blender/draw/engines/gpencil/gpencil_engine.c
M	source/blender/draw/engines/gpencil/gpencil_engine.h
M	source/blender/draw/engines/gpencil/shaders/gpencil_fill_frag.glsl
M	source/blender/draw/engines/gpencil/shaders/gpencil_point_geom.glsl
M	source/blender/draw/engines/gpencil/shaders/gpencil_stroke_geom.glsl
M	source/blender/editors/gpencil/annotate_paint.c
M	source/blender/editors/gpencil/drawgpencil.c
M	source/blender/makesdna/DNA_gpencil_types.h
M	source/blender/makesrna/intern/rna_gpencil.c

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

diff --git a/release/scripts/startup/bl_ui/properties_data_gpencil.py b/release/scripts/startup/bl_ui/properties_data_gpencil.py
index b8b197ac3ac..d383982f61e 100644
--- a/release/scripts/startup/bl_ui/properties_data_gpencil.py
+++ b/release/scripts/startup/bl_ui/properties_data_gpencil.py
@@ -347,9 +347,9 @@ class DATA_PT_gpencil_strokes(DataButtonsPanel, Panel):
 
         gpd = context.gpencil_data
 
-        layout.prop(gpd, "object_depth_order")
-        if gpd.object_depth_order == '3DSPACE':
-            layout.prop(gpd, "stroke_depth_order")
+        col = layout.column(align=True)
+        col.prop(gpd, "stroke_depth_order")
+        col.enabled = not ob.show_in_front
 
         col = layout.column(align=True)
         col.prop(gpd, "stroke_thickness_space")
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index 108192c5be9..c9cb38fcc4e 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -411,7 +411,6 @@ bGPdata *BKE_gpencil_data_addnew(Main *bmain, const char name[])
 	/* GP object specific settings */
 	ARRAY_SET_ITEMS(gpd->line_color, 0.6f, 0.6f, 0.6f, 0.5f);
 
-	gpd->xray_mode = GP_XRAY_3DSPACE;
 	gpd->pixfactor = GP_DEFAULT_PIX_FACTOR;
 
 	/* grid settings */
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
index 1b406f298cd..e77f570b7bd 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
@@ -416,7 +416,8 @@ static DRWShadingGroup *DRW_gpencil_shgroup_fill_create(
 	stl->shgroups[id].texture_flip = gp_style->flag & GP_STYLE_COLOR_FLIP_FILL ? 1 : 0;
 	DRW_shgroup_uniform_int(grp, "texture_flip", &stl->shgroups[id].texture_flip, 1);
 
-	DRW_shgroup_uniform_int(grp, "xraymode", (const int *) &gpd->xray_mode, 1);
+	stl->shgroups[id].xray_mode = (ob->dtx & OB_DRAWXRAY) ? GP_XRAY_FRONT : GP_XRAY_3DSPACE;
+	DRW_shgroup_uniform_int(grp, "xraymode", &stl->shgroups[id].xray_mode, 1);
 	DRW_shgroup_uniform_int(grp, "drawmode", (const int *) &gpd->draw_mode, 1);
 
 	/* viewport x-ray */
@@ -570,7 +571,8 @@ DRWShadingGroup *DRW_gpencil_shgroup_stroke_create(
 	}
 
 	if ((gpd) && (id > -1)) {
-		DRW_shgroup_uniform_int(grp, "xraymode", (const int *) &gpd->xray_mode, 1);
+		stl->shgroups[id].xray_mode = (ob->dtx & OB_DRAWXRAY) ? GP_XRAY_FRONT : GP_XRAY_3DSPACE;
+		DRW_shgroup_uniform_int(grp, "xraymode", &stl->shgroups[id].xray_mode, 1);
 	}
 	else {
 		/* for drawing always on predefined z-depth */
@@ -689,7 +691,8 @@ static DRWShadingGroup *DRW_gpencil_shgroup_point_create(
 	}
 
 	if (gpd) {
-		DRW_shgroup_uniform_int(grp, "xraymode", (const int *)&gpd->xray_mode, 1);
+		stl->shgroups[id].xray_mode = (ob->dtx & OB_DRAWXRAY) ? GP_XRAY_FRONT : GP_XRAY_3DSPACE;
+		DRW_shgroup_uniform_int(grp, "xraymode", (const int *)&stl->shgroups[id].xray_mode, 1);
 	}
 	else {
 		/* for drawing always on on predefined z-depth */
@@ -1495,7 +1498,7 @@ static void DRW_gpencil_shgroups_create(
 	GPENCIL_StorageList *stl = ((GPENCIL_Data *)vedata)->stl;
 	GPENCIL_PassList *psl = ((GPENCIL_Data *)vedata)->psl;
 	bGPdata *gpd = (bGPdata *)ob->data;
-	DRWPass *stroke_pass = GPENCIL_3D_DRAWMODE(gpd) ? psl->stroke_pass_3d : psl->stroke_pass_2d;
+	DRWPass *stroke_pass = GPENCIL_3D_DRAWMODE(ob, gpd) ? psl->stroke_pass_3d : psl->stroke_pass_2d;
 
 	GpencilBatchGroup *elm = NULL;
 	DRWShadingGroup *shgrp = NULL;
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c
index 60e6de164e7..b7d03900eb1 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -740,7 +740,7 @@ static void gpencil_free_obj_runtime(GPENCIL_StorageList *stl)
 static void gpencil_draw_pass_range(
 	GPENCIL_FramebufferList *fbl, GPENCIL_StorageList *stl,
 	GPENCIL_PassList *psl, GPENCIL_TextureList *txl,
-	GPUFrameBuffer *fb, bGPdata *gpd,
+	GPUFrameBuffer *fb, Object *ob, bGPdata *gpd,
 	DRWShadingGroup *init_shgrp, DRWShadingGroup *end_shgrp, bool multi)
 {
 	if (init_shgrp == NULL) {
@@ -753,7 +753,7 @@ static void gpencil_draw_pass_range(
 	}
 
 	DRW_draw_pass_subset(
-		GPENCIL_3D_DRAWMODE(gpd) ? psl->stroke_pass_3d : psl->stroke_pass_2d,
+		GPENCIL_3D_DRAWMODE(ob, gpd) ? psl->stroke_pass_3d : psl->stroke_pass_2d,
 		init_shgrp, end_shgrp);
 
 	if ((!stl->storage->is_mat_preview) && (multi)) {
@@ -780,6 +780,7 @@ static void drw_gpencil_select_render(GPENCIL_StorageList *stl, GPENCIL_PassList
 		for (int i = 0; i < stl->g_data->gp_cache_used; i++) {
 			cache_ob = &stl->g_data->gp_object_cache[i];
 			if (cache_ob) {
+				Object *ob = cache_ob->ob;
 				bGPdata *gpd = cache_ob->gpd;
 				init_shgrp = NULL;
 				if (cache_ob->tot_layers > 0) {
@@ -792,7 +793,7 @@ static void drw_gpencil_select_render(GPENCIL_StorageList *stl, GPENCIL_PassList
 					}
 					/* draw group */
 					DRW_draw_pass_subset(
-						GPENCIL_3D_DRAWMODE(gpd) ? psl->stroke_pass_3d : psl->stroke_pass_2d,
+						GPENCIL_3D_DRAWMODE(ob, gpd) ? psl->stroke_pass_3d : psl->stroke_pass_2d,
 						init_shgrp, end_shgrp);
 				}
 				/* the cache must be dirty for next loop */
@@ -911,7 +912,7 @@ void GPENCIL_draw_scene(void *ved)
 							/* draw pending groups */
 							gpencil_draw_pass_range(
 								fbl, stl, psl, txl, fbl->temp_fb_a,
-								gpd, init_shgrp, end_shgrp, is_last);
+								ob, gpd, init_shgrp, end_shgrp, is_last);
 
 							/* draw current group in separated texture */
 							init_shgrp = array_elm->init_shgrp;
@@ -921,7 +922,7 @@ void GPENCIL_draw_scene(void *ved)
 							GPU_framebuffer_clear_color_depth(fbl->temp_fb_fx, clearcol, 1.0f);
 							gpencil_draw_pass_range(
 							        fbl, stl, psl, txl, fbl->temp_fb_fx,
-							        gpd, init_shgrp, end_shgrp,
+							        ob, gpd, init_shgrp, end_shgrp,
 							        is_last);
 
 							/* Blend A texture and FX texture */
@@ -949,7 +950,7 @@ void GPENCIL_draw_scene(void *ved)
 					/* last group */
 					gpencil_draw_pass_range(
 					        fbl, stl, psl, txl, fbl->temp_fb_a,
-					        gpd, init_shgrp, end_shgrp,
+					        ob, gpd, init_shgrp, end_shgrp,
 					        true);
 				}
 
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h
index 0c917b038a4..1ab45328377 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -118,6 +118,7 @@ typedef struct GPENCIL_shgroup {
 	int keep_size;
 	int caps_mode[2];
 	float obj_scale;
+	int xray_mode;
 
 	/* color of the wireframe */
 	float wire_color[4];
@@ -467,8 +468,8 @@ void GPENCIL_render_to_image(void *vedata, struct RenderEngine *engine, struct R
 	} \
 }
 
-#define GPENCIL_3D_DRAWMODE(gpd) \
-	((gpd) && (gpd->draw_mode == GP_DRAWMODE_3D) && (gpd->xray_mode == GP_XRAY_3DSPACE))
+#define GPENCIL_3D_DRAWMODE(ob, gpd) \
+	((gpd) && (gpd->draw_mode == GP_DRAWMODE_3D) && (ob->dtx & OB_DRAWXRAY))
 
 #define GPENCIL_USE_SOLID(stl) \
 	((stl) && ((stl->storage->is_render) || (stl->storage->is_mat_preview)))
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_fill_frag.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_fill_frag.glsl
index b35970780a4..f0878c8bc89 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_fill_frag.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_fill_frag.glsl
@@ -35,7 +35,6 @@ uniform vec4 wire_color;
 
 #define GP_XRAY_FRONT 0
 #define GP_XRAY_3DSPACE 1
-#define GP_XRAY_BACK  2
 
 #define GP_DRAWMODE_2D 0
 #define GP_DRAWMODE_3D 1
@@ -163,9 +162,6 @@ void main()
 			gl_FragDepth = gl_FragCoord.z;
 		}
 	}
-	else if  (xraymode == GP_XRAY_BACK) {
-		gl_FragDepth = 0.999999;
-	}
 	else {
 		gl_FragDepth = 0.000001;
 	}
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_point_geom.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_point_geom.glsl
index 63f22e0f812..6c22633c521 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_point_geom.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_point_geom.glsl
@@ -14,7 +14,6 @@ out vec2 mTexCoord;
 
 #define GP_XRAY_FRONT 0
 #define GP_XRAY_3DSPACE 1
-#define GP_XRAY_BACK  2
 
 /* project 3d point to 2d on screen space */
 vec2 toScreenSpace(vec4 vertex)
@@ -31,9 +30,6 @@ float getZdepth(vec4 point)
 	if (xraymode == GP_XRAY_3DSPACE) {
 		return (point.z / point.w);
 	}
-	if  (xraymode == GP_XRAY_BACK) {
-		return 0.999999;
-	}
 
 	/* in front by default */
 	return 0.000001;
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_geom.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_geom.glsl
index ad85046487b..0caeb4c9d63 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_geom.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_geom.glsl
@@ -17,7 +17,6 @@ out vec2 uvfac;
 
 #define GP_XRAY_FRONT 0
 #define GP_XRAY_3DSPACE 1
-#define GP_XRAY_BACK  2
 
 /* keep this list synchronized with list in gpencil_engine.h */
 #define GPENCIL_COLOR_SOLID   0
@@ -41,9 +40,6 @@ float getZdepth(vec4 point)
 	if (xraymode == GP_XRAY_3DSPACE) {
 		return (point.z / point.w);
 	}
-	if  (xraymode == GP_XRAY_BACK) {
-		return 0.999999;
-	}
 
 	/* in front by default */
 	return 0.000001;
diff --git a/source/blender/editors/gpencil/annotate_paint.c b/source/blender/editors/gpencil/annotate_paint.c
index 5e1e33aa9be..a9654e50822 100644
--- a/source/blender/editors/gpencil/annotate_paint.c
+++ b/source/blender/editors/gpencil/annotate_paint.c
@@ -1188,9 +1188,6 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p)
 
 			/* mark datablock as being used for annotations */
 			gpd->flag |= GP_DATA_ANNOTATIONS;
-
-			/* annotations always in front of all objects */
-			gpd->xray_mode = GP_XRAY_FRONT;
 		}
 		p->gpd = *gpd_ptr;
 	}
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c
index b36929f66b0..8551dc6f981 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/e

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list