Fix T95952: Uninitialized value used in Bezier Segment node

0fd72a98ac called functions to set bezier handle positions
that used uninitialized memory. The fix is to define the handle positions
explicitly, like before.
This commit is contained in:
Hans Goudey 2022-02-23 13:57:04 -05:00
parent 398538b914
commit dbef66c32f
Notes: blender-bot 2023-02-13 23:16:02 +01:00
Referenced by issue #96146, Subdivide and cycle Bezier curve
Referenced by issue #95952, "Set Handle Position" node in Blender 3.1.0 Beta randomly changes handle positions on bezier curve when muted and unmuted
1 changed files with 13 additions and 4 deletions

View File

@ -91,13 +91,22 @@ static std::unique_ptr<CurveEval> create_bezier_segment_curve(
positions.first() = start;
positions.last() = end;
MutableSpan<float3> handles_right = spline->handle_positions_right();
MutableSpan<float3> handles_left = spline->handle_positions_left();
if (mode == GEO_NODE_CURVE_PRIMITIVE_BEZIER_SEGMENT_POSITION) {
spline->set_handle_position_right(0, start_handle_right);
spline->set_handle_position_left(1, end_handle_left);
handles_left.first() = 2.0f * start - start_handle_right;
handles_right.first() = start_handle_right;
handles_left.last() = end_handle_left;
handles_right.last() = 2.0f * end - end_handle_left;
}
else {
spline->set_handle_position_right(0, start + start_handle_right);
spline->set_handle_position_left(1, end + end_handle_left);
handles_left.first() = start - start_handle_right;
handles_right.first() = start + start_handle_right;
handles_left.last() = end + end_handle_left;
handles_right.last() = end - end_handle_left;
}
curve->add_spline(std::move(spline));