diff options
author | Jacques Lucke <jacques@blender.org> | 2021-01-14 17:52:08 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-01-14 17:52:08 +0300 |
commit | e5ee7e9a2df93d7f28f9e1f8bc0eb2d33dfadfb4 (patch) | |
tree | f36c7d02bc3441c75b6233fcaa4b0611df883248 /source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc | |
parent | 53bd58993e2f6d35452242762402c20343d6eef3 (diff) |
Geometry Nodes: don't delete existing attribute before new attribute is computed
This fixes the behavior of some nodes when the same attribute
name is used for input and output. If both attributes have a
different type, they can't exist at the same time. Therefore,
the input attribute has to be removed in order to create the
output attribute.
Previously, the input attribute was remove before it was used
in any computations. Now, the output is written to a temporary
buffer and only later saved in the geometry component. This
allows both attributes to coexist within the node.
The temporary attribute is only create when necessary. The
normal case without name collisions still works the same
as before.
Differential Revision: https://developer.blender.org/D10109
Ref T83793.
Diffstat (limited to 'source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc')
-rw-r--r-- | source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc index 6e3b34f702a..f8ec9124db3 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc @@ -107,7 +107,7 @@ static void attribute_math_calc(GeometryComponent &component, const GeoNodeExecP /* Get result attribute first, in case it has to overwrite one of the existing attributes. */ const std::string result_name = params.get_input<std::string>("Result"); - WriteAttributePtr attribute_result = component.attribute_try_ensure_for_write( + OutputAttributePtr attribute_result = component.attribute_try_get_for_output( result_name, result_domain, result_type); if (!attribute_result) { return; @@ -123,6 +123,7 @@ static void attribute_math_calc(GeometryComponent &component, const GeoNodeExecP } do_math_operation(*attribute_a, *attribute_b, *attribute_result, operation); + attribute_result.save(); } static void geo_node_attribute_math_exec(GeoNodeExecParams params) |