diff options
author | Aleksi Juvani <aleksijuvani> | 2022-03-09 00:51:53 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-03-09 00:51:53 +0300 |
commit | eb326c7b402e4914e9a619b899a388be7668255b (patch) | |
tree | 6bc777edd98e593aab183d18997bf3426d6abe25 /source/blender/blenkernel/intern/customdata.cc | |
parent | 521d4190a09b1117f4f729991a0c636be4c2b8f3 (diff) |
Attributes: Implement CustomData interpolation for boolean data type
This commit fixes an issue, where for instance, when merging vertices
with the "Merge by Distance" geometry node, the resulting vertices had
their boolean attributes set unpredictably.
Boolean attributes are implemented as custom data, and when welding
vertices, the custom data for the resulting vertices comes from
interpolating the custom data of the source vertices.
This commit implements the missing interpolation function for the
boolean custom data type. This interpolation function is implemented in
terms of the logical or operation, that is to say, if any of the source
vertices (with a weight greater than zero) have the boolean set, the
boolean will also be set on the resulting vertex.
This logic matches 95981c9876483256b28.
In geometry nodes, attribute interpolation generally does not use the
CustomData API for performance reasons, but other areas of Blender
still do.
Differential Revision: https://developer.blender.org/D14172
Diffstat (limited to 'source/blender/blenkernel/intern/customdata.cc')
-rw-r--r-- | source/blender/blenkernel/intern/customdata.cc | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/customdata.cc b/source/blender/blenkernel/intern/customdata.cc index 4492f8bbc64..b348e18a6a8 100644 --- a/source/blender/blenkernel/intern/customdata.cc +++ b/source/blender/blenkernel/intern/customdata.cc @@ -1450,6 +1450,21 @@ static bool layerValidate_propfloat2(void *data, const uint totitems, const bool return has_errors; } +static void layerInterp_propbool(const void **sources, + const float *weights, + const float *UNUSED(sub_weights), + int count, + void *dest) +{ + bool result = false; + for (int i = 0; i < count; i++) { + const float interp_weight = weights[i]; + const bool src = *(const bool *)sources[i]; + result |= src && (interp_weight > 0.0f); + } + *(bool *)dest = result; +} + static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { /* 0: CD_MVERT */ {sizeof(MVert), "MVert", 1, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}, @@ -1838,7 +1853,7 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { N_("Boolean"), nullptr, nullptr, - nullptr, + layerInterp_propbool, nullptr, nullptr, nullptr, |