diff --git a/source/blender/draw/engines/overlay/shaders/overlay_edit_uv_edges_frag.glsl b/source/blender/draw/engines/overlay/shaders/overlay_edit_uv_edges_frag.glsl index c2989de3947..d6c84a42593 100644 --- a/source/blender/draw/engines/overlay/shaders/overlay_edit_uv_edges_frag.glsl +++ b/source/blender/draw/engines/overlay/shaders/overlay_edit_uv_edges_frag.glsl @@ -66,7 +66,7 @@ void main() final_color.a *= 1.0f - (outer_color.a > 0.0f ? mix_w_outer : mix_w); eObjectInfoFlag ob_flag = drw_object_infos().flag; - bool is_active = flag_test(ob_flag, OBJECT_ACTIVE); + bool is_active = flag_test(ob_flag, OBJECT_ACTIVE_EDIT_MODE); final_color.a *= is_active ? alpha : (alpha * 0.25f); frag_color = final_color; diff --git a/source/blender/draw/engines/overlay/shaders/overlay_edit_uv_faces_vert.glsl b/source/blender/draw/engines/overlay/shaders/overlay_edit_uv_faces_vert.glsl index 2ef58511f8e..c1246d83691 100644 --- a/source/blender/draw/engines/overlay/shaders/overlay_edit_uv_faces_vert.glsl +++ b/source/blender/draw/engines/overlay/shaders/overlay_edit_uv_faces_vert.glsl @@ -19,7 +19,7 @@ void main() bool is_selected = (flag & FACE_UV_SELECT) != 0u; bool is_active = (flag & FACE_UV_ACTIVE) != 0u; eObjectInfoFlag ob_flag = drw_object_infos().flag; - bool is_object_active = flag_test(ob_flag, OBJECT_ACTIVE); + bool is_object_active = flag_test(ob_flag, OBJECT_ACTIVE_EDIT_MODE); final_color = (is_selected) ? theme.colors.face_select : theme.colors.face; final_color = (is_active) ? theme.colors.edit_mesh_active : final_color; diff --git a/source/blender/draw/intern/draw_manager.hh b/source/blender/draw/intern/draw_manager.hh index c995028c09b..b14ca09a625 100644 --- a/source/blender/draw/intern/draw_manager.hh +++ b/source/blender/draw/intern/draw_manager.hh @@ -327,9 +327,11 @@ inline ResourceHandleRange Manager::unique_handle(const ObjectRef &ref) inline ResourceHandleRange Manager::resource_handle(const ObjectRef &ref, float inflate_bounds) { bool is_active_object = (ref.dupli_object ? ref.dupli_parent : ref.object) == object_active; + bool is_edit_mode = DRW_object_is_in_edit_mode(object_active) && + ref.object->mode == object_active->mode; matrix_buf.current().get_or_resize(resource_len_).sync(*ref.object); bounds_buf.current().get_or_resize(resource_len_).sync(*ref.object, inflate_bounds); - infos_buf.current().get_or_resize(resource_len_).sync(ref, is_active_object); + infos_buf.current().get_or_resize(resource_len_).sync(ref, is_active_object, is_edit_mode); return ResourceHandle(resource_len_++, (ref.object->transflag & OB_NEG_SCALE) != 0); } @@ -339,6 +341,8 @@ inline ResourceHandle Manager::resource_handle(const ObjectRef &ref, const float3 *bounds_half_extent) { bool is_active_object = (ref.dupli_object ? ref.dupli_parent : ref.object) == object_active; + bool is_edit_mode = DRW_object_is_in_edit_mode(object_active) && + ref.object->mode == object_active->mode; if (model_matrix) { matrix_buf.current().get_or_resize(resource_len_).sync(*model_matrix); } @@ -351,7 +355,7 @@ inline ResourceHandle Manager::resource_handle(const ObjectRef &ref, else { bounds_buf.current().get_or_resize(resource_len_).sync(*ref.object); } - infos_buf.current().get_or_resize(resource_len_).sync(ref, is_active_object); + infos_buf.current().get_or_resize(resource_len_).sync(ref, is_active_object, is_edit_mode); return ResourceHandle(resource_len_++, (ref.object->transflag & OB_NEG_SCALE) != 0); } @@ -377,9 +381,13 @@ inline ResourceHandle Manager::resource_handle_for_psys(const ObjectRef &ref, const float4x4 &model_matrix) { bool is_active_object = (ref.dupli_object ? ref.dupli_parent : ref.object) == object_active; + bool matches_active_object_edit_mode = object_active->mode == eObjectMode::OB_MODE_EDIT && + ref.object->mode == object_active->mode; matrix_buf.current().get_or_resize(resource_len_).sync(model_matrix); bounds_buf.current().get_or_resize(resource_len_).sync(); - infos_buf.current().get_or_resize(resource_len_).sync(ref, is_active_object); + infos_buf.current() + .get_or_resize(resource_len_) + .sync(ref, is_active_object, matches_active_object_edit_mode); return ResourceHandle(resource_len_++, (ref.object->transflag & OB_NEG_SCALE) != 0); } diff --git a/source/blender/draw/intern/draw_resource.hh b/source/blender/draw/intern/draw_resource.hh index 17dc8ae0875..e59cb760f17 100644 --- a/source/blender/draw/intern/draw_resource.hh +++ b/source/blender/draw/intern/draw_resource.hh @@ -69,7 +69,9 @@ inline void ObjectInfos::sync() flag = eObjectInfoFlag::OBJECT_NO_INFO; } -inline void ObjectInfos::sync(const blender::draw::ObjectRef ref, bool is_active_object) +inline void ObjectInfos::sync(const blender::draw::ObjectRef ref, + bool is_active_object, + bool is_active_edit_mode) { object_attrs_len = 0; object_attrs_offset = 0; @@ -97,6 +99,7 @@ inline void ObjectInfos::sync(const blender::draw::ObjectRef ref, bool is_active SET_FLAG_FROM_TEST( flag, ref.object->transflag & OB_NEG_SCALE, eObjectInfoFlag::OBJECT_NEGATIVE_SCALE); SET_FLAG_FROM_TEST(flag, is_holdout, eObjectInfoFlag::OBJECT_HOLDOUT); + SET_FLAG_FROM_TEST(flag, is_active_edit_mode, eObjectInfoFlag::OBJECT_ACTIVE_EDIT_MODE); if (ref.object->shadow_terminator_normal_offset > 0.0f) { using namespace blender::math; diff --git a/source/blender/draw/intern/draw_shader_shared.hh b/source/blender/draw/intern/draw_shader_shared.hh index 42cb4ae6133..f280e8c184b 100644 --- a/source/blender/draw/intern/draw_shader_shared.hh +++ b/source/blender/draw/intern/draw_shader_shared.hh @@ -148,6 +148,9 @@ enum eObjectInfoFlag : uint32_t { OBJECT_ACTIVE = (1u << 3u), OBJECT_NEGATIVE_SCALE = (1u << 4u), OBJECT_HOLDOUT = (1u << 5u), + /* Implies all objects that match the current active object's mode and able to be edited + * simultaneously. Currently only applicable for edit mode. */ + OBJECT_ACTIVE_EDIT_MODE = (1u << 6u), /* Avoid skipped info to change culling. */ OBJECT_NO_INFO = ~OBJECT_HOLDOUT }; @@ -172,7 +175,7 @@ struct ObjectInfos { #if !defined(GPU_SHADER) && defined(__cplusplus) void sync(); - void sync(const blender::draw::ObjectRef ref, bool is_active_object); + void sync(const blender::draw::ObjectRef ref, bool is_active_object, bool is_active_edit_mode); #endif }; BLI_STATIC_ASSERT_ALIGN(ObjectInfos, 16)