Overlays: Make flash on mode transfer an operator property

This moves the flash on mode transfer effect option from the overlays to
an operator property of the mode transfer operator.

- This effect is intended to show the target object when no overlays or
a minimal set of overlays is enabled. Making it part of the whole set of
overlays invalidates this use case.

- The effect is not intended to be configurable per viewport, it should
be a global option.

The effect is still implemented using the overlay engine (instead of a
draw modal callback) due to performance and drawing artifacts. Having it
implemented as an overlay with runtime timer data in the objects makes
also possible to run multiple animations at the same time without any
visual glitches.

Reviewed By: campbellbarton, JulienKaspar

Differential Revision: https://developer.blender.org/D11519
This commit is contained in:
Pablo Dobarro 2021-06-11 21:42:36 +02:00 committed by Pablo Dobarro
parent f6c5af3d47
commit 7bc5246156
5 changed files with 10 additions and 14 deletions

View File

@ -6186,9 +6186,6 @@ class VIEW3D_PT_overlay_geometry(Panel):
sub.active = overlay.show_fade_inactive
sub.prop(overlay, "fade_inactive_alpha", text="Fade Inactive Geometry")
row = col.row(align=True)
row.prop(overlay, "show_mode_transfer", text="Flash on Mode Transfer")
col = layout.column(align=True)
col.active = display_all

View File

@ -324,7 +324,7 @@ static void OVERLAY_cache_populate(void *vedata, Object *ob)
!is_select;
const bool draw_fade = draw_surface && (pd->overlay.flag & V3D_OVERLAY_FADE_INACTIVE) &&
overlay_should_fade_object(ob, draw_ctx->obact);
const bool draw_mode_transfer = draw_surface && (pd->overlay.flag & V3D_OVERLAY_MODE_TRANSFER);
const bool draw_mode_transfer = draw_surface;
const bool draw_bones = (pd->overlay.flag & V3D_OVERLAY_HIDE_BONES) == 0;
const bool draw_wires = draw_surface && has_surface &&
(pd->wireframe_mode || !pd->hide_overlays);

View File

@ -484,7 +484,9 @@ static bool object_transfer_mode_to_base(bContext *C, wmOperator *op, Base *base
ob_dst_orig = DEG_get_original_object(ob_dst);
ED_object_mode_set_ex(C, last_mode, true, op->reports);
object_overlay_mode_transfer_animation_start(C, ob_dst);
if (RNA_boolean_get(op->ptr, "use_flash_on_transfer")) {
object_overlay_mode_transfer_animation_start(C, ob_dst);
}
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
WM_toolsystem_update_from_context_view3d(C);
@ -578,6 +580,12 @@ void OBJECT_OT_transfer_mode(wmOperatorType *ot)
false,
"Use Eyedropper",
"Pick the object to switch to using an eyedropper");
RNA_def_boolean(ot->srna,
"use_flash_on_transfer",
true,
"Flash On Transfer",
"Flash the target object when transfering the mode");
}
/** \} */

View File

@ -515,7 +515,6 @@ enum {
V3D_OVERLAY_HIDE_OBJECT_ORIGINS = (1 << 10),
V3D_OVERLAY_STATS = (1 << 11),
V3D_OVERLAY_FADE_INACTIVE = (1 << 12),
V3D_OVERLAY_MODE_TRANSFER = (1 << 13),
};
/** #View3DOverlay.edit_flag */

View File

@ -4129,14 +4129,6 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
prop, "Fade Inactive Objects", "Fade inactive geometry using the viewport background color");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
prop = RNA_def_property(srna, "show_mode_transfer", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "overlay.flag", V3D_OVERLAY_MODE_TRANSFER);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop,
"Flash on Mode Transfer",
"Flash the target object when tranfering the active mode to it");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
prop = RNA_def_property(srna, "fade_inactive_alpha", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "overlay.fade_alpha");
RNA_def_property_ui_text(prop, "Opacity", "Strength of the fade effect");