23#define COST_INIT_MAX FLT_MAX
33 const float v1[3],
const float v2[3],
const float v3[3],
bool skip_12,
bool skip_23)
42 const float cost = ((skip_12 ? 0.0f : cost_12) + (skip_23 ? 0.0f : cost_23));
77 const float cost_cut =
params->use_topology_distance ? 1.0f :
len_v3v3(v_a->
co, v_b->
co);
78 const float cost_new = cost[v_a_index] + cost_cut;
80 if (cost[v_b_index] > cost_new) {
81 cost[v_b_index] = cost_new;
82 verts_prev[v_b_index] = v_a;
89 if (
params->use_step_face) {
102 const float cost_cut =
params->use_topology_distance ? 1.0f :
104 const float cost_new = cost[v_a_index] + cost_cut;
106 if (cost[v_b_index] > cost_new) {
107 cost[v_b_index] = cost_new;
108 verts_prev[v_b_index] = v_a;
112 }
while ((l_iter = l_iter->
next) !=
l->prev);
122 bool (*filter_fn)(
BMVert *,
void *user_data),
144 totvert =
bm->totvert;
207 float e_a_cent[3], e_b_cent[3], f_cent[3];
227 if (
params->use_step_face ==
false || e_a->
l ==
nullptr) {
248 const float cost_cut =
params->use_topology_distance ?
251 const float cost_new = cost[e_a_index] + cost_cut;
253 if (cost[e_b_index] > cost_new) {
254 cost[e_b_index] = cost_new;
255 edges_prev[e_b_index] = e_a;
265 l_iter = l_first = e_a->
l;
267 BMLoop *l_cycle_iter, *l_cycle_end;
269 l_cycle_iter = l_iter->
next;
270 l_cycle_end = l_iter;
274 if (l_iter->
f->
len > 3) {
275 l_cycle_iter = l_cycle_iter->
next;
276 l_cycle_end = l_cycle_end->
prev;
285 const float cost_cut =
params->use_topology_distance ?
288 const float cost_new = cost[e_a_index] + cost_cut;
290 if (cost[e_b_index] > cost_new) {
291 cost[e_b_index] = cost_new;
292 edges_prev[e_b_index] = e_a;
296 }
while ((l_cycle_iter = l_cycle_iter->
next) != l_cycle_end);
297 }
while ((l_iter = l_iter->
radial_next) != l_first);
305 bool (*filter_fn)(
BMEdge *,
void *user_data),
335 totedge =
bm->totedge;
398 const void *
const f_endpoints[2])
411 float ix_e[3], ix_f[3];
417 else if (factor > 1.0f) {
427 f_a_cent, e_cent, f_b_cent, (f_a == f_endpoints[0]), (f_b == f_endpoints[1]));
433 const void *
const f_endpoints[2])
442 f_a_cent,
v->co, f_b_cent, (f_a == f_endpoints[0]), (f_b == f_endpoints[1]));
449 const void *
const f_endpoints[2],
462 l_iter = l_first = l_a;
468 const float cost_cut =
params->use_topology_distance ?
471 const float cost_new = cost[f_a_index] + cost_cut;
473 if (cost[f_b_index] > cost_new) {
474 cost[f_b_index] = cost_new;
475 faces_prev[f_b_index] = f_a;
479 }
while ((l_iter = l_iter->
radial_next) != l_first);
483 if (
params->use_step_face) {
496 const float cost_cut =
params->use_topology_distance ?
499 const float cost_new = cost[f_a_index] + cost_cut;
501 if (cost[f_b_index] > cost_new) {
502 cost[f_b_index] = cost_new;
503 faces_prev[f_b_index] = f_a;
517 bool (*filter_fn)(
BMFace *,
void *user_data),
530 const void *
const f_endpoints[2] = {f_src, f_dst};
542 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)
int isect_line_line_v3(const float v1[3], const float v2[3], const float v3[3], const float v4[3], float r_i1[3], float r_i2[3])
float line_point_factor_v3(const float p[3], const float l1[3], const float l2[3])
MINLINE float len_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void copy_v3_v3(float r[3], const float a[3])
void copy_vn_fl(float *array_tar, int size, float val)
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
void mid_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE float normalize_v3(float n[3])
Read Guarded memory(de)allocation.
#define BM_elem_index_get(ele)
#define BM_elem_flag_disable(ele, hflag)
#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_INDEX(ele, iter, bm, itype, indexvar)
LinkNode * BM_mesh_calc_path_edge(BMesh *bm, BMEdge *e_src, BMEdge *e_dst, const BMCalcPathParams *params, bool(*filter_fn)(BMEdge *, void *user_data), void *user_data)
static float edgetag_cut_cost_face(BMEdge *e_a, BMEdge *e_b, BMFace *f)
static float facetag_cut_cost_edge(BMFace *f_a, BMFace *f_b, BMEdge *e, const void *const f_endpoints[2])
static float step_cost_3_v3_ex(const float v1[3], const float v2[3], const float v3[3], bool skip_12, bool skip_23)
LinkNode * BM_mesh_calc_path_vert(BMesh *bm, BMVert *v_src, BMVert *v_dst, const BMCalcPathParams *params, bool(*filter_fn)(BMVert *, void *user_data), void *user_data)
static void verttag_add_adjacent(HeapSimple *heap, BMVert *v_a, BMVert **verts_prev, float *cost, const BMCalcPathParams *params)
LinkNode * BM_mesh_calc_path_face(BMesh *bm, BMFace *f_src, BMFace *f_dst, const BMCalcPathParams *params, bool(*filter_fn)(BMFace *, void *user_data), void *user_data)
static float edgetag_cut_cost_vert(BMEdge *e_a, BMEdge *e_b, BMVert *v)
static void facetag_add_adjacent(HeapSimple *heap, BMFace *f_a, BMFace **faces_prev, float *cost, const void *const f_endpoints[2], const BMCalcPathParams *params)
static float step_cost_3_v3(const float v1[3], const float v2[3], const float v3[3])
static float facetag_cut_cost_vert(BMFace *f_a, BMFace *f_b, BMVert *v, const void *const f_endpoints[2])
static void edgetag_add_adjacent(HeapSimple *heap, BMEdge *e_a, BMEdge **edges_prev, float *cost, const BMCalcPathParams *params)
void BM_face_calc_center_median_weighted(const BMFace *f, float r_cent[3])
bool BM_loop_share_edge_check(BMLoop *l_a, BMLoop *l_b)
BLI_INLINE BMVert * BM_edge_other_vert(BMEdge *e, const BMVert *v) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
BLI_INLINE bool BM_vert_in_edge(const BMEdge *e, const BMVert *v) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
ATTR_WARN_UNUSED_RESULT const BMVert * v2
ATTR_WARN_UNUSED_RESULT const BMLoop * l
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
ATTR_WARN_UNUSED_RESULT const BMLoop * l_b
ATTR_WARN_UNUSED_RESULT const BMVert * v
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