[Bf-blender-cvs] [c769b1a5533] blender2.8: Armature: Add a special Pass for bone axes.

Clément Foucault noreply at git.blender.org
Sun May 6 18:34:52 CEST 2018


Commit: c769b1a5533bb0fcf04452cde4d81dd77f7ae03b
Author: Clément Foucault
Date:   Sun May 6 18:36:27 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBc769b1a5533bb0fcf04452cde4d81dd77f7ae03b

Armature: Add a special Pass for bone axes.

In object mode, the axes are drawn like any other wire objects with
depth test and depth write. Thus enabling MSAA to work but not their xray
behaviour.

In edit armature/pose mode, draw smooth line without depth testing. This
produces wrong draw ordering problem but still gives the desired xray
behaviour. We do it outside of the MSAA pass since the xray behaviour is not
compatible with it. But we are drawing smoothed lines so no need for MSAA.
The lines are 2px thick and improve readability.

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

M	source/blender/draw/intern/draw_armature.c
M	source/blender/draw/intern/draw_common.h
M	source/blender/draw/modes/edit_armature_mode.c
M	source/blender/draw/modes/object_mode.c
M	source/blender/draw/modes/pose_mode.c

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

diff --git a/source/blender/draw/intern/draw_armature.c b/source/blender/draw/intern/draw_armature.c
index c4331f4ebdc..a0486233ddb 100644
--- a/source/blender/draw/intern/draw_armature.c
+++ b/source/blender/draw/intern/draw_armature.c
@@ -312,7 +312,7 @@ static void drw_shgroup_bone_point(
 static void drw_shgroup_bone_axes(const float (*bone_mat)[4], const float color[4])
 {
 	if (g_data.bone_axes == NULL) {
-		g_data.bone_axes = shgroup_instance_bone_axes(g_data.passes.bone_wire);
+		g_data.bone_axes = shgroup_instance_bone_axes(g_data.passes.bone_axes);
 	}
 	float final_bonemat[4][4];
 	mul_m4_m4m4(final_bonemat, g_data.ob->obmat, bone_mat);
diff --git a/source/blender/draw/intern/draw_common.h b/source/blender/draw/intern/draw_common.h
index d53538f10d4..ae1c449399a 100644
--- a/source/blender/draw/intern/draw_common.h
+++ b/source/blender/draw/intern/draw_common.h
@@ -135,6 +135,7 @@ typedef struct DRWArmaturePasses{
 	struct DRWPass *bone_outline;
 	struct DRWPass *bone_wire;
 	struct DRWPass *bone_envelope;
+	struct DRWPass *bone_axes;
 } DRWArmaturePasses;
 
 void DRW_shgroup_armature_object(
diff --git a/source/blender/draw/modes/edit_armature_mode.c b/source/blender/draw/modes/edit_armature_mode.c
index f9bf003758f..254d2c12667 100644
--- a/source/blender/draw/modes/edit_armature_mode.c
+++ b/source/blender/draw/modes/edit_armature_mode.c
@@ -40,6 +40,7 @@ typedef struct EDIT_ARMATURE_PassList {
 	struct DRWPass *bone_wire;
 	struct DRWPass *bone_outline;
 	struct DRWPass *bone_envelope;
+	struct DRWPass *bone_axes;
 	struct DRWPass *relationship;
 } EDIT_ARMATURE_PassList;
 
@@ -97,6 +98,11 @@ static void EDIT_ARMATURE_cache_init(void *vedata)
 		psl->bone_envelope = DRW_pass_create("Bone Envelope Outline Pass", state);
 	}
 
+	{
+		DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WIRE_SMOOTH | DRW_STATE_BLEND;
+		psl->bone_axes = DRW_pass_create("Bone Axes Pass", state);
+	}
+
 	{
 		/* Non Meshes Pass (Camera, empties, lamps ...) */
 		DRWState state =
@@ -123,6 +129,7 @@ static void EDIT_ARMATURE_cache_populate(void *vedata, Object *ob)
 			    .bone_outline = psl->bone_outline,
 			    .bone_wire = psl->bone_wire,
 			    .bone_envelope = psl->bone_envelope,
+			    .bone_axes = psl->bone_axes,
 			};
 			DRW_shgroup_armature_edit(ob, passes, stl->g_data->relationship_lines);
 		}
@@ -145,6 +152,9 @@ static void EDIT_ARMATURE_draw_scene(void *vedata)
 	DRW_draw_pass(psl->relationship);
 
 	MULTISAMPLE_SYNC_DISABLE(dfbl, dtxl)
+
+	/* Draw axes with linesmooth and outside of multisample buffer. */
+	DRW_draw_pass(psl->bone_axes);
 }
 
 #if 0
diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c
index 7b89ea817ed..8d49899109a 100644
--- a/source/blender/draw/modes/object_mode.c
+++ b/source/blender/draw/modes/object_mode.c
@@ -104,6 +104,7 @@ typedef struct OBJECT_PassList {
 	struct DRWPass *bone_outline;
 	struct DRWPass *bone_wire;
 	struct DRWPass *bone_envelope;
+	struct DRWPass *bone_axes;
 	struct DRWPass *particle;
 	struct DRWPass *lightprobes;
 	/* use for empty/background images */
@@ -1003,6 +1004,11 @@ static void OBJECT_cache_init(void *vedata)
 		psl->bone_envelope = DRW_pass_create("Bone Envelope Outline Pass", state);
 	}
 
+	{
+		DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | DRW_STATE_WIRE;
+		psl->bone_axes = DRW_pass_create("Bone Axes Pass", state);
+	}
+
 	{
 		/* Non Meshes Pass (Camera, empties, lamps ...) */
 		struct Gwn_Batch *geom;
@@ -2103,6 +2109,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
 					    .bone_outline = psl->bone_outline,
 					    .bone_wire = psl->bone_wire,
 					    .bone_envelope = psl->bone_envelope,
+					    .bone_axes = psl->bone_axes,
 					};
 					DRW_shgroup_armature_object(ob, view_layer, passes, stl->g_data->relationship_lines);
 				}
@@ -2175,6 +2182,7 @@ static void OBJECT_draw_scene(void *vedata)
 	DRW_draw_pass(psl->non_meshes);
 	DRW_draw_pass(psl->particle);
 	DRW_draw_pass(psl->reference_image);
+	DRW_draw_pass(psl->bone_axes);
 
 	MULTISAMPLE_SYNC_DISABLE(dfbl, dtxl)
 
diff --git a/source/blender/draw/modes/pose_mode.c b/source/blender/draw/modes/pose_mode.c
index d1b4dd77246..10d6bffcbe1 100644
--- a/source/blender/draw/modes/pose_mode.c
+++ b/source/blender/draw/modes/pose_mode.c
@@ -47,6 +47,7 @@ typedef struct POSE_PassList {
 	struct DRWPass *bone_outline;
 	struct DRWPass *bone_wire;
 	struct DRWPass *bone_envelope;
+	struct DRWPass *bone_axes;
 	struct DRWPass *relationship;
 } POSE_PassList;
 
@@ -106,6 +107,11 @@ static void POSE_cache_init(void *vedata)
 		psl->bone_envelope = DRW_pass_create("Bone Envelope Outline Pass", state);
 	}
 
+	{
+		DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WIRE_SMOOTH | DRW_STATE_BLEND;
+		psl->bone_axes = DRW_pass_create("Bone Axes Pass", state);
+	}
+
 	{
 		/* Non Meshes Pass (Camera, empties, lamps ...) */
 		DRWState state =
@@ -136,6 +142,7 @@ static void POSE_cache_populate(void *vedata, Object *ob)
 			    .bone_outline = psl->bone_outline,
 			    .bone_wire = psl->bone_wire,
 			    .bone_envelope = psl->bone_envelope,
+			    .bone_axes = psl->bone_axes,
 			};
 			DRW_shgroup_armature_pose(ob, passes, stl->g_data->relationship_lines);
 		}
@@ -183,6 +190,9 @@ static void POSE_draw_scene(void *vedata)
 	DRW_draw_pass(psl->relationship);
 
 	MULTISAMPLE_SYNC_DISABLE(dfbl, dtxl)
+
+	/* Draw axes with linesmooth and outside of multisample buffer. */
+	DRW_draw_pass(psl->bone_axes);
 }
 
 /* Create collection settings here.



More information about the Bf-blender-cvs mailing list