diff options
author | Hans Goudey <h.goudey@me.com> | 2022-02-23 01:37:58 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-02-23 01:37:58 +0300 |
commit | 5b4732f81ca8a159e937336fba7c8eb3220216de (patch) | |
tree | 4c0ab34fda202c209cbc99934a5355feec26af49 | |
parent | 0b9cc6725cca193ec20868caf266ea35c173b956 (diff) |
Cleanup: Use new enum for CurveEval handle types
This will make the transition to the new curves data structure
a bit simple, since the handle types can be copied directly between
the two. The change to CurveEval is simple because it is runtime-only.
15 files changed, 123 insertions, 134 deletions
diff --git a/source/blender/blenkernel/BKE_spline.hh b/source/blender/blenkernel/BKE_spline.hh index 846dcd3ca8e..646af6f8f98 100644 --- a/source/blender/blenkernel/BKE_spline.hh +++ b/source/blender/blenkernel/BKE_spline.hh @@ -10,6 +10,8 @@ #include "FN_generic_virtual_array.hh" +#include "DNA_curves_types.h" + #include "BLI_float4x4.hh" #include "BLI_math_vec_types.hh" #include "BLI_vector.hh" @@ -252,26 +254,13 @@ class Spline { * factors and indices in a list of floats, which is then used to interpolate any other data. */ class BezierSpline final : public Spline { - public: - enum class HandleType { - /** The handle can be moved anywhere, and doesn't influence the point's other handle. */ - Free, - /** The location is automatically calculated to be smooth. */ - Auto, - /** The location is calculated to point to the next/previous control point. */ - Vector, - /** The location is constrained to point in the opposite direction as the other handle. */ - Align, - }; - - private: blender::Vector<blender::float3> positions_; blender::Vector<float> radii_; blender::Vector<float> tilts_; int resolution_; - blender::Vector<HandleType> handle_types_left_; - blender::Vector<HandleType> handle_types_right_; + blender::Vector<int8_t> handle_types_left_; + blender::Vector<int8_t> handle_types_right_; /* These are mutable to allow lazy recalculation of #Auto and #Vector handle positions. */ mutable blender::Vector<blender::float3> handle_positions_left_; @@ -323,8 +312,8 @@ class BezierSpline final : public Spline { blender::Span<float> radii() const final; blender::MutableSpan<float> tilts() final; blender::Span<float> tilts() const final; - blender::Span<HandleType> handle_types_left() const; - blender::MutableSpan<HandleType> handle_types_left(); + blender::Span<int8_t> handle_types_left() const; + blender::MutableSpan<int8_t> handle_types_left(); blender::Span<blender::float3> handle_positions_left() const; /** * Get writable access to the handle position. @@ -333,8 +322,8 @@ class BezierSpline final : public Spline { * uninitialized memory while auto-generating handles. */ blender::MutableSpan<blender::float3> handle_positions_left(bool write_only = false); - blender::Span<HandleType> handle_types_right() const; - blender::MutableSpan<HandleType> handle_types_right(); + blender::Span<int8_t> handle_types_right() const; + blender::MutableSpan<int8_t> handle_types_right(); blender::Span<blender::float3> handle_positions_right() const; /** * Get writable access to the handle position. diff --git a/source/blender/blenkernel/intern/curve_eval.cc b/source/blender/blenkernel/intern/curve_eval.cc index 7fb833e67f8..49010caef24 100644 --- a/source/blender/blenkernel/intern/curve_eval.cc +++ b/source/blender/blenkernel/intern/curve_eval.cc @@ -160,24 +160,24 @@ void CurveEval::mark_cache_invalid() } } -static BezierSpline::HandleType handle_type_from_dna_bezt(const eBezTriple_Handle dna_handle_type) +static HandleType handle_type_from_dna_bezt(const eBezTriple_Handle dna_handle_type) { switch (dna_handle_type) { case HD_FREE: - return BezierSpline::HandleType::Free; + return BEZIER_HANDLE_FREE; case HD_AUTO: - return BezierSpline::HandleType::Auto; + return BEZIER_HANDLE_AUTO; case HD_VECT: - return BezierSpline::HandleType::Vector; + return BEZIER_HANDLE_VECTOR; case HD_ALIGN: - return BezierSpline::HandleType::Align; + return BEZIER_HANDLE_ALIGN; case HD_AUTO_ANIM: - return BezierSpline::HandleType::Auto; + return BEZIER_HANDLE_AUTO; case HD_ALIGN_DOUBLESIDE: - return BezierSpline::HandleType::Align; + return BEZIER_HANDLE_ALIGN; } BLI_assert_unreachable(); - return BezierSpline::HandleType::Auto; + return BEZIER_HANDLE_AUTO; } static Spline::NormalCalculationMode normal_mode_from_dna_curve(const int twist_mode) @@ -220,8 +220,8 @@ static SplinePtr spline_from_dna_bezier(const Nurb &nurb) MutableSpan<float3> positions = spline->positions(); MutableSpan<float3> handle_positions_left = spline->handle_positions_left(true); MutableSpan<float3> handle_positions_right = spline->handle_positions_right(true); - MutableSpan<BezierSpline::HandleType> handle_types_left = spline->handle_types_left(); - MutableSpan<BezierSpline::HandleType> handle_types_right = spline->handle_types_right(); + MutableSpan<int8_t> handle_types_left = spline->handle_types_left(); + MutableSpan<int8_t> handle_types_right = spline->handle_types_right(); MutableSpan<float> radii = spline->radii(); MutableSpan<float> tilts = spline->tilts(); diff --git a/source/blender/blenkernel/intern/spline_bezier.cc b/source/blender/blenkernel/intern/spline_bezier.cc index 57f1d73d55e..3c2ac1dae9c 100644 --- a/source/blender/blenkernel/intern/spline_bezier.cc +++ b/source/blender/blenkernel/intern/spline_bezier.cc @@ -93,11 +93,11 @@ Span<float> BezierSpline::tilts() const { return tilts_; } -Span<BezierSpline::HandleType> BezierSpline::handle_types_left() const +Span<int8_t> BezierSpline::handle_types_left() const { return handle_types_left_; } -MutableSpan<BezierSpline::HandleType> BezierSpline::handle_types_left() +MutableSpan<int8_t> BezierSpline::handle_types_left() { return handle_types_left_; } @@ -114,11 +114,11 @@ MutableSpan<float3> BezierSpline::handle_positions_left(const bool write_only) return handle_positions_left_; } -Span<BezierSpline::HandleType> BezierSpline::handle_types_right() const +Span<int8_t> BezierSpline::handle_types_right() const { return handle_types_right_; } -MutableSpan<BezierSpline::HandleType> BezierSpline::handle_types_right() +MutableSpan<int8_t> BezierSpline::handle_types_right() { return handle_types_right_; } @@ -187,7 +187,7 @@ void BezierSpline::ensure_auto_handles() const for (const int i : IndexRange(this->size())) { using namespace blender; - if (ELEM(HandleType::Auto, handle_types_left_[i], handle_types_right_[i])) { + if (ELEM(BEZIER_HANDLE_AUTO, handle_types_left_[i], handle_types_right_[i])) { const float3 prev_diff = positions_[i] - previous_position(positions_, is_cyclic_, i); const float3 next_diff = next_position(positions_, is_cyclic_, i) - positions_[i]; float prev_len = math::length(prev_diff); @@ -203,23 +203,23 @@ void BezierSpline::ensure_auto_handles() const /* This magic number is unfortunate, but comes from elsewhere in Blender. */ const float len = math::length(dir) * 2.5614f; if (len != 0.0f) { - if (handle_types_left_[i] == HandleType::Auto) { + if (handle_types_left_[i] == BEZIER_HANDLE_AUTO) { const float prev_len_clamped = std::min(prev_len, next_len * 5.0f); handle_positions_left_[i] = positions_[i] + dir * -(prev_len_clamped / len); } - if (handle_types_right_[i] == HandleType::Auto) { + if (handle_types_right_[i] == BEZIER_HANDLE_AUTO) { const float next_len_clamped = std::min(next_len, prev_len * 5.0f); handle_positions_right_[i] = positions_[i] + dir * (next_len_clamped / len); } } } - if (handle_types_left_[i] == HandleType::Vector) { + if (handle_types_left_[i] == BEZIER_HANDLE_VECTOR) { const float3 prev = previous_position(positions_, is_cyclic_, i); handle_positions_left_[i] = math::interpolate(positions_[i], prev, 1.0f / 3.0f); } - if (handle_types_right_[i] == HandleType::Vector) { + if (handle_types_right_[i] == BEZIER_HANDLE_VECTOR) { const float3 next = next_position(positions_, is_cyclic_, i); handle_positions_right_[i] = math::interpolate(positions_[i], next, 1.0f / 3.0f); } @@ -257,8 +257,8 @@ void BezierSpline::transform(const blender::float4x4 &matrix) } static void set_handle_position(const float3 &position, - const BezierSpline::HandleType type, - const BezierSpline::HandleType type_other, + const HandleType type, + const HandleType type_other, const float3 &new_value, float3 &handle, float3 &handle_other) @@ -266,12 +266,12 @@ static void set_handle_position(const float3 &position, using namespace blender::math; /* Don't bother when the handle positions are calculated automatically anyway. */ - if (ELEM(type, BezierSpline::HandleType::Auto, BezierSpline::HandleType::Vector)) { + if (ELEM(type, BEZIER_HANDLE_AUTO, BEZIER_HANDLE_VECTOR)) { return; } handle = new_value; - if (type_other == BezierSpline::HandleType::Align) { + if (type_other == BEZIER_HANDLE_ALIGN) { /* Keep track of the old length of the opposite handle. */ const float length = distance(handle_other, position); /* Set the other handle to directly opposite from the current handle. */ @@ -283,8 +283,8 @@ static void set_handle_position(const float3 &position, void BezierSpline::set_handle_position_right(const int index, const blender::float3 &value) { set_handle_position(positions_[index], - handle_types_right_[index], - handle_types_left_[index], + static_cast<HandleType>(handle_types_right_[index]), + static_cast<HandleType>(handle_types_left_[index]), value, handle_positions_right_[index], handle_positions_left_[index]); @@ -293,8 +293,8 @@ void BezierSpline::set_handle_position_right(const int index, const blender::flo void BezierSpline::set_handle_position_left(const int index, const blender::float3 &value) { set_handle_position(positions_[index], - handle_types_left_[index], - handle_types_right_[index], + static_cast<HandleType>(handle_types_right_[index]), + static_cast<HandleType>(handle_types_left_[index]), value, handle_positions_left_[index], handle_positions_right_[index]); @@ -302,8 +302,8 @@ void BezierSpline::set_handle_position_left(const int index, const blender::floa bool BezierSpline::point_is_sharp(const int index) const { - return ELEM(handle_types_left_[index], HandleType::Vector, HandleType::Free) || - ELEM(handle_types_right_[index], HandleType::Vector, HandleType::Free); + return ELEM(handle_types_left_[index], BEZIER_HANDLE_VECTOR, BEZIER_HANDLE_FREE) || + ELEM(handle_types_right_[index], BEZIER_HANDLE_VECTOR, BEZIER_HANDLE_FREE); } bool BezierSpline::segment_is_vector(const int index) const @@ -313,15 +313,15 @@ bool BezierSpline::segment_is_vector(const int index) const if (index == this->size() - 1) { if (is_cyclic_) { - return handle_types_right_.last() == HandleType::Vector && - handle_types_left_.first() == HandleType::Vector; + return handle_types_right_.last() == BEZIER_HANDLE_VECTOR && + handle_types_left_.first() == BEZIER_HANDLE_VECTOR; } /* There is actually no segment in this case, but it's nice to avoid * having a special case for the last segment in calling code. */ return true; } - return handle_types_right_[index] == HandleType::Vector && - handle_types_left_[index + 1] == HandleType::Vector; + return handle_types_right_[index] == BEZIER_HANDLE_VECTOR && + handle_types_left_[index + 1] == BEZIER_HANDLE_VECTOR; } void BezierSpline::mark_cache_invalid() diff --git a/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_curve_select_by_handle_type.cc b/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_curve_select_by_handle_type.cc index f0a201c5adf..091726bdf84 100644 --- a/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_curve_select_by_handle_type.cc +++ b/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_curve_select_by_handle_type.cc @@ -33,24 +33,24 @@ static void node_init(bNodeTree *UNUSED(tree), bNode *node) node->storage = data; } -static BezierSpline::HandleType handle_type_from_input_type(const GeometryNodeCurveHandleType type) +static HandleType handle_type_from_input_type(const GeometryNodeCurveHandleType type) { switch (type) { case GEO_NODE_CURVE_HANDLE_AUTO: - return BezierSpline::HandleType::Auto; + return BEZIER_HANDLE_AUTO; case GEO_NODE_CURVE_HANDLE_ALIGN: - return BezierSpline::HandleType::Align; + return BEZIER_HANDLE_ALIGN; case GEO_NODE_CURVE_HANDLE_FREE: - return BezierSpline::HandleType::Free; + return BEZIER_HANDLE_FREE; case GEO_NODE_CURVE_HANDLE_VECTOR: - return BezierSpline::HandleType::Vector; + return BEZIER_HANDLE_VECTOR; } BLI_assert_unreachable(); - return BezierSpline::HandleType::Auto; + return BEZIER_HANDLE_AUTO; } static void select_curve_by_handle_type(const CurveEval &curve, - const BezierSpline::HandleType type, + const HandleType type, const GeometryNodeCurveHandleMode mode, const MutableSpan<bool> r_selection) { @@ -61,8 +61,8 @@ static void select_curve_by_handle_type(const CurveEval &curve, const Spline &spline = *splines[i_spline]; if (spline.type() == Spline::Type::Bezier) { const BezierSpline &bezier_spline = static_cast<const BezierSpline &>(spline); - Span<BezierSpline::HandleType> types_left = bezier_spline.handle_types_left(); - Span<BezierSpline::HandleType> types_right = bezier_spline.handle_types_right(); + Span<int8_t> types_left = bezier_spline.handle_types_left(); + Span<int8_t> types_right = bezier_spline.handle_types_right(); for (const int i_point : IndexRange(bezier_spline.size())) { r_selection[offsets[i_spline] + i_point] = (mode & GEO_NODE_CURVE_HANDLE_LEFT && types_left[i_point] == type) || @@ -81,7 +81,7 @@ static void node_geo_exec(GeoNodeExecParams params) { const NodeGeometryCurveSelectHandles *storage = (const NodeGeometryCurveSelectHandles *)params.node().storage; - const BezierSpline::HandleType handle_type = handle_type_from_input_type( + const HandleType handle_type = handle_type_from_input_type( (GeometryNodeCurveHandleType)storage->handle_type); const GeometryNodeCurveHandleMode mode = (GeometryNodeCurveHandleMode)storage->mode; diff --git a/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_curve_set_handles.cc b/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_curve_set_handles.cc index b574b2e3cff..92dbd6afcaa 100644 --- a/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_curve_set_handles.cc +++ b/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_curve_set_handles.cc @@ -31,20 +31,20 @@ static void node_init(bNodeTree *UNUSED(tree), bNode *node) node->storage = data; } -static BezierSpline::HandleType handle_type_from_input_type(GeometryNodeCurveHandleType type) +static HandleType handle_type_from_input_type(GeometryNodeCurveHandleType type) { switch (type) { case GEO_NODE_CURVE_HANDLE_AUTO: - return BezierSpline::HandleType::Auto; + return BEZIER_HANDLE_AUTO; case GEO_NODE_CURVE_HANDLE_ALIGN: - return BezierSpline::HandleType::Align; + return BEZIER_HANDLE_ALIGN; case GEO_NODE_CURVE_HANDLE_FREE: - return BezierSpline::HandleType::Free; + return BEZIER_HANDLE_FREE; case GEO_NODE_CURVE_HANDLE_VECTOR: - return BezierSpline::HandleType::Vector; + return BEZIER_HANDLE_VECTOR; } BLI_assert_unreachable(); - return BezierSpline::HandleType::Auto; + return BEZIER_HANDLE_AUTO; } static void node_geo_exec(GeoNodeExecParams params) @@ -70,7 +70,7 @@ static void node_geo_exec(GeoNodeExecParams params) VArray<bool> selection = curve_component.attribute_get_for_read( selection_name, ATTR_DOMAIN_POINT, true); - const BezierSpline::HandleType new_handle_type = handle_type_from_input_type(type); + const HandleType new_handle_type = handle_type_from_input_type(type); int point_index = 0; bool has_bezier_spline = false; for (SplinePtr &spline : splines) { @@ -80,7 +80,7 @@ static void node_geo_exec(GeoNodeExecParams params) } BezierSpline &bezier_spline = static_cast<BezierSpline &>(*spline); - if (ELEM(new_handle_type, BezierSpline::HandleType::Free, BezierSpline::HandleType::Align)) { + if (ELEM(new_handle_type, BEZIER_HANDLE_FREE, BEZIER_HANDLE_ALIGN)) { /* In this case the automatically calculated handle types need to be "baked", because * they're possibly changing from a type that is calculated automatically to a type that * is positioned manually. */ diff --git a/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_curve_spline_type.cc b/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_curve_spline_type.cc index b8696e1eb52..e0ce5ae1a97 100644 --- a/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_curve_spline_type.cc +++ b/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_curve_spline_type.cc @@ -148,8 +148,8 @@ static SplinePtr poly_to_bezier(const Spline &input) output->positions().copy_from(input.positions()); output->radii().copy_from(input.radii()); output->tilts().copy_from(input.tilts()); - output->handle_types_left().fill(BezierSpline::HandleType::Vector); - output->handle_types_right().fill(BezierSpline::HandleType::Vector); + output->handle_types_left().fill(BEZIER_HANDLE_VECTOR); + output->handle_types_right().fill(BEZIER_HANDLE_VECTOR); output->set_resolution(12); Spline::copy_base_settings(input, *output); output->attributes = input.attributes; @@ -166,8 +166,8 @@ static SplinePtr nurbs_to_bezier(const Spline &input) scale_input_assign<float3>(input.positions(), 3, 2, output->handle_positions_right()); scale_input_assign<float>(input.radii(), 3, 2, output->radii()); scale_input_assign<float>(input.tilts(), 3, 2, output->tilts()); - output->handle_types_left().fill(BezierSpline::HandleType::Align); - output->handle_types_right().fill(BezierSpline::HandleType::Align); + output->handle_types_left().fill(BEZIER_HANDLE_ALIGN); + output->handle_types_right().fill(BEZIER_HANDLE_ALIGN); output->set_resolution(nurbs_spline.resolution()); Spline::copy_base_settings(input, *output); output->attributes.reallocate(output->size()); diff --git a/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_curve_subdivide.cc b/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_curve_subdivide.cc index 8ae9df78936..38930d5db85 100644 --- a/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_curve_subdivide.cc +++ b/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_curve_subdivide.cc @@ -111,8 +111,8 @@ static void subdivide_bezier_segment(const BezierSpline &src, MutableSpan<float3> dst_positions, MutableSpan<float3> dst_handles_left, MutableSpan<float3> dst_handles_right, - MutableSpan<BezierSpline::HandleType> dst_type_left, - MutableSpan<BezierSpline::HandleType> dst_type_right) + MutableSpan<int8_t> dst_type_left, + MutableSpan<int8_t> dst_type_right) { const bool is_last_cyclic_segment = index == (src.size() - 1); const int next_index = is_last_cyclic_segment ? 0 : index + 1; @@ -122,10 +122,10 @@ static void subdivide_bezier_segment(const BezierSpline &src, if (src.segment_is_vector(index)) { if (is_last_cyclic_segment) { - dst_type_left.first() = BezierSpline::HandleType::Vector; + dst_type_left.first() = BEZIER_HANDLE_VECTOR; } - dst_type_left.slice(offset + 1, result_size).fill(BezierSpline::HandleType::Vector); - dst_type_right.slice(offset, result_size).fill(BezierSpline::HandleType::Vector); + dst_type_left.slice(offset + 1, result_size).fill(BEZIER_HANDLE_VECTOR); + dst_type_right.slice(offset, result_size).fill(BEZIER_HANDLE_VECTOR); const float factor_delta = 1.0f / result_size; for (const int cut : IndexRange(result_size)) { @@ -136,10 +136,10 @@ static void subdivide_bezier_segment(const BezierSpline &src, } else { if (is_last_cyclic_segment) { - dst_type_left.first() = BezierSpline::HandleType::Free; + dst_type_left.first() = BEZIER_HANDLE_FREE; } - dst_type_left.slice(offset + 1, result_size).fill(BezierSpline::HandleType::Free); - dst_type_right.slice(offset, result_size).fill(BezierSpline::HandleType::Free); + dst_type_left.slice(offset + 1, result_size).fill(BEZIER_HANDLE_FREE); + dst_type_right.slice(offset, result_size).fill(BEZIER_HANDLE_FREE); const int i_segment_last = is_last_cyclic_segment ? 0 : offset + result_size; @@ -187,8 +187,8 @@ static void subdivide_bezier_spline(const BezierSpline &src, MutableSpan<float3> dst_positions = dst.positions(); MutableSpan<float3> dst_handles_left = dst.handle_positions_left(); MutableSpan<float3> dst_handles_right = dst.handle_positions_right(); - MutableSpan<BezierSpline::HandleType> dst_type_left = dst.handle_types_left(); - MutableSpan<BezierSpline::HandleType> dst_type_right = dst.handle_types_right(); + MutableSpan<int8_t> dst_type_left = dst.handle_types_left(); + MutableSpan<int8_t> dst_type_right = dst.handle_types_right(); threading::parallel_for(IndexRange(src.size() - 1), 512, [&](IndexRange range) { for (const int i : range) { 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 94425ab48f4..149b387b179 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_fillet.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_fillet.cc @@ -394,9 +394,9 @@ static void update_bezier_positions(const FilletData &fd, dst_spline.handle_positions_left()[end_i] = dst_spline.positions()[end_i] - handle_length * next_dir; dst_spline.handle_types_right()[i_dst] = dst_spline.handle_types_left()[end_i] = - BezierSpline::HandleType::Align; + BEZIER_HANDLE_ALIGN; dst_spline.handle_types_left()[i_dst] = dst_spline.handle_types_right()[end_i] = - BezierSpline::HandleType::Vector; + BEZIER_HANDLE_VECTOR; dst_spline.mark_cache_invalid(); /* Calculate the center of the radius to be formed. */ @@ -406,8 +406,8 @@ static void update_bezier_positions(const FilletData &fd, float radius; radius_vec = math::normalize_and_get_length(radius_vec, radius); - dst_spline.handle_types_right().slice(1, count - 2).fill(BezierSpline::HandleType::Align); - dst_spline.handle_types_left().slice(1, count - 2).fill(BezierSpline::HandleType::Align); + dst_spline.handle_types_right().slice(1, count - 2).fill(BEZIER_HANDLE_ALIGN); + dst_spline.handle_types_left().slice(1, count - 2).fill(BEZIER_HANDLE_ALIGN); /* For each of the vertices in between the end points. */ for (const int j : IndexRange(1, count - 2)) { @@ -516,8 +516,8 @@ static SplinePtr fillet_spline(const Spline &spline, const BezierSpline &src_spline = static_cast<const BezierSpline &>(spline); BezierSpline &dst_spline = static_cast<BezierSpline &>(*dst_spline_ptr); if (fillet_param.mode == GEO_NODE_CURVE_FILLET_POLY) { - dst_spline.handle_types_left().fill(BezierSpline::HandleType::Vector); - dst_spline.handle_types_right().fill(BezierSpline::HandleType::Vector); + dst_spline.handle_types_left().fill(BEZIER_HANDLE_VECTOR); + dst_spline.handle_types_right().fill(BEZIER_HANDLE_VECTOR); update_poly_positions(fd, dst_spline, src_spline, point_counts); } else { diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_handle_type_selection.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_handle_type_selection.cc index 26a8ad2d988..a7ef06a48b0 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_handle_type_selection.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_handle_type_selection.cc @@ -31,24 +31,24 @@ static void node_init(bNodeTree *UNUSED(tree), bNode *node) node->storage = data; } -static BezierSpline::HandleType handle_type_from_input_type(const GeometryNodeCurveHandleType type) +static HandleType handle_type_from_input_type(const GeometryNodeCurveHandleType type) { switch (type) { case GEO_NODE_CURVE_HANDLE_AUTO: - return BezierSpline::HandleType::Auto; + return BEZIER_HANDLE_AUTO; case GEO_NODE_CURVE_HANDLE_ALIGN: - return BezierSpline::HandleType::Align; + return BEZIER_HANDLE_ALIGN; case GEO_NODE_CURVE_HANDLE_FREE: - return BezierSpline::HandleType::Free; + return BEZIER_HANDLE_FREE; case GEO_NODE_CURVE_HANDLE_VECTOR: - return BezierSpline::HandleType::Vector; + return BEZIER_HANDLE_VECTOR; } BLI_assert_unreachable(); - return BezierSpline::HandleType::Auto; + return BEZIER_HANDLE_AUTO; } static void select_by_handle_type(const CurveEval &curve, - const BezierSpline::HandleType type, + const HandleType type, const GeometryNodeCurveHandleMode mode, const MutableSpan<bool> r_selection) { @@ -71,11 +71,11 @@ static void select_by_handle_type(const CurveEval &curve, } class HandleTypeFieldInput final : public GeometryFieldInput { - BezierSpline::HandleType type_; + HandleType type_; GeometryNodeCurveHandleMode mode_; public: - HandleTypeFieldInput(BezierSpline::HandleType type, GeometryNodeCurveHandleMode mode) + HandleTypeFieldInput(HandleType type, GeometryNodeCurveHandleMode mode) : GeometryFieldInput(CPPType::get<bool>(), "Handle Type Selection node"), type_(type), mode_(mode) @@ -124,7 +124,7 @@ class HandleTypeFieldInput final : public GeometryFieldInput { static void node_geo_exec(GeoNodeExecParams params) { const NodeGeometryCurveSelectHandles &storage = node_storage(params.node()); - const BezierSpline::HandleType handle_type = handle_type_from_input_type( + const HandleType handle_type = handle_type_from_input_type( (GeometryNodeCurveHandleType)storage.handle_type); const GeometryNodeCurveHandleMode mode = (GeometryNodeCurveHandleMode)storage.mode; diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_bezier_segment.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_bezier_segment.cc index c6b9018f0db..69f43c81ea3 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_bezier_segment.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_bezier_segment.cc @@ -69,8 +69,8 @@ static std::unique_ptr<CurveEval> create_bezier_segment_curve( spline->resize(2); MutableSpan<float3> positions = spline->positions(); - spline->handle_types_left().fill(BezierSpline::HandleType::Align); - spline->handle_types_right().fill(BezierSpline::HandleType::Align); + spline->handle_types_left().fill(BEZIER_HANDLE_ALIGN); + spline->handle_types_right().fill(BEZIER_HANDLE_ALIGN); spline->radii().fill(1.0f); spline->tilts().fill(0.0f); diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_set_handles.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_set_handles.cc index 3d7b2fddf72..fdc717bb7ee 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_set_handles.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_set_handles.cc @@ -33,20 +33,20 @@ static void node_init(bNodeTree *UNUSED(tree), bNode *node) node->storage = data; } -static BezierSpline::HandleType handle_type_from_input_type(GeometryNodeCurveHandleType type) +static HandleType handle_type_from_input_type(GeometryNodeCurveHandleType type) { switch (type) { case GEO_NODE_CURVE_HANDLE_AUTO: - return BezierSpline::HandleType::Auto; + return BEZIER_HANDLE_AUTO; case GEO_NODE_CURVE_HANDLE_ALIGN: - return BezierSpline::HandleType::Align; + return BEZIER_HANDLE_ALIGN; case GEO_NODE_CURVE_HANDLE_FREE: - return BezierSpline::HandleType::Free; + return BEZIER_HANDLE_FREE; case GEO_NODE_CURVE_HANDLE_VECTOR: - return BezierSpline::HandleType::Vector; + return BEZIER_HANDLE_VECTOR; } BLI_assert_unreachable(); - return BezierSpline::HandleType::Auto; + return BEZIER_HANDLE_AUTO; } static void node_geo_exec(GeoNodeExecParams params) @@ -77,7 +77,7 @@ static void node_geo_exec(GeoNodeExecParams params) selection_evaluator.evaluate(); const VArray<bool> &selection = selection_evaluator.get_evaluated<bool>(0); - const BezierSpline::HandleType new_handle_type = handle_type_from_input_type(type); + const HandleType new_handle_type = handle_type_from_input_type(type); int point_index = 0; for (SplinePtr &spline : splines) { @@ -88,7 +88,7 @@ static void node_geo_exec(GeoNodeExecParams params) has_bezier_spline = true; BezierSpline &bezier_spline = static_cast<BezierSpline &>(*spline); - if (ELEM(new_handle_type, BezierSpline::HandleType::Free, BezierSpline::HandleType::Align)) { + if (ELEM(new_handle_type, BEZIER_HANDLE_FREE, BEZIER_HANDLE_ALIGN)) { /* In this case the automatically calculated handle types need to be "baked", because * they're possibly changing from a type that is calculated automatically to a type that * is positioned manually. */ diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_spline_type.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_spline_type.cc index 4e4cabd3c33..aec2e106315 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_spline_type.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_spline_type.cc @@ -259,8 +259,8 @@ static SplinePtr poly_to_bezier(const Spline &input) output->positions().copy_from(input.positions()); output->radii().copy_from(input.radii()); output->tilts().copy_from(input.tilts()); - output->handle_types_left().fill(BezierSpline::HandleType::Vector); - output->handle_types_right().fill(BezierSpline::HandleType::Vector); + output->handle_types_left().fill(BEZIER_HANDLE_VECTOR); + output->handle_types_right().fill(BEZIER_HANDLE_VECTOR); output->set_resolution(12); Spline::copy_base_settings(input, *output); output->attributes = input.attributes; @@ -298,8 +298,8 @@ static SplinePtr nurbs_to_bezier(const Spline &input) nurbs_to_bezier_assign(nurbs_spline.tilts(), output->tilts(), knots_mode); scale_input_assign(handle_positions.as_span(), 2, 0, output->handle_positions_left()); scale_input_assign(handle_positions.as_span(), 2, 1, output->handle_positions_right()); - output->handle_types_left().fill(BezierSpline::HandleType::Align); - output->handle_types_right().fill(BezierSpline::HandleType::Align); + output->handle_types_left().fill(BEZIER_HANDLE_ALIGN); + output->handle_types_right().fill(BEZIER_HANDLE_ALIGN); output->set_resolution(nurbs_spline.resolution()); Spline::copy_base_settings(nurbs_spline, *output); output->attributes.reallocate(output->size()); diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_subdivide.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_subdivide.cc index 9daf3ff0594..79576854548 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_subdivide.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_subdivide.cc @@ -93,8 +93,8 @@ static void subdivide_bezier_segment(const BezierSpline &src, MutableSpan<float3> dst_positions, MutableSpan<float3> dst_handles_left, MutableSpan<float3> dst_handles_right, - MutableSpan<BezierSpline::HandleType> dst_type_left, - MutableSpan<BezierSpline::HandleType> dst_type_right) + MutableSpan<int8_t> dst_type_left, + MutableSpan<int8_t> dst_type_right) { const bool is_last_cyclic_segment = index == (src.size() - 1); const int next_index = is_last_cyclic_segment ? 0 : index + 1; @@ -104,10 +104,10 @@ static void subdivide_bezier_segment(const BezierSpline &src, if (src.segment_is_vector(index)) { if (is_last_cyclic_segment) { - dst_type_left.first() = BezierSpline::HandleType::Vector; + dst_type_left.first() = BEZIER_HANDLE_VECTOR; } - dst_type_left.slice(offset + 1, result_size).fill(BezierSpline::HandleType::Vector); - dst_type_right.slice(offset, result_size).fill(BezierSpline::HandleType::Vector); + dst_type_left.slice(offset + 1, result_size).fill(BEZIER_HANDLE_VECTOR); + dst_type_right.slice(offset, result_size).fill(BEZIER_HANDLE_VECTOR); const float factor_delta = 1.0f / result_size; for (const int cut : IndexRange(result_size)) { @@ -118,10 +118,10 @@ static void subdivide_bezier_segment(const BezierSpline &src, } else { if (is_last_cyclic_segment) { - dst_type_left.first() = BezierSpline::HandleType::Free; + dst_type_left.first() = BEZIER_HANDLE_FREE; } - dst_type_left.slice(offset + 1, result_size).fill(BezierSpline::HandleType::Free); - dst_type_right.slice(offset, result_size).fill(BezierSpline::HandleType::Free); + dst_type_left.slice(offset + 1, result_size).fill(BEZIER_HANDLE_FREE); + dst_type_right.slice(offset, result_size).fill(BEZIER_HANDLE_FREE); const int i_segment_last = is_last_cyclic_segment ? 0 : offset + result_size; @@ -169,8 +169,8 @@ static void subdivide_bezier_spline(const BezierSpline &src, MutableSpan<float3> dst_positions = dst.positions(); MutableSpan<float3> dst_handles_left = dst.handle_positions_left(); MutableSpan<float3> dst_handles_right = dst.handle_positions_right(); - MutableSpan<BezierSpline::HandleType> dst_type_left = dst.handle_types_left(); - MutableSpan<BezierSpline::HandleType> dst_type_right = dst.handle_types_right(); + MutableSpan<int8_t> dst_type_left = dst.handle_types_left(); + MutableSpan<int8_t> dst_type_right = dst.handle_types_right(); threading::parallel_for(IndexRange(src.size() - 1), 512, [&](IndexRange range) { for (const int i : range) { diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc index abc5b1649c7..e6d40a8b6f7 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc @@ -400,8 +400,8 @@ static void to_single_point_bezier(Spline &spline, const Spline::LookupResult &l const BezierSpline::InsertResult new_point = bezier.calculate_segment_insertion( trim.left_index, trim.right_index, trim.factor); bezier.positions().first() = new_point.position; - bezier.handle_types_left().first() = BezierSpline::HandleType::Free; - bezier.handle_types_right().first() = BezierSpline::HandleType::Free; + bezier.handle_types_left().first() = BEZIER_HANDLE_FREE; + bezier.handle_types_right().first() = BEZIER_HANDLE_FREE; bezier.handle_positions_left().first() = new_point.left_handle; bezier.handle_positions_right().first() = new_point.right_handle; diff --git a/source/blender/nodes/geometry/nodes/node_geo_set_curve_handles.cc b/source/blender/nodes/geometry/nodes/node_geo_set_curve_handles.cc index fb648baad08..4223356397e 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_set_curve_handles.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_set_curve_handles.cc @@ -67,23 +67,23 @@ static void set_position_in_component(const GeometryNodeCurveHandleMode mode, for (int i : bezier.positions().index_range()) { if (current_mask < selection.size() && selection[current_mask] == current_point) { if (mode & GEO_NODE_CURVE_HANDLE_LEFT) { - if (bezier.handle_types_left()[i] == BezierSpline::HandleType::Vector) { + if (bezier.handle_types_left()[i] == BEZIER_HANDLE_VECTOR) { bezier.ensure_auto_handles(); - bezier.handle_types_left()[i] = BezierSpline::HandleType::Free; + bezier.handle_types_left()[i] = BEZIER_HANDLE_FREE; } - else if (bezier.handle_types_left()[i] == BezierSpline::HandleType::Auto) { + else if (bezier.handle_types_left()[i] == BEZIER_HANDLE_AUTO) { bezier.ensure_auto_handles(); - bezier.handle_types_left()[i] = BezierSpline::HandleType::Align; + bezier.handle_types_left()[i] = BEZIER_HANDLE_ALIGN; } } else { - if (bezier.handle_types_right()[i] == BezierSpline::HandleType::Vector) { + if (bezier.handle_types_right()[i] == BEZIER_HANDLE_VECTOR) { bezier.ensure_auto_handles(); - bezier.handle_types_right()[i] = BezierSpline::HandleType::Free; + bezier.handle_types_right()[i] = BEZIER_HANDLE_FREE; } - else if (bezier.handle_types_right()[i] == BezierSpline::HandleType::Auto) { + else if (bezier.handle_types_right()[i] == BEZIER_HANDLE_AUTO) { bezier.ensure_auto_handles(); - bezier.handle_types_right()[i] = BezierSpline::HandleType::Align; + bezier.handle_types_right()[i] = BEZIER_HANDLE_ALIGN; } } current_mask++; |