[Bf-blender-cvs] [319de793d79] master: Fix T92508: cache invalidation bug in Set Position node

Jacques Lucke noreply at git.blender.org
Tue Oct 26 20:52:29 CEST 2021


Commit: 319de793d79865603b3cdccec5933d2152e43bb3
Author: Jacques Lucke
Date:   Tue Oct 26 20:50:57 2021 +0200
Branches: master
https://developer.blender.org/rB319de793d79865603b3cdccec5933d2152e43bb3

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.

===================================================================

M	source/blender/nodes/geometry/nodes/node_geo_set_position.cc

===================================================================

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];
   }



More information about the Bf-blender-cvs mailing list