Fix T55956: Transfer Weights: Source Layers can't be set to Active Layer.
authorBastien Montagne <montagne29@wanadoo.fr>
Wed, 27 Mar 2019 19:44:14 +0000 (20:44 +0100)
committerBastien Montagne <montagne29@wanadoo.fr>
Wed, 27 Mar 2019 19:47:56 +0000 (20:47 +0100)
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.

source/blender/editors/object/object_data_transfer.c

index 3e32770c9a8aa0561f9b31e17c4c4e09d831dbf0..52b607935858e1384232c831db7af7a67e34d95e 100644 (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);