Cleanup: consistent naming for EditMesh::looptris elements

Use the term `ltri` everywhere.
This commit is contained in:
Campbell Barton 2024-03-27 10:09:12 +11:00
parent 2220696d25
commit 3f594f7b2f
5 changed files with 41 additions and 40 deletions

View File

@ -520,15 +520,15 @@ static bool bmbvh_overlap_cb(void *userdata, int index_a, int index_b, int /*thr
const BMBVHTree *bmtree_a = data->tree_pair[0];
const BMBVHTree *bmtree_b = data->tree_pair[1];
const std::array<BMLoop *, 3> &tri_a = bmtree_a->looptris[index_a];
const std::array<BMLoop *, 3> &tri_b = bmtree_b->looptris[index_b];
const float *tri_a_co[3] = {tri_a[0]->v->co, tri_a[1]->v->co, tri_a[2]->v->co};
const float *tri_b_co[3] = {tri_b[0]->v->co, tri_b[1]->v->co, tri_b[2]->v->co};
const std::array<BMLoop *, 3> &ltri_a = bmtree_a->looptris[index_a];
const std::array<BMLoop *, 3> &ltri_b = bmtree_b->looptris[index_b];
const float *tri_a_co[3] = {ltri_a[0]->v->co, ltri_a[1]->v->co, ltri_a[2]->v->co};
const float *tri_b_co[3] = {ltri_b[0]->v->co, ltri_b[1]->v->co, ltri_b[2]->v->co};
float ix_pair[2][3];
int verts_shared = 0;
if (bmtree_a->looptris == bmtree_b->looptris) {
if (UNLIKELY(tri_a[0]->f == tri_b[0]->f)) {
if (UNLIKELY(ltri_a[0]->f == ltri_b[0]->f)) {
return false;
}

View File

@ -59,14 +59,14 @@ struct SGLSLEditMeshToTangent {
const BMLoop *GetLoop(const uint face_num, uint vert_index)
{
// BLI_assert(vert_index >= 0 && vert_index < 4);
BMLoop *const *lt;
BMLoop *const *ltri;
const BMLoop *l;
#ifdef USE_LOOPTRI_DETECT_QUADS
if (face_as_quad_map) {
lt = looptris[face_as_quad_map[face_num]].data();
if (lt[0]->f->len == 4) {
l = BM_FACE_FIRST_LOOP(lt[0]->f);
ltri = looptris[face_as_quad_map[face_num]].data();
if (ltri[0]->f->len == 4) {
l = BM_FACE_FIRST_LOOP(ltri[0]->f);
while (vert_index--) {
l = l->next;
}
@ -75,12 +75,12 @@ struct SGLSLEditMeshToTangent {
/* fall through to regular triangle */
}
else {
lt = looptris[face_num].data();
ltri = looptris[face_num].data();
}
#else
lt = looptris[face_num].data();
ltri = looptris[face_num].data();
#endif
return lt[vert_index];
return ltri[vert_index];
}
mikk::float3 GetPosition(const uint face_num, const uint vert_index)

View File

@ -159,11 +159,11 @@ void BM_face_calc_tessellation(const BMFace *f,
void BM_face_calc_point_in_face(const BMFace *f, float r_co[3])
{
const BMLoop *l_tri[3];
const BMLoop *ltri[3];
if (f->len == 3) {
const BMLoop *l = BM_FACE_FIRST_LOOP(f);
ARRAY_SET_ITEMS(l_tri, l, l->next, l->prev);
ARRAY_SET_ITEMS(ltri, l, l->next, l->prev);
}
else {
/* tessellation here seems overkill when in many cases this will be the center,
@ -189,10 +189,10 @@ void BM_face_calc_point_in_face(const BMFace *f, float r_co[3])
}
ARRAY_SET_ITEMS(
l_tri, loops[index[j_best][0]], loops[index[j_best][1]], loops[index[j_best][2]]);
ltri, loops[index[j_best][0]], loops[index[j_best][1]], loops[index[j_best][2]]);
}
mid_v3_v3v3v3(r_co, l_tri[0]->v->co, l_tri[1]->v->co, l_tri[2]->v->co);
mid_v3_v3v3v3(r_co, ltri[0]->v->co, ltri[1]->v->co, ltri[2]->v->co);
}
float BM_face_calc_area(const BMFace *f)
@ -1091,9 +1091,9 @@ void BM_face_triangulate(BMesh *bm,
/* loop over calculated triangles and create new geometry */
for (i = 0; i < totfilltri; i++) {
BMLoop *l_tri[3] = {loops[tris[i][0]], loops[tris[i][1]], loops[tris[i][2]]};
BMLoop *ltri[3] = {loops[tris[i][0]], loops[tris[i][1]], loops[tris[i][2]]};
BMVert *v_tri[3] = {l_tri[0]->v, l_tri[1]->v, l_tri[2]->v};
BMVert *v_tri[3] = {ltri[0]->v, ltri[1]->v, ltri[2]->v};
f_new = BM_face_create_verts(bm, v_tri, 3, f, BM_CREATE_NOP, true);
l_new = BM_FACE_FIRST_LOOP(f_new);
@ -1113,9 +1113,9 @@ void BM_face_triangulate(BMesh *bm,
}
/* copy CD data */
BM_elem_attrs_copy(bm, l_tri[0], l_new);
BM_elem_attrs_copy(bm, l_tri[1], l_new->next);
BM_elem_attrs_copy(bm, l_tri[2], l_new->prev);
BM_elem_attrs_copy(bm, ltri[0], l_new);
BM_elem_attrs_copy(bm, ltri[1], l_new->next);
BM_elem_attrs_copy(bm, ltri[2], l_new->prev);
/* add all but the last face which is swapped and removed (below) */
if (i != last_tri) {

View File

@ -458,18 +458,18 @@ void DRW_text_edit_mesh_measure_stats(ARegion *region,
n = 0;
area = 0;
zero_v3(vmid);
const std::array<BMLoop *, 3> *l = &em->looptris[tri_index];
const std::array<BMLoop *, 3> *ltri_array = &em->looptris[tri_index];
for (int j = 0; j < f_corner_tris_len; j++) {
if (use_coords) {
copy_v3_v3(v1, vert_coords[BM_elem_index_get(l[j][0]->v)]);
copy_v3_v3(v2, vert_coords[BM_elem_index_get(l[j][1]->v)]);
copy_v3_v3(v3, vert_coords[BM_elem_index_get(l[j][2]->v)]);
copy_v3_v3(v1, vert_coords[BM_elem_index_get(ltri_array[j][0]->v)]);
copy_v3_v3(v2, vert_coords[BM_elem_index_get(ltri_array[j][1]->v)]);
copy_v3_v3(v3, vert_coords[BM_elem_index_get(ltri_array[j][2]->v)]);
}
else {
copy_v3_v3(v1, l[j][0]->v->co);
copy_v3_v3(v2, l[j][1]->v->co);
copy_v3_v3(v3, l[j][2]->v->co);
copy_v3_v3(v1, ltri_array[j][0]->v->co);
copy_v3_v3(v2, ltri_array[j][1]->v->co);
copy_v3_v3(v3, ltri_array[j][2]->v->co);
}
add_v3_v3(vmid, v1);

View File

@ -1166,8 +1166,9 @@ static const int *knife_bm_tri_index_get(const KnifeTool_OpData *kcd,
if (obinfo->tri_indices) {
return obinfo->tri_indices[tri_index];
}
const std::array<BMLoop *, 3> &ltri = obinfo->em->looptris[tri_index];
for (int i = 0; i < 3; i++) {
tri_index_buf[i] = BM_elem_index_get(obinfo->em->looptris[tri_index][i]->v);
tri_index_buf[i] = BM_elem_index_get(ltri[i]->v);
}
return tri_index_buf;
}
@ -2519,8 +2520,8 @@ static bool knife_ray_intersect_face(KnifeTool_OpData *kcd,
float tri_cos[3][3];
float ray_tri_uv[2];
const std::array<BMLoop *, 3> &tri = em->looptris[tri_i];
if (tri[0]->f != f) {
const std::array<BMLoop *, 3> &ltri = em->looptris[tri_i];
if (ltri[0]->f != f) {
break;
}
@ -2555,7 +2556,7 @@ static bool knife_ray_intersect_face(KnifeTool_OpData *kcd,
return false;
}
}
interp_v3_v3v3v3_uv(hit_co, tri[0]->v->co, tri[1]->v->co, tri[2]->v->co, ray_tri_uv);
interp_v3_v3v3v3_uv(hit_co, ltri[0]->v->co, ltri[1]->v->co, ltri[2]->v->co, ray_tri_uv);
return true;
}
}
@ -2901,18 +2902,18 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd)
for (i = 0, result = results; i < tot; i++, result++) {
uint ob_index = 0;
BMLoop *const *ls = nullptr;
BMLoop *const *ltri = nullptr;
for (ob_index = 0; ob_index < kcd->objects.size(); ob_index++) {
ob = kcd->objects[ob_index];
em = BKE_editmesh_from_object(ob);
if (*result >= 0 && *result < em->looptris.size()) {
ls = em->looptris[*result].data();
ltri = em->looptris[*result].data();
break;
}
*result -= em->looptris.size();
}
BLI_assert(ls != nullptr);
BMFace *f = ls[0]->f;
BLI_assert(ltri != nullptr);
BMFace *f = ltri[0]->f;
set_lowest_face_tri(kcd, em, f, *result);
/* Occlude but never cut unselected faces (when only_select is used). */
@ -3960,10 +3961,10 @@ static void knifetool_init_obinfo(KnifeTool_OpData *kcd,
int(*tri_indices)[3] = static_cast<int(*)[3]>(
MEM_mallocN(sizeof(int[3]) * em_eval->looptris.size(), __func__));
for (int i = 0; i < em_eval->looptris.size(); i++) {
const std::array<BMLoop *, 3> &tri = em_eval->looptris[i];
tri_indices[i][0] = BM_elem_index_get(tri[0]->v);
tri_indices[i][1] = BM_elem_index_get(tri[1]->v);
tri_indices[i][2] = BM_elem_index_get(tri[2]->v);
const std::array<BMLoop *, 3> &ltri = em_eval->looptris[i];
tri_indices[i][0] = BM_elem_index_get(ltri[0]->v);
tri_indices[i][1] = BM_elem_index_get(ltri[1]->v);
tri_indices[i][2] = BM_elem_index_get(ltri[2]->v);
}
obinfo->tri_indices = tri_indices;
}