Mesh: Rename totvert, totedge, and totloop fields

Use the standard "elements_num" naming, and use the "corner" name rather
than the old "loop" name: `verts_num`, `edges_num`, and `corners_num`.
This matches the existing `faces_num` field which was already renamed.

Pull Request: https://projects.blender.org/blender/blender/pulls/116350
This commit is contained in:
Hans Goudey 2023-12-20 02:21:48 +01:00 committed by Hans Goudey
parent 01dbe11ea6
commit efbee2d606
228 changed files with 1527 additions and 1468 deletions

View File

@ -764,11 +764,11 @@ static void attr_create_random_per_island(Scene *scene,
return;
}
if (b_mesh.totvert == 0) {
if (b_mesh.verts_num == 0) {
return;
}
DisjointSet vertices_sets(b_mesh.totvert);
DisjointSet vertices_sets(b_mesh.verts_num);
const blender::Span<blender::int2> edges = b_mesh.edges();
const blender::Span<int> corner_verts = b_mesh.corner_verts();
@ -1205,7 +1205,7 @@ void BlenderSync::sync_mesh_motion(BL::Depsgraph b_depsgraph,
/* TODO(sergey): Perform preliminary check for number of vertices. */
if (b_mesh_rna) {
const ::Mesh &b_mesh = *static_cast<const ::Mesh *>(b_mesh_rna.ptr.data);
const int b_verts_num = b_mesh.totvert;
const int b_verts_num = b_mesh.verts_num;
const blender::Span<blender::float3> positions = b_mesh.vert_positions();
if (positions.is_empty()) {
free_object_to_mesh(b_data, b_ob_info, b_mesh_rna);

View File

@ -112,15 +112,15 @@ void BKE_mesh_ensure_skin_customdata(struct Mesh *mesh);
/** Add face offsets to describe faces to a new mesh. */
void BKE_mesh_face_offsets_ensure_alloc(struct Mesh *mesh);
struct Mesh *BKE_mesh_new_nomain(int verts_num, int edges_num, int faces_num, int loops_num);
struct Mesh *BKE_mesh_new_nomain(int verts_num, int edges_num, int faces_num, int corners_num);
struct Mesh *BKE_mesh_new_nomain_from_template(
const struct Mesh *me_src, int verts_num, int edges_num, int faces_num, int loops_num);
const struct Mesh *me_src, int verts_num, int edges_num, int faces_num, int corners_num);
struct Mesh *BKE_mesh_new_nomain_from_template_ex(const struct Mesh *me_src,
int verts_num,
int edges_num,
int tessface_num,
int faces_num,
int loops_num,
int corners_num,
struct CustomData_MeshMasks mask);
void BKE_mesh_eval_delete(struct Mesh *mesh_eval);
@ -481,14 +481,14 @@ bool BKE_mesh_validate_material_indices(struct Mesh *mesh);
*/
bool BKE_mesh_validate_arrays(struct Mesh *mesh,
float (*vert_positions)[3],
unsigned int totvert,
unsigned int verts_num,
blender::int2 *edges,
unsigned int totedge,
struct MFace *mfaces,
unsigned int totface,
unsigned int edges_num,
struct MFace *legacy_faces,
unsigned int legacy_faces_num,
int *corner_verts,
int *corner_edges,
unsigned int totloop,
unsigned int corners_num,
int *face_offsets,
unsigned int faces_num,
struct MDeformVert *dverts, /* assume totvert length */
@ -504,9 +504,9 @@ bool BKE_mesh_validate_arrays(struct Mesh *mesh,
bool BKE_mesh_validate_all_customdata(struct CustomData *vert_data,
uint totvert,
struct CustomData *edge_data,
uint totedge,
uint edges_num,
struct CustomData *loop_data,
uint totloop,
uint corners_num,
struct CustomData *pdata,
uint faces_num,
bool check_meshmask,

View File

@ -137,7 +137,7 @@ struct CornerNormalSpaceArray {
/**
* The index of the data in the #spaces array for each face corner (the array size is the
* same as #Mesh::totloop). Rare -1 values define face corners without a coordinate space.
* same as #Mesh::corners_num). Rare -1 values define face corners without a coordinate space.
*/
Array<int> corner_space_indices;

View File

@ -121,7 +121,7 @@ void BKE_mesh_vert_corner_tri_map_create(MeshElemMap **r_map,
const blender::int3 *corner_tris,
int tottris,
const int *corner_verts,
int totloop);
int corners_num);
/**
* This function creates a map so the source-data (vert/edge/loop/face)
* can loop over the destination data (using the destination arrays origindex).
@ -198,7 +198,7 @@ using MeshRemapIslandsCalc = bool (*)(const float (*vert_positions)[3],
blender::OffsetIndices<int> faces,
const int *corner_verts,
const int *corner_edges,
int totloop,
int corners_num,
MeshIslandStore *r_island_store);
/* Above vert/UV mapping stuff does not do what we need here, but does things we do not need here.
@ -216,7 +216,7 @@ bool BKE_mesh_calc_islands_loop_face_edgeseam(const float (*vert_positions)[3],
blender::OffsetIndices<int> faces,
const int *corner_verts,
const int *corner_edges,
int totloop,
int corners_num,
MeshIslandStore *r_island_store);
/**
@ -240,7 +240,7 @@ bool BKE_mesh_calc_islands_loop_face_uvmap(float (*vert_positions)[3],
blender::OffsetIndices<int> faces,
const int *corner_verts,
const int *corner_edges,
int totloop,
int corners_num,
const float (*luvs)[2],
MeshIslandStore *r_island_store);

View File

@ -245,9 +245,9 @@ void BKE_mesh_runtime_eval_to_meshkey(Mesh *me_deformed, Mesh *mesh, KeyBlock *k
/* Just a shallow wrapper around #BKE_keyblock_convert_from_mesh,
* that ensures both evaluated mesh and original one has same number of vertices. */
const int totvert = me_deformed->totvert;
const int totvert = me_deformed->verts_num;
if (totvert == 0 || mesh->totvert == 0 || mesh->totvert != totvert) {
if (totvert == 0 || mesh->verts_num == 0 || mesh->verts_num != totvert) {
return;
}
@ -392,7 +392,7 @@ static Mesh *create_orco_mesh(Object *ob, Mesh *mesh, BMEditMesh *em, int layer)
if (orco) {
orco_mesh->vert_positions_for_write().copy_from(
{reinterpret_cast<const float3 *>(orco), orco_mesh->totvert});
{reinterpret_cast<const float3 *>(orco), orco_mesh->verts_num});
orco_mesh->tag_positions_changed();
if (free) {
MEM_freeN(orco);
@ -404,23 +404,23 @@ static Mesh *create_orco_mesh(Object *ob, Mesh *mesh, BMEditMesh *em, int layer)
static MutableSpan<float3> orco_coord_layer_ensure(Mesh *mesh, const eCustomDataType layer)
{
void *data = CustomData_get_layer_for_write(&mesh->vert_data, layer, mesh->totvert);
void *data = CustomData_get_layer_for_write(&mesh->vert_data, layer, mesh->verts_num);
if (!data) {
data = CustomData_add_layer(&mesh->vert_data, layer, CD_CONSTRUCT, mesh->totvert);
data = CustomData_add_layer(&mesh->vert_data, layer, CD_CONSTRUCT, mesh->verts_num);
}
return MutableSpan(reinterpret_cast<float3 *>(data), mesh->totvert);
return MutableSpan(reinterpret_cast<float3 *>(data), mesh->verts_num);
}
static void add_orco_mesh(
Object *ob, BMEditMesh *em, Mesh *mesh, Mesh *mesh_orco, const eCustomDataType layer)
{
const int totvert = mesh->totvert;
const int totvert = mesh->verts_num;
MutableSpan<float3> layer_orco;
if (mesh_orco) {
layer_orco = orco_coord_layer_ensure(mesh, layer);
if (mesh_orco->totvert == totvert) {
if (mesh_orco->verts_num == totvert) {
layer_orco.copy_from(mesh_orco->vert_positions());
}
else {
@ -765,21 +765,21 @@ static void mesh_calc_modifiers(Depsgraph *depsgraph,
((nextmask.vmask | nextmask.emask | nextmask.pmask) & CD_MASK_ORIGINDEX)) {
/* calc */
CustomData_add_layer(
&mesh_final->vert_data, CD_ORIGINDEX, CD_CONSTRUCT, mesh_final->totvert);
&mesh_final->vert_data, CD_ORIGINDEX, CD_CONSTRUCT, mesh_final->verts_num);
CustomData_add_layer(
&mesh_final->edge_data, CD_ORIGINDEX, CD_CONSTRUCT, mesh_final->totedge);
&mesh_final->edge_data, CD_ORIGINDEX, CD_CONSTRUCT, mesh_final->edges_num);
CustomData_add_layer(
&mesh_final->face_data, CD_ORIGINDEX, CD_CONSTRUCT, mesh_final->faces_num);
/* Not worth parallelizing this,
* gives less than 0.1% overall speedup in best of best cases... */
range_vn_i((int *)CustomData_get_layer_for_write(
&mesh_final->vert_data, CD_ORIGINDEX, mesh_final->totvert),
mesh_final->totvert,
&mesh_final->vert_data, CD_ORIGINDEX, mesh_final->verts_num),
mesh_final->verts_num,
0);
range_vn_i((int *)CustomData_get_layer_for_write(
&mesh_final->edge_data, CD_ORIGINDEX, mesh_final->totedge),
mesh_final->totedge,
&mesh_final->edge_data, CD_ORIGINDEX, mesh_final->edges_num),
mesh_final->edges_num,
0);
range_vn_i((int *)CustomData_get_layer_for_write(
&mesh_final->face_data, CD_ORIGINDEX, mesh_final->faces_num),
@ -809,7 +809,7 @@ static void mesh_calc_modifiers(Depsgraph *depsgraph,
if ((md_datamask->mask.lmask) & CD_MASK_ORIGSPACE_MLOOP) {
if (!CustomData_has_layer(&mesh_final->loop_data, CD_ORIGSPACE_MLOOP)) {
CustomData_add_layer(
&mesh_final->loop_data, CD_ORIGSPACE_MLOOP, CD_SET_DEFAULT, mesh_final->totloop);
&mesh_final->loop_data, CD_ORIGSPACE_MLOOP, CD_SET_DEFAULT, mesh_final->corners_num);
mesh_init_origspace(mesh_final);
}
}
@ -935,7 +935,7 @@ static void mesh_calc_modifiers(Depsgraph *depsgraph,
/* Remove temporary data layer only needed for modifier evaluation.
* Save some memory, and ensure GPU subdivision does not need to deal with this. */
CustomData_free_layers(&mesh_final->vert_data, CD_CLOTH_ORCO, mesh_final->totvert);
CustomData_free_layers(&mesh_final->vert_data, CD_CLOTH_ORCO, mesh_final->verts_num);
/* Compute normals. */
if (is_own_mesh) {
@ -1206,7 +1206,7 @@ static void editbmesh_calc_modifiers(Depsgraph *depsgraph,
if (mask.lmask & CD_MASK_ORIGSPACE_MLOOP) {
if (!CustomData_has_layer(&mesh_final->loop_data, CD_ORIGSPACE_MLOOP)) {
CustomData_add_layer(
&mesh_final->loop_data, CD_ORIGSPACE_MLOOP, CD_SET_DEFAULT, mesh_final->totloop);
&mesh_final->loop_data, CD_ORIGSPACE_MLOOP, CD_SET_DEFAULT, mesh_final->corners_num);
mesh_init_origspace(mesh_final);
}
}
@ -1622,7 +1622,7 @@ static void mesh_init_origspace(Mesh *mesh)
const float default_osf[4][2] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}};
OrigSpaceLoop *lof_array = (OrigSpaceLoop *)CustomData_get_layer_for_write(
&mesh->loop_data, CD_ORIGSPACE_MLOOP, mesh->totloop);
&mesh->loop_data, CD_ORIGSPACE_MLOOP, mesh->corners_num);
const Span<float3> positions = mesh->vert_positions();
const blender::OffsetIndices faces = mesh->faces();
const Span<int> corner_verts = mesh->corner_verts();

View File

@ -436,7 +436,7 @@ static void armature_vert_task(void *__restrict userdata,
const MDeformVert *dvert;
if (data->use_dverts || data->armature_def_nr != -1) {
if (data->me_target) {
BLI_assert(i < data->me_target->totvert);
BLI_assert(i < data->me_target->verts_num);
if (data->dverts != nullptr) {
dvert = data->dverts + i;
}
@ -522,7 +522,7 @@ static void armature_deform_coords_impl(const Object *ob_arm,
const Mesh *mesh = (const Mesh *)target_data_id;
dverts = mesh->deform_verts().data();
if (dverts) {
dverts_len = mesh->totvert;
dverts_len = mesh->verts_num;
}
}
}

View File

@ -72,11 +72,11 @@ static void get_domains(const ID *id, DomainInfo info[ATTR_DOMAIN_NUM])
}
else {
info[ATTR_DOMAIN_POINT].customdata = &mesh->vert_data;
info[ATTR_DOMAIN_POINT].length = mesh->totvert;
info[ATTR_DOMAIN_POINT].length = mesh->verts_num;
info[ATTR_DOMAIN_EDGE].customdata = &mesh->edge_data;
info[ATTR_DOMAIN_EDGE].length = mesh->totedge;
info[ATTR_DOMAIN_EDGE].length = mesh->edges_num;
info[ATTR_DOMAIN_CORNER].customdata = &mesh->loop_data;
info[ATTR_DOMAIN_CORNER].length = mesh->totloop;
info[ATTR_DOMAIN_CORNER].length = mesh->corners_num;
info[ATTR_DOMAIN_FACE].customdata = &mesh->face_data;
info[ATTR_DOMAIN_FACE].length = mesh->faces_num;
}

View File

@ -522,10 +522,10 @@ static Mesh *try_load_mesh(const DictionaryValue &io_geometry,
CustomData_free_layer_named(&mesh->edge_data, ".edge_verts", 0);
CustomData_free_layer_named(&mesh->loop_data, ".corner_vert", 0);
CustomData_free_layer_named(&mesh->loop_data, ".corner_edge", 0);
mesh->totvert = io_mesh->lookup_int("num_vertices").value_or(0);
mesh->totedge = io_mesh->lookup_int("num_edges").value_or(0);
mesh->verts_num = io_mesh->lookup_int("num_vertices").value_or(0);
mesh->edges_num = io_mesh->lookup_int("num_edges").value_or(0);
mesh->faces_num = io_mesh->lookup_int("num_polygons").value_or(0);
mesh->totloop = io_mesh->lookup_int("num_corners").value_or(0);
mesh->corners_num = io_mesh->lookup_int("num_corners").value_or(0);
auto cancel = [&]() {
BKE_id_free(nullptr, mesh);
@ -694,10 +694,10 @@ static std::shared_ptr<DictionaryValue> serialize_geometry_set(const GeometrySet
const Mesh &mesh = *geometry.get_mesh();
auto io_mesh = io_geometry->append_dict("mesh");
io_mesh->append_int("num_vertices", mesh.totvert);
io_mesh->append_int("num_edges", mesh.totedge);
io_mesh->append_int("num_vertices", mesh.verts_num);
io_mesh->append_int("num_edges", mesh.edges_num);
io_mesh->append_int("num_polygons", mesh.faces_num);
io_mesh->append_int("num_corners", mesh.totloop);
io_mesh->append_int("num_corners", mesh.corners_num);
if (mesh.faces_num > 0) {
io_mesh->append("poly_offsets",

View File

@ -158,29 +158,29 @@ static DerivedMesh *cdDM_from_mesh_ex(Mesh *mesh, const CustomData_MeshMasks *ma
DM_init(dm,
DM_TYPE_CDDM,
mesh->totvert,
mesh->totedge,
mesh->verts_num,
mesh->edges_num,
0 /* `mesh->totface` */,
mesh->totloop,
mesh->corners_num,
mesh->faces_num);
CustomData_merge(&mesh->vert_data, &dm->vertData, cddata_masks.vmask, mesh->totvert);
CustomData_merge(&mesh->edge_data, &dm->edgeData, cddata_masks.emask, mesh->totedge);
CustomData_merge(&mesh->vert_data, &dm->vertData, cddata_masks.vmask, mesh->verts_num);
CustomData_merge(&mesh->edge_data, &dm->edgeData, cddata_masks.emask, mesh->edges_num);
CustomData_merge(&mesh->fdata_legacy,
&dm->faceData,
cddata_masks.fmask | CD_MASK_ORIGINDEX,
0 /* `mesh->totface` */);
CustomData_merge(&mesh->loop_data, &dm->loopData, cddata_masks.lmask, mesh->totloop);
CustomData_merge(&mesh->loop_data, &dm->loopData, cddata_masks.lmask, mesh->corners_num);
CustomData_merge(&mesh->face_data, &dm->polyData, cddata_masks.pmask, mesh->faces_num);
cddm->vert_positions = static_cast<float(*)[3]>(CustomData_get_layer_named_for_write(
&dm->vertData, CD_PROP_FLOAT3, "position", mesh->totvert));
&dm->vertData, CD_PROP_FLOAT3, "position", mesh->verts_num));
cddm->medge = static_cast<vec2i *>(CustomData_get_layer_named_for_write(
&dm->edgeData, CD_PROP_INT32_2D, ".edge_verts", mesh->totedge));
&dm->edgeData, CD_PROP_INT32_2D, ".edge_verts", mesh->edges_num));
cddm->corner_verts = static_cast<int *>(CustomData_get_layer_named_for_write(
&dm->loopData, CD_PROP_INT32, ".corner_vert", mesh->totloop));
&dm->loopData, CD_PROP_INT32, ".corner_vert", mesh->corners_num));
cddm->corner_edges = static_cast<int *>(CustomData_get_layer_named_for_write(
&dm->loopData, CD_PROP_INT32, ".corner_edge", mesh->totloop));
&dm->loopData, CD_PROP_INT32, ".corner_edge", mesh->corners_num));
dm->face_offsets = static_cast<int *>(MEM_dupallocN(mesh->face_offset_indices));
#if 0
cddm->mface = CustomData_get_layer(&dm->faceData, CD_MFACE);

View File

@ -338,7 +338,8 @@ void clothModifier_do(ClothModifierData *clmd,
clmd->sim_parms->timescale = timescale * clmd->sim_parms->time_scale;
if (clmd->sim_parms->reset ||
(clmd->clothObject && mesh->totvert != clmd->clothObject->mvert_num)) {
(clmd->clothObject && mesh->verts_num != clmd->clothObject->mvert_num))
{
clmd->sim_parms->reset = 0;
cache->flag |= PTCACHE_OUTDATED;
BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED);
@ -604,7 +605,7 @@ static void cloth_apply_vgroup(ClothModifierData *clmd, Mesh *mesh)
return;
}
int mvert_num = mesh->totvert;
int mvert_num = mesh->verts_num;
ClothVertex *verts = clmd->clothObject->verts;
@ -755,7 +756,7 @@ static bool cloth_from_object(
verts = clmd->clothObject->verts;
/* set initial values */
for (i = 0; i < mesh->totvert; i++, verts++) {
for (i = 0; i < mesh->verts_num; i++, verts++) {
if (first) {
copy_v3_v3(verts->x, positions[i]);
@ -828,7 +829,7 @@ static void cloth_from_mesh(ClothModifierData *clmd, const Object *ob, Mesh *mes
{
const blender::Span<int> corner_verts = mesh->corner_verts();
const blender::Span<blender::int3> corner_tris = mesh->corner_tris();
const uint mvert_num = mesh->totvert;
const uint mvert_num = mesh->verts_num;
/* Allocate our vertices. */
clmd->clothObject->mvert_num = mvert_num;
@ -844,7 +845,7 @@ static void cloth_from_mesh(ClothModifierData *clmd, const Object *ob, Mesh *mes
clmd->clothObject->primitive_num = corner_tris.size();
}
else {
clmd->clothObject->primitive_num = mesh->totedge;
clmd->clothObject->primitive_num = mesh->edges_num;
}
clmd->clothObject->tri = static_cast<MVertTri *>(
@ -1151,7 +1152,7 @@ static void cloth_update_verts(Object *ob, ClothModifierData *clmd, Mesh *mesh)
ClothVertex *verts = clmd->clothObject->verts;
/* vertex count is already ensured to match */
for (i = 0; i < mesh->totvert; i++, verts++) {
for (i = 0; i < mesh->verts_num; i++, verts++) {
copy_v3_v3(verts->xrest, positions[i]);
mul_m4_v3(ob->object_to_world, verts->xrest);
}
@ -1181,7 +1182,7 @@ static void cloth_update_spring_lengths(ClothModifierData *clmd, Mesh *mesh)
LinkNode *search = cloth->springs;
uint struct_springs = 0;
uint i = 0;
uint mvert_num = uint(mesh->totvert);
uint mvert_num = uint(mesh->verts_num);
float shrink_factor;
clmd->sim_parms->avg_spring_len = 0.0f;
@ -1455,8 +1456,8 @@ static bool cloth_build_springs(ClothModifierData *clmd, Mesh *mesh)
Cloth *cloth = clmd->clothObject;
ClothSpring *spring = nullptr, *tspring = nullptr, *tspring2 = nullptr;
uint struct_springs = 0, shear_springs = 0, bend_springs = 0, struct_springs_real = 0;
uint mvert_num = uint(mesh->totvert);
uint numedges = uint(mesh->totedge);
uint mvert_num = uint(mesh->verts_num);
uint numedges = uint(mesh->edges_num);
uint numface = uint(mesh->faces_num);
float shrink_factor;
const blender::Span<int2> edges = mesh->edges();

View File

@ -191,7 +191,7 @@ void BKE_crazyspace_set_quats_mesh(Mesh *mesh,
{
using namespace blender;
using namespace blender::bke;
BitVector<> vert_tag(mesh->totvert);
BitVector<> vert_tag(mesh->verts_num);
/* first store two sets of tangent vectors in vertices, we derive it just from the face-edges */
const Span<float3> positions = mesh->vert_positions();
@ -376,7 +376,7 @@ int BKE_sculpt_get_first_deform_matrices(Depsgraph *depsgraph,
Mesh *mesh = static_cast<Mesh *>(object_eval.data);
me_eval = BKE_mesh_copy_for_eval(mesh);
deformcos = mesh->vert_positions();
deformmats.reinitialize(mesh->totvert);
deformmats.reinitialize(mesh->verts_num);
deformmats.fill(blender::float3x3::identity());
}
@ -427,7 +427,7 @@ void BKE_crazyspace_build_sculpt(Depsgraph *depsgraph,
if (deformcos.is_empty()) {
deformcos = mesh->vert_positions();
deformmats.reinitialize(mesh->totvert);
deformmats.reinitialize(mesh->verts_num);
deformmats.fill(blender::float3x3::identity());
}
@ -465,11 +465,11 @@ void BKE_crazyspace_build_sculpt(Depsgraph *depsgraph,
}
}
quats = static_cast<float(*)[4]>(MEM_mallocN(mesh->totvert * sizeof(*quats), "crazy quats"));
quats = static_cast<float(*)[4]>(MEM_mallocN(mesh->verts_num * sizeof(*quats), "crazy quats"));
BKE_crazyspace_set_quats_mesh(mesh, origVerts, deformedVerts, quats);
for (i = 0; i < mesh->totvert; i++) {
for (i = 0; i < mesh->verts_num; i++) {
float qmat[3][3], tmat[3][3];
quat_to_mat3(qmat, quats[i]);
@ -488,7 +488,7 @@ void BKE_crazyspace_build_sculpt(Depsgraph *depsgraph,
Mesh *mesh = (Mesh *)object->data;
deformcos = mesh->vert_positions();
deformmats.reinitialize(mesh->totvert);
deformmats.reinitialize(mesh->verts_num);
deformmats.fill(blender::float3x3::identity());
}
}

View File

@ -457,7 +457,7 @@ static void build_mesh_positions(const CurvesInfo &curves_info,
const bool ignore_profile_position = profile_positions.size() == 1 &&
math::is_equal(profile_positions.first(), float3(0.0f));
if (ignore_profile_position) {
if (mesh.totvert == curves_info.main.points_num()) {
if (mesh.verts_num == curves_info.main.points_num()) {
const GAttributeReader src = curves_info.main.attributes().lookup("position");
if (src.sharing_info && src.varray.is_span()) {
const AttributeInitShared init(src.varray.get_internal_span().data(), *src.sharing_info);
@ -802,7 +802,7 @@ Mesh *curve_to_mesh_sweep(const CurvesGeometry &main,
Mesh *mesh = BKE_mesh_new_nomain(
0, offsets.edge.last(), offsets.face.last(), offsets.loop.last());
CustomData_free_layer_named(&mesh->vert_data, "position", 0);
mesh->totvert = offsets.vert.last();
mesh->verts_num = offsets.vert.last();
MutableSpan<int2> edges = mesh->edges_for_write();
MutableSpan<int> face_offsets = mesh->face_offsets_for_write();

View File

@ -366,13 +366,13 @@ static void data_transfer_dtdata_type_postprocess(Mesh *me_dst,
CustomData *ldata_dst = &me_dst->loop_data;
blender::float3 *loop_nors_dst = static_cast<blender::float3 *>(
CustomData_get_layer_for_write(ldata_dst, CD_NORMAL, me_dst->totloop));
CustomData_get_layer_for_write(ldata_dst, CD_NORMAL, me_dst->corners_num));
blender::short2 *custom_nors_dst = static_cast<blender::short2 *>(
CustomData_get_layer_for_write(ldata_dst, CD_CUSTOMLOOPNORMAL, me_dst->totloop));
CustomData_get_layer_for_write(ldata_dst, CD_CUSTOMLOOPNORMAL, me_dst->corners_num));
if (!custom_nors_dst) {
custom_nors_dst = static_cast<blender::short2 *>(
CustomData_add_layer(ldata_dst, CD_CUSTOMLOOPNORMAL, CD_SET_DEFAULT, me_dst->totloop));
custom_nors_dst = static_cast<blender::short2 *>(CustomData_add_layer(
ldata_dst, CD_CUSTOMLOOPNORMAL, CD_SET_DEFAULT, me_dst->corners_num));
}
bke::MutableAttributeAccessor attributes = me_dst->attributes_for_write();
@ -389,10 +389,10 @@ static void data_transfer_dtdata_type_postprocess(Mesh *me_dst,
me_dst->face_normals(),
sharp_faces,
sharp_edges.span,
{loop_nors_dst, me_dst->totloop},
{custom_nors_dst, me_dst->totloop});
{loop_nors_dst, me_dst->corners_num},
{custom_nors_dst, me_dst->corners_num});
sharp_edges.finish();
CustomData_free_layers(ldata_dst, CD_NORMAL, me_dst->totloop);
CustomData_free_layers(ldata_dst, CD_NORMAL, me_dst->corners_num);
}
}
@ -927,7 +927,7 @@ static bool data_transfer_layersmapping_generate(ListBase *r_map,
CustomData_add_layer_named(&me_dst->vert_data,
CD_PROP_FLOAT,
CD_SET_DEFAULT,
me_dst->totvert,
me_dst->verts_num,
"bevel_weight_vert");
}
data_transfer_layersmapping_add_item_cd(
@ -938,7 +938,7 @@ static bool data_transfer_layersmapping_generate(ListBase *r_map,
mix_weights,
CustomData_get_layer_named(&me_src->vert_data, CD_PROP_FLOAT, "bevel_weight_vert"),
CustomData_get_layer_named_for_write(
&me_dst->vert_data, CD_PROP_FLOAT, "bevel_weight_vert", me_dst->totvert),
&me_dst->vert_data, CD_PROP_FLOAT, "bevel_weight_vert", me_dst->verts_num),
interp,
interp_data);
return true;
@ -972,7 +972,7 @@ static bool data_transfer_layersmapping_generate(ListBase *r_map,
if (r_map && cddata_type == CD_FAKE_SEAM) {
if (!CustomData_has_layer_named(&me_dst->edge_data, CD_PROP_BOOL, ".uv_seam")) {
CustomData_add_layer_named(
&me_dst->edge_data, CD_PROP_BOOL, CD_SET_DEFAULT, me_dst->totedge, ".uv_seam");
&me_dst->edge_data, CD_PROP_BOOL, CD_SET_DEFAULT, me_dst->edges_num, ".uv_seam");
}
data_transfer_layersmapping_add_item_cd(
r_map,
@ -982,7 +982,7 @@ static bool data_transfer_layersmapping_generate(ListBase *r_map,
mix_weights,
CustomData_get_layer_named(&me_src->edge_data, CD_PROP_BOOL, ".uv_seam"),
CustomData_get_layer_named_for_write(
&me_dst->edge_data, CD_PROP_BOOL, ".uv_seam", me_dst->totedge),
&me_dst->edge_data, CD_PROP_BOOL, ".uv_seam", me_dst->edges_num),
interp,
interp_data);
return true;
@ -990,7 +990,7 @@ static bool data_transfer_layersmapping_generate(ListBase *r_map,
if (r_map && cddata_type == CD_FAKE_SHARP) {
if (!CustomData_has_layer_named(&me_dst->edge_data, CD_PROP_BOOL, "sharp_edge")) {
CustomData_add_layer_named(
&me_dst->edge_data, CD_PROP_BOOL, CD_SET_DEFAULT, me_dst->totedge, "sharp_edge");
&me_dst->edge_data, CD_PROP_BOOL, CD_SET_DEFAULT, me_dst->edges_num, "sharp_edge");
}
data_transfer_layersmapping_add_item_cd(
r_map,
@ -1000,7 +1000,7 @@ static bool data_transfer_layersmapping_generate(ListBase *r_map,
mix_weights,
CustomData_get_layer_named(&me_src->edge_data, CD_PROP_BOOL, "sharp_edge"),
CustomData_get_layer_named_for_write(
&me_dst->edge_data, CD_PROP_BOOL, "sharp_edge", me_dst->totedge),
&me_dst->edge_data, CD_PROP_BOOL, "sharp_edge", me_dst->edges_num),
interp,
interp_data);
return true;
@ -1010,7 +1010,7 @@ static bool data_transfer_layersmapping_generate(ListBase *r_map,
CustomData_add_layer_named(&me_dst->edge_data,
CD_PROP_FLOAT,
CD_SET_DEFAULT,
me_dst->totedge,
me_dst->edges_num,
"bevel_weight_edge");
}
data_transfer_layersmapping_add_item_cd(
@ -1021,7 +1021,7 @@ static bool data_transfer_layersmapping_generate(ListBase *r_map,
mix_weights,
CustomData_get_layer_named(&me_src->edge_data, CD_PROP_FLOAT, "bevel_weight_edge"),
CustomData_get_layer_named_for_write(
&me_dst->edge_data, CD_PROP_FLOAT, "bevel_weight_edge", me_dst->totedge),
&me_dst->edge_data, CD_PROP_FLOAT, "bevel_weight_edge", me_dst->edges_num),
interp,
interp_data);
return true;
@ -1029,7 +1029,7 @@ static bool data_transfer_layersmapping_generate(ListBase *r_map,
if (r_map && cddata_type == CD_FAKE_CREASE) {
if (!CustomData_get_layer_named(&me_dst->edge_data, CD_PROP_FLOAT, "crease_edge")) {
CustomData_add_layer_named(
&me_dst->edge_data, CD_PROP_FLOAT, CD_SET_DEFAULT, me_dst->totedge, "crease_edge");
&me_dst->edge_data, CD_PROP_FLOAT, CD_SET_DEFAULT, me_dst->edges_num, "crease_edge");
}
data_transfer_layersmapping_add_item_cd(
r_map,
@ -1039,7 +1039,7 @@ static bool data_transfer_layersmapping_generate(ListBase *r_map,
mix_weights,
CustomData_get_layer_named(&me_src->edge_data, CD_PROP_FLOAT, "crease_edge"),
CustomData_get_layer_named_for_write(
&me_dst->edge_data, CD_PROP_FLOAT, "crease_edge", me_dst->totedge),
&me_dst->edge_data, CD_PROP_FLOAT, "crease_edge", me_dst->edges_num),
interp,
interp_data);
return true;
@ -1053,7 +1053,7 @@ static bool data_transfer_layersmapping_generate(ListBase *r_map,
}
else if (cddata_type == CD_FAKE_LNOR) {
if (!CustomData_get_layer(&me_dst->loop_data, CD_PROP_FLOAT)) {
CustomData_add_layer(&me_dst->loop_data, CD_NORMAL, CD_SET_DEFAULT, me_dst->totloop);
CustomData_add_layer(&me_dst->loop_data, CD_NORMAL, CD_SET_DEFAULT, me_dst->corners_num);
}
/* Post-process will convert it back to CD_CUSTOMLOOPNORMAL. */
data_transfer_layersmapping_add_item_cd(
@ -1063,7 +1063,7 @@ static bool data_transfer_layersmapping_generate(ListBase *r_map,
mix_factor,
mix_weights,
me_src->corner_normals().data(),
CustomData_get_layer_for_write(&me_dst->loop_data, CD_NORMAL, me_dst->totloop),
CustomData_get_layer_for_write(&me_dst->loop_data, CD_NORMAL, me_dst->corners_num),
customdata_data_transfer_interp_normal_normals,
space_transform);
return true;
@ -1196,7 +1196,7 @@ void BKE_object_data_transfer_layout(Depsgraph *depsgraph,
}
if (DT_DATATYPE_IS_VERT(dtdata_type)) {
const int num_elem_dst = me_dst->totvert;
const int num_elem_dst = me_dst->verts_num;
data_transfer_layersmapping_generate(nullptr,
ob_src,
@ -1224,7 +1224,7 @@ void BKE_object_data_transfer_layout(Depsgraph *depsgraph,
}
}
if (DT_DATATYPE_IS_EDGE(dtdata_type)) {
const int num_elem_dst = me_dst->totedge;
const int num_elem_dst = me_dst->edges_num;
data_transfer_layersmapping_generate(nullptr,
ob_src,
@ -1244,7 +1244,7 @@ void BKE_object_data_transfer_layout(Depsgraph *depsgraph,
nullptr);
}
if (DT_DATATYPE_IS_LOOP(dtdata_type)) {
const int num_elem_dst = me_dst->totloop;
const int num_elem_dst = me_dst->corners_num;
data_transfer_layersmapping_generate(nullptr,
ob_src,
@ -1379,7 +1379,7 @@ bool BKE_object_data_transfer_ex(Depsgraph *depsgraph,
BKE_mesh_remap_find_best_match_from_mesh(
reinterpret_cast<const float(*)[3]>(me_dst->vert_positions().data()),
me_dst->totvert,
me_dst->verts_num,
me_src,
space_transform);
}
@ -1408,10 +1408,10 @@ bool BKE_object_data_transfer_ex(Depsgraph *depsgraph,
if (DT_DATATYPE_IS_VERT(dtdata_type)) {
blender::MutableSpan<blender::float3> positions_dst = me_dst->vert_positions_for_write();
const int num_verts_dst = me_dst->totvert;
const int num_verts_dst = me_dst->verts_num;
if (!geom_map_init[VDATA]) {
const int num_verts_src = me_src->totvert;
const int num_verts_src = me_src->verts_num;
if ((map_vert_mode == MREMAP_MODE_TOPOLOGY) && (num_verts_dst != num_verts_src)) {
BKE_report(reports,
@ -1420,7 +1420,7 @@ bool BKE_object_data_transfer_ex(Depsgraph *depsgraph,
"'Topology' mapping cannot be used in this case");
continue;
}
if ((map_vert_mode & MREMAP_USE_EDGE) && (me_src->totedge == 0)) {
if ((map_vert_mode & MREMAP_USE_EDGE) && (me_src->edges_num == 0)) {
BKE_report(reports,
RPT_ERROR,
"Source mesh does not have any edges, "
@ -1491,11 +1491,11 @@ bool BKE_object_data_transfer_ex(Depsgraph *depsgraph,
if (DT_DATATYPE_IS_EDGE(dtdata_type)) {
blender::MutableSpan<blender::float3> positions_dst = me_dst->vert_positions_for_write();
const int num_verts_dst = me_dst->totvert;
const int num_verts_dst = me_dst->verts_num;
const blender::Span<blender::int2> edges_dst = me_dst->edges();
if (!geom_map_init[EDATA]) {
const int num_edges_src = me_src->totedge;
const int num_edges_src = me_src->edges_num;
if ((map_edge_mode == MREMAP_MODE_TOPOLOGY) && (edges_dst.size() != num_edges_src)) {
BKE_report(reports,
@ -1574,14 +1574,14 @@ bool BKE_object_data_transfer_ex(Depsgraph *depsgraph,
}
if (DT_DATATYPE_IS_LOOP(dtdata_type)) {
const blender::Span<blender::float3> positions_dst = me_dst->vert_positions();
const int num_verts_dst = me_dst->totvert;
const int num_verts_dst = me_dst->verts_num;
const blender::OffsetIndices faces_dst = me_dst->faces();
const blender::Span<int> corner_verts_dst = me_dst->corner_verts();
MeshRemapIslandsCalc island_callback = data_transfer_get_loop_islands_generator(cddata_type);
if (!geom_map_init[LDATA]) {
const int num_loops_src = me_src->totloop;
const int num_loops_src = me_src->corners_num;
if ((map_loop_mode == MREMAP_MODE_TOPOLOGY) && (corner_verts_dst.size() != num_loops_src))
{
@ -1591,7 +1591,7 @@ bool BKE_object_data_transfer_ex(Depsgraph *depsgraph,
"'Topology' mapping cannot be used in this case");
continue;
}
if ((map_loop_mode & MREMAP_USE_EDGE) && (me_src->totedge == 0)) {
if ((map_loop_mode & MREMAP_USE_EDGE) && (me_src->edges_num == 0)) {
BKE_report(reports,
RPT_ERROR,
"Source mesh does not have any edges, "
@ -1664,7 +1664,7 @@ bool BKE_object_data_transfer_ex(Depsgraph *depsgraph,
}
if (DT_DATATYPE_IS_FACE(dtdata_type)) {
const blender::Span<blender::float3> positions_dst = me_dst->vert_positions();
const int num_verts_dst = me_dst->totvert;
const int num_verts_dst = me_dst->verts_num;
const blender::OffsetIndices faces_dst = me_dst->faces();
const blender::Span<int> corner_verts_dst = me_dst->corner_verts();
@ -1678,7 +1678,7 @@ bool BKE_object_data_transfer_ex(Depsgraph *depsgraph,
"'Topology' mapping cannot be used in this case");
continue;
}
if ((map_face_mode & MREMAP_USE_EDGE) && (me_src->totedge == 0)) {
if ((map_face_mode & MREMAP_USE_EDGE) && (me_src->edges_num == 0)) {
BKE_report(reports,
RPT_ERROR,
"Source mesh does not have any edges, "

View File

@ -315,7 +315,7 @@ static int dynamicPaint_surfaceNumOfPoints(DynamicPaintSurface *surface)
}
if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) {
const Mesh *canvas_mesh = dynamicPaint_canvas_mesh_get(surface->canvas);
return (canvas_mesh) ? canvas_mesh->totvert : 0;
return (canvas_mesh) ? canvas_mesh->verts_num : 0;
}
return 0;
@ -1391,7 +1391,7 @@ static void dynamicPaint_initAdjacencyData(DynamicPaintSurface *surface, const b
if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) {
/* For vertex format, neighbors are connected by edges */
neigh_points = 2 * mesh->totedge;
neigh_points = 2 * mesh->edges_num;
}
else if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ) {
neigh_points = sData->total_points * 8;
@ -1431,7 +1431,7 @@ static void dynamicPaint_initAdjacencyData(DynamicPaintSurface *surface, const b
if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) {
/* For vertex format, count every vertex that is connected by an edge */
int numOfEdges = mesh->totedge;
int numOfEdges = mesh->edges_num;
int numOfPolys = mesh->faces_num;
const blender::Span<blender::int2> edges = mesh->edges();
const blender::OffsetIndices faces = mesh->faces();
@ -1962,8 +1962,11 @@ static Mesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd, Object *
}
/* paint layer */
MLoopCol *mloopcol = static_cast<MLoopCol *>(CustomData_get_layer_named_for_write(
&result->loop_data, CD_PROP_BYTE_COLOR, surface->output_name, result->totloop));
MLoopCol *mloopcol = static_cast<MLoopCol *>(
CustomData_get_layer_named_for_write(&result->loop_data,
CD_PROP_BYTE_COLOR,
surface->output_name,
result->corners_num));
/* if output layer is lost from a constructive modifier, re-add it */
if (!mloopcol && dynamicPaint_outputLayerExists(surface, ob, 0)) {
mloopcol = static_cast<MLoopCol *>(CustomData_add_layer_named(&result->loop_data,
@ -1974,8 +1977,11 @@ static Mesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd, Object *
}
/* wet layer */
MLoopCol *mloopcol_wet = static_cast<MLoopCol *>(CustomData_get_layer_named_for_write(
&result->loop_data, CD_PROP_BYTE_COLOR, surface->output_name2, result->totloop));
MLoopCol *mloopcol_wet = static_cast<MLoopCol *>(
CustomData_get_layer_named_for_write(&result->loop_data,
CD_PROP_BYTE_COLOR,
surface->output_name2,
result->corners_num));
/* if output layer is lost from a constructive modifier, re-add it */
if (!mloopcol_wet && dynamicPaint_outputLayerExists(surface, ob, 1)) {
mloopcol_wet = static_cast<MLoopCol *>(
@ -2006,7 +2012,7 @@ static Mesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd, Object *
else if (surface->type == MOD_DPAINT_SURFACE_T_WEIGHT) {
int defgrp_index = BKE_object_defgroup_name_index(ob, surface->output_name);
MDeformVert *dvert = static_cast<MDeformVert *>(CustomData_get_layer_for_write(
&result->vert_data, CD_MDEFORMVERT, result->totvert));
&result->vert_data, CD_MDEFORMVERT, result->verts_num));
float *weight = (float *)sData->type_data;
/* apply weights into a vertex group, if doesn't exists add a new layer */
@ -2988,11 +2994,11 @@ int dynamicPaint_createUVSurface(Scene *scene,
BKE_mesh_vert_corner_tri_map_create(&vert_to_tri_map,
&vert_to_tri_map_mem,
mesh->totvert,
mesh->verts_num,
corner_tris.data(),
corner_tris.size(),
corner_verts.data(),
mesh->totloop);
mesh->corners_num);
int total_border = 0;
@ -3819,7 +3825,7 @@ static void dynamicPaint_brushMeshCalculateVelocity(Depsgraph *depsgraph,
BKE_scene_ctime_get(scene),
eModifierType_DynamicPaint);
mesh_p = BKE_mesh_copy_for_eval(dynamicPaint_brush_mesh_get(brush));
numOfVerts_p = mesh_p->totvert;
numOfVerts_p = mesh_p->verts_num;
float(*positions_p)[3] = reinterpret_cast<float(*)[3]>(
mesh_p->vert_positions_for_write().data());
@ -3837,7 +3843,7 @@ static void dynamicPaint_brushMeshCalculateVelocity(Depsgraph *depsgraph,
BKE_scene_ctime_get(scene),
eModifierType_DynamicPaint);
mesh_c = dynamicPaint_brush_mesh_get(brush);
numOfVerts_c = mesh_c->totvert;
numOfVerts_c = mesh_c->verts_num;
float(*positions_c)[3] = reinterpret_cast<float(*)[3]>(
mesh_c->vert_positions_for_write().data());
@ -4314,7 +4320,7 @@ static bool dynamicPaint_paintMesh(Depsgraph *depsgraph,
const blender::Span<blender::float3> vert_normals = mesh->vert_normals();
const blender::Span<int> corner_verts = mesh->corner_verts();
const blender::Span<int3> corner_tris = mesh->corner_tris();
numOfVerts = mesh->totvert;
numOfVerts = mesh->verts_num;
/* Transform collider vertices to global space
* (Faster than transforming per surface point
@ -5916,7 +5922,7 @@ static bool dynamicPaint_surfaceHasMoved(DynamicPaintSurface *surface, Object *o
Mesh *mesh = dynamicPaint_canvas_mesh_get(surface->canvas);
const blender::Span<blender::float3> positions = mesh->vert_positions();
int numOfVerts = mesh->totvert;
int numOfVerts = mesh->verts_num;
if (!bData->prev_positions) {
return true;
@ -6074,7 +6080,7 @@ static bool dynamicPaint_generateBakeData(DynamicPaintSurface *surface,
BRUSH_USES_VELOCITY));
const bool do_accel_data = (surface->effect & MOD_DPAINT_EFFECT_DO_DRIP) != 0;
int canvasNumOfVerts = mesh->totvert;
int canvasNumOfVerts = mesh->verts_num;
const blender::Span<blender::float3> positions = mesh->vert_positions();
Vec3f *canvas_verts;

View File

@ -828,7 +828,7 @@ static void get_effector_tot(
if (eff->pd->shape == PFIELD_SHAPE_POINTS) {
/* TODO: hair and points object support */
const Mesh *me_eval = BKE_object_get_evaluated_mesh(eff->ob);
*tot = me_eval != nullptr ? me_eval->totvert : 1;
*tot = me_eval != nullptr ? me_eval->verts_num : 1;
if (*tot && eff->pd->forcefield == PFIELD_HARMONIC && point->index >= 0) {
*p = point->index % *tot;

View File

@ -411,7 +411,7 @@ static void manta_set_domain_from_mesh(FluidDomainSettings *fds,
res = fds->maxres;
/* Set minimum and maximum coordinates of BB. */
for (i = 0; i < mesh->totvert; i++) {
for (i = 0; i < mesh->verts_num; i++) {
minmax_v3v3_v3(min, max, positions[i]);
}
@ -1023,7 +1023,7 @@ static void obstacles_from_mesh(Object *coll_ob,
const blender::Span<int> corner_verts = mesh->corner_verts();
const blender::Span<blender::int3> corner_tris = mesh->corner_tris();
numverts = mesh->totvert;
numverts = mesh->verts_num;
/* TODO(sebbas): Make initialization of vertex velocities optional? */
{
@ -2084,7 +2084,7 @@ static void emit_from_mesh(
const blender::Span<int> corner_verts = mesh->corner_verts();
const blender::Span<blender::int3> corner_tris = mesh->corner_tris();
const int numverts = mesh->totvert;
const int numverts = mesh->verts_num;
const MDeformVert *dvert = mesh->deform_verts().data();
const float(*mloopuv)[2] = static_cast<const float(*)[2]>(
CustomData_get_layer_named(&mesh->loop_data, CD_PROP_FLOAT2, ffs->uvlayer_name));

View File

@ -169,11 +169,11 @@ static void adapt_mesh_domain_corner_to_point_impl(const Mesh &mesh,
const VArray<T> &old_values,
MutableSpan<T> r_values)
{
BLI_assert(r_values.size() == mesh.totvert);
BLI_assert(r_values.size() == mesh.verts_num);
const Span<int> corner_verts = mesh.corner_verts();
attribute_math::DefaultMixer<T> mixer(r_values);
for (const int corner : IndexRange(mesh.totloop)) {
for (const int corner : IndexRange(mesh.corners_num)) {
mixer.mix_in(corner_verts[corner], old_values[corner]);
}
mixer.finalize();
@ -185,11 +185,11 @@ void adapt_mesh_domain_corner_to_point_impl(const Mesh &mesh,
const VArray<bool> &old_values,
MutableSpan<bool> r_values)
{
BLI_assert(r_values.size() == mesh.totvert);
BLI_assert(r_values.size() == mesh.verts_num);
const Span<int> corner_verts = mesh.corner_verts();
r_values.fill(true);
for (const int corner : IndexRange(mesh.totloop)) {
for (const int corner : IndexRange(mesh.corners_num)) {
const int point_index = corner_verts[corner];
if (!old_values[corner]) {
@ -213,7 +213,7 @@ void adapt_mesh_domain_corner_to_point_impl(const Mesh &mesh,
static GVArray adapt_mesh_domain_corner_to_point(const Mesh &mesh, const GVArray &varray)
{
GArray<> values(varray.type(), mesh.totvert);
GArray<> values(varray.type(), mesh.verts_num);
attribute_math::convert_to_static_type(varray.type(), [&](auto dummy) {
using T = decltype(dummy);
if constexpr (!std::is_void_v<attribute_math::DefaultMixer<T>>) {
@ -237,7 +237,7 @@ static GVArray adapt_mesh_domain_point_to_corner(const Mesh &mesh, const GVArray
attribute_math::convert_to_static_type(varray.type(), [&](auto dummy) {
using T = decltype(dummy);
new_varray = VArray<T>::ForFunc(
mesh.totloop, [corner_verts, varray = varray.typed<T>()](const int64_t corner) {
mesh.corners_num, [corner_verts, varray = varray.typed<T>()](const int64_t corner) {
return varray[corner_verts[corner]];
});
});
@ -287,7 +287,7 @@ static void adapt_mesh_domain_corner_to_edge_impl(const Mesh &mesh,
const VArray<T> &old_values,
MutableSpan<T> r_values)
{
BLI_assert(r_values.size() == mesh.totedge);
BLI_assert(r_values.size() == mesh.edges_num);
const OffsetIndices faces = mesh.faces();
const Span<int> corner_edges = mesh.corner_edges();
@ -314,7 +314,7 @@ void adapt_mesh_domain_corner_to_edge_impl(const Mesh &mesh,
const VArray<bool> &old_values,
MutableSpan<bool> r_values)
{
BLI_assert(r_values.size() == mesh.totedge);
BLI_assert(r_values.size() == mesh.edges_num);
const OffsetIndices faces = mesh.faces();
const Span<int> corner_edges = mesh.corner_edges();
@ -334,7 +334,7 @@ void adapt_mesh_domain_corner_to_edge_impl(const Mesh &mesh,
const LooseEdgeCache &loose_edges = mesh.loose_edges();
if (loose_edges.count > 0) {
/* Deselect loose edges without corners that are still selected from the 'true' default. */
threading::parallel_for(IndexRange(mesh.totedge), 2048, [&](const IndexRange range) {
threading::parallel_for(IndexRange(mesh.edges_num), 2048, [&](const IndexRange range) {
for (const int edge_index : range) {
if (loose_edges.is_loose_bits[edge_index]) {
r_values[edge_index] = false;
@ -346,7 +346,7 @@ void adapt_mesh_domain_corner_to_edge_impl(const Mesh &mesh,
static GVArray adapt_mesh_domain_corner_to_edge(const Mesh &mesh, const GVArray &varray)
{
GArray<> values(varray.type(), mesh.totedge);
GArray<> values(varray.type(), mesh.edges_num);
attribute_math::convert_to_static_type(varray.type(), [&](auto dummy) {
using T = decltype(dummy);
if constexpr (!std::is_void_v<attribute_math::DefaultMixer<T>>) {
@ -362,7 +362,7 @@ void adapt_mesh_domain_face_to_point_impl(const Mesh &mesh,
const VArray<T> &old_values,
MutableSpan<T> r_values)
{
BLI_assert(r_values.size() == mesh.totvert);
BLI_assert(r_values.size() == mesh.verts_num);
const OffsetIndices faces = mesh.faces();
const Span<int> corner_verts = mesh.corner_verts();
@ -384,7 +384,7 @@ void adapt_mesh_domain_face_to_point_impl(const Mesh &mesh,
const VArray<bool> &old_values,
MutableSpan<bool> r_values)
{
BLI_assert(r_values.size() == mesh.totvert);
BLI_assert(r_values.size() == mesh.verts_num);
const OffsetIndices faces = mesh.faces();
const Span<int> corner_verts = mesh.corner_verts();
@ -402,7 +402,7 @@ void adapt_mesh_domain_face_to_point_impl(const Mesh &mesh,
static GVArray adapt_mesh_domain_face_to_point(const Mesh &mesh, const GVArray &varray)
{
GArray<> values(varray.type(), mesh.totvert);
GArray<> values(varray.type(), mesh.verts_num);
attribute_math::convert_to_static_type(varray.type(), [&](auto dummy) {
using T = decltype(dummy);
if constexpr (!std::is_void_v<attribute_math::DefaultMixer<T>>) {
@ -419,7 +419,7 @@ void adapt_mesh_domain_face_to_corner_impl(const Mesh &mesh,
const VArray<T> &old_values,
MutableSpan<T> r_values)
{
BLI_assert(r_values.size() == mesh.totloop);
BLI_assert(r_values.size() == mesh.corners_num);
const OffsetIndices faces = mesh.faces();
threading::parallel_for(faces.index_range(), 1024, [&](const IndexRange range) {
@ -432,7 +432,7 @@ void adapt_mesh_domain_face_to_corner_impl(const Mesh &mesh,
static GVArray adapt_mesh_domain_face_to_corner(const Mesh &mesh, const GVArray &varray)
{
GArray<> values(varray.type(), mesh.totloop);
GArray<> values(varray.type(), mesh.corners_num);
attribute_math::convert_to_static_type(varray.type(), [&](auto dummy) {
using T = decltype(dummy);
if constexpr (!std::is_void_v<attribute_math::DefaultMixer<T>>) {
@ -448,7 +448,7 @@ void adapt_mesh_domain_face_to_edge_impl(const Mesh &mesh,
const VArray<T> &old_values,
MutableSpan<T> r_values)
{
BLI_assert(r_values.size() == mesh.totedge);
BLI_assert(r_values.size() == mesh.edges_num);
const OffsetIndices faces = mesh.faces();
const Span<int> corner_edges = mesh.corner_edges();
@ -469,7 +469,7 @@ void adapt_mesh_domain_face_to_edge_impl(const Mesh &mesh,
const VArray<bool> &old_values,
MutableSpan<bool> r_values)
{
BLI_assert(r_values.size() == mesh.totedge);
BLI_assert(r_values.size() == mesh.edges_num);
const OffsetIndices faces = mesh.faces();
const Span<int> corner_edges = mesh.corner_edges();
@ -487,7 +487,7 @@ void adapt_mesh_domain_face_to_edge_impl(const Mesh &mesh,
static GVArray adapt_mesh_domain_face_to_edge(const Mesh &mesh, const GVArray &varray)
{
GArray<> values(varray.type(), mesh.totedge);
GArray<> values(varray.type(), mesh.edges_num);
attribute_math::convert_to_static_type(varray.type(), [&](auto dummy) {
using T = decltype(dummy);
if constexpr (!std::is_void_v<attribute_math::DefaultMixer<T>>) {
@ -576,7 +576,7 @@ void adapt_mesh_domain_edge_to_corner_impl(const Mesh &mesh,
const VArray<T> &old_values,
MutableSpan<T> r_values)
{
BLI_assert(r_values.size() == mesh.totloop);
BLI_assert(r_values.size() == mesh.corners_num);
const OffsetIndices faces = mesh.faces();
const Span<int> corner_edges = mesh.corner_edges();
@ -604,7 +604,7 @@ void adapt_mesh_domain_edge_to_corner_impl(const Mesh &mesh,
const VArray<bool> &old_values,
MutableSpan<bool> r_values)
{
BLI_assert(r_values.size() == mesh.totloop);
BLI_assert(r_values.size() == mesh.corners_num);
const OffsetIndices faces = mesh.faces();
const Span<int> corner_edges = mesh.corner_edges();
@ -627,7 +627,7 @@ void adapt_mesh_domain_edge_to_corner_impl(const Mesh &mesh,
static GVArray adapt_mesh_domain_edge_to_corner(const Mesh &mesh, const GVArray &varray)
{
GArray<> values(varray.type(), mesh.totloop);
GArray<> values(varray.type(), mesh.corners_num);
attribute_math::convert_to_static_type(varray.type(), [&](auto dummy) {
using T = decltype(dummy);
if constexpr (!std::is_void_v<attribute_math::DefaultMixer<T>>) {
@ -643,12 +643,12 @@ static void adapt_mesh_domain_edge_to_point_impl(const Mesh &mesh,
const VArray<T> &old_values,
MutableSpan<T> r_values)
{
BLI_assert(r_values.size() == mesh.totvert);
BLI_assert(r_values.size() == mesh.verts_num);
const Span<int2> edges = mesh.edges();
attribute_math::DefaultMixer<T> mixer(r_values);
for (const int edge_index : IndexRange(mesh.totedge)) {
for (const int edge_index : IndexRange(mesh.edges_num)) {
const int2 &edge = edges[edge_index];
const T value = old_values[edge_index];
mixer.mix_in(edge[0], value);
@ -664,7 +664,7 @@ void adapt_mesh_domain_edge_to_point_impl(const Mesh &mesh,
const VArray<bool> &old_values,
MutableSpan<bool> r_values)
{
BLI_assert(r_values.size() == mesh.totvert);
BLI_assert(r_values.size() == mesh.verts_num);
const Span<int2> edges = mesh.edges();
/* Multiple threads can write to the same index here, but they are only
@ -683,7 +683,7 @@ void adapt_mesh_domain_edge_to_point_impl(const Mesh &mesh,
static GVArray adapt_mesh_domain_edge_to_point(const Mesh &mesh, const GVArray &varray)
{
GArray<> values(varray.type(), mesh.totvert);
GArray<> values(varray.type(), mesh.verts_num);
attribute_math::convert_to_static_type(varray.type(), [&](auto dummy) {
using T = decltype(dummy);
if constexpr (!std::is_void_v<attribute_math::DefaultMixer<T>>) {
@ -891,7 +891,7 @@ class MeshVertexGroupsAttributeProvider final : public DynamicAttributesProvider
const Span<MDeformVert> dverts = mesh->deform_verts();
if (dverts.is_empty()) {
static const float default_value = 0.0f;
return {VArray<float>::ForSingle(default_value, mesh->totvert), ATTR_DOMAIN_POINT};
return {VArray<float>::ForSingle(default_value, mesh->verts_num), ATTR_DOMAIN_POINT};
}
return {bke::varray_for_deform_verts(dverts, vertex_group_index), ATTR_DOMAIN_POINT};
}
@ -989,13 +989,13 @@ static ComponentAttributeProviders create_attribute_providers_for_mesh()
static CustomDataAccessInfo corner_access = {MAKE_MUTABLE_CUSTOM_DATA_GETTER(loop_data),
MAKE_CONST_CUSTOM_DATA_GETTER(loop_data),
MAKE_GET_ELEMENT_NUM_GETTER(totloop)};
MAKE_GET_ELEMENT_NUM_GETTER(corners_num)};
static CustomDataAccessInfo point_access = {MAKE_MUTABLE_CUSTOM_DATA_GETTER(vert_data),
MAKE_CONST_CUSTOM_DATA_GETTER(vert_data),
MAKE_GET_ELEMENT_NUM_GETTER(totvert)};
MAKE_GET_ELEMENT_NUM_GETTER(verts_num)};
static CustomDataAccessInfo edge_access = {MAKE_MUTABLE_CUSTOM_DATA_GETTER(edge_data),
MAKE_CONST_CUSTOM_DATA_GETTER(edge_data),
MAKE_GET_ELEMENT_NUM_GETTER(totedge)};
MAKE_GET_ELEMENT_NUM_GETTER(edges_num)};
static CustomDataAccessInfo face_access = {MAKE_MUTABLE_CUSTOM_DATA_GETTER(face_data),
MAKE_CONST_CUSTOM_DATA_GETTER(face_data),
MAKE_GET_ELEMENT_NUM_GETTER(faces_num)};
@ -1128,13 +1128,13 @@ static AttributeAccessorFunctions get_mesh_accessor_functions()
const Mesh &mesh = *static_cast<const Mesh *>(owner);
switch (domain) {
case ATTR_DOMAIN_POINT:
return mesh.totvert;
return mesh.verts_num;
case ATTR_DOMAIN_EDGE:
return mesh.totedge;
return mesh.edges_num;
case ATTR_DOMAIN_FACE:
return mesh.faces_num;
case ATTR_DOMAIN_CORNER:
return mesh.totloop;
return mesh.corners_num;
default:
return 0;
}

View File

@ -225,10 +225,10 @@ std::ostream &operator<<(std::ostream &stream, const GeometrySet &geometry_set)
{
Vector<std::string> parts;
if (const Mesh *mesh = geometry_set.get_mesh()) {
parts.append(std::to_string(mesh->totvert) + " verts");
parts.append(std::to_string(mesh->totedge) + " edges");
parts.append(std::to_string(mesh->verts_num) + " verts");
parts.append(std::to_string(mesh->edges_num) + " edges");
parts.append(std::to_string(mesh->faces_num) + " faces");
parts.append(std::to_string(mesh->totloop) + " corners");
parts.append(std::to_string(mesh->corners_num) + " corners");
}
if (const Curves *curves = geometry_set.get_curves()) {
parts.append(std::to_string(curves->geometry.point_num) + " control points");

View File

@ -2449,7 +2449,7 @@ static void gpencil_generate_edgeloops(Object *ob,
{
using namespace blender;
Mesh *mesh = (Mesh *)ob->data;
if (mesh->totedge == 0) {
if (mesh->edges_num == 0) {
return;
}
const Span<float3> vert_positions = mesh->vert_positions();
@ -2462,14 +2462,14 @@ static void gpencil_generate_edgeloops(Object *ob,
/* Arrays for all edge vertices (forward and backward) that form a edge loop.
* This is reused for each edge-loop to create gpencil stroke. */
uint *stroke = (uint *)MEM_mallocN(sizeof(uint) * mesh->totedge * 2, __func__);
uint *stroke_fw = (uint *)MEM_mallocN(sizeof(uint) * mesh->totedge, __func__);
uint *stroke_bw = (uint *)MEM_mallocN(sizeof(uint) * mesh->totedge, __func__);
uint *stroke = (uint *)MEM_mallocN(sizeof(uint) * mesh->edges_num * 2, __func__);
uint *stroke_fw = (uint *)MEM_mallocN(sizeof(uint) * mesh->edges_num, __func__);
uint *stroke_bw = (uint *)MEM_mallocN(sizeof(uint) * mesh->edges_num, __func__);
/* Create array with all edges. */
GpEdge *gp_edges = (GpEdge *)MEM_callocN(sizeof(GpEdge) * mesh->totedge, __func__);
GpEdge *gp_edges = (GpEdge *)MEM_callocN(sizeof(GpEdge) * mesh->edges_num, __func__);
GpEdge *gped = nullptr;
for (int i = 0; i < mesh->totedge; i++) {
for (int i = 0; i < mesh->edges_num; i++) {
const blender::int2 &edge = edges[i];
gped = &gp_edges[i];
copy_v3_v3(gped->n1, vert_normals[edge[0]]);
@ -2497,7 +2497,7 @@ static void gpencil_generate_edgeloops(Object *ob,
/* Look first unused edge. */
if (gped->flag != 0) {
e++;
if (e == mesh->totedge) {
if (e == mesh->edges_num) {
pending = false;
}
continue;
@ -2510,9 +2510,10 @@ static void gpencil_generate_edgeloops(Object *ob,
/* Hash used to avoid loop over same vertices. */
GHash *v_table = BLI_ghash_int_new(__func__);
/* Look forward edges. */
int totedges = gpencil_walk_edge(v_table, gp_edges, mesh->totedge, stroke_fw, e, angle, false);
int totedges = gpencil_walk_edge(
v_table, gp_edges, mesh->edges_num, stroke_fw, e, angle, false);
/* Look backward edges. */
int totbw = gpencil_walk_edge(v_table, gp_edges, mesh->totedge, stroke_bw, e, angle, true);
int totbw = gpencil_walk_edge(v_table, gp_edges, mesh->edges_num, stroke_bw, e, angle, true);
BLI_ghash_free(v_table, nullptr, nullptr);
@ -2673,7 +2674,7 @@ bool BKE_gpencil_convert_mesh(Main *bmain,
char element_name[200];
/* Need at least an edge. */
if (me_eval->totedge < 1) {
if (me_eval->edges_num < 1) {
return false;
}

View File

@ -1275,7 +1275,7 @@ static float *get_weights_array(Object *ob, char *vgroup, WeightsArrayCache *cac
if (ob->type == OB_MESH) {
Mesh *mesh = static_cast<Mesh *>(ob->data);
dvert = mesh->deform_verts().data();
totvert = mesh->totvert;
totvert = mesh->verts_num;
if (mesh->edit_mesh && mesh->edit_mesh->bm->totvert == totvert) {
em = mesh->edit_mesh;
@ -1526,7 +1526,7 @@ float *BKE_key_evaluate_object_ex(
if (ob->type == OB_MESH) {
Mesh *mesh = static_cast<Mesh *>(ob->data);
tot = mesh->totvert;
tot = mesh->verts_num;
size = tot * sizeof(float[KEYELEM_FLOAT_LEN_COORD]);
}
else if (ob->type == OB_LATTICE) {
@ -1604,7 +1604,7 @@ float *BKE_key_evaluate_object_ex(
switch (GS(obdata->name)) {
case ID_ME: {
Mesh *mesh = (Mesh *)obdata;
const int totvert = min_ii(tot, mesh->totvert);
const int totvert = min_ii(tot, mesh->verts_num);
mesh->vert_positions_for_write().take_front(totvert).copy_from(
{reinterpret_cast<const blender::float3 *>(out), totvert});
mesh->tag_positions_changed();
@ -2184,9 +2184,9 @@ void BKE_keyblock_convert_to_curve(KeyBlock *kb, Curve * /*cu*/, ListBase *nurb)
void BKE_keyblock_update_from_mesh(const Mesh *mesh, KeyBlock *kb)
{
BLI_assert(mesh->totvert == kb->totelem);
BLI_assert(mesh->verts_num == kb->totelem);
const int tot = mesh->totvert;
const int tot = mesh->verts_num;
if (tot == 0) {
return;
}
@ -2197,9 +2197,9 @@ void BKE_keyblock_update_from_mesh(const Mesh *mesh, KeyBlock *kb)
void BKE_keyblock_convert_from_mesh(const Mesh *mesh, const Key *key, KeyBlock *kb)
{
const int len = mesh->totvert;
const int len = mesh->verts_num;
if (mesh->totvert == 0) {
if (mesh->verts_num == 0) {
return;
}
@ -2231,7 +2231,8 @@ void BKE_keyblock_mesh_calc_normals(const KeyBlock *kb,
}
blender::Array<blender::float3> positions(mesh->vert_positions());
BKE_keyblock_convert_to_mesh(kb, reinterpret_cast<float(*)[3]>(positions.data()), mesh->totvert);
BKE_keyblock_convert_to_mesh(
kb, reinterpret_cast<float(*)[3]>(positions.data()), mesh->verts_num);
const blender::Span<blender::int2> edges = mesh->edges();
const blender::OffsetIndices faces = mesh->faces();
const blender::Span<int> corner_verts = mesh->corner_verts();
@ -2248,7 +2249,7 @@ void BKE_keyblock_mesh_calc_normals(const KeyBlock *kb,
bool free_face_normals = false;
if (vert_normals_needed && r_vert_normals == nullptr) {
vert_normals = static_cast<float(*)[3]>(
MEM_malloc_arrayN(mesh->totvert, sizeof(float[3]), __func__));
MEM_malloc_arrayN(mesh->verts_num, sizeof(float[3]), __func__));
free_vert_normals = true;
}
if (face_normals_needed && r_face_normals == nullptr) {
@ -2271,7 +2272,7 @@ void BKE_keyblock_mesh_calc_normals(const KeyBlock *kb,
corner_verts,
mesh->vert_to_face_map(),
{reinterpret_cast<const blender::float3 *>(face_normals), faces.size()},
{reinterpret_cast<blender::float3 *>(vert_normals), mesh->totvert});
{reinterpret_cast<blender::float3 *>(vert_normals), mesh->verts_num});
}
if (loop_normals_needed) {
const blender::short2 *clnors = static_cast<const blender::short2 *>(
@ -2286,7 +2287,7 @@ void BKE_keyblock_mesh_calc_normals(const KeyBlock *kb,
corner_verts,
corner_edges,
mesh->corner_to_face_map(),
{reinterpret_cast<blender::float3 *>(vert_normals), mesh->totvert},
{reinterpret_cast<blender::float3 *>(vert_normals), mesh->verts_num},
{reinterpret_cast<blender::float3 *>(face_normals), faces.size()},
sharp_edges,
sharp_faces,
@ -2322,7 +2323,7 @@ void BKE_keyblock_update_from_vertcos(const Object *ob, KeyBlock *kb, const floa
}
else if (ob->type == OB_MESH) {
Mesh *mesh = static_cast<Mesh *>(ob->data);
BLI_assert(mesh->totvert == kb->totelem);
BLI_assert(mesh->verts_num == kb->totelem);
}
else {
BLI_assert(0 == kb->totelem);
@ -2373,7 +2374,7 @@ void BKE_keyblock_convert_from_vertcos(const Object *ob, KeyBlock *kb, const flo
/* Count of vertex coords in array */
if (ob->type == OB_MESH) {
const Mesh *mesh = (const Mesh *)ob->data;
tot = mesh->totvert;
tot = mesh->verts_num;
elemsize = mesh->key->elemsize;
}
else if (ob->type == OB_LATTICE) {
@ -2406,7 +2407,7 @@ float (*BKE_keyblock_convert_to_vertcos(const Object *ob, const KeyBlock *kb))[3
/* Count of vertex coords in array */
if (ob->type == OB_MESH) {
const Mesh *mesh = (const Mesh *)ob->data;
tot = mesh->totvert;
tot = mesh->verts_num;
}
else if (ob->type == OB_LATTICE) {
const Lattice *lt = (const Lattice *)ob->data;

View File

@ -648,7 +648,7 @@ void BKE_mball_data_update(Depsgraph *depsgraph, Scene *scene, Object *ob)
ob->parent,
ob,
reinterpret_cast<float(*)[3]>(mesh->vert_positions_for_write().data()),
mesh->totvert,
mesh->verts_num,
0,
nullptr,
1.0f);

View File

@ -1488,7 +1488,7 @@ Mesh *BKE_mball_polygonize(Depsgraph *depsgraph, Scene *scene, Object *ob)
}
MEM_freeN(process.indices);
for (int i = 0; i < mesh->totvert; i++) {
for (int i = 0; i < mesh->verts_num; i++) {
normalize_v3(process.no[i]);
}
blender::bke::mesh_vert_normals_assign(*mesh, std::move(process.no));

View File

@ -165,9 +165,9 @@ static void mesh_copy_data(Main *bmain, ID *id_dst, const ID *id_src, const int
mesh_dst->default_color_attribute = static_cast<char *>(
MEM_dupallocN(mesh_src->default_color_attribute));
CustomData_copy(&mesh_src->vert_data, &mesh_dst->vert_data, mask.vmask, mesh_dst->totvert);
CustomData_copy(&mesh_src->edge_data, &mesh_dst->edge_data, mask.emask, mesh_dst->totedge);
CustomData_copy(&mesh_src->loop_data, &mesh_dst->loop_data, mask.lmask, mesh_dst->totloop);
CustomData_copy(&mesh_src->vert_data, &mesh_dst->vert_data, mask.vmask, mesh_dst->verts_num);
CustomData_copy(&mesh_src->edge_data, &mesh_dst->edge_data, mask.emask, mesh_dst->edges_num);
CustomData_copy(&mesh_src->loop_data, &mesh_dst->loop_data, mask.lmask, mesh_dst->corners_num);
CustomData_copy(&mesh_src->face_data, &mesh_dst->face_data, mask.pmask, mesh_dst->faces_num);
blender::implicit_sharing::copy_shared_pointer(mesh_src->face_offset_indices,
mesh_src->runtime->face_offsets_sharing_info,
@ -263,13 +263,13 @@ static void mesh_blend_write(BlendWriter *writer, ID *id, const void *id_address
/* Do not store actual geometry data in case this is a library override ID. */
if (ID_IS_OVERRIDE_LIBRARY(mesh) && !is_undo) {
mesh->totvert = 0;
mesh->verts_num = 0;
memset(&mesh->vert_data, 0, sizeof(mesh->vert_data));
mesh->totedge = 0;
mesh->edges_num = 0;
memset(&mesh->edge_data, 0, sizeof(mesh->edge_data));
mesh->totloop = 0;
mesh->corners_num = 0;
memset(&mesh->loop_data, 0, sizeof(mesh->loop_data));
mesh->faces_num = 0;
@ -299,14 +299,14 @@ static void mesh_blend_write(BlendWriter *writer, ID *id, const void *id_address
BLO_write_raw(writer, sizeof(MSelect) * mesh->totselect, mesh->mselect);
CustomData_blend_write(
writer, &mesh->vert_data, vert_layers, mesh->totvert, CD_MASK_MESH.vmask, &mesh->id);
writer, &mesh->vert_data, vert_layers, mesh->verts_num, CD_MASK_MESH.vmask, &mesh->id);
CustomData_blend_write(
writer, &mesh->edge_data, edge_layers, mesh->totedge, CD_MASK_MESH.emask, &mesh->id);
writer, &mesh->edge_data, edge_layers, mesh->edges_num, CD_MASK_MESH.emask, &mesh->id);
/* `fdata` is cleared above but written so slots align. */
CustomData_blend_write(
writer, &mesh->fdata_legacy, {}, mesh->totface_legacy, CD_MASK_MESH.fmask, &mesh->id);
CustomData_blend_write(
writer, &mesh->loop_data, loop_layers, mesh->totloop, CD_MASK_MESH.lmask, &mesh->id);
writer, &mesh->loop_data, loop_layers, mesh->corners_num, CD_MASK_MESH.lmask, &mesh->id);
CustomData_blend_write(
writer, &mesh->face_data, face_layers, mesh->faces_num, CD_MASK_MESH.pmask, &mesh->id);
@ -338,15 +338,15 @@ static void mesh_blend_read_data(BlendDataReader *reader, ID *id)
BLO_read_list(reader, &mesh->vertex_group_names);
CustomData_blend_read(reader, &mesh->vert_data, mesh->totvert);
CustomData_blend_read(reader, &mesh->edge_data, mesh->totedge);
CustomData_blend_read(reader, &mesh->vert_data, mesh->verts_num);
CustomData_blend_read(reader, &mesh->edge_data, mesh->edges_num);
CustomData_blend_read(reader, &mesh->fdata_legacy, mesh->totface_legacy);
CustomData_blend_read(reader, &mesh->loop_data, mesh->totloop);
CustomData_blend_read(reader, &mesh->loop_data, mesh->corners_num);
CustomData_blend_read(reader, &mesh->face_data, mesh->faces_num);
if (mesh->deform_verts().is_empty()) {
/* Vertex group data was also an owning pointer in old Blender versions.
* Don't read them again if they were read as part of #CustomData. */
BKE_defvert_blend_read(reader, mesh->totvert, mesh->dvert);
BKE_defvert_blend_read(reader, mesh->verts_num, mesh->dvert);
}
BLO_read_data_address(reader, &mesh->active_color_attribute);
BLO_read_data_address(reader, &mesh->default_color_attribute);
@ -431,7 +431,7 @@ void BKE_mesh_ensure_skin_customdata(Mesh *mesh)
else {
if (!CustomData_has_layer(&mesh->vert_data, CD_MVERT_SKIN)) {
vs = (MVertSkin *)CustomData_add_layer(
&mesh->vert_data, CD_MVERT_SKIN, CD_SET_DEFAULT, mesh->totvert);
&mesh->vert_data, CD_MVERT_SKIN, CD_SET_DEFAULT, mesh->verts_num);
/* Mark an arbitrary vertex as root */
if (vs) {
@ -469,10 +469,10 @@ void BKE_mesh_free_data_for_undo(Mesh *mesh)
*/
static void mesh_clear_geometry(Mesh &mesh)
{
CustomData_free(&mesh.vert_data, mesh.totvert);
CustomData_free(&mesh.edge_data, mesh.totedge);
CustomData_free(&mesh.vert_data, mesh.verts_num);
CustomData_free(&mesh.edge_data, mesh.edges_num);
CustomData_free(&mesh.fdata_legacy, mesh.totface_legacy);
CustomData_free(&mesh.loop_data, mesh.totloop);
CustomData_free(&mesh.loop_data, mesh.corners_num);
CustomData_free(&mesh.face_data, mesh.faces_num);
if (mesh.face_offset_indices) {
blender::implicit_sharing::free_shared_data(&mesh.face_offset_indices,
@ -480,10 +480,10 @@ static void mesh_clear_geometry(Mesh &mesh)
}
MEM_SAFE_FREE(mesh.mselect);
mesh.totvert = 0;
mesh.totedge = 0;
mesh.verts_num = 0;
mesh.edges_num = 0;
mesh.totface_legacy = 0;
mesh.totloop = 0;
mesh.corners_num = 0;
mesh.faces_num = 0;
mesh.act_face = -1;
mesh.totselect = 0;
@ -544,33 +544,33 @@ void BKE_mesh_face_offsets_ensure_alloc(Mesh *mesh)
#endif
/* Set common values for convenience. */
mesh->face_offset_indices[0] = 0;
mesh->face_offset_indices[mesh->faces_num] = mesh->totloop;
mesh->face_offset_indices[mesh->faces_num] = mesh->corners_num;
}
Span<float3> Mesh::vert_positions() const
{
return {static_cast<const float3 *>(
CustomData_get_layer_named(&this->vert_data, CD_PROP_FLOAT3, "position")),
this->totvert};
this->verts_num};
}
MutableSpan<float3> Mesh::vert_positions_for_write()
{
return {static_cast<float3 *>(CustomData_get_layer_named_for_write(
&this->vert_data, CD_PROP_FLOAT3, "position", this->totvert)),
this->totvert};
&this->vert_data, CD_PROP_FLOAT3, "position", this->verts_num)),
this->verts_num};
}
Span<int2> Mesh::edges() const
{
return {static_cast<const int2 *>(
CustomData_get_layer_named(&this->edge_data, CD_PROP_INT32_2D, ".edge_verts")),
this->totedge};
this->edges_num};
}
MutableSpan<int2> Mesh::edges_for_write()
{
return {static_cast<int2 *>(CustomData_get_layer_named_for_write(
&this->edge_data, CD_PROP_INT32_2D, ".edge_verts", this->totedge)),
this->totedge};
&this->edge_data, CD_PROP_INT32_2D, ".edge_verts", this->edges_num)),
this->edges_num};
}
OffsetIndices<int> Mesh::faces() const
@ -598,26 +598,26 @@ Span<int> Mesh::corner_verts() const
{
return {static_cast<const int *>(
CustomData_get_layer_named(&this->loop_data, CD_PROP_INT32, ".corner_vert")),
this->totloop};
this->corners_num};
}
MutableSpan<int> Mesh::corner_verts_for_write()
{
return {static_cast<int *>(CustomData_get_layer_named_for_write(
&this->loop_data, CD_PROP_INT32, ".corner_vert", this->totloop)),
this->totloop};
&this->loop_data, CD_PROP_INT32, ".corner_vert", this->corners_num)),
this->corners_num};
}
Span<int> Mesh::corner_edges() const
{
return {static_cast<const int *>(
CustomData_get_layer_named(&this->loop_data, CD_PROP_INT32, ".corner_edge")),
this->totloop};
this->corners_num};
}
MutableSpan<int> Mesh::corner_edges_for_write()
{
return {static_cast<int *>(CustomData_get_layer_named_for_write(
&this->loop_data, CD_PROP_INT32, ".corner_edge", this->totloop)),
this->totloop};
&this->loop_data, CD_PROP_INT32, ".corner_edge", this->corners_num)),
this->corners_num};
}
Span<MDeformVert> Mesh::deform_verts() const
@ -627,18 +627,18 @@ Span<MDeformVert> Mesh::deform_verts() const
if (!dverts) {
return {};
}
return {dverts, this->totvert};
return {dverts, this->verts_num};
}
MutableSpan<MDeformVert> Mesh::deform_verts_for_write()
{
MDeformVert *dvert = static_cast<MDeformVert *>(
CustomData_get_layer_for_write(&this->vert_data, CD_MDEFORMVERT, this->totvert));
CustomData_get_layer_for_write(&this->vert_data, CD_MDEFORMVERT, this->verts_num));
if (dvert) {
return {dvert, this->totvert};
return {dvert, this->verts_num};
}
return {static_cast<MDeformVert *>(CustomData_add_layer(
&this->vert_data, CD_MDEFORMVERT, CD_SET_DEFAULT, this->totvert)),
this->totvert};
&this->vert_data, CD_MDEFORMVERT, CD_SET_DEFAULT, this->verts_num)),
this->verts_num};
}
static void mesh_ensure_cdlayers_primary(Mesh &mesh)
@ -656,16 +656,16 @@ static void mesh_ensure_cdlayers_primary(Mesh &mesh)
Mesh *BKE_mesh_new_nomain(const int verts_num,
const int edges_num,
const int faces_num,
const int loops_num)
const int corners_num)
{
Mesh *mesh = static_cast<Mesh *>(BKE_libblock_alloc(
nullptr, ID_ME, BKE_idtype_idcode_to_name(ID_ME), LIB_ID_CREATE_LOCALIZE));
BKE_libblock_init_empty(&mesh->id);
mesh->totvert = verts_num;
mesh->totedge = edges_num;
mesh->verts_num = verts_num;
mesh->edges_num = edges_num;
mesh->faces_num = faces_num;
mesh->totloop = loops_num;
mesh->corners_num = corners_num;
mesh_ensure_cdlayers_primary(*mesh);
BKE_mesh_face_offsets_ensure_alloc(mesh);
@ -743,10 +743,10 @@ Mesh *BKE_mesh_new_nomain_from_template_ex(const Mesh *me_src,
me_dst->mselect = (MSelect *)MEM_dupallocN(me_src->mselect);
me_dst->totvert = verts_num;
me_dst->totedge = edges_num;
me_dst->verts_num = verts_num;
me_dst->edges_num = edges_num;
me_dst->faces_num = faces_num;
me_dst->totloop = loops_num;
me_dst->corners_num = loops_num;
me_dst->totface_legacy = tessface_num;
BKE_mesh_copy_parameters_for_eval(me_dst, me_src);
@ -867,8 +867,8 @@ void BKE_mesh_ensure_default_orig_index_customdata(Mesh *mesh)
void BKE_mesh_ensure_default_orig_index_customdata_no_check(Mesh *mesh)
{
ensure_orig_index_layer(mesh->vert_data, mesh->totvert);
ensure_orig_index_layer(mesh->edge_data, mesh->totedge);
ensure_orig_index_layer(mesh->vert_data, mesh->verts_num);
ensure_orig_index_layer(mesh->edge_data, mesh->edges_num);
ensure_orig_index_layer(mesh->face_data, mesh->faces_num);
}
@ -950,10 +950,10 @@ float (*BKE_mesh_orco_verts_get(Object *ob))[3]
Mesh *tme = mesh->texcomesh ? mesh->texcomesh : mesh;
/* Get appropriate vertex coordinates */
float(*vcos)[3] = (float(*)[3])MEM_calloc_arrayN(mesh->totvert, sizeof(*vcos), "orco mesh");
float(*vcos)[3] = (float(*)[3])MEM_calloc_arrayN(mesh->verts_num, sizeof(*vcos), "orco mesh");
const Span<float3> positions = tme->vert_positions();
int totvert = min_ii(tme->totvert, mesh->totvert);
int totvert = min_ii(tme->verts_num, mesh->verts_num);
for (int a = 0; a < totvert; a++) {
copy_v3_v3(vcos[a], positions[a]);
@ -993,8 +993,8 @@ void BKE_mesh_orco_ensure(Object *ob, Mesh *mesh)
/* Orcos are stored in normalized 0..1 range by convention. */
float(*orcodata)[3] = BKE_mesh_orco_verts_get(ob);
BKE_mesh_orco_verts_transform(mesh, orcodata, mesh->totvert, false);
CustomData_add_layer_with_data(&mesh->vert_data, CD_ORCO, orcodata, mesh->totvert, nullptr);
BKE_mesh_orco_verts_transform(mesh, orcodata, mesh->verts_num, false);
CustomData_add_layer_with_data(&mesh->vert_data, CD_ORCO, orcodata, mesh->verts_num, nullptr);
}
Mesh *BKE_mesh_from_object(Object *ob)

View File

@ -195,7 +195,7 @@ void MeshesToIMeshInfo::input_mvert_for_orig_index(int orig_index,
BLI_assert(0 <= orig_mesh_index && orig_mesh_index < meshes.size());
const Mesh *mesh = meshes[orig_mesh_index];
int index_in_mesh = orig_index - mesh_vert_offset[orig_mesh_index];
BLI_assert(0 <= index_in_mesh && index_in_mesh < mesh->totvert);
BLI_assert(0 <= index_in_mesh && index_in_mesh < mesh->verts_num);
if (r_orig_mesh) {
*r_orig_mesh = mesh;
}
@ -213,7 +213,7 @@ void MeshesToIMeshInfo::input_medge_for_orig_index(int orig_index,
BLI_assert(0 <= orig_mesh_index && orig_mesh_index < meshes.size());
const Mesh *mesh = meshes[orig_mesh_index];
int index_in_mesh = orig_index - mesh_edge_offset[orig_mesh_index];
BLI_assert(0 <= index_in_mesh && index_in_mesh < mesh->totedge);
BLI_assert(0 <= index_in_mesh && index_in_mesh < mesh->edges_num);
if (r_orig_mesh) {
*r_orig_mesh = mesh;
}
@ -250,8 +250,8 @@ static IMesh meshes_to_imesh(Span<const Mesh *> meshes,
int &totedge = r_info->tot_meshes_edges;
int &faces_num = r_info->tot_meshes_polys;
for (const Mesh *mesh : meshes) {
totvert += mesh->totvert;
totedge += mesh->totedge;
totvert += mesh->verts_num;
totedge += mesh->edges_num;
faces_num += mesh->faces_num;
}
@ -307,7 +307,7 @@ static IMesh meshes_to_imesh(Span<const Mesh *> meshes,
* that would have a negative transform if you do that. */
bool need_face_flip = r_info->has_negative_transform[mi] != r_info->has_negative_transform[0];
Vector<Vert *> verts(mesh->totvert);
Vector<Vert *> verts(mesh->verts_num);
const Span<float3> vert_positions = mesh->vert_positions();
const OffsetIndices faces = mesh->faces();
const Span<int> corner_verts = mesh->corner_verts();
@ -364,7 +364,7 @@ static IMesh meshes_to_imesh(Span<const Mesh *> meshes,
r_info->mesh_to_imesh_face[f] = arena.add_face(face_vert, f, face_edge_orig);
++f;
}
e += mesh->totedge;
e += mesh->edges_num;
}
return IMesh(r_info->mesh_to_imesh_face);
}
@ -495,7 +495,7 @@ static int fill_orig_loops(const Face *f,
}
int orig_me_vert_offset = mim.mesh_vert_offset[orig_me_index];
int first_orig_v_in_orig_me = first_orig_v - orig_me_vert_offset;
BLI_assert(0 <= first_orig_v_in_orig_me && first_orig_v_in_orig_me < orig_me->totvert);
BLI_assert(0 <= first_orig_v_in_orig_me && first_orig_v_in_orig_me < orig_me->verts_num);
/* Assume all vertices in each face is unique. */
int offset = -1;
for (int i = 0; i < orig_mplen; ++i) {
@ -515,7 +515,7 @@ static int fill_orig_loops(const Face *f,
int fv_orig = f->vert[mp_loop_index]->orig;
if (fv_orig != NO_INDEX) {
fv_orig -= orig_me_vert_offset;
if (fv_orig < 0 || fv_orig >= orig_me->totvert) {
if (fv_orig < 0 || fv_orig >= orig_me->verts_num) {
fv_orig = NO_INDEX;
}
}
@ -525,7 +525,7 @@ static int fill_orig_loops(const Face *f,
int fvnext_orig = f->vert[(mp_loop_index + 1) % orig_mplen]->orig;
if (fvnext_orig != NO_INDEX) {
fvnext_orig -= orig_me_vert_offset;
if (fvnext_orig < 0 || fvnext_orig >= orig_me->totvert) {
if (fvnext_orig < 0 || fvnext_orig >= orig_me->verts_num) {
fvnext_orig = NO_INDEX;
}
}
@ -639,7 +639,7 @@ static void copy_or_interp_loop_attributes(Mesh *dest_mesh,
src_blocks_ofs[j] = POINTER_OFFSET(layer, size * (orig_face[j]));
}
void *dst_layer = CustomData_get_layer_n_for_write(
target_cd, ty, target_layer_type_index, dest_mesh->totloop);
target_cd, ty, target_layer_type_index, dest_mesh->corners_num);
void *dst_block_ofs = POINTER_OFFSET(dst_layer, size * loop_index);
CustomData_bmesh_interp_n(target_cd,
src_blocks_ofs.data(),
@ -663,19 +663,19 @@ static void merge_vertex_loop_face_customdata_layers(Mesh *target, MeshesToIMesh
{
for (int mesh_index = 1; mesh_index < mim.meshes.size(); ++mesh_index) {
const Mesh *mesh = mim.meshes[mesh_index];
if (mesh->totvert) {
if (mesh->verts_num) {
CustomData_merge_layout(&mesh->vert_data,
&target->vert_data,
CD_MASK_MESH.vmask,
CD_SET_DEFAULT,
target->totvert);
target->verts_num);
}
if (mesh->totloop) {
if (mesh->corners_num) {
CustomData_merge_layout(&mesh->loop_data,
&target->loop_data,
CD_MASK_MESH.lmask,
CD_SET_DEFAULT,
target->totloop);
target->corners_num);
}
if (mesh->faces_num) {
CustomData_merge_layout(&mesh->face_data,
@ -691,12 +691,12 @@ static void merge_edge_customdata_layers(Mesh *target, MeshesToIMeshInfo &mim)
{
for (int mesh_index = 0; mesh_index < mim.meshes.size(); ++mesh_index) {
const Mesh *mesh = mim.meshes[mesh_index];
if (mesh->totedge) {
if (mesh->edges_num) {
CustomData_merge_layout(&mesh->edge_data,
&target->edge_data,
CD_MASK_MESH.emask,
CD_SET_DEFAULT,
target->totedge);
target->edges_num);
}
}
}

View File

@ -42,7 +42,8 @@ static void reserve_hash_maps(const Mesh *mesh,
const bool keep_existing_edges,
MutableSpan<EdgeMap> edge_maps)
{
const int totedge_guess = std::max(keep_existing_edges ? mesh->totedge : 0, mesh->faces_num * 2);
const int totedge_guess = std::max(keep_existing_edges ? mesh->edges_num : 0,
mesh->faces_num * 2);
threading::parallel_for_each(
edge_maps, [&](EdgeMap &edge_map) { edge_map.reserve(totedge_guess / edge_maps.size()); });
}
@ -217,9 +218,9 @@ void BKE_mesh_calc_edges(Mesh *mesh, bool keep_existing_edges, const bool select
mesh->corner_edges_for_write());
/* Free old CustomData and assign new one. */
CustomData_free(&mesh->edge_data, mesh->totedge);
CustomData_free(&mesh->edge_data, mesh->edges_num);
CustomData_reset(&mesh->edge_data);
mesh->totedge = new_totedge;
mesh->edges_num = new_totedge;
attributes.add<int2>(".edge_verts", ATTR_DOMAIN_EDGE, AttributeInitMoveArray(new_edges.data()));
if (select_new_edges) {

View File

@ -684,11 +684,11 @@ static std::optional<MeshMismatch> construct_vertex_mapping(const Mesh &mesh1,
Array<int> vert_to_edge_offsets1;
Array<int> vert_to_edge_indices1;
const GroupedSpan<int> vert_to_edge_map1 = mesh::build_vert_to_edge_map(
mesh1.edges(), mesh1.totvert, vert_to_edge_offsets1, vert_to_edge_indices1);
mesh1.edges(), mesh1.verts_num, vert_to_edge_offsets1, vert_to_edge_indices1);
Array<int> vert_to_edge_offsets2;
Array<int> vert_to_edge_indices2;
const GroupedSpan<int> vert_to_edge_map2 = mesh::build_vert_to_edge_map(
mesh2.edges(), mesh2.totvert, vert_to_edge_offsets2, vert_to_edge_indices2);
mesh2.edges(), mesh2.verts_num, vert_to_edge_offsets2, vert_to_edge_indices2);
for (const int sorted_i : verts.from_sorted1.index_range()) {
const int vert1 = verts.from_sorted1[sorted_i];
@ -768,13 +768,13 @@ std::optional<MeshMismatch> compare_meshes(const Mesh &mesh1,
{
/* These will be assumed implicitly later on. */
if (mesh1.totvert != mesh2.totvert) {
if (mesh1.verts_num != mesh2.verts_num) {
return MeshMismatch::NumVerts;
}
if (mesh1.totedge != mesh2.totedge) {
if (mesh1.edges_num != mesh2.edges_num) {
return MeshMismatch::NumEdges;
}
if (mesh1.totloop != mesh2.totloop) {
if (mesh1.corners_num != mesh2.corners_num) {
return MeshMismatch::NumCorners;
}
if (mesh1.faces_num != mesh2.faces_num) {
@ -790,7 +790,7 @@ std::optional<MeshMismatch> compare_meshes(const Mesh &mesh1,
return mismatch;
}
IndexMapping verts(mesh1.totvert);
IndexMapping verts(mesh1.verts_num);
mismatch = sort_domain_using_attributes(
mesh1_attributes, mesh2_attributes, ATTR_DOMAIN_POINT, {}, verts, threshold);
if (mismatch) {
@ -800,7 +800,7 @@ std::optional<MeshMismatch> compare_meshes(const Mesh &mesh1,
/* We need the maps going the other way as well. */
verts.recalculate_inverse_maps();
IndexMapping edges(mesh1.totedge);
IndexMapping edges(mesh1.edges_num);
if (!sort_edges(mesh1.edges(), mesh2.edges(), verts, edges)) {
return MeshMismatch::EdgeTopology;
}
@ -814,7 +814,7 @@ std::optional<MeshMismatch> compare_meshes(const Mesh &mesh1,
/* We need the maps going the other way as well. */
edges.recalculate_inverse_maps();
IndexMapping corners(mesh1.totloop);
IndexMapping corners(mesh1.corners_num);
if (!sort_corners_based_on_domain(mesh1.corner_verts(), mesh2.corner_verts(), verts, corners)) {
return MeshMismatch::FaceTopology;
}

View File

@ -551,9 +551,9 @@ void BKE_mesh_to_pointcloud(Main *bmain, Depsgraph *depsgraph, Scene * /*scene*/
PointCloud *pointcloud = (PointCloud *)BKE_pointcloud_add(bmain, ob->id.name + 2);
CustomData_free(&pointcloud->pdata, pointcloud->totpoint);
pointcloud->totpoint = mesh_eval->totvert;
pointcloud->totpoint = mesh_eval->verts_num;
CustomData_merge(
&mesh_eval->vert_data, &pointcloud->pdata, CD_MASK_PROP_ALL, mesh_eval->totvert);
&mesh_eval->vert_data, &pointcloud->pdata, CD_MASK_PROP_ALL, mesh_eval->verts_num);
BKE_id_materials_copy(bmain, (ID *)ob->data, (ID *)pointcloud);
@ -575,7 +575,7 @@ void BKE_pointcloud_to_mesh(Main *bmain, Depsgraph *depsgraph, Scene * /*scene*/
Mesh *mesh = BKE_mesh_add(bmain, ob->id.name + 2);
if (const PointCloud *points = geometry.get_pointcloud()) {
mesh->totvert = points->totpoint;
mesh->verts_num = points->totpoint;
CustomData_merge(&points->pdata, &mesh->vert_data, CD_MASK_PROP_ALL, points->totpoint);
}
@ -1032,21 +1032,21 @@ static void move_shapekey_layers_to_keyblocks(const Mesh &mesh,
KeyBlock *kb = keyblock_ensure_from_uid(key_dst, layer.uid, layer.name);
MEM_SAFE_FREE(kb->data);
kb->totelem = mesh.totvert;
kb->totelem = mesh.verts_num;
kb->data = MEM_malloc_arrayN(kb->totelem, sizeof(float3), __func__);
MutableSpan<float3> kb_coords(static_cast<float3 *>(kb->data), kb->totelem);
if (kb->uid == actshape_uid) {
mesh.attributes().lookup<float3>("position").varray.materialize(kb_coords);
}
else {
kb_coords.copy_from({static_cast<const float3 *>(layer.data), mesh.totvert});
kb_coords.copy_from({static_cast<const float3 *>(layer.data), mesh.verts_num});
}
}
LISTBASE_FOREACH (KeyBlock *, kb, &key_dst.block) {
if (kb->totelem != mesh.totvert) {
if (kb->totelem != mesh.verts_num) {
MEM_SAFE_FREE(kb->data);
kb->totelem = mesh.totvert;
kb->totelem = mesh.verts_num;
kb->data = MEM_cnew_array<float3>(kb->totelem, __func__);
CLOG_ERROR(&LOG, "Data for shape key '%s' on mesh missing from evaluated mesh ", kb->name);
}
@ -1063,18 +1063,18 @@ void BKE_mesh_nomain_to_mesh(Mesh *mesh_src, Mesh *mesh_dst, Object *ob)
BKE_mesh_clear_geometry_and_metadata(mesh_dst);
const bool verts_num_changed = mesh_dst->totvert != mesh_src->totvert;
mesh_dst->totvert = mesh_src->totvert;
mesh_dst->totedge = mesh_src->totedge;
const bool verts_num_changed = mesh_dst->verts_num != mesh_src->verts_num;
mesh_dst->verts_num = mesh_src->verts_num;
mesh_dst->edges_num = mesh_src->edges_num;
mesh_dst->faces_num = mesh_src->faces_num;
mesh_dst->totloop = mesh_src->totloop;
mesh_dst->corners_num = mesh_src->corners_num;
/* Using #CD_MASK_MESH ensures that only data that should exist in Main meshes is moved. */
const CustomData_MeshMasks mask = CD_MASK_MESH;
CustomData_copy(&mesh_src->vert_data, &mesh_dst->vert_data, mask.vmask, mesh_src->totvert);
CustomData_copy(&mesh_src->edge_data, &mesh_dst->edge_data, mask.emask, mesh_src->totedge);
CustomData_copy(&mesh_src->vert_data, &mesh_dst->vert_data, mask.vmask, mesh_src->verts_num);
CustomData_copy(&mesh_src->edge_data, &mesh_dst->edge_data, mask.emask, mesh_src->edges_num);
CustomData_copy(&mesh_src->face_data, &mesh_dst->face_data, mask.pmask, mesh_src->faces_num);
CustomData_copy(&mesh_src->loop_data, &mesh_dst->loop_data, mask.lmask, mesh_src->totloop);
CustomData_copy(&mesh_src->loop_data, &mesh_dst->loop_data, mask.lmask, mesh_src->corners_num);
std::swap(mesh_dst->face_offset_indices, mesh_src->face_offset_indices);
std::swap(mesh_dst->runtime->face_offsets_sharing_info,
mesh_src->runtime->face_offsets_sharing_info);
@ -1115,16 +1115,16 @@ void BKE_mesh_nomain_to_meshkey(Mesh *mesh_src, Mesh *mesh_dst, KeyBlock *kb)
{
BLI_assert(mesh_src->id.tag & LIB_TAG_NO_MAIN);
const int totvert = mesh_src->totvert;
const int totvert = mesh_src->verts_num;
if (totvert == 0 || mesh_dst->totvert == 0 || mesh_dst->totvert != totvert) {
if (totvert == 0 || mesh_dst->verts_num == 0 || mesh_dst->verts_num != totvert) {
return;
}
if (kb->data) {
MEM_freeN(kb->data);
}
kb->data = MEM_malloc_arrayN(mesh_dst->key->elemsize, mesh_dst->totvert, "kb->data");
kb->data = MEM_malloc_arrayN(mesh_dst->key->elemsize, mesh_dst->verts_num, "kb->data");
kb->totelem = totvert;
MutableSpan(static_cast<float3 *>(kb->data), kb->totelem).copy_from(mesh_src->vert_positions());
}

View File

@ -37,8 +37,8 @@ char *BKE_mesh_debug_info(const Mesh *mesh)
BLI_dynstr_append(dynstr, "{\n");
BLI_dynstr_appendf(dynstr, " 'ptr': '%p',\n", (void *)mesh);
BLI_dynstr_appendf(dynstr, " 'totvert': %d,\n", mesh->totvert);
BLI_dynstr_appendf(dynstr, " 'totedge': %d,\n", mesh->totedge);
BLI_dynstr_appendf(dynstr, " 'totvert': %d,\n", mesh->verts_num);
BLI_dynstr_appendf(dynstr, " 'totedge': %d,\n", mesh->edges_num);
BLI_dynstr_appendf(dynstr, " 'totface': %d,\n", mesh->totface_legacy);
BLI_dynstr_appendf(dynstr, " 'faces_num': %d,\n", mesh->faces_num);

View File

@ -252,10 +252,10 @@ bool BKE_mesh_center_median(const Mesh *mesh, float r_cent[3])
add_v3_v3(r_cent, positions[i]);
}
/* otherwise we get NAN for 0 verts */
if (mesh->totvert) {
mul_v3_fl(r_cent, 1.0f / float(mesh->totvert));
if (mesh->verts_num) {
mul_v3_fl(r_cent, 1.0f / float(mesh->verts_num));
}
return (mesh->totvert != 0);
return (mesh->verts_num != 0);
}
bool BKE_mesh_center_median_from_faces(const Mesh *mesh, float r_cent[3])

View File

@ -196,8 +196,8 @@ class MeshFairingContext : public FairingContext {
public:
MeshFairingContext(Mesh *mesh, MutableSpan<float3> deform_positions)
{
totvert_ = mesh->totvert;
totloop_ = mesh->totloop;
totvert_ = mesh->verts_num;
totloop_ = mesh->corners_num;
MutableSpan<float3> positions = mesh->vert_positions_for_write();
edges_ = mesh->edges();
@ -207,14 +207,14 @@ class MeshFairingContext : public FairingContext {
vlmap_ = mesh->vert_to_corner_map();
/* Deformation coords. */
co_.resize(mesh->totvert);
co_.resize(mesh->verts_num);
if (!deform_positions.is_empty()) {
for (int i = 0; i < mesh->totvert; i++) {
for (int i = 0; i < mesh->verts_num; i++) {
co_[i] = deform_positions[i];
}
}
else {
for (int i = 0; i < mesh->totvert; i++) {
for (int i = 0; i < mesh->verts_num; i++) {
co_[i] = positions[i];
}
}

View File

@ -63,7 +63,7 @@ void mesh_flip_faces(Mesh &mesh, const IndexMask &selection)
flip_custom_data_type<OrigSpaceLoop>(faces, mesh.loop_data, selection, CD_ORIGSPACE_MLOOP);
flip_custom_data_type<MDisps>(faces, mesh.loop_data, selection, CD_MDISPS);
if (MDisps *mdisp = static_cast<MDisps *>(
CustomData_get_layer_for_write(&mesh.loop_data, CD_MDISPS, mesh.totloop)))
CustomData_get_layer_for_write(&mesh.loop_data, CD_MDISPS, mesh.corners_num)))
{
selection.foreach_index(GrainSize(512), [&](const int i) {
for (const int corner : faces[i]) {

View File

@ -73,7 +73,7 @@ void BKE_mesh_foreach_mapped_vert(
}
if (index) {
for (int i = 0; i < mesh->totvert; i++) {
for (int i = 0; i < mesh->verts_num; i++) {
const float *no = (flag & MESH_FOREACH_USE_NORMAL) ? &vert_normals[i].x : nullptr;
const int orig = *index++;
if (orig == ORIGINDEX_NONE) {
@ -83,7 +83,7 @@ void BKE_mesh_foreach_mapped_vert(
}
}
else {
for (int i = 0; i < mesh->totvert; i++) {
for (int i = 0; i < mesh->verts_num; i++) {
const float *no = (flag & MESH_FOREACH_USE_NORMAL) ? &vert_normals[i].x : nullptr;
func(user_data, i, positions[i], no);
}
@ -135,7 +135,7 @@ void BKE_mesh_foreach_mapped_edge(
func(user_data, orig, positions[edges[i][0]], positions[edges[i][1]]);
}
}
else if (mesh->totedge == tot_edges) {
else if (mesh->edges_num == tot_edges) {
for (const int i : edges.index_range()) {
func(user_data, i, positions[edges[i][0]], positions[edges[i][1]]);
}

View File

@ -220,30 +220,31 @@ void BKE_mesh_calc_edges_legacy(Mesh *mesh)
MEdge *edges;
int totedge = 0;
const Span<MVert> verts(
static_cast<const MVert *>(CustomData_get_layer(&mesh->vert_data, CD_MVERT)), mesh->totvert);
static_cast<const MVert *>(CustomData_get_layer(&mesh->vert_data, CD_MVERT)),
mesh->verts_num);
mesh_calc_edges_mdata(
verts.data(),
mesh->mface,
static_cast<MLoop *>(
CustomData_get_layer_for_write(&mesh->loop_data, CD_MLOOP, mesh->totloop)),
CustomData_get_layer_for_write(&mesh->loop_data, CD_MLOOP, mesh->corners_num)),
static_cast<const MPoly *>(CustomData_get_layer(&mesh->face_data, CD_MPOLY)),
verts.size(),
mesh->totface_legacy,
mesh->totloop,
mesh->corners_num,
mesh->faces_num,
&edges,
&totedge);
if (totedge == 0) {
/* flag that mesh has edges */
mesh->totedge = 0;
mesh->edges_num = 0;
return;
}
edges = (MEdge *)CustomData_add_layer_with_data(
&mesh->edge_data, CD_MEDGE, edges, totedge, nullptr);
mesh->totedge = totedge;
mesh->edges_num = totedge;
mesh->tag_topology_changed();
BKE_mesh_strip_loose_faces(mesh);
@ -285,9 +286,11 @@ void BKE_mesh_do_versions_cd_flag_init(Mesh *mesh)
}
const Span<MVert> verts(
static_cast<const MVert *>(CustomData_get_layer(&mesh->vert_data, CD_MVERT)), mesh->totvert);
static_cast<const MVert *>(CustomData_get_layer(&mesh->vert_data, CD_MVERT)),
mesh->verts_num);
const Span<MEdge> edges(
static_cast<const MEdge *>(CustomData_get_layer(&mesh->edge_data, CD_MEDGE)), mesh->totedge);
static_cast<const MEdge *>(CustomData_get_layer(&mesh->edge_data, CD_MEDGE)),
mesh->edges_num);
for (const MVert &vert : verts) {
if (vert.bweight_legacy != 0) {
@ -731,13 +734,13 @@ void BKE_mesh_convert_mfaces_to_mpolys(Mesh *mesh)
&mesh->fdata_legacy,
&mesh->loop_data,
&mesh->face_data,
mesh->totedge,
mesh->edges_num,
mesh->totface_legacy,
mesh->totloop,
mesh->corners_num,
mesh->faces_num,
mesh->edges_for_write().data(),
(MFace *)CustomData_get_layer(&mesh->fdata_legacy, CD_MFACE),
&mesh->totloop,
&mesh->corners_num,
&mesh->faces_num);
BKE_mesh_legacy_convert_loops_to_corners(mesh);
BKE_mesh_legacy_convert_polys_to_offsets(mesh);
@ -791,13 +794,13 @@ void BKE_mesh_do_versions_convert_mfaces_to_mpolys(Mesh *mesh)
&mesh->fdata_legacy,
&mesh->loop_data,
&mesh->face_data,
mesh->totedge,
mesh->edges_num,
mesh->totface_legacy,
mesh->totloop,
mesh->corners_num,
mesh->faces_num,
mesh->edges_for_write().data(),
(MFace *)CustomData_get_layer(&mesh->fdata_legacy, CD_MFACE),
&mesh->totloop,
&mesh->corners_num,
&mesh->faces_num);
BKE_mesh_legacy_convert_loops_to_corners(mesh);
BKE_mesh_legacy_convert_polys_to_offsets(mesh);
@ -1246,7 +1249,7 @@ void BKE_mesh_tessface_calc(Mesh *mesh)
&mesh->face_data,
reinterpret_cast<float(*)[3]>(mesh->vert_positions_for_write().data()),
mesh->totface_legacy,
mesh->totloop,
mesh->corners_num,
mesh->faces_num);
mesh_ensure_tessellation_customdata(mesh);
@ -1416,7 +1419,7 @@ void BKE_mesh_legacy_bevel_weight_to_layers(Mesh *mesh)
{
using namespace blender;
if (mesh->mvert && !CustomData_has_layer(&mesh->vert_data, CD_BWEIGHT)) {
const Span<MVert> verts(mesh->mvert, mesh->totvert);
const Span<MVert> verts(mesh->mvert, mesh->verts_num);
if (mesh->cd_flag & ME_CDFLAG_VERT_BWEIGHT) {
float *weights = static_cast<float *>(
CustomData_add_layer(&mesh->vert_data, CD_BWEIGHT, CD_CONSTRUCT, verts.size()));
@ -1427,7 +1430,7 @@ void BKE_mesh_legacy_bevel_weight_to_layers(Mesh *mesh)
}
if (mesh->medge && !CustomData_has_layer(&mesh->edge_data, CD_BWEIGHT)) {
const Span<MEdge> edges(mesh->medge, mesh->totedge);
const Span<MEdge> edges(mesh->medge, mesh->edges_num);
if (mesh->cd_flag & ME_CDFLAG_EDGE_BWEIGHT) {
float *weights = static_cast<float *>(
CustomData_add_layer(&mesh->edge_data, CD_BWEIGHT, CD_CONSTRUCT, edges.size()));
@ -1471,11 +1474,11 @@ void BKE_mesh_legacy_bevel_weight_to_generic(Mesh *mesh)
{
if (!mesh->attributes().contains("bevel_weight_vert")) {
replace_custom_data_layer_with_named(
mesh->vert_data, CD_BWEIGHT, CD_PROP_FLOAT, mesh->totvert, "bevel_weight_vert");
mesh->vert_data, CD_BWEIGHT, CD_PROP_FLOAT, mesh->verts_num, "bevel_weight_vert");
}
if (!mesh->attributes().contains("bevel_weight_edge")) {
replace_custom_data_layer_with_named(
mesh->edge_data, CD_BWEIGHT, CD_PROP_FLOAT, mesh->totedge, "bevel_weight_edge");
mesh->edge_data, CD_BWEIGHT, CD_PROP_FLOAT, mesh->edges_num, "bevel_weight_edge");
}
}
@ -1494,7 +1497,7 @@ void BKE_mesh_legacy_edge_crease_to_layers(Mesh *mesh)
if (CustomData_has_layer(&mesh->edge_data, CD_CREASE)) {
return;
}
const Span<MEdge> edges(mesh->medge, mesh->totedge);
const Span<MEdge> edges(mesh->medge, mesh->edges_num);
if (mesh->cd_flag & ME_CDFLAG_EDGE_CREASE) {
float *creases = static_cast<float *>(
CustomData_add_layer(&mesh->edge_data, CD_CREASE, CD_CONSTRUCT, edges.size()));
@ -1508,11 +1511,11 @@ void BKE_mesh_legacy_crease_to_generic(Mesh *mesh)
{
if (!mesh->attributes().contains("crease_vert")) {
replace_custom_data_layer_with_named(
mesh->vert_data, CD_CREASE, CD_PROP_FLOAT, mesh->totvert, "crease_vert");
mesh->vert_data, CD_CREASE, CD_PROP_FLOAT, mesh->verts_num, "crease_vert");
}
if (!mesh->attributes().contains("crease_edge")) {
replace_custom_data_layer_with_named(
mesh->edge_data, CD_CREASE, CD_PROP_FLOAT, mesh->totedge, "crease_edge");
mesh->edge_data, CD_CREASE, CD_PROP_FLOAT, mesh->edges_num, "crease_edge");
}
}
@ -1529,7 +1532,7 @@ void BKE_mesh_legacy_sharp_edges_from_flags(Mesh *mesh)
if (!mesh->medge) {
return;
}
const Span<MEdge> edges(mesh->medge, mesh->totedge);
const Span<MEdge> edges(mesh->medge, mesh->edges_num);
MutableAttributeAccessor attributes = mesh->attributes_for_write();
if (attributes.contains("sharp_edge")) {
return;
@ -1562,7 +1565,7 @@ void BKE_mesh_legacy_uv_seam_from_flags(Mesh *mesh)
if (!mesh->medge) {
return;
}
MutableSpan<MEdge> edges(mesh->medge, mesh->totedge);
MutableSpan<MEdge> edges(mesh->medge, mesh->edges_num);
MutableAttributeAccessor attributes = mesh->attributes_for_write();
if (attributes.contains(".uv_seam")) {
return;
@ -1598,7 +1601,7 @@ void BKE_mesh_legacy_convert_flags_to_hide_layers(Mesh *mesh)
{
return;
}
const Span<MVert> verts(mesh->mvert, mesh->totvert);
const Span<MVert> verts(mesh->mvert, mesh->verts_num);
if (std::any_of(verts.begin(), verts.end(), [](const MVert &vert) {
return vert.flag_legacy & ME_HIDE;
}))
@ -1614,7 +1617,7 @@ void BKE_mesh_legacy_convert_flags_to_hide_layers(Mesh *mesh)
}
if (mesh->medge) {
const Span<MEdge> edges(mesh->medge, mesh->totedge);
const Span<MEdge> edges(mesh->medge, mesh->edges_num);
if (std::any_of(edges.begin(), edges.end(), [](const MEdge &edge) {
return edge.flag_legacy & ME_HIDE;
}))
@ -1709,7 +1712,7 @@ void BKE_mesh_legacy_convert_uvs_to_generic(Mesh *mesh)
const MLoopUV *mloopuv = static_cast<const MLoopUV *>(
CustomData_get_layer_named(&mesh->loop_data, CD_MLOOPUV, uv_names[i].c_str()));
const uint32_t needed_boolean_attributes = threading::parallel_reduce(
IndexRange(mesh->totloop),
IndexRange(mesh->corners_num),
4096,
0,
[&](const IndexRange range, uint32_t init) {
@ -1721,23 +1724,23 @@ void BKE_mesh_legacy_convert_uvs_to_generic(Mesh *mesh)
[](const uint32_t a, const uint32_t b) { return a | b; });
float2 *coords = static_cast<float2 *>(
MEM_malloc_arrayN(mesh->totloop, sizeof(float2), __func__));
MEM_malloc_arrayN(mesh->corners_num, sizeof(float2), __func__));
bool *vert_selection = nullptr;
bool *edge_selection = nullptr;
bool *pin = nullptr;
if (needed_boolean_attributes & MLOOPUV_VERTSEL) {
vert_selection = static_cast<bool *>(
MEM_malloc_arrayN(mesh->totloop, sizeof(bool), __func__));
MEM_malloc_arrayN(mesh->corners_num, sizeof(bool), __func__));
}
if (needed_boolean_attributes & MLOOPUV_EDGESEL) {
edge_selection = static_cast<bool *>(
MEM_malloc_arrayN(mesh->totloop, sizeof(bool), __func__));
MEM_malloc_arrayN(mesh->corners_num, sizeof(bool), __func__));
}
if (needed_boolean_attributes & MLOOPUV_PINNED) {
pin = static_cast<bool *>(MEM_malloc_arrayN(mesh->totloop, sizeof(bool), __func__));
pin = static_cast<bool *>(MEM_malloc_arrayN(mesh->corners_num, sizeof(bool), __func__));
}
threading::parallel_for(IndexRange(mesh->totloop), 4096, [&](IndexRange range) {
threading::parallel_for(IndexRange(mesh->corners_num), 4096, [&](IndexRange range) {
for (const int i : range) {
coords[i] = mloopuv[i].uv;
}
@ -1758,20 +1761,20 @@ void BKE_mesh_legacy_convert_uvs_to_generic(Mesh *mesh)
}
});
CustomData_free_layer_named(&mesh->loop_data, uv_names[i].c_str(), mesh->totloop);
CustomData_free_layer_named(&mesh->loop_data, uv_names[i].c_str(), mesh->corners_num);
char new_name[MAX_CUSTOMDATA_LAYER_NAME];
BKE_id_attribute_calc_unique_name(&mesh->id, uv_names[i].c_str(), new_name);
uv_names[i] = new_name;
CustomData_add_layer_named_with_data(
&mesh->loop_data, CD_PROP_FLOAT2, coords, mesh->totloop, new_name, nullptr);
&mesh->loop_data, CD_PROP_FLOAT2, coords, mesh->corners_num, new_name, nullptr);
char buffer[MAX_CUSTOMDATA_LAYER_NAME];
if (vert_selection) {
CustomData_add_layer_named_with_data(&mesh->loop_data,
CD_PROP_BOOL,
vert_selection,
mesh->totloop,
mesh->corners_num,
BKE_uv_map_vert_select_name_get(new_name, buffer),
nullptr);
}
@ -1779,7 +1782,7 @@ void BKE_mesh_legacy_convert_uvs_to_generic(Mesh *mesh)
CustomData_add_layer_named_with_data(&mesh->loop_data,
CD_PROP_BOOL,
edge_selection,
mesh->totloop,
mesh->corners_num,
BKE_uv_map_edge_select_name_get(new_name, buffer),
nullptr);
}
@ -1787,7 +1790,7 @@ void BKE_mesh_legacy_convert_uvs_to_generic(Mesh *mesh)
CustomData_add_layer_named_with_data(&mesh->loop_data,
CD_PROP_BOOL,
pin,
mesh->totloop,
mesh->corners_num,
BKE_uv_map_pin_name_get(new_name, buffer),
nullptr);
}
@ -1825,7 +1828,7 @@ void BKE_mesh_legacy_convert_flags_to_selection_layers(Mesh *mesh)
return;
}
const Span<MVert> verts(mesh->mvert, mesh->totvert);
const Span<MVert> verts(mesh->mvert, mesh->verts_num);
if (std::any_of(
verts.begin(), verts.end(), [](const MVert &vert) { return vert.flag_legacy & SELECT; }))
{
@ -1840,7 +1843,7 @@ void BKE_mesh_legacy_convert_flags_to_selection_layers(Mesh *mesh)
}
if (mesh->medge) {
const Span<MEdge> edges(mesh->medge, mesh->totedge);
const Span<MEdge> edges(mesh->medge, mesh->edges_num);
if (std::any_of(edges.begin(), edges.end(), [](const MEdge &edge) {
return edge.flag_legacy & SELECT;
}))
@ -1890,18 +1893,18 @@ void BKE_mesh_legacy_convert_verts_to_positions(Mesh *mesh)
return;
}
const Span<MVert> verts(mvert, mesh->totvert);
const Span<MVert> verts(mvert, mesh->verts_num);
MutableSpan<float3> positions(
static_cast<float3 *>(CustomData_add_layer_named(
&mesh->vert_data, CD_PROP_FLOAT3, CD_CONSTRUCT, mesh->totvert, "position")),
mesh->totvert);
&mesh->vert_data, CD_PROP_FLOAT3, CD_CONSTRUCT, mesh->verts_num, "position")),
mesh->verts_num);
threading::parallel_for(verts.index_range(), 2048, [&](IndexRange range) {
for (const int i : range) {
positions[i] = verts[i].co_legacy;
}
});
CustomData_free_layers(&mesh->vert_data, CD_MVERT, mesh->totvert);
CustomData_free_layers(&mesh->vert_data, CD_MVERT, mesh->verts_num);
mesh->mvert = nullptr;
}
@ -1921,18 +1924,18 @@ void BKE_mesh_legacy_convert_edges_to_generic(Mesh *mesh)
return;
}
const Span<MEdge> legacy_edges(medge, mesh->totedge);
const Span<MEdge> legacy_edges(medge, mesh->edges_num);
MutableSpan<int2> edges(
static_cast<int2 *>(CustomData_add_layer_named(
&mesh->edge_data, CD_PROP_INT32_2D, CD_CONSTRUCT, mesh->totedge, ".edge_verts")),
mesh->totedge);
&mesh->edge_data, CD_PROP_INT32_2D, CD_CONSTRUCT, mesh->edges_num, ".edge_verts")),
mesh->edges_num);
threading::parallel_for(legacy_edges.index_range(), 2048, [&](IndexRange range) {
for (const int i : range) {
edges[i] = int2(legacy_edges[i].v1, legacy_edges[i].v2);
}
});
CustomData_free_layers(&mesh->edge_data, CD_MEDGE, mesh->totedge);
CustomData_free_layers(&mesh->edge_data, CD_MEDGE, mesh->edges_num);
mesh->medge = nullptr;
}
@ -2021,15 +2024,16 @@ void BKE_mesh_legacy_convert_loops_to_corners(Mesh *mesh)
return;
}
const Span<MLoop> loops(
static_cast<const MLoop *>(CustomData_get_layer(&mesh->loop_data, CD_MLOOP)), mesh->totloop);
static_cast<const MLoop *>(CustomData_get_layer(&mesh->loop_data, CD_MLOOP)),
mesh->corners_num);
MutableSpan<int> corner_verts(
static_cast<int *>(CustomData_add_layer_named(
&mesh->loop_data, CD_PROP_INT32, CD_CONSTRUCT, mesh->totloop, ".corner_vert")),
mesh->totloop);
&mesh->loop_data, CD_PROP_INT32, CD_CONSTRUCT, mesh->corners_num, ".corner_vert")),
mesh->corners_num);
MutableSpan<int> corner_edges(
static_cast<int *>(CustomData_add_layer_named(
&mesh->loop_data, CD_PROP_INT32, CD_CONSTRUCT, mesh->totloop, ".corner_edge")),
mesh->totloop);
&mesh->loop_data, CD_PROP_INT32, CD_CONSTRUCT, mesh->corners_num, ".corner_edge")),
mesh->corners_num);
threading::parallel_for(loops.index_range(), 2048, [&](IndexRange range) {
for (const int i : range) {
corner_verts[i] = loops[i].v;
@ -2037,7 +2041,7 @@ void BKE_mesh_legacy_convert_loops_to_corners(Mesh *mesh)
}
});
CustomData_free_layers(&mesh->loop_data, CD_MLOOP, mesh->totloop);
CustomData_free_layers(&mesh->loop_data, CD_MLOOP, mesh->corners_num);
}
/** \} */
@ -2318,13 +2322,13 @@ void mesh_sculpt_mask_to_generic(Mesh &mesh)
sharing_info = layer.sharing_info;
layer.data = nullptr;
layer.sharing_info = nullptr;
CustomData_free_layer(&mesh.vert_data, CD_PAINT_MASK, mesh.totvert, i);
CustomData_free_layer(&mesh.vert_data, CD_PAINT_MASK, mesh.verts_num, i);
break;
}
}
if (data != nullptr) {
CustomData_add_layer_named_with_data(
&mesh.vert_data, CD_PROP_FLOAT, data, mesh.totvert, ".sculpt_mask", sharing_info);
&mesh.vert_data, CD_PROP_FLOAT, data, mesh.verts_num, ".sculpt_mask", sharing_info);
}
if (sharing_info != nullptr) {
sharing_info->remove_user_and_delete_if_last();

View File

@ -106,7 +106,7 @@ static void merge_uvs_for_vertex(const Span<int> loops_for_vert, Span<float2 *>
void BKE_mesh_merge_customdata_for_apply_modifier(Mesh *mesh)
{
if (mesh->totloop == 0) {
if (mesh->corners_num == 0) {
return;
}
const int mloopuv_layers_num = CustomData_number_of_layers(&mesh->loop_data, CD_PROP_FLOAT2);
@ -120,13 +120,13 @@ void BKE_mesh_merge_customdata_for_apply_modifier(Mesh *mesh)
mloopuv_layers.reserve(mloopuv_layers_num);
for (int a = 0; a < mloopuv_layers_num; a++) {
float2 *mloopuv = static_cast<float2 *>(
CustomData_get_layer_n_for_write(&mesh->loop_data, CD_PROP_FLOAT2, a, mesh->totloop));
CustomData_get_layer_n_for_write(&mesh->loop_data, CD_PROP_FLOAT2, a, mesh->corners_num));
mloopuv_layers.append_unchecked(mloopuv);
}
Span<float2 *> mloopuv_layers_as_span = mloopuv_layers.as_span();
threading::parallel_for(IndexRange(mesh->totvert), 1024, [&](IndexRange range) {
threading::parallel_for(IndexRange(mesh->verts_num), 1024, [&](IndexRange range) {
for (const int64_t v_index : range) {
merge_uvs_for_vertex(vert_to_loop[v_index], mloopuv_layers_as_span);
}

View File

@ -190,10 +190,10 @@ Mesh *BKE_mesh_mirror_apply_mirror_on_axis_for_modifier(MirrorModifierData *mmd,
mesh = mesh_bisect;
}
const int src_verts_num = mesh->totvert;
const int src_edges_num = mesh->totedge;
const int src_verts_num = mesh->verts_num;
const int src_edges_num = mesh->edges_num;
const blender::OffsetIndices src_faces = mesh->faces();
const int src_loops_num = mesh->totloop;
const int src_loops_num = mesh->corners_num;
Mesh *result = BKE_mesh_new_nomain_from_template(
mesh, src_verts_num * 2, src_edges_num * 2, src_faces.size() * 2, src_loops_num * 2);
@ -286,8 +286,8 @@ Mesh *BKE_mesh_mirror_apply_mirror_on_axis_for_modifier(MirrorModifierData *mmd,
totshape = CustomData_number_of_layers(&result->vert_data, CD_SHAPEKEY);
for (a = 0; a < totshape; a++) {
float(*cos)[3] = static_cast<float(*)[3]>(
CustomData_get_layer_n_for_write(&result->vert_data, CD_SHAPEKEY, a, result->totvert));
for (int i = src_verts_num; i < result->totvert; i++) {
CustomData_get_layer_n_for_write(&result->vert_data, CD_SHAPEKEY, a, result->verts_num));
for (int i = src_verts_num; i < result->verts_num; i++) {
mul_m4_v3(mtx, cos[i]);
}
}
@ -342,7 +342,7 @@ Mesh *BKE_mesh_mirror_apply_mirror_on_axis_for_modifier(MirrorModifierData *mmd,
if (!mesh->runtime->subsurf_optimal_display_edges.is_empty()) {
const blender::BoundedBitSpan src = mesh->runtime->subsurf_optimal_display_edges;
result->runtime->subsurf_optimal_display_edges.resize(result->totedge);
result->runtime->subsurf_optimal_display_edges.resize(result->edges_num);
blender::MutableBoundedBitSpan dst = result->runtime->subsurf_optimal_display_edges;
dst.take_front(src.size()).copy_from(src);
dst.take_back(src.size()).copy_from(src);
@ -362,7 +362,7 @@ Mesh *BKE_mesh_mirror_apply_mirror_on_axis_for_modifier(MirrorModifierData *mmd,
for (a = 0; a < totuv; a++) {
float(*dmloopuv)[2] = static_cast<float(*)[2]>(CustomData_get_layer_n_for_write(
&result->loop_data, CD_PROP_FLOAT2, a, result->totloop));
&result->loop_data, CD_PROP_FLOAT2, a, result->corners_num));
int j = src_loops_num;
dmloopuv += j; /* second set of loops only */
for (; j-- > 0; dmloopuv++) {
@ -395,8 +395,8 @@ Mesh *BKE_mesh_mirror_apply_mirror_on_axis_for_modifier(MirrorModifierData *mmd,
result->faces_num > 0)
{
blender::Array<blender::float3> loop_normals(result_corner_verts.size());
blender::short2 *clnors = static_cast<blender::short2 *>(
CustomData_get_layer_for_write(&result->loop_data, CD_CUSTOMLOOPNORMAL, result->totloop));
blender::short2 *clnors = static_cast<blender::short2 *>(CustomData_get_layer_for_write(
&result->loop_data, CD_CUSTOMLOOPNORMAL, result->corners_num));
blender::bke::mesh::CornerNormalSpaceArray lnors_spacearr;
/* The transform matrix of a normal must be

View File

@ -274,7 +274,7 @@ blender::Span<blender::float3> Mesh::corner_normals() const
using namespace blender;
using namespace blender::bke;
this->runtime->corner_normals_cache.ensure([&](Vector<float3> &r_data) {
r_data.reinitialize(this->totloop);
r_data.reinitialize(this->corners_num);
const OffsetIndices<int> faces = this->faces();
switch (this->normals_domain()) {
case MeshNormalDomain::Point: {
@ -1548,32 +1548,32 @@ void normals_loop_custom_set_from_verts(const Span<float3> vert_positions,
static void mesh_set_custom_normals(Mesh *mesh, float (*r_custom_nors)[3], const bool use_vertices)
{
short2 *clnors = static_cast<short2 *>(
CustomData_get_layer_for_write(&mesh->loop_data, CD_CUSTOMLOOPNORMAL, mesh->totloop));
CustomData_get_layer_for_write(&mesh->loop_data, CD_CUSTOMLOOPNORMAL, mesh->corners_num));
if (clnors != nullptr) {
memset(clnors, 0, sizeof(*clnors) * mesh->totloop);
memset(clnors, 0, sizeof(*clnors) * mesh->corners_num);
}
else {
clnors = static_cast<short2 *>(CustomData_add_layer(
&mesh->loop_data, CD_CUSTOMLOOPNORMAL, CD_SET_DEFAULT, mesh->totloop));
&mesh->loop_data, CD_CUSTOMLOOPNORMAL, CD_SET_DEFAULT, mesh->corners_num));
}
MutableAttributeAccessor attributes = mesh->attributes_for_write();
SpanAttributeWriter<bool> sharp_edges = attributes.lookup_or_add_for_write_span<bool>(
"sharp_edge", ATTR_DOMAIN_EDGE);
const VArraySpan sharp_faces = *attributes.lookup<bool>("sharp_face", ATTR_DOMAIN_FACE);
mesh_normals_loop_custom_set(
mesh->vert_positions(),
mesh->edges(),
mesh->faces(),
mesh->corner_verts(),
mesh->corner_edges(),
mesh->vert_normals(),
mesh->face_normals(),
sharp_faces,
use_vertices,
{reinterpret_cast<float3 *>(r_custom_nors), use_vertices ? mesh->totvert : mesh->totloop},
sharp_edges.span,
{clnors, mesh->totloop});
mesh_normals_loop_custom_set(mesh->vert_positions(),
mesh->edges(),
mesh->faces(),
mesh->corner_verts(),
mesh->corner_edges(),
mesh->vert_normals(),
mesh->face_normals(),
sharp_faces,
use_vertices,
{reinterpret_cast<float3 *>(r_custom_nors),
use_vertices ? mesh->verts_num : mesh->corners_num},
sharp_edges.span,
{clnors, mesh->corners_num});
sharp_edges.finish();
}

View File

@ -267,7 +267,7 @@ void BKE_mesh_remap_find_best_match_from_mesh(const float (*vert_positions_dst)[
float mat_src[4][4], mat_dst[4][4], best_mat_dst[4][4];
float best_match = FLT_MAX, match;
const int numverts_src = me_src->totvert;
const int numverts_src = me_src->verts_num;
const blender::Span<blender::float3> positions_src = me_src->vert_positions();
mesh_calc_eigen_matrix(
nullptr, reinterpret_cast<const float(*)[3]>(positions_src.data()), numverts_src, mat_src);
@ -468,7 +468,7 @@ void BKE_mesh_remap_calc_verts_from_mesh(const int mode,
BKE_mesh_remap_init(r_map, numverts_dst);
if (mode == MREMAP_MODE_TOPOLOGY) {
BLI_assert(numverts_dst == me_src->totvert);
BLI_assert(numverts_dst == me_src->verts_num);
for (i = 0; i < numverts_dst; i++) {
mesh_remap_item_define(r_map, i, FLT_MAX, 0, 1, &i, &full_weight);
}
@ -694,7 +694,7 @@ void BKE_mesh_remap_calc_edges_from_mesh(const int mode,
BKE_mesh_remap_init(r_map, numedges_dst);
if (mode == MREMAP_MODE_TOPOLOGY) {
BLI_assert(numedges_dst == me_src->totedge);
BLI_assert(numedges_dst == me_src->edges_num);
for (i = 0; i < numedges_dst; i++) {
mesh_remap_item_define(r_map, i, FLT_MAX, 0, 1, &i, &full_weight);
}
@ -707,7 +707,7 @@ void BKE_mesh_remap_calc_edges_from_mesh(const int mode,
float tmp_co[3], tmp_no[3];
if (mode == MREMAP_MODE_EDGE_VERT_NEAREST) {
const int num_verts_src = me_src->totvert;
const int num_verts_src = me_src->verts_num;
const blender::Span<blender::int2> edges_src = me_src->edges();
const blender::Span<blender::float3> positions_src = me_src->vert_positions();
@ -908,7 +908,7 @@ void BKE_mesh_remap_calc_edges_from_mesh(const int mode,
}
else if (mode == MREMAP_MODE_EDGE_EDGEINTERP_VNORPROJ) {
const int num_rays_min = 5, num_rays_max = 100;
const int numedges_src = me_src->totedge;
const int numedges_src = me_src->edges_num;
/* Subtleness - this one we can allocate only max number of cast rays per edges! */
int *indices = static_cast<int *>(
@ -1234,7 +1234,7 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
if (mode == MREMAP_MODE_TOPOLOGY) {
/* In topology mapping, we assume meshes are identical, islands included! */
BLI_assert(numloops_dst == me_src->totloop);
BLI_assert(numloops_dst == me_src->corners_num);
for (int i = 0; i < numloops_dst; i++) {
mesh_remap_item_define(r_map, i, FLT_MAX, 0, 1, &i, &full_weight);
}
@ -1281,7 +1281,7 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
blender::Span<int> loop_to_face_map_src;
const blender::Span<blender::float3> positions_src = me_src->vert_positions();
const int num_verts_src = me_src->totvert;
const int num_verts_src = me_src->verts_num;
const blender::Span<blender::int2> edges_src = me_src->edges();
const blender::OffsetIndices faces_src = me_src->faces();
const blender::Span<int> corner_verts_src = me_src->corner_verts();

View File

@ -78,7 +78,7 @@ static Mesh *remesh_quadriflow(const Mesh *input_mesh,
verttri.data(), input_corner_verts.data(), corner_tris.data(), corner_tris.size());
const int totfaces = corner_tris.size();
const int totverts = input_mesh->totvert;
const int totverts = input_mesh->verts_num;
Array<int> faces(totfaces * 3);
for (const int i : IndexRange(totfaces)) {
@ -191,10 +191,10 @@ static openvdb::FloatGrid::Ptr remesh_voxel_level_set_create(const Mesh *mesh,
const Span<int> corner_verts = mesh->corner_verts();
const Span<int3> corner_tris = mesh->corner_tris();
std::vector<openvdb::Vec3s> points(mesh->totvert);
std::vector<openvdb::Vec3s> points(mesh->verts_num);
std::vector<openvdb::Vec3I> triangles(corner_tris.size());
for (const int i : IndexRange(mesh->totvert)) {
for (const int i : IndexRange(mesh->verts_num)) {
const float3 &co = positions[i];
points[i] = openvdb::Vec3s(co.x, co.y, co.z);
}
@ -543,7 +543,7 @@ void mesh_remesh_reproject_attributes(const Mesh &src, Mesh &dst)
find_nearest_tris_parallel(dst_positions, bvhtree, vert_nearest_tris);
if (!point_ids.is_empty()) {
Array<int> map(dst.totvert);
Array<int> map(dst.verts_num);
find_nearest_verts(
src_positions, src_corner_verts, src_corner_tris, dst_positions, vert_nearest_tris, map);
gather_attributes(point_ids, src_attributes, ATTR_DOMAIN_POINT, map, dst_attributes);
@ -551,7 +551,7 @@ void mesh_remesh_reproject_attributes(const Mesh &src, Mesh &dst)
if (!corner_ids.is_empty()) {
const Span<int> src_tri_faces = src.corner_tri_faces();
Array<int> map(dst.totloop);
Array<int> map(dst.corners_num);
find_nearest_corners(src_positions,
src_faces,
src_corner_verts,
@ -569,7 +569,7 @@ void mesh_remesh_reproject_attributes(const Mesh &src, Mesh &dst)
const Span<int> src_corner_edges = src.corner_edges();
const Span<int> src_tri_faces = src.corner_tri_faces();
const Span<int2> dst_edges = dst.edges();
Array<int> map(dst.totedge);
Array<int> map(dst.edges_num);
find_nearest_edges(src_positions,
src_edges,
src_faces,

View File

@ -131,7 +131,7 @@ blender::OffsetIndices<int> Mesh::vert_to_face_map_offsets() const
{
using namespace blender;
this->runtime->vert_to_face_offset_cache.ensure([&](Array<int> &r_data) {
r_data = Array<int>(this->totvert + 1, 0);
r_data = Array<int>(this->verts_num + 1, 0);
offset_indices::build_reverse_offsets(this->corner_verts(), r_data);
});
return OffsetIndices<int>(this->runtime->vert_to_face_offset_cache.data());
@ -142,7 +142,7 @@ blender::GroupedSpan<int> Mesh::vert_to_face_map() const
using namespace blender;
const OffsetIndices offsets = this->vert_to_face_map_offsets();
this->runtime->vert_to_face_map_cache.ensure([&](Array<int> &r_data) {
r_data.reinitialize(this->totloop);
r_data.reinitialize(this->corners_num);
if (this->runtime->vert_to_corner_map_cache.is_cached() &&
this->runtime->corner_to_face_map_cache.is_cached())
{
@ -174,7 +174,8 @@ const blender::bke::LooseVertCache &Mesh::loose_verts() const
using namespace blender::bke;
this->runtime->loose_verts_cache.ensure([&](LooseVertCache &r_data) {
const Span<int> verts = this->edges().cast<int>();
bit_vector_with_reset_bits_or_empty(verts, this->totvert, r_data.is_loose_bits, r_data.count);
bit_vector_with_reset_bits_or_empty(
verts, this->verts_num, r_data.is_loose_bits, r_data.count);
});
return this->runtime->loose_verts_cache.data();
}
@ -184,7 +185,8 @@ const blender::bke::LooseVertCache &Mesh::verts_no_face() const
using namespace blender::bke;
this->runtime->verts_no_face_cache.ensure([&](LooseVertCache &r_data) {
const Span<int> verts = this->corner_verts();
bit_vector_with_reset_bits_or_empty(verts, this->totvert, r_data.is_loose_bits, r_data.count);
bit_vector_with_reset_bits_or_empty(
verts, this->verts_num, r_data.is_loose_bits, r_data.count);
});
return this->runtime->verts_no_face_cache.data();
}
@ -199,7 +201,8 @@ const blender::bke::LooseEdgeCache &Mesh::loose_edges() const
using namespace blender::bke;
this->runtime->loose_edges_cache.ensure([&](LooseEdgeCache &r_data) {
const Span<int> edges = this->corner_edges();
bit_vector_with_reset_bits_or_empty(edges, this->totedge, r_data.is_loose_bits, r_data.count);
bit_vector_with_reset_bits_or_empty(
edges, this->edges_num, r_data.is_loose_bits, r_data.count);
});
return this->runtime->loose_edges_cache.data();
}
@ -256,7 +259,7 @@ blender::Span<int> Mesh::corner_tri_faces() const
using namespace blender;
this->runtime->corner_tri_faces_cache.ensure([&](blender::Array<int> &r_data) {
const OffsetIndices faces = this->faces();
r_data.reinitialize(poly_to_tri_count(faces.size(), this->totloop));
r_data.reinitialize(poly_to_tri_count(faces.size(), this->corners_num));
bke::mesh::corner_tris_calc_face_indices(faces, r_data);
});
return this->runtime->corner_tri_faces_cache.data();
@ -265,7 +268,7 @@ blender::Span<int> Mesh::corner_tri_faces() const
int BKE_mesh_runtime_corner_tris_len(const Mesh *mesh)
{
/* Allow returning the size without calculating the cache. */
return poly_to_tri_count(mesh->faces_num, mesh->totloop);
return poly_to_tri_count(mesh->faces_num, mesh->corners_num);
}
void BKE_mesh_runtime_verttris_from_corner_tris(MVertTri *r_verttri,
@ -438,11 +441,11 @@ bool BKE_mesh_runtime_is_valid(Mesh *me_eval)
is_valid &= BKE_mesh_validate_all_customdata(
&me_eval->vert_data,
me_eval->totvert,
me_eval->verts_num,
&me_eval->edge_data,
me_eval->totedge,
me_eval->edges_num,
&me_eval->loop_data,
me_eval->totloop,
me_eval->corners_num,
&me_eval->face_data,
me_eval->faces_num,
false, /* setting mask here isn't useful, gives false positives */

View File

@ -140,12 +140,12 @@ void BKE_mesh_calc_loop_tangent_single(Mesh *mesh,
BKE_mesh_calc_loop_tangent_single_ex(
reinterpret_cast<const float(*)[3]>(mesh->vert_positions().data()),
mesh->totvert,
mesh->verts_num,
mesh->corner_verts().data(),
r_looptangents,
reinterpret_cast<const float(*)[3]>(mesh->corner_normals().data()),
reinterpret_cast<const float(*)[2]>(uv_map.data()),
mesh->totloop,
mesh->corners_num,
mesh->faces(),
reports);
}
@ -606,7 +606,7 @@ void BKE_mesh_calc_loop_tangents(Mesh *me_eval,
static_cast<const float(*)[3]>(CustomData_get_layer(&me_eval->vert_data, CD_ORCO)),
/* result */
&me_eval->loop_data,
uint(me_eval->totloop),
uint(me_eval->corners_num),
&tangent_mask);
}

View File

@ -213,17 +213,17 @@ static int search_polyloop_cmp(const void *v1, const void *v2)
/* NOLINTNEXTLINE: readability-function-size */
bool BKE_mesh_validate_arrays(Mesh *mesh,
float (*vert_positions)[3],
uint totvert,
uint verts_num,
blender::int2 *edges,
uint totedge,
MFace *mfaces,
uint totface,
uint edges_num,
MFace *legacy_faces,
uint legacy_faces_num,
int *corner_verts,
int *corner_edges,
uint totloop,
uint corners_num,
int *face_offsets,
uint faces_num,
MDeformVert *dverts, /* assume totvert length */
MDeformVert *dverts, /* assume verts_num length */
const bool do_verbose,
const bool do_fixes,
bool *r_changed)
@ -289,7 +289,7 @@ bool BKE_mesh_validate_arrays(Mesh *mesh,
} recalc_flag;
Map<OrderedEdge, int> edge_hash;
edge_hash.reserve(totedge);
edge_hash.reserve(edges_num);
BLI_assert(!(do_fixes && mesh == nullptr));
@ -297,14 +297,18 @@ bool BKE_mesh_validate_arrays(Mesh *mesh,
free_flag.as_flag = 0;
recalc_flag.as_flag = 0;
PRINT_MSG("verts(%u), edges(%u), loops(%u), polygons(%u)", totvert, totedge, totloop, faces_num);
PRINT_MSG("verts(%u), edges(%u), loops(%u), polygons(%u)",
verts_num,
edges_num,
corners_num,
faces_num);
if (totedge == 0 && faces_num != 0) {
if (edges_num == 0 && faces_num != 0) {
PRINT_ERR("\tLogical error, %u polygons and 0 edges", faces_num);
recalc_flag.edges = do_fixes;
}
for (i = 0; i < totvert; i++) {
for (i = 0; i < verts_num; i++) {
for (j = 0; j < 3; j++) {
if (!isfinite(vert_positions[i][j])) {
PRINT_ERR("\tVertex %u: has invalid coordinate", i);
@ -318,7 +322,7 @@ bool BKE_mesh_validate_arrays(Mesh *mesh,
}
}
for (i = 0; i < totedge; i++) {
for (i = 0; i < edges_num; i++) {
blender::int2 &edge = edges[i];
bool remove = false;
@ -326,11 +330,11 @@ bool BKE_mesh_validate_arrays(Mesh *mesh,
PRINT_ERR("\tEdge %u: has matching verts, both %d", i, edge[0]);
remove = do_fixes;
}
if (edge[0] >= totvert) {
if (edge[0] >= verts_num) {
PRINT_ERR("\tEdge %u: v1 index out of range, %d", i, edge[0]);
remove = do_fixes;
}
if (edge[1] >= totvert) {
if (edge[1] >= verts_num) {
PRINT_ERR("\tEdge %u: v2 index out of range, %d", i, edge[1]);
remove = do_fixes;
}
@ -350,7 +354,7 @@ bool BKE_mesh_validate_arrays(Mesh *mesh,
}
}
if (mfaces && !face_offsets) {
if (legacy_faces && !face_offsets) {
#define REMOVE_FACE_TAG(_mf) \
{ \
_mf->v3 = 0; \
@ -376,14 +380,15 @@ bool BKE_mesh_validate_arrays(Mesh *mesh,
MFace *mf;
MFace *mf_prev;
SortFace *sort_faces = (SortFace *)MEM_callocN(sizeof(SortFace) * totface, "search faces");
SortFace *sort_faces = (SortFace *)MEM_callocN(sizeof(SortFace) * legacy_faces_num,
"search faces");
SortFace *sf;
SortFace *sf_prev;
uint totsortface = 0;
PRINT_ERR("No Polys, only tessellated Faces");
for (i = 0, mf = mfaces, sf = sort_faces; i < totface; i++, mf++) {
for (i = 0, mf = legacy_faces, sf = sort_faces; i < legacy_faces_num; i++, mf++) {
bool remove = false;
int fidx;
uint fv[4];
@ -391,7 +396,7 @@ bool BKE_mesh_validate_arrays(Mesh *mesh,
fidx = mf->v4 ? 3 : 2;
do {
fv[fidx] = *(&(mf->v1) + fidx);
if (fv[fidx] >= totvert) {
if (fv[fidx] >= verts_num) {
PRINT_ERR("\tFace %u: 'v%d' index out of range, %u", i, fidx + 1, fv[fidx]);
remove = do_fixes;
}
@ -416,7 +421,7 @@ bool BKE_mesh_validate_arrays(Mesh *mesh,
}
if (remove == false) {
if (totedge) {
if (edges_num) {
if (mf->v4) {
CHECK_FACE_EDGE(v1, v2);
CHECK_FACE_EDGE(v2, v3);
@ -463,10 +468,10 @@ bool BKE_mesh_validate_arrays(Mesh *mesh,
/* on a valid mesh, code below will never run */
if (memcmp(sf->es, sf_prev->es, sizeof(sf_prev->es)) == 0) {
mf = mfaces + sf->index;
mf = legacy_faces + sf->index;
if (do_verbose) {
mf_prev = mfaces + sf_prev->index;
mf_prev = legacy_faces + sf_prev->index;
if (mf->v4) {
PRINT_ERR("\tFace %u & %u: are duplicates (%u,%u,%u,%u) (%u,%u,%u,%u)",
@ -516,7 +521,7 @@ bool BKE_mesh_validate_arrays(Mesh *mesh,
*
* Polys must have:
* - a valid loopstart value.
* - a valid totloop value (>= 3 and loopstart+totloop < mesh.totloop).
* - a valid corners_num value (>= 3 and loopstart+corners_num < mesh.corners_num).
*
* Loops must have:
* - a valid v value.
@ -527,7 +532,7 @@ bool BKE_mesh_validate_arrays(Mesh *mesh,
* so be sure to leave at most one face per loop!
*/
{
BLI_bitmap *vert_tag = BLI_BITMAP_NEW(mesh->totvert, __func__);
BLI_bitmap *vert_tag = BLI_BITMAP_NEW(mesh->verts_num, __func__);
SortPoly *sort_polys = (SortPoly *)MEM_callocN(sizeof(SortPoly) * faces_num,
"mesh validate's sort_polys");
@ -551,11 +556,13 @@ bool BKE_mesh_validate_arrays(Mesh *mesh,
if (poly_start < 0 || poly_size < 3) {
/* Invalid loop data. */
PRINT_ERR(
"\tPoly %u is invalid (loopstart: %d, totloop: %d)", sp->index, poly_start, poly_size);
PRINT_ERR("\tPoly %u is invalid (loopstart: %d, corners_num: %d)",
sp->index,
poly_start,
poly_size);
sp->invalid = true;
}
else if (poly_start + poly_size > totloop) {
else if (poly_start + poly_size > corners_num) {
/* Invalid loop data. */
PRINT_ERR(
"\tPoly %u uses loops out of range "
@ -563,7 +570,7 @@ bool BKE_mesh_validate_arrays(Mesh *mesh,
sp->index,
poly_start,
poly_start + poly_size - 1,
totloop - 1);
corners_num - 1);
sp->invalid = true;
}
else {
@ -579,7 +586,7 @@ bool BKE_mesh_validate_arrays(Mesh *mesh,
* so we have to ensure here all verts of current face are cleared. */
for (j = 0; j < poly_size; j++) {
const int vert = corner_verts[sp->loopstart + j];
if (vert < totvert) {
if (vert < verts_num) {
BLI_BITMAP_DISABLE(vert_tag, vert);
}
}
@ -587,7 +594,7 @@ bool BKE_mesh_validate_arrays(Mesh *mesh,
/* Test all face's loops' vert idx. */
for (j = 0; j < poly_size; j++, v++) {
const int vert = corner_verts[sp->loopstart + j];
if (vert >= totvert) {
if (vert >= verts_num) {
/* Invalid vert idx. */
PRINT_ERR("\tLoop %u has invalid vert reference (%d)", sp->loopstart + j, vert);
sp->invalid = true;
@ -624,7 +631,7 @@ bool BKE_mesh_validate_arrays(Mesh *mesh,
sp->invalid = true;
}
}
else if (edge_i >= totedge) {
else if (edge_i >= edges_num) {
/* Invalid edge idx.
* We already know from previous text that a valid edge exists, use it (if allowed)! */
if (do_fixes) {
@ -776,9 +783,9 @@ bool BKE_mesh_validate_arrays(Mesh *mesh,
}
}
/* We may have some remaining unused loops to get rid of! */
if (prev_end < totloop) {
if (prev_end < corners_num) {
int corner;
for (j = prev_end, corner = prev_end; j < totloop; j++, corner++) {
for (j = prev_end, corner = prev_end; j < corners_num; j++, corner++) {
PRINT_ERR("\tLoop %u is unused.", j);
if (do_fixes) {
REMOVE_LOOP_TAG(corner);
@ -792,7 +799,7 @@ bool BKE_mesh_validate_arrays(Mesh *mesh,
/* fix deform verts */
if (dverts) {
MDeformVert *dv;
for (i = 0, dv = dverts; i < totvert; i++, dv++) {
for (i = 0, dv = dverts; i < verts_num; i++, dv++) {
MDeformWeight *dw;
for (j = 0, dw = dv->dw; j < dv->totweight; j++, dw++) {
@ -876,10 +883,10 @@ bool BKE_mesh_validate_arrays(Mesh *mesh,
switch (msel->type) {
case ME_VSEL:
tot_elem = mesh->totvert;
tot_elem = mesh->verts_num;
break;
case ME_ESEL:
tot_elem = mesh->totedge;
tot_elem = mesh->edges_num;
break;
case ME_FSEL:
tot_elem = mesh->faces_num;
@ -1020,11 +1027,11 @@ static bool mesh_validate_customdata(CustomData *data,
}
bool BKE_mesh_validate_all_customdata(CustomData *vert_data,
const uint totvert,
const uint verts_num,
CustomData *edge_data,
const uint totedge,
const uint edges_num,
CustomData *loop_data,
const uint totloop,
const uint corners_num,
CustomData *face_data,
const uint faces_num,
const bool check_meshmask,
@ -1040,11 +1047,11 @@ bool BKE_mesh_validate_all_customdata(CustomData *vert_data,
}
is_valid &= mesh_validate_customdata(
vert_data, mask.vmask, totvert, do_verbose, do_fixes, &is_change_v);
vert_data, mask.vmask, verts_num, do_verbose, do_fixes, &is_change_v);
is_valid &= mesh_validate_customdata(
edge_data, mask.emask, totedge, do_verbose, do_fixes, &is_change_e);
edge_data, mask.emask, edges_num, do_verbose, do_fixes, &is_change_e);
is_valid &= mesh_validate_customdata(
loop_data, mask.lmask, totloop, do_verbose, do_fixes, &is_change_l);
loop_data, mask.lmask, corners_num, do_verbose, do_fixes, &is_change_l);
is_valid &= mesh_validate_customdata(
face_data, mask.pmask, faces_num, do_verbose, do_fixes, &is_change_p);
@ -1081,11 +1088,11 @@ bool BKE_mesh_validate(Mesh *mesh, const bool do_verbose, const bool cddata_chec
}
BKE_mesh_validate_all_customdata(&mesh->vert_data,
mesh->totvert,
mesh->verts_num,
&mesh->edge_data,
mesh->totedge,
mesh->edges_num,
&mesh->loop_data,
mesh->totloop,
mesh->corners_num,
&mesh->face_data,
mesh->faces_num,
cddata_check_mask,
@ -1134,11 +1141,11 @@ bool BKE_mesh_is_valid(Mesh *mesh)
is_valid &= BKE_mesh_validate_all_customdata(
&mesh->vert_data,
mesh->totvert,
mesh->verts_num,
&mesh->edge_data,
mesh->totedge,
mesh->edges_num,
&mesh->loop_data,
mesh->totloop,
mesh->corners_num,
&mesh->face_data,
mesh->faces_num,
false, /* setting mask here isn't useful, gives false positives */
@ -1213,7 +1220,7 @@ void strip_loose_facesloops(Mesh *mesh, blender::BitSpan faces_to_remove)
int a, b;
/* New loops idx! */
int *new_idx = (int *)MEM_mallocN(sizeof(int) * mesh->totloop, __func__);
int *new_idx = (int *)MEM_mallocN(sizeof(int) * mesh->corners_num, __func__);
for (a = b = 0; a < mesh->faces_num; a++) {
bool invalid = false;
@ -1224,7 +1231,7 @@ void strip_loose_facesloops(Mesh *mesh, blender::BitSpan faces_to_remove)
if (faces_to_remove[a]) {
invalid = true;
}
else if (stop > mesh->totloop || stop < start || size < 0) {
else if (stop > mesh->corners_num || stop < start || size < 0) {
invalid = true;
}
else {
@ -1249,7 +1256,7 @@ void strip_loose_facesloops(Mesh *mesh, blender::BitSpan faces_to_remove)
/* And now, get rid of invalid loops. */
int corner = 0;
for (a = b = 0; a < mesh->totloop; a++, corner++) {
for (a = b = 0; a < mesh->corners_num; a++, corner++) {
if (corner_edges[corner] != INVALID_LOOP_EDGE_MARKER) {
if (a != b) {
CustomData_copy_data(&mesh->loop_data, &mesh->loop_data, a, b, 1);
@ -1265,10 +1272,10 @@ void strip_loose_facesloops(Mesh *mesh, blender::BitSpan faces_to_remove)
}
if (a != b) {
CustomData_free_elem(&mesh->loop_data, b, a - b);
mesh->totloop = b;
mesh->corners_num = b;
}
face_offsets[mesh->faces_num] = mesh->totloop;
face_offsets[mesh->faces_num] = mesh->corners_num;
/* And now, update faces' start loop index. */
/* NOTE: At this point, there should never be any face using a striped loop! */
@ -1284,10 +1291,10 @@ void mesh_strip_edges(Mesh *mesh)
{
blender::int2 *e;
int a, b;
uint *new_idx = (uint *)MEM_mallocN(sizeof(int) * mesh->totedge, __func__);
uint *new_idx = (uint *)MEM_mallocN(sizeof(int) * mesh->edges_num, __func__);
MutableSpan<blender::int2> edges = mesh->edges_for_write();
for (a = b = 0, e = edges.data(); a < mesh->totedge; a++, e++) {
for (a = b = 0, e = edges.data(); a < mesh->edges_num; a++, e++) {
if ((*e)[0] != (*e)[1]) {
if (a != b) {
memcpy(&edges[b], e, sizeof(edges[b]));
@ -1302,7 +1309,7 @@ void mesh_strip_edges(Mesh *mesh)
}
if (a != b) {
CustomData_free_elem(&mesh->edge_data, b, a - b);
mesh->totedge = b;
mesh->edges_num = b;
}
/* And now, update loops' edge indices. */
@ -1324,14 +1331,14 @@ void mesh_strip_edges(Mesh *mesh)
void BKE_mesh_calc_edges_tessface(Mesh *mesh)
{
const int numFaces = mesh->totface_legacy;
const int nulegacy_faces = mesh->totface_legacy;
blender::VectorSet<blender::OrderedEdge> eh;
eh.reserve(numFaces);
MFace *mfaces = (MFace *)CustomData_get_layer_for_write(
eh.reserve(nulegacy_faces);
MFace *legacy_faces = (MFace *)CustomData_get_layer_for_write(
&mesh->fdata_legacy, CD_MFACE, mesh->totface_legacy);
MFace *mf = mfaces;
for (int i = 0; i < numFaces; i++, mf++) {
MFace *mf = legacy_faces;
for (int i = 0; i < nulegacy_faces; i++, mf++) {
eh.add({mf->v1, mf->v2});
eh.add({mf->v2, mf->v3});
@ -1353,16 +1360,16 @@ void BKE_mesh_calc_edges_tessface(Mesh *mesh)
CustomData_add_layer(&edgeData, CD_ORIGINDEX, CD_SET_DEFAULT, numEdges);
blender::int2 *ege = (blender::int2 *)CustomData_get_layer_named_for_write(
&edgeData, CD_PROP_INT32_2D, ".edge_verts", mesh->totedge);
int *index = (int *)CustomData_get_layer_for_write(&edgeData, CD_ORIGINDEX, mesh->totedge);
&edgeData, CD_PROP_INT32_2D, ".edge_verts", mesh->edges_num);
int *index = (int *)CustomData_get_layer_for_write(&edgeData, CD_ORIGINDEX, mesh->edges_num);
memset(index, ORIGINDEX_NONE, sizeof(int) * numEdges);
MutableSpan(ege, numEdges).copy_from(eh.as_span().cast<blender::int2>());
/* free old CustomData and assign new one */
CustomData_free(&mesh->edge_data, mesh->totedge);
CustomData_free(&mesh->edge_data, mesh->edges_num);
mesh->edge_data = edgeData;
mesh->totedge = numEdges;
mesh->edges_num = numEdges;
}
/** \} */

View File

@ -75,15 +75,15 @@ Mesh *BKE_mesh_wrapper_from_editmesh(BMEditMesh *em,
/* Make sure we crash if these are ever used. */
#ifndef NDEBUG
mesh->totvert = INT_MAX;
mesh->totedge = INT_MAX;
mesh->verts_num = INT_MAX;
mesh->edges_num = INT_MAX;
mesh->faces_num = INT_MAX;
mesh->totloop = INT_MAX;
mesh->corners_num = INT_MAX;
#else
mesh->totvert = 0;
mesh->totedge = 0;
mesh->verts_num = 0;
mesh->edges_num = 0;
mesh->faces_num = 0;
mesh->totloop = 0;
mesh->corners_num = 0;
#endif
return mesh;
@ -104,10 +104,10 @@ void BKE_mesh_wrapper_ensure_mdata(Mesh *mesh)
break; /* Quiet warning. */
}
case ME_WRAPPER_TYPE_BMESH: {
mesh->totvert = 0;
mesh->totedge = 0;
mesh->verts_num = 0;
mesh->edges_num = 0;
mesh->faces_num = 0;
mesh->totloop = 0;
mesh->corners_num = 0;
BLI_assert(mesh->edit_mesh != nullptr);
BLI_assert(mesh->runtime->edit_data != nullptr);
@ -253,7 +253,7 @@ void BKE_mesh_wrapper_vert_coords_copy_with_mat4(const Mesh *mesh,
}
case ME_WRAPPER_TYPE_MDATA:
case ME_WRAPPER_TYPE_SUBD: {
BLI_assert(vert_coords_len == mesh->totvert);
BLI_assert(vert_coords_len == mesh->verts_num);
const Span<float3> positions = mesh->vert_positions();
for (int i = 0; i < vert_coords_len; i++) {
mul_v3_m4v3(vert_coords[i], mat, positions[i]);
@ -277,7 +277,7 @@ int BKE_mesh_wrapper_vert_len(const Mesh *mesh)
return mesh->edit_mesh->bm->totvert;
case ME_WRAPPER_TYPE_MDATA:
case ME_WRAPPER_TYPE_SUBD:
return mesh->totvert;
return mesh->verts_num;
}
BLI_assert_unreachable();
return -1;
@ -290,7 +290,7 @@ int BKE_mesh_wrapper_edge_len(const Mesh *mesh)
return mesh->edit_mesh->bm->totedge;
case ME_WRAPPER_TYPE_MDATA:
case ME_WRAPPER_TYPE_SUBD:
return mesh->totedge;
return mesh->edges_num;
}
BLI_assert_unreachable();
return -1;
@ -303,7 +303,7 @@ int BKE_mesh_wrapper_loop_len(const Mesh *mesh)
return mesh->edit_mesh->bm->totloop;
case ME_WRAPPER_TYPE_MDATA:
case ME_WRAPPER_TYPE_SUBD:
return mesh->totloop;
return mesh->corners_num;
}
BLI_assert_unreachable();
return -1;
@ -355,7 +355,8 @@ static Mesh *mesh_wrapper_ensure_subdivision(Mesh *mesh)
if (use_clnors) {
/* If custom normals are present and the option is turned on calculate the split
* normals and clear flag so the normals get interpolated to the result mesh. */
void *data = CustomData_add_layer(&mesh->loop_data, CD_NORMAL, CD_CONSTRUCT, mesh->totloop);
void *data = CustomData_add_layer(
&mesh->loop_data, CD_NORMAL, CD_CONSTRUCT, mesh->corners_num);
memcpy(data, mesh->corner_normals().data(), mesh->corner_normals().size_in_bytes());
}
@ -364,8 +365,8 @@ static Mesh *mesh_wrapper_ensure_subdivision(Mesh *mesh)
if (use_clnors) {
BKE_mesh_set_custom_normals(subdiv_mesh,
static_cast<float(*)[3]>(CustomData_get_layer_for_write(
&subdiv_mesh->loop_data, CD_NORMAL, mesh->totloop)));
CustomData_free_layers(&subdiv_mesh->loop_data, CD_NORMAL, mesh->totloop);
&subdiv_mesh->loop_data, CD_NORMAL, mesh->corners_num)));
CustomData_free_layers(&subdiv_mesh->loop_data, CD_NORMAL, mesh->corners_num);
}
if (!ELEM(subdiv, runtime_data->subdiv_cpu, runtime_data->subdiv_gpu)) {

View File

@ -83,10 +83,10 @@ void multires_customdata_delete(Mesh *mesh)
}
}
else {
CustomData_external_remove(&mesh->loop_data, &mesh->id, CD_MDISPS, mesh->totloop);
CustomData_free_layer_active(&mesh->loop_data, CD_MDISPS, mesh->totloop);
CustomData_external_remove(&mesh->loop_data, &mesh->id, CD_MDISPS, mesh->corners_num);
CustomData_free_layer_active(&mesh->loop_data, CD_MDISPS, mesh->corners_num);
CustomData_free_layer_active(&mesh->loop_data, CD_GRID_PAINT_MASK, mesh->totloop);
CustomData_free_layer_active(&mesh->loop_data, CD_GRID_PAINT_MASK, mesh->corners_num);
}
}
@ -470,7 +470,7 @@ void multires_force_external_reload(Object *object)
{
Mesh *mesh = BKE_mesh_from_object(object);
CustomData_external_reload(&mesh->loop_data, &mesh->id, CD_MASK_MDISPS, mesh->totloop);
CustomData_external_reload(&mesh->loop_data, &mesh->id, CD_MASK_MDISPS, mesh->corners_num);
multires_force_sculpt_rebuild(object);
}
@ -536,11 +536,11 @@ void multiresModifier_set_levels_from_disps(MultiresModifierData *mmd, Object *o
static void multires_set_tot_mdisps(Mesh *mesh, int lvl)
{
MDisps *mdisps = static_cast<MDisps *>(
CustomData_get_layer_for_write(&mesh->loop_data, CD_MDISPS, mesh->totloop));
CustomData_get_layer_for_write(&mesh->loop_data, CD_MDISPS, mesh->corners_num));
int i;
if (mdisps) {
for (i = 0; i < mesh->totloop; i++, mdisps++) {
for (i = 0; i < mesh->corners_num; i++, mdisps++) {
mdisps->totdisp = multires_grid_tot[lvl];
mdisps->level = lvl;
}
@ -656,9 +656,9 @@ static void multires_del_higher(MultiresModifierData *mmd, Object *ob, int lvl)
multires_set_tot_mdisps(mesh, mmd->totlvl);
multiresModifier_ensure_external_read(mesh, mmd);
mdisps = static_cast<MDisps *>(
CustomData_get_layer_for_write(&mesh->loop_data, CD_MDISPS, mesh->totloop));
CustomData_get_layer_for_write(&mesh->loop_data, CD_MDISPS, mesh->corners_num));
gpm = static_cast<GridPaintMask *>(
CustomData_get_layer_for_write(&mesh->loop_data, CD_GRID_PAINT_MASK, mesh->totloop));
CustomData_get_layer_for_write(&mesh->loop_data, CD_GRID_PAINT_MASK, mesh->corners_num));
multires_force_sculpt_rebuild(ob);
@ -720,7 +720,7 @@ void multiresModifier_del_levels(MultiresModifierData *mmd,
multires_set_tot_mdisps(mesh, mmd->totlvl);
multiresModifier_ensure_external_read(mesh, mmd);
MDisps *mdisps = static_cast<MDisps *>(
CustomData_get_layer_for_write(&mesh->loop_data, CD_MDISPS, mesh->totloop));
CustomData_get_layer_for_write(&mesh->loop_data, CD_MDISPS, mesh->corners_num));
multires_force_sculpt_rebuild(ob);
@ -958,7 +958,7 @@ static void multiresModifier_disp_run(
CCGKey key;
blender::OffsetIndices faces = mesh->faces();
MDisps *mdisps = static_cast<MDisps *>(
CustomData_get_layer_for_write(&mesh->loop_data, CD_MDISPS, mesh->totloop));
CustomData_get_layer_for_write(&mesh->loop_data, CD_MDISPS, mesh->corners_num));
GridPaintMask *grid_paint_mask = nullptr;
int *gridOffset;
int i, gridSize, dGridSize, dSkip;
@ -974,14 +974,14 @@ static void multiresModifier_disp_run(
faces_num = dm2->numPolyData;
}
else {
totloop = mesh->totloop;
totloop = mesh->corners_num;
faces_num = mesh->faces_num;
}
if (!mdisps) {
if (op == CALC_DISPLACEMENTS) {
mdisps = static_cast<MDisps *>(
CustomData_add_layer(&mesh->loop_data, CD_MDISPS, CD_SET_DEFAULT, mesh->totloop));
CustomData_add_layer(&mesh->loop_data, CD_MDISPS, CD_SET_DEFAULT, mesh->corners_num));
}
else {
return;
@ -1001,7 +1001,7 @@ static void multiresModifier_disp_run(
/* multires paint masks */
if (key.has_mask) {
grid_paint_mask = static_cast<GridPaintMask *>(
CustomData_get_layer_for_write(&mesh->loop_data, CD_GRID_PAINT_MASK, mesh->totloop));
CustomData_get_layer_for_write(&mesh->loop_data, CD_GRID_PAINT_MASK, mesh->corners_num));
}
/* when adding new faces in edit mode, need to allocate disps */
@ -1173,14 +1173,14 @@ void multires_modifier_update_hidden(DerivedMesh *dm)
BLI_bitmap **grid_hidden = ccgdm->gridHidden;
Mesh *mesh = static_cast<Mesh *>(ccgdm->multires.ob->data);
MDisps *mdisps = static_cast<MDisps *>(
CustomData_get_layer_for_write(&mesh->loop_data, CD_MDISPS, mesh->totloop));
CustomData_get_layer_for_write(&mesh->loop_data, CD_MDISPS, mesh->corners_num));
int totlvl = ccgdm->multires.totlvl;
int lvl = ccgdm->multires.lvl;
if (mdisps) {
int i;
for (i = 0; i < mesh->totloop; i++) {
for (i = 0; i < mesh->corners_num; i++) {
MDisps *md = &mdisps[i];
BLI_bitmap *gh = grid_hidden[i];
@ -1384,8 +1384,8 @@ static void multires_apply_uniform_scale(Object *object, const float scale)
{
Mesh *mesh = (Mesh *)object->data;
MDisps *mdisps = static_cast<MDisps *>(
CustomData_get_layer_for_write(&mesh->loop_data, CD_MDISPS, mesh->totloop));
for (int i = 0; i < mesh->totloop; i++) {
CustomData_get_layer_for_write(&mesh->loop_data, CD_MDISPS, mesh->corners_num));
for (int i = 0; i < mesh->corners_num; i++) {
MDisps *grid = &mdisps[i];
for (int j = 0; j < grid->totdisp; j++) {
mul_v3_fl(grid->disps[j], scale);
@ -1464,16 +1464,16 @@ void multires_topology_changed(Mesh *mesh)
MDisps *mdisp = nullptr, *cur = nullptr;
int i, grid = 0;
CustomData_external_read(&mesh->loop_data, &mesh->id, CD_MASK_MDISPS, mesh->totloop);
CustomData_external_read(&mesh->loop_data, &mesh->id, CD_MASK_MDISPS, mesh->corners_num);
mdisp = static_cast<MDisps *>(
CustomData_get_layer_for_write(&mesh->loop_data, CD_MDISPS, mesh->totloop));
CustomData_get_layer_for_write(&mesh->loop_data, CD_MDISPS, mesh->corners_num));
if (!mdisp) {
return;
}
cur = mdisp;
for (i = 0; i < mesh->totloop; i++, cur++) {
for (i = 0; i < mesh->corners_num; i++, cur++) {
if (cur->totdisp) {
grid = mdisp->totdisp;
@ -1481,7 +1481,7 @@ void multires_topology_changed(Mesh *mesh)
}
}
for (i = 0; i < mesh->totloop; i++, mdisp++) {
for (i = 0; i < mesh->corners_num; i++, mdisp++) {
/* allocate memory for mdisp, the whole disp layer would be erased otherwise */
if (!mdisp->totdisp || !mdisp->disps) {
if (grid) {
@ -1507,10 +1507,10 @@ void multires_ensure_external_read(Mesh *mesh, int top_level)
static_cast<const MDisps *>(CustomData_get_layer(&mesh->loop_data, CD_MDISPS)));
if (mdisps == nullptr) {
mdisps = static_cast<MDisps *>(
CustomData_add_layer(&mesh->loop_data, CD_MDISPS, CD_SET_DEFAULT, mesh->totloop));
CustomData_add_layer(&mesh->loop_data, CD_MDISPS, CD_SET_DEFAULT, mesh->corners_num));
}
const int totloop = mesh->totloop;
const int totloop = mesh->corners_num;
for (int i = 0; i < totloop; ++i) {
if (mdisps[i].level != top_level) {
@ -1525,7 +1525,7 @@ void multires_ensure_external_read(Mesh *mesh, int top_level)
mdisps[i].level = top_level;
}
CustomData_external_read(&mesh->loop_data, &mesh->id, CD_MASK_MDISPS, mesh->totloop);
CustomData_external_read(&mesh->loop_data, &mesh->id, CD_MASK_MDISPS, mesh->corners_num);
}
void multiresModifier_ensure_external_read(Mesh *mesh, const MultiresModifierData *mmd)
{

View File

@ -75,7 +75,7 @@ bool multiresModifier_reshapeFromObject(Depsgraph *depsgraph,
dst,
mmd,
reinterpret_cast<const float(*)[3]>(src_mesh_eval->vert_positions().data()),
src_mesh_eval->totvert);
src_mesh_eval->verts_num);
}
/** \} */
@ -173,7 +173,7 @@ void multiresModifier_subdivide_to_level(Object *object,
}
Mesh *coarse_mesh = static_cast<Mesh *>(object->data);
if (coarse_mesh->totloop == 0) {
if (coarse_mesh->corners_num == 0) {
/* If there are no loops in the mesh implies there is no CD_MDISPS as well. So can early output
* from here as there is nothing to subdivide. */
return;
@ -185,7 +185,8 @@ void multiresModifier_subdivide_to_level(Object *object,
* are allocated at a proper level and return. */
const bool has_mdisps = CustomData_has_layer(&coarse_mesh->loop_data, CD_MDISPS);
if (!has_mdisps) {
CustomData_add_layer(&coarse_mesh->loop_data, CD_MDISPS, CD_SET_DEFAULT, coarse_mesh->totloop);
CustomData_add_layer(
&coarse_mesh->loop_data, CD_MDISPS, CD_SET_DEFAULT, coarse_mesh->corners_num);
}
/* NOTE: Subdivision happens from the top level of the existing multires modifier. If it is set

View File

@ -75,12 +75,12 @@ void multires_reshape_apply_base_refit_base_mesh(MultiresReshapeContext *reshape
const blender::GroupedSpan<int> pmap = base_mesh->vert_to_face_map();
float(*origco)[3] = static_cast<float(*)[3]>(
MEM_calloc_arrayN(base_mesh->totvert, sizeof(float[3]), __func__));
for (int i = 0; i < base_mesh->totvert; i++) {
MEM_calloc_arrayN(base_mesh->verts_num, sizeof(float[3]), __func__));
for (int i = 0; i < base_mesh->verts_num; i++) {
copy_v3_v3(origco[i], base_positions[i]);
}
for (int i = 0; i < base_mesh->totvert; i++) {
for (int i = 0; i < base_mesh->verts_num; i++) {
float avg_no[3] = {0, 0, 0}, center[3] = {0, 0, 0}, push[3];
/* Don't adjust vertices not used by at least one face. */

View File

@ -852,7 +852,7 @@ static void geometry_init_loose_information(MultiresReshapeSmoothContext *reshap
reshape_smooth_context->loose_base_edges = loose_edges.is_loose_bits;
int num_used_edges = 0;
for (const int edge : blender::IndexRange(base_mesh->totedge)) {
for (const int edge : blender::IndexRange(base_mesh->edges_num)) {
if (loose_edges.count > 0 && loose_edges.is_loose_bits[edge]) {
continue;
}

View File

@ -36,7 +36,7 @@ static void multires_subdivide_create_object_space_linear_grids(Mesh *mesh)
const blender::Span<int> corner_verts = mesh->corner_verts();
MDisps *mdisps = static_cast<MDisps *>(
CustomData_get_layer_for_write(&mesh->loop_data, CD_MDISPS, mesh->totloop));
CustomData_get_layer_for_write(&mesh->loop_data, CD_MDISPS, mesh->corners_num));
for (const int p : faces.index_range()) {
const blender::IndexRange face = faces[p];
const float3 face_center = mesh::face_center_calc(positions, corner_verts.slice(face));
@ -74,7 +74,8 @@ void multires_subdivide_create_tangent_displacement_linear_grids(Object *object,
const bool has_mdisps = CustomData_has_layer(&coarse_mesh->loop_data, CD_MDISPS);
if (!has_mdisps) {
CustomData_add_layer(&coarse_mesh->loop_data, CD_MDISPS, CD_SET_DEFAULT, coarse_mesh->totloop);
CustomData_add_layer(
&coarse_mesh->loop_data, CD_MDISPS, CD_SET_DEFAULT, coarse_mesh->corners_num);
}
if (new_top_level == 1) {

View File

@ -109,9 +109,9 @@ static void context_init_grid_pointers(MultiresReshapeContext *reshape_context)
{
Mesh *base_mesh = reshape_context->base_mesh;
reshape_context->mdisps = static_cast<MDisps *>(
CustomData_get_layer_for_write(&base_mesh->loop_data, CD_MDISPS, base_mesh->totloop));
CustomData_get_layer_for_write(&base_mesh->loop_data, CD_MDISPS, base_mesh->corners_num));
reshape_context->grid_paint_masks = static_cast<GridPaintMask *>(CustomData_get_layer_for_write(
&base_mesh->loop_data, CD_GRID_PAINT_MASK, base_mesh->totloop));
&base_mesh->loop_data, CD_GRID_PAINT_MASK, base_mesh->corners_num));
}
static void context_init_commoon(MultiresReshapeContext *reshape_context)
@ -573,9 +573,9 @@ static void ensure_displacement_grid(MDisps *displacement_grid, const int level)
static void ensure_displacement_grids(Mesh *mesh, const int grid_level)
{
const int num_grids = mesh->totloop;
const int num_grids = mesh->corners_num;
MDisps *mdisps = static_cast<MDisps *>(
CustomData_get_layer_for_write(&mesh->loop_data, CD_MDISPS, mesh->totloop));
CustomData_get_layer_for_write(&mesh->loop_data, CD_MDISPS, mesh->corners_num));
for (int grid_index = 0; grid_index < num_grids; grid_index++) {
ensure_displacement_grid(&mdisps[grid_index], grid_level);
}
@ -584,11 +584,11 @@ static void ensure_displacement_grids(Mesh *mesh, const int grid_level)
static void ensure_mask_grids(Mesh *mesh, const int level)
{
GridPaintMask *grid_paint_masks = static_cast<GridPaintMask *>(
CustomData_get_layer_for_write(&mesh->loop_data, CD_GRID_PAINT_MASK, mesh->totloop));
CustomData_get_layer_for_write(&mesh->loop_data, CD_GRID_PAINT_MASK, mesh->corners_num));
if (grid_paint_masks == nullptr) {
return;
}
const int num_grids = mesh->totloop;
const int num_grids = mesh->corners_num;
const int grid_size = BKE_subdiv_grid_size_from_level(level);
const int grid_area = grid_size * grid_size;
for (int grid_index = 0; grid_index < num_grids; grid_index++) {

View File

@ -888,13 +888,13 @@ static void multires_unsubdivide_free_original_datalayers(Mesh *mesh)
const int l_layer_index = CustomData_get_named_layer_index(
&mesh->loop_data, CD_PROP_INT32, lname);
if (l_layer_index != -1) {
CustomData_free_layer(&mesh->loop_data, CD_PROP_INT32, mesh->totloop, l_layer_index);
CustomData_free_layer(&mesh->loop_data, CD_PROP_INT32, mesh->corners_num, l_layer_index);
}
const int v_layer_index = CustomData_get_named_layer_index(
&mesh->vert_data, CD_PROP_INT32, vname);
if (v_layer_index != -1) {
CustomData_free_layer(&mesh->vert_data, CD_PROP_INT32, mesh->totvert, v_layer_index);
CustomData_free_layer(&mesh->vert_data, CD_PROP_INT32, mesh->verts_num, v_layer_index);
}
}
@ -907,16 +907,16 @@ static void multires_unsubdivide_add_original_index_datalayers(Mesh *mesh)
multires_unsubdivide_free_original_datalayers(mesh);
int *l_index = static_cast<int *>(CustomData_add_layer_named(
&mesh->loop_data, CD_PROP_INT32, CD_SET_DEFAULT, mesh->totloop, lname));
&mesh->loop_data, CD_PROP_INT32, CD_SET_DEFAULT, mesh->corners_num, lname));
int *v_index = static_cast<int *>(CustomData_add_layer_named(
&mesh->vert_data, CD_PROP_INT32, CD_SET_DEFAULT, mesh->totvert, vname));
&mesh->vert_data, CD_PROP_INT32, CD_SET_DEFAULT, mesh->verts_num, vname));
/* Initialize these data-layer with the indices in the current mesh. */
for (int i = 0; i < mesh->totloop; i++) {
for (int i = 0; i < mesh->corners_num; i++) {
l_index[i] = i;
}
for (int i = 0; i < mesh->totvert; i++) {
for (int i = 0; i < mesh->verts_num; i++) {
v_index[i] = i;
}
}
@ -946,7 +946,7 @@ static void multires_unsubdivide_prepare_original_bmesh_for_extract(
CustomData_get_layer_named(&base_mesh->vert_data, CD_PROP_INT32, vname));
/* Tag the base mesh vertices in the original mesh. */
for (int i = 0; i < base_mesh->totvert; i++) {
for (int i = 0; i < base_mesh->verts_num; i++) {
int vert_basemesh_index = context->base_to_orig_vmap[i];
BMVert *v = BM_vert_at_index(bm_original_mesh, vert_basemesh_index);
BM_elem_flag_set(v, BM_ELEM_TAG, true);
@ -990,9 +990,9 @@ static void multires_unsubdivide_extract_grids(MultiresUnsubdivideContext *conte
BMesh *bm_original_mesh = context->bm_original_mesh;
context->num_grids = base_mesh->totloop;
context->num_grids = base_mesh->corners_num;
context->base_mesh_grids = static_cast<MultiresUnsubdivideGrid *>(
MEM_calloc_arrayN(base_mesh->totloop, sizeof(MultiresUnsubdivideGrid), "grids"));
MEM_calloc_arrayN(base_mesh->corners_num, sizeof(MultiresUnsubdivideGrid), "grids"));
/* Based on the existing indices in the data-layers, generate two vertex indices maps. */
/* From vertex index in original to vertex index in base and from vertex index in base to vertex
@ -1000,21 +1000,21 @@ static void multires_unsubdivide_extract_grids(MultiresUnsubdivideContext *conte
int *orig_to_base_vmap = static_cast<int *>(
MEM_calloc_arrayN(bm_original_mesh->totvert, sizeof(int), "orig vmap"));
int *base_to_orig_vmap = static_cast<int *>(
MEM_calloc_arrayN(base_mesh->totvert, sizeof(int), "base vmap"));
MEM_calloc_arrayN(base_mesh->verts_num, sizeof(int), "base vmap"));
context->base_to_orig_vmap = static_cast<const int *>(
CustomData_get_layer_named(&base_mesh->vert_data, CD_PROP_INT32, vname));
for (int i = 0; i < base_mesh->totvert; i++) {
for (int i = 0; i < base_mesh->verts_num; i++) {
base_to_orig_vmap[i] = context->base_to_orig_vmap[i];
}
/* If an index in original does not exist in base (it was dissolved when creating the new base
* mesh, return -1. */
for (int i = 0; i < original_mesh->totvert; i++) {
for (int i = 0; i < original_mesh->verts_num; i++) {
orig_to_base_vmap[i] = -1;
}
for (int i = 0; i < base_mesh->totvert; i++) {
for (int i = 0; i < base_mesh->verts_num; i++) {
const int orig_vertex_index = context->base_to_orig_vmap[i];
orig_to_base_vmap[orig_vertex_index] = i;
}
@ -1174,15 +1174,15 @@ static void multires_create_grids_in_unsubdivided_base_mesh(MultiresUnsubdivideC
{
/* Free the current MDISPS and create a new ones. */
if (CustomData_has_layer(&base_mesh->loop_data, CD_MDISPS)) {
CustomData_free_layers(&base_mesh->loop_data, CD_MDISPS, base_mesh->totloop);
CustomData_free_layers(&base_mesh->loop_data, CD_MDISPS, base_mesh->corners_num);
}
MDisps *mdisps = static_cast<MDisps *>(
CustomData_add_layer(&base_mesh->loop_data, CD_MDISPS, CD_SET_DEFAULT, base_mesh->totloop));
MDisps *mdisps = static_cast<MDisps *>(CustomData_add_layer(
&base_mesh->loop_data, CD_MDISPS, CD_SET_DEFAULT, base_mesh->corners_num));
const int totdisp = pow_i(BKE_ccg_gridsize(context->num_total_levels), 2);
const int totloop = base_mesh->totloop;
const int totloop = base_mesh->corners_num;
BLI_assert(base_mesh->totloop == context->num_grids);
BLI_assert(base_mesh->corners_num == context->num_grids);
/* Allocate the MDISPS grids and copy the extracted data from context. */
for (int i = 0; i < totloop; i++) {

View File

@ -59,7 +59,7 @@ static Subdiv *subdiv_for_simple_to_catmull_clark(Object *object, MultiresModifi
void multires_do_versions_simple_to_catmull_clark(Object *object, MultiresModifierData *mmd)
{
const Mesh *base_mesh = static_cast<const Mesh *>(object->data);
if (base_mesh->totloop == 0) {
if (base_mesh->corners_num == 0) {
return;
}

View File

@ -1492,10 +1492,10 @@ static void copy_ccg_data(Mesh *mesh_destination,
Mesh *mesh_source,
const eCustomDataType layer_type)
{
BLI_assert(mesh_destination->totloop == mesh_source->totloop);
BLI_assert(mesh_destination->corners_num == mesh_source->corners_num);
CustomData *data_destination = &mesh_destination->loop_data;
CustomData *data_source = &mesh_source->loop_data;
const int num_elements = mesh_source->totloop;
const int num_elements = mesh_source->corners_num;
if (!CustomData_has_layer(data_source, layer_type)) {
return;
}
@ -3089,7 +3089,7 @@ static void give_parvert(Object *par, int nr, float vec[3])
if (me_eval) {
const Span<float3> positions = me_eval->vert_positions();
int count = 0;
int numVerts = me_eval->totvert;
int numVerts = me_eval->verts_num;
if (em && me_eval->runtime->wrapper_type == ME_WRAPPER_TYPE_BMESH) {
numVerts = em->bm->totvert;
@ -3142,7 +3142,7 @@ static void give_parvert(Object *par, int nr, float vec[3])
}
else {
/* use first index if its out of range */
if (me_eval->totvert) {
if (me_eval->verts_num) {
copy_v3_v3(vec, positions[0]);
}
}
@ -4531,7 +4531,7 @@ bool BKE_object_shapekey_remove(Main *bmain, Object *ob, KeyBlock *kb)
Mesh *mesh = (Mesh *)ob->data;
MutableSpan<float3> positions = mesh->vert_positions_for_write();
BKE_keyblock_convert_to_mesh(
key->refkey, reinterpret_cast<float(*)[3]>(positions.data()), mesh->totvert);
key->refkey, reinterpret_cast<float(*)[3]>(positions.data()), mesh->verts_num);
break;
}
case OB_CURVES_LEGACY:

View File

@ -167,7 +167,7 @@ bool BKE_object_defgroup_clear(Object *ob, bDeformGroup *dg, const bool use_sele
dv = mesh->deform_verts_for_write().data();
for (i = 0; i < mesh->totvert; i++, dv++) {
for (i = 0; i < mesh->verts_num; i++, dv++) {
if (dv->dw && (!use_selection || (select_vert && select_vert[i]))) {
MDeformWeight *dw = BKE_defvert_find_index(dv, def_nr);
BKE_defvert_remove_group(dv, dw); /* dw can be nullptr */
@ -258,7 +258,7 @@ static void object_defgroup_remove_common(Object *ob, bDeformGroup *dg, const in
if (BLI_listbase_is_empty(defbase)) {
if (ob->type == OB_MESH) {
Mesh *mesh = static_cast<Mesh *>(ob->data);
CustomData_free_layer_active(&mesh->vert_data, CD_MDEFORMVERT, mesh->totvert);
CustomData_free_layer_active(&mesh->vert_data, CD_MDEFORMVERT, mesh->verts_num);
}
else if (ob->type == OB_LATTICE) {
Lattice *lt = object_defgroup_lattice_get((ID *)(ob->data));
@ -405,7 +405,7 @@ void BKE_object_defgroup_remove_all_ex(Object *ob, bool only_unlocked)
/* Remove all deform-verts. */
if (ob->type == OB_MESH) {
Mesh *mesh = static_cast<Mesh *>(ob->data);
CustomData_free_layer_active(&mesh->vert_data, CD_MDEFORMVERT, mesh->totvert);
CustomData_free_layer_active(&mesh->vert_data, CD_MDEFORMVERT, mesh->verts_num);
}
else if (ob->type == OB_LATTICE) {
Lattice *lt = object_defgroup_lattice_get((ID *)(ob->data));
@ -497,7 +497,7 @@ bool BKE_object_defgroup_array_get(ID *id, MDeformVert **dvert_arr, int *dvert_t
case ID_ME: {
Mesh *mesh = (Mesh *)id;
*dvert_arr = mesh->deform_verts_for_write().data();
*dvert_tot = mesh->totvert;
*dvert_tot = mesh->verts_num;
return true;
}
case ID_LT: {

View File

@ -744,7 +744,7 @@ static void make_duplis_verts(const DupliContext *ctx)
else {
VertexDupliData_Mesh vdd{};
vdd.params = vdd_params;
vdd.totvert = me_eval->totvert;
vdd.totvert = me_eval->verts_num;
vdd.vert_positions = me_eval->vert_positions();
vdd.vert_normals = me_eval->vert_normals();
vdd.orco = (const float(*)[3])CustomData_get_layer(&me_eval->vert_data, CD_ORCO);

View File

@ -1568,7 +1568,7 @@ static MultiresModifierData *sculpt_multires_modifier_get(const Scene *scene,
if (mmd->sculptlvl > 0 && !(mmd->flags & eMultiresModifierFlag_UseSculptBaseMesh)) {
if (need_mdisps) {
CustomData_add_layer(&mesh->loop_data, CD_MDISPS, CD_SET_DEFAULT, mesh->totloop);
CustomData_add_layer(&mesh->loop_data, CD_MDISPS, CD_SET_DEFAULT, mesh->corners_num);
}
return mmd;
@ -1683,7 +1683,7 @@ static void sculpt_update_object(Depsgraph *depsgraph,
ss->multires.active = true;
ss->multires.modifier = mmd;
ss->multires.level = mmd->sculptlvl;
ss->totvert = me_eval->totvert;
ss->totvert = me_eval->verts_num;
ss->faces_num = me_eval->faces_num;
ss->totfaces = mesh->faces_num;
@ -1694,7 +1694,7 @@ static void sculpt_update_object(Depsgraph *depsgraph,
ss->corner_verts = mesh->corner_verts();
}
else {
ss->totvert = mesh->totvert;
ss->totvert = mesh->verts_num;
ss->faces_num = mesh->faces_num;
ss->totfaces = mesh->faces_num;
ss->vert_positions = mesh->vert_positions_for_write();
@ -1767,12 +1767,12 @@ static void sculpt_update_object(Depsgraph *depsgraph,
* This matters because crazyspace evaluation is very restrictive and excludes even modifiers
* that simply recompute vertex weights (which can even include Geometry Nodes). */
if (me_eval_deform->faces_num == me_eval->faces_num &&
me_eval_deform->totloop == me_eval->totloop &&
me_eval_deform->totvert == me_eval->totvert)
me_eval_deform->corners_num == me_eval->corners_num &&
me_eval_deform->verts_num == me_eval->verts_num)
{
BKE_sculptsession_free_deformMats(ss);
BLI_assert(me_eval_deform->totvert == mesh->totvert);
BLI_assert(me_eval_deform->verts_num == mesh->verts_num);
ss->deform_cos = me_eval->vert_positions();
BKE_pbvh_vert_coords_apply(ss->pbvh, ss->deform_cos);
@ -1786,7 +1786,7 @@ static void sculpt_update_object(Depsgraph *depsgraph,
ss->orig_cos = (ss->shapekey_active) ?
Span(static_cast<const float3 *>(ss->shapekey_active->data),
mesh->totvert) :
mesh->verts_num) :
mesh->vert_positions();
BKE_crazyspace_build_sculpt(depsgraph, scene, ob, ss->deform_imats, ss->deform_cos);
@ -1802,14 +1802,14 @@ static void sculpt_update_object(Depsgraph *depsgraph,
}
if (ss->shapekey_active != nullptr && ss->deform_cos.is_empty()) {
ss->deform_cos = Span(static_cast<const float3 *>(ss->shapekey_active->data), mesh->totvert);
ss->deform_cos = Span(static_cast<const float3 *>(ss->shapekey_active->data), mesh->verts_num);
}
/* if pbvh is deformed, key block is already applied to it */
if (ss->shapekey_active) {
bool pbvh_deformed = BKE_pbvh_is_deformed(ss->pbvh);
if (!pbvh_deformed || ss->deform_cos.is_empty()) {
const Span key_data(static_cast<const float3 *>(ss->shapekey_active->data), mesh->totvert);
const Span key_data(static_cast<const float3 *>(ss->shapekey_active->data), mesh->verts_num);
if (key_data.data() != nullptr) {
if (!pbvh_deformed) {
@ -1957,10 +1957,10 @@ void BKE_sculpt_mask_layers_ensure(Depsgraph *depsgraph,
int gridsize = BKE_ccg_gridsize(level);
int gridarea = gridsize * gridsize;
GridPaintMask *gmask = static_cast<GridPaintMask *>(
CustomData_add_layer(&mesh->loop_data, CD_GRID_PAINT_MASK, CD_SET_DEFAULT, mesh->totloop));
GridPaintMask *gmask = static_cast<GridPaintMask *>(CustomData_add_layer(
&mesh->loop_data, CD_GRID_PAINT_MASK, CD_SET_DEFAULT, mesh->corners_num));
for (int i = 0; i < mesh->totloop; i++) {
for (int i = 0; i < mesh->corners_num; i++) {
GridPaintMask *gpm = &gmask[i];
gpm->level = level;

View File

@ -1954,7 +1954,7 @@ static int psys_map_index_on_dm(Mesh *mesh,
/* for meshes that are either only deformed or for child particles, the
* index and fw do not require any mapping, so we can directly use it */
if (from == PART_FROM_VERT) {
if (index >= mesh->totvert) {
if (index >= mesh->verts_num) {
return 0;
}
@ -1974,7 +1974,7 @@ static int psys_map_index_on_dm(Mesh *mesh,
* to their new location, which means a different index, and for faces
* also a new face interpolation weights */
if (from == PART_FROM_VERT) {
if (index_dmcache == DMCACHE_NOTFOUND || index_dmcache >= mesh->totvert) {
if (index_dmcache == DMCACHE_NOTFOUND || index_dmcache >= mesh->verts_num) {
return 0;
}
@ -2577,7 +2577,7 @@ float *psys_cache_vgroup(Mesh *mesh, ParticleSystem *psys, int vgroup)
else if (psys->vgroup[vgroup]) {
const MDeformVert *dvert = mesh->deform_verts().data();
if (dvert) {
int totvert = mesh->totvert, i;
int totvert = mesh->verts_num, i;
vg = static_cast<float *>(MEM_callocN(sizeof(float) * totvert, "vg_cache"));
if (psys->vg_neg & (1 << vgroup)) {
for (i = 0; i < totvert; i++) {
@ -4163,7 +4163,7 @@ static int get_particle_uv(Mesh *mesh,
if (pa) {
i = ELEM(pa->num_dmcache, DMCACHE_NOTFOUND, DMCACHE_ISCHILD) ? pa->num : pa->num_dmcache;
if ((!from_vert && i >= mesh->totface_legacy) || (from_vert && i >= mesh->totvert)) {
if ((!from_vert && i >= mesh->totface_legacy) || (from_vert && i >= mesh->verts_num)) {
i = -1;
}
}

View File

@ -100,7 +100,7 @@ static void distribute_grid(Mesh *mesh, ParticleSystem *psys)
ParticleData *pa = nullptr;
float min[3], max[3], delta[3], d;
const blender::Span<blender::float3> positions = mesh->vert_positions();
int totvert = mesh->totvert, from = psys->part->from;
int totvert = mesh->verts_num, from = psys->part->from;
int i, j, k, p, res = psys->part->grid_res, size[3], axis;
/* find bounding box of dm */
@ -475,7 +475,7 @@ static void distribute_from_verts_exec(ParticleTask *thread, ParticleData *pa, i
zero_v4(pa->fuv);
if (pa->num != DMCACHE_NOTFOUND && pa->num < ctx->mesh->totvert) {
if (pa->num != DMCACHE_NOTFOUND && pa->num < ctx->mesh->verts_num) {
/* This finds the first face to contain the emitting vertex,
* this is not ideal, but is mostly fine as UV seams generally
@ -1024,7 +1024,7 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx,
const blender::Span<blender::float3> positions = mesh->vert_positions();
const float(*orcodata)[3] = static_cast<const float(*)[3]>(
CustomData_get_layer(&mesh->vert_data, CD_ORCO));
int totvert = mesh->totvert;
int totvert = mesh->verts_num;
tree = BLI_kdtree_3d_new(totvert);
@ -1044,7 +1044,7 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx,
}
/* Get total number of emission elements and allocate needed arrays */
totelem = (from == PART_FROM_VERT) ? mesh->totvert : mesh->totface_legacy;
totelem = (from == PART_FROM_VERT) ? mesh->verts_num : mesh->totface_legacy;
if (totelem == 0) {
distribute_invalid(sim, children ? PART_FROM_CHILD : 0);
@ -1260,7 +1260,7 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx,
const int *orig_index = nullptr;
if (from == PART_FROM_VERT) {
if (mesh->totvert) {
if (mesh->verts_num) {
orig_index = static_cast<const int *>(
CustomData_get_layer(&mesh->vert_data, CD_ORIGINDEX));
}

View File

@ -332,14 +332,14 @@ void psys_calc_dmcache(Object *ob, Mesh *mesh_final, Mesh *mesh_original, Partic
const int *origindex;
const int *origindex_poly = nullptr;
if (psys->part->from == PART_FROM_VERT) {
totdmelem = mesh_final->totvert;
totdmelem = mesh_final->verts_num;
if (use_modifier_stack) {
totelem = totdmelem;
origindex = nullptr;
}
else {
totelem = mesh->totvert;
totelem = mesh->verts_num;
origindex = static_cast<const int *>(
CustomData_get_layer(&mesh_final->vert_data, CD_ORIGINDEX));
}
@ -3495,7 +3495,7 @@ static void do_hair_dynamics(ParticleSimulationData *sim)
realloc_roots = false;
if (psys->hair_in_mesh) {
Mesh *mesh = psys->hair_in_mesh;
if (totpoint != mesh->totvert || totedge != mesh->totedge) {
if (totpoint != mesh->verts_num || totedge != mesh->edges_num) {
BKE_id_free(nullptr, mesh);
psys->hair_in_mesh = nullptr;
realloc_roots = true;

View File

@ -710,8 +710,8 @@ PBVH *build_mesh(Mesh *mesh)
std::unique_ptr<PBVH> pbvh = std::make_unique<PBVH>();
pbvh->header.type = PBVH_FACES;
const int totvert = mesh->totvert;
const int corner_tris_num = poly_to_tri_count(mesh->faces_num, mesh->totloop);
const int totvert = mesh->verts_num;
const int corner_tris_num = poly_to_tri_count(mesh->faces_num, mesh->corners_num);
MutableSpan<float3> vert_positions = mesh->vert_positions_for_write();
const OffsetIndices<int> faces = mesh->faces();
const Span<int> corner_verts = mesh->corner_verts();

View File

@ -373,7 +373,7 @@ static rbCollisionShape *rigidbody_get_shape_convexhull_from_mesh(Object *ob,
mesh = rigidbody_get_mesh(ob);
positions = (mesh) ? reinterpret_cast<float(*)[3]>(mesh->vert_positions_for_write().data()) :
nullptr;
totvert = (mesh) ? mesh->totvert : 0;
totvert = (mesh) ? mesh->verts_num : 0;
}
else {
CLOG_ERROR(&LOG, "cannot make Convex Hull collision shape for non-Mesh object");
@ -404,7 +404,7 @@ static rbCollisionShape *rigidbody_get_shape_trimesh_from_mesh(Object *ob)
}
const blender::Span<blender::float3> positions = mesh->vert_positions();
const int totvert = mesh->totvert;
const int totvert = mesh->verts_num;
const blender::Span<blender::int3> corner_tris = mesh->corner_tris();
const int tottri = corner_tris.size();
const blender::Span<int> corner_verts = mesh->corner_verts();
@ -1766,7 +1766,7 @@ static void rigidbody_update_sim_ob(Depsgraph *depsgraph, Object *ob, RigidBodyO
if (mesh) {
float(*positions)[3] = reinterpret_cast<float(*)[3]>(
mesh->vert_positions_for_write().data());
int totvert = mesh->totvert;
int totvert = mesh->verts_num;
const std::optional<blender::Bounds<blender::float3>> bounds = BKE_object_boundbox_get(ob);
RB_shape_trimesh_update(static_cast<rbCollisionShape *>(rbo->shared->physics_shape),

View File

@ -112,7 +112,7 @@ bool BKE_shrinkwrap_init_tree(
* Convert mesh data since this isn't typically used in edit-mode. */
BKE_mesh_wrapper_ensure_mdata(mesh);
if (mesh->totvert <= 0) {
if (mesh->verts_num <= 0) {
return false;
}
@ -192,9 +192,9 @@ static std::unique_ptr<ShrinkwrapBoundaryData> shrinkwrap_build_boundary_data(Me
/* Count faces per edge (up to 2). */
char *edge_mode = static_cast<char *>(
MEM_calloc_arrayN(size_t(mesh->totedge), sizeof(char), __func__));
MEM_calloc_arrayN(size_t(mesh->edges_num), sizeof(char), __func__));
for (int i = 0; i < mesh->totloop; i++) {
for (int i = 0; i < mesh->corners_num; i++) {
const int eidx = corner_edges[i];
if (edge_mode[eidx] < 2) {
@ -203,10 +203,10 @@ static std::unique_ptr<ShrinkwrapBoundaryData> shrinkwrap_build_boundary_data(Me
}
/* Build the boundary edge bitmask. */
blender::BitVector<> edge_is_boundary(mesh->totedge, false);
blender::BitVector<> edge_is_boundary(mesh->edges_num, false);
uint num_boundary_edges = 0;
for (int i = 0; i < mesh->totedge; i++) {
for (int i = 0; i < mesh->edges_num; i++) {
edge_mode[i] = (edge_mode[i] == 1);
if (edge_mode[i]) {
@ -246,9 +246,9 @@ static std::unique_ptr<ShrinkwrapBoundaryData> shrinkwrap_build_boundary_data(Me
data->tri_has_boundary = std::move(tri_has_boundary);
/* Find boundary vertices and build a mapping table for compact storage of data. */
Array<int> vert_boundary_id(mesh->totvert, 0);
Array<int> vert_boundary_id(mesh->verts_num, 0);
for (int i = 0; i < mesh->totedge; i++) {
for (int i = 0; i < mesh->edges_num; i++) {
if (edge_mode[i]) {
const blender::int2 &edge = edges[i];
@ -259,7 +259,7 @@ static std::unique_ptr<ShrinkwrapBoundaryData> shrinkwrap_build_boundary_data(Me
uint num_boundary_verts = 0;
for (int i = 0; i < mesh->totvert; i++) {
for (int i = 0; i < mesh->verts_num; i++) {
vert_boundary_id[i] = (vert_boundary_id[i] != 0) ? int(num_boundary_verts++) : -1;
}
@ -271,7 +271,7 @@ static std::unique_ptr<ShrinkwrapBoundaryData> shrinkwrap_build_boundary_data(Me
signed char *vert_status = static_cast<signed char *>(
MEM_calloc_arrayN(num_boundary_verts, sizeof(char), __func__));
for (int i = 0; i < mesh->totedge; i++) {
for (int i = 0; i < mesh->edges_num; i++) {
if (edge_mode[i]) {
const blender::int2 &edge = edges[i];
@ -288,7 +288,7 @@ static std::unique_ptr<ShrinkwrapBoundaryData> shrinkwrap_build_boundary_data(Me
/* Finalize average direction and compute normal. */
const blender::Span<blender::float3> vert_normals = mesh->vert_normals();
for (int i = 0; i < mesh->totvert; i++) {
for (int i = 0; i < mesh->verts_num; i++) {
int bidx = vert_boundary_id[i];
if (bidx >= 0) {
@ -1545,7 +1545,7 @@ void BKE_shrinkwrap_mesh_nearest_surface_deform(Depsgraph *depsgraph,
nullptr,
-1,
reinterpret_cast<float(*)[3]>(src_me->vert_positions_for_write().data()),
src_me->totvert);
src_me->verts_num);
src_me->tag_positions_changed();
}
@ -1567,7 +1567,7 @@ void BKE_shrinkwrap_remesh_target_project(Mesh *src_me, Mesh *target_me, Object
ShrinkwrapCalcData calc = NULL_ShrinkwrapCalcData;
calc.smd = &ssmd;
calc.numVerts = src_me->totvert;
calc.numVerts = src_me->verts_num;
calc.vertexCos = reinterpret_cast<float(*)[3]>(src_me->vert_positions_for_write().data());
calc.vert_normals = src_me->vert_normals();
calc.vgroup = -1;

View File

@ -2656,9 +2656,9 @@ static void springs_from_mesh(Object *ob)
* will be overwritten sbObjectStep() to receive
* actual modifier stack vert_positions
*/
if (mesh->totvert) {
if (mesh->verts_num) {
bp = ob->soft->bpoint;
for (a = 0; a < mesh->totvert; a++, bp++) {
for (a = 0; a < mesh->verts_num; a++, bp++) {
copy_v3_v3(bp->origS, positions[a]);
mul_m4_v3(ob->object_to_world, bp->origS);
}
@ -2688,14 +2688,14 @@ static void mesh_to_softbody(Object *ob)
int defgroup_index, defgroup_index_mass, defgroup_index_spring;
if (ob->softflag & OB_SB_EDGES) {
totedge = mesh->totedge;
totedge = mesh->edges_num;
}
else {
totedge = 0;
}
/* renew ends with ob->soft with points and edges, also checks & makes ob->soft */
renew_softbody(ob, mesh->totvert, totedge);
renew_softbody(ob, mesh->verts_num, totedge);
/* we always make body points */
sb = ob->soft;
@ -2707,7 +2707,7 @@ static void mesh_to_softbody(Object *ob)
defgroup_index_mass = dvert ? BKE_id_defgroup_name_index(&mesh->id, sb->namedVG_Mass) : -1;
defgroup_index_spring = dvert ? BKE_id_defgroup_name_index(&mesh->id, sb->namedVG_Spring_K) : -1;
for (a = 0; a < mesh->totvert; a++, bp++) {
for (a = 0; a < mesh->verts_num; a++, bp++) {
/* get scalar values needed *per vertex* from vertex group functions,
* so we can *paint* them nicely ..
* they are normalized [0.0..1.0] so may be we need amplitude for scale
@ -2738,7 +2738,7 @@ static void mesh_to_softbody(Object *ob)
if (ob->softflag & OB_SB_EDGES) {
if (edge) {
bs = sb->bspring;
for (a = mesh->totedge; a > 0; a--, edge++, bs++) {
for (a = mesh->edges_num; a > 0; a--, edge++, bs++) {
bs->v1 = edge->x;
bs->v2 = edge->y;
bs->springtype = SB_EDGE;
@ -2775,7 +2775,7 @@ static void mesh_faces_to_scratch(Object *ob)
/* Allocate and copy faces. */
sb->scratch->bodyface_num = poly_to_tri_count(mesh->faces_num, mesh->totloop);
sb->scratch->bodyface_num = poly_to_tri_count(mesh->faces_num, mesh->corners_num);
blender::Array<blender::int3> corner_tris(sb->scratch->bodyface_num);
blender::bke::mesh::corner_tris_calc(
mesh->vert_positions(), mesh->faces(), mesh->corner_verts(), corner_tris);
@ -3208,7 +3208,7 @@ void sbObjectToSoftbody(Object *ob)
static bool object_has_edges(const Object *ob)
{
if (ob->type == OB_MESH) {
return ((Mesh *)ob->data)->totedge;
return ((Mesh *)ob->data)->edges_num;
}
if (ob->type == OB_LATTICE) {
return true;

View File

@ -127,7 +127,7 @@ Subdiv *BKE_subdiv_new_from_converter(const SubdivSettings *settings,
Subdiv *BKE_subdiv_new_from_mesh(const SubdivSettings *settings, const Mesh *mesh)
{
if (mesh->totvert == 0) {
if (mesh->verts_num == 0) {
return nullptr;
}
OpenSubdiv_Converter converter;

View File

@ -207,12 +207,12 @@ static void precalc_uv_layer(const OpenSubdiv_Converter *converter, const int la
const Mesh *mesh = storage->mesh;
const float(*mloopuv)[2] = static_cast<const float(*)[2]>(
CustomData_get_layer_n(&mesh->loop_data, CD_PROP_FLOAT2, layer_index));
const int num_vert = mesh->totvert;
const int num_vert = mesh->verts_num;
const float limit[2] = {STD_UV_CONNECT_LIMIT, STD_UV_CONNECT_LIMIT};
/* Initialize memory required for the operations. */
if (storage->loop_uv_indices == nullptr) {
storage->loop_uv_indices = static_cast<int *>(
MEM_malloc_arrayN(mesh->totloop, sizeof(int), "loop uv vertex index"));
MEM_malloc_arrayN(mesh->corners_num, sizeof(int), "loop uv vertex index"));
}
UvVertMap *uv_vert_map = BKE_mesh_uv_vert_map_create(storage->faces,
nullptr,
@ -355,20 +355,20 @@ static void initialize_manifold_indices(ConverterStorage *storage)
const bke::LooseVertCache &loose_verts = mesh->verts_no_face();
const bke::LooseEdgeCache &loose_edges = mesh->loose_edges();
initialize_manifold_index_array(loose_verts.is_loose_bits,
mesh->totvert,
mesh->verts_num,
&storage->manifold_vertex_index,
&storage->manifold_vertex_index_reverse,
&storage->num_manifold_vertices);
initialize_manifold_index_array(loose_edges.is_loose_bits,
mesh->totedge,
mesh->edges_num,
nullptr,
&storage->manifold_edge_index_reverse,
&storage->num_manifold_edges);
/* Initialize infinite sharp mapping. */
if (loose_edges.count > 0) {
const Span<int2> edges = storage->edges;
storage->infinite_sharp_vertices_map.resize(mesh->totvert, false);
for (int edge_index = 0; edge_index < mesh->totedge; edge_index++) {
storage->infinite_sharp_vertices_map.resize(mesh->verts_num, false);
for (int edge_index = 0; edge_index < mesh->edges_num; edge_index++) {
if (loose_edges.is_loose_bits[edge_index]) {
const int2 edge = edges[edge_index];
storage->infinite_sharp_vertices_map[edge[0]].set();

View File

@ -107,7 +107,7 @@ static bool subdiv_mesh_topology_info(const SubdivForeachContext *foreach_contex
{
SubdivDeformContext *subdiv_context = static_cast<SubdivDeformContext *>(
foreach_context->user_data);
subdiv_mesh_prepare_accumulator(subdiv_context, subdiv_context->coarse_mesh->totvert);
subdiv_mesh_prepare_accumulator(subdiv_context, subdiv_context->coarse_mesh->verts_num);
return true;
}

View File

@ -237,7 +237,7 @@ bool BKE_subdiv_eval_refine_from_mesh(Subdiv *subdiv,
set_coarse_positions(
subdiv,
coarse_vertex_cos ?
Span(reinterpret_cast<const float3 *>(coarse_vertex_cos), mesh->totvert) :
Span(reinterpret_cast<const float3 *>(coarse_vertex_cos), mesh->verts_num) :
mesh->vert_positions(),
mesh->verts_no_face());

View File

@ -166,8 +166,8 @@ static void subdiv_foreach_ctx_count(SubdivForeachTaskContext *ctx)
const int num_inner_vertices_per_noquad_patch = (no_quad_patch_resolution - 2) *
(no_quad_patch_resolution - 2);
const Mesh *coarse_mesh = ctx->coarse_mesh;
ctx->num_subdiv_vertices = coarse_mesh->totvert;
ctx->num_subdiv_edges = coarse_mesh->totedge * (num_subdiv_vertices_per_coarse_edge + 1);
ctx->num_subdiv_vertices = coarse_mesh->verts_num;
ctx->num_subdiv_edges = coarse_mesh->edges_num * (num_subdiv_vertices_per_coarse_edge + 1);
/* Calculate extra vertices and edges created by non-loose geometry. */
for (int face_index = 0; face_index < coarse_mesh->faces_num; face_index++) {
const IndexRange coarse_face = ctx->coarse_faces[face_index];
@ -195,7 +195,7 @@ static void subdiv_foreach_ctx_count(SubdivForeachTaskContext *ctx)
}
/* Add vertices used by outer edges on subdivided faces and loose edges. */
ctx->num_subdiv_vertices += num_subdiv_vertices_per_coarse_edge * coarse_mesh->totedge;
ctx->num_subdiv_vertices += num_subdiv_vertices_per_coarse_edge * coarse_mesh->edges_num;
ctx->num_subdiv_loops = ctx->num_subdiv_faces * 4;
}
@ -213,12 +213,12 @@ static void subdiv_foreach_ctx_init_offsets(SubdivForeachTaskContext *ctx)
const int num_subdiv_edges_per_coarse_edge = resolution - 1;
/* Constant offsets in arrays. */
ctx->vertices_corner_offset = 0;
ctx->vertices_edge_offset = coarse_mesh->totvert;
ctx->vertices_edge_offset = coarse_mesh->verts_num;
ctx->vertices_inner_offset = ctx->vertices_edge_offset +
coarse_mesh->totedge * num_subdiv_vertices_per_coarse_edge;
coarse_mesh->edges_num * num_subdiv_vertices_per_coarse_edge;
ctx->edge_boundary_offset = 0;
ctx->edge_inner_offset = ctx->edge_boundary_offset +
coarse_mesh->totedge * num_subdiv_edges_per_coarse_edge;
coarse_mesh->edges_num * num_subdiv_edges_per_coarse_edge;
/* "Indexed" offsets. */
int vertex_offset = 0;
int edge_offset = 0;
@ -252,8 +252,8 @@ static void subdiv_foreach_ctx_init(Subdiv *subdiv, SubdivForeachTaskContext *ct
{
const Mesh *coarse_mesh = ctx->coarse_mesh;
/* Allocate maps and offsets. */
ctx->coarse_vertices_used_map = BLI_BITMAP_NEW(coarse_mesh->totvert, "vertices used map");
ctx->coarse_edges_used_map = BLI_BITMAP_NEW(coarse_mesh->totedge, "edges used map");
ctx->coarse_vertices_used_map = BLI_BITMAP_NEW(coarse_mesh->verts_num, "vertices used map");
ctx->coarse_edges_used_map = BLI_BITMAP_NEW(coarse_mesh->edges_num, "edges used map");
ctx->subdiv_vertex_offset = static_cast<int *>(MEM_malloc_arrayN(
coarse_mesh->faces_num, sizeof(*ctx->subdiv_vertex_offset), "vertex_offset"));
ctx->subdiv_edge_offset = static_cast<int *>(MEM_malloc_arrayN(
@ -1846,21 +1846,21 @@ bool BKE_subdiv_foreach_subdiv_geometry(Subdiv *subdiv,
0, coarse_mesh->faces_num, &ctx, subdiv_foreach_task, &parallel_range_settings);
if (context->vertex_loose != nullptr) {
BLI_task_parallel_range(0,
coarse_mesh->totvert,
coarse_mesh->verts_num,
&ctx,
subdiv_foreach_loose_vertices_task,
&parallel_range_settings);
}
if (context->vertex_of_loose_edge != nullptr) {
BLI_task_parallel_range(0,
coarse_mesh->totedge,
coarse_mesh->edges_num,
&ctx,
subdiv_foreach_vertices_of_loose_edges_task,
&parallel_range_settings);
}
if (context->edge != nullptr) {
BLI_task_parallel_range(0,
coarse_mesh->totedge,
coarse_mesh->edges_num,
&ctx,
subdiv_foreach_boundary_edges_task,
&parallel_range_settings);

View File

@ -91,7 +91,7 @@ static void subdiv_mesh_ctx_cache_uv_layers(SubdivMeshContext *ctx)
CustomData_number_of_layers(&subdiv_mesh->loop_data, CD_PROP_FLOAT2), MAX_MTFACE);
for (int layer_index = 0; layer_index < ctx->num_uv_layers; layer_index++) {
ctx->uv_layers[layer_index] = static_cast<float2 *>(CustomData_get_layer_n_for_write(
&subdiv_mesh->loop_data, CD_PROP_FLOAT2, layer_index, subdiv_mesh->totloop));
&subdiv_mesh->loop_data, CD_PROP_FLOAT2, layer_index, subdiv_mesh->corners_num));
}
}
@ -104,21 +104,21 @@ static void subdiv_mesh_ctx_cache_custom_data_layers(SubdivMeshContext *ctx)
ctx->subdiv_corner_verts = subdiv_mesh->corner_verts_for_write();
ctx->subdiv_corner_edges = subdiv_mesh->corner_edges_for_write();
/* Pointers to original indices layers. */
ctx->vert_origindex = static_cast<int *>(
CustomData_get_layer_for_write(&subdiv_mesh->vert_data, CD_ORIGINDEX, subdiv_mesh->totvert));
ctx->edge_origindex = static_cast<int *>(
CustomData_get_layer_for_write(&subdiv_mesh->edge_data, CD_ORIGINDEX, subdiv_mesh->totedge));
ctx->loop_origindex = static_cast<int *>(
CustomData_get_layer_for_write(&subdiv_mesh->loop_data, CD_ORIGINDEX, subdiv_mesh->totloop));
ctx->vert_origindex = static_cast<int *>(CustomData_get_layer_for_write(
&subdiv_mesh->vert_data, CD_ORIGINDEX, subdiv_mesh->verts_num));
ctx->edge_origindex = static_cast<int *>(CustomData_get_layer_for_write(
&subdiv_mesh->edge_data, CD_ORIGINDEX, subdiv_mesh->edges_num));
ctx->loop_origindex = static_cast<int *>(CustomData_get_layer_for_write(
&subdiv_mesh->loop_data, CD_ORIGINDEX, subdiv_mesh->corners_num));
ctx->face_origindex = static_cast<int *>(CustomData_get_layer_for_write(
&subdiv_mesh->face_data, CD_ORIGINDEX, subdiv_mesh->faces_num));
/* UV layers interpolation. */
subdiv_mesh_ctx_cache_uv_layers(ctx);
/* Orco interpolation. */
ctx->orco = static_cast<float(*)[3]>(
CustomData_get_layer_for_write(&subdiv_mesh->vert_data, CD_ORCO, subdiv_mesh->totvert));
CustomData_get_layer_for_write(&subdiv_mesh->vert_data, CD_ORCO, subdiv_mesh->verts_num));
ctx->cloth_orco = static_cast<float(*)[3]>(CustomData_get_layer_for_write(
&subdiv_mesh->vert_data, CD_CLOTH_ORCO, subdiv_mesh->totvert));
&subdiv_mesh->vert_data, CD_CLOTH_ORCO, subdiv_mesh->verts_num));
}
static void subdiv_mesh_prepare_accumulator(SubdivMeshContext *ctx, int num_vertices)
@ -1169,7 +1169,7 @@ Mesh *BKE_subdiv_to_mesh(Subdiv *subdiv,
if (coarse_mesh->loose_edges().count > 0) {
subdiv_context.vert_to_edge_map = bke::mesh::build_vert_to_edge_map(
subdiv_context.coarse_edges,
coarse_mesh->totvert,
coarse_mesh->verts_num,
subdiv_context.vert_to_edge_offsets,
subdiv_context.vert_to_edge_indices);
}

View File

@ -961,9 +961,9 @@ void blo_do_versions_250(FileData *fd, Library * /*lib*/, Main *bmain)
key->refkey)
{
data = static_cast<const float *>(key->refkey->data);
tot = std::min(me->totvert, key->refkey->totelem);
tot = std::min(me->verts_num, key->refkey->totelem);
MVert *verts = (MVert *)CustomData_get_layer_for_write(
&me->vert_data, CD_MVERT, me->totvert);
&me->vert_data, CD_MVERT, me->verts_num);
for (a = 0; a < tot; a++, data += 3) {
copy_v3_v3(verts[a].co_legacy, data);
}

View File

@ -357,7 +357,7 @@ static void do_versions_mesh_mloopcol_swap_2_62_1(Mesh *mesh)
if (layer->type == CD_PROP_BYTE_COLOR) {
MLoopCol *mloopcol = static_cast<MLoopCol *>(layer->data);
for (int i = 0; i < mesh->totloop; i++, mloopcol++) {
for (int i = 0; i < mesh->corners_num; i++, mloopcol++) {
SWAP(uchar, mloopcol->r, mloopcol->b);
}
}
@ -1908,7 +1908,7 @@ void blo_do_versions_260(FileData *fd, Library * /*lib*/, Main *bmain)
{
LISTBASE_FOREACH (Mesh *, me, &bmain->meshes) {
CustomData_update_typemap(&me->vert_data);
CustomData_free_layers(&me->vert_data, CD_MSTICKY, me->totvert);
CustomData_free_layers(&me->vert_data, CD_MSTICKY, me->verts_num);
}
}
}

View File

@ -835,15 +835,15 @@ void blo_do_versions_290(FileData *fd, Library * /*lib*/, Main *bmain)
BKE_mesh_validate_arrays(
me,
reinterpret_cast<float(*)[3]>(me->vert_positions_for_write().data()),
me->totvert,
me->verts_num,
me->edges_for_write().data(),
me->totedge,
me->edges_num,
(MFace *)CustomData_get_layer_for_write(
&me->fdata_legacy, CD_MFACE, me->totface_legacy),
me->totface_legacy,
me->corner_verts_for_write().data(),
me->corner_edges_for_write().data(),
me->totloop,
me->corners_num,
me->face_offsets_for_write().data(),
me->faces_num,
me->deform_verts_for_write().data(),

View File

@ -358,7 +358,8 @@ static void blo_update_defaults_scene(Main *bmain, Scene *scene)
/* Correct default startup UVs. */
Mesh *mesh = static_cast<Mesh *>(BLI_findstring(&bmain->meshes, "Cube", offsetof(ID, name) + 2));
if (mesh && (mesh->totloop == 24) && CustomData_has_layer(&mesh->loop_data, CD_PROP_FLOAT2)) {
if (mesh && (mesh->corners_num == 24) && CustomData_has_layer(&mesh->loop_data, CD_PROP_FLOAT2))
{
const float uv_values[24][2] = {
{0.625, 0.50}, {0.875, 0.50}, {0.875, 0.75}, {0.625, 0.75}, {0.375, 0.75}, {0.625, 0.75},
{0.625, 1.00}, {0.375, 1.00}, {0.375, 0.00}, {0.625, 0.00}, {0.625, 0.25}, {0.375, 0.25},
@ -366,8 +367,8 @@ static void blo_update_defaults_scene(Main *bmain, Scene *scene)
{0.625, 0.75}, {0.375, 0.75}, {0.375, 0.25}, {0.625, 0.25}, {0.625, 0.50}, {0.375, 0.50},
};
float(*mloopuv)[2] = static_cast<float(*)[2]>(
CustomData_get_layer_for_write(&mesh->loop_data, CD_PROP_FLOAT2, mesh->totloop));
memcpy(mloopuv, uv_values, sizeof(float[2]) * mesh->totloop);
CustomData_get_layer_for_write(&mesh->loop_data, CD_PROP_FLOAT2, mesh->corners_num));
memcpy(mloopuv, uv_values, sizeof(float[2]) * mesh->corners_num);
}
/* Make sure that the curve profile is initialized */
@ -603,8 +604,8 @@ void BLO_update_defaults_startup_blend(Main *bmain, const char *app_template)
}
else {
/* Remove sculpt-mask data in default mesh objects for all non-sculpt templates. */
CustomData_free_layers(&mesh->vert_data, CD_PAINT_MASK, mesh->totvert);
CustomData_free_layers(&mesh->loop_data, CD_GRID_PAINT_MASK, mesh->totloop);
CustomData_free_layers(&mesh->vert_data, CD_PAINT_MASK, mesh->verts_num);
CustomData_free_layers(&mesh->loop_data, CD_GRID_PAINT_MASK, mesh->corners_num);
}
mesh->attributes_for_write().remove(".sculpt_face_set");
}

View File

@ -270,17 +270,17 @@ static void customdata_version_242(Mesh *mesh)
if (!mesh->vert_data.totlayer) {
CustomData_add_layer_with_data(
&mesh->vert_data, CD_MVERT, mesh->mvert, mesh->totvert, nullptr);
&mesh->vert_data, CD_MVERT, mesh->mvert, mesh->verts_num, nullptr);
if (mesh->dvert) {
CustomData_add_layer_with_data(
&mesh->vert_data, CD_MDEFORMVERT, mesh->dvert, mesh->totvert, nullptr);
&mesh->vert_data, CD_MDEFORMVERT, mesh->dvert, mesh->verts_num, nullptr);
}
}
if (!mesh->edge_data.totlayer) {
CustomData_add_layer_with_data(
&mesh->edge_data, CD_MEDGE, mesh->medge, mesh->totedge, nullptr);
&mesh->edge_data, CD_MEDGE, mesh->medge, mesh->edges_num, nullptr);
}
if (!mesh->fdata_legacy.totlayer) {

View File

@ -183,15 +183,15 @@ extern const BMAllocTemplate bm_mesh_chunksize_default;
#define _VA_BMALLOC_TEMPLATE_FROM_ME_1(me) \
{ \
(CHECK_TYPE_INLINE(me, Mesh *), (me)->totvert), (me)->totedge, (me)->totloop, \
(CHECK_TYPE_INLINE(me, Mesh *), (me)->verts_num), (me)->edges_num, (me)->corners_num, \
(me)->faces_num, \
}
#define _VA_BMALLOC_TEMPLATE_FROM_ME_2(me_a, me_b) \
{ \
(CHECK_TYPE_INLINE(me_a, Mesh *), \
CHECK_TYPE_INLINE(me_b, Mesh *), \
(me_a)->totvert + (me_b)->totvert), \
(me_a)->totedge + (me_b)->totedge, (me_a)->totloop + (me_b)->totloop, \
(me_a)->verts_num + (me_b)->verts_num), \
(me_a)->edges_num + (me_b)->edges_num, (me_a)->corners_num + (me_b)->corners_num, \
(me_a)->faces_num + (me_b)->faces_num, \
}
#define BMALLOC_TEMPLATE_FROM_ME(...) \

View File

@ -241,26 +241,29 @@ void BM_mesh_bm_from_me(BMesh *bm, const Mesh *mesh, const BMeshFromMeshParams *
BKE_uv_map_vert_select_name_get(
CustomData_get_layer_name(&mesh_ldata, CD_PROP_FLOAT2, layer_index), name);
if (CustomData_get_named_layer_index(&mesh_ldata, CD_PROP_BOOL, name) < 0) {
CustomData_add_layer_named(&mesh_ldata, CD_PROP_BOOL, CD_SET_DEFAULT, mesh->totloop, name);
CustomData_add_layer_named(
&mesh_ldata, CD_PROP_BOOL, CD_SET_DEFAULT, mesh->corners_num, name);
temporary_layers_to_delete.append(std::string(name));
}
BKE_uv_map_edge_select_name_get(
CustomData_get_layer_name(&mesh_ldata, CD_PROP_FLOAT2, layer_index), name);
if (CustomData_get_named_layer_index(&mesh_ldata, CD_PROP_BOOL, name) < 0) {
CustomData_add_layer_named(&mesh_ldata, CD_PROP_BOOL, CD_SET_DEFAULT, mesh->totloop, name);
CustomData_add_layer_named(
&mesh_ldata, CD_PROP_BOOL, CD_SET_DEFAULT, mesh->corners_num, name);
temporary_layers_to_delete.append(std::string(name));
}
BKE_uv_map_pin_name_get(CustomData_get_layer_name(&mesh_ldata, CD_PROP_FLOAT2, layer_index),
name);
if (CustomData_get_named_layer_index(&mesh_ldata, CD_PROP_BOOL, name) < 0) {
CustomData_add_layer_named(&mesh_ldata, CD_PROP_BOOL, CD_SET_DEFAULT, mesh->totloop, name);
CustomData_add_layer_named(
&mesh_ldata, CD_PROP_BOOL, CD_SET_DEFAULT, mesh->corners_num, name);
temporary_layers_to_delete.append(std::string(name));
}
}
BLI_SCOPED_DEFER([&]() {
for (const std::string &name : temporary_layers_to_delete) {
CustomData_free_layer_named(&mesh_ldata, name.c_str(), mesh->totloop);
CustomData_free_layer_named(&mesh_ldata, name.c_str(), mesh->corners_num);
}
MEM_SAFE_FREE(mesh_vdata.layers);
@ -269,7 +272,7 @@ void BM_mesh_bm_from_me(BMesh *bm, const Mesh *mesh, const BMeshFromMeshParams *
MEM_SAFE_FREE(mesh_ldata.layers);
});
if (mesh->totvert == 0) {
if (mesh->verts_num == 0) {
if (is_new) {
/* No verts? still copy custom-data layout. */
CustomData_copy_layout(&mesh_vdata, &bm->vdata, mask.vmask, CD_CONSTRUCT, 0);
@ -277,9 +280,9 @@ void BM_mesh_bm_from_me(BMesh *bm, const Mesh *mesh, const BMeshFromMeshParams *
CustomData_copy_layout(&mesh_pdata, &bm->pdata, mask.pmask, CD_CONSTRUCT, 0);
CustomData_copy_layout(&mesh_ldata, &bm->ldata, mask.lmask, CD_CONSTRUCT, 0);
CustomData_bmesh_init_pool(&bm->vdata, mesh->totvert, BM_VERT);
CustomData_bmesh_init_pool(&bm->edata, mesh->totedge, BM_EDGE);
CustomData_bmesh_init_pool(&bm->ldata, mesh->totloop, BM_LOOP);
CustomData_bmesh_init_pool(&bm->vdata, mesh->verts_num, BM_VERT);
CustomData_bmesh_init_pool(&bm->edata, mesh->edges_num, BM_EDGE);
CustomData_bmesh_init_pool(&bm->ldata, mesh->corners_num, BM_LOOP);
CustomData_bmesh_init_pool(&bm->pdata, mesh->faces_num, BM_FACE);
}
return;
@ -371,7 +374,7 @@ void BM_mesh_bm_from_me(BMesh *bm, const Mesh *mesh, const BMeshFromMeshParams *
}
}
if (actkey && actkey->totelem == mesh->totvert) {
if (actkey && actkey->totelem == mesh->verts_num) {
keyco = params->use_shapekey ? static_cast<float(*)[3]>(actkey->data) : nullptr;
if (is_new) {
bm->shapenr = params->active_shapekey;
@ -397,9 +400,9 @@ void BM_mesh_bm_from_me(BMesh *bm, const Mesh *mesh, const BMeshFromMeshParams *
const Vector<MeshToBMeshLayerInfo> poly_info = mesh_to_bm_copy_info_calc(mesh_pdata, bm->pdata);
const Vector<MeshToBMeshLayerInfo> loop_info = mesh_to_bm_copy_info_calc(mesh_ldata, bm->ldata);
if (is_new) {
CustomData_bmesh_init_pool(&bm->vdata, mesh->totvert, BM_VERT);
CustomData_bmesh_init_pool(&bm->edata, mesh->totedge, BM_EDGE);
CustomData_bmesh_init_pool(&bm->ldata, mesh->totloop, BM_LOOP);
CustomData_bmesh_init_pool(&bm->vdata, mesh->verts_num, BM_VERT);
CustomData_bmesh_init_pool(&bm->edata, mesh->edges_num, BM_EDGE);
CustomData_bmesh_init_pool(&bm->ldata, mesh->corners_num, BM_LOOP);
CustomData_bmesh_init_pool(&bm->pdata, mesh->faces_num, BM_FACE);
}
@ -424,7 +427,7 @@ void BM_mesh_bm_from_me(BMesh *bm, const Mesh *mesh, const BMeshFromMeshParams *
const VArraySpan uv_seams = *attributes.lookup<bool>(".uv_seam", ATTR_DOMAIN_EDGE);
const Span<float3> positions = mesh->vert_positions();
Array<BMVert *> vtable(mesh->totvert);
Array<BMVert *> vtable(mesh->verts_num);
for (const int i : positions.index_range()) {
BMVert *v = vtable[i] = BM_vert_create(
bm, keyco ? keyco[i] : positions[i], nullptr, BM_CREATE_SKIP_CD);
@ -461,7 +464,7 @@ void BM_mesh_bm_from_me(BMesh *bm, const Mesh *mesh, const BMeshFromMeshParams *
}
const Span<blender::int2> edges = mesh->edges();
Array<BMEdge *> etable(mesh->totedge);
Array<BMEdge *> etable(mesh->edges_num);
for (const int i : edges.index_range()) {
BMEdge *e = etable[i] = BM_edge_create(
bm, vtable[edges[i][0]], vtable[edges[i][1]], nullptr, BM_CREATE_SKIP_CD);
@ -1253,7 +1256,7 @@ static void bm_to_mesh_verts(const BMesh &bm,
MutableSpan<bool> hide_vert)
{
CustomData_add_layer_named(
&mesh.vert_data, CD_PROP_FLOAT3, CD_CONSTRUCT, mesh.totvert, "position");
&mesh.vert_data, CD_PROP_FLOAT3, CD_CONSTRUCT, mesh.verts_num, "position");
const Vector<BMeshToMeshLayerInfo> info = bm_to_mesh_copy_info_calc(bm.vdata, mesh.vert_data);
MutableSpan<float3> dst_vert_positions = mesh.vert_positions_for_write();
@ -1295,7 +1298,7 @@ static void bm_to_mesh_edges(const BMesh &bm,
MutableSpan<bool> uv_seams)
{
CustomData_add_layer_named(
&mesh.edge_data, CD_PROP_INT32_2D, CD_CONSTRUCT, mesh.totedge, ".edge_verts");
&mesh.edge_data, CD_PROP_INT32_2D, CD_CONSTRUCT, mesh.edges_num, ".edge_verts");
const Vector<BMeshToMeshLayerInfo> info = bm_to_mesh_copy_info_calc(bm.edata, mesh.edge_data);
MutableSpan<int2> dst_edges = mesh.edges_for_write();
@ -1402,14 +1405,14 @@ static void bm_to_mesh_loops(const BMesh &bm, const Span<const BMLoop *> bm_loop
void BM_mesh_bm_to_me(Main *bmain, BMesh *bm, Mesh *mesh, const BMeshToMeshParams *params)
{
using namespace blender;
const int old_verts_num = mesh->totvert;
const int old_verts_num = mesh->verts_num;
BKE_mesh_clear_geometry(mesh);
mesh->totvert = bm->totvert;
mesh->totedge = bm->totedge;
mesh->verts_num = bm->totvert;
mesh->edges_num = bm->totedge;
mesh->totface_legacy = 0;
mesh->totloop = bm->totloop;
mesh->corners_num = bm->totloop;
mesh->faces_num = bm->totface;
mesh->act_face = -1;
@ -1429,7 +1432,7 @@ void BM_mesh_bm_to_me(Main *bmain, BMesh *bm, Mesh *mesh, const BMeshToMeshParam
Array<const BMLoop *> loop_table;
Vector<int> loop_layers_not_to_copy;
threading::parallel_invoke(
(mesh->faces_num + mesh->totedge) > 1024,
(mesh->faces_num + mesh->edges_num) > 1024,
[&]() {
vert_table.reinitialize(bm->totvert);
bm_vert_table_build(*bm, vert_table, need_select_vert, need_hide_vert);
@ -1459,9 +1462,12 @@ void BM_mesh_bm_to_me(Main *bmain, BMesh *bm, Mesh *mesh, const BMeshToMeshParam
{
CustomData_MeshMasks mask = CD_MASK_MESH;
CustomData_MeshMasks_update(&mask, &params->cd_mask_extra);
CustomData_copy_layout(&bm->vdata, &mesh->vert_data, mask.vmask, CD_CONSTRUCT, mesh->totvert);
CustomData_copy_layout(&bm->edata, &mesh->edge_data, mask.emask, CD_CONSTRUCT, mesh->totedge);
CustomData_copy_layout(&bm->ldata, &mesh->loop_data, mask.lmask, CD_CONSTRUCT, mesh->totloop);
CustomData_copy_layout(
&bm->vdata, &mesh->vert_data, mask.vmask, CD_CONSTRUCT, mesh->verts_num);
CustomData_copy_layout(
&bm->edata, &mesh->edge_data, mask.emask, CD_CONSTRUCT, mesh->edges_num);
CustomData_copy_layout(
&bm->ldata, &mesh->loop_data, mask.lmask, CD_CONSTRUCT, mesh->corners_num);
CustomData_copy_layout(
&bm->pdata, &mesh->face_data, mask.pmask, CD_CONSTRUCT, mesh->faces_num);
}
@ -1513,7 +1519,7 @@ void BM_mesh_bm_to_me(Main *bmain, BMesh *bm, Mesh *mesh, const BMeshToMeshParam
/* Loop over all elements in parallel, copying attributes and building the Mesh topology. */
threading::parallel_invoke(
(mesh->faces_num + mesh->totedge) > 1024,
(mesh->faces_num + mesh->edges_num) > 1024,
[&]() {
bm_to_mesh_verts(*bm, vert_table, *mesh, select_vert.span, hide_vert.span);
if (mesh->key) {
@ -1617,15 +1623,15 @@ void BM_mesh_bm_to_me_for_eval(BMesh *bm, Mesh *mesh, const CustomData_MeshMasks
using namespace blender;
/* Must be an empty mesh. */
BLI_assert(mesh->totvert == 0);
BLI_assert(mesh->verts_num == 0);
BLI_assert(cd_mask_extra == nullptr || (cd_mask_extra->vmask & CD_MASK_SHAPEKEY) == 0);
/* Just in case, clear the derived geometry caches from the input mesh. */
BKE_mesh_runtime_clear_geometry(mesh);
mesh->totvert = bm->totvert;
mesh->totedge = bm->totedge;
mesh->verts_num = bm->totvert;
mesh->edges_num = bm->totedge;
mesh->totface_legacy = 0;
mesh->totloop = bm->totloop;
mesh->corners_num = bm->totloop;
mesh->faces_num = bm->totface;
mesh->runtime->deformed_only = true;
@ -1649,7 +1655,7 @@ void BM_mesh_bm_to_me_for_eval(BMesh *bm, Mesh *mesh, const CustomData_MeshMasks
Array<const BMLoop *> loop_table;
Vector<int> loop_layers_not_to_copy;
threading::parallel_invoke(
(mesh->faces_num + mesh->totedge) > 1024,
(mesh->faces_num + mesh->edges_num) > 1024,
[&]() {
vert_table.reinitialize(bm->totvert);
bm_vert_table_build(*bm, vert_table, need_select_vert, need_hide_vert);
@ -1683,9 +1689,10 @@ void BM_mesh_bm_to_me_for_eval(BMesh *bm, Mesh *mesh, const CustomData_MeshMasks
CustomData_MeshMasks_update(&mask, cd_mask_extra);
}
mask.vmask &= ~CD_MASK_SHAPEKEY;
CustomData_merge_layout(&bm->vdata, &mesh->vert_data, mask.vmask, CD_CONSTRUCT, mesh->totvert);
CustomData_merge_layout(&bm->edata, &mesh->edge_data, mask.emask, CD_CONSTRUCT, mesh->totedge);
CustomData_merge_layout(&bm->ldata, &mesh->loop_data, mask.lmask, CD_CONSTRUCT, mesh->totloop);
CustomData_merge_layout(&bm->vdata, &mesh->vert_data, mask.vmask, CD_CONSTRUCT, mesh->verts_num);
CustomData_merge_layout(&bm->edata, &mesh->edge_data, mask.emask, CD_CONSTRUCT, mesh->edges_num);
CustomData_merge_layout(
&bm->ldata, &mesh->loop_data, mask.lmask, CD_CONSTRUCT, mesh->corners_num);
CustomData_merge_layout(&bm->pdata, &mesh->face_data, mask.pmask, CD_CONSTRUCT, mesh->faces_num);
/* Add optional mesh attributes before parallel iteration. */
@ -1735,7 +1742,7 @@ void BM_mesh_bm_to_me_for_eval(BMesh *bm, Mesh *mesh, const CustomData_MeshMasks
/* Loop over all elements in parallel, copying attributes and building the Mesh topology. */
threading::parallel_invoke(
(mesh->faces_num + mesh->totedge) > 1024,
(mesh->faces_num + mesh->edges_num) > 1024,
[&]() { bm_to_mesh_verts(*bm, vert_table, *mesh, select_vert.span, hide_vert.span); },
[&]() {
bm_to_mesh_edges(*bm,

View File

@ -186,7 +186,7 @@ void OVERLAY_wireframe_cache_populate(OVERLAY_Data *vedata,
mesh = editmesh_eval_final;
}
}
is_mesh_verts_only = mesh->totedge == 0 && mesh->totvert > 0;
is_mesh_verts_only = mesh->edges_num == 0 && mesh->verts_num > 0;
}
const bool use_wire = !is_mesh_verts_only && ((pd->overlay.flag & V3D_OVERLAY_WIREFRAMES) ||

View File

@ -163,7 +163,7 @@ static void draw_select_id_mesh(SELECTID_StorageList *stl,
DRWShadingGroup *edge_shgrp = DRW_shgroup_create_sub(stl->g_data->shgrp_edge);
DRW_shgroup_uniform_int_copy(edge_shgrp, "offset", *(int *)r_face_offset);
DRW_shgroup_call_no_cull(edge_shgrp, geom_edges, ob);
*r_edge_offset = *r_face_offset + mesh->totedge;
*r_edge_offset = *r_face_offset + mesh->edges_num;
}
else {
*r_edge_offset = *r_face_offset;
@ -174,7 +174,7 @@ static void draw_select_id_mesh(SELECTID_StorageList *stl,
DRWShadingGroup *vert_shgrp = DRW_shgroup_create_sub(stl->g_data->shgrp_vert);
DRW_shgroup_uniform_int_copy(vert_shgrp, "offset", *r_edge_offset);
DRW_shgroup_call_no_cull(vert_shgrp, geom_verts, ob);
*r_vert_offset = *r_edge_offset + mesh->totvert;
*r_vert_offset = *r_edge_offset + mesh->verts_num;
}
else {
*r_vert_offset = *r_edge_offset;

View File

@ -56,7 +56,7 @@ static void mesh_render_data_loose_geom_mesh(const MeshRenderData &mr, MeshBuffe
const bool no_loose_edge_hint = mesh.runtime->loose_edges_cache.is_cached() &&
mesh.runtime->loose_edges_cache.data().count == 0;
threading::parallel_invoke(
mesh.totedge > 4096 && !no_loose_vert_hint && !no_loose_edge_hint,
mesh.edges_num > 4096 && !no_loose_vert_hint && !no_loose_edge_hint,
[&]() {
const bke::LooseEdgeCache &loose_edges = mesh.loose_edges();
if (loose_edges.count > 0) {
@ -660,9 +660,9 @@ MeshRenderData *mesh_render_data_create(Object *object,
if (mr->extract_type != MR_EXTRACT_BMESH) {
/* Mesh */
mr->vert_len = mr->mesh->totvert;
mr->edge_len = mr->mesh->totedge;
mr->loop_len = mr->mesh->totloop;
mr->vert_len = mr->mesh->verts_num;
mr->edge_len = mr->mesh->edges_num;
mr->loop_len = mr->mesh->corners_num;
mr->face_len = mr->mesh->faces_num;
mr->tri_len = poly_to_tri_count(mr->face_len, mr->loop_len);

View File

@ -2231,7 +2231,7 @@ void DRW_subdivide_loose_geom(DRWSubdivCache *subdiv_cache, MeshBufferCache *cac
blender::Array<int> vert_to_edge_offsets;
blender::Array<int> vert_to_edge_indices;
const blender::GroupedSpan<int> vert_to_edge_map = blender::bke::mesh::build_vert_to_edge_map(
coarse_edges, coarse_mesh->totvert, vert_to_edge_offsets, vert_to_edge_indices);
coarse_edges, coarse_mesh->verts_num, vert_to_edge_offsets, vert_to_edge_indices);
for (int i = 0; i < coarse_loose_edge_len; i++) {
const int coarse_edge_index = cache->loose_geom.edges[i];

View File

@ -270,7 +270,7 @@ static void extract_attr_init_subdiv(const DRWSubdivCache &subdiv_cache,
GPUVertBuf *src_data = GPU_vertbuf_calloc();
GPUVertFormat coarse_format = draw::init_format_for_attribute(request.cd_type, "data");
GPU_vertbuf_init_with_format_ex(src_data, &coarse_format, GPU_USAGE_STATIC);
GPU_vertbuf_data_alloc(src_data, uint32_t(coarse_mesh->totloop));
GPU_vertbuf_data_alloc(src_data, uint32_t(coarse_mesh->corners_num));
extract_attr(mr, request, *src_data);

View File

@ -263,7 +263,7 @@ static void extract_pos_nor_init_subdiv(const DRWSubdivCache &subdiv_cache,
GPUVertBuf *src_custom_normals = GPU_vertbuf_calloc();
GPU_vertbuf_init_with_format(src_custom_normals, get_custom_normals_format());
GPU_vertbuf_data_alloc(src_custom_normals, coarse_mesh->totloop);
GPU_vertbuf_data_alloc(src_custom_normals, coarse_mesh->corners_num);
memcpy(GPU_vertbuf_get_data(src_custom_normals),
corner_normals.data(),

View File

@ -135,7 +135,7 @@ static void extract_sculpt_data_init_subdiv(const DRWSubdivCache &subdiv_cache,
mask_vbo = GPU_vertbuf_calloc();
GPU_vertbuf_init_with_format(mask_vbo, &mask_format);
GPU_vertbuf_data_alloc(mask_vbo, coarse_mesh->totloop);
GPU_vertbuf_data_alloc(mask_vbo, coarse_mesh->corners_num);
float *v_mask = static_cast<float *>(GPU_vertbuf_get_data(mask_vbo));
for (int i = 0; i < coarse_mesh->faces_num; i++) {

View File

@ -215,7 +215,7 @@ static void envelope_bone_weighting(Object *ob,
&mesh->vert_data, CD_PROP_BOOL, ".select_vert");
/* for each vertex in the mesh */
for (int i = 0; i < mesh->totvert; i++) {
for (int i = 0; i < mesh->verts_num; i++) {
if (use_mask && !(select_vert && select_vert[i])) {
continue;
@ -401,14 +401,14 @@ static void add_verts_to_dgroups(ReportList *reports,
/* create verts */
mesh = (Mesh *)ob->data;
verts = static_cast<float(*)[3]>(
MEM_callocN(mesh->totvert * sizeof(*verts), "closestboneverts"));
MEM_callocN(mesh->verts_num * sizeof(*verts), "closestboneverts"));
if (wpmode) {
/* if in weight paint mode, use final verts from evaluated mesh */
const Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
const Mesh *me_eval = BKE_object_get_evaluated_mesh(ob_eval);
if (me_eval) {
BKE_mesh_foreach_mapped_vert_coords_get(me_eval, verts, mesh->totvert);
BKE_mesh_foreach_mapped_vert_coords_get(me_eval, verts, mesh->verts_num);
vertsfilled = 1;
}
}
@ -422,7 +422,7 @@ static void add_verts_to_dgroups(ReportList *reports,
/* transform verts to global space */
const blender::Span<blender::float3> positions = mesh->vert_positions();
for (int i = 0; i < mesh->totvert; i++) {
for (int i = 0; i < mesh->verts_num; i++) {
if (!vertsfilled) {
copy_v3_v3(verts[i], positions[i]);
}

View File

@ -657,12 +657,12 @@ void heat_bone_weighting(Object *ob,
*error_str = nullptr;
/* bone heat needs triangulated faces */
tris_num = poly_to_tri_count(mesh->faces_num, mesh->totloop);
tris_num = poly_to_tri_count(mesh->faces_num, mesh->corners_num);
/* count triangles and create mask */
if (ob->mode & OB_MODE_WEIGHT_PAINT && (use_face_sel || use_vert_sel)) {
mask = static_cast<int *>(
MEM_callocN(sizeof(int) * mesh->totvert, "heat_bone_weighting mask"));
MEM_callocN(sizeof(int) * mesh->verts_num, "heat_bone_weighting mask"));
/* (added selectedVerts content for vertex mask, they used to just equal 1) */
if (use_vert_sel) {
@ -692,9 +692,9 @@ void heat_bone_weighting(Object *ob,
}
/* create laplacian */
sys = laplacian_system_construct_begin(mesh->totvert, tris_num, 1);
sys = laplacian_system_construct_begin(mesh->verts_num, tris_num, 1);
sys->heat.tris_num = poly_to_tri_count(mesh->faces_num, mesh->totloop);
sys->heat.tris_num = poly_to_tri_count(mesh->faces_num, mesh->corners_num);
corner_tris = static_cast<blender::int3 *>(
MEM_mallocN(sizeof(*sys->heat.corner_tris) * sys->heat.tris_num, __func__));
@ -703,7 +703,7 @@ void heat_bone_weighting(Object *ob,
sys->heat.corner_tris = corner_tris;
sys->heat.corner_verts = corner_verts;
sys->heat.verts_num = mesh->totvert;
sys->heat.verts_num = mesh->verts_num;
sys->heat.verts = verts;
sys->heat.root = root;
sys->heat.tip = tip;
@ -715,8 +715,8 @@ void heat_bone_weighting(Object *ob,
laplacian_system_construct_end(sys);
if (dgroupflip) {
vertsflipped = static_cast<int *>(MEM_callocN(sizeof(int) * mesh->totvert, "vertsflipped"));
for (a = 0; a < mesh->totvert; a++) {
vertsflipped = static_cast<int *>(MEM_callocN(sizeof(int) * mesh->verts_num, "vertsflipped"));
for (a = 0; a < mesh->verts_num; a++) {
vertsflipped[a] = mesh_get_x_mirror_vert(ob, nullptr, a, use_topology);
}
}
@ -733,7 +733,7 @@ void heat_bone_weighting(Object *ob,
/* clear weights */
if (bbone && firstsegment) {
for (a = 0; a < mesh->totvert; a++) {
for (a = 0; a < mesh->verts_num; a++) {
if (mask && !mask[a]) {
continue;
}
@ -748,7 +748,7 @@ void heat_bone_weighting(Object *ob,
/* fill right hand side */
laplacian_begin_solve(sys, -1);
for (a = 0; a < mesh->totvert; a++) {
for (a = 0; a < mesh->verts_num; a++) {
if (heat_source_closest(sys, a, j)) {
laplacian_add_right_hand_side(sys, a, sys->heat.H[a] * sys->heat.p[a]);
}
@ -757,7 +757,7 @@ void heat_bone_weighting(Object *ob,
/* solve */
if (laplacian_system_solve(sys)) {
/* load solution into vertex groups */
for (a = 0; a < mesh->totvert; a++) {
for (a = 0; a < mesh->verts_num; a++) {
if (mask && !mask[a]) {
continue;
}
@ -805,7 +805,7 @@ void heat_bone_weighting(Object *ob,
/* remove too small vertex weights */
if (bbone && lastsegment) {
for (a = 0; a < mesh->totvert; a++) {
for (a = 0; a < mesh->verts_num; a++) {
if (mask && !mask[a]) {
continue;
}
@ -1777,7 +1777,7 @@ void ED_mesh_deform_bind_callback(Object *object,
mdb.verts_num = verts_num;
mdb.cagemesh = cagemesh;
mdb.cage_verts_num = mdb.cagemesh->totvert;
mdb.cage_verts_num = mdb.cagemesh->verts_num;
mdb.cagecos = static_cast<float(*)[3]>(
MEM_callocN(sizeof(*mdb.cagecos) * mdb.cage_verts_num, "MeshDeformBindCos"));
copy_m4_m4(mdb.cagemat, cagemat);

View File

@ -431,7 +431,7 @@ static int geometry_attribute_convert_exec(bContext *C, wmOperator *op)
break;
}
case ConvertAttributeMode::VertexGroup: {
Array<float> src_weights(mesh->totvert);
Array<float> src_weights(mesh->verts_num);
VArray<float> src_varray = *attributes.lookup_or_default<float>(
name, ATTR_DOMAIN_POINT, 0.0f);
src_varray.materialize(src_weights);
@ -440,7 +440,7 @@ static int geometry_attribute_convert_exec(bContext *C, wmOperator *op)
bDeformGroup *defgroup = BKE_object_defgroup_new(ob, name.c_str());
const int defgroup_index = BLI_findindex(BKE_id_defgroup_list_get(&mesh->id), defgroup);
MDeformVert *dverts = BKE_object_defgroup_data_create(&mesh->id);
for (const int i : IndexRange(mesh->totvert)) {
for (const int i : IndexRange(mesh->verts_num)) {
const float weight = src_weights[i];
if (weight > 0.0f) {
BKE_defvert_add_index_notest(dverts + i, defgroup_index, weight);

View File

@ -222,7 +222,7 @@ void paintface_reveal(bContext *C, Object *ob, const bool select)
/**
* Join all edges of each face in the #AtomicDisjointSet. This can be used to find out which faces
* are connected to each other.
* \param islands: Is expected to be of length `mesh->totedge`.
* \param islands: Is expected to be of length `mesh->edges_num`.
* \param skip_seams: Faces separated by a seam will be treated as not connected.
*/
static void build_poly_connections(blender::AtomicDisjointSet &islands,
@ -276,7 +276,7 @@ static void paintface_select_linked_faces(Mesh &mesh,
{
using namespace blender;
AtomicDisjointSet islands(mesh.totedge);
AtomicDisjointSet islands(mesh.edges_num);
build_poly_connections(islands, mesh);
const OffsetIndices faces = mesh.faces();
@ -487,7 +487,7 @@ void paintface_select_loop(bContext *C, Object *ob, const int mval[2], const boo
Array<int> edge_to_face_offsets;
Array<int> edge_to_face_indices;
const GroupedSpan<int> edge_to_face_map = bke::mesh::build_edge_to_face_map(
faces, corner_edges, mesh->totedge, edge_to_face_offsets, edge_to_face_indices);
faces, corner_edges, mesh->edges_num, edge_to_face_offsets, edge_to_face_indices);
VectorSet<int> faces_to_select;
@ -623,7 +623,7 @@ void paintface_select_less(Mesh *mesh, const bool face_step)
const Span<int> corner_edges = mesh->corner_edges();
const Span<int2> edges = mesh->edges();
BitVector<> verts_of_unselected_faces(mesh->totvert);
BitVector<> verts_of_unselected_faces(mesh->verts_num);
/* Find all vertices of unselected faces to help find neighboring faces after. */
for (const int i : faces.index_range()) {
@ -887,7 +887,7 @@ static void paintvert_select_linked_vertices(bContext *C,
}
/* AtomicDisjointSet is used to store connection information in vertex indices. */
AtomicDisjointSet islands(mesh->totvert);
AtomicDisjointSet islands(mesh->verts_num);
const Span<int2> edges = mesh->edges();
/* By calling join() on the vertices of all edges, the AtomicDisjointSet contains information on
@ -982,12 +982,12 @@ void paintvert_select_more(Mesh *mesh, const bool face_step)
GroupedSpan<int> edge_to_face_map;
if (face_step) {
edge_to_face_map = bke::mesh::build_edge_to_face_map(
faces, corner_edges, mesh->totedge, edge_to_face_offsets, edge_to_face_indices);
faces, corner_edges, mesh->edges_num, edge_to_face_offsets, edge_to_face_indices);
}
/* Need a copy of the selected verts that we can read from and is not modified. */
BitVector<> select_vert_original(mesh->totvert, false);
for (int i = 0; i < mesh->totvert; i++) {
BitVector<> select_vert_original(mesh->verts_num, false);
for (int i = 0; i < mesh->verts_num; i++) {
select_vert_original[i].set(select_vert.span[i]);
}
@ -1044,8 +1044,8 @@ void paintvert_select_less(Mesh *mesh, const bool face_step)
}
/* Need a copy of the selected verts that we can read from and is not modified. */
BitVector<> select_vert_original(mesh->totvert);
for (int i = 0; i < mesh->totvert; i++) {
BitVector<> select_vert_original(mesh->verts_num);
for (int i = 0; i < mesh->verts_num; i++) {
select_vert_original[i].set(select_vert.span[i]);
}
@ -1096,7 +1096,7 @@ bool paintvert_deselect_all_visible(Object *ob, int action, bool flush_flags)
if (action == SEL_TOGGLE) {
action = SEL_SELECT;
for (int i = 0; i < mesh->totvert; i++) {
for (int i = 0; i < mesh->verts_num; i++) {
if (!hide_vert[i] && select_vert.span[i]) {
action = SEL_DESELECT;
break;
@ -1105,7 +1105,7 @@ bool paintvert_deselect_all_visible(Object *ob, int action, bool flush_flags)
}
bool changed = false;
for (int i = 0; i < mesh->totvert; i++) {
for (int i = 0; i < mesh->verts_num; i++) {
if (hide_vert[i]) {
continue;
}
@ -1189,7 +1189,7 @@ void paintvert_hide(bContext *C, Object *ob, const bool unselected)
{
using namespace blender;
Mesh *mesh = BKE_mesh_from_object(ob);
if (mesh == nullptr || mesh->totvert == 0) {
if (mesh == nullptr || mesh->verts_num == 0) {
return;
}
@ -1223,7 +1223,7 @@ void paintvert_reveal(bContext *C, Object *ob, const bool select)
{
using namespace blender;
Mesh *mesh = BKE_mesh_from_object(ob);
if (mesh == nullptr || mesh->totvert == 0) {
if (mesh == nullptr || mesh->verts_num == 0) {
return;
}

View File

@ -193,7 +193,7 @@ static int geometry_extract_apply(bContext *C,
BKE_editmesh_free_data(em);
MEM_freeN(em);
if (new_mesh->totvert == 0) {
if (new_mesh->verts_num == 0) {
BKE_id_free(bmain, new_mesh);
return OPERATOR_FINISHED;
}

View File

@ -368,10 +368,10 @@ static void um_arraystore_compact_ex(UndoMesh *um, const UndoMesh *um_ref, bool
* Since this is itself a background thread, using too many threads here could
* interfere with foreground tasks. */
blender::threading::parallel_invoke(
4096 < (mesh->totvert + mesh->totedge + mesh->totloop + mesh->faces_num),
4096 < (mesh->verts_num + mesh->edges_num + mesh->corners_num + mesh->faces_num),
[&]() {
um_arraystore_cd_compact(&mesh->vert_data,
mesh->totvert,
mesh->verts_num,
create,
ARRAY_STORE_INDEX_VERT,
um_ref ? um_ref->store.vdata : nullptr,
@ -379,7 +379,7 @@ static void um_arraystore_compact_ex(UndoMesh *um, const UndoMesh *um_ref, bool
},
[&]() {
um_arraystore_cd_compact(&mesh->edge_data,
mesh->totedge,
mesh->edges_num,
create,
ARRAY_STORE_INDEX_EDGE,
um_ref ? um_ref->store.edata : nullptr,
@ -387,7 +387,7 @@ static void um_arraystore_compact_ex(UndoMesh *um, const UndoMesh *um_ref, bool
},
[&]() {
um_arraystore_cd_compact(&mesh->loop_data,
mesh->totloop,
mesh->corners_num,
create,
ARRAY_STORE_INDEX_LOOP,
um_ref ? um_ref->store.ldata : nullptr,
@ -563,9 +563,9 @@ static void um_arraystore_expand(UndoMesh *um)
{
Mesh *mesh = &um->mesh;
um_arraystore_cd_expand(um->store.vdata, &mesh->vert_data, mesh->totvert);
um_arraystore_cd_expand(um->store.edata, &mesh->edge_data, mesh->totedge);
um_arraystore_cd_expand(um->store.ldata, &mesh->loop_data, mesh->totloop);
um_arraystore_cd_expand(um->store.vdata, &mesh->vert_data, mesh->verts_num);
um_arraystore_cd_expand(um->store.edata, &mesh->edge_data, mesh->edges_num);
um_arraystore_cd_expand(um->store.ldata, &mesh->loop_data, mesh->corners_num);
um_arraystore_cd_expand(um->store.pdata, &mesh->face_data, mesh->faces_num);
if (um->store.keyblocks) {

View File

@ -68,7 +68,7 @@ static CustomData *mesh_customdata_get_type(Mesh *mesh, const char htype, int *r
}
else {
data = &mesh->vert_data;
tot = mesh->totvert;
tot = mesh->verts_num;
}
break;
case BM_EDGE:
@ -78,7 +78,7 @@ static CustomData *mesh_customdata_get_type(Mesh *mesh, const char htype, int *r
}
else {
data = &mesh->edge_data;
tot = mesh->totedge;
tot = mesh->edges_num;
}
break;
case BM_LOOP:
@ -88,7 +88,7 @@ static CustomData *mesh_customdata_get_type(Mesh *mesh, const char htype, int *r
}
else {
data = &mesh->loop_data;
tot = mesh->totloop;
tot = mesh->corners_num;
}
break;
case BM_FACE:
@ -205,7 +205,7 @@ void ED_mesh_uv_loop_reset_ex(Mesh *mesh, const int layernum)
/* Collect Mesh UVs */
BLI_assert(CustomData_has_layer(&mesh->loop_data, CD_PROP_FLOAT2));
float2 *mloopuv = static_cast<float2 *>(CustomData_get_layer_n_for_write(
&mesh->loop_data, CD_PROP_FLOAT2, layernum, mesh->totloop));
&mesh->loop_data, CD_PROP_FLOAT2, layernum, mesh->corners_num));
const blender::OffsetIndices polys = mesh->faces();
for (const int i : polys.index_range()) {
@ -276,7 +276,7 @@ int ED_mesh_uv_add(
&mesh->loop_data,
CD_PROP_FLOAT2,
MEM_dupallocN(CustomData_get_layer(&mesh->loop_data, CD_PROP_FLOAT2)),
mesh->totloop,
mesh->corners_num,
unique_name,
nullptr);
@ -284,7 +284,7 @@ int ED_mesh_uv_add(
}
else {
CustomData_add_layer_named(
&mesh->loop_data, CD_PROP_FLOAT2, CD_SET_DEFAULT, mesh->totloop, unique_name);
&mesh->loop_data, CD_PROP_FLOAT2, CD_SET_DEFAULT, mesh->corners_num, unique_name);
}
if (active_set || layernum_dst == 0) {
@ -341,7 +341,7 @@ const bool *ED_mesh_uv_map_pin_layer_get(const Mesh *mesh, const int uv_index)
static bool *ensure_corner_boolean_attribute(Mesh &mesh, const blender::StringRefNull name)
{
bool *data = static_cast<bool *>(CustomData_get_layer_named_for_write(
&mesh.loop_data, CD_PROP_BOOL, name.c_str(), mesh.totloop));
&mesh.loop_data, CD_PROP_BOOL, name.c_str(), mesh.corners_num));
if (!data) {
data = static_cast<bool *>(CustomData_add_layer_named(
&mesh.loop_data, CD_PROP_BOOL, CD_SET_DEFAULT, mesh.faces_num, name.c_str()));
@ -414,7 +414,8 @@ int ED_mesh_color_add(
BM_data_layer_copy(&bm, &bm.ldata, CD_PROP_BYTE_COLOR, src_i, dst_i);
}
else {
memcpy(layer->data, active_layer->data, CustomData_get_elem_size(layer) * mesh->totloop);
memcpy(
layer->data, active_layer->data, CustomData_get_elem_size(layer) * mesh->corners_num);
}
}
}
@ -729,7 +730,7 @@ static int mesh_customdata_custom_splitnormals_add_exec(bContext *C, wmOperator
BM_data_layer_add(&bm, &bm.ldata, CD_CUSTOMLOOPNORMAL);
}
else {
CustomData_add_layer(&mesh->loop_data, CD_CUSTOMLOOPNORMAL, CD_SET_DEFAULT, mesh->totloop);
CustomData_add_layer(&mesh->loop_data, CD_CUSTOMLOOPNORMAL, CD_SET_DEFAULT, mesh->corners_num);
}
DEG_id_tag_update(&mesh->id, 0);
@ -789,22 +790,22 @@ static void mesh_add_verts(Mesh *mesh, int len)
return;
}
int totvert = mesh->totvert + len;
int totvert = mesh->verts_num + len;
CustomData vert_data;
CustomData_copy_layout(
&mesh->vert_data, &vert_data, CD_MASK_MESH.vmask, CD_SET_DEFAULT, totvert);
CustomData_copy_data(&mesh->vert_data, &vert_data, 0, 0, mesh->totvert);
CustomData_copy_data(&mesh->vert_data, &vert_data, 0, 0, mesh->verts_num);
if (!CustomData_has_layer_named(&vert_data, CD_PROP_FLOAT3, "position")) {
CustomData_add_layer_named(&vert_data, CD_PROP_FLOAT3, CD_SET_DEFAULT, totvert, "position");
}
CustomData_free(&mesh->vert_data, mesh->totvert);
CustomData_free(&mesh->vert_data, mesh->verts_num);
mesh->vert_data = vert_data;
BKE_mesh_runtime_clear_cache(mesh);
mesh->totvert = totvert;
mesh->verts_num = totvert;
bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
bke::SpanAttributeWriter<bool> select_vert = attributes.lookup_or_add_for_write_span<bool>(
@ -823,24 +824,24 @@ static void mesh_add_edges(Mesh *mesh, int len)
return;
}
totedge = mesh->totedge + len;
totedge = mesh->edges_num + len;
/* Update custom-data. */
CustomData_copy_layout(
&mesh->edge_data, &edge_data, CD_MASK_MESH.emask, CD_SET_DEFAULT, totedge);
CustomData_copy_data(&mesh->edge_data, &edge_data, 0, 0, mesh->totedge);
CustomData_copy_data(&mesh->edge_data, &edge_data, 0, 0, mesh->edges_num);
if (!CustomData_has_layer_named(&edge_data, CD_PROP_INT32_2D, ".edge_verts")) {
CustomData_add_layer_named(
&edge_data, CD_PROP_INT32_2D, CD_SET_DEFAULT, totedge, ".edge_verts");
}
CustomData_free(&mesh->edge_data, mesh->totedge);
CustomData_free(&mesh->edge_data, mesh->edges_num);
mesh->edge_data = edge_data;
BKE_mesh_runtime_clear_cache(mesh);
mesh->totedge = totedge;
mesh->edges_num = totedge;
bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
bke::SpanAttributeWriter<bool> select_edge = attributes.lookup_or_add_for_write_span<bool>(
@ -858,11 +859,11 @@ static void mesh_add_loops(Mesh *mesh, int len)
return;
}
totloop = mesh->totloop + len; /* new face count */
totloop = mesh->corners_num + len; /* new face count */
/* update customdata */
CustomData_copy_layout(&mesh->loop_data, &ldata, CD_MASK_MESH.lmask, CD_SET_DEFAULT, totloop);
CustomData_copy_data(&mesh->loop_data, &ldata, 0, 0, mesh->totloop);
CustomData_copy_data(&mesh->loop_data, &ldata, 0, 0, mesh->corners_num);
if (!CustomData_has_layer_named(&ldata, CD_PROP_INT32, ".corner_vert")) {
CustomData_add_layer_named(&ldata, CD_PROP_INT32, CD_SET_DEFAULT, totloop, ".corner_vert");
@ -873,15 +874,15 @@ static void mesh_add_loops(Mesh *mesh, int len)
BKE_mesh_runtime_clear_cache(mesh);
CustomData_free(&mesh->loop_data, mesh->totloop);
CustomData_free(&mesh->loop_data, mesh->corners_num);
mesh->loop_data = ldata;
mesh->totloop = totloop;
mesh->corners_num = totloop;
/* Keep the last face offset up to date with the corner total (they must be the same). We have
* to be careful here though, since the mesh may not be in a valid state at this point. */
if (mesh->face_offset_indices) {
mesh->face_offsets_for_write().last() = mesh->totloop;
mesh->face_offsets_for_write().last() = mesh->corners_num;
}
}
@ -908,7 +909,7 @@ static void mesh_add_faces(Mesh *mesh, int len)
faces_num + 1);
/* Set common values for convenience. */
mesh->face_offset_indices[0] = 0;
mesh->face_offset_indices[faces_num] = mesh->totloop;
mesh->face_offset_indices[faces_num] = mesh->corners_num;
CustomData_free(&mesh->face_data, mesh->faces_num);
mesh->face_data = face_data;
@ -975,10 +976,10 @@ static void mesh_remove_verts(Mesh *mesh, int len)
if (len == 0) {
return;
}
CustomData_ensure_layers_are_mutable(&mesh->vert_data, mesh->totvert);
const int totvert = mesh->totvert - len;
CustomData_ensure_layers_are_mutable(&mesh->vert_data, mesh->verts_num);
const int totvert = mesh->verts_num - len;
CustomData_free_elem(&mesh->vert_data, totvert, len);
mesh->totvert = totvert;
mesh->verts_num = totvert;
}
static void mesh_remove_edges(Mesh *mesh, int len)
@ -986,10 +987,10 @@ static void mesh_remove_edges(Mesh *mesh, int len)
if (len == 0) {
return;
}
CustomData_ensure_layers_are_mutable(&mesh->edge_data, mesh->totedge);
const int totedge = mesh->totedge - len;
CustomData_ensure_layers_are_mutable(&mesh->edge_data, mesh->edges_num);
const int totedge = mesh->edges_num - len;
CustomData_free_elem(&mesh->edge_data, totedge, len);
mesh->totedge = totedge;
mesh->edges_num = totedge;
}
static void mesh_remove_loops(Mesh *mesh, int len)
@ -997,10 +998,10 @@ static void mesh_remove_loops(Mesh *mesh, int len)
if (len == 0) {
return;
}
CustomData_ensure_layers_are_mutable(&mesh->loop_data, mesh->totloop);
const int totloop = mesh->totloop - len;
CustomData_ensure_layers_are_mutable(&mesh->loop_data, mesh->corners_num);
const int totloop = mesh->corners_num - len;
CustomData_free_elem(&mesh->loop_data, totloop, len);
mesh->totloop = totloop;
mesh->corners_num = totloop;
}
static void mesh_remove_faces(Mesh *mesh, int len)
@ -1020,7 +1021,7 @@ void ED_mesh_verts_remove(Mesh *mesh, ReportList *reports, int count)
BKE_report(reports, RPT_ERROR, "Cannot remove vertices in edit mode");
return;
}
if (count > mesh->totvert) {
if (count > mesh->verts_num) {
BKE_report(reports, RPT_ERROR, "Cannot remove more vertices than the mesh contains");
return;
}
@ -1034,7 +1035,7 @@ void ED_mesh_edges_remove(Mesh *mesh, ReportList *reports, int count)
BKE_report(reports, RPT_ERROR, "Cannot remove edges in edit mode");
return;
}
if (count > mesh->totedge) {
if (count > mesh->edges_num) {
BKE_report(reports, RPT_ERROR, "Cannot remove more edges than the mesh contains");
return;
}
@ -1048,7 +1049,7 @@ void ED_mesh_loops_remove(Mesh *mesh, ReportList *reports, int count)
BKE_report(reports, RPT_ERROR, "Cannot remove loops in edit mode");
return;
}
if (count > mesh->totloop) {
if (count > mesh->corners_num) {
BKE_report(reports, RPT_ERROR, "Cannot remove more loops than the mesh contains");
return;
}
@ -1072,9 +1073,9 @@ void ED_mesh_faces_remove(Mesh *mesh, ReportList *reports, int count)
void ED_mesh_geometry_clear(Mesh *mesh)
{
mesh_remove_verts(mesh, mesh->totvert);
mesh_remove_edges(mesh, mesh->totedge);
mesh_remove_loops(mesh, mesh->totloop);
mesh_remove_verts(mesh, mesh->verts_num);
mesh_remove_edges(mesh, mesh->edges_num);
mesh_remove_loops(mesh, mesh->corners_num);
mesh_remove_faces(mesh, mesh->faces_num);
}
@ -1139,7 +1140,7 @@ void ED_mesh_split_faces(Mesh *mesh)
const bool *sharp_faces = static_cast<const bool *>(
CustomData_get_layer_named(&mesh->face_data, CD_PROP_BOOL, "sharp_face"));
Array<bool> sharp_edges(mesh->totedge);
Array<bool> sharp_edges(mesh->edges_num);
mesh_sharp_edges.materialize(sharp_edges);
threading::parallel_for(polys.index_range(), 1024, [&](const IndexRange range) {

View File

@ -34,7 +34,7 @@ void ED_mesh_mirror_spatial_table_begin(Object *ob, BMEditMesh *em, Mesh *me_eva
{
Mesh *mesh = static_cast<Mesh *>(ob->data);
const bool use_em = (!me_eval && em && mesh->edit_mesh == em);
const int totvert = use_em ? em->bm->totvert : me_eval ? me_eval->totvert : mesh->totvert;
const int totvert = use_em ? em->bm->totvert : me_eval ? me_eval->verts_num : mesh->verts_num;
if (MirrKdStore.tree) { /* happens when entering this call without ending it */
ED_mesh_mirror_spatial_table_end(ob);
@ -142,8 +142,8 @@ bool ED_mesh_mirrtopo_recalc_check(BMEditMesh *em, Mesh *mesh, MirrTopoStore_t *
totedge = em->bm->totedge;
}
else {
totvert = mesh->totvert;
totedge = mesh->totedge;
totvert = mesh->verts_num;
totedge = mesh->edges_num;
}
if ((mesh_topo_store->index_lookup == nullptr) ||
@ -187,7 +187,7 @@ void ED_mesh_mirrtopo_init(BMEditMesh *em,
totvert = em->bm->totvert;
}
else {
totvert = mesh->totvert;
totvert = mesh->verts_num;
}
MirrTopoHash_t *topo_hash = static_cast<MirrTopoHash_t *>(
@ -204,7 +204,7 @@ void ED_mesh_mirrtopo_init(BMEditMesh *em,
}
}
else {
totedge = mesh->totedge;
totedge = mesh->edges_num;
for (const blender::int2 &edge : mesh->edges()) {
topo_hash[edge[0]]++;
topo_hash[edge[1]]++;

View File

@ -105,11 +105,11 @@ static void join_mesh_single(Depsgraph *depsgraph,
int *corner_verts = *corner_verts_pp;
int *corner_edges = *corner_edges_pp;
if (mesh->totvert) {
if (mesh->verts_num) {
/* standard data */
CustomData_merge_layout(
&mesh->vert_data, vert_data, CD_MASK_MESH.vmask, CD_SET_DEFAULT, totvert);
CustomData_copy_data_named(&mesh->vert_data, vert_data, 0, *vertofs, mesh->totvert);
CustomData_copy_data_named(&mesh->vert_data, vert_data, 0, *vertofs, mesh->verts_num);
/* vertex groups */
MDeformVert *dvert = (MDeformVert *)CustomData_get_for_write(
@ -127,7 +127,7 @@ static void join_mesh_single(Depsgraph *depsgraph,
vgroup_index_map = BKE_object_defgroup_index_map_create(
ob_src, ob_dst, &vgroup_index_map_len);
BKE_object_defgroup_index_map_apply(
dvert, mesh->totvert, vgroup_index_map, vgroup_index_map_len);
dvert, mesh->verts_num, vgroup_index_map, vgroup_index_map_len);
if (vgroup_index_map != nullptr) {
MEM_freeN(vgroup_index_map);
}
@ -141,7 +141,7 @@ static void join_mesh_single(Depsgraph *depsgraph,
mul_m4_m4m4(cmat, imat, ob_src->object_to_world);
/* transform vertex coordinates into new space */
for (a = 0; a < mesh->totvert; a++) {
for (a = 0; a < mesh->verts_num; a++) {
mul_m4_v3(cmat, vert_positions[a]);
}
@ -163,14 +163,14 @@ static void join_mesh_single(Depsgraph *depsgraph,
/* copy this mesh's shape-key to the destination shape-key
* (need to transform first) */
float(*ocos)[3] = static_cast<float(*)[3]>(okb->data);
for (a = 0; a < mesh->totvert; a++, cos++, ocos++) {
for (a = 0; a < mesh->verts_num; a++, cos++, ocos++) {
copy_v3_v3(*cos, *ocos);
mul_m4_v3(cmat, *cos);
}
}
else {
/* Copy this mesh's vertex coordinates to the destination shape-key. */
for (a = 0; a < mesh->totvert; a++, cos++) {
for (a = 0; a < mesh->verts_num; a++, cos++) {
copy_v3_v3(*cos, vert_positions[a]);
}
}
@ -192,13 +192,13 @@ static void join_mesh_single(Depsgraph *depsgraph,
if (okb) {
/* copy this mesh's shape-key to the destination shape-key */
float(*ocos)[3] = static_cast<float(*)[3]>(okb->data);
for (a = 0; a < mesh->totvert; a++, cos++, ocos++) {
for (a = 0; a < mesh->verts_num; a++, cos++, ocos++) {
copy_v3_v3(*cos, *ocos);
}
}
else {
/* Copy base-coordinates to the destination shape-key. */
for (a = 0; a < mesh->totvert; a++, cos++) {
for (a = 0; a < mesh->verts_num; a++, cos++) {
copy_v3_v3(*cos, vert_positions[a]);
}
}
@ -207,17 +207,17 @@ static void join_mesh_single(Depsgraph *depsgraph,
}
}
if (mesh->totedge) {
if (mesh->edges_num) {
CustomData_merge_layout(
&mesh->edge_data, edge_data, CD_MASK_MESH.emask, CD_SET_DEFAULT, totedge);
CustomData_copy_data_named(&mesh->edge_data, edge_data, 0, *edgeofs, mesh->totedge);
CustomData_copy_data_named(&mesh->edge_data, edge_data, 0, *edgeofs, mesh->edges_num);
for (a = 0; a < mesh->totedge; a++, edge++) {
for (a = 0; a < mesh->edges_num; a++, edge++) {
(*edge) += *vertofs;
}
}
if (mesh->totloop) {
if (mesh->corners_num) {
if (ob_src != ob_dst) {
MultiresModifierData *mmd;
@ -230,9 +230,9 @@ static void join_mesh_single(Depsgraph *depsgraph,
}
CustomData_merge_layout(&mesh->loop_data, ldata, CD_MASK_MESH.lmask, CD_SET_DEFAULT, totloop);
CustomData_copy_data_named(&mesh->loop_data, ldata, 0, *loopofs, mesh->totloop);
CustomData_copy_data_named(&mesh->loop_data, ldata, 0, *loopofs, mesh->corners_num);
for (a = 0; a < mesh->totloop; a++) {
for (a = 0; a < mesh->corners_num; a++) {
corner_verts[a] += *vertofs;
corner_edges[a] += *edgeofs;
}
@ -279,13 +279,13 @@ static void join_mesh_single(Depsgraph *depsgraph,
}
/* these are used for relinking (cannot be set earlier, or else reattaching goes wrong) */
*vertofs += mesh->totvert;
*vert_positions_pp += mesh->totvert;
*edgeofs += mesh->totedge;
*medge_pp += mesh->totedge;
*loopofs += mesh->totloop;
*corner_verts_pp += mesh->totloop;
*corner_edges_pp += mesh->totloop;
*vertofs += mesh->verts_num;
*vert_positions_pp += mesh->verts_num;
*edgeofs += mesh->edges_num;
*medge_pp += mesh->edges_num;
*loopofs += mesh->corners_num;
*corner_verts_pp += mesh->corners_num;
*corner_edges_pp += mesh->corners_num;
*polyofs += mesh->faces_num;
}
@ -348,9 +348,9 @@ int ED_mesh_join_objects_exec(bContext *C, wmOperator *op)
if (ob_iter->type == OB_MESH) {
mesh = static_cast<Mesh *>(ob_iter->data);
totvert += mesh->totvert;
totedge += mesh->totedge;
totloop += mesh->totloop;
totvert += mesh->verts_num;
totedge += mesh->edges_num;
totloop += mesh->corners_num;
faces_num += mesh->faces_num;
totmat += ob_iter->totcol;
@ -388,7 +388,7 @@ int ED_mesh_join_objects_exec(bContext *C, wmOperator *op)
mesh = (Mesh *)ob->data;
key = mesh->key;
if (ELEM(totvert, 0, mesh->totvert)) {
if (ELEM(totvert, 0, mesh->verts_num)) {
BKE_report(op->reports, RPT_WARNING, "No mesh data to join");
return OPERATOR_CANCELLED;
}
@ -470,7 +470,7 @@ int ED_mesh_join_objects_exec(bContext *C, wmOperator *op)
mesh_join_offset_face_sets_ID(mesh, &face_set_id_offset);
if (mesh->totvert) {
if (mesh->verts_num) {
/* Add this object's materials to the base one's if they don't exist already
* (but only if limits not exceeded yet) */
if (totcol < MAXMAT) {
@ -657,9 +657,9 @@ int ED_mesh_join_objects_exec(bContext *C, wmOperator *op)
face_offsets);
}
mesh->totvert = totvert;
mesh->totedge = totedge;
mesh->totloop = totloop;
mesh->verts_num = totvert;
mesh->edges_num = totedge;
mesh->corners_num = totloop;
mesh->faces_num = faces_num;
mesh->vert_data = vert_data;
@ -748,7 +748,7 @@ int ED_mesh_shapes_join_objects_exec(bContext *C, wmOperator *op)
if (ob_iter->type == OB_MESH) {
selme = (Mesh *)ob_iter->data;
if (selme->totvert == mesh->totvert) {
if (selme->verts_num == mesh->verts_num) {
ok = true;
}
else {
@ -788,7 +788,7 @@ int ED_mesh_shapes_join_objects_exec(bContext *C, wmOperator *op)
if (ob_iter->type == OB_MESH) {
selme = (Mesh *)ob_iter->data;
if (selme->totvert == mesh->totvert) {
if (selme->verts_num == mesh->verts_num) {
Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob_iter);
@ -1106,7 +1106,7 @@ int *mesh_get_x_mirror_faces(Object *ob, BMEditMesh *em, Mesh *me_eval)
BLI_assert(em == nullptr); /* Does not work otherwise, currently... */
const bool use_topology = (mesh->editflag & ME_EDIT_MIRROR_TOPO) != 0;
const int totvert = me_eval ? me_eval->totvert : mesh->totvert;
const int totvert = me_eval ? me_eval->verts_num : mesh->verts_num;
const int totface = me_eval ? me_eval->totface_legacy : mesh->totface_legacy;
int a;
@ -1286,7 +1286,7 @@ bool ED_mesh_pick_face_vert(
}
}
if ((v_idx_best != ORIGINDEX_NONE) && (v_idx_best < mesh->totvert)) {
if ((v_idx_best != ORIGINDEX_NONE) && (v_idx_best < mesh->verts_num)) {
*r_index = v_idx_best;
return true;
}
@ -1339,7 +1339,7 @@ bool ED_mesh_pick_vert(
BLI_assert(mesh && GS(mesh->id.name) == ID_ME);
if (!mesh || mesh->totvert == 0) {
if (!mesh || mesh->verts_num == 0) {
return false;
}
@ -1352,14 +1352,14 @@ bool ED_mesh_pick_vert(
/* Sample rectangle to increase chances of selecting, so that when clicking
* on an face in the back-buffer, we can still select a vert. */
*r_index = DRW_select_buffer_find_nearest_to_point(
vc.depsgraph, vc.region, vc.v3d, mval, 1, mesh->totvert + 1, &dist_px);
vc.depsgraph, vc.region, vc.v3d, mval, 1, mesh->verts_num + 1, &dist_px);
}
else {
/* sample only on the exact position */
*r_index = DRW_select_buffer_sample_point(vc.depsgraph, vc.region, vc.v3d, mval);
}
if ((*r_index) == 0 || (*r_index) > uint(mesh->totvert)) {
if ((*r_index) == 0 || (*r_index) > uint(mesh->verts_num)) {
return false;
}

View File

@ -1013,7 +1013,7 @@ static bool bake_targets_init_vertex_colors(Main *bmain,
targets->materials_num = ob->totcol;
BakeImage *bk_image = &targets->images[0];
bk_image->width = mesh->totloop;
bk_image->width = mesh->corners_num;
bk_image->height = 1;
bk_image->offset = 0;
bk_image->image = nullptr;
@ -1075,7 +1075,7 @@ static void bake_targets_populate_pixels_color_attributes(BakeTargets *targets,
}
/* Populate through adjacent triangles, first triangle wins. */
const int corner_tris_num = poly_to_tri_count(me_eval->faces_num, me_eval->totloop);
const int corner_tris_num = poly_to_tri_count(me_eval->faces_num, me_eval->corners_num);
blender::int3 *corner_tris = static_cast<blender::int3 *>(
MEM_mallocN(sizeof(*corner_tris) * corner_tris_num, __func__));
@ -1104,7 +1104,7 @@ static void bake_targets_populate_pixels_color_attributes(BakeTargets *targets,
if (vert_origindex != nullptr && poly_origindex != nullptr) {
l = find_original_loop(
orig_faces, orig_corner_verts, vert_origindex, poly_origindex, face_i, v);
if (l == ORIGINDEX_NONE || l >= mesh->totloop) {
if (l == ORIGINDEX_NONE || l >= mesh->corners_num) {
continue;
}
}
@ -1189,16 +1189,16 @@ static bool bake_targets_output_vertex_colors(BakeTargets *targets, Object *ob)
const float *result = targets->result;
if (domain == ATTR_DOMAIN_POINT) {
const int totvert = mesh->totvert;
const int totloop = mesh->totloop;
const int totvert = mesh->verts_num;
const int totloop = mesh->corners_num;
MPropCol *mcol = static_cast<MPropCol *>(
MEM_malloc_arrayN(totvert, sizeof(MPropCol), __func__));
/* Accumulate float vertex colors in scene linear color space. */
int *num_loops_for_vertex = static_cast<int *>(
MEM_callocN(sizeof(int) * mesh->totvert, "num_loops_for_vertex"));
memset(mcol, 0, sizeof(MPropCol) * mesh->totvert);
MEM_callocN(sizeof(int) * mesh->verts_num, "num_loops_for_vertex"));
memset(mcol, 0, sizeof(MPropCol) * mesh->verts_num);
const blender::Span<int> corner_verts = mesh->corner_verts();
for (int i = 0; i < totloop; i++) {
@ -1236,7 +1236,7 @@ static bool bake_targets_output_vertex_colors(BakeTargets *targets, Object *ob)
else {
/* Copy to mesh. */
if (active_color_layer->type == CD_PROP_COLOR) {
memcpy(active_color_layer->data, mcol, sizeof(MPropCol) * mesh->totvert);
memcpy(active_color_layer->data, mcol, sizeof(MPropCol) * mesh->verts_num);
}
else {
convert_float_color_to_byte_color(
@ -1280,14 +1280,14 @@ static bool bake_targets_output_vertex_colors(BakeTargets *targets, Object *ob)
/* Copy to mesh. */
if (active_color_layer->type == CD_PROP_COLOR) {
MPropCol *colors = static_cast<MPropCol *>(active_color_layer->data);
for (int i = 0; i < mesh->totloop; i++) {
for (int i = 0; i < mesh->corners_num; i++) {
zero_v4(colors[i].color);
bake_result_add_to_rgba(colors[i].color, &result[i * channels_num], channels_num);
}
}
else {
MLoopCol *colors = static_cast<MLoopCol *>(active_color_layer->data);
for (int i = 0; i < mesh->totloop; i++) {
for (int i = 0; i < mesh->corners_num; i++) {
MPropCol color;
zero_v4(color.color);
bake_result_add_to_rgba(color.color, &result[i * channels_num], channels_num);
@ -1512,7 +1512,7 @@ static int bake(const BakeAPIRender *bkr,
if (ob_cage) {
me_cage_eval = bake_mesh_new_from_object(depsgraph, ob_cage_eval, preserve_origindex);
if ((me_low_eval->faces_num != me_cage_eval->faces_num) ||
(me_low_eval->totloop != me_cage_eval->totloop))
(me_low_eval->corners_num != me_cage_eval->corners_num))
{
BKE_report(reports,
RPT_ERROR,

View File

@ -342,11 +342,11 @@ XFormObjectData *ED_object_data_xform_create_ex(ID *id, bool is_edit_mode)
}
}
else {
const int elem_array_len = mesh->totvert;
const int elem_array_len = mesh->verts_num;
XFormObjectData_Mesh *xod = static_cast<XFormObjectData_Mesh *>(
MEM_mallocN(sizeof(*xod) + (sizeof(*xod->elem_array) * elem_array_len), __func__));
memset(xod, 0x0, sizeof(*xod));
blender::MutableSpan(reinterpret_cast<blender::float3 *>(xod->elem_array), mesh->totvert)
blender::MutableSpan(reinterpret_cast<blender::float3 *>(xod->elem_array), mesh->verts_num)
.copy_from(mesh->vert_positions());
xod_base = &xod->base;
@ -660,7 +660,7 @@ void ED_object_data_xform_restore(XFormObjectData *xod_base)
}
else {
mesh->vert_positions_for_write().copy_from(
{reinterpret_cast<const blender::float3 *>(xod->elem_array), mesh->totvert});
{reinterpret_cast<const blender::float3 *>(xod->elem_array), mesh->verts_num});
mesh->tag_positions_changed();
}

View File

@ -654,13 +654,13 @@ bool ED_object_modifier_convert_psys_to_mesh(ReportList * /*reports*/,
Object *obn = BKE_object_add(bmain, scene, view_layer, OB_MESH, nullptr);
Mesh *mesh = static_cast<Mesh *>(obn->data);
mesh->totvert = verts_num;
mesh->totedge = edges_num;
mesh->verts_num = verts_num;
mesh->edges_num = edges_num;
CustomData_add_layer_named(
&mesh->vert_data, CD_PROP_FLOAT3, CD_CONSTRUCT, verts_num, "position");
CustomData_add_layer_named(
&mesh->edge_data, CD_PROP_INT32_2D, CD_CONSTRUCT, mesh->totedge, ".edge_verts");
&mesh->edge_data, CD_PROP_INT32_2D, CD_CONSTRUCT, mesh->edges_num, ".edge_verts");
CustomData_add_layer(&mesh->fdata_legacy, CD_MFACE, CD_SET_DEFAULT, 0);
blender::MutableSpan<float3> positions = mesh->vert_positions_for_write();
@ -723,22 +723,22 @@ static void add_shapekey_layers(Mesh &mesh_dest, const Mesh &mesh_src)
int i;
LISTBASE_FOREACH_INDEX (const KeyBlock *, kb, &mesh_src.key->block, i) {
void *array;
if (mesh_src.totvert != kb->totelem) {
if (mesh_src.verts_num != kb->totelem) {
CLOG_ERROR(&LOG,
"vertex size mismatch (Mesh '%s':%d != KeyBlock '%s':%d)",
mesh_src.id.name + 2,
mesh_src.totvert,
mesh_src.verts_num,
kb->name,
kb->totelem);
array = MEM_calloc_arrayN(size_t(mesh_src.totvert), sizeof(float[3]), __func__);
array = MEM_calloc_arrayN(size_t(mesh_src.verts_num), sizeof(float[3]), __func__);
}
else {
array = MEM_malloc_arrayN(size_t(mesh_src.totvert), sizeof(float[3]), __func__);
memcpy(array, kb->data, sizeof(float[3]) * size_t(mesh_src.totvert));
array = MEM_malloc_arrayN(size_t(mesh_src.verts_num), sizeof(float[3]), __func__);
memcpy(array, kb->data, sizeof(float[3]) * size_t(mesh_src.verts_num));
}
CustomData_add_layer_named_with_data(
&mesh_dest.vert_data, CD_SHAPEKEY, array, mesh_dest.totvert, kb->name, nullptr);
&mesh_dest.vert_data, CD_SHAPEKEY, array, mesh_dest.verts_num, kb->name, nullptr);
const int ci = CustomData_get_layer_index_n(&mesh_dest.vert_data, CD_SHAPEKEY, i);
mesh_dest.vert_data.layers[ci].uid = kb->uid;
@ -779,7 +779,7 @@ static Mesh *create_applied_mesh_for_modifier(Depsgraph *depsgraph,
BKE_keyblock_convert_to_mesh(
kb,
reinterpret_cast<float(*)[3]>(mesh->vert_positions_for_write().data()),
mesh->totvert);
mesh->verts_num);
}
}
@ -2426,8 +2426,8 @@ static int multires_external_save_exec(bContext *C, wmOperator *op)
BLI_path_rel(filepath, BKE_main_blendfile_path(bmain));
}
CustomData_external_add(&mesh->loop_data, &mesh->id, CD_MDISPS, mesh->totloop, filepath);
CustomData_external_write(&mesh->loop_data, &mesh->id, CD_MASK_MESH.lmask, mesh->totloop, 0);
CustomData_external_add(&mesh->loop_data, &mesh->id, CD_MDISPS, mesh->corners_num, filepath);
CustomData_external_write(&mesh->loop_data, &mesh->id, CD_MASK_MESH.lmask, mesh->corners_num, 0);
return OPERATOR_FINISHED;
}
@ -2507,7 +2507,7 @@ static int multires_external_pack_exec(bContext *C, wmOperator * /*op*/)
}
/* XXX don't remove. */
CustomData_external_remove(&mesh->loop_data, &mesh->id, CD_MDISPS, mesh->totloop);
CustomData_external_remove(&mesh->loop_data, &mesh->id, CD_MDISPS, mesh->corners_num);
return OPERATOR_FINISHED;
}
@ -2699,7 +2699,7 @@ static void modifier_skin_customdata_delete(Object *ob)
BM_data_layer_free(em->bm, &em->bm->vdata, CD_MVERT_SKIN);
}
else {
CustomData_free_layer_active(&mesh->vert_data, CD_MVERT_SKIN, mesh->totvert);
CustomData_free_layer_active(&mesh->vert_data, CD_MVERT_SKIN, mesh->verts_num);
}
}
@ -2943,7 +2943,7 @@ static Object *modifier_skin_armature_create(Depsgraph *depsgraph, Main *bmain,
const Span<float3> positions_eval = me_eval_deform->vert_positions();
/* add vertex weights to original mesh */
CustomData_add_layer(&mesh->vert_data, CD_MDEFORMVERT, CD_SET_DEFAULT, mesh->totvert);
CustomData_add_layer(&mesh->vert_data, CD_MDEFORMVERT, CD_SET_DEFAULT, mesh->verts_num);
Scene *scene = DEG_get_input_scene(depsgraph);
ViewLayer *view_layer = DEG_get_input_view_layer(depsgraph);
@ -2956,18 +2956,18 @@ static Object *modifier_skin_armature_create(Depsgraph *depsgraph, Main *bmain,
arm->edbo = MEM_cnew<ListBase>("edbo armature");
MVertSkin *mvert_skin = static_cast<MVertSkin *>(
CustomData_get_layer_for_write(&mesh->vert_data, CD_MVERT_SKIN, mesh->totvert));
CustomData_get_layer_for_write(&mesh->vert_data, CD_MVERT_SKIN, mesh->verts_num));
blender::Array<int> vert_to_edge_offsets;
blender::Array<int> vert_to_edge_indices;
const blender::GroupedSpan<int> emap = blender::bke::mesh::build_vert_to_edge_map(
me_edges, mesh->totvert, vert_to_edge_offsets, vert_to_edge_indices);
me_edges, mesh->verts_num, vert_to_edge_offsets, vert_to_edge_indices);
BLI_bitmap *edges_visited = BLI_BITMAP_NEW(mesh->totedge, "edge_visited");
BLI_bitmap *edges_visited = BLI_BITMAP_NEW(mesh->edges_num, "edge_visited");
/* NOTE: we use EditBones here, easier to set them up and use
* edit-armature functions to convert back to regular bones */
for (int v = 0; v < mesh->totvert; v++) {
for (int v = 0; v < mesh->verts_num; v++) {
if (mvert_skin[v].flag & MVERT_SKIN_ROOT) {
EditBone *bone = nullptr;

View File

@ -679,11 +679,11 @@ static bool mesh_is_manifold_consistent(Mesh *mesh)
const Span<int> corner_edges = mesh->corner_edges();
bool is_manifold_consistent = true;
char *edge_faces = (char *)MEM_callocN(mesh->totedge * sizeof(char), "remesh_manifold_check");
char *edge_faces = (char *)MEM_callocN(mesh->edges_num * sizeof(char), "remesh_manifold_check");
int *edge_vert = (int *)MEM_malloc_arrayN(
mesh->totedge, sizeof(uint), "remesh_consistent_check");
mesh->edges_num, sizeof(uint), "remesh_consistent_check");
for (uint i = 0; i < mesh->totedge; i++) {
for (uint i = 0; i < mesh->edges_num; i++) {
edge_vert[i] = -1;
}

View File

@ -122,7 +122,7 @@ static bool object_shape_key_mirror(
ED_mesh_mirror_spatial_table_begin(ob, nullptr, nullptr);
for (i1 = 0; i1 < mesh->totvert; i1++) {
for (i1 = 0; i1 < mesh->verts_num; i1++) {
i2 = mesh_get_x_mirror_vert(ob, nullptr, i1, use_topology);
if (i2 == i1) {
fp1 = ((float *)kb->data) + i1 * 3;

View File

@ -205,21 +205,21 @@ bool ED_vgroup_parray_alloc(ID *id,
if (!mesh->deform_verts().is_empty()) {
MutableSpan<MDeformVert> dverts = mesh->deform_verts_for_write();
*dvert_tot = mesh->totvert;
*dvert_tot = mesh->verts_num;
*dvert_arr = static_cast<MDeformVert **>(
MEM_mallocN(sizeof(void *) * mesh->totvert, __func__));
MEM_mallocN(sizeof(void *) * mesh->verts_num, __func__));
if (use_vert_sel) {
const bke::AttributeAccessor attributes = mesh->attributes();
const VArray<bool> select_vert = *attributes.lookup_or_default<bool>(
".select_vert", ATTR_DOMAIN_POINT, false);
for (int i = 0; i < mesh->totvert; i++) {
for (int i = 0; i < mesh->verts_num; i++) {
(*dvert_arr)[i] = select_vert[i] ? &dverts[i] : nullptr;
}
}
else {
for (int i = 0; i < mesh->totvert; i++) {
for (int i = 0; i < mesh->verts_num; i++) {
(*dvert_arr)[i] = &dverts[i];
}
}
@ -683,7 +683,7 @@ static void vgroup_copy_active_to_sel(Object *ob, eVGroupSelect subset_type)
dvert_act = ED_mesh_active_dvert_get_ob(ob, &v_act);
if (dvert_act) {
MutableSpan<MDeformVert> dverts = mesh->deform_verts_for_write();
for (i = 0; i < mesh->totvert; i++) {
for (i = 0; i < mesh->verts_num; i++) {
if (select_vert[i] && &dverts[i] != dvert_act) {
BKE_defvert_copy_subset(&dverts[i], dvert_act, vgroup_validmap, vgroup_tot);
if (mesh->symmetry & ME_SYMMETRY_X) {
@ -963,7 +963,7 @@ static float get_vert_def_nr(Object *ob, const int def_nr, const int vertnum)
else {
const Span<MDeformVert> dverts = mesh->deform_verts();
if (!dverts.is_empty()) {
if (vertnum >= mesh->totvert) {
if (vertnum >= mesh->verts_num) {
return 0.0f;
}
dv = &dverts[vertnum];
@ -1584,7 +1584,7 @@ static void vgroup_smooth_subset(Object *ob,
}
else {
emap = blender::bke::mesh::build_vert_to_edge_map(
mesh->edges(), mesh->totvert, vert_to_edge_offsets, vert_to_edge_indices);
mesh->edges(), mesh->verts_num, vert_to_edge_offsets, vert_to_edge_indices);
}
weight_accum_prev = static_cast<float *>(
@ -2104,13 +2104,13 @@ void ED_vgroup_mirror(Object *ob,
goto cleanup;
}
BLI_bitmap *vert_tag = BLI_BITMAP_NEW(mesh->totvert, __func__);
BLI_bitmap *vert_tag = BLI_BITMAP_NEW(mesh->verts_num, __func__);
MutableSpan<MDeformVert> dverts = mesh->deform_verts_for_write();
const bke::AttributeAccessor attributes = mesh->attributes();
const VArray<bool> select_vert = *attributes.lookup_or_default<bool>(
".select_vert", ATTR_DOMAIN_POINT, false);
for (int vidx = 0; vidx < mesh->totvert; vidx++) {
for (int vidx = 0; vidx < mesh->verts_num; vidx++) {
if (!BLI_BITMAP_TEST(vert_tag, vidx)) {
int vidx_mirr;
if ((vidx_mirr = mesh_get_x_mirror_vert(ob, nullptr, vidx, use_topology)) != -1) {
@ -2272,7 +2272,7 @@ static void vgroup_assign_verts(Object *ob, const float weight)
MutableSpan<MDeformVert> dverts = mesh->deform_verts_for_write();
for (int i = 0; i < mesh->totvert; i++) {
for (int i = 0; i < mesh->verts_num; i++) {
if (select_vert[i]) {
MDeformWeight *dw;
dw = BKE_defvert_ensure_index(&dverts[i], def_nr);
@ -3927,7 +3927,7 @@ static void vgroup_copy_active_to_sel_single(Object *ob, const int def_nr)
const VArray<bool> select_vert = *attributes.lookup_or_default<bool>(
".select_vert", ATTR_DOMAIN_POINT, false);
for (i = 0; i < mesh->totvert; i++) {
for (i = 0; i < mesh->verts_num; i++) {
if (select_vert[i] && (&dverts[i] != dvert_act)) {
BKE_defvert_copy_index(&dverts[i], def_nr, dvert_act, def_nr);

View File

@ -749,7 +749,7 @@ static bool remap_hair_emitter(Depsgraph *depsgraph,
/* BMESH_ONLY, deform dm may not have tessface */
BKE_mesh_tessface_ensure(mesh);
numverts = mesh->totvert;
numverts = mesh->verts_num;
blender::MutableSpan<blender::float3> positions = mesh->vert_positions_for_write();
/* convert to global coordinates */
@ -761,7 +761,7 @@ static bool remap_hair_emitter(Depsgraph *depsgraph,
mface = static_cast<const MFace *>(CustomData_get_layer(&mesh->fdata_legacy, CD_MFACE));
BKE_bvhtree_from_mesh_get(&bvhtree, mesh, BVHTREE_FROM_FACES, 2);
}
else if (mesh->totedge != 0) {
else if (mesh->edges_num != 0) {
edges = static_cast<const vec2i *>(
CustomData_get_layer_named(&mesh->edge_data, CD_PROP_INT32_2D, ".edge_verts"));
BKE_bvhtree_from_mesh_get(&bvhtree, mesh, BVHTREE_FROM_EDGES, 2);

View File

@ -4103,9 +4103,9 @@ static bool proj_paint_state_mesh_eval_init(const bContext *C, ProjPaintState *p
ps->sharp_faces_eval = static_cast<const bool *>(
CustomData_get_layer_named(&ps->me_eval->face_data, CD_PROP_BOOL, "sharp_face"));
ps->totvert_eval = ps->me_eval->totvert;
ps->totvert_eval = ps->me_eval->verts_num;
ps->faces_num_eval = ps->me_eval->faces_num;
ps->totloop_eval = ps->me_eval->totloop;
ps->totloop_eval = ps->me_eval->corners_num;
ps->corner_tris_eval = ps->me_eval->corner_tris();
ps->corner_tri_faces_eval = ps->me_eval->corner_tri_faces();

View File

@ -1775,7 +1775,7 @@ static void sculpt_gesture_trim_apply_for_symmetry_pass(bContext * /*C*/,
SculptGestureTrimOperation *trim_operation = (SculptGestureTrimOperation *)sgcontext->operation;
Mesh *trim_mesh = trim_operation->mesh;
MutableSpan<float3> positions = trim_mesh->vert_positions_for_write();
for (int i = 0; i < trim_mesh->totvert; i++) {
for (int i = 0; i < trim_mesh->verts_num; i++) {
flip_v3_v3(positions[i], trim_operation->true_mesh_co[i], sgcontext->symmpass);
}
sculpt_gesture_trim_normals_update(sgcontext);

View File

@ -249,14 +249,14 @@ void init_session_data(const ToolSettings *ts, Object *ob)
if (ob->mode == OB_MODE_WEIGHT_PAINT) {
if (!vwpaint::brush_use_accumulate(ts->wpaint)) {
if (ob->sculpt->mode.wpaint.alpha_weight == nullptr) {
ob->sculpt->mode.wpaint.alpha_weight = (float *)MEM_callocN(mesh->totvert * sizeof(float),
__func__);
ob->sculpt->mode.wpaint.alpha_weight = (float *)MEM_callocN(
mesh->verts_num * sizeof(float), __func__);
}
if (ob->sculpt->mode.wpaint.dvert_prev == nullptr) {
ob->sculpt->mode.wpaint.dvert_prev = (MDeformVert *)MEM_callocN(
mesh->totvert * sizeof(MDeformVert), __func__);
mesh->verts_num * sizeof(MDeformVert), __func__);
MDeformVert *dv = ob->sculpt->mode.wpaint.dvert_prev;
for (int i = 0; i < mesh->totvert; i++, dv++) {
for (int i = 0; i < mesh->verts_num; i++, dv++) {
/* Use to show this isn't initialized, never apply to the mesh data. */
dv->flag = 1;
}
@ -265,7 +265,7 @@ void init_session_data(const ToolSettings *ts, Object *ob)
else {
MEM_SAFE_FREE(ob->sculpt->mode.wpaint.alpha_weight);
if (ob->sculpt->mode.wpaint.dvert_prev != nullptr) {
BKE_defvert_array_free_elems(ob->sculpt->mode.wpaint.dvert_prev, mesh->totvert);
BKE_defvert_array_free_elems(ob->sculpt->mode.wpaint.dvert_prev, mesh->verts_num);
MEM_freeN(ob->sculpt->mode.wpaint.dvert_prev);
ob->sculpt->mode.wpaint.dvert_prev = nullptr;
}

Some files were not shown because too many files have changed in this diff Show More