14using bke::AttributeMetaData;
15using bke::GeometryComponent;
16using bke::GeometrySet;
34 *meta_data_final = {iter.domain, iter.data_type};
38 {meta_data_final->data_type, iter.
data_type});
40 {meta_data_final->domain, iter.
domain});
54 const CPPType *cpp_type = bke::custom_data_type_to_cpp_type(data_type);
59 const int domain_num = component->attribute_domain_size(domain);
60 if (domain_num == 0) {
63 GVArray read_attribute = *component->attributes()->lookup_or_default(
64 attribute_id, domain, data_type,
nullptr);
67 const void *src_buffer = src_span.data();
68 void *dst_buffer = dst_span[offset];
87 result.attributes_for_write()->lookup_or_add_for_write_only_span(
89 if (!write_attribute) {
104 offsets_data[i] = src_component.get()->instances_num();
106 const OffsetIndices offsets = offset_indices::accumulate_counts_to_offsets(offsets_data);
108 std::unique_ptr<bke::Instances> dst_instances = std::make_unique<bke::Instances>();
111 MutableSpan<int> all_handles = dst_instances->reference_handles_for_write();
121 for (
const int src_handle : src_references.
index_range()) {
124 src_reference, [&]() {
return dst_instances->add_new_reference(src_reference); });
130 array_utils::gather(handle_map.
as_span(), src_handles, all_handles.
slice(dst_range));
133 result.replace_instances(dst_instances.release());
151 for (
const GeometrySet &geometry_set : src_geometry_sets) {
153 if (component !=
nullptr && !component->
is_empty()) {
154 components.append(component);
158 if (components.is_empty()) {
161 if (components.size() == 1) {
162 result.add(*components.first());
166 switch (component_type) {
167 case bke::GeometryComponent::Type::Instance:
170 case bke::GeometryComponent::Type::Volume:
177 std::unique_ptr<bke::Instances> instances = std::make_unique<bke::Instances>();
178 instances->resize(components.size());
179 instances->transforms_for_write().fill(float4x4::identity());
182 for (
const int i : components.index_range()) {
186 tmp_geo.
add(*components[i]);
192 options.keep_original_ids =
true;
193 options.realize_instance_attributes =
false;
194 options.attribute_filter = attribute_filter;
196 GeometrySet::from_instances(instances.release()),
options);
206 result.
name = geometries.is_empty() ?
"" : geometries[0].name;
208 {GeometryComponent::Type::Mesh,
209 GeometryComponent::Type::PointCloud,
210 GeometryComponent::Type::Instance,
211 GeometryComponent::Type::Volume,
212 GeometryComponent::Type::Curve,
213 GeometryComponent::Type::GreasePencil,
214 GeometryComponent::Type::Edit});
217 *component_types_to_join :
Span< T > as_span() const
void copy_assign_n(const void *src, void *dst, int64_t n) const
Value & lookup_or_add_cb(const Key &key, const CreateValueF &create_value)
ItemIterator items() const
auto add_or_modify(const Key &key, const CreateValueF &create_value, const ModifyValueF &modify_value) -> decltype(create_value(nullptr))
constexpr MutableSpan slice(const int64_t start, const int64_t size) const
constexpr int64_t size() const
constexpr IndexRange index_range() const
constexpr bool contains(const T &value) const
eCustomDataType data_type
virtual bool is_empty() const
Span< int > reference_handles() const
Span< InstanceReference > references() const
CCL_NAMESPACE_BEGIN struct Options options
eCustomDataType attribute_data_type_highest_complexity(Span< eCustomDataType > data_types)
AttrDomain attribute_domain_highest_priority(Span< AttrDomain > domains)
static void fill_new_attribute(const Span< const GeometryComponent * > src_components, const StringRef attribute_id, const eCustomDataType data_type, const bke::AttrDomain domain, GMutableSpan dst_span)
static void join_instances(const Span< const GeometryComponent * > src_components, GeometrySet &result)
static void join_volumes(const Span< const GeometryComponent * >, GeometrySet &)
void join_attributes(const Span< const bke::GeometryComponent * > src_components, bke::GeometryComponent &r_result, const Span< StringRef > ignored_attributes={})
static void join_component_type(const bke::GeometryComponent::Type component_type, const Span< GeometrySet > src_geometry_sets, const bke::AttributeFilter &attribute_filter, GeometrySet &result)
bke::GeometrySet join_geometries(Span< bke::GeometrySet > geometries, const bke::AttributeFilter &attribute_filter, const std::optional< Span< bke::GeometryComponent::Type > > &component_types_to_join=std::nullopt)
static Map< StringRef, AttributeMetaData > get_final_attribute_info(const Span< const GeometryComponent * > components, const Span< StringRef > ignored_attributes)
bke::GeometrySet realize_instances(bke::GeometrySet geometry_set, const RealizeInstancesOptions &options)
GeometryComponent & get_component_for_write(GeometryComponent::Type component_type)
void add(const GeometryComponent &component)