[Bf-blender-cvs] [80d7cac22d8] master: Fix T91773: improve numerical stability in Curve Spiral node

Jacques Lucke noreply at git.blender.org
Thu Sep 30 12:33:46 CEST 2021


Commit: 80d7cac22d8726ca33590d644278f91a4b73c303
Author: Jacques Lucke
Date:   Thu Sep 30 12:33:11 2021 +0200
Branches: master
https://developer.blender.org/rB80d7cac22d8726ca33590d644278f91a4b73c303

Fix T91773: improve numerical stability in Curve Spiral node

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

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

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

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());



More information about the Bf-blender-cvs mailing list