Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2018-05-06 19:36:27 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-05-06 19:42:23 +0300
commitc769b1a5533bb0fcf04452cde4d81dd77f7ae03b (patch)
treef80d6bb3a8a9ab41f07e3f71e2a0eb2ab62d17e3
parent48ddb2b98a5d9f77d5589afd137019dc85f1e460 (diff)
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.
-rw-r--r--source/blender/draw/intern/draw_armature.c2
-rw-r--r--source/blender/draw/intern/draw_common.h1
-rw-r--r--source/blender/draw/modes/edit_armature_mode.c10
-rw-r--r--source/blender/draw/modes/object_mode.c8
-rw-r--r--source/blender/draw/modes/pose_mode.c10
5 files changed, 30 insertions, 1 deletions
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;
@@ -98,6 +99,11 @@ static void EDIT_ARMATURE_cache_init(void *vedata)
}
{
+ 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 =
DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS |
@@ -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 */
@@ -1004,6 +1005,11 @@ static void OBJECT_cache_init(void *vedata)
}
{
+ 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;
@@ -107,6 +108,11 @@ static void POSE_cache_init(void *vedata)
}
{
+ 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 =
DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS |
@@ -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.