Blender V5.0
bmesh_path_uv.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
10
11#include "MEM_guardedalloc.h"
12
13#include "BLI_heap_simple.h"
14#include "BLI_linklist.h"
15#include "BLI_math_geom.h"
16#include "BLI_math_vector.h"
17
18#include "bmesh.hh"
19#include "bmesh_path_uv.hh" /* own include */
20#include "intern/bmesh_query.hh"
22
23#define COST_INIT_MAX FLT_MAX
24
25/* -------------------------------------------------------------------- */
28
34static float step_cost_3_v2_ex(
35 const float v1[2], const float v2[2], const float v3[2], bool skip_12, bool skip_23)
36{
37 float d1[2], d2[2];
38
39 /* The cost is based on the simple sum of the length of the two edges. */
40 sub_v2_v2v2(d1, v2, v1);
41 sub_v2_v2v2(d2, v3, v2);
42 const float cost_12 = normalize_v2(d1);
43 const float cost_23 = normalize_v2(d2);
44 const float cost = ((skip_12 ? 0.0f : cost_12) + (skip_23 ? 0.0f : cost_23));
45
46 /* But is biased to give higher values to sharp turns, so that it will take paths with
47 * fewer "turns" when selecting between equal-weighted paths between the two edges. */
48 return cost * (1.0f + 0.5f * (2.0f - sqrtf(fabsf(dot_v2v2(d1, d2)))));
49}
50
51static float step_cost_3_v2(const float v1[2], const float v2[2], const float v3[2])
52{
53 return step_cost_3_v2_ex(v1, v2, v3, false, false);
54}
55
57
58/* -------------------------------------------------------------------- */
61
63 BMLoop *l_a,
64 BMLoop **loops_prev,
65 float *cost,
67{
68 BLI_assert(params->aspect_y != 0.0f);
69 const int cd_loop_uv_offset = params->cd_loop_uv_offset;
70 const int l_a_index = BM_elem_index_get(l_a);
71 const float *luv_a = BM_ELEM_CD_GET_FLOAT_P(l_a, cd_loop_uv_offset);
72 const float uv_a[2] = {luv_a[0], luv_a[1] / params->aspect_y};
73
74 {
75 BMIter liter;
76 BMLoop *l;
77 /* Loop over faces of face, but do so by first looping over loops. */
78 BM_ITER_ELEM (l, &liter, l_a->v, BM_LOOPS_OF_VERT) {
79 const float *luv = BM_ELEM_CD_GET_FLOAT_P(l, cd_loop_uv_offset);
80 if (equals_v2v2(luv_a, luv)) {
81 /* 'l_a' is already tagged, tag all adjacent. */
83 BMLoop *l_b = l->next;
84 do {
86 const float *luv_b = BM_ELEM_CD_GET_FLOAT_P(l_b, cd_loop_uv_offset);
87 const float uv_b[2] = {luv_b[0], luv_b[1] / params->aspect_y};
88 /* We know 'l_b' is not visited, check it out! */
89 const int l_b_index = BM_elem_index_get(l_b);
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;
92
93 if (cost[l_b_index] > cost_new) {
94 cost[l_b_index] = cost_new;
95 loops_prev[l_b_index] = l_a;
96 BLI_heapsimple_insert(heap, cost_new, l_b);
97 }
98 }
99 /* This means we only step onto `l->prev` & `l->next`. */
100 if (params->use_step_face == false) {
101 if (l_b == l->next) {
102 l_b = l->prev->prev;
103 }
104 }
105 } while ((l_b = l_b->next) != l);
106 }
107 }
108 }
109}
110
112 BMLoop *l_src,
113 BMLoop *l_dst,
115 bool (*filter_fn)(BMLoop *, void *),
116 void *user_data)
117{
118 LinkNode *path = nullptr;
119 /* BM_ELEM_TAG flag is used to store visited edges */
120 BMIter viter;
121 HeapSimple *heap;
122 float *cost;
123 BMLoop **loops_prev;
124 int i = 0, totloop;
125 BMFace *f;
126
127 /* NOTE: would pass BM_EDGE except we are looping over all faces anyway. */
128 // BM_mesh_elem_index_ensure(bm, BM_LOOP); /* NOTE: not needed for facetag. */
129
130 BM_ITER_MESH (f, &viter, bm, BM_FACES_OF_MESH) {
131 BMLoop *l_first = BM_FACE_FIRST_LOOP(f);
132 BMLoop *l_iter = l_first;
133 do {
134 BM_elem_flag_set(l_iter, BM_ELEM_TAG, !filter_fn(l_iter, user_data));
135 BM_elem_index_set(l_iter, i); /* set_inline */
136 i += 1;
137 } while ((l_iter = l_iter->next) != l_first);
138 }
139 bm->elem_index_dirty &= ~BM_LOOP;
140
141 /* Allocate. */
142 totloop = bm->totloop;
143 loops_prev = MEM_calloc_arrayN<BMLoop *>(totloop, __func__);
144 cost = MEM_malloc_arrayN<float>(totloop, __func__);
145
146 copy_vn_fl(cost, totloop, COST_INIT_MAX);
147
148 /* Regular dijkstra shortest path, but over UV loops instead of vertices. */
149 heap = BLI_heapsimple_new();
150 BLI_heapsimple_insert(heap, 0.0f, l_src);
151 cost[BM_elem_index_get(l_src)] = 0.0f;
152
153 BMLoop *l = nullptr;
154 while (!BLI_heapsimple_is_empty(heap)) {
155 l = static_cast<BMLoop *>(BLI_heapsimple_pop_min(heap));
156
157 if ((l->v == l_dst->v) && BM_loop_uv_share_vert_check(l, l_dst, params->cd_loop_uv_offset)) {
158 break;
159 }
160
162 /* Adjacent loops are tagged while stepping to avoid 2x loops. */
164 verttag_add_adjacent_uv(heap, l, loops_prev, cost, params);
165 }
166 }
167
168 if ((l->v == l_dst->v) && BM_loop_uv_share_vert_check(l, l_dst, params->cd_loop_uv_offset)) {
169 do {
170 BLI_linklist_prepend(&path, l);
171 } while ((l = loops_prev[BM_elem_index_get(l)]));
172 }
173
174 MEM_freeN(loops_prev);
175 MEM_freeN(cost);
176 BLI_heapsimple_free(heap, nullptr);
177
178 return path;
179}
180
182
183/* -------------------------------------------------------------------- */
186
188 BMLoop *l_e_a, BMLoop *l_e_b, BMLoop *l_v, const float aspect_y, const int cd_loop_uv_offset)
189{
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;
192
193 float *luv_v1 = BM_ELEM_CD_GET_FLOAT_P(l_v1, cd_loop_uv_offset);
194 float *luv_v2 = BM_ELEM_CD_GET_FLOAT_P(l_v2, cd_loop_uv_offset);
195 float *luv_v = BM_ELEM_CD_GET_FLOAT_P(l_v, cd_loop_uv_offset);
196
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};
200
201 return step_cost_3_v2(uv_v1, uv_v, uv_v2);
202}
203
205 BMLoop *l_e_a, BMLoop *l_e_b, BMFace *f, const float aspect_v2[2], const int cd_loop_uv_offset)
206{
207 float l_e_a_cent[2], l_e_b_cent[2], f_cent[2];
208 float *luv_e_a = BM_ELEM_CD_GET_FLOAT_P(l_e_a, cd_loop_uv_offset);
209 float *luv_e_b = BM_ELEM_CD_GET_FLOAT_P(l_e_b, cd_loop_uv_offset);
210
211 mid_v2_v2v2(l_e_a_cent, luv_e_a, luv_e_a);
212 mid_v2_v2v2(l_e_b_cent, luv_e_b, luv_e_b);
213
214 mul_v2_v2(l_e_a_cent, aspect_v2);
215 mul_v2_v2(l_e_b_cent, aspect_v2);
216
217 BM_face_uv_calc_center_median_weighted(f, aspect_v2, cd_loop_uv_offset, f_cent);
218
219 return step_cost_3_v2(l_e_a_cent, l_e_b_cent, f_cent);
220}
221
223 BMLoop *l_a,
224 BMLoop **loops_prev,
225 float *cost,
227{
228 BLI_assert(params->aspect_y != 0.0f);
229 const int cd_loop_uv_offset = params->cd_loop_uv_offset;
230 BMLoop *l_a_verts[2] = {l_a, l_a->next};
231 const int l_a_index = BM_elem_index_get(l_a);
232
233 if (params->use_step_face == false) {
234 for (int i = 0; i < ARRAY_SIZE(l_a_verts); i++) {
235
236 /* Skip current UV vert if it is part of the previous UV edge in the path. */
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;
241 }
242 if (l_prev && BM_loop_uv_share_vert_check(l_a_verts[i], l_prev, cd_loop_uv_offset)) {
243 continue;
244 }
245 }
246
247 BMEdge *e_b;
248 BMIter eiter;
249 BM_ITER_ELEM (e_b, &eiter, l_a_verts[i]->v, BM_EDGES_OF_VERT) {
250 if (e_b->l == nullptr) {
251 continue;
252 }
253 BMLoop *l_first, *l_b;
254 l_first = l_b = e_b->l;
255 do {
257 BMLoop *l_b_vert = (l_a_verts[i]->v == l_b->v) ? l_b : l_b->next;
258 if (BM_loop_uv_share_vert_check(l_a_verts[i], l_b_vert, cd_loop_uv_offset)) {
259 /* We know 'l_b' is not visited, check it out! */
260 const int l_b_index = BM_elem_index_get(l_b);
261 const float cost_cut = params->use_topology_distance ?
262 1.0f :
264 l_b,
265 l_a_verts[i],
266 params->aspect_y,
267 cd_loop_uv_offset);
268 const float cost_new = cost[l_a_index] + cost_cut;
269
270 if (cost[l_b_index] > cost_new) {
271 cost[l_b_index] = cost_new;
272 loops_prev[l_b_index] = l_a;
273 BLI_heapsimple_insert(heap, cost_new, l_b);
274 }
275 }
276 }
277 } while ((l_b = l_b->radial_next) != l_first);
278 }
279 }
280 }
281 else {
282 const float aspect_v2[2] = {1.0f, 1.0f / params->aspect_y};
283 BMLoop *l_first, *l_iter;
284 l_iter = l_first = l_a;
285 do {
286 /* Ensures connected UVs and that they lie on the same island. */
287 if (!BM_loop_uv_share_edge_check(l_a, l_iter, cd_loop_uv_offset)) {
288 continue;
289 }
290
291 BMLoop *l_cycle_iter, *l_cycle_end;
292 l_cycle_iter = l_iter->next;
293 l_cycle_end = l_iter;
294 do {
295 BMLoop *l_b = l_cycle_iter;
297 /* We know 'l_b' is not visited, check it out! */
298 const int l_b_index = BM_elem_index_get(l_b);
299 const float cost_cut = params->use_topology_distance ?
300 1.0f :
302 l_b,
303 l_iter->f,
304 aspect_v2,
305 params->cd_loop_uv_offset);
306 const float cost_new = cost[l_a_index] + cost_cut;
307
308 if (cost[l_b_index] > cost_new) {
309 cost[l_b_index] = cost_new;
310 loops_prev[l_b_index] = l_a;
311 BLI_heapsimple_insert(heap, cost_new, l_b);
312 }
313 }
314 } while ((l_cycle_iter = l_cycle_iter->next) != l_cycle_end);
315 } while ((l_iter = l_iter->radial_next) != l_first);
316 }
317}
318
320 BMLoop *l_src,
321 BMLoop *l_dst,
323 bool (*filter_fn)(BMLoop *, void *),
324 void *user_data)
325{
326 LinkNode *path = nullptr;
327
328 BMFace *f;
329 BMIter iter;
330 HeapSimple *heap;
331 float *cost;
332 BMLoop **loops_prev;
333 int i = 0, totloop;
334
335 BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
336 BMLoop *l_first = BM_FACE_FIRST_LOOP(f);
337 BMLoop *l_iter = l_first;
338 do {
339 BM_elem_flag_set(l_iter, BM_ELEM_TAG, !filter_fn(l_iter, user_data));
340 BM_elem_index_set(l_iter, i);
341 i += 1;
342 } while ((l_iter = l_iter->next) != l_first);
343 }
344 bm->elem_index_dirty &= ~BM_LOOP;
345
346 totloop = bm->totloop;
347 loops_prev = MEM_calloc_arrayN<BMLoop *>(totloop, __func__);
348 cost = MEM_malloc_arrayN<float>(totloop, __func__);
349
350 copy_vn_fl(cost, totloop, COST_INIT_MAX);
351
352 /* Regular dijkstra shortest path, but over UV loops/edges instead of vertices. */
353 heap = BLI_heapsimple_new();
354 BLI_heapsimple_insert(heap, 0.0f, l_src);
355 cost[BM_elem_index_get(l_src)] = 0.0f;
356
357 BMLoop *l = nullptr;
358 while (!BLI_heapsimple_is_empty(heap)) {
359 l = static_cast<BMLoop *>(BLI_heapsimple_pop_min(heap));
360
361 if ((l->e == l_dst->e) && BM_loop_uv_share_edge_check(l, l_dst, params->cd_loop_uv_offset)) {
362 break;
363 }
364
367 edgetag_add_adjacent_uv(heap, l, loops_prev, cost, params);
368 }
369 }
370
371 if ((l->e == l_dst->e) && BM_loop_uv_share_edge_check(l, l_dst, params->cd_loop_uv_offset)) {
372 do {
373 BLI_linklist_prepend(&path, l);
374 } while ((l = loops_prev[BM_elem_index_get(l)]));
375 }
376
377 MEM_freeN(loops_prev);
378 MEM_freeN(cost);
379 BLI_heapsimple_free(heap, nullptr);
380
381 return path;
382}
383
385
386/* -------------------------------------------------------------------- */
389
391 BMFace *f_b,
392 BMLoop *l_edge,
393 const void *const f_endpoints[2],
394 const float aspect_v2[2],
395 const int cd_loop_uv_offset)
396{
397 float f_a_cent[2];
398 float f_b_cent[2];
399 float e_cent[2];
400
401 BM_face_uv_calc_center_median_weighted(f_a, aspect_v2, cd_loop_uv_offset, f_a_cent);
402 BM_face_uv_calc_center_median_weighted(f_b, aspect_v2, cd_loop_uv_offset, f_b_cent);
403
404 const float *co_v1 = BM_ELEM_CD_GET_FLOAT_P(l_edge, cd_loop_uv_offset);
405 const float *co_v2 = BM_ELEM_CD_GET_FLOAT_P(l_edge->next, cd_loop_uv_offset);
406
407#if 0
408 mid_v2_v2v2(e_cent, co_v1, co_v2);
409#else
410 /* For triangle fans it gives better results to pick a point on the edge. */
411 {
412 float ix_e[2];
413 isect_line_line_v2_point(co_v1, co_v2, f_a_cent, f_b_cent, ix_e);
414 const float factor = line_point_factor_v2(ix_e, co_v1, co_v2);
415 if (factor < 0.0f) {
416 copy_v2_v2(e_cent, co_v1);
417 }
418 else if (factor > 1.0f) {
419 copy_v2_v2(e_cent, co_v2);
420 }
421 else {
422 copy_v2_v2(e_cent, ix_e);
423 }
424 }
425#endif
426
427 /* Apply aspect before calculating cost. */
428 mul_v2_v2(f_a_cent, aspect_v2);
429 mul_v2_v2(f_b_cent, aspect_v2);
430 mul_v2_v2(e_cent, aspect_v2);
431
432 return step_cost_3_v2_ex(
433 f_a_cent, e_cent, f_b_cent, (f_a == f_endpoints[0]), (f_b == f_endpoints[1]));
434}
435
437 BMFace *f_b,
438 BMLoop *l_vert,
439 const void *const f_endpoints[2],
440 const float aspect_v2[2],
441 const int cd_loop_uv_offset)
442{
443 float f_a_cent[2];
444 float f_b_cent[2];
445 float v_cent[2];
446
447 BM_face_uv_calc_center_median_weighted(f_a, aspect_v2, cd_loop_uv_offset, f_a_cent);
448 BM_face_uv_calc_center_median_weighted(f_b, aspect_v2, cd_loop_uv_offset, f_b_cent);
449
450 copy_v2_v2(v_cent, BM_ELEM_CD_GET_FLOAT_P(l_vert, cd_loop_uv_offset));
451
452 mul_v2_v2(f_a_cent, aspect_v2);
453 mul_v2_v2(f_b_cent, aspect_v2);
454 mul_v2_v2(v_cent, aspect_v2);
455
456 return step_cost_3_v2_ex(
457 f_a_cent, v_cent, f_b_cent, (f_a == f_endpoints[0]), (f_b == f_endpoints[1]));
458}
459
461 BMFace *f_a,
462 BMFace **faces_prev,
463 float *cost,
464 const void *const f_endpoints[2],
465 const float aspect_v2[2],
467{
468 const int cd_loop_uv_offset = params->cd_loop_uv_offset;
469 const int f_a_index = BM_elem_index_get(f_a);
470
471 /* Loop over faces of face, but do so by first looping over loops. */
472 {
473 BMIter liter;
474 BMLoop *l_a;
475
476 BM_ITER_ELEM (l_a, &liter, f_a, BM_LOOPS_OF_FACE) {
477 BMLoop *l_first, *l_iter;
478
479 /* Check there is an adjacent face to loop over. */
480 if (l_a != l_a->radial_next) {
481 l_iter = l_first = l_a->radial_next;
482 do {
483 BMFace *f_b = l_iter->f;
484 if (!BM_elem_flag_test(f_b, BM_ELEM_TAG)) {
485 if (BM_loop_uv_share_edge_check(l_a, l_iter, cd_loop_uv_offset)) {
486 /* We know 'f_b' is not visited, check it out! */
487 const int f_b_index = BM_elem_index_get(f_b);
488 const float cost_cut =
489 params->use_topology_distance ?
490 1.0f :
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;
494
495 if (cost[f_b_index] > cost_new) {
496 cost[f_b_index] = cost_new;
497 faces_prev[f_b_index] = f_a;
498 BLI_heapsimple_insert(heap, cost_new, f_b);
499 }
500 }
501 }
502 } while ((l_iter = l_iter->radial_next) != l_first);
503 }
504 }
505 }
506
507 if (params->use_step_face) {
508 BMIter liter;
509 BMLoop *l_a;
510
511 BM_ITER_ELEM (l_a, &liter, f_a, BM_LOOPS_OF_FACE) {
512 BMIter litersub;
513 BMLoop *l_b;
514 BM_ITER_ELEM (l_b, &litersub, l_a->v, BM_LOOPS_OF_VERT) {
515 if ((l_a != l_b) && !BM_loop_share_edge_check(l_a, l_b)) {
516 BMFace *f_b = l_b->f;
517 if (!BM_elem_flag_test(f_b, BM_ELEM_TAG)) {
518 if (BM_loop_uv_share_vert_check(l_a, l_b, cd_loop_uv_offset)) {
519 /* We know 'f_b' is not visited, check it out! */
520 const int f_b_index = BM_elem_index_get(f_b);
521 const float cost_cut =
522 params->use_topology_distance ?
523 1.0f :
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;
527
528 if (cost[f_b_index] > cost_new) {
529 cost[f_b_index] = cost_new;
530 faces_prev[f_b_index] = f_a;
531 BLI_heapsimple_insert(heap, cost_new, f_b);
532 }
533 }
534 }
535 }
536 }
537 }
538 }
539}
540
542 BMFace *f_src,
543 BMFace *f_dst,
545 bool (*filter_fn)(BMFace *, void *),
546 void *user_data)
547{
548 const float aspect_v2[2] = {1.0f, 1.0f / params->aspect_y};
549 LinkNode *path = nullptr;
550 /* BM_ELEM_TAG flag is used to store visited edges */
551 BMIter fiter;
552 HeapSimple *heap;
553 float *cost;
554 BMFace **faces_prev;
555 int i = 0, totface;
556
557 /* Start measuring face path at the face edges, ignoring their centers. */
558 const void *const f_endpoints[2] = {f_src, f_dst};
559
560 /* NOTE: would pass BM_EDGE except we are looping over all faces anyway. */
561 // BM_mesh_elem_index_ensure(bm, BM_LOOP); /* NOTE: not needed for facetag. */
562
563 {
564 BMFace *f;
565 BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) {
566 BM_elem_flag_set(f, BM_ELEM_TAG, !filter_fn(f, user_data));
567 BM_elem_index_set(f, i); /* set_inline */
568 i += 1;
569 }
570 bm->elem_index_dirty &= ~BM_FACE;
571 }
572
573 /* Allocate. */
574 totface = bm->totface;
575 faces_prev = MEM_calloc_arrayN<BMFace *>(totface, __func__);
576 cost = MEM_malloc_arrayN<float>(totface, __func__);
577
578 copy_vn_fl(cost, totface, COST_INIT_MAX);
579
580 /* Regular dijkstra shortest path, but over UV faces instead of vertices. */
581 heap = BLI_heapsimple_new();
582 BLI_heapsimple_insert(heap, 0.0f, f_src);
583 cost[BM_elem_index_get(f_src)] = 0.0f;
584
585 BMFace *f = nullptr;
586 while (!BLI_heapsimple_is_empty(heap)) {
587 f = static_cast<BMFace *>(BLI_heapsimple_pop_min(heap));
588
589 if (f == f_dst) {
590 break;
591 }
592
594 /* Adjacent loops are tagged while stepping to avoid 2x loops. */
596 facetag_add_adjacent_uv(heap, f, faces_prev, cost, f_endpoints, aspect_v2, params);
597 }
598 }
599
600 if (f == f_dst) {
601 do {
602 BLI_linklist_prepend(&path, f);
603 } while ((f = faces_prev[BM_elem_index_get(f)]));
604 }
605
606 MEM_freeN(faces_prev);
607 MEM_freeN(cost);
608 BLI_heapsimple_free(heap, nullptr);
609
610 return path;
611}
612
#define BLI_assert(a)
Definition BLI_assert.h:46
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)
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])
#define ARRAY_SIZE(arr)
Read Guarded memory(de)allocation.
#define BM_FACE_FIRST_LOOP(p)
#define BM_ELEM_CD_GET_FLOAT_P(ele, offset)
@ BM_ELEM_TAG
@ BM_LOOP
#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)
@ BM_FACES_OF_MESH
@ BM_LOOPS_OF_VERT
@ BM_EDGES_OF_VERT
@ BM_LOOPS_OF_FACE
BMesh * bm
#define BM_FACE
#define COST_INIT_MAX
Definition bmesh_path.cc:23
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])
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
void * MEM_calloc_arrayN(size_t len, size_t size, const char *str)
Definition mallocn.cc:123
void * MEM_malloc_arrayN(size_t len, size_t size, const char *str)
Definition mallocn.cc:133
void MEM_freeN(void *vmemh)
Definition mallocn.cc:113
#define fabsf
#define sqrtf
struct BMLoop * l
struct BMVert * v
struct BMEdge * e
struct BMLoop * radial_next
struct BMFace * f
struct BMLoop * next
i
Definition text_draw.cc:230