Armature: Add new Transparent Bone overlay option.
This is half the replacement of the old wireframe mode. It's not doing any XRay drawing at the moment.
This commit is contained in:
@@ -3626,6 +3626,8 @@ class VIEW3D_PT_overlay(Panel):
|
||||
subsub.active = scene.unit_settings.system == 'NONE'
|
||||
subsub.prop(overlay, "grid_subdivisions", text="Subdivisions")
|
||||
|
||||
|
||||
|
||||
if context.mode == 'EDIT_MESH':
|
||||
col.separator()
|
||||
col.label(text="Edit Mode:")
|
||||
@@ -3647,6 +3649,21 @@ class VIEW3D_PT_overlay(Panel):
|
||||
sub.active = overlay.show_vertex_normals or overlay.show_face_normals or overlay.show_split_normals
|
||||
sub.prop(overlay, "normals_length", text="Size")
|
||||
|
||||
elif context.mode == 'POSE':
|
||||
col.separator()
|
||||
col.label(text="Pose Mode:")
|
||||
|
||||
col = layout.column()
|
||||
col.active = display_all
|
||||
col.prop(overlay, "transparent_bones")
|
||||
|
||||
elif context.mode == 'EDIT_ARMATURE':
|
||||
col.separator()
|
||||
col.label(text="Edit Armature:")
|
||||
|
||||
col = layout.column()
|
||||
col.active = display_all
|
||||
col.prop(overlay, "transparent_bones")
|
||||
|
||||
elif context.mode in {'PAINT_WEIGHT', 'PAINT_VERTEX', 'PAINT_TEXTURE'}:
|
||||
col.separator()
|
||||
|
||||
@@ -1028,7 +1028,7 @@ static void draw_axes(EditBone *eBone, bPoseChannel *pchan)
|
||||
const float *col = (g_theme.const_color) ? g_theme.const_color :
|
||||
(BONE_FLAG(eBone, pchan) & BONE_SELECTED) ? g_theme.text_hi_color : g_theme.text_color;
|
||||
copy_v4_v4(final_col, col);
|
||||
final_col[3] = (g_theme.const_color) ? 1.0 : 0.4; /* Mix with axes color. */
|
||||
final_col[3] = (g_theme.const_color) ? 1.0 : (BONE_FLAG(eBone, pchan) & BONE_SELECTED) ? 0.3 : 0.8; /* Mix with axes color. */
|
||||
drw_shgroup_bone_axes(BONE_VAR(eBone, pchan, disp_mat), final_col);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "DRW_render.h"
|
||||
|
||||
#include "DNA_armature_types.h"
|
||||
#include "DNA_view3d_types.h"
|
||||
|
||||
#include "draw_common.h"
|
||||
|
||||
@@ -76,7 +77,7 @@ static void EDIT_ARMATURE_cache_init(void *vedata)
|
||||
|
||||
{
|
||||
/* Solid bones */
|
||||
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS;
|
||||
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | DRW_STATE_CULL_BACK;
|
||||
psl->bone_solid = DRW_pass_create("Bone Solid Pass", state);
|
||||
}
|
||||
|
||||
@@ -137,13 +138,24 @@ static void EDIT_ARMATURE_draw_scene(void *vedata)
|
||||
EDIT_ARMATURE_PassList *psl = ((EDIT_ARMATURE_Data *)vedata)->psl;
|
||||
DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
|
||||
DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
|
||||
const DRWContextState *draw_ctx = DRW_context_state_get();
|
||||
const bool transparent_bones = (draw_ctx->v3d->overlay.arm_flag & V3D_OVERLAY_ARM_TRANSP_BONES) != 0;
|
||||
|
||||
DRW_draw_pass(psl->bone_envelope);
|
||||
|
||||
if (transparent_bones) {
|
||||
DRW_pass_state_add(psl->bone_solid, DRW_STATE_BLEND);
|
||||
DRW_pass_state_remove(psl->bone_solid, DRW_STATE_WRITE_DEPTH);
|
||||
DRW_draw_pass(psl->bone_solid);
|
||||
}
|
||||
|
||||
MULTISAMPLE_SYNC_ENABLE(dfbl, dtxl)
|
||||
|
||||
if (!transparent_bones) {
|
||||
DRW_draw_pass(psl->bone_solid);
|
||||
}
|
||||
|
||||
DRW_draw_pass(psl->bone_outline);
|
||||
DRW_draw_pass(psl->bone_solid);
|
||||
DRW_draw_pass(psl->bone_wire);
|
||||
DRW_draw_pass(psl->relationship);
|
||||
|
||||
|
||||
@@ -987,7 +987,7 @@ static void OBJECT_cache_init(void *vedata)
|
||||
|
||||
{
|
||||
/* Solid bones */
|
||||
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS;
|
||||
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | DRW_STATE_CULL_BACK;
|
||||
psl->bone_solid = DRW_pass_create("Bone Solid Pass", state);
|
||||
psl->bone_outline = DRW_pass_create("Bone Outline Pass", state);
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
#include "DRW_engine.h"
|
||||
#include "DRW_render.h"
|
||||
#include "DNA_view3d_types.h"
|
||||
|
||||
/* If builtin shaders are needed */
|
||||
#include "GPU_shader.h"
|
||||
@@ -85,7 +86,7 @@ static void POSE_cache_init(void *vedata)
|
||||
|
||||
{
|
||||
/* Solid bones */
|
||||
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS;
|
||||
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | DRW_STATE_CULL_BACK;
|
||||
psl->bone_solid = DRW_pass_create("Bone Solid Pass", state);
|
||||
}
|
||||
|
||||
@@ -175,14 +176,25 @@ static void POSE_draw_scene(void *vedata)
|
||||
POSE_PassList *psl = ((POSE_Data *)vedata)->psl;
|
||||
DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
|
||||
DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
|
||||
const DRWContextState *draw_ctx = DRW_context_state_get();
|
||||
const bool transparent_bones = (draw_ctx->v3d->overlay.arm_flag & V3D_OVERLAY_ARM_TRANSP_BONES) != 0;
|
||||
|
||||
DRW_draw_pass(psl->bone_envelope);
|
||||
|
||||
if (transparent_bones) {
|
||||
DRW_pass_state_add(psl->bone_solid, DRW_STATE_BLEND);
|
||||
DRW_pass_state_remove(psl->bone_solid, DRW_STATE_WRITE_DEPTH);
|
||||
DRW_draw_pass(psl->bone_solid);
|
||||
}
|
||||
|
||||
MULTISAMPLE_SYNC_ENABLE(dfbl, dtxl)
|
||||
|
||||
if (!transparent_bones) {
|
||||
DRW_draw_pass(psl->bone_solid);
|
||||
}
|
||||
|
||||
DRW_draw_pass(psl->bone_outline);
|
||||
DRW_draw_pass(psl->bone_wire);
|
||||
DRW_draw_pass(psl->bone_solid);
|
||||
DRW_draw_pass(psl->relationship);
|
||||
|
||||
MULTISAMPLE_SYNC_DISABLE(dfbl, dtxl)
|
||||
|
||||
@@ -5,5 +5,5 @@ out vec4 fragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
fragColor = finalColor;
|
||||
fragColor = vec4(finalColor.rgb, 0.6); /* Hardcoded transparency factor. */
|
||||
}
|
||||
|
||||
@@ -73,7 +73,8 @@ void main()
|
||||
float dither = (0.5 + dot(vec2(ivec2(gl_FragCoord.xy) & ivec2(1)), vec2(1.0, 2.0))) * 0.25;
|
||||
dither *= (1.0 / 255.0); /* Assume 8bit per color buffer. */
|
||||
|
||||
fragColor = vec4(fragColor.rgb + dither, 1.0);
|
||||
/* Hardcoded transparency factor. Less than shape to be less distractive. */
|
||||
fragColor = vec4(fragColor.rgb + dither, 0.4);
|
||||
|
||||
t /= ray_len;
|
||||
gl_FragDepth = get_depth_from_view_z(ray_dir_view.z * t + ray_ori_view.z);
|
||||
|
||||
@@ -154,7 +154,9 @@ typedef struct View3DOverlay {
|
||||
|
||||
/* Paint mode settings */
|
||||
int paint_flag;
|
||||
int pad;
|
||||
|
||||
/* Armature edit/pose mode settings */
|
||||
int arm_flag;
|
||||
} View3DOverlay;
|
||||
|
||||
/* 3D ViewPort Struct */
|
||||
@@ -353,6 +355,11 @@ enum {
|
||||
V3D_OVERLAY_EDIT_WEIGHT = (1 << 4),
|
||||
};
|
||||
|
||||
/* View3DOverlay->arm_flag */
|
||||
enum {
|
||||
V3D_OVERLAY_ARM_TRANSP_BONES = (1 << 0),
|
||||
};
|
||||
|
||||
/* View3DOverlay->paint_flag */
|
||||
enum {
|
||||
V3D_OVERLAY_PAINT_WIRE = (1 << 0),
|
||||
|
||||
@@ -2384,6 +2384,11 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
|
||||
RNA_def_property_ui_text(prop, "Backwire Opacity", "Opacity when rendering transparent wires");
|
||||
RNA_def_property_range(prop, 0.0f, 1.0f);
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
|
||||
|
||||
prop = RNA_def_property(srna, "transparent_bones", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "overlay.arm_flag", V3D_OVERLAY_ARM_TRANSP_BONES);
|
||||
RNA_def_property_ui_text(prop, "Transparent Bones", "Display bones as transparent");
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
|
||||
}
|
||||
|
||||
static void rna_def_space_view3d(BlenderRNA *brna)
|
||||
|
||||
Reference in New Issue
Block a user