diff options
author | Jacques Lucke <jacques@blender.org> | 2021-09-30 13:33:11 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-09-30 13:33:34 +0300 |
commit | 80d7cac22d8726ca33590d644278f91a4b73c303 (patch) | |
tree | 24b8b9a8cfbe4df5aba910bf575b838d15349f54 | |
parent | ae0f944a579c98af0095258d83665d1d5b3423da (diff) |
Fix T91773: improve numerical stability in Curve Spiral node
-rw-r--r-- | source/blender/nodes/geometry/nodes/node_geo_curve_primitive_spiral.cc | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_spiral.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_spiral.cc index 0803d43e5c3..7292fafc8b0 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_spiral.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_spiral.cc @@ -43,26 +43,18 @@ static std::unique_ptr<CurveEval> create_spiral_curve(const float rotations, const int totalpoints = std::max(int(resolution * rotations), 1); const float delta_radius = (end_radius - start_radius) / (float)totalpoints; - float radius = start_radius; const float delta_height = height / (float)totalpoints; - const float delta_theta = (M_PI * 2 * rotations) / (float)totalpoints; - float theta = 0.0f; + const float delta_theta = (M_PI * 2 * rotations) / (float)totalpoints * + (direction ? 1.0f : -1.0f); for (const int i : IndexRange(totalpoints + 1)) { + const float theta = i * delta_theta; + const float radius = start_radius + i * delta_radius; const float x = radius * cos(theta); const float y = radius * sin(theta); const float z = delta_height * i; spline->add_point(float3(x, y, z), 1.0f, 0.0f); - - radius += delta_radius; - - if (direction) { - theta += delta_theta; - } - else { - theta -= delta_theta; - } } spline->attributes.reallocate(spline->size()); |