18using bke::AttributeDomainAndType;
19using bke::GeometryComponent;
20using bke::GeometrySet;
52 const int domain_num = component->attribute_domain_size(domain);
53 if (domain_num == 0) {
56 GVArray read_attribute = *component->attributes()->lookup_or_default(
57 name, domain, data_type,
nullptr);
60 const void *src_buffer = src_span.
data();
61 void *dst_buffer = dst_span[offset];
83 const GPointer first_value = get_single_value(*src_components.
first());
95 for (
const int i : range) {
96 const GPointer value = get_single_value(*src_components[i]);
106 std::logical_and<bool>());
110 return dst_attributes.add(name, domain, data_type, bke::AttributeInitValue(first_value));
121 for (
const int i : info.
names.index_range()) {
126 src_components, name, meta_data.
domain, meta_data.
data_type, dst_attributes))
133 if (!write_attribute) {
143 const bool allow_merging_instance_references,
149 offsets_data[i] = src_component.get()->instances_num();
153 auto dst_instances = std::make_unique<bke::Instances>(offsets.
total_size());
155 MutableSpan<int> all_handles = dst_instances->reference_handles_for_write();
165 for (
const int src_handle : src_references.
index_range()) {
167 if (allow_merging_instance_references) {
168 handle_map[src_handle] = new_handle_by_src_reference_cache.
lookup_or_add_cb(
169 src_reference, [&]() {
return dst_instances->add_new_reference(src_reference); });
172 handle_map[src_handle] = dst_instances->add_new_reference(src_reference);
182 result.replace_instances(dst_instances.release());
197 const bool allow_merging_instance_references,
201 for (
const GeometrySet &geometry_set : src_geometry_sets) {
203 if (component !=
nullptr && !component->
is_empty()) {
204 components.
append(component);
211 if (components.
size() == 1) {
216 switch (component_type) {
217 case bke::GeometryComponent::Type::Instance:
220 case bke::GeometryComponent::Type::Volume:
227 auto instances = std::make_unique<bke::Instances>(components.
size());
235 tmp_geo.
add(*components[i]);
241 options.keep_original_ids =
true;
242 options.realize_instance_attributes =
false;
243 options.attribute_filter = attribute_filter;
253 const bool allow_merging_instance_references)
256 result.set_name(geometries.
is_empty() ?
"" : geometries[0].name());
257 for (
const GeometrySet &geometry_set : geometries) {
258 result.merge_bundle_from(geometry_set);
261 {GeometryComponent::Type::Mesh,
262 GeometryComponent::Type::PointCloud,
263 GeometryComponent::Type::Instance,
264 GeometryComponent::Type::Volume,
265 GeometryComponent::Type::Curve,
266 GeometryComponent::Type::GreasePencil,
267 GeometryComponent::Type::Edit});
270 *component_types_to_join :
276 type, geometries, attribute_filter, allow_merging_instance_references,
result);
Span< T > as_span() const
void copy_construct_n(const void *src, void *dst, int64_t n) const
bool is_equal(const void *a, const void *b) const
const CPPType * type() const
const void * data() const
CommonVArrayInfo common_info() const
const CPPType & type() const
constexpr IndexRange drop_front(int64_t n) const
Value & lookup_or_add_cb(const Key &key, const CreateValueF &create_value)
constexpr MutableSpan slice(const int64_t start, const int64_t size) const
constexpr const T & first() const
constexpr int64_t size() const
constexpr IndexRange index_range() const
constexpr bool is_empty() const
constexpr bool contains(const T &value) const
void append(const T &value)
IndexRange index_range() const
GAttributeReader lookup_or_default(StringRef name, AttrDomain domain, AttrType data_type, const void *default_value=nullptr) const
virtual bool is_empty() const
Span< int > reference_handles() const
Span< InstanceReference > references() const
GSpanAttributeWriter lookup_or_add_for_write_only_span(StringRef name, AttrDomain domain, AttrType data_type)
CCL_NAMESPACE_BEGIN struct Options options
void gather(const GVArray &src, const IndexMask &indices, GMutableSpan dst, exec_mode::Mode mode=exec_mode::parallel)
const CPPType & attribute_type_to_cpp_type(AttrType type)
static void join_instances(const Span< const GeometryComponent * > src_components, const bool allow_merging_instance_references, 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, bool allow_merging_instance_references=true)
static bool try_join_single_value_attribute(const Span< const GeometryComponent * > src_components, const StringRef name, const bke::AttrDomain domain, const bke::AttrType data_type, bke::MutableAttributeAccessor dst_attributes)
static void join_volumes(const Span< const GeometryComponent * >, GeometrySet &)
static GeometrySet::GatheredAttributes get_final_attribute_info(const Span< const GeometryComponent * > components, const Span< StringRef > ignored_attributes)
RealizeInstancesResult realize_instances(bke::GeometrySet geometry_set, const RealizeInstancesOptions &options)
static void join_component_type(const bke::GeometryComponent::Type component_type, const Span< GeometrySet > src_geometry_sets, const bke::AttributeFilter &attribute_filter, const bool allow_merging_instance_references, GeometrySet &result)
static void fill_new_attribute(const Span< const GeometryComponent * > src_components, const StringRef name, const bke::AttrType data_type, const bke::AttrDomain domain, GMutableSpan dst_span)
static void join_attributes(const Span< const GeometryComponent * > src_components, GeometryComponent &result, const Span< StringRef > ignored_attributes)
OffsetIndices< int > accumulate_counts_to_offsets(MutableSpan< int > counts_to_offsets, int start_offset=0)
Value parallel_reduce(IndexRange range, int64_t grain_size, const Value &identity, const Function &function, const Reduction &reduction)
static MatBase identity()
GeometryComponent & get_component_for_write(GeometryComponent::Type component_type)
void add(const GeometryComponent &component)
void add(const StringRef name, const AttributeDomainAndType &kind)
Vector< AttributeDomainAndType, 16 > kinds
VectorSet< StringRef, 16 > names
static GeometrySet from_instances(std::unique_ptr< Instances > instances)
bke::GeometrySet geometry