diff options
author | Jacques Lucke <jacques@blender.org> | 2021-10-26 21:50:57 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-10-26 21:52:18 +0300 |
commit | 319de793d79865603b3cdccec5933d2152e43bb3 (patch) | |
tree | 73a8a117f4c8085e4a6e98a7c0223b87608a171d /source/blender | |
parent | 35aa3bf22d4e1780cd4560d9ebafebb84384b085 (diff) |
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.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/nodes/geometry/nodes/node_geo_set_position.cc | 8 |
1 files changed, 4 insertions, 4 deletions
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<float3> positions = component.attribute_try_get_for_output<float3>( - "position", ATTR_DOMAIN_POINT, {0, 0, 0}); - MutableSpan<float3> 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<float3> &positions_input = position_evaluator.get_evaluated<float3>(0); const VArray<float3> &offsets_input = position_evaluator.get_evaluated<float3>(1); + OutputAttribute_Typed<float3> positions = component.attribute_try_get_for_output<float3>( + "position", ATTR_DOMAIN_POINT, {0, 0, 0}); + MutableSpan<float3> position_mutable = positions.as_span(); + for (int i : selection) { position_mutable[i] = positions_input[i] + offsets_input[i]; } |