[Bf-blender-cvs] [ee4ed99866f] master: Fix T93521: Single point NURBS crash in resample node

Hans Goudey noreply at git.blender.org
Mon Dec 6 18:19:34 CET 2021


Commit: ee4ed99866fbb7ab048b637b2d71a872b7eef2b5
Author: Hans Goudey
Date:   Mon Dec 6 12:19:27 2021 -0500
Branches: master
https://developer.blender.org/rBee4ed99866fbb7ab048b637b2d71a872b7eef2b5

Fix T93521: Single point NURBS crash in resample node

The resample node didn't handle the case of when a spline didn't have
any evaluated points. For poly and Bezier splines we should never hit
this case, but it is expected when the number of NURBS control points
is smaller than its order, so we have to handle the case here.

It's not that obvious what to do in this case, there are a few options:
 - Remove the bad splines from the result
 - Generate empty splines for those inputs
 - Skip resampling the bad splines, copy them to the result
 - Arbitrarily generate single point splines

I chose option three, just skipping the "bad" splines. Since the node
already has a selection input, this can be described by just extending
that. "Splines with no evaluated points are implicitly deselected."
The first option would probably be valid too though.

Differential Revision: https://developer.blender.org/D13434

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

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

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

diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc
index 594ffcffb39..4f02afd1e69 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc
@@ -189,7 +189,7 @@ static std::unique_ptr<CurveEval> resample_curve(const CurveComponent *component
     threading::parallel_for(input_splines.index_range(), 128, [&](IndexRange range) {
       for (const int i : range) {
         BLI_assert(mode_param.count);
-        if (selections[i]) {
+        if (selections[i] && input_splines[i]->evaluated_points_size() > 0) {
           output_splines[i] = resample_spline(*input_splines[i], std::max(cuts[i], 1));
         }
         else {
@@ -208,7 +208,7 @@ static std::unique_ptr<CurveEval> resample_curve(const CurveComponent *component
 
     threading::parallel_for(input_splines.index_range(), 128, [&](IndexRange range) {
       for (const int i : range) {
-        if (selections[i]) {
+        if (selections[i] && input_splines[i]->evaluated_points_size() > 0) {
           /* Don't allow asymptotic count increase for low resolution values. */
           const float divide_length = std::max(lengths[i], 0.0001f);
           const float spline_length = input_splines[i]->length();
@@ -229,7 +229,7 @@ static std::unique_ptr<CurveEval> resample_curve(const CurveComponent *component
 
     threading::parallel_for(input_splines.index_range(), 128, [&](IndexRange range) {
       for (const int i : range) {
-        if (selections[i]) {
+        if (selections[i] && input_splines[i]->evaluated_points_size() > 0) {
           output_splines[i] = resample_spline_evaluated(*input_splines[i]);
         }
         else {



More information about the Bf-blender-cvs mailing list