From 319de793d79865603b3cdccec5933d2152e43bb3 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Tue, 26 Oct 2021 20:50:57 +0200 Subject: Fix T92508: cache invalidation bug in Set Position node The call to `attribute_try_get_for_output` does some cache invalidation internally. Under some circumstances the call to `position_evaluator.evaluate()` recomputed the caches (e.g. when the Normal node was used, the evaluated handle positions cache on curves were updated). After the positions have been updated in the Set Position node, the cache was not invalidated again., leading to incorrect rendering. The proper solution will be to do the cache invalidation in `OutputAttribute.save()` again. That is a bit more involved though. For now just reorder the code a bit to do the cache invalidation after the field has been computed. There is a follow up task: T92509. --- source/blender/nodes/geometry/nodes/node_geo_set_position.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source/blender') diff --git a/source/blender/nodes/geometry/nodes/node_geo_set_position.cc b/source/blender/nodes/geometry/nodes/node_geo_set_position.cc index 1b6b6a5bdd7..a20f14e1ee3 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_set_position.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_set_position.cc @@ -45,10 +45,6 @@ static void set_position_in_component(GeometryComponent &component, selection_evaluator.evaluate(); const IndexMask selection = selection_evaluator.get_evaluated_as_mask(0); - OutputAttribute_Typed positions = component.attribute_try_get_for_output( - "position", ATTR_DOMAIN_POINT, {0, 0, 0}); - MutableSpan position_mutable = positions.as_span(); - fn::FieldEvaluator position_evaluator{field_context, &selection}; position_evaluator.add(position_field); position_evaluator.add(offset_field); @@ -60,6 +56,10 @@ static void set_position_in_component(GeometryComponent &component, const VArray &positions_input = position_evaluator.get_evaluated(0); const VArray &offsets_input = position_evaluator.get_evaluated(1); + OutputAttribute_Typed positions = component.attribute_try_get_for_output( + "position", ATTR_DOMAIN_POINT, {0, 0, 0}); + MutableSpan position_mutable = positions.as_span(); + for (int i : selection) { position_mutable[i] = positions_input[i] + offsets_input[i]; } -- cgit v1.2.3