Fix #140621: Multi-object edit mode displays non-active UVs as faded
The feature to display multiple objects in the UV and Image Editor was
added in 24d08e0bae.
This commit did not account the multi-edit mode feature, where there may
be more than one object currently being edited, causing some UVs to
display with a faded opacity.
To fix this, introduce a new `eObjectInfoFlag` flag to indicate this
state, populate it when syncing the object, and use the flag inside the
relevant shaders.
Pull Request: https://projects.blender.org/blender/blender/pulls/141254
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user