From 29951651489079da8d72782eb4f8b693d57896a8 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Tue, 31 Jan 2023 18:45:34 +0100 Subject: [PATCH] Cleanup: simplify wrapping CurvesGeometry in C++ --- source/blender/blenkernel/BKE_curves.hh | 22 +++++++++---------- source/blender/blenkernel/intern/attribute.cc | 2 +- .../blender/blenkernel/intern/crazyspace.cc | 4 ++-- .../blenkernel/intern/curve_legacy_convert.cc | 2 +- source/blender/blenkernel/intern/curves.cc | 17 +++++++------- .../intern/geometry_component_edit_data.cc | 2 +- .../blenkernel/intern/geometry_fields.cc | 5 ++--- .../blender/blenkernel/intern/geometry_set.cc | 2 +- .../blender/blenkernel/intern/mesh_convert.cc | 3 +-- .../engines/overlay/overlay_sculpt_curves.cc | 2 +- .../overlay/overlay_viewer_attribute.cc | 4 ++-- .../draw/intern/draw_cache_impl_curve.cc | 16 ++++++-------- .../draw/intern/draw_cache_impl_curves.cc | 17 ++++++-------- source/blender/draw/intern/draw_curves.cc | 3 +-- .../editors/curves/intern/curves_data.cc | 2 +- .../editors/curves/intern/curves_ops.cc | 18 +++++++-------- .../editors/curves/intern/curves_selection.cc | 4 ++-- .../editors/curves/intern/curves_undo.cc | 4 ++-- source/blender/editors/object/object_add.cc | 8 +++---- .../blender/editors/object/object_modifier.cc | 7 ++---- .../editors/object/object_transform.cc | 6 ++--- .../editors/sculpt_paint/curves_sculpt_add.cc | 2 +- .../sculpt_paint/curves_sculpt_brush.cc | 2 +- .../sculpt_paint/curves_sculpt_comb.cc | 2 +- .../sculpt_paint/curves_sculpt_delete.cc | 2 +- .../sculpt_paint/curves_sculpt_density.cc | 6 ++--- .../sculpt_paint/curves_sculpt_grow_shrink.cc | 2 +- .../editors/sculpt_paint/curves_sculpt_ops.cc | 8 +++---- .../sculpt_paint/curves_sculpt_pinch.cc | 2 +- .../sculpt_paint/curves_sculpt_puff.cc | 2 +- .../sculpt_paint/curves_sculpt_selection.cc | 2 +- .../curves_sculpt_selection_paint.cc | 2 +- .../sculpt_paint/curves_sculpt_slide.cc | 2 +- .../sculpt_paint/curves_sculpt_smooth.cc | 2 +- .../sculpt_paint/curves_sculpt_snake_hook.cc | 2 +- .../transform/transform_convert_curves.cc | 6 ++--- .../geometry/intern/realize_instances.cc | 6 ++--- source/blender/makesdna/DNA_curves_types.h | 6 +++++ .../geometry/nodes/node_geo_convex_hull.cc | 4 ++-- .../geometry/nodes/node_geo_curve_fill.cc | 2 +- .../geometry/nodes/node_geo_curve_fillet.cc | 2 +- .../geometry/nodes/node_geo_curve_length.cc | 2 +- .../nodes/node_geo_curve_primitive_arc.cc | 4 ++-- ...node_geo_curve_primitive_bezier_segment.cc | 2 +- .../nodes/node_geo_curve_primitive_circle.cc | 4 ++-- .../nodes/node_geo_curve_primitive_line.cc | 4 ++-- ...de_geo_curve_primitive_quadratic_bezier.cc | 2 +- .../node_geo_curve_primitive_quadrilateral.cc | 2 +- .../nodes/node_geo_curve_primitive_spiral.cc | 2 +- .../nodes/node_geo_curve_primitive_star.cc | 2 +- .../geometry/nodes/node_geo_curve_resample.cc | 9 +++----- .../geometry/nodes/node_geo_curve_reverse.cc | 4 ++-- .../geometry/nodes/node_geo_curve_sample.cc | 6 ++--- .../nodes/node_geo_curve_set_handle_type.cc | 2 +- .../nodes/node_geo_curve_spline_type.cc | 4 ++-- .../nodes/node_geo_curve_subdivide.cc | 2 +- .../geometry/nodes/node_geo_curve_to_mesh.cc | 9 +++----- .../nodes/node_geo_curve_to_points.cc | 9 +++----- .../geometry/nodes/node_geo_curve_trim.cc | 2 +- .../node_geo_deform_curves_on_surface.cc | 4 ++-- .../nodes/node_geo_delete_geometry.cc | 4 ++-- .../nodes/node_geo_duplicate_elements.cc | 8 +++---- .../nodes/node_geo_interpolate_curves.cc | 7 +++--- .../nodes/node_geo_set_curve_handles.cc | 2 +- .../nodes/node_geo_set_curve_normal.cc | 2 +- .../nodes/node_geo_set_curve_radius.cc | 2 +- .../geometry/nodes/node_geo_set_curve_tilt.cc | 2 +- .../geometry/nodes/node_geo_set_position.cc | 2 +- .../nodes/node_geo_set_spline_cyclic.cc | 2 +- .../nodes/node_geo_set_spline_resolution.cc | 2 +- .../nodes/node_geo_string_to_curves.cc | 2 +- .../nodes/node_geo_transform_geometry.cc | 4 ++-- 72 files changed, 154 insertions(+), 174 deletions(-) diff --git a/source/blender/blenkernel/BKE_curves.hh b/source/blender/blenkernel/BKE_curves.hh index e22348106db..8e4a83a1135 100644 --- a/source/blender/blenkernel/BKE_curves.hh +++ b/source/blender/blenkernel/BKE_curves.hh @@ -128,17 +128,6 @@ class CurvesGeometry : public ::CurvesGeometry { CurvesGeometry &operator=(CurvesGeometry &&other); ~CurvesGeometry(); - static CurvesGeometry &wrap(::CurvesGeometry &dna_struct) - { - CurvesGeometry *geometry = reinterpret_cast(&dna_struct); - return *geometry; - } - static const CurvesGeometry &wrap(const ::CurvesGeometry &dna_struct) - { - const CurvesGeometry *geometry = reinterpret_cast(&dna_struct); - return *geometry; - } - /* -------------------------------------------------------------------- * Accessors. */ @@ -408,6 +397,8 @@ class CurvesGeometry : public ::CurvesGeometry { } }; +static_assert(sizeof(blender::bke::CurvesGeometry) == sizeof(::CurvesGeometry)); + /** * Used to propagate deformation data through modifier evaluation so that sculpt tools can work on * evaluated data. @@ -966,3 +957,12 @@ struct CurvesSurfaceTransforms { }; } // namespace blender::bke + +inline blender::bke::CurvesGeometry &CurvesGeometry::wrap() +{ + return *reinterpret_cast(this); +} +inline const blender::bke::CurvesGeometry &CurvesGeometry::wrap() const +{ + return *reinterpret_cast(this); +} diff --git a/source/blender/blenkernel/intern/attribute.cc b/source/blender/blenkernel/intern/attribute.cc index 4b090e710f5..32d12e1af17 100644 --- a/source/blender/blenkernel/intern/attribute.cc +++ b/source/blender/blenkernel/intern/attribute.cc @@ -112,7 +112,7 @@ static std::optional get_attribute_acces } case ID_CV: { Curves &curves_id = reinterpret_cast(id); - CurvesGeometry &curves = CurvesGeometry::wrap(curves_id.geometry); + CurvesGeometry &curves = curves_id.geometry.wrap(); return curves.attributes_for_write(); } default: { diff --git a/source/blender/blenkernel/intern/crazyspace.cc b/source/blender/blenkernel/intern/crazyspace.cc index dd58f137abe..906d4c82623 100644 --- a/source/blender/blenkernel/intern/crazyspace.cc +++ b/source/blender/blenkernel/intern/crazyspace.cc @@ -601,7 +601,7 @@ GeometryDeformation get_evaluated_curves_deformation(const Depsgraph &depsgraph, { BLI_assert(ob_orig.type == OB_CURVES); const Curves &curves_id_orig = *static_cast(ob_orig.data); - const CurvesGeometry &curves_orig = CurvesGeometry::wrap(curves_id_orig.geometry); + const CurvesGeometry &curves_orig = curves_id_orig.geometry.wrap(); const int points_num = curves_orig.points_num(); GeometryDeformation deformation; @@ -643,7 +643,7 @@ GeometryDeformation get_evaluated_curves_deformation(const Depsgraph &depsgraph, if (curves_component_eval != nullptr) { const Curves *curves_id_eval = curves_component_eval->get_for_read(); if (curves_id_eval != nullptr) { - const CurvesGeometry &curves_eval = CurvesGeometry::wrap(curves_id_eval->geometry); + const CurvesGeometry &curves_eval = curves_id_eval->geometry.wrap(); if (curves_eval.points_num() == points_num) { deformation.positions = curves_eval.positions(); } diff --git a/source/blender/blenkernel/intern/curve_legacy_convert.cc b/source/blender/blenkernel/intern/curve_legacy_convert.cc index f82d931114e..c8ae56220c3 100644 --- a/source/blender/blenkernel/intern/curve_legacy_convert.cc +++ b/source/blender/blenkernel/intern/curve_legacy_convert.cc @@ -82,7 +82,7 @@ Curves *curve_legacy_to_curves(const Curve &curve_legacy, const ListBase &nurbs_ const Vector src_curves(nurbs_list); Curves *curves_id = curves_new_nomain(0, src_curves.size()); - CurvesGeometry &curves = CurvesGeometry::wrap(curves_id->geometry); + CurvesGeometry &curves = curves_id->geometry.wrap(); MutableAttributeAccessor curves_attributes = curves.attributes_for_write(); MutableSpan types = curves.curve_types_for_write(); diff --git a/source/blender/blenkernel/intern/curves.cc b/source/blender/blenkernel/intern/curves.cc index 0bdddc9c389..a7ac35ce56b 100644 --- a/source/blender/blenkernel/intern/curves.cc +++ b/source/blender/blenkernel/intern/curves.cc @@ -70,8 +70,8 @@ static void curves_copy_data(Main * /*bmain*/, ID *id_dst, const ID *id_src, con const Curves *curves_src = (const Curves *)id_src; curves_dst->mat = static_cast(MEM_dupallocN(curves_src->mat)); - const bke::CurvesGeometry &src = bke::CurvesGeometry::wrap(curves_src->geometry); - bke::CurvesGeometry &dst = bke::CurvesGeometry::wrap(curves_dst->geometry); + const bke::CurvesGeometry &src = curves_src->geometry.wrap(); + bke::CurvesGeometry &dst = curves_dst->geometry.wrap(); /* We need special handling here because the generic ID management code has already done a * shallow copy from the source to the destination, and because the copy-on-write functionality @@ -103,7 +103,7 @@ static void curves_free_data(ID *id) Curves *curves = (Curves *)id; BKE_animdata_free(&curves->id, false); - blender::bke::CurvesGeometry::wrap(curves->geometry).~CurvesGeometry(); + curves->geometry.wrap().~CurvesGeometry(); BKE_curves_batch_cache_free(curves); @@ -174,7 +174,7 @@ static void curves_blend_read_data(BlendDataReader *reader, ID *id) curves->geometry.runtime = MEM_new(__func__); /* Recalculate curve type count cache that isn't saved in files. */ - blender::bke::CurvesGeometry::wrap(curves->geometry).update_curve_types(); + curves->geometry.wrap().update_curve_types(); /* Materials */ BLO_read_pointer_array(reader, (void **)&curves->mat); @@ -247,8 +247,7 @@ BoundBox *BKE_curves_boundbox_get(Object *ob) if (ob->runtime.bb == nullptr) { ob->runtime.bb = MEM_cnew(__func__); - const blender::bke::CurvesGeometry &curves = blender::bke::CurvesGeometry::wrap( - curves_id->geometry); + const blender::bke::CurvesGeometry &curves = curves_id->geometry.wrap(); float3 min(FLT_MAX); float3 max(-FLT_MAX); @@ -372,7 +371,7 @@ Curves *curves_new_nomain(const int points_num, const int curves_num) BLI_assert(points_num >= 0); BLI_assert(curves_num >= 0); Curves *curves_id = static_cast(BKE_id_new_nomain(ID_CV, nullptr)); - CurvesGeometry &curves = CurvesGeometry::wrap(curves_id->geometry); + CurvesGeometry &curves = curves_id->geometry.wrap(); curves.resize(points_num, curves_num); return curves_id; } @@ -380,7 +379,7 @@ Curves *curves_new_nomain(const int points_num, const int curves_num) Curves *curves_new_nomain_single(const int points_num, const CurveType type) { Curves *curves_id = curves_new_nomain(points_num, 1); - CurvesGeometry &curves = CurvesGeometry::wrap(curves_id->geometry); + CurvesGeometry &curves = curves_id->geometry.wrap(); curves.offsets_for_write().last() = points_num; curves.fill_curve_types(type); return curves_id; @@ -389,7 +388,7 @@ Curves *curves_new_nomain_single(const int points_num, const CurveType type) Curves *curves_new_nomain(CurvesGeometry curves) { Curves *curves_id = static_cast(BKE_id_new_nomain(ID_CV, nullptr)); - bke::CurvesGeometry::wrap(curves_id->geometry) = std::move(curves); + curves_id->geometry.wrap() = std::move(curves); return curves_id; } diff --git a/source/blender/blenkernel/intern/geometry_component_edit_data.cc b/source/blender/blenkernel/intern/geometry_component_edit_data.cc index 2c00de3254f..9a5cd1aa904 100644 --- a/source/blender/blenkernel/intern/geometry_component_edit_data.cc +++ b/source/blender/blenkernel/intern/geometry_component_edit_data.cc @@ -48,7 +48,7 @@ void GeometryComponentEditData::remember_deformed_curve_positions_if_necessary( if (curves_id == nullptr) { return; } - const bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id->geometry); + const bke::CurvesGeometry &curves = curves_id->geometry.wrap(); const int points_num = curves.points_num(); if (points_num != edit_component.curves_edit_hints_->curves_id_orig.geometry.point_num) { return; diff --git a/source/blender/blenkernel/intern/geometry_fields.cc b/source/blender/blenkernel/intern/geometry_fields.cc index f4f4d0d8719..fd07f7eceab 100644 --- a/source/blender/blenkernel/intern/geometry_fields.cc +++ b/source/blender/blenkernel/intern/geometry_fields.cc @@ -55,7 +55,7 @@ GeometryFieldContext::GeometryFieldContext(const GeometryComponent &component, case GEO_COMPONENT_TYPE_CURVE: { const CurveComponent &curve_component = static_cast(component); const Curves *curves = curve_component.get_for_read(); - geometry_ = curves ? &CurvesGeometry::wrap(curves->geometry) : nullptr; + geometry_ = curves ? &curves->geometry.wrap() : nullptr; break; } case GEO_COMPONENT_TYPE_POINT_CLOUD: { @@ -560,8 +560,7 @@ std::optional try_detect_field_domain(const GeometryComponent &comp } else if (const auto *curves_field_input = dynamic_cast( &field_input)) { - if (!handle_domain( - curves_field_input->preferred_domain(CurvesGeometry::wrap(curves->geometry)))) { + if (!handle_domain(curves_field_input->preferred_domain(curves->geometry.wrap()))) { return std::nullopt; } } diff --git a/source/blender/blenkernel/intern/geometry_set.cc b/source/blender/blenkernel/intern/geometry_set.cc index 8fff80e709f..2417f8e2f73 100644 --- a/source/blender/blenkernel/intern/geometry_set.cc +++ b/source/blender/blenkernel/intern/geometry_set.cc @@ -227,7 +227,7 @@ bool GeometrySet::compute_boundbox_without_instances(float3 *r_min, float3 *r_ma have_minmax |= BKE_volume_min_max(volume, *r_min, *r_max); } if (const Curves *curves_id = this->get_curves_for_read()) { - const bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id->geometry); + const bke::CurvesGeometry &curves = curves_id->geometry.wrap(); have_minmax |= curves.bounds_min_max(*r_min, *r_max); } return have_minmax; diff --git a/source/blender/blenkernel/intern/mesh_convert.cc b/source/blender/blenkernel/intern/mesh_convert.cc index d9a84e98326..3d868d243ae 100644 --- a/source/blender/blenkernel/intern/mesh_convert.cc +++ b/source/blender/blenkernel/intern/mesh_convert.cc @@ -802,8 +802,7 @@ static Mesh *mesh_new_from_evaluated_curve_type_object(const Object *evaluated_o } if (const Curves *curves = get_evaluated_curves_from_object(evaluated_object)) { const blender::bke::AnonymousAttributePropagationInfo propagation_info; - return blender::bke::curve_to_wire_mesh(blender::bke::CurvesGeometry::wrap(curves->geometry), - propagation_info); + return blender::bke::curve_to_wire_mesh(curves->geometry.wrap(), propagation_info); } return nullptr; } diff --git a/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc b/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc index 40abfad12f5..f84b93a487c 100644 --- a/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc +++ b/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc @@ -33,7 +33,7 @@ void OVERLAY_sculpt_curves_cache_init(OVERLAY_Data *vedata) static bool everything_selected(const Curves &curves_id) { using namespace blender; - const bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id.geometry); + const bke::CurvesGeometry &curves = curves_id.geometry.wrap(); const VArray selection = curves.attributes().lookup_or_default( ".selection", ATTR_DOMAIN_POINT, true); return selection.is_single() && selection.get_internal_single(); diff --git a/source/blender/draw/engines/overlay/overlay_viewer_attribute.cc b/source/blender/draw/engines/overlay/overlay_viewer_attribute.cc index fd1657b3d59..69ff877c1e5 100644 --- a/source/blender/draw/engines/overlay/overlay_viewer_attribute.cc +++ b/source/blender/draw/engines/overlay/overlay_viewer_attribute.cc @@ -131,7 +131,7 @@ static void populate_cache_for_geometry(Object &object, } case OB_CURVES_LEGACY: { Curve *curve = static_cast(object.data); - const bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curve->curve_eval->geometry); + const bke::CurvesGeometry &curves = curve->curve_eval->geometry.wrap(); if (curves.attributes().contains(".viewer")) { GPUBatch *batch = DRW_cache_curve_edge_wire_viewer_attribute_get(&object); DRW_shgroup_uniform_float_copy(pd.viewer_attribute_curve_grp, "opacity", opacity); @@ -141,7 +141,7 @@ static void populate_cache_for_geometry(Object &object, } case OB_CURVES: { Curves *curves_id = static_cast(object.data); - const bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id->geometry); + const bke::CurvesGeometry &curves = curves_id->geometry.wrap(); if (curves.attributes().contains(".viewer")) { bool is_point_domain; GPUVertBuf **texture = DRW_curves_texture_for_evaluated_attribute( diff --git a/source/blender/draw/intern/draw_cache_impl_curve.cc b/source/blender/draw/intern/draw_cache_impl_curve.cc index ab8399216ec..b2e66c99eb4 100644 --- a/source/blender/draw/intern/draw_cache_impl_curve.cc +++ b/source/blender/draw/intern/draw_cache_impl_curve.cc @@ -213,11 +213,10 @@ static CurveRenderData *curve_render_data_create(Curve *cu, if (types & CU_DATATYPE_WIRE) { if (rdata->curve_eval != nullptr) { - curve_eval_render_wire_verts_edges_len_get( - blender::bke::CurvesGeometry::wrap(rdata->curve_eval->geometry), - &rdata->wire.curve_len, - &rdata->wire.vert_len, - &rdata->wire.edge_len); + curve_eval_render_wire_verts_edges_len_get(rdata->curve_eval->geometry.wrap(), + &rdata->wire.curve_len, + &rdata->wire.vert_len, + &rdata->wire.edge_len); } } @@ -473,8 +472,7 @@ static void curve_create_curves_pos(CurveRenderData *rdata, GPUVertBuf *vbo_curv GPU_vertbuf_init_with_format(vbo_curves_pos, &format); GPU_vertbuf_data_alloc(vbo_curves_pos, vert_len); - const blender::bke::CurvesGeometry &curves = blender::bke::CurvesGeometry::wrap( - rdata->curve_eval->geometry); + const blender::bke::CurvesGeometry &curves = rdata->curve_eval->geometry.wrap(); const Span positions = curves.evaluated_positions(); GPU_vertbuf_attr_fill(vbo_curves_pos, attr_id.pos, positions.data()); } @@ -495,7 +493,7 @@ static void curve_create_attribute(CurveRenderData *rdata, GPUVertBuf *vbo_attr) GPU_vertbuf_init_with_format(vbo_attr, &format); GPU_vertbuf_data_alloc(vbo_attr, vert_len); - const bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(rdata->curve_eval->geometry); + const bke::CurvesGeometry &curves = rdata->curve_eval->geometry.wrap(); curves.ensure_can_interpolate_to_evaluated(); const VArraySpan colors = curves.attributes().lookup( ".viewer", ATTR_DOMAIN_POINT); @@ -519,7 +517,7 @@ static void curve_create_curves_lines(CurveRenderData *rdata, GPUIndexBuf *ibo_c GPUIndexBufBuilder elb; GPU_indexbuf_init_ex(&elb, GPU_PRIM_LINE_STRIP, index_len, vert_len); - const bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(rdata->curve_eval->geometry); + const bke::CurvesGeometry &curves = rdata->curve_eval->geometry.wrap(); const OffsetIndices points_by_curve = curves.evaluated_points_by_curve(); const VArray cyclic = curves.cyclic(); diff --git a/source/blender/draw/intern/draw_cache_impl_curves.cc b/source/blender/draw/intern/draw_cache_impl_curves.cc index 0203554db4a..22e1eb3ece5 100644 --- a/source/blender/draw/intern/draw_cache_impl_curves.cc +++ b/source/blender/draw/intern/draw_cache_impl_curves.cc @@ -237,7 +237,7 @@ static void curves_batch_cache_fill_segments_proc_pos( { using namespace blender; /* TODO: use hair radius layer if available. */ - const bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id.geometry); + const bke::CurvesGeometry &curves = curves_id.geometry.wrap(); const OffsetIndices points_by_curve = curves.points_by_curve(); const Span positions = curves.positions(); @@ -305,7 +305,7 @@ static void curves_batch_cache_ensure_edit_points_pos(const Curves &curves_id, CurvesBatchCache &cache) { using namespace blender; - const bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id.geometry); + const bke::CurvesGeometry &curves = curves_id.geometry.wrap(); static GPUVertFormat format_pos = {0}; static uint pos; @@ -324,7 +324,7 @@ static void curves_batch_cache_ensure_edit_points_data(const Curves &curves_id, CurvesBatchCache &cache) { using namespace blender; - const bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id.geometry); + const bke::CurvesGeometry &curves = curves_id.geometry.wrap(); static GPUVertFormat format_data = {0}; static uint color; @@ -361,7 +361,7 @@ static void curves_batch_cache_ensure_edit_points_data(const Curves &curves_id, static void curves_batch_cache_ensure_edit_lines(const Curves &curves_id, CurvesBatchCache &cache) { using namespace blender; - const bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id.geometry); + const bke::CurvesGeometry &curves = curves_id.geometry.wrap(); const int vert_len = curves.points_num(); const int curve_len = curves.curves_num(); @@ -432,8 +432,7 @@ static void curves_batch_ensure_attribute(const Curves &curves, request.domain == ATTR_DOMAIN_POINT ? curves.geometry.point_num : curves.geometry.curve_num); - const bke::AttributeAccessor attributes = - bke::CurvesGeometry::wrap(curves.geometry).attributes(); + const bke::AttributeAccessor attributes = curves.geometry.wrap().attributes(); /* TODO(@kevindietrich): float4 is used for scalar attributes as the implicit conversion done * by OpenGL to vec4 for a scalar `s` will produce a `vec4(s, 0, 0, 1)`. However, following @@ -463,8 +462,7 @@ static void curves_batch_cache_fill_strands_data(const Curves &curves_id, GPUVertBufRaw &data_step, GPUVertBufRaw &seg_step) { - const blender::bke::CurvesGeometry &curves = blender::bke::CurvesGeometry::wrap( - curves_id.geometry); + const blender::bke::CurvesGeometry &curves = curves_id.geometry.wrap(); const blender::OffsetIndices points_by_curve = curves.points_by_curve(); for (const int i : IndexRange(curves.curves_num())) { @@ -694,8 +692,7 @@ static void request_attribute(Curves &curves, const char *name) DRW_Attributes attributes{}; - blender::bke::CurvesGeometry &curves_geometry = blender::bke::CurvesGeometry::wrap( - curves.geometry); + blender::bke::CurvesGeometry &curves_geometry = curves.geometry.wrap(); std::optional meta_data = curves_geometry.attributes().lookup_meta_data(name); if (!meta_data) { diff --git a/source/blender/draw/intern/draw_curves.cc b/source/blender/draw/intern/draw_curves.cc index 1ee489c54c2..45a72d67d31 100644 --- a/source/blender/draw/intern/draw_curves.cc +++ b/source/blender/draw/intern/draw_curves.cc @@ -327,8 +327,7 @@ DRWShadingGroup *DRW_shgroup_curves_create_sub(Object *object, /* Use the radius of the root and tip of the first curve for now. This is a workaround that we * use for now because we can't use a per-point radius yet. */ - const blender::bke::CurvesGeometry &curves = blender::bke::CurvesGeometry::wrap( - curves_id.geometry); + const blender::bke::CurvesGeometry &curves = curves_id.geometry.wrap(); if (curves.curves_num() >= 1) { blender::VArray radii = curves.attributes().lookup_or_default( "radius", ATTR_DOMAIN_POINT, 0.005f); diff --git a/source/blender/editors/curves/intern/curves_data.cc b/source/blender/editors/curves/intern/curves_data.cc index bcec7156bf3..c11879a18f9 100644 --- a/source/blender/editors/curves/intern/curves_data.cc +++ b/source/blender/editors/curves/intern/curves_data.cc @@ -8,7 +8,7 @@ float (*ED_curves_point_normals_array_create(const Curves *curves_id))[3] { using namespace blender; - const bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id->geometry); + const bke::CurvesGeometry &curves = curves_id->geometry.wrap(); const int size = curves.points_num(); float3 *data = static_cast(MEM_malloc_arrayN(size, sizeof(float3), __func__)); diff --git a/source/blender/editors/curves/intern/curves_ops.cc b/source/blender/editors/curves/intern/curves_ops.cc index d0a68774c71..7136c6f6d0a 100644 --- a/source/blender/editors/curves/intern/curves_ops.cc +++ b/source/blender/editors/curves/intern/curves_ops.cc @@ -238,7 +238,7 @@ static void try_convert_single_object(Object &curves_ob, return; } Curves &curves_id = *static_cast(curves_ob.data); - CurvesGeometry &curves = CurvesGeometry::wrap(curves_id.geometry); + CurvesGeometry &curves = curves_id.geometry.wrap(); if (curves_id.surface == nullptr) { return; } @@ -521,7 +521,7 @@ static int curves_convert_from_particle_system_exec(bContext *C, wmOperator * /* Object *ob_new = BKE_object_add(&bmain, &scene, &view_layer, OB_CURVES, psys_eval->name); Curves *curves_id = static_cast(ob_new->data); BKE_object_apply_mat4(ob_new, ob_from_orig->object_to_world, true, false); - bke::CurvesGeometry::wrap(curves_id->geometry) = particles_to_curves(*ob_from_eval, *psys_eval); + curves_id->geometry.wrap() = particles_to_curves(*ob_from_eval, *psys_eval); DEG_relations_tag_update(&bmain); WM_main_add_notifier(NC_OBJECT | ND_DRAW, nullptr); @@ -562,7 +562,7 @@ static void snap_curves_to_surface_exec_object(Object &curves_ob, bool *r_missing_uvs) { Curves &curves_id = *static_cast(curves_ob.data); - CurvesGeometry &curves = CurvesGeometry::wrap(curves_id.geometry); + CurvesGeometry &curves = curves_id.geometry.wrap(); const Mesh &surface_mesh = *static_cast(surface_ob.data); const Span surface_positions = surface_mesh.vert_positions(); @@ -774,7 +774,7 @@ static int curves_set_selection_domain_exec(bContext *C, wmOperator *op) curves_id->selection_domain = domain; - CurvesGeometry &curves = CurvesGeometry::wrap(curves_id->geometry); + CurvesGeometry &curves = curves_id->geometry.wrap(); bke::MutableAttributeAccessor attributes = curves.attributes_for_write(); if (curves.points_num() == 0) { continue; @@ -830,7 +830,7 @@ static void CURVES_OT_set_selection_domain(wmOperatorType *ot) static bool has_anything_selected(const Span curves_ids) { return std::any_of(curves_ids.begin(), curves_ids.end(), [](const Curves *curves_id) { - return has_anything_selected(CurvesGeometry::wrap(curves_id->geometry)); + return has_anything_selected(curves_id->geometry.wrap()); }); } @@ -846,9 +846,7 @@ static int select_all_exec(bContext *C, wmOperator *op) for (Curves *curves_id : unique_curves) { /* (De)select all the curves. */ - select_all(CurvesGeometry::wrap(curves_id->geometry), - eAttrDomain(curves_id->selection_domain), - action); + select_all(curves_id->geometry.wrap(), eAttrDomain(curves_id->selection_domain), action); /* Use #ID_RECALC_GEOMETRY instead of #ID_RECALC_SELECT because it is handled as a generic * attribute for now. */ @@ -881,7 +879,7 @@ static int select_random_exec(bContext *C, wmOperator *op) const float probability = RNA_float_get(op->ptr, "probability"); for (Curves *curves_id : unique_curves) { - CurvesGeometry &curves = CurvesGeometry::wrap(curves_id->geometry); + CurvesGeometry &curves = curves_id->geometry.wrap(); select_random(curves, eAttrDomain(curves_id->selection_domain), uint32_t(seed), probability); /* Use #ID_RECALC_GEOMETRY instead of #ID_RECALC_SELECT because it is handled as a generic @@ -952,7 +950,7 @@ static int select_end_exec(bContext *C, wmOperator *op) const int amount = RNA_int_get(op->ptr, "amount"); for (Curves *curves_id : unique_curves) { - CurvesGeometry &curves = CurvesGeometry::wrap(curves_id->geometry); + CurvesGeometry &curves = curves_id->geometry.wrap(); select_ends(curves, eAttrDomain(curves_id->selection_domain), amount, end_points); /* Use #ID_RECALC_GEOMETRY instead of #ID_RECALC_SELECT because it is handled as a generic diff --git a/source/blender/editors/curves/intern/curves_selection.cc b/source/blender/editors/curves/intern/curves_selection.cc index f74ac53de9a..d40e736b266 100644 --- a/source/blender/editors/curves/intern/curves_selection.cc +++ b/source/blender/editors/curves/intern/curves_selection.cc @@ -52,7 +52,7 @@ static IndexMask retrieve_selected_curves(const bke::CurvesGeometry &curves, IndexMask retrieve_selected_curves(const Curves &curves_id, Vector &r_indices) { - const bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id.geometry); + const bke::CurvesGeometry &curves = curves_id.geometry.wrap(); return retrieve_selected_curves(curves, r_indices); } @@ -67,7 +67,7 @@ IndexMask retrieve_selected_points(const bke::CurvesGeometry &curves, Vector &r_indices) { - const bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id.geometry); + const bke::CurvesGeometry &curves = curves_id.geometry.wrap(); return retrieve_selected_points(curves, r_indices); } diff --git a/source/blender/editors/curves/intern/curves_undo.cc b/source/blender/editors/curves/intern/curves_undo.cc index 551fbadfefc..5b02b401e4c 100644 --- a/source/blender/editors/curves/intern/curves_undo.cc +++ b/source/blender/editors/curves/intern/curves_undo.cc @@ -60,7 +60,7 @@ static bool step_encode(bContext *C, Main *bmain, UndoStep *us_p) StepObject &object = us->objects[i]; object.obedit_ref.ptr = ob; - object.geometry = bke::CurvesGeometry::wrap(curves_id.geometry); + object.geometry = curves_id.geometry.wrap(); } }); MEM_SAFE_FREE(objects); @@ -86,7 +86,7 @@ static void step_decode( Curves &curves_id = *static_cast(object.obedit_ref.ptr->data); /* Overwrite the curves geometry. */ - bke::CurvesGeometry::wrap(curves_id.geometry) = object.geometry; + curves_id.geometry.wrap() = object.geometry; DEG_id_tag_update(&curves_id.id, ID_RECALC_GEOMETRY); } diff --git a/source/blender/editors/object/object_add.cc b/source/blender/editors/object/object_add.cc index 3d9cb9b8167..6832e9add2c 100644 --- a/source/blender/editors/object/object_add.cc +++ b/source/blender/editors/object/object_add.cc @@ -2048,7 +2048,7 @@ static int object_curves_random_add_exec(bContext *C, wmOperator *op) Object *object = ED_object_add_type(C, OB_CURVES, nullptr, loc, rot, false, local_view_bits); Curves *curves_id = static_cast(object->data); - bke::CurvesGeometry::wrap(curves_id->geometry) = ed::curves::primitive_random_sphere(500, 8); + curves_id->geometry.wrap() = ed::curves::primitive_random_sphere(500, 8); return OPERATOR_FINISHED; } @@ -3091,8 +3091,7 @@ static int object_convert_exec(bContext *C, wmOperator *op) newob->data = new_curves; newob->type = OB_CURVES; - blender::bke::CurvesGeometry::wrap( - new_curves->geometry) = blender::bke::CurvesGeometry::wrap(curves_eval->geometry); + new_curves->geometry.wrap() = curves_eval->geometry.wrap(); BKE_object_material_from_eval_data(bmain, newob, &curves_eval->id); BKE_object_free_derived_caches(newob); @@ -3392,8 +3391,7 @@ static int object_convert_exec(bContext *C, wmOperator *op) else if (const Curves *curves_eval = geometry.get_curves_for_read()) { bke::AnonymousAttributePropagationInfo propagation_info; propagation_info.propagate_all = false; - Mesh *mesh = bke::curve_to_wire_mesh(bke::CurvesGeometry::wrap(curves_eval->geometry), - propagation_info); + Mesh *mesh = bke::curve_to_wire_mesh(curves_eval->geometry.wrap(), propagation_info); BKE_mesh_nomain_to_mesh(mesh, new_mesh, newob); BKE_object_material_from_eval_data(bmain, newob, &curves_eval->id); } diff --git a/source/blender/editors/object/object_modifier.cc b/source/blender/editors/object/object_modifier.cc index 9964d658994..5ac76b9a82c 100644 --- a/source/blender/editors/object/object_modifier.cc +++ b/source/blender/editors/object/object_modifier.cc @@ -1075,13 +1075,10 @@ static bool modifier_apply_obdata( Curves &curves_eval = *geometry_set.get_curves_for_write(); /* Anonymous attributes shouldn't be available on the applied geometry. */ - blender::bke::CurvesGeometry::wrap(curves_eval.geometry) - .attributes_for_write() - .remove_anonymous(); + curves_eval.geometry.wrap().attributes_for_write().remove_anonymous(); /* Copy the relevant information to the original. */ - blender::bke::CurvesGeometry::wrap(curves.geometry) = std::move( - blender::bke::CurvesGeometry::wrap(curves_eval.geometry)); + curves.geometry.wrap() = std::move(curves_eval.geometry.wrap()); Main *bmain = DEG_get_bmain(depsgraph); BKE_object_material_from_eval_data(bmain, ob, &curves_eval.id); } diff --git a/source/blender/editors/object/object_transform.cc b/source/blender/editors/object/object_transform.cc index 539260cd27f..ffa6639f9c1 100644 --- a/source/blender/editors/object/object_transform.cc +++ b/source/blender/editors/object/object_transform.cc @@ -944,8 +944,8 @@ static int apply_objects_internal(bContext *C, } else if (ob->type == OB_CURVES) { Curves &curves = *static_cast(ob->data); - blender::bke::CurvesGeometry::wrap(curves.geometry).transform(mat); - blender::bke::CurvesGeometry::wrap(curves.geometry).calculate_bezier_auto_handles(); + curves.geometry.wrap().transform(mat); + curves.geometry.wrap().calculate_bezier_auto_handles(); } else if (ob->type == OB_POINTCLOUD) { PointCloud &pointcloud = *static_cast(ob->data); @@ -1674,7 +1674,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) else if (ob->type == OB_CURVES) { using namespace blender; Curves &curves_id = *static_cast(ob->data); - bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id.geometry); + bke::CurvesGeometry &curves = curves_id.geometry.wrap(); if (ELEM(centermode, ORIGIN_TO_CENTER_OF_MASS_SURFACE, ORIGIN_TO_CENTER_OF_MASS_VOLUME) || !ELEM(around, V3D_AROUND_CENTER_BOUNDS, V3D_AROUND_CENTER_MEDIAN)) { BKE_report( diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_add.cc b/source/blender/editors/sculpt_paint/curves_sculpt_add.cc index 4f7668e8e67..3c0e54c3992 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_add.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_add.cc @@ -117,7 +117,7 @@ struct AddOperationExecutor { curves_ob_orig_ = CTX_data_active_object(&C); curves_id_orig_ = static_cast(curves_ob_orig_->data); - curves_orig_ = &CurvesGeometry::wrap(curves_id_orig_->geometry); + curves_orig_ = &curves_id_orig_->geometry.wrap(); if (curves_id_orig_->surface == nullptr || curves_id_orig_->surface->type != OB_MESH) { report_missing_surface(stroke_extension.reports); diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_brush.cc b/source/blender/editors/sculpt_paint/curves_sculpt_brush.cc index ead9b988829..f14c8284641 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_brush.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_brush.cc @@ -177,7 +177,7 @@ std::optional sample_curves_3d_brush(const Depsgraph &depsgraph, const float brush_radius_re) { const Curves &curves_id = *static_cast(curves_object.data); - const CurvesGeometry &curves = CurvesGeometry::wrap(curves_id.geometry); + const CurvesGeometry &curves = curves_id.geometry.wrap(); Object *surface_object = curves_id.surface; Object *surface_object_eval = DEG_get_evaluated_object(&depsgraph, surface_object); diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_comb.cc b/source/blender/editors/sculpt_paint/curves_sculpt_comb.cc index c9b273aacb8..7622dd43963 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_comb.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_comb.cc @@ -117,7 +117,7 @@ struct CombOperationExecutor { curves_ob_orig_ = CTX_data_active_object(&C); curves_id_orig_ = static_cast(curves_ob_orig_->data); - curves_orig_ = &CurvesGeometry::wrap(curves_id_orig_->geometry); + curves_orig_ = &curves_id_orig_->geometry.wrap(); if (curves_orig_->curves_num() == 0) { return; } diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_delete.cc b/source/blender/editors/sculpt_paint/curves_sculpt_delete.cc index 08d61dad219..641505654a5 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_delete.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_delete.cc @@ -94,7 +94,7 @@ struct DeleteOperationExecutor { object_ = CTX_data_active_object(&C); curves_id_ = static_cast(object_->data); - curves_ = &CurvesGeometry::wrap(curves_id_->geometry); + curves_ = &curves_id_->geometry.wrap(); selected_curve_indices_.clear(); curve_selection_ = curves::retrieve_selected_curves(*curves_id_, selected_curve_indices_); diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_density.cc b/source/blender/editors/sculpt_paint/curves_sculpt_density.cc index 8d7c4a07574..b61fa1035d5 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_density.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_density.cc @@ -102,7 +102,7 @@ struct DensityAddOperationExecutor { self_ = &self; curves_ob_orig_ = CTX_data_active_object(&C); curves_id_orig_ = static_cast(curves_ob_orig_->data); - curves_orig_ = &CurvesGeometry::wrap(curves_id_orig_->geometry); + curves_orig_ = &curves_id_orig_->geometry.wrap(); if (stroke_extension.is_first) { self_->original_curve_num_ = curves_orig_->curves_num(); @@ -540,7 +540,7 @@ struct DensitySubtractOperationExecutor { object_ = CTX_data_active_object(&C); curves_id_ = static_cast(object_->data); - curves_ = &CurvesGeometry::wrap(curves_id_->geometry); + curves_ = &curves_id_->geometry.wrap(); if (curves_->curves_num() == 0) { return; } @@ -834,7 +834,7 @@ static bool use_add_density_mode(const BrushStrokeMode brush_mode, if (surface_ob_eval == nullptr) { return true; } - const CurvesGeometry &curves = CurvesGeometry::wrap(curves_id_orig.geometry); + const CurvesGeometry &curves = curves_id_orig.geometry.wrap(); if (curves.curves_num() <= 1) { return true; } diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_grow_shrink.cc b/source/blender/editors/sculpt_paint/curves_sculpt_grow_shrink.cc index f84305de426..dcb0d838421 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_grow_shrink.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_grow_shrink.cc @@ -278,7 +278,7 @@ struct CurvesEffectOperationExecutor { object_ = CTX_data_active_object(&C); curves_id_ = static_cast(object_->data); - curves_ = &CurvesGeometry::wrap(curves_id_->geometry); + curves_ = &curves_id_->geometry.wrap(); if (curves_->curves_num() == 0) { return; } diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc b/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc index 39575015381..913bed704ab 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc @@ -362,7 +362,7 @@ static int select_random_exec(bContext *C, wmOperator *op) const auto next_bool_random_value = [&]() { return rng.get_float() <= probability; }; for (Curves *curves_id : unique_curves) { - CurvesGeometry &curves = CurvesGeometry::wrap(curves_id->geometry); + CurvesGeometry &curves = curves_id->geometry.wrap(); const bool was_anything_selected = curves::has_anything_selected(curves); bke::SpanAttributeWriter attribute = float_selection_ensure(*curves_id); @@ -581,7 +581,7 @@ static int select_grow_update(bContext *C, wmOperator *op, const float mouse_dif for (std::unique_ptr &curve_op_data : op_data.per_curve) { Curves &curves_id = *curve_op_data->curves_id; - CurvesGeometry &curves = CurvesGeometry::wrap(curves_id.geometry); + CurvesGeometry &curves = curves_id.geometry.wrap(); const float distance = curve_op_data->pixel_to_distance_factor * mouse_diff_x; bke::SpanAttributeWriter selection = float_selection_ensure(curves_id); @@ -629,7 +629,7 @@ static void select_grow_invoke_per_curve(const Curves &curves_id, const RegionView3D &rv3d, GrowOperatorDataPerCurve &curve_op_data) { - const CurvesGeometry &curves = CurvesGeometry::wrap(curves_id.geometry); + const CurvesGeometry &curves = curves_id.geometry.wrap(); const Span positions = curves.positions(); if (const bke::GAttributeReader original_selection = curves.attributes().lookup(".selection")) { @@ -773,7 +773,7 @@ static int select_grow_modal(bContext *C, wmOperator *op, const wmEvent *event) /* Undo operator by resetting the selection to the original value. */ for (std::unique_ptr &curve_op_data : op_data.per_curve) { Curves &curves_id = *curve_op_data->curves_id; - CurvesGeometry &curves = CurvesGeometry::wrap(curves_id.geometry); + CurvesGeometry &curves = curves_id.geometry.wrap(); bke::MutableAttributeAccessor attributes = curves.attributes_for_write(); attributes.remove(".selection"); diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_pinch.cc b/source/blender/editors/sculpt_paint/curves_sculpt_pinch.cc index db1ad9c7bfb..a3dcbd2d185 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_pinch.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_pinch.cc @@ -90,7 +90,7 @@ struct PinchOperationExecutor { object_ = CTX_data_active_object(&C); curves_id_ = static_cast(object_->data); - curves_ = &CurvesGeometry::wrap(curves_id_->geometry); + curves_ = &curves_id_->geometry.wrap(); if (curves_->curves_num() == 0) { return; } diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_puff.cc b/source/blender/editors/sculpt_paint/curves_sculpt_puff.cc index dcb7a3ae797..9fe2632b02e 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_puff.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_puff.cc @@ -87,7 +87,7 @@ struct PuffOperationExecutor { object_ = CTX_data_active_object(&C); curves_id_ = static_cast(object_->data); - curves_ = &CurvesGeometry::wrap(curves_id_->geometry); + curves_ = &curves_id_->geometry.wrap(); if (curves_->curves_num() == 0) { return; } diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_selection.cc b/source/blender/editors/sculpt_paint/curves_sculpt_selection.cc index adc4f965102..f0760dc5635 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_selection.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_selection.cc @@ -13,7 +13,7 @@ namespace blender::ed::sculpt_paint { bke::SpanAttributeWriter float_selection_ensure(Curves &curves_id) { /* TODO: Use a generic attribute conversion utility instead of this function. */ - bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id.geometry); + bke::CurvesGeometry &curves = curves_id.geometry.wrap(); bke::MutableAttributeAccessor attributes = curves.attributes_for_write(); if (const auto meta_data = attributes.lookup_meta_data(".selection")) { diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_selection_paint.cc b/source/blender/editors/sculpt_paint/curves_sculpt_selection_paint.cc index 190249c7c27..515908c80a7 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_selection_paint.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_selection_paint.cc @@ -83,7 +83,7 @@ struct SelectionPaintOperationExecutor { object_ = CTX_data_active_object(&C); curves_id_ = static_cast(object_->data); - curves_ = &CurvesGeometry::wrap(curves_id_->geometry); + curves_ = &curves_id_->geometry.wrap(); if (curves_->curves_num() == 0) { return; } diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_slide.cc b/source/blender/editors/sculpt_paint/curves_sculpt_slide.cc index 6d716ad06a9..9b865b89969 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_slide.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_slide.cc @@ -131,7 +131,7 @@ struct SlideOperationExecutor { curves_ob_orig_ = CTX_data_active_object(&C); curves_id_orig_ = static_cast(curves_ob_orig_->data); - curves_orig_ = &CurvesGeometry::wrap(curves_id_orig_->geometry); + curves_orig_ = &curves_id_orig_->geometry.wrap(); if (curves_id_orig_->surface == nullptr || curves_id_orig_->surface->type != OB_MESH) { report_missing_surface(stroke_extension.reports); return; diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_smooth.cc b/source/blender/editors/sculpt_paint/curves_sculpt_smooth.cc index eb80b2e4025..750f496513e 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_smooth.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_smooth.cc @@ -66,7 +66,7 @@ struct SmoothOperationExecutor { object_ = CTX_data_active_object(&C); curves_id_ = static_cast(object_->data); - curves_ = &CurvesGeometry::wrap(curves_id_->geometry); + curves_ = &curves_id_->geometry.wrap(); if (curves_->curves_num() == 0) { return; } diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_snake_hook.cc b/source/blender/editors/sculpt_paint/curves_sculpt_snake_hook.cc index c00bc07c3dc..cb6766dd6ec 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_snake_hook.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_snake_hook.cc @@ -118,7 +118,7 @@ struct SnakeHookOperatorExecutor { falloff_shape_ = static_cast(brush_->falloff_shape); curves_id_ = static_cast(object_->data); - curves_ = &CurvesGeometry::wrap(curves_id_->geometry); + curves_ = &curves_id_->geometry.wrap(); if (curves_->curves_num() == 0) { return; } diff --git a/source/blender/editors/transform/transform_convert_curves.cc b/source/blender/editors/transform/transform_convert_curves.cc index 63eaba6de54..a1c489f3d87 100644 --- a/source/blender/editors/transform/transform_convert_curves.cc +++ b/source/blender/editors/transform/transform_convert_curves.cc @@ -33,7 +33,7 @@ static void createTransCurvesVerts(bContext * /*C*/, TransInfo *t) for (const int i : trans_data_contrainers.index_range()) { TransDataContainer &tc = trans_data_contrainers[i]; Curves *curves_id = static_cast(tc.obedit->data); - bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id->geometry); + bke::CurvesGeometry &curves = curves_id->geometry.wrap(); selection_per_object[i] = ed::curves::retrieve_selected_points(curves, selected_indices_per_object[i]); @@ -51,7 +51,7 @@ static void createTransCurvesVerts(bContext * /*C*/, TransInfo *t) continue; } Curves *curves_id = static_cast(tc.obedit->data); - bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id->geometry); + bke::CurvesGeometry &curves = curves_id->geometry.wrap(); IndexMask selected_indices = selection_per_object[i]; float mtx[3][3], smtx[3][3]; @@ -82,7 +82,7 @@ static void recalcData_curves(TransInfo *t) Span trans_data_contrainers(t->data_container, t->data_container_len); for (const TransDataContainer &tc : trans_data_contrainers) { Curves *curves_id = static_cast(tc.obedit->data); - bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id->geometry); + bke::CurvesGeometry &curves = curves_id->geometry.wrap(); curves.calculate_bezier_auto_handles(); curves.tag_positions_changed(); diff --git a/source/blender/geometry/intern/realize_instances.cc b/source/blender/geometry/intern/realize_instances.cc index 5c1f0605d24..8bae0c1d7b3 100644 --- a/source/blender/geometry/intern/realize_instances.cc +++ b/source/blender/geometry/intern/realize_instances.cc @@ -1197,7 +1197,7 @@ static AllCurvesInfo preprocess_curves(const GeometrySet &geometry_set, for (const int curve_index : info.realize_info.index_range()) { RealizeCurveInfo &curve_info = info.realize_info[curve_index]; const Curves *curves_id = info.order[curve_index]; - const bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id->geometry); + const bke::CurvesGeometry &curves = curves_id->geometry.wrap(); curve_info.curves = curves_id; /* Access attributes. */ @@ -1258,7 +1258,7 @@ static void execute_realize_curve_task(const RealizeInstancesOptions &options, { const RealizeCurveInfo &curves_info = *task.curve_info; const Curves &curves_id = *curves_info.curves; - const bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id.geometry); + const bke::CurvesGeometry &curves = curves_id.geometry.wrap(); const IndexRange dst_point_range{task.start_indices.point, curves.points_num()}; const IndexRange dst_curve_range{task.start_indices.curve, curves.curves_num()}; @@ -1347,7 +1347,7 @@ static void execute_realize_curve_tasks(const RealizeInstancesOptions &options, /* Allocate new curves data-block. */ Curves *dst_curves_id = bke::curves_new_nomain(points_num, curves_num); - bke::CurvesGeometry &dst_curves = bke::CurvesGeometry::wrap(dst_curves_id->geometry); + bke::CurvesGeometry &dst_curves = dst_curves_id->geometry.wrap(); dst_curves.offsets_for_write().last() = points_num; CurveComponent &dst_component = r_realized_geometry.get_component_for_write(); dst_component.replace(dst_curves_id); diff --git a/source/blender/makesdna/DNA_curves_types.h b/source/blender/makesdna/DNA_curves_types.h index 5ecc816f4ea..3ee2ba2797d 100644 --- a/source/blender/makesdna/DNA_curves_types.h +++ b/source/blender/makesdna/DNA_curves_types.h @@ -17,6 +17,7 @@ extern "C" { #ifdef __cplusplus namespace blender::bke { +class CurvesGeometry; class CurvesGeometryRuntime; } // namespace blender::bke using CurvesGeometryRuntimeHandle = blender::bke::CurvesGeometryRuntime; @@ -134,6 +135,11 @@ typedef struct CurvesGeometry { * Runtime data for curves, stored as a pointer to allow defining this as a C++ class. */ CurvesGeometryRuntimeHandle *runtime; + +#ifdef __cplusplus + blender::bke::CurvesGeometry &wrap(); + const blender::bke::CurvesGeometry &wrap() const; +#endif } CurvesGeometry; /** diff --git a/source/blender/nodes/geometry/nodes/node_geo_convex_hull.cc b/source/blender/nodes/geometry/nodes/node_geo_convex_hull.cc index 3ede378e95a..9ec82d2666f 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_convex_hull.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_convex_hull.cc @@ -170,7 +170,7 @@ static Mesh *compute_hull(const GeometrySet &geometry_set) if (const Curves *curves_id = geometry_set.get_curves_for_read()) { count++; span_count++; - const bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id->geometry); + const bke::CurvesGeometry &curves = curves_id->geometry.wrap(); positions_span = curves.evaluated_positions(); total_num += positions_span.size(); } @@ -205,7 +205,7 @@ static Mesh *compute_hull(const GeometrySet &geometry_set) } if (const Curves *curves_id = geometry_set.get_curves_for_read()) { - const bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id->geometry); + const bke::CurvesGeometry &curves = curves_id->geometry.wrap(); Span array = curves.evaluated_positions(); positions.as_mutable_span().slice(offset, array.size()).copy_from(array); offset += array.size(); diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_fill.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_fill.cc index c09a128a3c1..2f4ac6c878c 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_fill.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_fill.cc @@ -116,7 +116,7 @@ static void curve_fill_calculate(GeometrySet &geometry_set, const GeometryNodeCu } const Curves &curves_id = *geometry_set.get_curves_for_read(); - const bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id.geometry); + const bke::CurvesGeometry &curves = curves_id.geometry.wrap(); if (curves.curves_num() == 0) { geometry_set.replace_curves(nullptr); return; 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 627abcab861..fa83dccf51e 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_fillet.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_fillet.cc @@ -76,7 +76,7 @@ static void node_geo_exec(GeoNodeExecParams params) } const Curves &curves_id = *geometry_set.get_curves_for_read(); - const bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id.geometry); + const bke::CurvesGeometry &curves = curves_id.geometry.wrap(); bke::CurvesFieldContext context{curves, ATTR_DOMAIN_POINT}; fn::FieldEvaluator evaluator{context, curves.points_num()}; evaluator.add(radius_field); diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_length.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_length.cc index 11eb472a6e2..fcbb80611b3 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_length.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_length.cc @@ -21,7 +21,7 @@ static void node_geo_exec(GeoNodeExecParams params) } const Curves &curves_id = *curve_set.get_curves_for_read(); - const bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id.geometry); + const bke::CurvesGeometry &curves = curves_id.geometry.wrap(); const VArray cyclic = curves.cyclic(); curves.ensure_evaluated_lengths(); diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_arc.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_arc.cc index e0148730710..71c4621c325 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_arc.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_arc.cc @@ -167,7 +167,7 @@ static Curves *create_arc_curve_from_points(const int resolution, { const int size = connect_center ? resolution + 1 : resolution; Curves *curves_id = bke::curves_new_nomain_single(size, CURVE_TYPE_POLY); - bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id->geometry); + bke::CurvesGeometry &curves = curves_id->geometry.wrap(); const int stepcount = resolution - 1; const int centerpoint = resolution; @@ -285,7 +285,7 @@ static Curves *create_arc_curve_from_radius(const int resolution, { const int size = connect_center ? resolution + 1 : resolution; Curves *curves_id = bke::curves_new_nomain_single(size, CURVE_TYPE_POLY); - bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id->geometry); + bke::CurvesGeometry &curves = curves_id->geometry.wrap(); const int stepcount = resolution - 1; const int centerpoint = resolution; 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 59c17365261..b212ef54d15 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 @@ -63,7 +63,7 @@ static Curves *create_bezier_segment_curve(const float3 start, const GeometryNodeCurvePrimitiveBezierSegmentMode mode) { Curves *curves_id = bke::curves_new_nomain_single(2, CURVE_TYPE_BEZIER); - bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id->geometry); + bke::CurvesGeometry &curves = curves_id->geometry.wrap(); curves.resolution_for_write().fill(resolution); MutableSpan positions = curves.positions_for_write(); diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc index 7eff4923138..1e358333a23 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc @@ -137,7 +137,7 @@ static Curves *create_point_circle_curve( } Curves *curves_id = bke::curves_new_nomain_single(resolution, CURVE_TYPE_POLY); - bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id->geometry); + bke::CurvesGeometry &curves = curves_id->geometry.wrap(); curves.cyclic_for_write().first() = true; MutableSpan positions = curves.positions_for_write(); @@ -163,7 +163,7 @@ static Curves *create_point_circle_curve( static Curves *create_radius_circle_curve(const int resolution, const float radius) { Curves *curves_id = bke::curves_new_nomain_single(resolution, CURVE_TYPE_POLY); - bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id->geometry); + bke::CurvesGeometry &curves = curves_id->geometry.wrap(); curves.cyclic_for_write().first() = true; MutableSpan positions = curves.positions_for_write(); diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_line.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_line.cc index d4ce1923178..5e4661bcedf 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_line.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_line.cc @@ -71,7 +71,7 @@ static void node_update(bNodeTree *ntree, bNode *node) static Curves *create_point_line_curve(const float3 start, const float3 end) { Curves *curves_id = bke::curves_new_nomain_single(2, CURVE_TYPE_POLY); - bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id->geometry); + bke::CurvesGeometry &curves = curves_id->geometry.wrap(); curves.positions_for_write().first() = start; curves.positions_for_write().last() = end; @@ -84,7 +84,7 @@ static Curves *create_direction_line_curve(const float3 start, const float length) { Curves *curves_id = bke::curves_new_nomain_single(2, CURVE_TYPE_POLY); - bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id->geometry); + bke::CurvesGeometry &curves = curves_id->geometry.wrap(); curves.positions_for_write().first() = start; curves.positions_for_write().last() = math::normalize(direction) * length + start; diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadratic_bezier.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadratic_bezier.cc index 9eae371d948..8f91ffbc160 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadratic_bezier.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadratic_bezier.cc @@ -34,7 +34,7 @@ static Curves *create_quadratic_bezier_curve(const float3 p1, const int resolution) { Curves *curves_id = bke::curves_new_nomain_single(resolution + 1, CURVE_TYPE_POLY); - bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id->geometry); + bke::CurvesGeometry &curves = curves_id->geometry.wrap(); MutableSpan positions = curves.positions_for_write(); diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadrilateral.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadrilateral.cc index b1bc8379ff2..559054ac2c0 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadrilateral.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadrilateral.cc @@ -216,7 +216,7 @@ static void node_geo_exec(GeoNodeExecParams params) const GeometryNodeCurvePrimitiveQuadMode mode = (GeometryNodeCurvePrimitiveQuadMode)storage.mode; Curves *curves_id = bke::curves_new_nomain_single(4, CURVE_TYPE_POLY); - bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id->geometry); + bke::CurvesGeometry &curves = curves_id->geometry.wrap(); curves.cyclic_for_write().first() = true; MutableSpan positions = curves.positions_for_write(); diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_spiral.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_spiral.cc index 66284fe77db..923a3fc50d1 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_spiral.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_spiral.cc @@ -49,7 +49,7 @@ static Curves *create_spiral_curve(const float rotations, (direction ? 1.0f : -1.0f); Curves *curves_id = bke::curves_new_nomain_single(totalpoints + 1, CURVE_TYPE_POLY); - bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id->geometry); + bke::CurvesGeometry &curves = curves_id->geometry.wrap(); MutableSpan positions = curves.positions_for_write(); diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_star.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_star.cc index 873b66688c5..46468c6cbf0 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_star.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_star.cc @@ -39,7 +39,7 @@ static Curves *create_star_curve(const float inner_radius, const int points) { Curves *curves_id = bke::curves_new_nomain_single(points * 2, CURVE_TYPE_POLY); - bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id->geometry); + bke::CurvesGeometry &curves = curves_id->geometry.wrap(); curves.cyclic_for_write().first() = true; MutableSpan positions = curves.positions_for_write(); 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 7d54f33d555..b34040b5b74 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc @@ -67,8 +67,7 @@ static void node_geo_exec(GeoNodeExecParams params) Field count = params.extract_input>("Count"); geometry_set.modify_geometry_sets([&](GeometrySet &geometry) { if (const Curves *src_curves_id = geometry.get_curves_for_read()) { - const bke::CurvesGeometry &src_curves = bke::CurvesGeometry::wrap( - src_curves_id->geometry); + const bke::CurvesGeometry &src_curves = src_curves_id->geometry.wrap(); bke::CurvesGeometry dst_curves = geometry::resample_to_count( src_curves, selection, count); Curves *dst_curves_id = bke::curves_new_nomain(std::move(dst_curves)); @@ -82,8 +81,7 @@ static void node_geo_exec(GeoNodeExecParams params) Field length = params.extract_input>("Length"); geometry_set.modify_geometry_sets([&](GeometrySet &geometry) { if (const Curves *src_curves_id = geometry.get_curves_for_read()) { - const bke::CurvesGeometry &src_curves = bke::CurvesGeometry::wrap( - src_curves_id->geometry); + const bke::CurvesGeometry &src_curves = src_curves_id->geometry.wrap(); bke::CurvesGeometry dst_curves = geometry::resample_to_length( src_curves, selection, length); Curves *dst_curves_id = bke::curves_new_nomain(std::move(dst_curves)); @@ -96,8 +94,7 @@ static void node_geo_exec(GeoNodeExecParams params) case GEO_NODE_CURVE_RESAMPLE_EVALUATED: geometry_set.modify_geometry_sets([&](GeometrySet &geometry) { if (const Curves *src_curves_id = geometry.get_curves_for_read()) { - const bke::CurvesGeometry &src_curves = bke::CurvesGeometry::wrap( - src_curves_id->geometry); + const bke::CurvesGeometry &src_curves = src_curves_id->geometry.wrap(); bke::CurvesGeometry dst_curves = geometry::resample_to_evaluated(src_curves, selection); Curves *dst_curves_id = bke::curves_new_nomain(std::move(dst_curves)); bke::curves_copy_parameters(*src_curves_id, *dst_curves_id); diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_reverse.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_reverse.cc index 311f2353391..0dfb338ef32 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_reverse.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_reverse.cc @@ -26,7 +26,7 @@ static void node_geo_exec(GeoNodeExecParams params) return; } const Curves &src_curves_id = *geometry_set.get_curves_for_read(); - const bke::CurvesGeometry &src_curves = bke::CurvesGeometry::wrap(src_curves_id.geometry); + const bke::CurvesGeometry &src_curves = src_curves_id.geometry.wrap(); bke::CurvesFieldContext field_context{src_curves, ATTR_DOMAIN_CURVE}; fn::FieldEvaluator selection_evaluator{field_context, src_curves.curves_num()}; @@ -38,7 +38,7 @@ static void node_geo_exec(GeoNodeExecParams params) } Curves &curves_id = *geometry_set.get_curves_for_write(); - bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id.geometry); + bke::CurvesGeometry &curves = curves_id.geometry.wrap(); curves.reverse_curves(selection); }); diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_sample.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_sample.cc index 9b703f952bb..9b2a2cb153d 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_sample.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_sample.cc @@ -297,7 +297,7 @@ class SampleCurveFunction : public mf::MultiFunction { } const Curves &curves_id = *geometry_set_.get_curves_for_read(); - const bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id.geometry); + const bke::CurvesGeometry &curves = curves_id.geometry.wrap(); if (curves.points_num() == 0) { return return_default(); } @@ -428,7 +428,7 @@ class SampleCurveFunction : public mf::MultiFunction { void evaluate_source() { const Curves &curves_id = *geometry_set_.get_curves_for_read(); - const bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id.geometry); + const bke::CurvesGeometry &curves = curves_id.geometry.wrap(); source_context_.emplace(bke::CurvesFieldContext{curves, ATTR_DOMAIN_POINT}); source_evaluator_ = std::make_unique(*source_context_, curves.points_num()); source_evaluator_->add(src_field_); @@ -506,7 +506,7 @@ static void node_geo_exec(GeoNodeExecParams params) } const Curves &curves_id = *geometry_set.get_curves_for_read(); - const bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id.geometry); + const bke::CurvesGeometry &curves = curves_id.geometry.wrap(); if (curves.points_num() == 0) { params.set_default_remaining_outputs(); return; diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_set_handle_type.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_set_handle_type.cc index 6a6e12642c5..8b0284c4018 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_set_handle_type.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_set_handle_type.cc @@ -91,7 +91,7 @@ static void node_geo_exec(GeoNodeExecParams params) geometry_set.modify_geometry_sets([&](GeometrySet &geometry_set) { if (Curves *curves_id = geometry_set.get_curves_for_write()) { - bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id->geometry); + bke::CurvesGeometry &curves = curves_id->geometry.wrap(); has_curves = true; const AttributeAccessor attributes = curves.attributes(); if (!attributes.contains("handle_type_left") || !attributes.contains("handle_type_right")) { 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 64a9ae08c9b..baf972ee3a6 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 @@ -46,7 +46,7 @@ static void node_geo_exec(GeoNodeExecParams params) return; } const Curves &src_curves_id = *geometry_set.get_curves_for_read(); - const bke::CurvesGeometry &src_curves = bke::CurvesGeometry::wrap(src_curves_id.geometry); + const bke::CurvesGeometry &src_curves = src_curves_id.geometry.wrap(); if (src_curves.is_single_type(dst_type)) { return; } @@ -62,7 +62,7 @@ static void node_geo_exec(GeoNodeExecParams params) if (geometry::try_curves_conversion_in_place( selection, dst_type, [&]() -> bke::CurvesGeometry & { - return bke::CurvesGeometry::wrap(geometry_set.get_curves_for_write()->geometry); + return geometry_set.get_curves_for_write()->geometry.wrap(); })) { return; } 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 479fdef56e7..8c23b83b5c3 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_subdivide.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_subdivide.cc @@ -37,7 +37,7 @@ static void node_geo_exec(GeoNodeExecParams params) } const Curves &src_curves_id = *geometry_set.get_curves_for_read(); - const bke::CurvesGeometry &src_curves = bke::CurvesGeometry::wrap(src_curves_id.geometry); + const bke::CurvesGeometry &src_curves = src_curves_id.geometry.wrap(); bke::CurvesFieldContext field_context{src_curves, ATTR_DOMAIN_POINT}; fn::FieldEvaluator evaluator{field_context, src_curves.points_num()}; diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_to_mesh.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_to_mesh.cc index 0b46fe569d1..54274f35305 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_to_mesh.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_to_mesh.cc @@ -34,15 +34,12 @@ static void geometry_set_curve_to_mesh(GeometrySet &geometry_set, GeometryComponentEditData::remember_deformed_curve_positions_if_necessary(geometry_set); if (profile_curves == nullptr) { - Mesh *mesh = bke::curve_to_wire_mesh(bke::CurvesGeometry::wrap(curves.geometry), - propagation_info); + Mesh *mesh = bke::curve_to_wire_mesh(curves.geometry.wrap(), propagation_info); geometry_set.replace_mesh(mesh); } else { - Mesh *mesh = bke::curve_to_mesh_sweep(bke::CurvesGeometry::wrap(curves.geometry), - bke::CurvesGeometry::wrap(profile_curves->geometry), - fill_caps, - propagation_info); + Mesh *mesh = bke::curve_to_mesh_sweep( + curves.geometry.wrap(), profile_curves->geometry.wrap(), fill_caps, propagation_info); geometry_set.replace_mesh(mesh); } } diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc index f17c8044995..4e535e83036 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc @@ -129,8 +129,7 @@ static void node_geo_exec(GeoNodeExecParams params) Field count = params.extract_input>("Count"); geometry_set.modify_geometry_sets([&](GeometrySet &geometry) { if (const Curves *src_curves_id = geometry.get_curves_for_read()) { - const bke::CurvesGeometry &src_curves = bke::CurvesGeometry::wrap( - src_curves_id->geometry); + const bke::CurvesGeometry &src_curves = src_curves_id->geometry.wrap(); bke::CurvesGeometry dst_curves = geometry::resample_to_count( src_curves, fn::make_constant_field(true), count, resample_attributes); PointCloud *pointcloud = pointcloud_from_curves(std::move(dst_curves), @@ -147,8 +146,7 @@ static void node_geo_exec(GeoNodeExecParams params) Field length = params.extract_input>("Length"); geometry_set.modify_geometry_sets([&](GeometrySet &geometry) { if (const Curves *src_curves_id = geometry.get_curves_for_read()) { - const bke::CurvesGeometry &src_curves = bke::CurvesGeometry::wrap( - src_curves_id->geometry); + const bke::CurvesGeometry &src_curves = src_curves_id->geometry.wrap(); bke::CurvesGeometry dst_curves = geometry::resample_to_length( src_curves, fn::make_constant_field(true), length, resample_attributes); PointCloud *pointcloud = pointcloud_from_curves(std::move(dst_curves), @@ -164,8 +162,7 @@ static void node_geo_exec(GeoNodeExecParams params) case GEO_NODE_CURVE_RESAMPLE_EVALUATED: geometry_set.modify_geometry_sets([&](GeometrySet &geometry) { if (const Curves *src_curves_id = geometry.get_curves_for_read()) { - const bke::CurvesGeometry &src_curves = bke::CurvesGeometry::wrap( - src_curves_id->geometry); + const bke::CurvesGeometry &src_curves = src_curves_id->geometry.wrap(); bke::CurvesGeometry dst_curves = geometry::resample_to_evaluated( src_curves, fn::make_constant_field(true), resample_attributes); PointCloud *pointcloud = pointcloud_from_curves(std::move(dst_curves), 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 56912931571..852c5867eed 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc @@ -119,7 +119,7 @@ static void geometry_set_curve_trim(GeometrySet &geometry_set, return; } const Curves &src_curves_id = *geometry_set.get_curves_for_read(); - const bke::CurvesGeometry &src_curves = bke::CurvesGeometry::wrap(src_curves_id.geometry); + const bke::CurvesGeometry &src_curves = src_curves_id.geometry.wrap(); if (src_curves.curves_num() == 0) { return; } diff --git a/source/blender/nodes/geometry/nodes/node_geo_deform_curves_on_surface.cc b/source/blender/nodes/geometry/nodes/node_geo_deform_curves_on_surface.cc index 4de87ba775b..deace5db4e8 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_deform_curves_on_surface.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_deform_curves_on_surface.cc @@ -278,7 +278,7 @@ static void node_geo_exec(GeoNodeExecParams params) const AttributeAccessor mesh_attributes_orig = surface_mesh_orig->attributes(); Curves &curves_id = *curves_geometry.get_curves_for_write(); - CurvesGeometry &curves = CurvesGeometry::wrap(curves_id.geometry); + CurvesGeometry &curves = curves_id.geometry.wrap(); if (!mesh_attributes_eval.contains(uv_map_name)) { pass_through_input(); @@ -383,7 +383,7 @@ static void node_geo_exec(GeoNodeExecParams params) {}, invalid_uv_count); /* Then also deform edit curve information for use in sculpt mode. */ - const CurvesGeometry &curves_orig = CurvesGeometry::wrap(edit_hints->curves_id_orig.geometry); + const CurvesGeometry &curves_orig = edit_hints->curves_id_orig.geometry.wrap(); const VArraySpan surface_uv_coords_orig = curves_orig.attributes().lookup_or_default( "surface_uv_coordinate", ATTR_DOMAIN_CURVE, float2(0)); if (!surface_uv_coords_orig.is_empty()) { diff --git a/source/blender/nodes/geometry/nodes/node_geo_delete_geometry.cc b/source/blender/nodes/geometry/nodes/node_geo_delete_geometry.cc index 7bb6b50fe18..912e846a3b9 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_delete_geometry.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_delete_geometry.cc @@ -293,7 +293,7 @@ static void delete_curves_selection(GeometrySet &geometry_set, const bke::AnonymousAttributePropagationInfo &propagation_info) { const Curves &src_curves_id = *geometry_set.get_curves_for_read(); - const bke::CurvesGeometry &src_curves = bke::CurvesGeometry::wrap(src_curves_id.geometry); + const bke::CurvesGeometry &src_curves = src_curves_id.geometry.wrap(); const int domain_size = src_curves.attributes().domain_size(selection_domain); bke::CurvesFieldContext field_context{src_curves, selection_domain}; @@ -311,7 +311,7 @@ static void delete_curves_selection(GeometrySet &geometry_set, CurveComponent &component = geometry_set.get_component_for_write(); Curves &curves_id = *component.get_for_write(); - bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id.geometry); + bke::CurvesGeometry &curves = curves_id.geometry.wrap(); if (selection_domain == ATTR_DOMAIN_POINT) { curves.remove_points(selection, propagation_info); diff --git a/source/blender/nodes/geometry/nodes/node_geo_duplicate_elements.cc b/source/blender/nodes/geometry/nodes/node_geo_duplicate_elements.cc index 90f089ae3df..586b14ff29f 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_duplicate_elements.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_duplicate_elements.cc @@ -330,7 +330,7 @@ static void duplicate_curves(GeometrySet &geometry_set, GeometryComponentEditData::remember_deformed_curve_positions_if_necessary(geometry_set); const Curves &curves_id = *geometry_set.get_curves_for_read(); - const bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id.geometry); + const bke::CurvesGeometry &curves = curves_id.geometry.wrap(); bke::CurvesFieldContext field_context{curves, ATTR_DOMAIN_CURVE}; FieldEvaluator evaluator{field_context, curves.curves_num()}; @@ -363,7 +363,7 @@ static void duplicate_curves(GeometrySet &geometry_set, Curves *new_curves_id = bke::curves_new_nomain(dst_points_num, dst_curves_num); bke::curves_copy_parameters(curves_id, *new_curves_id); - bke::CurvesGeometry &new_curves = bke::CurvesGeometry::wrap(new_curves_id->geometry); + bke::CurvesGeometry &new_curves = new_curves_id->geometry.wrap(); MutableSpan all_dst_offsets = new_curves.offsets_for_write(); threading::parallel_for(selection.index_range(), 512, [&](IndexRange range) { @@ -811,7 +811,7 @@ static void duplicate_points_curve(GeometrySet &geometry_set, const AnonymousAttributePropagationInfo &propagation_info) { const Curves &src_curves_id = *geometry_set.get_curves_for_read(); - const bke::CurvesGeometry &src_curves = bke::CurvesGeometry::wrap(src_curves_id.geometry); + const bke::CurvesGeometry &src_curves = src_curves_id.geometry.wrap(); if (src_curves.points_num() == 0) { return; } @@ -833,7 +833,7 @@ static void duplicate_points_curve(GeometrySet &geometry_set, Curves *new_curves_id = bke::curves_new_nomain(dst_num, dst_num); bke::curves_copy_parameters(src_curves_id, *new_curves_id); - bke::CurvesGeometry &new_curves = bke::CurvesGeometry::wrap(new_curves_id->geometry); + bke::CurvesGeometry &new_curves = new_curves_id->geometry.wrap(); MutableSpan new_curve_offsets = new_curves.offsets_for_write(); for (const int i : new_curves.curves_range()) { new_curve_offsets[i] = i; diff --git a/source/blender/nodes/geometry/nodes/node_geo_interpolate_curves.cc b/source/blender/nodes/geometry/nodes/node_geo_interpolate_curves.cc index dc3b24e4fae..48ffd5a6996 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_interpolate_curves.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_interpolate_curves.cc @@ -660,7 +660,7 @@ static GeometrySet generate_interpolated_curves( const AutoAnonymousAttributeID &index_attribute_id, const AutoAnonymousAttributeID &weight_attribute_id) { - const bke::CurvesGeometry &guide_curves = bke::CurvesGeometry::wrap(guide_curves_id.geometry); + const bke::CurvesGeometry &guide_curves = guide_curves_id.geometry.wrap(); const MultiValueMap guides_by_group = separate_guides_by_group(guide_group_ids); const Map points_per_curve_by_group = compute_points_per_curve_by_group( @@ -692,7 +692,7 @@ static GeometrySet generate_interpolated_curves( all_neighbor_counts); Curves *child_curves_id = bke::curves_new_nomain(0, num_child_curves); - bke::CurvesGeometry &child_curves = bke::CurvesGeometry::wrap(child_curves_id->geometry); + bke::CurvesGeometry &child_curves = child_curves_id->geometry.wrap(); MutableSpan children_curve_offsets = child_curves.offsets_for_write(); Array use_direct_interpolation_per_child(num_child_curves); @@ -792,8 +792,7 @@ static void node_geo_exec(GeoNodeExecParams params) const Curves &guide_curves_id = *guide_curves_geometry.get_curves_for_read(); - bke::CurvesFieldContext curves_context{bke::CurvesGeometry::wrap(guide_curves_id.geometry), - ATTR_DOMAIN_CURVE}; + bke::CurvesFieldContext curves_context{guide_curves_id.geometry.wrap(), ATTR_DOMAIN_CURVE}; fn::FieldEvaluator curves_evaluator{curves_context, guide_curves_id.geometry.curve_num}; curves_evaluator.add(guides_up_field); curves_evaluator.add(guide_group_field); 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 3e5eb482d9f..dbf75f1c0b5 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 @@ -144,7 +144,7 @@ static void node_geo_exec(GeoNodeExecParams params) geometry_set.modify_geometry_sets([&](GeometrySet &geometry_set) { if (Curves *curves_id = geometry_set.get_curves_for_write()) { - bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id->geometry); + bke::CurvesGeometry &curves = curves_id->geometry.wrap(); has_curves = true; const AttributeAccessor attributes = curves.attributes(); if (!attributes.contains("handle_left") || !attributes.contains("handle_right")) { diff --git a/source/blender/nodes/geometry/nodes/node_geo_set_curve_normal.cc b/source/blender/nodes/geometry/nodes/node_geo_set_curve_normal.cc index 19e9d18dd54..a931312aa31 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_set_curve_normal.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_set_curve_normal.cc @@ -48,7 +48,7 @@ static void node_geo_exec(GeoNodeExecParams params) geometry_set.modify_geometry_sets([&](GeometrySet &geometry_set) { if (Curves *curves_id = geometry_set.get_curves_for_write()) { - bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id->geometry); + bke::CurvesGeometry &curves = curves_id->geometry.wrap(); set_normal_mode(curves, mode, selection_field); } }); diff --git a/source/blender/nodes/geometry/nodes/node_geo_set_curve_radius.cc b/source/blender/nodes/geometry/nodes/node_geo_set_curve_radius.cc index f03f5aa0413..83f490fa3da 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_set_curve_radius.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_set_curve_radius.cc @@ -46,7 +46,7 @@ static void node_geo_exec(GeoNodeExecParams params) geometry_set.modify_geometry_sets([&](GeometrySet &geometry_set) { if (Curves *curves_id = geometry_set.get_curves_for_write()) { - set_radius(bke::CurvesGeometry::wrap(curves_id->geometry), selection_field, radii_field); + set_radius(curves_id->geometry.wrap(), selection_field, radii_field); } }); diff --git a/source/blender/nodes/geometry/nodes/node_geo_set_curve_tilt.cc b/source/blender/nodes/geometry/nodes/node_geo_set_curve_tilt.cc index 2887800995f..0c4b21a38c3 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_set_curve_tilt.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_set_curve_tilt.cc @@ -42,7 +42,7 @@ static void node_geo_exec(GeoNodeExecParams params) geometry_set.modify_geometry_sets([&](GeometrySet &geometry_set) { if (Curves *curves_id = geometry_set.get_curves_for_write()) { - set_tilt(bke::CurvesGeometry::wrap(curves_id->geometry), selection_field, tilt_field); + set_tilt(curves_id->geometry.wrap(), selection_field, tilt_field); } }); diff --git a/source/blender/nodes/geometry/nodes/node_geo_set_position.cc b/source/blender/nodes/geometry/nodes/node_geo_set_position.cc index 4f6a256620a..2f13bc1f591 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_set_position.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_set_position.cc @@ -52,7 +52,7 @@ static void set_computed_position_and_offset(GeometryComponent &component, if (attributes.contains("handle_right") && attributes.contains("handle_left")) { CurveComponent &curve_component = static_cast(component); Curves &curves_id = *curve_component.get_for_write(); - bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id.geometry); + bke::CurvesGeometry &curves = curves_id.geometry.wrap(); SpanAttributeWriter handle_right_attribute = attributes.lookup_or_add_for_write_span("handle_right", ATTR_DOMAIN_POINT); SpanAttributeWriter handle_left_attribute = diff --git a/source/blender/nodes/geometry/nodes/node_geo_set_spline_cyclic.cc b/source/blender/nodes/geometry/nodes/node_geo_set_spline_cyclic.cc index 962937b4aca..f625e66c4ef 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_set_spline_cyclic.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_set_spline_cyclic.cc @@ -42,7 +42,7 @@ static void node_geo_exec(GeoNodeExecParams params) geometry_set.modify_geometry_sets([&](GeometrySet &geometry_set) { if (Curves *curves_id = geometry_set.get_curves_for_write()) { - set_cyclic(bke::CurvesGeometry::wrap(curves_id->geometry), selection_field, cyclic_field); + set_cyclic(curves_id->geometry.wrap(), selection_field, cyclic_field); } }); diff --git a/source/blender/nodes/geometry/nodes/node_geo_set_spline_resolution.cc b/source/blender/nodes/geometry/nodes/node_geo_set_spline_resolution.cc index df9363c233c..b695b042da2 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_set_spline_resolution.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_set_spline_resolution.cc @@ -44,7 +44,7 @@ static void node_geo_exec(GeoNodeExecParams params) geometry_set.modify_geometry_sets([&](GeometrySet &geometry_set) { if (Curves *curves_id = geometry_set.get_curves_for_write()) { - set_resolution(bke::CurvesGeometry::wrap(curves_id->geometry), selection, resolution); + set_resolution(curves_id->geometry.wrap(), selection, resolution); } }); diff --git a/source/blender/nodes/geometry/nodes/node_geo_string_to_curves.cc b/source/blender/nodes/geometry/nodes/node_geo_string_to_curves.cc index 5eb98fe8f01..4d6b1bb0bc4 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_string_to_curves.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_string_to_curves.cc @@ -301,7 +301,7 @@ static Map create_curve_instances(GeoNodeExecParams ¶ms, continue; } - bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id->geometry); + bke::CurvesGeometry &curves = curves_id->geometry.wrap(); BKE_nurbList_free(&cu.nurb); float4x4 size_matrix = float4x4::identity(); diff --git a/source/blender/nodes/geometry/nodes/node_geo_transform_geometry.cc b/source/blender/nodes/geometry/nodes/node_geo_transform_geometry.cc index 123b02daf02..29eb19d0b9b 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_transform_geometry.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_transform_geometry.cc @@ -194,7 +194,7 @@ static void translate_geometry_set(GeoNodeExecParams ¶ms, const Depsgraph &depsgraph) { if (Curves *curves = geometry.get_curves_for_write()) { - bke::CurvesGeometry::wrap(curves->geometry).translate(translation); + curves->geometry.wrap().translate(translation); } if (Mesh *mesh = geometry.get_mesh_for_write()) { translate_mesh(*mesh, translation); @@ -219,7 +219,7 @@ void transform_geometry_set(GeoNodeExecParams ¶ms, const Depsgraph &depsgraph) { if (Curves *curves = geometry.get_curves_for_write()) { - bke::CurvesGeometry::wrap(curves->geometry).transform(transform); + curves->geometry.wrap().transform(transform); } if (Mesh *mesh = geometry.get_mesh_for_write()) { transform_mesh(*mesh, transform);