[Bf-blender-cvs] [2f2bedafa10] geometry-nodes-curve-support: Geometry Nodes Curves: Optimize evaluated points size

Hans Goudey noreply at git.blender.org
Tue Apr 6 00:24:32 CEST 2021


Commit: 2f2bedafa10d367b34eb414a1ed770981596ab3d
Author: Hans Goudey
Date:   Mon Apr 5 17:23:18 2021 -0500
Branches: geometry-nodes-curve-support
https://developer.blender.org/rB2f2bedafa10d367b34eb414a1ed770981596ab3d

Geometry Nodes Curves: Optimize evaluated points size

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

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 c0959e70e61..df766b75ea8 100644
--- a/source/blender/blenkernel/intern/derived_curve.cc
+++ b/source/blender/blenkernel/intern/derived_curve.cc
@@ -108,6 +108,14 @@ static bool segment_is_vector(const BezierPoint &point_a, const BezierPoint &poi
 int BezierSpline::evaluated_points_size() const
 {
   BLI_assert(control_points.size() > 0);
+#ifndef DEBUG
+  if (!this->cache_dirty_) {
+    /* In a non-debug build, assume that the cache's size has not changed, and that any operation
+     * that would cause the cache to change its length would also mark the cache dirty. This is
+     * checked at the end of this function in a debug build. */
+    return this->evaluated_positions_cache_.size();
+  }
+#endif
 
   int total_len = 0;
   for (const int i : IndexRange(1, this->control_points.size() - 1)) {
@@ -135,6 +143,11 @@ int BezierSpline::evaluated_points_size() const
     total_len++;
   }
 
+  /* Assert that the cache has the correct length in debug mode. */
+  if (!this->cache_dirty_) {
+    BLI_assert(this->evaluated_positions_cache_.size() == total_len);
+  }
+
   return total_len;
 }



More information about the Bf-blender-cvs mailing list