Fix T45991: Transfer Weight tool UI is inconsistent and crashes blender.

Since data transfer when called from this tool has reversed behavior (it transfers **towards**
active object, as previous tool), we have to also reverse source/destination layers selection options.

Also fix 'reverse' option being saved, otherwise calling regular operator after 'transfer weights'
would stay in reverse mode, ugly!
This commit is contained in:
Bastien Montagne 2015-09-02 13:02:06 +02:00
parent 5fe9b36aa6
commit 525d7e02d4
Notes: blender-bot 2023-02-14 11:25:11 +01:00
Referenced by issue #45991, Transfer Weight tool UI is inconsistent and crashes blender.
1 changed files with 25 additions and 4 deletions

View File

@ -183,7 +183,8 @@ static EnumPropertyItem *dt_layers_select_src_itemf(
}
/* Note: DT_layers_select_dst_items enum is from rna_modifier.c */
static EnumPropertyItem *dt_layers_select_dst_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free)
static EnumPropertyItem *dt_layers_select_dst_itemf(
bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free)
{
EnumPropertyItem *item = NULL;
int totitem = 0;
@ -208,6 +209,26 @@ static EnumPropertyItem *dt_layers_select_dst_itemf(bContext *C, PointerRNA *ptr
return item;
}
static EnumPropertyItem *dt_layers_select_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *prop, bool *r_free)
{
const bool reverse_transfer = RNA_boolean_get(ptr, "use_reverse_transfer");
if (STREQ(RNA_property_identifier(prop), "layers_select_dst")) {
if (reverse_transfer) {
return dt_layers_select_src_itemf(C, ptr, prop, r_free);
}
else {
return dt_layers_select_dst_itemf(C, ptr, prop, r_free);
}
}
else if (reverse_transfer) {
return dt_layers_select_dst_itemf(C, ptr, prop, r_free);
}
else {
return dt_layers_select_src_itemf(C, ptr, prop, r_free);
}
}
/* Note: DT_mix_mode_items enum is from rna_modifier.c */
static EnumPropertyItem *dt_mix_mode_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free)
{
@ -530,7 +551,7 @@ void OBJECT_OT_data_transfer(wmOperatorType *ot)
/* Properties.*/
prop = RNA_def_boolean(ot->srna, "use_reverse_transfer", false, "Reverse Transfer",
"Transfer from selected objects to active one");
RNA_def_property_flag(prop, PROP_HIDDEN);
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
RNA_def_boolean(ot->srna, "use_freeze", false, "Freeze Operator",
"Prevent changes to settings to re-run the operator, "
@ -574,11 +595,11 @@ void OBJECT_OT_data_transfer(wmOperatorType *ot)
/* How to handle multi-layers types of data. */
prop = RNA_def_enum(ot->srna, "layers_select_src", DT_layers_select_src_items, DT_LAYERS_ACTIVE_SRC,
"Source Layers Selection", "Which layers to transfer, in case of multi-layers types");
RNA_def_property_enum_funcs_runtime(prop, NULL, NULL, dt_layers_select_src_itemf);
RNA_def_property_enum_funcs_runtime(prop, NULL, NULL, dt_layers_select_itemf);
prop = RNA_def_enum(ot->srna, "layers_select_dst", DT_layers_select_dst_items, DT_LAYERS_ACTIVE_DST,
"Destination Layers Matching", "How to match source and destination layers");
RNA_def_property_enum_funcs_runtime(prop, NULL, NULL, dt_layers_select_dst_itemf);
RNA_def_property_enum_funcs_runtime(prop, NULL, NULL, dt_layers_select_itemf);
prop = RNA_def_enum(ot->srna, "mix_mode", DT_mix_mode_items, CDT_MIX_TRANSFER, "Mix Mode",
"How to affect destination elements with source values");