From 500bc99da5dbcdf7c728833326fc29babaf529e0 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Tue, 16 Feb 2021 14:25:35 +0100 Subject: Fix T85697: implement interpolation for float custom data type This just hasn't been implemented before. --- source/blender/blenkernel/intern/customdata.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'source') diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 782b4fc200e..9188d8c1afd 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -473,6 +473,21 @@ static void layerCopy_propFloat(const void *source, void *dest, int count) memcpy(dest, source, sizeof(MFloatProperty) * count); } +static void layerInterp_propFloat(const void **sources, + const float *weights, + const float *UNUSED(sub_weights), + int count, + void *dest) +{ + float result = 0.0f; + for (int i = 0; i < count; i++) { + const float interp_weight = weights[i]; + const float src = *(const float *)sources[i]; + result += src * interp_weight; + } + *(float *)dest = result; +} + static bool layerValidate_propFloat(void *data, const uint totitems, const bool do_fixes) { MFloatProperty *fp = data; @@ -1553,7 +1568,7 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { N_("Float"), layerCopy_propFloat, NULL, - NULL, + layerInterp_propFloat, NULL, NULL, layerValidate_propFloat}, -- cgit v1.2.3