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.
This commit is contained in:
parent
35aa3bf22d
commit
319de793d7
Notes:
blender-bot
2023-02-14 00:37:17 +01:00
Referenced by issue #92508, Using a normal field input node to offset curve control points has unexpected results.
|
@ -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];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue