14#define DNA_DEPRECATED_ALLOW
85#define STACK_FIXED_DEPTH 100
107 std::optional<Library *> owner_library,
112 Mesh *mesh_dst =
reinterpret_cast<Mesh *
>(id_dst);
113 const Mesh *mesh_src =
reinterpret_cast<const Mesh *
>(id_src);
197 mesh_dst->
runtime->
edit_data = std::make_unique<bke::EditMeshData>(*edit_data);
201 mesh_dst->
mat = MEM_dupalloc(mesh_src->
mat);
246 reinterpret_cast<ID **
>(&mesh_dst->
key),
265 mesh->vertex_group_names.free_no_destruct();
266 MEM_SAFE_DELETE(
mesh->active_color_attribute);
267 MEM_SAFE_DELETE(
mesh->default_color_attribute);
268 MEM_SAFE_DELETE(
mesh->active_uv_map_attribute);
269 MEM_SAFE_DELETE(
mesh->default_uv_map_attribute);
270 MEM_SAFE_DELETE(
mesh->stencil_uv_map_attribute);
271 MEM_SAFE_DELETE(
mesh->clone_uv_map_attribute);
272 mesh->attribute_storage.wrap().~AttributeStorage();
273 if (
mesh->face_offset_indices) {
275 &
mesh->runtime->face_offsets_sharing_info);
277 MEM_SAFE_DELETE(
mesh->mselect);
278 MEM_SAFE_DELETE(
mesh->mat);
279 delete mesh->runtime;
288 for (
int i = 0; i <
mesh->totcol; i++) {
301 if (std::any_of(layers.
begin(),
304 return CustomData_external_test(&data, eCustomDataType(layer.type));
308 bpath_data,
data.external->filepath,
sizeof(
data.external->filepath));
318 mesh->attribute_storage.wrap().foreach_working_space_color(
fn);
320 auto convert_domain = [&
fn](
CustomData *customdata,
size_t size) {
321 for (
int i = 0; i < customdata->
totlayer; i++) {
331 convert_domain(&
mesh->vert_data,
mesh->verts_num);
332 convert_domain(&
mesh->edge_data,
mesh->edges_num);
333 convert_domain(&
mesh->face_data,
mesh->faces_num);
334 convert_domain(&
mesh->corner_data,
mesh->corners_num);
342 const bool is_undo = writer->
is_undo();
352 mesh->mface =
nullptr;
353 mesh->totface_legacy = 0;
364 mesh->corners_num = 0;
369 mesh->face_offset_indices =
nullptr;
374 mesh->attribute_storage.wrap(),
376 [&](
const AttrDomain domain) { return mesh->attributes().domain_size(domain); },
386 mesh->attribute_storage.dna_attributes =
nullptr;
387 mesh->attribute_storage.dna_attributes_num = 0;
390 mesh->attribute_storage.dna_attributes = attribute_data.
attributes.data();
391 mesh->attribute_storage.dna_attributes_num = attribute_data.
attributes.size();
396 mesh->runtime =
nullptr;
428 mesh->attribute_storage.wrap().blend_write(*writer, attribute_data);
430 if (
mesh->face_offset_indices) {
432 mesh->face_offset_indices,
433 sizeof(
int) *
mesh->faces_num,
435 [&]() { writer->write_int32_array(mesh->faces_num + 1, mesh->face_offset_indices); });
470 mesh->attribute_storage.wrap().blend_read(*reader);
471 if (
mesh->deform_verts().is_empty()) {
487 if (
mesh->face_offset_indices) {
489 reader, &
mesh->face_offset_indices, [&]() {
490 if (!BLO_read_array(reader, &mesh->face_offset_indices, int64_t(mesh->faces_num) + 1)) {
493 return mesh->face_offset_indices ?
499 if (
mesh->mselect ==
nullptr) {
509 .id_code = Mesh::id_type,
513 .struct_size =
sizeof(
Mesh),
515 .name_plural =
N_(
"meshes"),
518 .asset_type_info =
nullptr,
523 .make_local =
nullptr,
525 .foreach_cache =
nullptr,
528 .foreach_asset_weak_reference =
nullptr,
529 .owner_pointer_get =
nullptr,
533 .blend_read_after_liblink =
nullptr,
535 .blend_read_undo_preserve =
nullptr,
537 .lib_override_apply_post =
nullptr,
542 return ELEM(name,
"position",
".corner_vert",
".corner_edge",
".edge_verts");
579 if (
mesh->verts_num > 0) {
594 return mesh->attributes().contains(
"custom_normal");
610 if (
mesh.default_color_attribute) {
627 if (!
mesh.default_uv_map_name().is_empty()) {
630 mesh.uv_maps_default_set(name);
665 mesh.uv_maps_active_set(default_name);
670 mesh.uv_maps_active_set(found);
682 mesh.uv_maps_default_set(found);
690 MEM_SAFE_DELETE(
mesh.active_color_attribute);
693 MEM_SAFE_DELETE(
mesh.default_color_attribute);
696 MEM_SAFE_DELETE(
mesh.active_uv_map_attribute);
699 MEM_SAFE_DELETE(
mesh.default_uv_map_attribute);
702 MEM_SAFE_DELETE(
mesh.stencil_uv_map_attribute);
705 MEM_SAFE_DELETE(
mesh.clone_uv_map_attribute);
716 return {
float3(std::numeric_limits<float>::max()),
float3(std::numeric_limits<float>::lowest())};
735 int target_group_size)
739 groups[node_index].children_offset = 0;
741 std::copy(face_indices.
begin(), face_indices.
end(), groups[node_index].faces.
begin());
746 const int children_start = groups.
size();
747 groups[node_index].children_offset = children_start;
750 groups[children_start].parent = node_index;
751 groups[children_start + 1].parent = node_index;
756 if (bounds_precalc) {
765 for (
const int face : face_indices.
slice(range)) {
806 if (groups[i].children_offset == 0 && !groups[i].faces.
is_empty()) {
815 for (const int i : range) {
816 const int group_idx = leaf_indices[i];
817 NonContiguousGroup &group = groups[group_idx];
819 int corners_count = 0;
821 for (const int face_index : group.faces) {
822 const IndexRange face = faces[face_index];
823 verts.add_multiple(corner_verts.slice(face));
824 corners_count += face.size();
827 new (&verts_per_leaf[i]) Array<int>(verts.size());
828 std::copy(verts.begin(), verts.end(), verts_per_leaf[i].begin());
829 std::ranges::sort(verts_per_leaf[i]);
830 group.corner_count = corners_count;
838 for (
const int i : leaf_indices.index_range()) {
839 const int group_idx = leaf_indices[i];
842 shared_verts.
clear();
844 for (
const int vert : verts_per_leaf[i]) {
845 if (vert_used[vert]) {
846 shared_verts.
append(vert);
849 vert_used[vert].set();
883 for (
const int face : range) {
885 vert_positions, corner_verts.
slice(faces[face]));
886 face_centers[face] =
bounds.center();
898 groups[0].parent = -1;
899 groups[0].children_offset = 0;
905 face_centers, prim_face_indices, groups, 0, 0,
bounds, material_index, 2500);
915 if (
mesh.verts_num == 0 ||
mesh.faces_num == 0) {
930 group_unique_offsets.
reserve(local_groups.
size() + 1);
931 group_unique_offsets.
append(0);
934 group_face_offsets.
reserve(local_groups.
size() + 1);
935 group_face_offsets.
append(0);
937 for (
const int group_index : local_groups.
index_range()) {
941 if (!added_verts[vert_idx]) {
942 new_vert_order.
append(vert_idx);
943 added_verts[vert_idx].set();
946 group_unique_offsets.
append(new_vert_order.
size());
949 if (!added_verts[vert_idx]) {
950 new_vert_order.
append(vert_idx);
951 added_verts[vert_idx].set();
955 for (
const int face_idx : local_group.
faces) {
956 new_face_order.
append(face_idx);
958 group_face_offsets.
append(new_face_order.
size());
962 if (!added_verts[vert]) {
963 new_vert_order.
append(vert);
964 added_verts[vert].set();
970 vert_reverse_map[new_vert_order[i]] = i;
974 for (
int2 &edge : edges) {
975 edge.x = vert_reverse_map[edge.x];
976 edge.y = vert_reverse_map[edge.y];
983 int new_corner_idx = 0;
984 for (
const int old_face_idx : new_face_order) {
985 const IndexRange face = old_faces[old_face_idx];
986 for (
const int corner : face) {
987 new_corner_verts[new_corner_idx] = vert_reverse_map[corner_verts[corner]];
991 corner_verts.
copy_from(new_corner_verts);
1004 int new_face_idx = 0;
1005 for (
const int old_face_idx : new_face_order) {
1006 type.
copy_construct(attribute_data[old_face_idx], new_values[new_face_idx]);
1018 int new_vert_idx = 0;
1019 for (
const int old_vert_idx : new_vert_order) {
1020 type.
copy_construct(attribute_data[old_vert_idx], new_values[new_vert_idx]);
1032 int new_corner_idx = 0;
1033 for (
const int old_face_idx : new_face_order) {
1034 const IndexRange face = old_faces[old_face_idx];
1035 for (
const int old_corner_idx : face) {
1036 type.
copy_construct(attribute_data[old_corner_idx], new_values[new_corner_idx]);
1046 gather_group_sizes(old_faces, new_face_order, face_sizes);
1052 for (
int &vert_idx : local_group.unique_verts) {
1053 vert_idx = vert_reverse_map[vert_idx];
1055 for (
int &vert_idx : local_group.shared_verts) {
1056 vert_idx = vert_reverse_map[vert_idx];
1062 for (
const int node_idx : local_groups.
index_range()) {
1072 int unique_start = (node_idx == 0) ? 0 : group_unique_offsets[node_idx];
1073 int unique_end = group_unique_offsets[node_idx + 1];
1074 node.unique_verts =
IndexRange(unique_start, unique_end - unique_start);
1076 int face_start = (node_idx == 0) ? 0 : group_face_offsets[node_idx];
1077 int face_end = group_face_offsets[node_idx + 1];
1089 mesh.tag_positions_changed();
1090 mesh.tag_topology_changed();
1091 mesh.runtime->spatial_groups = std::make_unique<Array<MeshGroup>>(std::move(
nodes));
1116 if (
mesh.face_offset_indices) {
1118 &
mesh.runtime->face_offsets_sharing_info);
1120 MEM_SAFE_DELETE(
mesh.mselect);
1124 mesh.totface_legacy = 0;
1125 mesh.corners_num = 0;
1133 mesh.vertex_group_names.free_no_destruct();
1134 MEM_SAFE_DELETE(
mesh.active_color_attribute);
1135 MEM_SAFE_DELETE(
mesh.default_color_attribute);
1136 MEM_SAFE_DELETE(
mesh.active_uv_map_attribute);
1137 MEM_SAFE_DELETE(
mesh.default_uv_map_attribute);
1138 MEM_SAFE_DELETE(
mesh.stencil_uv_map_attribute);
1139 MEM_SAFE_DELETE(
mesh.clone_uv_map_attribute);
1157 if (free_customdata) {
1164 mesh->totface_legacy = 0;
1176 if (
mesh->faces_num == 0) {
1182 mesh->face_offset_indices);
1186 mesh->face_offsets_for_write().fill(-1);
1189 mesh->face_offset_indices[0] = 0;
1190 mesh->face_offset_indices[
mesh->faces_num] =
mesh->corners_num;
1201 return bke::get_mutable_attribute<float3>(
1202 this->
attribute_storage.wrap(), bke::AttrDomain::Point,
"position", this->verts_num);
1207 return bke::get_span_attribute<int2>(
1208 this->
attribute_storage.wrap(), bke::AttrDomain::Edge,
".edge_verts", this->edges_num)
1209 .value_or(Span<int2>());
1213 return bke::get_mutable_attribute<int2>(
1214 this->
attribute_storage.wrap(), bke::AttrDomain::Edge,
".edge_verts", this->edges_num);
1233 implicit_sharing::make_trivial_data_mutable(
1241 bke::AttrDomain::Corner,
1244 .value_or(Span<int>());
1248 return bke::get_mutable_attribute<int>(
1249 this->
attribute_storage.wrap(), bke::AttrDomain::Corner,
".corner_vert", this->corners_num);
1255 bke::AttrDomain::Corner,
1258 .value_or(Span<int>());
1262 return bke::get_mutable_attribute<int>(
1263 this->
attribute_storage.wrap(), bke::AttrDomain::Corner,
".corner_edge", this->corners_num);
1268 const MDeformVert *dverts =
static_cast<const MDeformVert *
>(
1277 MDeformVert *
dvert =
static_cast<MDeformVert *
>(
1290 this->face_offsets().size_in_bytes());
1300 return bke::AttributeAccessor(
this, bke::mesh_attribute_accessor_functions());
1305 return bke::MutableAttributeAccessor(
this, bke::mesh_attribute_accessor_functions());
1310 VectorSet<StringRefNull> names;
1311 this->
attributes().foreach_attribute([&](
const bke::AttributeIter &iter) {
1339 const StringRefNull active_name = this->active_uv_map_name();
1343 return this->default_uv_map_name();
1346void Mesh::uv_maps_active_set(
const StringRef name)
1361void Mesh::uv_maps_default_set(
const StringRef name)
1377 const int edges_num,
1378 const int faces_num,
1379 const int corners_num)
1395bool is_uv_map(
const std::optional<AttributeMetaData> &meta_data)
1397 return meta_data &&
is_uv_map(*meta_data);
1414 const int edges_num,
1415 const int faces_num,
1416 const int corners_num)
1422 mesh->verts_num = verts_num;
1423 mesh->edges_num = edges_num;
1424 mesh->faces_num = faces_num;
1425 mesh->corners_num = corners_num;
1498 if (me_dst->
mat !=
nullptr) {
1499 MEM_delete(me_dst->
mat);
1501 me_dst->
mat = MEM_dupalloc(me_src->
mat);
1508 const int verts_num,
1509 const int edges_num,
1510 const int tessface_num,
1511 const int faces_num,
1512 const int corners_num,
1516 const bool do_tessface = (tessface_num ||
1558 if (dst_attrs.
contains(attr.name())) {
1568 const int verts_num,
1569 const int edges_num,
1570 const int faces_num,
1571 const int corners_num)
1579 return reinterpret_cast<Mesh *
>(
1596 const int active_shapekey,
1597 const bool add_key_index,
1611 const Mesh *me_settings)
1622 const Mesh *me_settings)
1635 int *indices =
static_cast<int *
>(
1659 float texspace_location[3], texspace_size[3];
1662 texspace_size[0] = (
bounds.max[0] -
bounds.min[0]) / 2.0f;
1663 texspace_size[1] = (
bounds.max[1] -
bounds.min[1]) / 2.0f;
1664 texspace_size[2] = (
bounds.max[2] -
bounds.min[2]) / 2.0f;
1666 for (
int a = 0; a < 3; a++) {
1667 if (texspace_size[a] == 0.0f) {
1668 texspace_size[a] = 1.0f;
1670 else if (texspace_size[a] > 0.0f && texspace_size[a] < 0.00001f) {
1671 texspace_size[a] = 0.00001f;
1673 else if (texspace_size[a] < 0.0f && texspace_size[a] > -0.00001f) {
1674 texspace_size[a] = -0.00001f;
1698 if (r_texspace_location) {
1701 if (r_texspace_size) {
1707 char **r_texspace_flag,
1708 float **r_texspace_location,
1709 float **r_texspace_size)
1713 if (r_texspace_flag !=
nullptr) {
1714 *r_texspace_flag = &
mesh->texspace_flag;
1716 if (r_texspace_location !=
nullptr) {
1717 *r_texspace_location =
mesh->texspace_location;
1719 if (r_texspace_size !=
nullptr) {
1720 *r_texspace_size =
mesh->texspace_size;
1731 result.as_mutable_span().take_front(positions.
size()).copy_from(positions);
1739 float texspace_location[3], texspace_size[3];
1742 mesh->texcomesh ?
mesh->texcomesh :
mesh, texspace_location, texspace_size);
1753 co[0] = (co[0] - texspace_location[0]) / texspace_size[0];
1754 co[1] = (co[1] - texspace_location[1]) / texspace_size[1];
1755 co[2] = (co[2] - texspace_location[2]) / texspace_size[2];
1781 if (ob ==
nullptr) {
1785 return id_cast<Mesh *>(ob->
data);
1795 if (ob ==
nullptr) {
1820 if (!material_indices) {
1829 if (indices_span[i] > 0 && indices_span[i] >=
index) {
1833 indices_span.
save();
1834 material_indices.
finish();
1856 attributes.
remove(
"material_index");
1864 const short remap_len_short = short(remap_len);
1866#define MAT_NR_REMAP(n) \
1867 if (n < remap_len_short) { \
1868 BLI_assert(n >= 0 && remap[n] < remap_len_short); \
1885 if (!material_indices) {
1888 for (
const int i : material_indices.
span.index_range()) {
1891 material_indices.
span.save();
1892 material_indices.
finish();
1903 if (!keep_sharp_edges) {
1904 attributes.
remove(
"sharp_edge");
1906 attributes.
remove(
"sharp_face");
1919 if (
angle == 0.0f) {
1923 if (!keep_sharp_edges) {
1924 attributes.
remove(
"sharp_edge");
1930 mesh.corner_verts(),
1931 mesh.corner_edges(),
1932 mesh.face_normals(),
1933 mesh.corner_to_face_map(),
1942std::optional<Bounds<float3>> Mesh::bounds_min_max()
const
1945 if (verts_num == 0) {
1946 return std::nullopt;
1948 this->
runtime->bounds_cache.ensure([&](Bounds<float3> &r_bounds) {
1949 switch (this->
runtime->wrapper_type) {
1956 r_bounds = *bounds::min_max(this->vert_positions());
1960 return this->
runtime->bounds_cache.data();
1965 this->
runtime->bounds_cache.ensure([&](Bounds<float3> &r_data) { r_data =
bounds; });
1973std::optional<int> Mesh::material_index_max()
const
1975 this->runtime->max_material_index.ensure([&](std::optional<int> &value) {
1979 value = std::nullopt;
1982 int max_material_index = 0;
1986 max_material_index = std::max<int>(max_material_index, efa->
mat_nr);
1988 value = max_material_index;
1992 value = std::nullopt;
1995 value = bounds::max<int>(
1996 *this->
attributes().lookup_or_default<int>(
"material_index", bke::AttrDomain::Face, 0));
1997 if (value.has_value()) {
1998 value = std::clamp(*value, 0,
MAXMAT);
2001 return this->
runtime->max_material_index.data();
2006 this->
runtime->used_material_indices.ensure([&](VectorSet<int> &r_data) {
2007 const std::optional<int> max_material_index_opt = this->material_index_max();
2009 if (!max_material_index_opt.has_value()) {
2012 const int max_material_index = *max_material_index_opt;
2013 const auto clamp_material_index = [&](
const int index) {
2014 return std::clamp<int>(
index, 0, max_material_index);
2018 Array<bool> used_indices(max_material_index + 1,
false);
2024 used_indices[clamp_material_index(efa->
mat_nr)] =
true;
2027 else if (
const VArray<int> material_indices = *this->
attributes().lookup_or_default<int>(
2028 "material_index", bke::AttrDomain::Face, 0))
2030 if (
const std::optional<int> single_material_index = material_indices.get_if_single()) {
2031 used_indices[clamp_material_index(*single_material_index)] =
true;
2034 VArraySpan<int> material_indices_span = material_indices;
2035 threading::parallel_for(
2036 material_indices_span.
index_range(), 8096, [&](
const IndexRange range) {
2037 for (const int i : range) {
2038 used_indices[clamp_material_index(material_indices_span[i])] = true;
2043 for (
const int i : used_indices.index_range()) {
2044 if (used_indices[i]) {
2049 return this->runtime->used_material_indices.
data();
2057 for (float3 &position : positions.slice(range)) {
2058 position += translation;
2069 std::optional<Bounds<float3>>
bounds;
2070 if (
mesh.runtime->bounds_cache.is_cached()) {
2076 if (do_shape_keys &&
mesh.key) {
2082 mesh.tag_positions_changed_uniformly();
2085 bounds->min += translation;
2086 bounds->max += translation;
2095 if (do_shape_keys &&
mesh.key) {
2103 mesh.tag_positions_changed();
2118 MEM_SAFE_DELETE(
mesh->mselect);
2119 mesh->totselect = 0;
2125 MSelect *mselect_src, *mselect_dst;
2128 if (
mesh->totselect == 0) {
2132 mselect_src =
mesh->mselect;
2134 "Mesh selection history");
2144 for (i_src = 0, i_dst = 0; i_src <
mesh->totselect; i_src++) {
2146 switch (mselect_src[i_src].type) {
2148 if (select_vert[
index]) {
2149 mselect_dst[i_dst] = mselect_src[i_src];
2155 if (select_edge[
index]) {
2156 mselect_dst[i_dst] = mselect_src[i_src];
2162 if (select_poly[
index]) {
2163 mselect_dst[i_dst] = mselect_src[i_src];
2175 MEM_delete(mselect_src);
2178 MEM_delete(mselect_dst);
2179 mselect_dst =
nullptr;
2181 else if (i_dst !=
mesh->totselect) {
2182 mselect_dst =
static_cast<MSelect *
>(
2186 mesh->totselect = i_dst;
2187 mesh->mselect = mselect_dst;
2194 for (
int i = 0; i <
mesh->totselect; i++) {
2195 if ((
mesh->mselect[i].index ==
index) && (
mesh->mselect[i].type == type)) {
2207 if (
mesh->totselect) {
2208 if (
mesh->mselect[
mesh->totselect - 1].type == type) {
2209 return mesh->mselect[
mesh->totselect - 1].index;
2219 if (msel_index == -1) {
2227 else if (msel_index !=
mesh->totselect - 1) {
2229 std::swap(
mesh->mselect[msel_index],
mesh->mselect[
mesh->totselect - 1]);
2233 (
mesh->mselect[
mesh->totselect - 1].type == type));
2238 r_count[0] = r_count[1] = r_count[2] = 0;
2256 if (
mesh->runtime->mesh_eval !=
nullptr) {
2258 mesh->runtime->mesh_eval =
nullptr;
#define BKE_LIB_FOREACHID_PROCESS_IDSUPER(data_, id_super_, cb_flag_)
General operations, lookup, etc. for materials.
General operations, lookup, etc. for blender objects.
A BVH for high poly meshes.
Platform independent time functions.
#define BLO_read_struct_list(reader, struct_name, list)
#define BLT_I18NCONTEXT_ID_MESH
#define ID_IS_OVERRIDE_LIBRARY(_id)
Object is a sort of wrapper for general info.
Read Blender memory allocation and freeing.
#define STACK_FIXED_DEPTH
#define BLI_assert_unreachable()
#define INIT_DEFAULT_STRUCT_AFTER(struct_dst, member)
#define BM_ELEM_CD_SET_BOOL(ele, offset, f)
#define BM_ELEM_CD_GET_VOID_P(ele, offset)
#define BM_ITER_MESH(ele, iter, bm, itype)
#define BMALLOC_TEMPLATE_FROM_ME(...)
#define MEM_realloc_uninitialized(vmemh, len)
static btDbvtVolume bounds(btDbvtNode **leaves, int count)
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
IndexRange index_range() const
void generated_ptr(int64_t offset)
void copy_construct(const void *src, void *dst) const
void copy_from(GSpan values)
const CPPType & type() const
constexpr int64_t size() const
constexpr MutableSpan slice(const int64_t start, const int64_t size) const
constexpr MutableSpan drop_front(const int64_t n) const
constexpr T * end() const
constexpr T * begin() const
constexpr IndexRange index_range() const
constexpr void copy_from(Span< T > values) const
constexpr MutableSpan take_front(const int64_t n) const
constexpr Span slice(int64_t start, int64_t size) const
constexpr int64_t size() const
constexpr const T * end() const
constexpr const T * begin() const
T get_internal_single() const
void add_new(const Key &key)
void append(const T &value)
IndexRange index_range() const
void resize(const int64_t new_size)
void reserve(const int64_t min_capacity)
GAttributeReader lookup_or_default(StringRef name, AttrDomain domain, AttrType data_type, const void *default_value=nullptr) const
void foreach_attribute(const FunctionRef< void(const AttributeIter &)> fn) const
bool contains(StringRef name) const
std::optional< AttributeMetaData > lookup_meta_data(StringRef name) const
GAttributeReader lookup(const StringRef name) const
std::optional< AttrStorageType > storage_type
bool add(const StringRef name, const AttrDomain domain, const AttrType data_type, const AttributeInit &initializer)
GSpanAttributeWriter lookup_or_add_for_write_span(StringRef name, AttrDomain domain, AttrType data_type, const AttributeInit &initializer=AttributeInitDefaultValue())
bool remove(const StringRef name)
GAttributeWriter lookup_for_write(StringRef name)
GSpanAttributeWriter lookup_for_write_span(StringRef name)
constexpr IndexRange index_range() const
constexpr bool contains(const T &value) const
constexpr IndexRange index_range() const
constexpr bool is_empty() const
constexpr int64_t size() const
constexpr const char * data() const
void add_shared(const ImplicitSharingInfo *sharing_info, const FunctionRef< void(MemoryCounter &shared_memory)> count_fn)
IndexRange index_range() const
float2x2 invert(float2x2 mat)
void fill_index_range(MutableSpan< T > span, const T start=0)
bool is_uv_map(const AttributeMetaData &meta_data)
void edges_sharp_from_angle_set(OffsetIndices< int > faces, Span< int > corner_verts, Span< int > corner_edges, Span< float3 > face_normals, Span< int > corner_to_face, Span< bool > sharp_faces, const float split_angle, MutableSpan< bool > sharp_edges)
bool is_color_attribute(const AttributeMetaData &meta_data)
Bounds< float3 > calc_face_bounds(const Span< float3 > vert_positions, const Span< int > face_verts)
int partition_along_axis(const Span< float3 > face_centers, MutableSpan< int > faces, const int axis, const float middle)
bool leaf_needs_material_split(const Span< int > faces, const Span< int > material_indices)
int partition_material_indices(const Span< int > material_indices, MutableSpan< int > faces)
static Bounds< float3 > merge_bounds(const Bounds< float3 > &a, const Bounds< float3 > &b)
bool attribute_name_is_anonymous(const StringRef name)
static void translate_positions(MutableSpan< float3 > positions, const float3 &translation)
void mesh_sharp_edges_set_from_angle(Mesh &mesh, float angle, bool keep_sharp_edges=false)
void mesh_skin_to_legacy(AttributeStorage::BlendWriteData &attr_write_data, CustomData &vert_data, Vector< CustomDataLayer, 16 > &vert_layers, int verts_num)
static Vector< NonContiguousGroup > compute_local_mesh_groups(Mesh &mesh)
static Bounds< float3 > negative_bounds()
std::optional< GSpan > get_span_attribute(const AttributeStorage &storage, const AttrDomain domain, const CPPType &cpp_type, const StringRef name, const int64_t domain_size)
static void build_vertex_groups_for_leaves(const int verts_num, const OffsetIndices< int > faces, const Span< int > corner_verts, Vector< NonContiguousGroup > &groups)
void mesh_remove_invalid_attribute_strings(Mesh &mesh)
static StringRefNull get_first_uv_map_name(const Mesh &mesh)
static void partition_faces_recursively(const Span< float3 > face_centers, MutableSpan< int > face_indices, Vector< NonContiguousGroup > &groups, int node_index, int depth, const std::optional< Bounds< float3 > > &bounds_precalc, const Span< int > material_indices, int target_group_size)
void mesh_smooth_set(Mesh &mesh, bool use_smooth, bool keep_sharp_edges=false)
void mesh_apply_spatial_organization(Mesh &mesh)
Mesh * mesh_new_no_attributes(int verts_num, int edges_num, int faces_num, int corners_num)
void mesh_transform(Mesh &mesh, const float4x4 &transform, bool do_shape_keys)
void mesh_ensure_default_uv_attribute_on_add(Mesh &mesh, StringRef name, AttrDomain domain, bke::AttrType data_type)
void transform_custom_normal_attribute(const float4x4 &transform, MutableAttributeAccessor &attributes)
void attribute_storage_blend_write_prepare(AttributeStorage &data, bool use_5_0_compatibility, FunctionRef< int(AttrDomain)> get_domain_size, AttributeStorage::BlendWriteData &write_data)
void mesh_ensure_required_data_layers(Mesh &mesh)
void mesh_ensure_default_color_attribute_on_add(Mesh &mesh, StringRef name, AttrDomain domain, bke::AttrType data_type)
void mesh_translate(Mesh &mesh, const float3 &translation, bool do_shape_keys)
void mesh_ensure_active_uv_map(Mesh &mesh)
void mesh_ensure_default_uv_map(Mesh &mesh)
Bounds< T > merge(const Bounds< T > &a, const Bounds< T > &b)
void copy_shared_pointer(T *src_ptr, const ImplicitSharingInfo *src_sharing_info, T **r_dst_ptr, const ImplicitSharingInfo **r_dst_sharing_info)
void free_shared_data(T **data, const ImplicitSharingInfo **sharing_info)
const ImplicitSharingInfo * info_for_mem_free(T *data)
void split(const std::string &s, const char delim, std::vector< std::string > &tokens)
T midpoint(const T &a, const T &b)
void min_max(const T &value, T &min, T &max)
int dominant_axis(const VecBase< T, 3 > &a)
void transform_points(const float4x4 &transform, MutableSpan< float3 > points, bool use_threading=true)
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))
Value parallel_reduce(IndexRange range, int64_t grain_size, const Value &identity, const Function &function, const Reduction &reduction)
void CustomData_MeshMasks_update(CustomData_MeshMasks *mask_dst, const CustomData_MeshMasks *mask_src)
const char * BKE_idtype_idcode_to_name(short idcode)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void BKE_mesh_copy_parameters(Mesh *me_dst, const Mesh *me_src)
const ImplicitSharingInfo * BLO_read_shared(BlendDataReader *reader, T **data_ptr, FunctionRef< const ImplicitSharingInfo *()> read_fn)
char * STRNCPY(char(&dst)[N], const char *src)
void BKE_defbase_blend_write(BlendWriter *writer, const ListBaseT< bDeformGroup > *defbase)
void BKE_mesh_texspace_get_reference(Mesh *mesh, char **r_texspace_flag, float **r_texspace_location, float **r_texspace_size)
BMesh * BKE_editmesh_bmesh_get_for_write(Mesh *mesh)
void BKE_mesh_clear_geometry_and_metadata(Mesh *mesh)
MINLINE void copy_v3_v3(float r[3], const float a[3])
void * MEM_new_array_uninitialized(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
int64_t BLI_time_now_seconds_i()
bool DEG_is_active(const Depsgraph *depsgraph)
void BLO_read_pointer_array_and_validate_size(BlendDataReader *reader, T **ptr_p, SizeT *array_size)
bool CustomData_has_layer(const CustomData *data, eCustomDataType type)
bool BKE_mesh_material_index_used(Mesh *mesh, short index)
Mesh * BKE_mesh_copy_for_eval(const Mesh &source)
void BKE_mesh_ensure_default_orig_index_customdata_no_check(Mesh *mesh)
void BKE_mesh_mselect_clear(Mesh *mesh)
void BKE_mesh_mselect_active_set(Mesh *mesh, int index, eMSelect_Type type)
static void mesh_tessface_clear_intern(Mesh *mesh, int free_customdata)
void BKE_mesh_face_offsets_ensure_alloc(Mesh *mesh)
void BKE_defvert_blend_read(BlendDataReader *reader, int count, MDeformVert *mdverts)
void DEG_debug_print_eval(Depsgraph *depsgraph, const char *function_name, const char *object_name, const void *object_address)
Mesh * BKE_mesh_from_bmesh_nomain(BMesh *bm, const BMeshToMeshParams *params, const Mesh *me_settings)
char * BLI_strdupn(const char *str, size_t len) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
static void clear_attribute_names(Mesh &mesh)
void BKE_mesh_tessface_clear(Mesh *mesh)
int CustomData_get_layer_index(const CustomData *data, eCustomDataType type)
ATTR_WARN_UNUSED_RESULT const BMVert * v
bool BKE_mesh_attribute_required(StringRef name)
static void ensure_orig_index_layer(CustomData &data, const int size)
MatBase< float, 4, 4 > float4x4
void BKE_mesh_count_selected_items(const Mesh *mesh, int r_count[3])
void BKE_id_blend_write(BlendWriter *writer, ID *id)
void BM_mesh_bm_to_me_for_eval(BMesh &bm, Mesh &mesh, const CustomData_MeshMasks *cd_mask_extra)
static void mesh_foreach_path(ID *id, BPathForeachPathData *bpath_data)
@ LIB_ID_CREATE_NO_USER_REFCOUNT
static void mesh_clear_geometry(Mesh &mesh)
int BKE_mesh_mselect_find(const Mesh *mesh, int index, eMSelect_Type type)
const char * CustomData_get_render_layer_name(const CustomData *data, eCustomDataType type)
void BM_mesh_bm_from_me(BMesh *bm, const Mesh *mesh, const BMeshFromMeshParams *params)
Mesh -> BMesh.
void BKE_mesh_copy_parameters_for_eval(Mesh *me_dst, const Mesh *me_src)
void CustomData_set_layer_render_index(CustomData *data, eCustomDataType type, int n)
VecBase< int32_t, 2 > int2
void CustomData_init_layout_from(const CustomData *source, CustomData *dest, eCustomDataMask mask, eCDAllocType alloctype, int totelem)
VecBase< float, 2 > float2
BMesh * BKE_mesh_to_bmesh_ex(const Mesh *mesh, const BMeshCreateParams *create_params, const BMeshFromMeshParams *convert_params)
BLI_INLINE unsigned int BLI_hash_int(unsigned int k)
bool BKE_mesh_has_custom_loop_normals(Mesh *mesh)
static void mesh_blend_read_data(BlendDataReader *reader, ID *id)
void CustomData_reset(CustomData *data)
void BKE_mesh_material_index_remove(Mesh *mesh, short index)
void CustomData_blend_write(BlendWriter *writer, CustomData *data, Span< CustomDataLayer > layers_to_write, int count, eCustomDataMask cddata_mask, ID *id)
std::optional< Bounds< float3 > > BKE_editmesh_cache_calc_minmax(BMesh &bm, const bke::EditMeshData &emd)
BMesh const char void * data
void BKE_object_materials_sync_length(Main *bmain, Object *ob, ID *id)
void BKE_mesh_mselect_validate(Mesh *mesh)
Mesh * BKE_mesh_from_object(Object *ob)
void BKE_mesh_texspace_get(Mesh *mesh, float r_texspace_location[3], float r_texspace_size[3])
int CustomData_get_offset_named(const CustomData *data, eCustomDataType type, StringRef name)
@ ME_TEXSPACE_FLAG_AUTO_EVALUATED
Mesh * BKE_mesh_new_nomain(int verts_num, int edges_num, int faces_num, int corners_num)
void BKE_mesh_runtime_clear_cache(Mesh *mesh)
void BKE_mesh_texspace_ensure(Mesh *mesh)
BMesh * BKE_mesh_to_bmesh(Mesh *mesh, int active_shapekey, bool add_key_index, const BMeshCreateParams *params)
void CustomData_blend_write_prepare(CustomData &data, Vector< CustomDataLayer, 16 > &layers_to_write)
int BKE_mesh_mselect_active_get(const Mesh *mesh, eMSelect_Type type)
void BKE_libblock_init_empty(ID *id) ATTR_NONNULL(1)
static bool use_bmesh_material_indices(const Mesh &mesh)
const void * CustomData_get_layer(const CustomData *data, eCustomDataType type)
void multires_force_sculpt_rebuild(Object *object)
int BKE_mesh_wrapper_vert_len(const Mesh *mesh)
const char * CustomData_get_active_layer_name(const CustomData *data, eCustomDataType type)
static void copy_attribute_names(const Mesh &mesh_src, Mesh &mesh_dst)
void BKE_id_free(Main *bmain, void *idv)
void BKE_mesh_ensure_skin_customdata(Mesh *mesh)
void BKE_mesh_orco_verts_transform(Mesh *mesh, MutableSpan< float3 > orco, bool invert)
bool BLO_read_array(BlendDataReader *reader, T **ptr_p, const SizeT array_size, const int elems=1)
void BKE_mesh_orco_ensure(Object *ob, Mesh *mesh)
int CustomData_get_named_layer_index(const CustomData *data, eCustomDataType type, StringRef name)
void BLO_read_array_and_validate_size(BlendDataReader *reader, T **ptr_p, SizeT *array_size, const int elems=1)
void * BKE_id_new_nomain(short type, const char *name)
const CustomData_MeshMasks CD_MASK_DERIVEDMESH
void BKE_mesh_eval_geometry(Depsgraph *depsgraph, Mesh *mesh)
void CustomData_count_memory(const CustomData &data, int totelem, MemoryCounter &memory)
MINLINE void madd_v3_v3v3v3(float r[3], const float a[3], const float b[3], const float c[3])
void mid_v3_v3v3(float r[3], const float a[3], const float b[3])
T * DEG_get_original(T *id)
bool BKE_bpath_foreach_path_fixed_process(BPathForeachPathData *bpath_data, char *path, size_t path_maxncpy)
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC
const CustomData_MeshMasks CD_MASK_MESH
void CustomData_free(CustomData *data)
void BKE_modifiers_test_object(Object *ob)
static void mesh_free_data(ID *id)
Mesh * BKE_mesh_from_bmesh_for_eval_nomain(BMesh *bm, const CustomData_MeshMasks *cd_mask_extra, const Mesh *me_settings)
void BKE_mesh_assign_object(Main *bmain, Object *ob, Mesh *mesh)
static void mesh_init_data(ID *id)
Mesh * BKE_mesh_new_nomain_from_template(const Mesh *me_src, int verts_num, int edges_num, int faces_num, int corners_num)
void BKE_defgroup_copy_list(ListBaseT< bDeformGroup > *outbase, const ListBaseT< bDeformGroup > *inbase)
void BKE_mesh_ensure_default_orig_index_customdata(Mesh *mesh)
static void mesh_foreach_id(ID *id, LibraryForeachIDData *data)
const BMesh * BKE_editmesh_bmesh_get(const Object *ob)
void BKE_mesh_material_index_clear(Mesh *mesh)
void BKE_mesh_material_remap(Mesh *mesh, const unsigned int *remap, unsigned int remap_len)
void BM_data_layer_add_named(BMesh *bm, CustomData *data, int type, const StringRef name)
ColorSceneLinear4f< eAlpha::Premultiplied > ColorGeometry4f
void CustomData_set_layer_active_index(CustomData *data, eCustomDataType type, int n)
static void mesh_foreach_working_space_color(ID *id, const IDTypeForeachColorFunctionCallback &fn)
void BM_mesh_bm_to_me(Main *bmain, BMesh *bm, Mesh *mesh, const BMeshToMeshParams *params)
void BKE_mesh_texspace_calc(Mesh *mesh)
void * CustomData_get_layer_for_write(CustomData *data, eCustomDataType type, int totelem)
ID * BKE_id_copy_ex(Main *bmain, const ID *id, ID **new_id_p, int flag)
VecBase< float, 3 > float3
Mesh * BKE_mesh_add(Main *bmain, const char *name)
const CustomData_MeshMasks CD_MASK_EVERYTHING
bool CustomData_has_layer_named(const CustomData *data, eCustomDataType type, StringRef name)
static void mesh_copy_data(Main *bmain, std::optional< Library * > owner_library, ID *id_dst, const ID *id_src, const int flag)
BMesh * BM_mesh_create(const BMAllocTemplate *allocsize, const BMeshCreateParams *params)
BMesh Make Mesh.
void CustomData_init_from(const CustomData *source, CustomData *dest, eCustomDataMask mask, int totelem)
void * BKE_id_new(Main *bmain, short type, const char *name)
void * BKE_libblock_alloc(Main *bmain, short type, const char *name, int flag) ATTR_WARN_UNUSED_RESULT
struct ID * BKE_id_copy_in_lib(Main *bmain, std::optional< Library * > owner_library, const ID *id, std::optional< const ID * > new_owner_id, ID **new_id_p, int flag)
void BKE_mesh_clear_geometry(Mesh *mesh)
void BLO_read_string(BlendDataReader *reader, char **ptr_p)
static void mesh_blend_write(BlendWriter *writer, ID *id, const void *id_address)
Array< float3 > BKE_mesh_orco_verts_get(const Object *ob)
void * CustomData_add_layer(CustomData *data, eCustomDataType type, eCDAllocType alloctype, int totelem)
void CustomData_blend_read(BlendDataReader *reader, CustomData *data, int count)
Mesh * BKE_mesh_new_nomain_from_template_ex(const Mesh *me_src, int verts_num, int edges_num, int tessface_num, int faces_num, int corners_num, CustomData_MeshMasks mask)
@ IDTYPE_FLAGS_APPEND_IS_REUSABLE
void write_pointer_array(int64_t num, const void *data)
void write_shared(const void *data, size_t approximate_size_in_bytes, const ImplicitSharingInfo *sharing_info, FunctionRef< void()> write_fn)
void generated_pointer_tag(const void *data)
void write_string(const char *data)
void write_id_struct(const void *id_address, const T *id, BlendStructWriterTypedFn< T > fn=nullptr)
void write_struct_array(const int64_t array_size, const T *data, BlendStructWriterTypedFn< T > fn=nullptr)
struct AttributeStorage attribute_storage
float texspace_location[3]
ListBaseT< bDeformGroup > vertex_group_names
bke::MeshRuntime * runtime
char * stencil_uv_map_attribute
int face_sets_color_default
int * face_offset_indices
int attributes_active_index
int vertex_group_active_index
char * default_uv_map_attribute
eMeshSymmetryType symmetry
char * active_uv_map_attribute
DNA_DEPRECATED struct MDeformVert * dvert
float remesh_voxel_adaptivity
eMesh_RemeshMode remesh_mode
char * clone_uv_map_attribute
char * active_color_attribute
char * default_color_attribute
Vector< blender::Attribute, 16 > & attributes
VMutableArray< T > varray
SharedCache< Bounds< float3 > > bounds_cache
SharedCache< std::unique_ptr< BVHTree, BVHTreeDeleter > > bvh_cache_loose_verts
BitVector subsurf_optimal_display_edges
std::unique_ptr< bake::BakeMaterialsList > bake_materials
SharedCache< std::unique_ptr< BVHTree, BVHTreeDeleter > > bvh_cache_loose_edges_no_hidden
SharedCache< LooseGeomCache > verts_no_face_cache
std::shared_ptr< BMEditMesh > edit_mesh
std::unique_ptr< EditMeshData > edit_data
SharedCache< bke::bvh::Tree > bvh_embree_tris_cache
SharedCache< std::unique_ptr< BVHTree, BVHTreeDeleter > > bvh_cache_corner_tris
SharedCache< NormalsCache > vert_normals_cache
BitVector subsurf_face_dot_tags
SharedCache< Array< int > > vert_to_face_offset_cache
SharedCache< Array< int > > edge_to_corner_map_cache
SharedCache< bke::bvh::Tree > bvh_embree_edges_cache
SharedCache< std::unique_ptr< BVHTree, BVHTreeDeleter > > bvh_cache_edges
SharedCache< Array< int > > corner_to_face_map_cache
SharedCache< NormalsCache > corner_normals_cache
SharedCache< NormalsCache > face_normals_cache
SharedCache< Array< int > > edge_to_corner_offset_cache
SharedCache< std::unique_ptr< BVHTree, BVHTreeDeleter > > bvh_cache_loose_verts_no_hidden
SharedCache< bke::bvh::Tree > bvh_embree_verts_cache
SharedCache< std::unique_ptr< BVHTree, BVHTreeDeleter > > bvh_cache_loose_edges
TrianglesCache corner_tris_cache
SharedCache< std::unique_ptr< BVHTree, BVHTreeDeleter > > bvh_cache_faces
SharedCache< Array< int > > corner_tri_faces_cache
SharedCache< LooseGeomCache > loose_edges_cache
SharedCache< Vector< float3 > > face_normals_true_cache
eMeshWrapperType wrapper_type
SharedCache< Array< int > > vert_to_face_map_cache
SharedCache< Vector< float3 > > vert_normals_true_cache
SharedCache< std::optional< int > > max_material_index
SharedCache< Array< int > > vert_to_corner_map_cache
SubsurfRuntimeData * subsurf_runtime_data
SharedCache< LooseGeomCache > loose_verts_cache
SharedCache< std::unique_ptr< BVHTree, BVHTreeDeleter > > bvh_cache_corner_tris_no_hidden
CustomData_MeshMasks cd_mask_extra
const ImplicitSharingInfo * face_offsets_sharing_info
Array< int > shared_verts
Array< int > unique_verts
MutableVArraySpan< T > span