[Bf-blender-cvs] [f8604f18e88] geometry-nodes-curve-support: Geometry Nodes Curves: Further clean up forward differencing function

Hans Goudey noreply at git.blender.org
Tue Apr 6 05:55:37 CEST 2021


Commit: f8604f18e8807ec9fae178c8b5ed027c06e16daf
Author: Hans Goudey
Date:   Mon Apr 5 22:55:31 2021 -0500
Branches: geometry-nodes-curve-support
https://developer.blender.org/rBf8604f18e8807ec9fae178c8b5ed027c06e16daf

Geometry Nodes Curves: Further clean up forward differencing function

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

M	source/blender/blenkernel/intern/derived_curve.cc

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

diff --git a/source/blender/blenkernel/intern/derived_curve.cc b/source/blender/blenkernel/intern/derived_curve.cc
index 3422bb7e5ae..5346692cdde 100644
--- a/source/blender/blenkernel/intern/derived_curve.cc
+++ b/source/blender/blenkernel/intern/derived_curve.cc
@@ -157,21 +157,19 @@ static void evaluate_bezier_section_3d(const float3 &point_0,
                                        const float3 &point_3,
                                        MutableSpan<float3> result)
 {
-  BLI_assert(result.size() > 0);
+  const float len = static_cast<float>(result.size());
+  const float len_squared = len * len;
+  const float len_cubed = len_squared * len;
+  BLI_assert(len > 0.0f);
 
-  float f = static_cast<float>(result.size());
-  float3 rt0 = point_0;
-  float3 rt1 = 3.0f * (point_1 - point_0) / f;
-  f *= f;
-  float3 rt2 = 3.0f * (point_0 - 2.0f * point_1 + point_2) / f;
-  f *= result.size();
-  float3 rt3 = (point_3 - point_0 + 3.0f * (point_1 - point_2)) / f;
+  const float3 rt1 = 3.0f * (point_1 - point_0) / len;
+  const float3 rt2 = 3.0f * (point_0 - 2.0f * point_1 + point_2) / len_squared;
+  const float3 rt3 = (point_3 - point_0 + 3.0f * (point_1 - point_2)) / len_cubed;
 
-  float3 q0 = rt0;
+  float3 q0 = point_0;
   float3 q1 = rt1 + rt2 + rt3;
   float3 q2 = 2.0f * rt2 + 6.0f * rt3;
   float3 q3 = 6.0f * rt3;
-
   for (const int i : result.index_range()) {
     result[i] = q0;
     q0 += q1;



More information about the Bf-blender-cvs mailing list