[Bf-blender-cvs] [f15b3c0f10a] soc-2021-curve-fillet: Made changes according to patch suggestions
dilithjay
noreply at git.blender.org
Tue Aug 24 19:53:59 CEST 2021
Commit: f15b3c0f10a2c6aa550ff5c12e79fedd035d6b99
Author: dilithjay
Date: Mon Aug 16 20:58:54 2021 +0530
Branches: soc-2021-curve-fillet
https://developer.blender.org/rBf15b3c0f10a2c6aa550ff5c12e79fedd035d6b99
Made changes according to patch suggestions
===================================================================
M source/blender/nodes/geometry/nodes/node_geo_curve_fillet.cc
===================================================================
diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_fillet.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_fillet.cc
index 549e3a882dc..c10af900237 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_curve_fillet.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_curve_fillet.cc
@@ -194,9 +194,10 @@ static Array<int> calculate_counts(const std::optional<float> arc_angle,
}
/* Calculate the radii for the vertices to be filleted. */
-static Array<float> calculate_radii(const FilletModeParam &mode_param, const int spline_index)
+static Array<float> calculate_radii(const FilletModeParam &mode_param,
+ const int size,
+ const int spline_index)
{
- const int size = mode_param.radii->size();
Array<float> radii(size, 0.0f);
for (const int i : IndexRange(size)) {
@@ -308,7 +309,7 @@ static FilletData calculate_fillet_data(const Spline &spline,
fd.axes = calculate_axes(fd.directions);
fd.angles = calculate_angles(fd.directions);
fd.counts = calculate_counts(mode_param.angle, mode_param.count, fd.angles, spline.is_cyclic());
- fd.radii = calculate_radii(mode_param, spline_index);
+ fd.radii = calculate_radii(mode_param, size, spline_index);
added_count = calculate_point_counts(point_counts, fd.radii, fd.counts);
@@ -382,45 +383,6 @@ static void copy_NURBS_attributes_by_mapping(const NURBSpline &src,
copy_attribute_by_mapping(src.weights(), dst.weights(), mapping);
}
-/*
- * Update the handle types to get a smoother curve.
- * Required when handles are not of type `Vector`.
- */
-static void update_bezier_handle_types(BezierSpline &dst,
- const Span<int> mapping,
- const Span<int> point_counts)
-{
- MutableSpan<BezierSpline::HandleType> left_handle_types = dst.handle_types_left();
- MutableSpan<BezierSpline::HandleType> right_handle_types = dst.handle_types_right();
-
- for (const int i : mapping.index_range()) {
- if (point_counts[mapping[i]] > 1) {
- /* There will always be a prev and next if point count > 1. */
- int prev = 0, next = 0;
- if (i == 0) {
- prev = mapping.size() - 1;
- next = i + 1;
- }
- else if (i < mapping.size() - 1) {
- prev = i - 1;
- next = i + 1;
- }
- else {
- prev = i - 1;
- next = 0;
- }
-
- /* Update handle types of adjacent points. */
- if (mapping[i] != mapping[prev]) {
- right_handle_types[prev] = BezierSpline::HandleType::Vector;
- }
- if (mapping[i] != mapping[next]) {
- left_handle_types[next] = BezierSpline::HandleType::Vector;
- }
- }
- }
-}
-
/* Update the positions and handle positions of a Bezier spline based on fillet data. */
static void update_bezier_positions(FilletData &fd,
BezierSpline &dst_spline,
@@ -462,8 +424,12 @@ static void update_bezier_positions(FilletData &fd,
dst_spline.positions()[end_i] = positions[i] + displacement * next_dir;
dst_spline.handle_positions_right()[cur_i] = dst_spline.positions()[cur_i] -
handle_length * prev_dir;
+ dst_spline.handle_positions_left()[cur_i] = dst_spline.positions()[cur_i] +
+ handle_length * prev_dir;
dst_spline.handle_positions_left()[end_i] = dst_spline.positions()[end_i] -
handle_length * next_dir;
+ dst_spline.handle_positions_right()[end_i] = dst_spline.positions()[end_i] +
+ handle_length * next_dir;
dst_spline.handle_types_right()[cur_i] = dst_spline.handle_types_left()[end_i] =
BezierSpline::HandleType::Align;
dst_spline.handle_types_left()[cur_i] = dst_spline.handle_types_right()[end_i] =
@@ -594,7 +560,6 @@ static SplinePtr fillet_spline(const Spline &spline,
BezierSpline &dst_spline = static_cast<BezierSpline &>(*dst_spline_ptr);
dst_spline.resize(total_points);
copy_bezier_attributes_by_mapping(src_spline, dst_spline, dst_to_src);
- update_bezier_handle_types(dst_spline, dst_to_src, point_counts);
update_bezier_positions(fd, dst_spline, point_counts, start, fillet_count);
break;
}
@@ -633,7 +598,7 @@ static std::unique_ptr<CurveEval> fillet_curve(const CurveEval &input_curve,
Array<int> spline_indices(input_splines.size());
spline_indices[0] = 0;
for (const int i : IndexRange(1, num_splines - 1)) {
- spline_indices[i] = spline_indices[i - 1] + input_splines[i]->size();
+ spline_indices[i] = spline_indices[i - 1] + input_splines[i - 1]->size();
}
threading::parallel_for(input_splines.index_range(), 128, [&](IndexRange range) {
More information about the Bf-blender-cvs
mailing list