Commit: 669577a9736a0106df50985b67d2b7a0f08f9361 Author: Hans Goudey Date: Mon Jan 10 16:26:09 2022 +0100 Branches: blender-v3.0-release https://developer.blender.org/rB669577a9736a0106df50985b67d2b7a0f08f9361
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 945dac5650b..758f81f4266 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc @@ -188,8 +188,13 @@ 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); - output_splines[i] = resample_spline(*input_splines[i], std::max(cuts[i], 1)); + if (input_splines[i]->evaluated_points_size() > 0) { + BLI_assert(mode_param.count); + output_splines[i] = resample_spline(*input_splines[i], std::max(cuts[i], 1)); + } + else { + output_splines[i] = input_splines[i]->copy(); + } } }); } @@ -201,18 +206,28 @@ 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) { - /* 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(); - const int count = std::max(int(spline_length / divide_length) + 1, 1); - output_splines[i] = resample_spline(*input_splines[i], count); + if (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(); + const int count = std::max(int(spline_length / divide_length) + 1, 1); + output_splines[i] = resample_spline(*input_splines[i], count); + } + else { + output_splines[i] = input_splines[i]->copy(); + } } }); } else if (mode_param.mode == GEO_NODE_CURVE_RESAMPLE_EVALUATED) { threading::parallel_for(input_splines.index_range(), 128, [&](IndexRange range) { for (const int i : range) { - output_splines[i] = resample_spline_evaluated(*input_splines[i]); + if (input_splines[i]->evaluated_points_size() > 0) { + output_splines[i] = resample_spline_evaluated(*input_splines[i]); + } + else { + output_splines[i] = input_splines[i]->copy(); + } } }); } _______________________________________________ Bf-blender-cvs mailing list [email protected] List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
