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-08-17 00:56:58 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-08-17 00:58:29 +0300
commit77e1942e0e1e7ef5bf36e217f5602fefe11447e1 (patch)
tree5ca3622c1a956a872808451459e5b016bd874c0f /source/blender/draw/modes/edit_armature_mode.c
parent4711e0ee265717fad30105df35a1c51bfddea0ce (diff)
Armature: Add ghosting support (old x-ray)
Diffstat (limited to 'source/blender/draw/modes/edit_armature_mode.c')
-rw-r--r--source/blender/draw/modes/edit_armature_mode.c86
1 files changed, 48 insertions, 38 deletions
diff --git a/source/blender/draw/modes/edit_armature_mode.c b/source/blender/draw/modes/edit_armature_mode.c
index 1e8293b5dbb..9f97620adb6 100644
--- a/source/blender/draw/modes/edit_armature_mode.c
+++ b/source/blender/draw/modes/edit_armature_mode.c
@@ -37,12 +37,12 @@ extern GlobalsUboStorage ts;
/* *********** LISTS *********** */
typedef struct EDIT_ARMATURE_PassList {
- struct DRWPass *bone_solid;
- struct DRWPass *bone_wire;
- struct DRWPass *bone_outline;
- struct DRWPass *bone_envelope;
+ struct DRWPass *bone_solid[2];
+ struct DRWPass *bone_wire[2];
+ struct DRWPass *bone_outline[2];
+ struct DRWPass *bone_envelope[2];
struct DRWPass *bone_axes;
- struct DRWPass *relationship;
+ struct DRWPass *relationship[2];
} EDIT_ARMATURE_PassList;
typedef struct EDIT_ARMATURE_StorageList {
@@ -77,43 +77,33 @@ static void EDIT_ARMATURE_cache_init(void *vedata)
}
stl->g_data->transparent_bones = (draw_ctx->v3d->overlay.arm_flag & V3D_OVERLAY_ARM_TRANSP_BONES) != 0;
- {
+ for (int i = 0; i < 2; ++i) {
/* Solid bones */
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_CULL_BACK;
state |= (stl->g_data->transparent_bones) ? DRW_STATE_BLEND : DRW_STATE_WRITE_DEPTH;
- psl->bone_solid = DRW_pass_create("Bone Solid Pass", state);
- }
+ psl->bone_solid[i] = DRW_pass_create("Bone Solid Pass", state);
- {
/* Bones Outline */
- DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL;
- psl->bone_outline = DRW_pass_create("Bone Outline Pass", state);
- }
+ state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL;
+ 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;
+ 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;
+ psl->bone_envelope[i] = DRW_pass_create("Bone Envelope Outline Pass", state);
+
+ state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL |
+ DRW_STATE_BLEND | DRW_STATE_WIRE;
+ psl->relationship[i] = DRW_pass_create("Bone Relationship 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 =
- DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL |
- DRW_STATE_BLEND | DRW_STATE_WIRE;
- psl->relationship = DRW_pass_create("Bone Relationship Pass", state);
- }
}
static void EDIT_ARMATURE_cache_populate(void *vedata, Object *ob)
@@ -125,13 +115,15 @@ static void EDIT_ARMATURE_cache_populate(void *vedata, Object *ob)
EDIT_ARMATURE_PassList *psl = ((EDIT_ARMATURE_Data *)vedata)->psl;
EDIT_ARMATURE_StorageList *stl = ((EDIT_ARMATURE_Data *)vedata)->stl;
+ int ghost = (ob->dtx & OB_DRAWXRAY) ? 1 : 0;
+
DRWArmaturePasses passes = {
- .bone_solid = psl->bone_solid,
- .bone_outline = psl->bone_outline,
- .bone_wire = psl->bone_wire,
- .bone_envelope = psl->bone_envelope,
+ .bone_solid = psl->bone_solid[ghost],
+ .bone_outline = psl->bone_outline[ghost],
+ .bone_wire = psl->bone_wire[ghost],
+ .bone_envelope = psl->bone_envelope[ghost],
.bone_axes = psl->bone_axes,
- .relationship_lines = psl->relationship,
+ .relationship_lines = psl->relationship[ghost],
};
DRW_shgroup_armature_edit(ob, passes, stl->g_data->transparent_bones);
}
@@ -145,25 +137,43 @@ static void EDIT_ARMATURE_draw_scene(void *vedata)
DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
- DRW_draw_pass(psl->bone_envelope);
+ DRW_draw_pass(psl->bone_envelope[0]);
if (stl->g_data->transparent_bones) {
/* For performance reason, avoid blending on MS target. */
- DRW_draw_pass(psl->bone_solid);
+ DRW_draw_pass(psl->bone_solid[0]);
}
MULTISAMPLE_SYNC_ENABLE(dfbl, dtxl)
if (!stl->g_data->transparent_bones) {
- DRW_draw_pass(psl->bone_solid);
+ DRW_draw_pass(psl->bone_solid[0]);
}
- DRW_draw_pass(psl->bone_outline);
- DRW_draw_pass(psl->bone_wire);
- DRW_draw_pass(psl->relationship);
+ DRW_draw_pass(psl->bone_outline[0]);
+ DRW_draw_pass(psl->bone_wire[0]);
+ DRW_draw_pass(psl->relationship[0]);
MULTISAMPLE_SYNC_DISABLE(dfbl, dtxl)
+ if (!DRW_pass_is_empty(psl->bone_envelope[1]) ||
+ !DRW_pass_is_empty(psl->bone_solid[1]) ||
+ !DRW_pass_is_empty(psl->bone_outline[1]) ||
+ !DRW_pass_is_empty(psl->bone_wire[1]) ||
+ !DRW_pass_is_empty(psl->relationship[1]))
+ {
+ if (DRW_state_is_fbo()) {
+ GPU_framebuffer_bind(dfbl->default_fb);
+ GPU_framebuffer_clear_depth(dfbl->default_fb, 1.0f);
+ }
+
+ DRW_draw_pass(psl->bone_envelope[1]);
+ DRW_draw_pass(psl->bone_solid[1]);
+ DRW_draw_pass(psl->bone_outline[1]);
+ DRW_draw_pass(psl->bone_wire[1]);
+ DRW_draw_pass(psl->relationship[1]);
+ }
+
/* Draw axes with linesmooth and outside of multisample buffer. */
DRW_draw_pass(psl->bone_axes);
}