Cleanup: clarify naming for BMesh tangent calculation functions

The newly added "tangent_pair" calculation functions meant the names
didn't read well in some cases, use this style of naming for clarity:

- BM_face_calc_tangent_from_*
- BM_face_calc_tangent_pair_from_*
This commit is contained in:
Campbell Barton
2025-01-17 15:28:32 +11:00
parent c7104f5392
commit 8d97330482
4 changed files with 32 additions and 28 deletions

View File

@@ -325,7 +325,7 @@ static int bm_vert_tri_find_unique_edge(BMVert *verts[3])
return order[0];
}
void BM_vert_tri_calc_tangent_edge(BMVert *verts[3], float r_tangent[3])
void BM_vert_tri_calc_tangent_from_edge(BMVert *verts[3], float r_tangent[3])
{
const int index = bm_vert_tri_find_unique_edge(verts);
const int index_next = (index + 1) % 3;
@@ -334,9 +334,9 @@ void BM_vert_tri_calc_tangent_edge(BMVert *verts[3], float r_tangent[3])
normalize_v3(r_tangent);
}
void BM_vert_tri_calc_tangent_pair_edge(BMVert *verts[3],
float r_tangent_a[3],
float r_tangent_b[3])
void BM_vert_tri_calc_tangent_pair_from_edge(BMVert *verts[3],
float r_tangent_a[3],
float r_tangent_b[3])
{
const int index = bm_vert_tri_find_unique_edge(verts);
const int index_next = (index + 1) % 3;
@@ -373,7 +373,7 @@ void BM_vert_tri_calc_tangent_edge_pair(BMVert *verts[3], float r_tangent[3])
normalize_v3(r_tangent);
}
void BM_face_calc_tangent_edge(const BMFace *f, float r_tangent[3])
void BM_face_calc_tangent_from_edge(const BMFace *f, float r_tangent[3])
{
const BMLoop *l_long = BM_face_find_longest_loop((BMFace *)f);
@@ -427,7 +427,9 @@ static void bm_face_calc_tangent_pair_from_quad_edge_pair(const BMFace *f,
}
}
void BM_face_calc_tangent_pair_edge(const BMFace *f, float r_tangent_a[3], float r_tangent_b[3])
void BM_face_calc_tangent_pair_from_edge(const BMFace *f,
float r_tangent_a[3],
float r_tangent_b[3])
{
const BMLoop *l_long = BM_face_find_longest_loop((BMFace *)f);
@@ -448,7 +450,7 @@ void BM_face_calc_tangent_pair_edge(const BMFace *f, float r_tangent_a[3], float
len_squared_v3(tmp_next) > len_squared_v3(tmp_prev) ? vec_next : vec_prev);
}
void BM_face_calc_tangent_edge_pair(const BMFace *f, float r_tangent[3])
void BM_face_calc_tangent_from_edge_pair(const BMFace *f, float r_tangent[3])
{
if (f->len == 3) {
BMVert *verts[3];
@@ -459,7 +461,7 @@ void BM_face_calc_tangent_edge_pair(const BMFace *f, float r_tangent[3])
}
else if (f->len == 4) {
/* Use longest edge pair */
BM_face_calc_tangent_edge(f, r_tangent);
BM_face_calc_tangent_from_edge(f, r_tangent);
}
else {
/* For ngons use two longest disconnected edges */
@@ -493,7 +495,7 @@ void BM_face_calc_tangent_edge_pair(const BMFace *f, float r_tangent[3])
}
}
void BM_face_calc_tangent_edge_diagonal(const BMFace *f, float r_tangent[3])
void BM_face_calc_tangent_from_edge_diagonal(const BMFace *f, float r_tangent[3])
{
BMLoop *l_iter, *l_first;
@@ -525,7 +527,7 @@ void BM_face_calc_tangent_edge_diagonal(const BMFace *f, float r_tangent[3])
normalize_v3(r_tangent);
}
void BM_face_calc_tangent_vert_diagonal(const BMFace *f, float r_tangent[3])
void BM_face_calc_tangent_from_vert_diagonal(const BMFace *f, float r_tangent[3])
{
BMLoop *l_iter, *l_first;
@@ -559,7 +561,7 @@ void BM_face_calc_tangent_auto(const BMFace *f, float r_tangent[3])
/* most 'unique' edge of a triangle */
BMVert *verts[3];
BM_face_as_array_vert_tri((BMFace *)f, verts);
BM_vert_tri_calc_tangent_edge(verts, r_tangent);
BM_vert_tri_calc_tangent_from_edge(verts, r_tangent);
}
else if (f->len == 4) {
/* longest edge pair of a quad */
@@ -567,7 +569,7 @@ void BM_face_calc_tangent_auto(const BMFace *f, float r_tangent[3])
}
else {
/* longest edge of an ngon */
BM_face_calc_tangent_edge(f, r_tangent);
BM_face_calc_tangent_from_edge(f, r_tangent);
}
}
@@ -577,7 +579,7 @@ void BM_face_calc_tangent_pair_auto(const BMFace *f, float r_tangent_a[3], float
/* most 'unique' edge of a triangle */
BMVert *verts[3];
BM_face_as_array_vert_tri((BMFace *)f, verts);
BM_vert_tri_calc_tangent_pair_edge(verts, r_tangent_a, r_tangent_b);
BM_vert_tri_calc_tangent_pair_from_edge(verts, r_tangent_a, r_tangent_b);
}
else if (f->len == 4) {
/* longest edge pair of a quad */
@@ -585,7 +587,7 @@ void BM_face_calc_tangent_pair_auto(const BMFace *f, float r_tangent_a[3], float
}
else {
/* longest edge of an ngon */
BM_face_calc_tangent_pair_edge(f, r_tangent_a, r_tangent_b);
BM_face_calc_tangent_pair_from_edge(f, r_tangent_a, r_tangent_b);
}
}

View File

@@ -97,27 +97,29 @@ float BM_face_calc_perimeter_with_mat3(const BMFace *f,
/**
* Compute the tangent of the face, using the longest edge.
*/
void BM_face_calc_tangent_edge(const BMFace *f, float r_tangent[3]) ATTR_NONNULL();
void BM_face_calc_tangent_pair_edge(const BMFace *f, float r_tangent_a[3], float r_tangent_b[3]);
void BM_face_calc_tangent_from_edge(const BMFace *f, float r_tangent[3]) ATTR_NONNULL();
void BM_face_calc_tangent_pair_from_edge(const BMFace *f,
float r_tangent_a[3],
float r_tangent_b[3]);
/**
* Compute the tangent of the face, using the two longest disconnected edges.
*
* \param r_tangent: Calculated unit length tangent (return value).
*/
void BM_face_calc_tangent_edge_pair(const BMFace *f, float r_tangent[3]) ATTR_NONNULL();
void BM_face_calc_tangent_from_edge_pair(const BMFace *f, float r_tangent[3]) ATTR_NONNULL();
/**
* Compute the tangent of the face, using the edge farthest away from any vertex in the face.
*
* \param r_tangent: Calculated unit length tangent (return value).
*/
void BM_face_calc_tangent_edge_diagonal(const BMFace *f, float r_tangent[3]) ATTR_NONNULL();
void BM_face_calc_tangent_from_edge_diagonal(const BMFace *f, float r_tangent[3]) ATTR_NONNULL();
/**
* Compute the tangent of the face, using longest distance between vertices on the face.
*
* \note The logic is almost identical to #BM_face_calc_tangent_edge_diagonal
*/
void BM_face_calc_tangent_vert_diagonal(const BMFace *f, float r_tangent[3]) ATTR_NONNULL();
void BM_face_calc_tangent_from_vert_diagonal(const BMFace *f, float r_tangent[3]) ATTR_NONNULL();
/**
* Compute a meaningful direction along the face (use for gizmo axis).
*
@@ -289,10 +291,10 @@ void BM_face_as_array_loop_quad(BMFace *f, BMLoop *r_loops[4]) ATTR_NONNULL();
*
* \param r_tangent: Calculated unit length tangent (return value).
*/
void BM_vert_tri_calc_tangent_edge(BMVert *verts[3], float r_tangent[3]);
void BM_vert_tri_calc_tangent_pair_edge(BMVert *verts[3],
float r_tangent_a[3],
float r_tangent_b[3]);
void BM_vert_tri_calc_tangent_from_edge(BMVert *verts[3], float r_tangent[3]);
void BM_vert_tri_calc_tangent_pair_from_edge(BMVert *verts[3],
float r_tangent_a[3],
float r_tangent_b[3]);
/**
* Calculate a tangent from any 3 vertices,
*

View File

@@ -1058,7 +1058,7 @@ int getTransformOrientation_ex(const Scene *scene,
sub_v3_v3v3(r_plane, v_pair[0]->co, v_pair[1]->co);
}
else {
BM_vert_tri_calc_tangent_edge(v_tri, r_plane);
BM_vert_tri_calc_tangent_from_edge(v_tri, r_plane);
}
}
else {

View File

@@ -2193,7 +2193,7 @@ static PyObject *bpy_bmface_calc_tangent_edge(BPy_BMFace *self)
float tangent[3];
BPY_BM_CHECK_OBJ(self);
BM_face_calc_tangent_edge(self->f, tangent);
BM_face_calc_tangent_from_edge(self->f, tangent);
return Vector_CreatePyObject(tangent, 3, nullptr);
}
@@ -2215,7 +2215,7 @@ static PyObject *bpy_bmface_calc_tangent_edge_pair(BPy_BMFace *self)
float tangent[3];
BPY_BM_CHECK_OBJ(self);
BM_face_calc_tangent_edge_pair(self->f, tangent);
BM_face_calc_tangent_from_edge_pair(self->f, tangent);
return Vector_CreatePyObject(tangent, 3, nullptr);
}
@@ -2233,7 +2233,7 @@ static PyObject *bpy_bmface_calc_tangent_edge_diagonal(BPy_BMFace *self)
float tangent[3];
BPY_BM_CHECK_OBJ(self);
BM_face_calc_tangent_edge_diagonal(self->f, tangent);
BM_face_calc_tangent_from_edge_diagonal(self->f, tangent);
return Vector_CreatePyObject(tangent, 3, nullptr);
}
@@ -2251,7 +2251,7 @@ static PyObject *bpy_bmface_calc_tangent_vert_diagonal(BPy_BMFace *self)
float tangent[3];
BPY_BM_CHECK_OBJ(self);
BM_face_calc_tangent_vert_diagonal(self->f, tangent);
BM_face_calc_tangent_from_vert_diagonal(self->f, tangent);
return Vector_CreatePyObject(tangent, 3, nullptr);
}