Commit: 16bf46b6b5a50514f988f6b93a7e455f9d84a21d Author: Alexander Gavrilov Date: Sun Jan 3 23:40:44 2021 +0300 Branches: temp-angavrilov https://developer.blender.org/rB16bf46b6b5a50514f988f6b93a7e455f9d84a21d
Bone Overlay: support changing bone wireframe opacity. When weight painting the bone overlay is extremely intrusive, effectively requiring either extensive use of hiding individual bones, or disabling the whole bone overlay between selections. This addresses the issue by adding a bone opacity slider that is used for the 'wireframe' armature drawing mode. It directly controls the uniform opacity as a straightforward option. Differential Revision: https://developer.blender.org/D11804 =================================================================== M release/scripts/startup/bl_ui/space_view3d.py M source/blender/blenloader/intern/versioning_300.c M source/blender/draw/engines/overlay/overlay_armature.c M source/blender/draw/engines/overlay/overlay_private.h M source/blender/draw/engines/overlay/shaders/armature_dof_solid_frag.glsl M source/blender/draw/engines/overlay/shaders/armature_envelope_solid_frag.glsl M source/blender/draw/engines/overlay/shaders/armature_stick_frag.glsl M source/blender/draw/engines/overlay/shaders/armature_wire_frag.glsl M source/blender/makesdna/DNA_view3d_defaults.h M source/blender/makesdna/DNA_view3d_types.h M source/blender/makesrna/intern/rna_space.c =================================================================== diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 3fd19dd70cf..7d8e74ed7ce 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -6504,18 +6504,38 @@ class VIEW3D_PT_overlay_sculpt(Panel): row.prop(overlay, "sculpt_mode_face_sets_opacity", text="Face Sets") -class VIEW3D_PT_overlay_pose(Panel): +class VIEW3D_PT_overlay_bones(Panel): bl_space_type = 'VIEW_3D' bl_region_type = 'HEADER' bl_parent_id = 'VIEW3D_PT_overlay' - bl_label = "Pose Mode" + bl_label = "Bones" + + @staticmethod + def is_using_wireframe(context): + shading = VIEW3D_PT_shading.get_shading(context) + + if shading.type == 'WIREFRAME' or shading.show_xray: + return True + + mode = context.mode + + if mode in ('POSE', 'PAINT_WEIGHT'): + armature = context.pose_object + elif mode == 'EDIT_ARMATURE': + armature = context.edit_object + else: + return False + + return armature and armature.display_type == 'WIRE' @classmethod def poll(cls, context): mode = context.mode return ( (mode == 'POSE') or - (mode == 'PAINT_WEIGHT' and context.pose_object) + (mode == 'PAINT_WEIGHT' and context.pose_object) or + (mode in ('EDIT_ARMATURE', 'OBJECT') and + VIEW3D_PT_overlay_bones.is_using_wireframe(context)) ) def draw(self, context): @@ -6534,10 +6554,13 @@ class VIEW3D_PT_overlay_pose(Panel): sub = row.row() sub.active = display_all and overlay.show_xray_bone sub.prop(overlay, "xray_alpha_bone", text="Fade Geometry") - else: + elif mode == 'PAINT_WEIGHT': row = col.row() row.prop(overlay, "show_xray_bone") + if VIEW3D_PT_overlay_bones.is_using_wireframe(context): + col.prop(overlay, "bone_wire_alpha") + class VIEW3D_PT_overlay_texture_paint(Panel): bl_space_type = 'VIEW_3D' @@ -7705,7 +7728,7 @@ classes = ( VIEW3D_PT_overlay_texture_paint, VIEW3D_PT_overlay_vertex_paint, VIEW3D_PT_overlay_weight_paint, - VIEW3D_PT_overlay_pose, + VIEW3D_PT_overlay_bones, VIEW3D_PT_overlay_sculpt, VIEW3D_PT_snapping, VIEW3D_PT_proportional_edit, diff --git a/source/blender/blenloader/intern/versioning_300.c b/source/blender/blenloader/intern/versioning_300.c index fbc9bd0f8b1..624761164a8 100644 --- a/source/blender/blenloader/intern/versioning_300.c +++ b/source/blender/blenloader/intern/versioning_300.c @@ -45,6 +45,8 @@ #include "DNA_listBase.h" #include "DNA_material_types.h" #include "DNA_modifier_types.h" +#include "DNA_screen_types.h" +#include "DNA_space_types.h" #include "DNA_text_types.h" #include "DNA_workspace_types.h" @@ -2502,5 +2504,19 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain) } } FOREACH_NODETREE_END; + + /* Initialize the bone wireframe opacity setting. */ + if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "bone_wire_alpha")) { + for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { + if (sl->spacetype == SPACE_VIEW3D) { + View3D *v3d = (View3D *)sl; + v3d->overlay.bone_wire_alpha = 1.0f; + } + } + } + } + } } } diff --git a/source/blender/draw/engines/overlay/overlay_armature.c b/source/blender/draw/engines/overlay/overlay_armature.c index dab9dae36b1..98306b185e7 100644 --- a/source/blender/draw/engines/overlay/overlay_armature.c +++ b/source/blender/draw/engines/overlay/overlay_armature.c @@ -139,6 +139,10 @@ void OVERLAY_armature_cache_init(OVERLAY_Data *vedata) pd->armature.do_pose_fade_geom = pd->armature.do_pose_xray && ((draw_ctx->object_mode & OB_MODE_WEIGHT_PAINT) == 0) && draw_ctx->object_pose != NULL; + + const float wire_alpha = pd->overlay.bone_wire_alpha; + const bool use_wire_alpha = (wire_alpha < 1.0f); + DRWState state; if (pd->armature.do_pose_fade_geom) { @@ -164,8 +168,8 @@ void OVERLAY_armature_cache_init(OVERLAY_Data *vedata) OVERLAY_InstanceFormats *formats = OVERLAY_shader_instance_formats_get(); OVERLAY_ArmatureCallBuffers *cb = &pd->armature_call_buffers[i]; - cb->custom_shapes_ghash = BLI_ghash_ptr_new(__func__); - cb->custom_shapes_transp_ghash = BLI_ghash_ptr_new(__func__); + cb->solid.custom_shapes_ghash = BLI_ghash_ptr_new(__func__); + cb->transp.custom_shapes_ghash = BLI_ghash_ptr_new(__func__); DRWPass **p_armature_ps = &psl->armature_ps[i]; DRWState infront_state = (DRW_state_is_select() && (i == 1)) ? DRW_STATE_IN_FRONT_SELECT : 0; @@ -189,44 +193,85 @@ void OVERLAY_armature_cache_init(OVERLAY_Data *vedata) grp = DRW_shgroup_create(sh, armature_ps); DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); DRW_shgroup_uniform_float_copy(grp, "alpha", 1.0f); - cb->point_solid = BUF_INSTANCE(grp, format, DRW_cache_bone_point_get()); + cb->solid.point_fill = BUF_INSTANCE(grp, format, DRW_cache_bone_point_get()); grp = DRW_shgroup_create(sh, armature_ps); DRW_shgroup_state_disable(grp, DRW_STATE_WRITE_DEPTH); DRW_shgroup_state_enable(grp, DRW_STATE_BLEND_ALPHA); - DRW_shgroup_uniform_float_copy(grp, "alpha", 0.4f); - cb->point_transp = BUF_INSTANCE(grp, format, DRW_cache_bone_point_get()); + DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); + DRW_shgroup_uniform_float_copy(grp, "alpha", wire_alpha * 0.4f); + cb->transp.point_fill = BUF_INSTANCE(grp, format, DRW_cache_bone_point_get()); sh = OVERLAY_shader_armature_shape(false); grp = DRW_shgroup_create(sh, armature_ps); DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); DRW_shgroup_uniform_float_copy(grp, "alpha", 1.0f); - cb->custom_solid = grp; - cb->box_solid = BUF_INSTANCE(grp, format, DRW_cache_bone_box_get()); - cb->octa_solid = BUF_INSTANCE(grp, format, DRW_cache_bone_octahedral_get()); + cb->solid.custom_fill = grp; + cb->solid.box_fill = BUF_INSTANCE(grp, format, DRW_cache_bone_box_get()); + cb->solid.octa_fill = BUF_INSTANCE(grp, format, DRW_cache_bone_octahedral_get()); grp = DRW_shgroup_create(sh, armature_ps); DRW_shgroup_state_disable(grp, DRW_STATE_WRITE_DEPTH); DRW_shgroup_state_enable(grp, DRW_STATE_BLEND_ALPHA); - DRW_shgroup_uniform_float_copy(grp, "alpha", 0.6f); - cb->custom_transp = grp; - cb->box_transp = BUF_INSTANCE(grp, format, DRW_cache_bone_box_get()); - cb->octa_transp = BUF_INSTANCE(grp, format, DRW_cache_bone_octahedral_get()); + DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); + DRW_shgroup_uniform_float_copy(grp, "alpha", wire_alpha * 0.6f); + cb->transp.custom_fill = grp; + cb->transp.box_fill = BUF_INSTANCE(grp, format, DRW_cache_bone_box_get()); + cb->transp.octa_fill = BUF_INSTANCE(grp, format, DRW_cache_bone_octahedral_get()); sh = OVERLAY_shader_armature_sphere(true); grp = DRW_shgroup_create(sh, armature_ps); DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); - cb->point_outline = BUF_INSTANCE(grp, format, DRW_cache_bone_point_wire_outline_get()); + DRW_shgroup_uniform_float_copy(grp, "alpha", 1.0f); + cb->solid.point_outline = BUF_INSTANCE(grp, format, DRW_cache_bone_point_wire_outline_get()); + + if (use_wire_alpha) { + grp = DRW_shgroup_create(sh, armature_ps); + DRW_shgroup_state_enable(grp, DRW_STATE_BLEND_ALPHA); + DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); + DRW_shgroup_uniform_float_copy(grp, "alpha", wire_alpha); + cb->transp.point_outline = BUF_INSTANCE( + grp, format, DRW_cache_bone_point_wire_outline_get()); + } + else { + cb->transp.point_outline = cb->solid.point_outline; + } sh = OVERLAY_shader_armature_shape(true); - cb->custom_outline = grp = DRW_shgroup_create(sh, armature_ps); + cb->solid.custom_outline = grp = DRW_shgroup_create(sh, armature_ps); DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); - cb->box_outline = BUF_INSTANCE(grp, format, DRW_cache_bone_box_wire_get()); - cb->octa_outline = BUF_INSTANCE(grp, format, DRW_cache_bone_octahedral_wire_get()); + DRW_shgroup_uniform_float_copy(grp, "alpha", 1.0f); + cb->solid.box_outline = BUF_INSTANCE(grp, format, DRW_cache_bone_box_wire_get()); + cb->solid.octa_outline = BUF_INSTANCE(grp, format, DRW_cache_bone_octahedral_wire_get()); + + if (use_wire_alpha) { + cb->transp.custom_outline = grp = DRW_shgroup_create(sh, armature_ps); + DRW_shgroup_state_enable(grp, DRW_STATE_BLEND_ALPHA); + DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); + DRW_shgroup_uniform_float_copy(grp, "alpha", wire_alpha); + cb->transp.box_outline = BUF_INSTANCE(grp, format, DRW_cache_bone_box_wire_get()); + cb->transp.octa_outline = BUF_INSTANCE(grp, format, DRW_cache_bone_octahedral_wire_get()); + } + else { + cb->transp.custom_outline = cb->solid.custom_outline; + cb->transp.box_outline = cb->solid.box_outline; + cb->transp.octa_outline = cb->solid.octa_outline; + } sh = OVERLAY_shader_armature_shape_wire(); - cb->custom_wire = grp = DRW_shgroup_create(sh, armature_ps); + cb->solid.custom_wire = grp = DRW_shgroup_create(sh, armature_ps); DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); + DRW_shgroup_uniform_float_copy(grp, "alpha", 1.0f); + + if (use_wire_alpha) { + cb->transp.custom_wire = grp = DRW_shgroup_create(sh, armature_ps); + DRW_shgroup_state_enable(grp, DRW_STATE @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs