diff options
author | Jacques Lucke <jacques@blender.org> | 2022-05-31 20:23:52 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2022-05-31 20:23:52 +0300 |
commit | dc389a61529d335ebdcc28882c8961f78c7c3d0c (patch) | |
tree | 3a50aba0b0edae4c753d4b25c8f90ce091348519 /source/blender/blenkernel/intern | |
parent | f2cd7e08fed02fdf02060c17c943e15e85638cb5 (diff) |
Fix T98454: subdivision doesn't propagate int attributes
Differential Revision: https://developer.blender.org/D15083
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/customdata.cc | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/customdata.cc b/source/blender/blenkernel/intern/customdata.cc index 62351a31042..1d9f377abec 100644 --- a/source/blender/blenkernel/intern/customdata.cc +++ b/source/blender/blenkernel/intern/customdata.cc @@ -54,6 +54,8 @@ /* only for customdata_data_transfer_interp_normal_normals */ #include "data_transfer_intern.h" +using blender::IndexRange; + /* number of layers to add when growing a CustomData object */ #define CUSTOMDATA_GROW 5 @@ -517,6 +519,22 @@ static void layerCopy_propInt(const void *source, void *dest, int count) memcpy(dest, source, sizeof(MIntProperty) * count); } +static void layerInterp_propInt(const void **sources, + const float *weights, + const float *UNUSED(sub_weights), + int count, + void *dest) +{ + float result = 0.0f; + for (const int i : IndexRange(count)) { + const float weight = weights[i]; + const float src = *static_cast<const int *>(sources[i]); + result += src * weight; + } + const int rounded_result = static_cast<int>(round(result)); + *static_cast<int *>(dest) = rounded_result; +} + /** \} */ /* -------------------------------------------------------------------- */ @@ -1679,7 +1697,7 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { N_("Int"), layerCopy_propInt, nullptr, - nullptr, + layerInterp_propInt, nullptr}, /* 12: CD_PROP_STRING */ {sizeof(MStringProperty), |