Docs: expand on doc-string for seam_connected_recursive

Also use const UVs where possible.
This commit is contained in:
Campbell Barton 2023-01-16 14:49:49 +11:00
parent 6a7ecec6e1
commit a294c35370
1 changed files with 26 additions and 9 deletions

View File

@ -899,14 +899,29 @@ static bool loop_uv_match(BMLoop *loop,
compare_v2v2(luv_b, luv_d, STD_UV_CONNECT_LIMIT);
}
/* Given `luv_anchor` and `needle`, return true if there are edges that fan between them that are
* seam-free. */
/**
* Utility function to implement #seam_connected.
*
* Given `edge`, `luv_anchor` & `luv_fan` find if `needle` is connected without
* seams or disjoint UVs which would delimit causing them not to be considered connected.
*
* \note The term *anchor* is used for the vertex at the center of a face-fan
* which is being stepped over. Even though every connected face may have a different UV,
* loops are only stepped onto which match the initial `luv_anchor`.
*
* \param edge: Search for `needle` in all loops connected to `edge` (recursively).
* \param luv_anchor: The UV of the anchor (vertex that's being stepped around).
* \param luv_fan: The UV of the outer edge, this changes as the fan is stepped over.
* \param visited: A set of edges to prevent recursing down the same edge multiple times.
* \param cd_loop_uv_offset: The UV layer.
* \return true if there are edges that fan between them that are seam-free.
* */
static bool seam_connected_recursive(BMEdge *edge,
const float luv_anchor[2],
const float luv_fan[2],
BMLoop *needle,
const BMLoop *needle,
GSet *visited,
int cd_loop_uv_offset)
const int cd_loop_uv_offset)
{
BMVert *anchor = needle->v;
BLI_assert(edge->v1 == anchor || edge->v2 == anchor);
@ -931,7 +946,7 @@ static bool seam_connected_recursive(BMEdge *edge,
return true; /* Success. */
}
float *luv_far = BM_ELEM_CD_GET_FLOAT_P(loop->prev, cd_loop_uv_offset);
const float *luv_far = BM_ELEM_CD_GET_FLOAT_P(loop->prev, cd_loop_uv_offset);
if (seam_connected_recursive(
loop->prev->e, luv_anchor, luv_far, needle, visited, cd_loop_uv_offset)) {
return true;
@ -947,7 +962,7 @@ static bool seam_connected_recursive(BMEdge *edge,
return true; /* Success. */
}
float *luv_far = BM_ELEM_CD_GET_FLOAT_P(loop->next->next, cd_loop_uv_offset);
const float *luv_far = BM_ELEM_CD_GET_FLOAT_P(loop->next->next, cd_loop_uv_offset);
if (seam_connected_recursive(
loop->next->e, luv_anchor, luv_far, needle, visited, cd_loop_uv_offset)) {
return true;
@ -958,8 +973,10 @@ static bool seam_connected_recursive(BMEdge *edge,
return false;
}
/* Given `loop_a` and `loop_b` originate from the same vertex and share a UV,
* return true if there are edges that fan between them that are seam-free.
/**
* Given `loop_a` and `loop_b` originate from the same vertex and share a UV,
*
* \return true if there are edges that fan between them that are seam-free.
* return false otherwise.
*/
static bool seam_connected(BMLoop *loop_a, BMLoop *loop_b, GSet *visited, int cd_loop_uv_offset)
@ -977,7 +994,7 @@ static bool seam_connected(BMLoop *loop_a, BMLoop *loop_b, GSet *visited, int cd
if (!result) {
/* Search around `loop_a` in the opposite direction, as one of the edges may be delimited by
* a boundary, seam or disjoint UV, or itself be one of these. See: T103670, T103787. */
float *luv_prev_fan = BM_ELEM_CD_GET_FLOAT_P(loop_a->prev, cd_loop_uv_offset);
const float *luv_prev_fan = BM_ELEM_CD_GET_FLOAT_P(loop_a->prev, cd_loop_uv_offset);
result = seam_connected_recursive(
loop_a->prev->e, luv_anchor, luv_prev_fan, loop_b, visited, cd_loop_uv_offset);
}