[Bf-blender-cvs] [13915c05dd9] blender2.8: CustomData: Allow copying content of a single layer

Sergey Sharybin noreply at git.blender.org
Tue Sep 25 12:28:07 CEST 2018


Commit: 13915c05dd9cedef0956761f3e07c09a224d2e48
Author: Sergey Sharybin
Date:   Tue Sep 25 12:27:43 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB13915c05dd9cedef0956761f3e07c09a224d2e48

CustomData: Allow copying content of a single layer

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

M	source/blender/blenkernel/BKE_customdata.h
M	source/blender/blenkernel/intern/customdata.c

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

diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h
index c37f5301ade..23bc7ddd6fd 100644
--- a/source/blender/blenkernel/BKE_customdata.h
+++ b/source/blender/blenkernel/BKE_customdata.h
@@ -231,6 +231,13 @@ void CustomData_bmesh_copy_data(const struct CustomData *source,
                                 struct CustomData *dest, void *src_block,
                                 void **dest_block);
 
+/* Copies data of a single layer of a given type. */
+void CustomData_copy_layer_type_data(const struct CustomData *source,
+                                     struct CustomData *destination,
+                                     int type,
+                                     int source_index, int destination_index,
+                                     int count);
+
 /* frees data in a CustomData object
  * return 1 on success, 0 on failure
  */
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index 33a96cbe42f..8defb1307ce 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -2239,6 +2239,27 @@ void CustomData_copy_data(const CustomData *source, CustomData *dest,
 	}
 }
 
+void CustomData_copy_layer_type_data(const CustomData *source,
+                                     CustomData *destination,
+                                     int type,
+                                     int source_index, int destination_index,
+                                     int count)
+{
+	const int source_layer_index = CustomData_get_layer_index(source, type);
+	if (source_layer_index == -1) {
+		return;
+	}
+	const int destinaiton_layer_index =
+	        CustomData_get_layer_index(destination, type);
+	if (destinaiton_layer_index == -1) {
+		return;
+	}
+	CustomData_copy_data_layer(source, destination,
+	                           source_layer_index, destinaiton_layer_index,
+	                           source_index, destination_index,
+	                           count);
+}
+
 void CustomData_free_elem(CustomData *data, int index, int count)
 {
 	int i;



More information about the Bf-blender-cvs mailing list