[Bf-blender-cvs] [0e3475b00d4] master: Fix T61255: Mesh Data Transfer: Do not abort when destination has not all source data layers.

Bastien Montagne noreply at git.blender.org
Fri Feb 8 10:16:09 CET 2019


Commit: 0e3475b00d44bc0220cee84d28daacaa6735f62f
Author: Bastien Montagne
Date:   Fri Feb 8 10:12:31 2019 +0100
Branches: master
https://developer.blender.org/rB0e3475b00d44bc0220cee84d28daacaa6735f62f

Fix T61255: Mesh Data Transfer: Do not abort when destination has not all source data layers.

Originally, when transferring all source data layers to destination
meshes, code would abort in case destination did not have all needed
layers, and creating them was not allowed.

Now, it will instead transfer data to layers that exists, merely
skipping source ones for which it cannot find a matching destination.

===================================================================

M	source/blender/blenkernel/intern/data_transfer.c
M	source/blender/blenkernel/intern/deform.c

===================================================================

diff --git a/source/blender/blenkernel/intern/data_transfer.c b/source/blender/blenkernel/intern/data_transfer.c
index e3d2f63ced9..70942b45d2b 100644
--- a/source/blender/blenkernel/intern/data_transfer.c
+++ b/source/blender/blenkernel/intern/data_transfer.c
@@ -501,12 +501,15 @@ static bool data_transfer_layersmapping_cdlayers_multisrc_to_dst(
 			idx_src++;
 
 			if (idx_dst < idx_src) {
-				if (!use_create) {
-					return true;
+				if (use_create) {
+					/* Create as much data layers as necessary! */
+					for (; idx_dst < idx_src; idx_dst++) {
+						CustomData_add_layer(cd_dst, cddata_type, CD_CALLOC, NULL, num_elem_dst);
+					}
 				}
-				/* Create as much data layers as necessary! */
-				for (; idx_dst < idx_src; idx_dst++) {
-					CustomData_add_layer(cd_dst, cddata_type, CD_CALLOC, NULL, num_elem_dst);
+				else {
+					/* Otherwise, just try to map what we can with existing dst data layers. */
+					idx_src = idx_dst;
 				}
 			}
 			else if (use_delete && idx_dst > idx_src) {
@@ -551,14 +554,14 @@ static bool data_transfer_layersmapping_cdlayers_multisrc_to_dst(
 				data_src = CustomData_get_layer_n(cd_src, cddata_type, idx_src);
 
 				if ((idx_dst = CustomData_get_named_layer(cd_dst, cddata_type, name)) == -1) {
-					if (!use_create) {
-						if (r_map) {
-							BLI_freelistN(r_map);
-						}
-						return true;
+					if (use_create) {
+						CustomData_add_layer_named(cd_dst, cddata_type, CD_CALLOC, NULL, num_elem_dst, name);
+						idx_dst = CustomData_get_named_layer(cd_dst, cddata_type, name);
+					}
+					else {
+						/* If we are not allowed to create missing dst data layers, just skip matching src one. */
+						continue;
 					}
-					CustomData_add_layer_named(cd_dst, cddata_type, CD_CALLOC, NULL, num_elem_dst, name);
-					idx_dst = CustomData_get_named_layer(cd_dst, cddata_type, name);
 				}
 				else if (data_dst_to_delete) {
 					data_dst_to_delete[idx_dst] = false;
diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c
index c3f3516c714..a6c5ddf0285 100644
--- a/source/blender/blenkernel/intern/deform.c
+++ b/source/blender/blenkernel/intern/deform.c
@@ -1060,12 +1060,15 @@ static bool data_transfer_layersmapping_vgroups_multisrc_to_dst(
 			idx_src++;
 
 			if (idx_dst < idx_src) {
-				if (!use_create) {
-					return false;
+				if (use_create) {
+					/* Create as much vgroups as necessary! */
+					for (; idx_dst < idx_src; idx_dst++) {
+						BKE_object_defgroup_add(ob_dst);
+					}
 				}
-				/* Create as much vgroups as necessary! */
-				for (; idx_dst < idx_src; idx_dst++) {
-					BKE_object_defgroup_add(ob_dst);
+				else {
+					/* Otherwise, just try to map what we can with existing dst vgroups. */
+					idx_src = idx_dst;
 				}
 			}
 			else if (use_delete && idx_dst > idx_src) {
@@ -1115,14 +1118,14 @@ static bool data_transfer_layersmapping_vgroups_multisrc_to_dst(
 					}
 
 					if ((idx_dst = defgroup_name_index(ob_dst, dg_src->name)) == -1) {
-						if (!use_create) {
-							if (r_map) {
-								BLI_freelistN(r_map);
-							}
-							return false;
+						if (use_create) {
+							BKE_object_defgroup_add_name(ob_dst, dg_src->name);
+							idx_dst = ob_dst->actdef - 1;
+						}
+						else {
+							/* If we are not allowed to create missing dst vgroups, just skip matching src one. */
+							continue;
 						}
-						BKE_object_defgroup_add_name(ob_dst, dg_src->name);
-						idx_dst = ob_dst->actdef - 1;
 					}
 					if (r_map) {
 						/* At this stage, we **need** a valid CD_MDEFORMVERT layer on dest!



More information about the Bf-blender-cvs mailing list