23#define COST_INIT_MAX FLT_MAX
35 const float v1[2],
const float v2[2],
const float v3[2],
bool skip_12,
bool skip_23)
44 const float cost = ((skip_12 ? 0.0f : cost_12) + (skip_23 ? 0.0f : cost_23));
69 const int cd_loop_uv_offset =
params->cd_loop_uv_offset;
72 const float uv_a[2] = {luv_a[0], luv_a[1] /
params->aspect_y};
87 const float uv_b[2] = {luv_b[0], luv_b[1] /
params->aspect_y};
90 const float cost_cut =
params->use_topology_distance ? 1.0f :
len_v2v2(uv_a, uv_b);
91 const float cost_new = cost[l_a_index] + cost_cut;
93 if (cost[l_b_index] > cost_new) {
94 cost[l_b_index] = cost_new;
95 loops_prev[l_b_index] = l_a;
100 if (
params->use_step_face ==
false) {
101 if (
l_b ==
l->next) {
105 }
while ((
l_b =
l_b->next) !=
l);
115 bool (*filter_fn)(
BMLoop *,
void *),
137 }
while ((l_iter = l_iter->
next) != l_first);
142 totloop =
bm->totloop;
188 BMLoop *l_e_a,
BMLoop *l_e_b,
BMLoop *l_v,
const float aspect_y,
const int cd_loop_uv_offset)
190 BMLoop *l_v1 = (l_v->
v == l_e_a->
v) ? l_e_a->
next : l_e_a;
191 BMLoop *l_v2 = (l_v->
v == l_e_b->
v) ? l_e_b->
next : l_e_b;
197 float uv_v1[2] = {luv_v1[0], luv_v1[1] / aspect_y};
198 float uv_v2[2] = {luv_v2[0], luv_v2[1] / aspect_y};
199 float uv_v[2] = {luv_v[0], luv_v[1] / aspect_y};
205 BMLoop *l_e_a,
BMLoop *l_e_b,
BMFace *f,
const float aspect_v2[2],
const int cd_loop_uv_offset)
207 float l_e_a_cent[2], l_e_b_cent[2], f_cent[2];
229 const int cd_loop_uv_offset =
params->cd_loop_uv_offset;
233 if (
params->use_step_face ==
false) {
237 if (loops_prev[l_a_index]) {
238 BMLoop *l_prev = loops_prev[l_a_index];
239 if (l_a_verts[
i]->
v != l_prev->
v) {
240 l_prev = (l_a_verts[
i]->
v == l_prev->
next->
v) ? l_prev->
next :
nullptr;
250 if (e_b->
l ==
nullptr) {
254 l_first =
l_b = e_b->
l;
261 const float cost_cut =
params->use_topology_distance ?
268 const float cost_new = cost[l_a_index] + cost_cut;
270 if (cost[l_b_index] > cost_new) {
271 cost[l_b_index] = cost_new;
272 loops_prev[l_b_index] = l_a;
277 }
while ((
l_b =
l_b->radial_next) != l_first);
282 const float aspect_v2[2] = {1.0f, 1.0f /
params->aspect_y};
284 l_iter = l_first = l_a;
291 BMLoop *l_cycle_iter, *l_cycle_end;
292 l_cycle_iter = l_iter->
next;
293 l_cycle_end = l_iter;
299 const float cost_cut =
params->use_topology_distance ?
305 params->cd_loop_uv_offset);
306 const float cost_new = cost[l_a_index] + cost_cut;
308 if (cost[l_b_index] > cost_new) {
309 cost[l_b_index] = cost_new;
310 loops_prev[l_b_index] = l_a;
314 }
while ((l_cycle_iter = l_cycle_iter->
next) != l_cycle_end);
315 }
while ((l_iter = l_iter->
radial_next) != l_first);
323 bool (*filter_fn)(
BMLoop *,
void *),
342 }
while ((l_iter = l_iter->
next) != l_first);
346 totloop =
bm->totloop;
393 const void *
const f_endpoints[2],
394 const float aspect_v2[2],
395 const int cd_loop_uv_offset)
418 else if (factor > 1.0f) {
433 f_a_cent, e_cent, f_b_cent, (f_a == f_endpoints[0]), (f_b == f_endpoints[1]));
439 const void *
const f_endpoints[2],
440 const float aspect_v2[2],
441 const int cd_loop_uv_offset)
457 f_a_cent, v_cent, f_b_cent, (f_a == f_endpoints[0]), (f_b == f_endpoints[1]));
464 const void *
const f_endpoints[2],
465 const float aspect_v2[2],
468 const int cd_loop_uv_offset =
params->cd_loop_uv_offset;
488 const float cost_cut =
489 params->use_topology_distance ?
492 f_a, f_b, l_iter, f_endpoints, aspect_v2, cd_loop_uv_offset);
493 const float cost_new = cost[f_a_index] + cost_cut;
495 if (cost[f_b_index] > cost_new) {
496 cost[f_b_index] = cost_new;
497 faces_prev[f_b_index] = f_a;
502 }
while ((l_iter = l_iter->
radial_next) != l_first);
507 if (
params->use_step_face) {
521 const float cost_cut =
522 params->use_topology_distance ?
525 f_a, f_b, l_a, f_endpoints, aspect_v2, cd_loop_uv_offset);
526 const float cost_new = cost[f_a_index] + cost_cut;
528 if (cost[f_b_index] > cost_new) {
529 cost[f_b_index] = cost_new;
530 faces_prev[f_b_index] = f_a;
545 bool (*filter_fn)(
BMFace *,
void *),
548 const float aspect_v2[2] = {1.0f, 1.0f /
params->aspect_y};
558 const void *
const f_endpoints[2] = {f_src, f_dst};
574 totface =
bm->totface;
A min-heap / priority queue ADT.
HeapSimple * BLI_heapsimple_new(void) ATTR_WARN_UNUSED_RESULT
void BLI_heapsimple_free(HeapSimple *heap, HeapSimpleFreeFP ptrfreefp) ATTR_NONNULL(1)
void * BLI_heapsimple_pop_min(HeapSimple *heap) ATTR_NONNULL(1)
bool BLI_heapsimple_is_empty(const HeapSimple *heap) ATTR_NONNULL(1)
void BLI_heapsimple_insert(HeapSimple *heap, float value, void *ptr) ATTR_NONNULL(1)
void void BLI_linklist_prepend(LinkNode **listp, void *ptr) ATTR_NONNULL(1)
float line_point_factor_v2(const float p[2], const float l1[2], const float l2[2])
int isect_line_line_v2_point(const float v0[2], const float v1[2], const float v2[2], const float v3[2], float r_vi[2])
MINLINE void mul_v2_v2(float r[2], const float a[2])
MINLINE float len_v2v2(const float v1[2], const float v2[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void copy_v2_v2(float r[2], const float a[2])
void copy_vn_fl(float *array_tar, int size, float val)
MINLINE bool equals_v2v2(const float v1[2], const float v2[2]) ATTR_WARN_UNUSED_RESULT
void mid_v2_v2v2(float r[2], const float a[2], const float b[2])
MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2])
MINLINE float dot_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
MINLINE float normalize_v2(float n[2])
Read Guarded memory(de)allocation.
#define BM_FACE_FIRST_LOOP(p)
#define BM_ELEM_CD_GET_FLOAT_P(ele, offset)
#define BM_elem_index_get(ele)
#define BM_elem_flag_set(ele, hflag, val)
#define BM_elem_index_set(ele, index)
#define BM_elem_flag_test(ele, hflag)
#define BM_elem_flag_enable(ele, hflag)
#define BM_ITER_ELEM(ele, iter, data, itype)
#define BM_ITER_MESH(ele, iter, bm, itype)
static float edgetag_cut_cost_face_uv(BMLoop *l_e_a, BMLoop *l_e_b, BMFace *f, const float aspect_v2[2], const int cd_loop_uv_offset)
LinkNode * BM_mesh_calc_path_uv_edge(BMesh *bm, BMLoop *l_src, BMLoop *l_dst, const BMCalcPathUVParams *params, bool(*filter_fn)(BMLoop *, void *), void *user_data)
static float edgetag_cut_cost_vert_uv(BMLoop *l_e_a, BMLoop *l_e_b, BMLoop *l_v, const float aspect_y, const int cd_loop_uv_offset)
static void facetag_add_adjacent_uv(HeapSimple *heap, BMFace *f_a, BMFace **faces_prev, float *cost, const void *const f_endpoints[2], const float aspect_v2[2], const BMCalcPathUVParams *params)
static void edgetag_add_adjacent_uv(HeapSimple *heap, BMLoop *l_a, BMLoop **loops_prev, float *cost, const BMCalcPathUVParams *params)
static float step_cost_3_v2(const float v1[2], const float v2[2], const float v3[2])
static void verttag_add_adjacent_uv(HeapSimple *heap, BMLoop *l_a, BMLoop **loops_prev, float *cost, const BMCalcPathUVParams *params)
LinkNode * BM_mesh_calc_path_uv_vert(BMesh *bm, BMLoop *l_src, BMLoop *l_dst, const BMCalcPathUVParams *params, bool(*filter_fn)(BMLoop *, void *), void *user_data)
LinkNode * BM_mesh_calc_path_uv_face(BMesh *bm, BMFace *f_src, BMFace *f_dst, const BMCalcPathUVParams *params, bool(*filter_fn)(BMFace *, void *), void *user_data)
static float step_cost_3_v2_ex(const float v1[2], const float v2[2], const float v3[2], bool skip_12, bool skip_23)
static float facetag_cut_cost_edge_uv(BMFace *f_a, BMFace *f_b, BMLoop *l_edge, const void *const f_endpoints[2], const float aspect_v2[2], const int cd_loop_uv_offset)
static float facetag_cut_cost_vert_uv(BMFace *f_a, BMFace *f_b, BMLoop *l_vert, const void *const f_endpoints[2], const float aspect_v2[2], const int cd_loop_uv_offset)
bool BM_loop_share_edge_check(BMLoop *l_a, BMLoop *l_b)
ATTR_WARN_UNUSED_RESULT const BMVert * v2
ATTR_WARN_UNUSED_RESULT const BMLoop * l
ATTR_WARN_UNUSED_RESULT const BMLoop * l_b
ATTR_WARN_UNUSED_RESULT const BMVert * v
bool BM_loop_uv_share_edge_check(const BMLoop *l_a, const BMLoop *l_b, const int cd_loop_uv_offset)
bool BM_loop_uv_share_vert_check(const BMLoop *l_a, const BMLoop *l_b, const int cd_loop_uv_offset)
void BM_face_uv_calc_center_median_weighted(const BMFace *f, const float aspect[2], const int cd_loop_uv_offset, float r_cent[2])
void * MEM_calloc_arrayN(size_t len, size_t size, const char *str)
void * MEM_malloc_arrayN(size_t len, size_t size, const char *str)
void MEM_freeN(void *vmemh)
struct BMLoop * radial_next