From ee363ee7b3a26e3236f2107b8a8324877404db04 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Fri, 13 May 2022 18:44:09 +0200 Subject: Cleanup: Use standard variable names for curves --- source/blender/blenkernel/intern/curve_eval.cc | 52 +++++++++++----------- source/blender/blenkernel/intern/curves.cc | 25 ++++++----- .../blenkernel/intern/geometry_component_curves.cc | 6 +-- 3 files changed, 42 insertions(+), 41 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/curve_eval.cc b/source/blender/blenkernel/intern/curve_eval.cc index c507e7934a8..dd2bd982506 100644 --- a/source/blender/blenkernel/intern/curve_eval.cc +++ b/source/blender/blenkernel/intern/curve_eval.cc @@ -373,15 +373,15 @@ static void copy_attributes_between_components(const GeometryComponent &src_comp }); } -std::unique_ptr curves_to_curve_eval(const Curves &curves) +std::unique_ptr curves_to_curve_eval(const Curves &curves_id) { CurveComponent src_component; - src_component.replace(&const_cast(curves), GeometryOwnershipType::ReadOnly); - const blender::bke::CurvesGeometry &geometry = blender::bke::CurvesGeometry::wrap( - curves.geometry); + src_component.replace(&const_cast(curves_id), GeometryOwnershipType::ReadOnly); + const blender::bke::CurvesGeometry &curves = blender::bke::CurvesGeometry::wrap( + curves_id.geometry); - VArray resolution = geometry.resolution(); - VArray normal_mode = geometry.normal_mode(); + VArray resolution = curves.resolution(); + VArray normal_mode = curves.normal_mode(); VArray_Span nurbs_weights{ src_component.attribute_get_for_read("nurbs_weight", ATTR_DOMAIN_POINT, 0.0f)}; @@ -396,34 +396,34 @@ std::unique_ptr curves_to_curve_eval(const Curves &curves) src_component.attribute_get_for_read("handle_type_left", ATTR_DOMAIN_POINT, 0)}; /* Create splines with the correct size and type. */ - VArray curve_types = geometry.curve_types(); + VArray curve_types = curves.curve_types(); std::unique_ptr curve_eval = std::make_unique(); for (const int curve_index : curve_types.index_range()) { - const IndexRange point_range = geometry.points_for_curve(curve_index); + const IndexRange points = curves.points_for_curve(curve_index); std::unique_ptr spline; /* #CurveEval does not support catmull rom curves, so convert those to poly splines. */ switch (std::max(1, curve_types[curve_index])) { case CURVE_TYPE_POLY: { spline = std::make_unique(); - spline->resize(point_range.size()); + spline->resize(points.size()); break; } case CURVE_TYPE_BEZIER: { std::unique_ptr bezier_spline = std::make_unique(); - bezier_spline->resize(point_range.size()); + bezier_spline->resize(points.size()); bezier_spline->set_resolution(resolution[curve_index]); - bezier_spline->handle_types_left().copy_from(handle_types_left.slice(point_range)); - bezier_spline->handle_types_right().copy_from(handle_types_right.slice(point_range)); + bezier_spline->handle_types_left().copy_from(handle_types_left.slice(points)); + bezier_spline->handle_types_right().copy_from(handle_types_right.slice(points)); spline = std::move(bezier_spline); break; } case CURVE_TYPE_NURBS: { std::unique_ptr nurb_spline = std::make_unique(); - nurb_spline->resize(point_range.size()); + nurb_spline->resize(points.size()); nurb_spline->set_resolution(resolution[curve_index]); - nurb_spline->weights().copy_from(nurbs_weights.slice(point_range)); + nurb_spline->weights().copy_from(nurbs_weights.slice(points)); nurb_spline->set_order(nurbs_orders[curve_index]); nurb_spline->knots_mode = static_cast(nurbs_knots_modes[curve_index]); @@ -463,14 +463,14 @@ std::unique_ptr curves_to_curve_eval(const Curves &curves) Curves *curve_eval_to_curves(const CurveEval &curve_eval) { - Curves *curves = blender::bke::curves_new_nomain(curve_eval.total_control_point_num(), - curve_eval.splines().size()); + Curves *curves_id = blender::bke::curves_new_nomain(curve_eval.total_control_point_num(), + curve_eval.splines().size()); CurveComponent dst_component; - dst_component.replace(curves, GeometryOwnershipType::Editable); + dst_component.replace(curves_id, GeometryOwnershipType::Editable); - blender::bke::CurvesGeometry &geometry = blender::bke::CurvesGeometry::wrap(curves->geometry); - geometry.offsets_for_write().copy_from(curve_eval.control_point_offsets()); - MutableSpan curve_types = geometry.curve_types_for_write(); + blender::bke::CurvesGeometry &curves = blender::bke::CurvesGeometry::wrap(curves_id->geometry); + curves.offsets_for_write().copy_from(curve_eval.control_point_offsets()); + MutableSpan curve_types = curves.curve_types_for_write(); OutputAttribute_Typed normal_mode = dst_component.attribute_try_get_for_output_only("normal_mode", ATTR_DOMAIN_CURVE); @@ -498,22 +498,22 @@ Curves *curve_eval_to_curves(const CurveEval &curve_eval) const Spline &spline = *curve_eval.splines()[curve_index]; curve_types[curve_index] = curve_eval.splines()[curve_index]->type(); normal_mode.as_span()[curve_index] = curve_eval.splines()[curve_index]->normal_mode; - const IndexRange point_range = geometry.points_for_curve(curve_index); + const IndexRange points = curves.points_for_curve(curve_index); switch (spline.type()) { case CURVE_TYPE_POLY: break; case CURVE_TYPE_BEZIER: { const BezierSpline &src = static_cast(spline); - handle_type_right.as_span().slice(point_range).copy_from(src.handle_types_right()); - handle_type_left.as_span().slice(point_range).copy_from(src.handle_types_left()); + handle_type_right.as_span().slice(points).copy_from(src.handle_types_right()); + handle_type_left.as_span().slice(points).copy_from(src.handle_types_left()); break; } case CURVE_TYPE_NURBS: { const NURBSpline &src = static_cast(spline); nurbs_knots_mode.as_span()[curve_index] = static_cast(src.knots_mode); nurbs_order.as_span()[curve_index] = src.order(); - nurbs_weight.as_span().slice(point_range).copy_from(src.weights()); + nurbs_weight.as_span().slice(points).copy_from(src.weights()); break; } case CURVE_TYPE_CATMULL_ROM: { @@ -523,7 +523,7 @@ Curves *curve_eval_to_curves(const CurveEval &curve_eval) } } - geometry.update_curve_types(); + curves.update_curve_types(); normal_mode.save(); nurbs_weight.save(); @@ -537,7 +537,7 @@ Curves *curve_eval_to_curves(const CurveEval &curve_eval) copy_attributes_between_components(src_component, dst_component, {}); - return curves; + return curves_id; } void CurveEval::assert_valid_point_attributes() const diff --git a/source/blender/blenkernel/intern/curves.cc b/source/blender/blenkernel/intern/curves.cc index 84ba98db54b..d38bc790978 100644 --- a/source/blender/blenkernel/intern/curves.cc +++ b/source/blender/blenkernel/intern/curves.cc @@ -247,7 +247,7 @@ void *BKE_curves_add(Main *bmain, const char *name) BoundBox *BKE_curves_boundbox_get(Object *ob) { BLI_assert(ob->type == OB_CURVES); - Curves *curves = static_cast(ob->data); + const Curves *curves_id = static_cast(ob->data); if (ob->runtime.bb != nullptr && (ob->runtime.bb->flag & BOUNDBOX_DIRTY) == 0) { return ob->runtime.bb; @@ -256,11 +256,12 @@ BoundBox *BKE_curves_boundbox_get(Object *ob) if (ob->runtime.bb == nullptr) { ob->runtime.bb = MEM_cnew(__func__); - blender::bke::CurvesGeometry &geometry = blender::bke::CurvesGeometry::wrap(curves->geometry); + const blender::bke::CurvesGeometry &curves = blender::bke::CurvesGeometry::wrap( + curves_id->geometry); float3 min(FLT_MAX); float3 max(-FLT_MAX); - if (!geometry.bounds_min_max(min, max)) { + if (!curves.bounds_min_max(min, max)) { min = float3(-1); max = float3(1); } @@ -364,19 +365,19 @@ namespace blender::bke { Curves *curves_new_nomain(const int points_num, const int curves_num) { - Curves *curves = static_cast(BKE_id_new_nomain(ID_CV, nullptr)); - CurvesGeometry &geometry = CurvesGeometry::wrap(curves->geometry); - geometry.resize(points_num, curves_num); - return curves; + Curves *curves_id = static_cast(BKE_id_new_nomain(ID_CV, nullptr)); + CurvesGeometry &curves = CurvesGeometry::wrap(curves_id->geometry); + curves.resize(points_num, curves_num); + return curves_id; } Curves *curves_new_nomain_single(const int points_num, const CurveType type) { - Curves *curves = curves_new_nomain(points_num, 1); - CurvesGeometry &geometry = CurvesGeometry::wrap(curves->geometry); - geometry.offsets_for_write().last() = points_num; - geometry.fill_curve_types(type); - return curves; + Curves *curves_id = curves_new_nomain(points_num, 1); + CurvesGeometry &curves = CurvesGeometry::wrap(curves_id->geometry); + curves.offsets_for_write().last() = points_num; + curves.fill_curve_types(type); + return curves_id; } Curves *curves_new_nomain(CurvesGeometry curves) diff --git a/source/blender/blenkernel/intern/geometry_component_curves.cc b/source/blender/blenkernel/intern/geometry_component_curves.cc index b565143d08f..d23918215ba 100644 --- a/source/blender/blenkernel/intern/geometry_component_curves.cc +++ b/source/blender/blenkernel/intern/geometry_component_curves.cc @@ -313,13 +313,13 @@ int CurveComponent::attribute_domain_num(const AttributeDomain domain) const if (curves_ == nullptr) { return 0; } - const blender::bke::CurvesGeometry &geometry = blender::bke::CurvesGeometry::wrap( + const blender::bke::CurvesGeometry &curves = blender::bke::CurvesGeometry::wrap( curves_->geometry); if (domain == ATTR_DOMAIN_POINT) { - return geometry.points_num(); + return curves.points_num(); } if (domain == ATTR_DOMAIN_CURVE) { - return geometry.curves_num(); + return curves.curves_num(); } return 0; } -- cgit v1.2.3