diff options
Diffstat (limited to 'source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc')
-rw-r--r-- | source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc | 21 |
1 files changed, 11 insertions, 10 deletions
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 7d83b4b3ecb..fd75855bddb 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 @@ -126,19 +126,18 @@ static GMutableSpan ensure_point_attribute(PointCloudComponent &points, const AttributeIDRef &attribute_id, const eCustomDataType data_type) { - points.attribute_try_create(attribute_id, ATTR_DOMAIN_POINT, data_type, AttributeInitDefault()); - WriteAttributeLookup attribute = points.attribute_try_get_for_write(attribute_id); - BLI_assert(attribute); - return attribute.varray.get_internal_span(); + return points.attributes_for_write() + ->lookup_or_add_for_write(attribute_id, ATTR_DOMAIN_POINT, data_type) + .varray.get_internal_span(); } template<typename T> static MutableSpan<T> ensure_point_attribute(PointCloudComponent &points, const AttributeIDRef &attribute_id) { - GMutableSpan attribute = ensure_point_attribute( - points, attribute_id, bke::cpp_type_to_custom_data_type(CPPType::get<T>())); - return attribute.typed<T>(); + return points.attributes_for_write() + ->lookup_or_add_for_write<T>(attribute_id, ATTR_DOMAIN_POINT) + .varray.get_internal_span(); } namespace { @@ -317,9 +316,11 @@ static void node_geo_exec(GeoNodeExecParams params) attribute_outputs.normal_id = StrongAnonymousAttributeID("Normal"); attribute_outputs.rotation_id = StrongAnonymousAttributeID("Rotation"); + GeometryComponentEditData::remember_deformed_curve_positions_if_necessary(geometry_set); + geometry_set.modify_geometry_sets([&](GeometrySet &geometry_set) { if (!geometry_set.has_curves()) { - geometry_set.keep_only({GEO_COMPONENT_TYPE_INSTANCES}); + geometry_set.remove_geometry_during_modify(); return; } const std::unique_ptr<CurveEval> curve = curves_to_curve_eval( @@ -330,7 +331,7 @@ static void node_geo_exec(GeoNodeExecParams params) const Array<int> offsets = calculate_spline_point_offsets(params, mode, *curve, splines); const int total_num = offsets.last(); if (total_num == 0) { - geometry_set.keep_only({GEO_COMPONENT_TYPE_INSTANCES}); + geometry_set.remove_geometry_during_modify(); return; } @@ -356,7 +357,7 @@ static void node_geo_exec(GeoNodeExecParams params) point_attributes.tangents, point_attributes.normals, point_attributes.rotations); } - geometry_set.keep_only({GEO_COMPONENT_TYPE_INSTANCES, GEO_COMPONENT_TYPE_POINT_CLOUD}); + geometry_set.keep_only_during_modify({GEO_COMPONENT_TYPE_POINT_CLOUD}); }); params.set_output("Points", std::move(geometry_set)); |