This introduces the concept of an #AttributeFilter. It's used to tell a geometry algorithm which attributes it should process/propagate and which can be ignored. We already had something similar before named `AnonymousAttributePropagationInfo`. However, as the name implies, this was specific to anonymous attributes. This had some downsides: * A lot of code had to be aware of the concept of anonymous attributes even if it did nothing special with anonymous attributes. * For non-anonymous attributes we often had a separate `Set<std::string> skip` parameter. It's not nice to have to pass two kinds of filters around and to have to construct a `Set<std::string>` in many cases. `AttributeFilter` solves both of these downsides. Technically, `AttributeFilter` could also just be a `FunctionRef<bool(StringRef attribute_name)>`, but that also has some issues: * The `bool` return value is often ambiguous, i.e. it's not clear if it means that the attribute should be processed or not. Using an enum works better. * Passing function refs around and combining them works, but can very easily lead to dangling references. * The default value of a `FunctionRef` is "empty", i.e. it can't be called. It's generally more nice to not have a special case for the default value. Now the default `AttributeFilter` propagates all attributes without any extra handling on the call-site. Pull Request: https://projects.blender.org/blender/blender/pulls/127155
24 lines
847 B
C++
24 lines
847 B
C++
/* SPDX-FileCopyrightText: 2024 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
#pragma once
|
|
|
|
#include "BKE_curves.hh"
|
|
|
|
namespace blender::geometry {
|
|
|
|
/**
|
|
* Join each selected curve's end point with another curve's start point to form a single curve.
|
|
*
|
|
* \param connect_to_curve: Index of the curve to connect to, invalid indices are ignored
|
|
* (set to -1 to leave a curve disconnected).
|
|
* \param flip_direction: Flip direction of input curves.
|
|
*/
|
|
bke::CurvesGeometry curves_merge_endpoints(const bke::CurvesGeometry &src_curves,
|
|
Span<int> connect_to_curve,
|
|
Span<bool> flip_direction,
|
|
const bke::AttributeFilter &attribute_filter);
|
|
|
|
}; // namespace blender::geometry
|