Fix T55956: Transfer Weights: Source Layers can't be set to Active Layer.

Behavior of source/destination options was rather flaky in reversed
mode...

Note that even though this mode is a bit annoying and cumbersome, the
only alternative (defining a specific transfer weight operator) would be
much more verbose, so think that for now we'd rather keep what we have
here.
This commit is contained in:
Bastien Montagne 2019-03-27 20:44:14 +01:00
parent 05201c75e3
commit 52d5d53b5e
Notes: blender-bot 2023-02-14 11:25:11 +01:00
Referenced by issue #55956, Transfer Weights: Source Layers can't be set to Active Layer
1 changed files with 23 additions and 11 deletions

View File

@ -88,19 +88,28 @@ static const EnumPropertyItem DT_layer_items[] = {
static const EnumPropertyItem *dt_layers_select_src_itemf(
bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free)
{
EnumPropertyItem *item = NULL, tmp_item = {0};
int totitem = 0;
const int data_type = RNA_enum_get(ptr, "data_type");
if (!C) { /* needed for docs and i18n tools */
return rna_enum_dt_layers_select_src_items;
}
EnumPropertyItem *item = NULL, tmp_item = {0};
int totitem = 0;
const int data_type = RNA_enum_get(ptr, "data_type");
Depsgraph *depsgraph = CTX_data_depsgraph(C);
RNA_enum_items_add_value(&item, &totitem, rna_enum_dt_layers_select_src_items, DT_LAYERS_ACTIVE_SRC);
PropertyRNA *prop = RNA_struct_find_property(ptr, "use_reverse_transfer");
const bool reverse_transfer = prop != NULL && RNA_property_boolean_get(ptr, prop);
const int layers_select_dst = reverse_transfer ? RNA_enum_get(ptr, "layers_select_src") :
RNA_enum_get(ptr, "layers_select_dst");
if (!reverse_transfer || layers_select_dst == DT_LAYERS_ACTIVE_DST || layers_select_dst >= 0) {
RNA_enum_items_add_value(&item, &totitem, rna_enum_dt_layers_select_src_items, DT_LAYERS_ACTIVE_SRC);
}
RNA_enum_items_add_value(&item, &totitem, rna_enum_dt_layers_select_src_items, DT_LAYERS_ALL_SRC);
if (data_type == DT_TYPE_MDEFORMVERT) {
Object *ob_src = CTX_data_active_object(C);
@ -184,16 +193,19 @@ static const EnumPropertyItem *dt_layers_select_src_itemf(
static const EnumPropertyItem *dt_layers_select_dst_itemf(
bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free)
{
EnumPropertyItem *item = NULL;
int totitem = 0;
const int layers_select_src = RNA_enum_get(ptr, "layers_select_src");
if (!C) { /* needed for docs and i18n tools */
return rna_enum_dt_layers_select_dst_items;
}
if (layers_select_src == DT_LAYERS_ACTIVE_SRC || layers_select_src >= 0) {
EnumPropertyItem *item = NULL;
int totitem = 0;
PropertyRNA *prop = RNA_struct_find_property(ptr, "use_reverse_transfer");
const bool reverse_transfer = prop != NULL && RNA_property_boolean_get(ptr, prop);
const int layers_select_src = reverse_transfer ? RNA_enum_get(ptr, "layers_select_dst") :
RNA_enum_get(ptr, "layers_select_src");
if (reverse_transfer || layers_select_src == DT_LAYERS_ACTIVE_SRC || layers_select_src >= 0) {
RNA_enum_items_add_value(&item, &totitem, rna_enum_dt_layers_select_dst_items, DT_LAYERS_ACTIVE_DST);
}
RNA_enum_items_add_value(&item, &totitem, rna_enum_dt_layers_select_dst_items, DT_LAYERS_NAME_DST);