[Bf-blender-cvs] [4711e0ee265] blender2.8: Non-Meshes: Add ghosting support (old x-ray)

Clément Foucault noreply at git.blender.org
Fri Aug 17 00:00:29 CEST 2018


Commit: 4711e0ee265717fad30105df35a1c51bfddea0ce
Author: Clément Foucault
Date:   Thu Aug 16 23:56:33 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB4711e0ee265717fad30105df35a1c51bfddea0ce

Non-Meshes: Add ghosting support (old x-ray)

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

M	source/blender/draw/modes/object_mode.c

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

diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c
index cf8fb3412f5..dc8ed1367b9 100644
--- a/source/blender/draw/modes/object_mode.c
+++ b/source/blender/draw/modes/object_mode.c
@@ -103,7 +103,7 @@ extern char datatoc_gpu_shader_uniform_color_frag_glsl[];
 
 /* *********** LISTS *********** */
 typedef struct OBJECT_PassList {
-	struct DRWPass *non_meshes;
+	struct DRWPass *non_meshes[2];
 	struct DRWPass *ob_center;
 	struct DRWPass *outlines;
 	struct DRWPass *outlines_search;
@@ -111,21 +111,20 @@ typedef struct OBJECT_PassList {
 	struct DRWPass *outlines_bleed;
 	struct DRWPass *outlines_resolve;
 	struct DRWPass *grid;
-	struct DRWPass *bone_solid;
-	struct DRWPass *bone_outline;
-	struct DRWPass *bone_wire;
-	struct DRWPass *bone_envelope;
-	struct DRWPass *bone_axes;
+	struct DRWPass *bone_solid[2];
+	struct DRWPass *bone_outline[2];
+	struct DRWPass *bone_wire[2];
+	struct DRWPass *bone_envelope[2];
+	struct DRWPass *bone_axes[2];
 	struct DRWPass *particle;
 	struct DRWPass *lightprobes;
-	/* use for empty/background images */
-	struct DRWPass *reference_image;
 } OBJECT_PassList;
 
 typedef struct OBJECT_FramebufferList {
 	struct GPUFrameBuffer *outlines_fb;
 	struct GPUFrameBuffer *blur_fb;
 	struct GPUFrameBuffer *expand_fb;
+	struct GPUFrameBuffer *ghost_fb;
 } OBJECT_FramebufferList;
 
 typedef struct OBJECT_StorageList {
@@ -140,12 +139,17 @@ typedef struct OBJECT_Data {
 	OBJECT_StorageList *stl;
 } OBJECT_Data;
 
-/* Prototypes. */
-static void DRW_shgroup_empty_ex(OBJECT_StorageList *stl, float mat[4][4], float *draw_size, char draw_type, float *color);
-
 /* *********** STATIC *********** */
 
-typedef struct OBJECT_PrivateData {
+typedef struct OBJECT_ShadingGroupList {
+	/* Reference only */
+	struct DRWPass *non_meshes;
+	struct DRWPass *bone_solid;
+	struct DRWPass *bone_outline;
+	struct DRWPass *bone_wire;
+	struct DRWPass *bone_envelope;
+	struct DRWPass *bone_axes;
+
 	/* Empties */
 	DRWShadingGroup *plain_axes;
 	DRWShadingGroup *cube;
@@ -208,13 +212,6 @@ typedef struct OBJECT_PrivateData {
 	/* Helpers */
 	DRWShadingGroup *relationship_lines;
 
-	/* Objects Centers */
-	DRWShadingGroup *center_active;
-	DRWShadingGroup *center_selected;
-	DRWShadingGroup *center_deselected;
-	DRWShadingGroup *center_selected_lib;
-	DRWShadingGroup *center_deselected_lib;
-
 	/* Camera */
 	DRWShadingGroup *camera;
 	DRWShadingGroup *camera_frame;
@@ -226,20 +223,6 @@ typedef struct OBJECT_PrivateData {
 	DRWShadingGroup *camera_mist_points;
 	ListBase camera_path;
 
-	/* Outlines */
-	DRWShadingGroup *outlines_active;
-	DRWShadingGroup *outlines_select;
-	DRWShadingGroup *outlines_transform;
-
-	/* Lightprobes */
-	DRWShadingGroup *lightprobes_cube_select;
-	DRWShadingGroup *lightprobes_cube_active;
-	DRWShadingGroup *lightprobes_cube_transform;
-
-	DRWShadingGroup *lightprobes_planar_select;
-	DRWShadingGroup *lightprobes_planar_active;
-	DRWShadingGroup *lightprobes_planar_transform;
-
 	/* Wire */
 	DRWShadingGroup *wire;
 	DRWShadingGroup *wire_active;
@@ -254,6 +237,32 @@ typedef struct OBJECT_PrivateData {
 
 	/* Texture Space */
 	DRWShadingGroup *texspace;
+} OBJECT_ShadingGroupList;
+
+typedef struct OBJECT_PrivateData {
+	OBJECT_ShadingGroupList sgl;
+	OBJECT_ShadingGroupList sgl_ghost;
+
+	/* Outlines */
+	DRWShadingGroup *outlines_active;
+	DRWShadingGroup *outlines_select;
+	DRWShadingGroup *outlines_transform;
+
+	/* Lightprobes */
+	DRWShadingGroup *lightprobes_cube_select;
+	DRWShadingGroup *lightprobes_cube_active;
+	DRWShadingGroup *lightprobes_cube_transform;
+
+	DRWShadingGroup *lightprobes_planar_select;
+	DRWShadingGroup *lightprobes_planar_active;
+	DRWShadingGroup *lightprobes_planar_transform;
+
+	/* Objects Centers */
+	DRWShadingGroup *center_active;
+	DRWShadingGroup *center_selected;
+	DRWShadingGroup *center_deselected;
+	DRWShadingGroup *center_selected_lib;
+	DRWShadingGroup *center_deselected_lib;
 
 	/* Outlines id offset */
 	int id_ofs_active;
@@ -322,6 +331,9 @@ enum {
 	GRID_BACK    = (1 << 9),
 };
 
+/* Prototypes. */
+static void DRW_shgroup_empty_ex(OBJECT_ShadingGroupList *sgl, float mat[4][4], float *draw_size, char draw_type, float *color);
+
 /* *********** FUNCTIONS *********** */
 
 static void OBJECT_engine_init(void *vedata)
@@ -755,30 +767,30 @@ static DRWShadingGroup *shgroup_theme_id_to_outline_or(
 }
 
 static DRWShadingGroup *shgroup_theme_id_to_wire_or(
-        OBJECT_StorageList *stl, int theme_id, DRWShadingGroup *fallback)
+        OBJECT_ShadingGroupList *sgl, int theme_id, DRWShadingGroup *fallback)
 {
 	switch (theme_id) {
 		case TH_ACTIVE:
-			return stl->g_data->wire_active;
+			return sgl->wire_active;
 		case TH_SELECT:
-			return stl->g_data->wire_select;
+			return sgl->wire_select;
 		case TH_TRANSFORM:
-			return stl->g_data->wire_transform;
+			return sgl->wire_transform;
 		default:
 			return fallback;
 	}
 }
 
 static DRWShadingGroup *shgroup_theme_id_to_point_or(
-        OBJECT_StorageList *stl, int theme_id, DRWShadingGroup *fallback)
+        OBJECT_ShadingGroupList *sgl, int theme_id, DRWShadingGroup *fallback)
 {
 	switch (theme_id) {
 		case TH_ACTIVE:
-			return stl->g_data->points_active;
+			return sgl->points_active;
 		case TH_SELECT:
-			return stl->g_data->points_select;
+			return sgl->points_select;
 		case TH_TRANSFORM:
-			return stl->g_data->points_transform;
+			return sgl->points_transform;
 		default:
 			return fallback;
 	}
@@ -828,12 +840,12 @@ struct EmptyImageShadingGroupData {
 };
 
 static void DRW_shgroup_empty_image(
-        OBJECT_StorageList *stl, OBJECT_PassList *psl, Object *ob, const float color[3])
+        OBJECT_ShadingGroupList *sgl, Object *ob, const float color[3])
 {
 	/* TODO: 'StereoViews', see draw_empty_image. */
 
-	if (stl->g_data->image_plane_map == NULL) {
-		stl->g_data->image_plane_map = BLI_ghash_ptr_new(__func__);
+	if (sgl->image_plane_map == NULL) {
+		sgl->image_plane_map = BLI_ghash_ptr_new(__func__);
 	}
 
 	struct EmptyImageShadingGroupData *empty_image_data;
@@ -843,7 +855,7 @@ static void DRW_shgroup_empty_image(
 	void **val_p;
 
 	/* Create on demand, 'tex' may be NULL. */
-	if (BLI_ghash_ensure_p(stl->g_data->image_plane_map, tex, &val_p)) {
+	if (BLI_ghash_ensure_p(sgl->image_plane_map, tex, &val_p)) {
 		empty_image_data = *val_p;
 	}
 	else {
@@ -861,7 +873,7 @@ static void DRW_shgroup_empty_image(
 
 			struct GPUBatch *geom = DRW_cache_image_plane_get();
 			DRWShadingGroup *grp = DRW_shgroup_instance_create(
-			        e_data.object_empty_image_sh, psl->non_meshes, geom, e_data.empty_image_format);
+			        e_data.object_empty_image_sh, sgl->non_meshes, geom, e_data.empty_image_format);
 			DRW_shgroup_uniform_texture(grp, "image", tex);
 			DRW_shgroup_uniform_vec2(grp, "aspect", empty_image_data->image_aspect, 1);
 
@@ -881,7 +893,7 @@ static void DRW_shgroup_empty_image(
 
 			struct GPUBatch *geom = DRW_cache_image_plane_wire_get();
 			DRWShadingGroup *grp = DRW_shgroup_instance_create(
-			        e_data.object_empty_image_wire_sh, psl->non_meshes, geom, e_data.empty_image_wire_format);
+			        e_data.object_empty_image_wire_sh, sgl->non_meshes, geom, e_data.empty_image_wire_format);
 			DRW_shgroup_uniform_vec2(grp, "aspect", empty_image_data->image_aspect, 1);
 
 			empty_image_data->shgrp_wire = grp;
@@ -1057,257 +1069,229 @@ static void OBJECT_cache_init(void *vedata)
 		DRW_shgroup_call_add(grp, quad, mat);
 	}
 
-	{
+	for (int i = 0; i < 2; ++i) {
+		OBJECT_ShadingGroupList *sgl = (i == 1) ? &stl->g_data->sgl_ghost : &stl->g_data->sgl;
+
 		/* Solid bones */
 		DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL;
-		psl->bone_solid = DRW_pass_create("Bone Solid Pass", state);
-		psl->bone_outline = DRW_pass_create("Bone Outline Pass", state);
-	}
+		sgl->bone_solid = psl->bone_solid[i] = DRW_pass_create("Bone Solid Pass", state);
+		sgl->bone_outline = psl->bone_outline[i] = DRW_pass_create("Bone Outline Pass", state);
 
-	{
 		/* Wire bones */
-		DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_BLEND;
-		psl->bone_wire = DRW_pass_create("Bone Wire Pass", state);
-	}
+		state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_BLEND;
+		sgl->bone_wire = psl->bone_wire[i] = DRW_pass_create("Bone Wire Pass", state);
 
-	{
 		/* distance outline around envelope bones */
-		DRWState state = DRW_STATE_ADDITIVE | DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_CULL_FRONT;
-		psl->bone_envelope = DRW_pass_create("Bone Envelope Outline Pass", state);
-	}
+		state = DRW_STATE_ADDITIVE | DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_CULL_FRONT;
+		sgl->bone_envelope = psl->bone_envelope[i] = DRW_pass_create("Bone Envelope Outline Pass", state);
 
-	{
-		DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_WIRE;
-		psl->bone_axes = DRW_pass_create("Bone Axes Pass", state);
+		state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_WIRE;
+		sgl->bone_axes = psl->bone_axes[i] = DRW_pass_create("Bone Axes Pass", state);
 	}
 
-	{
+	for (int i = 0; i < 2; ++i) {
+		OBJECT_ShadingGroupList *sgl = (i == 1) ? &stl->g_data->sgl_ghost : &stl->g_data->sgl;
+
 		/* Non Meshes Pass (Camera, empties, lamps ...) */
 		struct GPUBatch *geom;
+		struct GPUShader *sh;
 
 		DRWState state =
 		        DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH |
 		        DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_BLEND | DRW_STATE_POINT;
 		state |= DRW_STATE_WIRE;
-		psl->non_meshes = DRW_pass_create("Non Meshes Pass", state);
+		sgl->non_meshes = psl->non_meshes[i] = DRW_pass_create("Non Meshes Pass", state);
 
 		/* Empties */
 		geom = DRW_cache_plain_axes_get();
-		stl->g_data->plain_axes = shgroup_instance(psl->non_meshes, geom);
+		sgl->plain_axes = shgroup_instance(sgl->non_meshes, geom);
 
 		geom = DRW_cache_empty_cube_get();
-		stl->g_data->cube = shgroup_instance(psl->non_meshes, geom);
+		sgl->cube = shgroup_instance(sgl->non_meshes, geom);
 
 		geom = DRW_cache_circle_get();
-		stl->g_data->circle 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list