14using bke::AttributeDomainAndType;
15using bke::GeometryComponent;
16using bke::GeometrySet;
48 const int domain_num = component->attribute_domain_size(domain);
49 if (domain_num == 0) {
52 GVArray read_attribute = *component->attributes()->lookup_or_default(
53 attribute_id, domain, data_type,
nullptr);
56 const void *src_buffer = src_span.
data();
57 void *dst_buffer = dst_span[offset];
71 for (
const int i : info.
names.index_range()) {
76 result.attributes_for_write()->lookup_or_add_for_write_only_span(
78 if (!write_attribute) {
88 const bool allow_merging_instance_references,
94 offsets_data[
i] = src_component.get()->instances_num();
98 std::unique_ptr<bke::Instances> dst_instances = std::make_unique<bke::Instances>();
101 MutableSpan<int> all_handles = dst_instances->reference_handles_for_write();
111 for (
const int src_handle : src_references.
index_range()) {
113 if (allow_merging_instance_references) {
114 handle_map[src_handle] = new_handle_by_src_reference_cache.
lookup_or_add_cb(
115 src_reference, [&]() {
return dst_instances->add_new_reference(src_reference); });
118 handle_map[src_handle] = dst_instances->add_new_reference(src_reference);
128 result.replace_instances(dst_instances.release());
143 const bool allow_merging_instance_references,
147 for (
const GeometrySet &geometry_set : src_geometry_sets) {
149 if (component !=
nullptr && !component->
is_empty()) {
150 components.
append(component);
157 if (components.
size() == 1) {
162 switch (component_type) {
163 case bke::GeometryComponent::Type::Instance:
166 case bke::GeometryComponent::Type::Volume:
173 std::unique_ptr<bke::Instances> instances = std::make_unique<bke::Instances>();
174 instances->resize(components.
size());
182 tmp_geo.
add(*components[
i]);
188 options.keep_original_ids =
true;
189 options.realize_instance_attributes =
false;
190 options.attribute_filter = attribute_filter;
200 const bool allow_merging_instance_references)
205 {GeometryComponent::Type::Mesh,
206 GeometryComponent::Type::PointCloud,
207 GeometryComponent::Type::Instance,
208 GeometryComponent::Type::Volume,
209 GeometryComponent::Type::Curve,
210 GeometryComponent::Type::GreasePencil,
211 GeometryComponent::Type::Edit});
214 *component_types_to_join :
220 type, geometries, attribute_filter, allow_merging_instance_references,
result);
Span< T > as_span() const
void copy_assign_n(const void *src, void *dst, int64_t n) const
const void * data() 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 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
virtual bool is_empty() const
Span< int > reference_handles() const
Span< InstanceReference > references() const
CCL_NAMESPACE_BEGIN struct Options options
void gather(const GVArray &src, const IndexMask &indices, GMutableSpan dst, int64_t grain_size=4096)
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 void fill_new_attribute(const Span< const GeometryComponent * > src_components, const StringRef attribute_id, const bke::AttrType data_type, const bke::AttrDomain domain, GMutableSpan dst_span)
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 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)
OffsetIndices< int > accumulate_counts_to_offsets(MutableSpan< int > counts_to_offsets, int start_offset=0)
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(Instances *instances, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
bke::GeometrySet geometry