Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Oeser <info@graphics-engineer.com>2019-06-17 20:05:41 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2019-06-17 20:38:19 +0300
commitbe52b25d3953696a775be9d2dae32cf713369e7c (patch)
treed476d4d4b399047dc18ab4edf47c6a2440440ace /source/blender/blenkernel
parentd2f7b93ba016486a23311499b54ae8f077d0fb46 (diff)
Fix T65357: wrong facemap indices after applying a boolean modifier
Properly initialize custom data layers to default values when copying from a mesh that does not have all the same layers. Differential Revision: https://developer.blender.org/D5003
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/intern/customdata.c62
1 files changed, 34 insertions, 28 deletions
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index 3af54603d67..9b7a6002035 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -3452,6 +3452,34 @@ static void CustomData_bmesh_alloc_block(CustomData *data, void **block)
}
}
+static void CustomData_bmesh_set_default_n(CustomData *data, void **block, int n)
+{
+ const LayerTypeInfo *typeInfo;
+ int offset = data->layers[n].offset;
+
+ typeInfo = layerType_getInfo(data->layers[n].type);
+
+ if (typeInfo->set_default) {
+ typeInfo->set_default(POINTER_OFFSET(*block, offset), 1);
+ }
+ else {
+ memset(POINTER_OFFSET(*block, offset), 0, typeInfo->size);
+ }
+}
+
+void CustomData_bmesh_set_default(CustomData *data, void **block)
+{
+ int i;
+
+ if (*block == NULL) {
+ CustomData_bmesh_alloc_block(data, block);
+ }
+
+ for (i = 0; i < data->totlayer; ++i) {
+ CustomData_bmesh_set_default_n(data, block, i);
+ }
+}
+
void CustomData_bmesh_copy_data(const CustomData *source,
CustomData *dest,
void *src_block,
@@ -3475,6 +3503,7 @@ void CustomData_bmesh_copy_data(const CustomData *source,
* (this should work because layers are ordered by type)
*/
while (dest_i < dest->totlayer && dest->layers[dest_i].type < source->layers[src_i].type) {
+ CustomData_bmesh_set_default_n(dest, dest_block, dest_i);
dest_i++;
}
@@ -3505,6 +3534,11 @@ void CustomData_bmesh_copy_data(const CustomData *source,
dest_i++;
}
}
+
+ while (dest_i < dest->totlayer) {
+ CustomData_bmesh_set_default_n(dest, dest_block, dest_i);
+ dest_i++;
+ }
}
/* BMesh Custom Data Functions.
@@ -3816,34 +3850,6 @@ void CustomData_bmesh_interp(CustomData *data,
}
}
-static void CustomData_bmesh_set_default_n(CustomData *data, void **block, int n)
-{
- const LayerTypeInfo *typeInfo;
- int offset = data->layers[n].offset;
-
- typeInfo = layerType_getInfo(data->layers[n].type);
-
- if (typeInfo->set_default) {
- typeInfo->set_default(POINTER_OFFSET(*block, offset), 1);
- }
- else {
- memset(POINTER_OFFSET(*block, offset), 0, typeInfo->size);
- }
-}
-
-void CustomData_bmesh_set_default(CustomData *data, void **block)
-{
- int i;
-
- if (*block == NULL) {
- CustomData_bmesh_alloc_block(data, block);
- }
-
- for (i = 0; i < data->totlayer; ++i) {
- CustomData_bmesh_set_default_n(data, block, i);
- }
-}
-
/**
* \param use_default_init: initializes data which can't be copied,
* typically you'll want to use this if the BM_xxx create function