[Bf-blender-cvs] [d1c9a99c07b] master: Splines: Optimize interpolation in special case virtual array

Hans Goudey noreply at git.blender.org
Wed May 19 23:17:27 CEST 2021


Commit: d1c9a99c07b1160b01710577ea0109addceac97c
Author: Hans Goudey
Date:   Wed May 19 17:17:16 2021 -0400
Branches: master
https://developer.blender.org/rBd1c9a99c07b1160b01710577ea0109addceac97c

Splines: Optimize interpolation in special case virtual array

When the input data is a virtual array for a single value, we don't need
to run any of the interpolation, instead just copy the input data.

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

M	source/blender/blenkernel/intern/spline_bezier.cc
M	source/blender/blenkernel/intern/spline_nurbs.cc

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

diff --git a/source/blender/blenkernel/intern/spline_bezier.cc b/source/blender/blenkernel/intern/spline_bezier.cc
index 0fd3efce033..4be3ba8576e 100644
--- a/source/blender/blenkernel/intern/spline_bezier.cc
+++ b/source/blender/blenkernel/intern/spline_bezier.cc
@@ -560,6 +560,10 @@ blender::fn::GVArrayPtr BezierSpline::interpolate_to_evaluated_points(
 {
   BLI_assert(source_data.size() == this->size());
 
+  if (source_data.is_single()) {
+    return source_data.shallow_copy();
+  }
+
   const int eval_size = this->evaluated_points_size();
   if (eval_size == 1) {
     return source_data.shallow_copy();
diff --git a/source/blender/blenkernel/intern/spline_nurbs.cc b/source/blender/blenkernel/intern/spline_nurbs.cc
index cd3ebe9e680..ae691d26cdb 100644
--- a/source/blender/blenkernel/intern/spline_nurbs.cc
+++ b/source/blender/blenkernel/intern/spline_nurbs.cc
@@ -389,6 +389,10 @@ blender::fn::GVArrayPtr NURBSpline::interpolate_to_evaluated_points(
 {
   BLI_assert(source_data.size() == this->size());
 
+  if (source_data.is_single()) {
+    return source_data.shallow_copy();
+  }
+
   this->calculate_basis_cache();
   Span<BasisCache> weights(basis_cache_);



More information about the Bf-blender-cvs mailing list