31using blender::bke::AttributeDomainAndType;
32using blender::bke::GSpanAttributeWriter;
33using blender::bke::InstanceReference;
34using blender::bke::Instances;
35using blender::bke::SpanAttributeWriter;
47 return this->kinds.
size();
391 src.type().copy_construct_n(src.slice(range).data(), dst.slice(range).data(), range.size());
399 value.type()->fill_construct_n(value.get(), dst.slice(range).data(), range.size());
404 const Span<std::optional<GVArraySpan>> src_attributes,
412 for (const int attribute_index : attribute_range) {
413 const bke::AttrDomain domain = ordered_attributes.kinds[attribute_index].domain;
414 const IndexRange element_slice = range_fn(domain);
416 GSpanAttributeWriter &writer = dst_attribute_writers[attribute_index];
420 GMutableSpan dst_span = writer.span.slice(element_slice);
421 if (src_attributes[attribute_index].has_value()) {
422 threaded_copy(*src_attributes[attribute_index], dst_span);
425 const CPPType &cpp_type = dst_span.type();
426 const void *fallback = attribute_fallbacks.array[attribute_index] == nullptr ?
427 cpp_type.default_value() :
428 attribute_fallbacks.array[attribute_index];
429 threaded_fill({cpp_type, fallback}, dst_span);
440 if (
options.keep_original_ids) {
451 for (const int i : range) {
452 dst_ids[i] = noise::hash(task_id, i);
458 for (const int i : range) {
459 dst_ids[i] = noise::hash(task_id, stored_ids[i]);
472 const int current_depth,
473 const int target_depth,
474 const bke::GeometrySet &geometry_set,
476 const InstanceContext &base_instance_context);
491 const int attribute_index = ordered_attributes.
ids.index_of_try(iter.
name);
492 if (attribute_index == -1) {
501 const bke::AttrType expected_type = ordered_attributes.
kinds[attribute_index].data_type;
511 std::unique_ptr<GArray<>> temporary_array = std::make_unique<GArray<>>(
514 span = temporary_array->as_span();
517 attributes_to_override.
append({attribute_index, span});
519 return attributes_to_override;
535 fn(geometry_set, base_transform,
id);
539 const int current_depth,
540 const int target_depth,
572 const bool is_top_level = current_depth == 0;
576 indices.foreach_index([&](
const int i) {
578 const int child_target_depth = is_top_level ? gather_info.
depths[
i] : target_depth;
585 for (
const std::pair<int, GSpan> &pair : pointcloud_attributes_to_override) {
588 for (
const std::pair<int, GSpan> &pair : mesh_attributes_to_override) {
589 instance_context.
meshes.
array[pair.first] = pair.second[
i];
591 for (
const std::pair<int, GSpan> &pair : curve_attributes_to_override) {
592 instance_context.
curves.
array[pair.first] = pair.second[
i];
594 for (
const std::pair<int, GSpan> &pair : grease_pencil_attributes_to_override) {
597 for (
const std::pair<int, GSpan> &pair : instance_attributes_to_override) {
601 uint32_t local_instance_id = 0;
603 if (stored_instance_ids.
is_empty()) {
604 local_instance_id = uint32_t(
i);
607 local_instance_id = uint32_t(stored_instance_ids[
i]);
610 const uint32_t instance_id =
noise::hash(base_instance_context.
id, local_instance_id);
619 instance_context.
id = id;
623 instance_geometry_set,
634 const int current_depth,
635 const int target_depth,
645 if (mesh !=
nullptr && mesh->
verts_num > 0) {
654 base_instance_context.
meshes,
655 base_instance_context.
id});
666 const PointCloud *pointcloud = pointcloud_component.get();
667 if (pointcloud !=
nullptr && pointcloud->
totpoint > 0) {
676 base_instance_context.
id});
683 const Curves *curves = curve_component.get();
693 base_instance_context.
curves,
694 base_instance_context.
id});
704 const GreasePencil *grease_pencil = grease_pencil_component.get();
705 if (grease_pencil !=
nullptr && !grease_pencil->layers().is_empty()) {
719 if (current_depth == target_depth) {
727 if (instances !=
nullptr && instances->
instances_num() > 0) {
733 base_instance_context);
751 if (edit_component->gizmo_edit_hints_ || edit_component->curves_edit_hints_) {
764 const int current_depth,
765 const std::optional<int> max_depth,
769 if (r_components.
add_as(component)) {
770 component->add_user();
773 if (current_depth == max_depth) {
777 if (!instances_component) {
784 if (
options.realize_instance_attributes) {
785 if (r_components.
add_as(instances_component)) {
786 instances_component->add_user();
793 reference_geometry, component_type,
options, current_depth + 1, max_depth, r_components);
805 if (r_components.
add_as(component)) {
806 component->add_user();
810 if (!instances_component) {
820 const int references_num = references.
size();
824 const int reference_i =
handles[instance_i];
825 const int instance_depth = varied_depth_option.
depths[instance_i];
826 std::optional<int> &max_depth = max_reference_depth[reference_i];
827 if (!max_depth.has_value()) {
835 max_depth = std::max<int>(*max_depth, instance_depth);
838 bool is_anything_realized =
false;
839 for (
const int reference_i :
IndexRange(references_num)) {
840 const std::optional<int> max_depth = max_reference_depth[reference_i];
841 if (max_depth == 0) {
848 reference_geometry, component_type,
options, 1, max_depth, r_components);
849 is_anything_realized =
true;
852 if (is_anything_realized) {
853 if (
options.realize_instance_attributes) {
854 if (r_components.
add_as(instances_component)) {
855 instances_component->add_user();
871 const int top_level_instances_num = top_level_instances_component ?
873 AttrDomain::Instance) :
879 varied_depth_option.
selection.
size() == top_level_instances_num)
903 if (
ELEM(iter.
name,
"instance_transform",
".reference_index")) {
919 dst_domain == AttrDomain::Instance)
923 dst_domain = AttrDomain::Layer;
927 dst_domain = AttrDomain::Point;
934 return attributes_to_propagate;
951 for (
const int i : attributes_to_propagate.
names.index_range()) {
952 if (attributes_to_propagate.
names[
i] ==
"id") {
955 ordered_attributes.
ids.add_new(attributes_to_propagate.
names[
i]);
956 ordered_attributes.
kinds.append(attributes_to_propagate.
kinds[
i]);
958 return ordered_attributes;
969 src_components.
size() == attribute_fallback.
size());
975 for (
const int component_index : src_components.
index_range()) {
977 *src_components[component_index]);
982 std::unique_ptr<bke::Instances> dst_instances = std::make_unique<bke::Instances>();
986 for (
const int attribute_index : all_instances_attributes.
index_range()) {
988 const StringRef id = all_instances_attributes.
ids[attribute_index];
990 dst_instances->attributes_for_write()
991 .lookup_or_add_for_write_only_span(
id, domain, type)
996 MutableSpan<int> all_handles = dst_instances->reference_handles_for_write();
998 for (
const int component_index : src_components.
index_range()) {
1000 *src_components[component_index]);
1002 const blender::float4x4 &src_base_transform = src_base_transforms[component_index];
1003 const Span<const void *> attribute_fallback_array = attribute_fallback[component_index].array;
1007 for (
const int src_handle : src_references.
index_range()) {
1008 handle_map[src_handle] = dst_instances->add_reference(src_references[src_handle]);
1010 const IndexRange dst_range = offsets[component_index];
1011 for (
const int attribute_index : all_instances_attributes.
index_range()) {
1012 const StringRef id = all_instances_attributes.
ids[attribute_index];
1013 const bke::AttrType type = all_instances_attributes.
kinds[attribute_index].data_type;
1016 dst_instances->attributes_for_write().lookup_for_write_span(
id);
1019 const void *attribute_ptr;
1020 if (attribute_fallback_array[attribute_index] !=
nullptr) {
1021 attribute_ptr = attribute_fallback_array[attribute_index];
1028 write_attribute.
finish();
1045 for_join_attributes.append(component.get());
1050 join_attributes(for_join_attributes, dst_component, {
".reference_index",
"instance_transform"});
1063 bool &r_create_radii,
1069 for (
const int i : attributes_to_propagate.
names.index_range()) {
1070 if (attributes_to_propagate.
names[
i] ==
"position") {
1073 if (attributes_to_propagate.
names[
i] ==
"id") {
1077 if (attributes_to_propagate.
names[
i] ==
"radius") {
1078 r_create_radii =
true;
1081 ordered_attributes.
ids.add_new(attributes_to_propagate.
names[
i]);
1082 ordered_attributes.
kinds.append(attributes_to_propagate.
kinds[
i]);
1084 return ordered_attributes;
1091 if (pointcloud->totpoint > 0) {
1092 r_pointclouds.
add(pointcloud);
1096 instances->foreach_referenced_geometry([&](
const bke::GeometrySet &instance_geometry_set) {
1109 varied_depth_option,
1115 for (
const int pointcloud_index : info.
realize_info.index_range()) {
1127 if (attributes.
contains(attribute_id)) {
1129 pointcloud_info.
attributes[attribute_index].emplace(std::move(attribute));
1181 BLI_assert(domain == bke::AttrDomain::Point);
1182 UNUSED_VARS_NDEBUG(domain);
1185 dst_attribute_writers);
1193 for (
const int attribute_index : ordered_attributes.
index_range()) {
1194 const void *value = attribute_fallbacks.
array[attribute_index];
1202 attributes.
add(ordered_attributes.
ids[attribute_index],
1219 if (tasks.
size() == 1) {
1224 new_points->tag_positions_changed();
1265 for (
const int attribute_index : ordered_attributes.
index_range()) {
1266 const StringRef attribute_id = ordered_attributes.
ids[attribute_index];
1274 for (const int task_index : task_range) {
1275 const RealizePointCloudTask &task = tasks[task_index];
1276 execute_realize_pointcloud_task(options,
1279 dst_attribute_writers,
1288 dst_attribute.finish();
1291 point_radii.finish();
1306 bool &r_create_material_index)
1311 for (
const int i : attributes_to_propagate.
names.index_range()) {
1321 if (attributes_to_propagate.
names[
i] ==
"id") {
1325 if (attributes_to_propagate.
names[
i] ==
"material_index") {
1326 r_create_material_index =
true;
1329 ordered_attributes.
ids.add_new(attributes_to_propagate.
names[
i]);
1330 ordered_attributes.
kinds.append(attributes_to_propagate.
kinds[
i]);
1332 return ordered_attributes;
1339 if (mesh->verts_num > 0) {
1344 instances->foreach_referenced_geometry([&](
const bke::GeometrySet &instance_geometry_set) {
1358 varied_depth_option,
1382 for (
const int mesh_index : info.
realize_info.index_range()) {
1384 const Mesh *mesh = info.
order[mesh_index];
1385 mesh_info.
mesh = mesh;
1386 mesh_info.
positions = mesh->vert_positions();
1387 mesh_info.
edges = mesh->edges();
1388 mesh_info.
faces = mesh->faces();
1412 if (attributes.
contains(attribute_id)) {
1414 mesh_info.
attributes[attribute_index].emplace(std::move(attribute));
1463 return mesh->runtime->loose_edges_cache.is_cached() && mesh->loose_edges().count == 0;
1467 return mesh->runtime->loose_verts_cache.is_cached() && mesh->loose_verts().count == 0;
1471 return mesh->no_overlapping_topology();
1491 const Mesh &mesh = *mesh_info.
mesh;
1513 for (const int i : edge_range) {
1514 dst_edges[i] = src_edges[i] + task.start_indices.vertex;
1518 for (const int i : loop_range) {
1519 dst_corner_verts[i] = src_corner_verts[i] + task.start_indices.vertex;
1522 threading::parallel_for(src_corner_edges.index_range(), 1024, [&](
const IndexRange loop_range) {
1523 for (const int i : loop_range) {
1524 dst_corner_edges[i] = src_corner_edges[i] + task.start_indices.edge;
1527 threading::parallel_for(src_faces.index_range(), 1024, [&](
const IndexRange face_range) {
1528 for (const int i : face_range) {
1529 dst_face_offsets[i] = src_faces[i].start() + task.start_indices.loop;
1532 if (!all_dst_material_indices.is_empty()) {
1533 const Span<int> material_index_map = mesh_info.material_index_map;
1535 if (mesh.totcol == 0) {
1537 dst_material_indices.
fill(material_index_map.
first());
1540 if (mesh_info.material_indices.is_single()) {
1541 const int src_index = mesh_info.material_indices.get_internal_single();
1543 dst_material_indices.
fill(valid ? material_index_map[src_index] : 0);
1546 VArraySpan<int> indices_span(mesh_info.material_indices);
1547 threading::parallel_for(src_faces.index_range(), 1024, [&](
const IndexRange face_range) {
1548 for (const int i : face_range) {
1549 const int src_index = indices_span[i];
1550 const bool valid = IndexRange(mesh.totcol).contains(src_index);
1551 dst_material_indices[i] = valid ? material_index_map[src_index] : 0;
1558 if (!all_dst_vertex_ids.is_empty()) {
1560 mesh_info.stored_vertex_ids,
1562 all_dst_vertex_ids.slice(task.start_indices.vertex, mesh.verts_num));
1565 const auto domain_to_range = [&](
const bke::AttrDomain domain) {
1567 case bke::AttrDomain::Point:
1568 return dst_vert_range;
1569 case bke::AttrDomain::Edge:
1570 return dst_edge_range;
1571 case bke::AttrDomain::Face:
1572 return dst_face_range;
1573 case bke::AttrDomain::Corner:
1574 return dst_loop_range;
1581 if (all_dst_custom_normals) {
1582 if (all_dst_custom_normals.span.type().is<
short2>()) {
1583 if (mesh_info.custom_normal.is_empty()) {
1584 all_dst_custom_normals.span.typed<
short2>().slice(dst_loop_range).fill(
short2(0));
1587 all_dst_custom_normals.span.typed<
short2>()
1588 .slice(dst_loop_range)
1589 .copy_from(mesh_info.custom_normal.typed<
short2>());
1593 const IndexRange dst_range = domain_to_range(all_dst_custom_normals.domain);
1596 all_dst_custom_normals.span.typed<
float3>().slice(dst_range));
1601 task.attribute_fallbacks,
1604 dst_attribute_writers);
1611 const int attribute_index = ordered_attributes.
ids.index_of_try(src_name);
1612 if (attribute_index == -1) {
1633 existing_names.
add(defgroup->name);
1635 for (
const Mesh *mesh : src_meshes) {
1637 if (existing_names.
contains(src->name)) {
1657 if (tasks.
size() == 1) {
1698 *dst_mesh, ordered_attributes, all_meshes_info.
order.
as_span().drop_front(1));
1703 Material *material = ordered_materials[
i];
1740 for (
const int attribute_index : ordered_attributes.
index_range()) {
1741 const StringRef attribute_id = ordered_attributes.
ids[attribute_index];
1744 dst_attribute_writers.
append(
1749 if (active_layer !=
nullptr) {
1757 if (render_layer !=
nullptr) {
1765 for (const int task_index : task_range) {
1766 const RealizeMeshTask &task = tasks[task_index];
1767 execute_realize_mesh_task(options,
1770 dst_attribute_writers,
1777 material_indices.span,
1784 dst_attribute.finish();
1786 vertex_ids.finish();
1787 material_indices.finish();
1788 custom_normals.finish();
1790 if (all_meshes_info.no_loose_edges_hint) {
1791 dst_mesh->tag_loose_edges_none();
1793 if (all_meshes_info.no_loose_verts_hint) {
1794 dst_mesh->tag_loose_verts_none();
1796 if (all_meshes_info.no_overlapping_hint) {
1797 dst_mesh->tag_overlapping_none();
1816 for (
const int i : attributes_to_propagate.
names.index_range()) {
1826 if (attributes_to_propagate.
names[
i] ==
"id") {
1830 ordered_attributes.
ids.add_new(attributes_to_propagate.
names[
i]);
1831 ordered_attributes.
kinds.append(attributes_to_propagate.
kinds[
i]);
1833 return ordered_attributes;
1840 if (curves->geometry.curve_num != 0) {
1841 r_curves.
add(curves);
1845 instances->foreach_referenced_geometry([&](
const bke::GeometrySet &instance_geometry_set) {
1861 for (
const int curve_index : info.
realize_info.index_range()) {
1863 const Curves *curves_id = info.
order[curve_index];
1865 curve_info.
curves = curves_id;
1874 if (attributes.
contains(attribute_id)) {
1876 curve_info.
attributes[attribute_index].emplace(std::move(attribute));
1888 if (attributes.
contains(
"radius")) {
1893 if (attributes.
contains(
"handle_right")) {
1895 .varray.get_internal_span();
1897 .varray.get_internal_span();
1900 if (attributes.
contains(
"custom_normal")) {
1902 .varray.get_internal_span();
1970 all_radii.
slice(dst_point_range).
fill(1.0f);
1984 all_custom_normals.
slice(dst_point_range));
1992 for (const int i : range) {
1993 dst_offsets[i] = task.start_indices.point + src_offsets[i];
1997 dst_curves.nurbs_custom_knots_for_write()
1998 .slice(dst_custom_knot_range)
1999 .copy_from(curves.nurbs_custom_knots());
2001 if (!all_dst_ids.is_empty()) {
2003 options, curves_info.stored_ids, task.id, all_dst_ids.slice(dst_point_range));
2006 copy_generic_attributes_to_result(
2007 curves_info.attributes,
2008 task.attribute_fallbacks,
2010 [&](
const bke::AttrDomain domain) {
2012 case bke::AttrDomain::Point:
2013 return IndexRange(task.start_indices.point, curves.points_num());
2014 case bke::AttrDomain::Curve:
2015 return IndexRange(task.start_indices.curve, curves.curves_num());
2017 BLI_assert_unreachable();
2018 return IndexRange();
2021 dst_attribute_writers);
2030 existing_names.
add(defgroup->name);
2032 for (
const Curves *src_curve : src_curves) {
2034 if (existing_names.
contains(src->name)) {
2038 existing_names.
add(src->name);
2054 if (tasks.
size() == 1) {
2062 new_curves->
geometry.wrap().attributes_for_write());
2073 r_result.
errors.
append(
RPT_(
"Realized curves data has too many elements."));
2080 if (custom_knot_num) {
2103 for (
const int attribute_index : ordered_attributes.
index_range()) {
2104 const StringRef attribute_id = ordered_attributes.
ids[attribute_index];
2107 dst_attribute_writers.
append(
2134 for (const int task_index : task_range) {
2135 const RealizeCurveTask &task = tasks[task_index];
2136 execute_realize_curve_task(options,
2141 dst_attribute_writers,
2146 custom_normal.span);
2151 dst_curves.runtime->type_counts.fill(0);
2152 for (
const RealizeCurveTask &task : tasks) {
2154 dst_curves.runtime->type_counts[
i] +=
2155 task.curve_info->curves->geometry.runtime->type_counts[
i];
2161 dst_attribute.finish();
2165 handle_left.finish();
2166 handle_right.finish();
2167 custom_normal.finish();
2184 for (
const int i : attributes_to_propagate.
names.index_range()) {
2185 ordered_attributes.
ids.add_new(attributes_to_propagate.
names[
i]);
2186 ordered_attributes.
kinds.append(attributes_to_propagate.
kinds[
i]);
2188 return ordered_attributes;
2195 if (!grease_pencil->layers().is_empty()) {
2196 r_grease_pencils.
add(grease_pencil);
2200 instances->foreach_referenced_geometry([&](
const bke::GeometrySet &instance_geometry_set) {
2213 geometry_set,
options, varied_depth_options);
2217 for (
const int grease_pencil_index : info.
realize_info.index_range()) {
2228 if (attributes.
contains(attribute_id)) {
2230 grease_pencil_info.
attributes[attribute_index].emplace(std::move(attribute));
2256 for (
const int layer_i : src_layers.
index_range()) {
2261 dst_layer.set_name(src_layer.name());
2272 dst_curves = src_curves;
2278 for (
int &material_index : material_indices.
span) {
2283 material_indices.
finish();
2291 BLI_assert(domain == bke::AttrDomain::Layer);
2292 UNUSED_VARS_NDEBUG(domain);
2293 return dst_layers_slice;
2295 dst_attribute_writers);
2302 layer->set_local_transform(
transform * layer->local_transform());
2317 if (tasks.
size() == 1) {
2331 r_result.
errors.
append(
RPT_(
"Realized grease pencil has too many layers."));
2338 *dst_grease_pencil);
2342 dst_grease_pencil->add_layers_with_empty_drawings_for_eval(new_layers_num);
2358 for (
const int attribute_index : ordered_attributes.
index_range()) {
2359 const StringRef attribute_id = ordered_attributes.
ids[attribute_index];
2367 for (const int task_index : task_range) {
2368 const RealizeGreasePencilTask &task = tasks[task_index];
2369 execute_realize_grease_pencil_task(
2370 task, ordered_attributes, *dst_grease_pencil, dst_attribute_writers);
2376 dst_attribute.finish();
2392 if (!component.curves_edit_hints_) {
2393 if (task.edit_data->curves_edit_hints_) {
2394 component.curves_edit_hints_ = std::make_unique<bke::CurvesEditHints>(
2395 *task.edit_data->curves_edit_hints_);
2398 if (
const bke::GizmoEditHints *src_gizmo_edit_hints = task.edit_data->gizmo_edit_hints_.get())
2400 if (!component.gizmo_edit_hints_) {
2401 component.gizmo_edit_hints_ = std::make_unique<bke::GizmoEditHints>();
2403 for (
auto item : src_gizmo_edit_hints->gizmo_transforms.items()) {
2404 component.gizmo_edit_hints_->gizmo_transforms.add(item.key, task.transform * item.value);
2425 if (reference.
type() == bke::InstanceReference::Type::GeometrySet) {
2442 inverse_selection_indices);
2444 if (inverse_selection.
is_empty()) {
2448 std::unique_ptr<Instances> new_instances = std::make_unique<Instances>(instances);
2449 new_instances->remove(inverse_selection, attribute_filter);
2460 return {geometry_set};
2482 return {geometry_set};
2487 geometry_set, varied_depth_option.
selection, not_to_realize_set,
options.attribute_filter);
2489 if (
options.keep_original_ids) {
2494 geometry_set,
options, varied_depth_option);
2498 geometry_set,
options, varied_depth_option);
2500 geometry_set,
options, varied_depth_option);
2509 all_grease_pencils_info,
2510 all_instance_attributes,
2511 create_id_attribute,
2513 varied_depth_option.
depths,
2534 all_instance_attributes,
2541 const int64_t approximate_used_bytes_num = total_points_num * 32;
2545 all_pointclouds_info,
struct Curves * BKE_curves_copy_for_eval(const struct Curves *curves_src)
Low-level operations for curves.
CustomData interface, see also DNA_customdata_types.h.
int CustomData_get_named_layer(const CustomData *data, eCustomDataType type, blender::StringRef name)
void CustomData_set_layer_render(CustomData *data, eCustomDataType type, int n)
const char * CustomData_get_render_layer_name(const CustomData *data, eCustomDataType type)
const char * CustomData_get_active_layer_name(const CustomData *data, eCustomDataType type)
void CustomData_set_layer_active(CustomData *data, eCustomDataType type, int n)
Low-level operations for grease pencil.
void BKE_grease_pencil_copy_parameters(const GreasePencil &src, GreasePencil &dst)
GreasePencil * BKE_grease_pencil_new_nomain()
void BKE_grease_pencil_copy_layer_parameters(const blender::bke::greasepencil::Layer &src, blender::bke::greasepencil::Layer &dst)
GreasePencil * BKE_grease_pencil_copy_for_eval(const GreasePencil *grease_pencil_src)
General operations, lookup, etc. for materials.
void BKE_id_material_eval_assign(ID *id, int slot, Material *material)
void BKE_mesh_copy_parameters_for_eval(Mesh *me_dst, const Mesh *me_src)
Mesh * BKE_mesh_new_nomain(int verts_num, int edges_num, int faces_num, int corners_num)
Mesh * BKE_mesh_copy_for_eval(const Mesh &source)
General operations for point clouds.
PointCloud * BKE_pointcloud_copy_for_eval(const PointCloud *pointcloud_src)
PointCloud * BKE_pointcloud_new_nomain(int totpoint)
#define BLI_assert_unreachable()
#define LISTBASE_FOREACH(type, var, list)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
int BLI_listbase_count(const ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
ATTR_WARN_UNUSED_RESULT const size_t num
Object is a sort of wrapper for general info.
SIMD_FORCE_INLINE btVector3 transform(const btVector3 &point) const
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
IndexRange index_range() const
void reinitialize(const int64_t new_size)
constexpr bool contains(int64_t value) const
constexpr MutableSpan slice(const int64_t start, const int64_t size) const
constexpr void fill(const T &value) const
constexpr T & last(const int64_t n=0) const
constexpr const T & first() const
constexpr bool is_empty() const
static VArray from_single(T value, const int64_t size)
static VArray from_span(Span< T > values)
int64_t index_of_or_add(const Key &key)
const Key * begin() const
int64_t index_of(const Key &key) const
Span< Key > as_span() const
void append(const T &value)
Span< T > as_span() const
void fill_assign_n(const void *value, void *dst, int64_t n) const
const void * default_value() const
GMutableSpan slice(const int64_t start, int64_t size) const
const CPPType & type() const
const CPPType * type() const
const CPPType & type() const
GSpan get_internal_span() const
const CPPType & type() const
static GVArray from_single(const CPPType &type, int64_t size, const void *value)
constexpr int64_t size() const
constexpr MutableSpan slice(const int64_t start, const int64_t size) const
constexpr bool is_empty() const
constexpr void fill(const T &value) const
constexpr IndexRange index_range() const
constexpr void copy_from(Span< T > values) const
bool add_as(ForwardKey &&key)
bool contains(const Key &key) const
constexpr const T & first() const
constexpr int64_t size() const
constexpr IndexRange index_range() const
constexpr bool is_empty() const
void copy_utf8_truncated(char *dst, int64_t dst_size) const
std::optional< T > get_if_single() const
void materialize(MutableSpan< T > r_span) const
Span< T > get_internal_span() const
void append(const T &value)
IndexRange index_range() const
GAttributeReader lookup_or_default(StringRef attribute_id, AttrDomain domain, AttrType data_type, const void *default_value=nullptr) const
bool is_builtin(const StringRef attribute_id) const
void foreach_attribute(const FunctionRef< void(const AttributeIter &)> fn) const
GPointer get_builtin_default(const StringRef attribute_id) const
bool contains(StringRef attribute_id) const
GAttributeReader lookup(const StringRef attribute_id) const
int domain_size(const AttrDomain domain) const
GAttributeReader get() const
MutableSpan< float3 > positions_for_write()
IndexRange curves_range() const
MutableAttributeAccessor attributes_for_write()
void nurbs_custom_knots_resize(int knots_num)
Span< int > offsets() const
Span< float3 > positions() const
AttributeAccessor attributes() const
MutableSpan< int > offsets_for_write()
OffsetIndices< int > nurbs_custom_knots_by_curve() const
void convert_to_initialized_n(GSpan from_span, GMutableSpan to_span) const
bool is_convertible(const CPPType &from_type, const CPPType &to_type) const
int attribute_domain_size(AttrDomain domain) const
void to_geometry_set(GeometrySet &r_geometry_set) const
GeometrySet & geometry_set()
const Instances * get() const
GeometryComponentPtr copy() const override
void replace(Instances *instances, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
Span< int > reference_handles() const
Span< float4x4 > transforms() const
Span< InstanceReference > references() const
bke::MutableAttributeAccessor attributes_for_write()
bke::AttributeAccessor attributes() const
MutableSpan< InstanceReference > references_for_write()
int instances_num() const
void ensure_geometry_instances()
bool add(const StringRef attribute_id, const AttrDomain domain, const AttrType data_type, const AttributeInit &initializer)
GSpanAttributeWriter lookup_or_add_for_write_span(StringRef attribute_id, AttrDomain domain, AttrType data_type, const AttributeInit &initializer=AttributeInitDefaultValue())
bool remove(const StringRef attribute_id)
GSpanAttributeWriter lookup_or_add_for_write_only_span(StringRef attribute_id, AttrDomain domain, AttrType data_type)
bke::CurvesGeometry & strokes_for_write()
const bke::CurvesGeometry & strokes() const
void set_local_transform(const float4x4 &transform)
float4x4 local_transform() const
std::optional< bke::AttrDomain > result_domain
void add_mesh(const Mesh &mesh)
IndexMask complement(const IndexMask &universe, IndexMaskMemory &memory) const
void foreach_index(Fn &&fn) const
CCL_NAMESPACE_BEGIN struct Options options
VecBase< short, 2 > short2
VecBase< float, 3 > float3
void * MEM_calloc_arrayN(size_t len, size_t size, const char *str)
void * MEM_callocN(size_t len, const char *str)
void * MEM_dupallocN(const void *vmemh)
void copy(const GVArray &src, GMutableSpan dst, int64_t grain_size=4096)
void gather(const GVArray &src, const IndexMask &indices, GMutableSpan dst, int64_t grain_size=4096)
bool is_corner_fan_normals(const AttributeMetaData &meta_data)
void curves_copy_parameters(const Curves &src, Curves &dst)
ImplicitSharingPtr< GeometryComponent > GeometryComponentPtr
const DataTypeConversions & get_implicit_type_conversions()
bool attribute_is_builtin_on_component_type(const GeometryComponent::Type type, StringRef name)
void mesh_transform(Mesh &mesh, const float4x4 &transform, bool do_shape_keys)
AttrType cpp_type_to_attribute_type(const CPPType &type)
const CPPType & attribute_type_to_cpp_type(AttrType type)
Curves * curves_new_nomain(int points_num, int curves_num)
static void propagate_instances_to_keep(const bke::GeometrySet &geometry_set, const IndexMask &selection, bke::GeometrySet &new_geometry_set, const bke::AttributeFilter &attribute_filter)
static void gather_realize_tasks_recursive(GatherTasksInfo &gather_info, const int current_depth, const int target_depth, const bke::GeometrySet &geometry_set, const float4x4 &base_transform, const InstanceContext &base_instance_context)
static OrderedAttributes gather_generic_pointcloud_attributes_to_propagate(const bke::GeometrySet &in_geometry_set, const RealizeInstancesOptions &options, const VariedDepthOptions &varied_depth_option, bool &r_create_radii, bool &r_create_id)
static void execute_realize_curve_tasks(const RealizeInstancesOptions &options, const GatherOffsets &offsets, const AllCurvesInfo &all_curves_info, const Span< RealizeCurveTask > tasks, const OrderedAttributes &ordered_attributes, RealizeInstancesResult &r_result)
static void execute_realize_grease_pencil_tasks(const AllGreasePencilsInfo &all_grease_pencils_info, const GatherOffsets &offsets, const Span< RealizeGreasePencilTask > tasks, const OrderedAttributes &ordered_attributes, RealizeInstancesResult &r_result)
static void copy_vertex_group_name(ListBase *dst_deform_group, const OrderedAttributes &ordered_attributes, const bDeformGroup &src_deform_group)
static void execute_realize_mesh_tasks(const RealizeInstancesOptions &options, const GatherOffsets &offsets, const AllMeshesInfo &all_meshes_info, const Span< RealizeMeshTask > tasks, const OrderedAttributes &ordered_attributes, const VectorSet< Material * > &ordered_materials, RealizeInstancesResult &r_result)
static void threaded_copy(const GSpan src, GMutableSpan dst)
static AllMeshesInfo preprocess_meshes(const bke::GeometrySet &geometry_set, const RealizeInstancesOptions &options, const VariedDepthOptions &varied_depth_option)
static void gather_grease_pencils_to_realize(const bke::GeometrySet &geometry_set, VectorSet< const GreasePencil * > &r_grease_pencils)
static void execute_realize_pointcloud_task(const RealizeInstancesOptions &options, const RealizePointCloudTask &task, const OrderedAttributes &ordered_attributes, MutableSpan< GSpanAttributeWriter > dst_attribute_writers, MutableSpan< float > all_dst_radii, MutableSpan< int > all_dst_ids, MutableSpan< float3 > all_dst_positions)
static int64_t get_final_points_num(const GatherTasks &tasks)
static void gather_pointclouds_to_realize(const bke::GeometrySet &geometry_set, VectorSet< const PointCloud * > &r_pointclouds)
static void execute_realize_grease_pencil_task(const RealizeGreasePencilTask &task, const OrderedAttributes &ordered_attributes, GreasePencil &dst_grease_pencil, MutableSpan< GSpanAttributeWriter > dst_attribute_writers)
static void execute_realize_mesh_task(const RealizeInstancesOptions &options, const RealizeMeshTask &task, const OrderedAttributes &ordered_attributes, MutableSpan< GSpanAttributeWriter > dst_attribute_writers, MutableSpan< float3 > all_dst_positions, MutableSpan< int2 > all_dst_edges, MutableSpan< int > all_dst_face_offsets, MutableSpan< int > all_dst_corner_verts, MutableSpan< int > all_dst_corner_edges, MutableSpan< int > all_dst_vertex_ids, MutableSpan< int > all_dst_material_indices, GSpanAttributeWriter &all_dst_custom_normals)
static OrderedAttributes gather_generic_curve_attributes_to_propagate(const bke::GeometrySet &in_geometry_set, const RealizeInstancesOptions &options, const VariedDepthOptions &varied_depth_option, bool &r_create_id)
static void gather_realize_tasks_for_instances(GatherTasksInfo &gather_info, const int current_depth, const int target_depth, const Instances &instances, const float4x4 &base_transform, const InstanceContext &base_instance_context)
static void remove_id_attribute_from_instances(bke::GeometrySet &geometry_set)
static void initialize_curves_builtin_attribute_defaults(const AllCurvesInfo &all_curves_info, InstanceContext &attribute_fallbacks)
static void create_result_ids(const RealizeInstancesOptions &options, const Span< int > stored_ids, const int task_id, MutableSpan< int > dst_ids)
static void gather_curves_to_realize(const bke::GeometrySet &geometry_set, VectorSet< const Curves * > &r_curves)
static void transform_grease_pencil_layers(Span< bke::greasepencil::Layer * > layers, const float4x4 &transform)
static void copy_generic_attributes_to_result(const Span< std::optional< GVArraySpan > > src_attributes, const AttributeFallbacksArray &attribute_fallbacks, const OrderedAttributes &ordered_attributes, const FunctionRef< IndexRange(bke::AttrDomain)> &range_fn, MutableSpan< GSpanAttributeWriter > dst_attribute_writers)
static bool valid_int_num(const int64_t num)
void join_attributes(const Span< const bke::GeometryComponent * > src_components, bke::GeometryComponent &r_result, const Span< StringRef > ignored_attributes={})
static void gather_attribute_propagation_components_with_custom_depths(const bke::GeometrySet &geometry, const bke::GeometryComponent::Type component_type, const RealizeInstancesOptions &options, const VariedDepthOptions &varied_depth_option, Set< bke::GeometryComponentPtr > &r_components)
static Vector< std::pair< int, GSpan > > prepare_attribute_fallbacks(GatherTasksInfo &gather_info, const Instances &instances, const OrderedAttributes &ordered_attributes)
static AllPointCloudsInfo preprocess_pointclouds(const bke::GeometrySet &geometry_set, const RealizeInstancesOptions &options, const VariedDepthOptions &varied_depth_option)
static void execute_realize_curve_task(const RealizeInstancesOptions &options, const AllCurvesInfo &all_curves_info, const RealizeCurveTask &task, const OrderedAttributes &ordered_attributes, bke::CurvesGeometry &dst_curves, MutableSpan< GSpanAttributeWriter > dst_attribute_writers, MutableSpan< int > all_dst_ids, MutableSpan< float3 > all_handle_left, MutableSpan< float3 > all_handle_right, MutableSpan< float > all_radii, MutableSpan< float3 > all_custom_normals)
static bke::GeometrySet::GatheredAttributes gather_attributes_to_propagate(const bke::GeometrySet &geometry, const bke::GeometryComponent::Type component_type, const RealizeInstancesOptions &options, const VariedDepthOptions &varied_depth_option)
static void copy_vertex_group_names(Mesh &dst_mesh, const OrderedAttributes &ordered_attributes, const Span< const Mesh * > src_meshes)
RealizeInstancesResult realize_instances(bke::GeometrySet geometry_set, const RealizeInstancesOptions &options)
static void execute_realize_pointcloud_tasks(const RealizeInstancesOptions &options, const GatherOffsets &offsets, const AllPointCloudsInfo &all_pointclouds_info, const Span< RealizePointCloudTask > tasks, const OrderedAttributes &ordered_attributes, RealizeInstancesResult &r_result)
static AllCurvesInfo preprocess_curves(const bke::GeometrySet &geometry_set, const RealizeInstancesOptions &options, const VariedDepthOptions &varied_depth_option)
static void gather_meshes_to_realize(const bke::GeometrySet &geometry_set, VectorSet< const Mesh * > &r_meshes)
static void add_instance_attributes_to_single_geometry(const OrderedAttributes &ordered_attributes, const AttributeFallbacksArray &attribute_fallbacks, bke::MutableAttributeAccessor attributes)
static AllGreasePencilsInfo preprocess_grease_pencils(const bke::GeometrySet &geometry_set, const RealizeInstancesOptions &options, const VariedDepthOptions &varied_depth_options)
static OrderedAttributes gather_generic_instance_attributes_to_propagate(const bke::GeometrySet &in_geometry_set, const RealizeInstancesOptions &options, const VariedDepthOptions &varied_depth_option)
static void foreach_geometry_in_reference(const InstanceReference &reference, const float4x4 &base_transform, const uint32_t id, FunctionRef< void(const bke::GeometrySet &geometry_set, const float4x4 &transform, uint32_t id)> fn)
static void threaded_fill(const GPointer value, GMutableSpan dst)
static void execute_realize_edit_data_tasks(const Span< RealizeEditDataTask > tasks, bke::GeometrySet &r_realized_geometry)
static bool skip_transform(const float4x4 &transform)
static OrderedAttributes gather_generic_grease_pencil_attributes_to_propagate(const bke::GeometrySet &in_geometry_set, const RealizeInstancesOptions &options, const VariedDepthOptions &varied_depth_options)
static void gather_attribute_propagation_components(const bke::GeometrySet &geometry, const bke::GeometryComponent::Type component_type, const RealizeInstancesOptions &options, const int current_depth, const std::optional< int > max_depth, Set< bke::GeometryComponentPtr > &r_components)
static void execute_instances_tasks(const Span< bke::GeometryComponentPtr > src_components, const Span< blender::float4x4 > src_base_transforms, const OrderedAttributes &all_instances_attributes, const Span< blender::geometry::AttributeFallbacksArray > attribute_fallback, bke::GeometrySet &r_realized_geometry)
static OrderedAttributes gather_generic_mesh_attributes_to_propagate(const bke::GeometrySet &in_geometry_set, const RealizeInstancesOptions &options, const VariedDepthOptions &varied_depth_option, bool &r_create_id, bool &r_create_material_index)
void transform_normals(const float3x3 &transform, MutableSpan< float3 > normals)
bool is_equal(const MatBase< T, NumCol, NumRow > &a, const MatBase< T, NumCol, NumRow > &b, const T epsilon=T(0))
void transform_points(const float4x4 &transform, MutableSpan< float3 > points, bool use_threading=true)
uint32_t hash(uint32_t kx)
OffsetIndices< int > accumulate_counts_to_offsets(MutableSpan< int > counts_to_offsets, int start_offset=0)
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
void memory_bandwidth_bound_task(const int64_t approximate_bytes_touched, const Function &function)
MatBase< float, 4, 4 > float4x4
MatBase< float, 3, 3 > float3x3
VecBase< float, 3 > float3
blender::VecBase< int16_t, 2 > short2
void uninitialized_copy_n(const T *src, int64_t n, T *dst)
ListBase vertex_group_names
struct Material ** material_array
ListBase vertex_group_names
int vertex_group_active_index
static MatBase identity()
bool allow_skip(const StringRef name) const
void add(const StringRef name, const AttributeDomainAndType &kind)
Vector< AttributeDomainAndType, 16 > kinds
VectorSet< StringRef, 16 > names
GeometryComponent & get_component_for_write(GeometryComponent::Type component_type)
void replace_instances(Instances *instances, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
Instances * get_instances_for_write()
const GreasePencil * get_grease_pencil() const
Vector< const GeometryComponent * > get_components() const
void replace_pointcloud(PointCloud *pointcloud, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
const Curves * get_curves() const
const Instances * get_instances() const
bool has_instances() const
void replace_curves(Curves *curves, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
const PointCloud * get_pointcloud() const
const Mesh * get_mesh() const
void replace_mesh(Mesh *mesh, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
void replace_grease_pencil(GreasePencil *grease_pencil, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
MutableVArraySpan< T > span
bool create_handle_postion_attributes
OrderedAttributes attributes
bool create_radius_attribute
bool create_custom_normal_attribute
VectorSet< const Curves * > order
Array< RealizeCurveInfo > realize_info
VectorSet< Material * > materials
VectorSet< const GreasePencil * > order
OrderedAttributes attributes
Array< GreasePencilRealizeInfo > realize_info
Vector< AttributeFallbacksArray > attribute_fallback
Vector< float4x4 > instances_components_transforms
Vector< bke::GeometryComponentPtr > instances_components_to_merge
VectorSet< Material * > materials
VectorSet< const Mesh * > order
bke::mesh::NormalJoinInfo custom_normal_info
bool create_material_index_attribute
OrderedAttributes attributes
Array< MeshRealizeInfo > realize_info
Array< PointCloudRealizeInfo > realize_info
VectorSet< const PointCloud * > order
OrderedAttributes attributes
bool create_radius_attribute
AttributeFallbacksArray(int size)
Array< const void * > array
int64_t grease_pencil_layer_offset
int64_t pointcloud_offset
struct blender::geometry::GatherOffsets::@077126055320236227323125127266171230262045216140 mesh_offsets
struct blender::geometry::GatherOffsets::@336116134033231205014131370346202371156352227156 curves_offsets
const AllPointCloudsInfo & pointclouds
const AllCurvesInfo & curves
const VArray< int > & depths
const AllMeshesInfo & meshes
bool create_id_attribute_on_any_component
AllInstancesInfo instances
Vector< std::unique_ptr< GArray<> > > & r_temporary_arrays
const OrderedAttributes & instances_attriubutes
const AllGreasePencilsInfo & grease_pencils
Vector< RealizeMeshTask > mesh_tasks
Vector< RealizeEditDataTask > edit_data_tasks
Vector< RealizePointCloudTask > pointcloud_tasks
Vector< RealizeCurveTask > curve_tasks
ImplicitSharingPtr< const bke::VolumeComponent > first_volume
Vector< RealizeGreasePencilTask > grease_pencil_tasks
Array< std::optional< GVArraySpan > > attributes
Array< int > material_index_map
const GreasePencil * grease_pencil
AttributeFallbacksArray grease_pencils
AttributeFallbacksArray instances
InstanceContext(const GatherTasksInfo &gather_info)
AttributeFallbacksArray meshes
AttributeFallbacksArray pointclouds
AttributeFallbacksArray curves
Span< int > stored_vertex_ids
VArray< int > material_indices
GVArraySpan custom_normal
OffsetIndices< int > faces
Array< std::optional< GVArraySpan > > attributes
Array< int > material_index_map
IndexRange index_range() const
VectorSet< StringRef > ids
Vector< AttributeDomainAndType > kinds
Array< std::optional< GVArraySpan > > attributes
const PointCloud * pointcloud
Span< float3 > custom_normal
Span< float3 > handle_left
Span< float3 > handle_right
Array< std::optional< GVArraySpan > > attributes
Span< float > nurbs_weight
const RealizeCurveInfo * curve_info
AttributeFallbacksArray attribute_fallbacks
CurvesElementStartIndices start_indices
const bke::GeometryComponentEditData * edit_data
AttributeFallbacksArray attribute_fallbacks
const GreasePencilRealizeInfo * grease_pencil_info
bke::GeometrySet geometry
Vector< std::string > errors
AttributeFallbacksArray attribute_fallbacks
const MeshRealizeInfo * mesh_info
MeshElementStartIndices start_indices
AttributeFallbacksArray attribute_fallbacks
const PointCloudRealizeInfo * pointcloud_info
static constexpr int MAX_DEPTH