forked from bartvdbraak/blender
Fix edge/vert slide UV-correct & zero length edges
When calculating loop angle weighting, skip overlapping vertices.
This commit is contained in:
parent
f1bad1d16b
commit
0d4cca6593
@ -1378,6 +1378,46 @@ void BM_edge_ordered_verts(const BMEdge *edge, BMVert **r_v1, BMVert **r_v2)
|
|||||||
BM_edge_ordered_verts_ex(edge, r_v1, r_v2, edge->l);
|
BM_edge_ordered_verts_ex(edge, r_v1, r_v2, edge->l);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \return The previous loop, over \a eps_sq distance from \a l (or \a NULL if l_stop is reached).
|
||||||
|
*/
|
||||||
|
BMLoop *BM_loop_find_prev_nodouble(BMLoop *l, BMLoop *l_stop, const float eps_sq)
|
||||||
|
{
|
||||||
|
BMLoop *l_step = l->prev;
|
||||||
|
|
||||||
|
BLI_assert(!ELEM(l_stop, NULL, l));
|
||||||
|
|
||||||
|
while (UNLIKELY(len_squared_v3v3(l->v->co, l_step->v->co) < eps_sq)) {
|
||||||
|
l_step = l_step->prev;
|
||||||
|
BLI_assert(l_step != l);
|
||||||
|
if (UNLIKELY(l_step == l_stop)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return l_step;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \return The next loop, over \a eps_sq distance from \a l (or \a NULL if l_stop is reached).
|
||||||
|
*/
|
||||||
|
BMLoop *BM_loop_find_next_nodouble(BMLoop *l, BMLoop *l_stop, const float eps_sq)
|
||||||
|
{
|
||||||
|
BMLoop *l_step = l->next;
|
||||||
|
|
||||||
|
BLI_assert(!ELEM(l_stop, NULL, l));
|
||||||
|
|
||||||
|
while (UNLIKELY(len_squared_v3v3(l->v->co, l_step->v->co) < eps_sq)) {
|
||||||
|
l_step = l_step->next;
|
||||||
|
BLI_assert(l_step != l);
|
||||||
|
if (UNLIKELY(l_step == l_stop)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return l_step;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the loop is convex or concave
|
* Check if the loop is convex or concave
|
||||||
* (depends on face normal)
|
* (depends on face normal)
|
||||||
|
@ -108,6 +108,9 @@ BLI_INLINE bool BM_loop_is_adjacent(const BMLoop *l_a, const BMLoop *l_b) ATTR_W
|
|||||||
float BM_loop_point_side_of_loop_test(const BMLoop *l, const float co[3]) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
|
float BM_loop_point_side_of_loop_test(const BMLoop *l, const float co[3]) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
|
||||||
float BM_loop_point_side_of_edge_test(const BMLoop *l, const float co[3]) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
|
float BM_loop_point_side_of_edge_test(const BMLoop *l, const float co[3]) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
|
||||||
|
|
||||||
|
BMLoop *BM_loop_find_prev_nodouble(BMLoop *l, BMLoop *l_stop, const float eps_sq);
|
||||||
|
BMLoop *BM_loop_find_next_nodouble(BMLoop *l, BMLoop *l_stop, const float eps_sq);
|
||||||
|
|
||||||
float BM_loop_calc_face_angle(const BMLoop *l) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
|
float BM_loop_calc_face_angle(const BMLoop *l) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
|
||||||
void BM_loop_calc_face_normal(const BMLoop *l, float r_normal[3]) ATTR_NONNULL();
|
void BM_loop_calc_face_normal(const BMLoop *l, float r_normal[3]) ATTR_NONNULL();
|
||||||
void BM_loop_calc_face_direction(const BMLoop *l, float r_normal[3]);
|
void BM_loop_calc_face_direction(const BMLoop *l, float r_normal[3]);
|
||||||
|
@ -5324,12 +5324,22 @@ static void slide_origdata_create_data_vert(
|
|||||||
loop_weights = BLI_array_alloca(loop_weights, l_num);
|
loop_weights = BLI_array_alloca(loop_weights, l_num);
|
||||||
for (j = 0; j < l_num; j++) {
|
for (j = 0; j < l_num; j++) {
|
||||||
BMLoop *l = BM_iter_step(&liter);
|
BMLoop *l = BM_iter_step(&liter);
|
||||||
|
BMLoop *l_prev, *l_next;
|
||||||
void **val_p;
|
void **val_p;
|
||||||
if (!BLI_ghash_ensure_p(sod->origfaces, l->f, &val_p)) {
|
if (!BLI_ghash_ensure_p(sod->origfaces, l->f, &val_p)) {
|
||||||
BMFace *f_copy = BM_face_copy(sod->bm_origfaces, bm, l->f, true, true);
|
BMFace *f_copy = BM_face_copy(sod->bm_origfaces, bm, l->f, true, true);
|
||||||
*val_p = f_copy;
|
*val_p = f_copy;
|
||||||
}
|
}
|
||||||
loop_weights[j] = BM_loop_calc_face_angle(l);
|
|
||||||
|
if ((l_prev = BM_loop_find_prev_nodouble(l, l->next, FLT_EPSILON)) &&
|
||||||
|
(l_next = BM_loop_find_next_nodouble(l, l_prev, FLT_EPSILON)))
|
||||||
|
{
|
||||||
|
loop_weights[j] = angle_v3v3v3(l_prev->v->co, l->v->co, l_next->v->co);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
loop_weights[j] = 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* store cd_loop_groups */
|
/* store cd_loop_groups */
|
||||||
|
Loading…
Reference in New Issue
Block a user