34 #define COST_INIT_MAX FLT_MAX
44 const float v1[3],
const float v2[3],
const float v3[3],
bool skip_12,
bool skip_23)
53 const float cost = ((skip_12 ? 0.0f : cost_12) + (skip_23 ? 0.0f : cost_23));
88 const float cost_cut =
params->use_topology_distance ? 1.0f :
len_v3v3(v_a->
co, v_b->
co);
89 const float cost_new = cost[v_a_index] + cost_cut;
91 if (cost[v_b_index] > cost_new) {
92 cost[v_b_index] = cost_new;
93 verts_prev[v_b_index] = v_a;
100 if (
params->use_step_face) {
113 const float cost_cut =
params->use_topology_distance ? 1.0f :
115 const float cost_new = cost[v_a_index] + cost_cut;
117 if (cost[v_b_index] > cost_new) {
118 cost[v_b_index] = cost_new;
119 verts_prev[v_b_index] = v_a;
123 }
while ((l_iter = l_iter->
next) !=
l->
prev);
156 verts_prev =
MEM_callocN(
sizeof(*verts_prev) * totvert, __func__);
157 cost =
MEM_mallocN(
sizeof(*cost) * totvert, __func__);
218 float e_a_cent[3], e_b_cent[3], f_cent[3];
238 if (
params->use_step_face ==
false || e_a->
l ==
NULL) {
248 if ((edges_prev[e_a_index]) && (
BM_vert_in_edge(edges_prev[e_a_index],
v))) {
256 const float cost_cut =
params->use_topology_distance ?
259 const float cost_new = cost[e_a_index] + cost_cut;
261 if (cost[e_b_index] > cost_new) {
262 cost[e_b_index] = cost_new;
263 edges_prev[e_b_index] = e_a;
273 l_iter = l_first = e_a->
l;
275 BMLoop *l_cycle_iter, *l_cycle_end;
277 l_cycle_iter = l_iter->
next;
278 l_cycle_end = l_iter;
282 if (l_iter->
f->
len > 3) {
283 l_cycle_iter = l_cycle_iter->
next;
284 l_cycle_end = l_cycle_end->
prev;
293 const float cost_cut =
params->use_topology_distance ?
296 const float cost_new = cost[e_a_index] + cost_cut;
298 if (cost[e_b_index] > cost_new) {
299 cost[e_b_index] = cost_new;
300 edges_prev[e_b_index] = e_a;
304 }
while ((l_cycle_iter = l_cycle_iter->
next) != l_cycle_end);
305 }
while ((l_iter = l_iter->
radial_next) != l_first);
336 edges_prev =
MEM_callocN(
sizeof(*edges_prev) * totedge, __func__);
337 cost =
MEM_mallocN(
sizeof(*cost) * totedge, __func__);
392 const void *
const f_endpoints[2])
405 float ix_e[3], ix_f[3];
411 else if (factor > 1.0f) {
421 f_a_cent, e_cent, f_b_cent, (f_a == f_endpoints[0]), (f_b == f_endpoints[1]));
427 const void *
const f_endpoints[2])
436 f_a_cent,
v->
co, f_b_cent, (f_a == f_endpoints[0]), (f_b == f_endpoints[1]));
443 const void *
const f_endpoints[2],
456 l_iter = l_first = l_a;
462 const float cost_cut =
params->use_topology_distance ?
465 const float cost_new = cost[f_a_index] + cost_cut;
467 if (cost[f_b_index] > cost_new) {
468 cost[f_b_index] = cost_new;
469 faces_prev[f_b_index] = f_a;
473 }
while ((l_iter = l_iter->
radial_next) != l_first);
477 if (
params->use_step_face) {
490 const float cost_cut =
params->use_topology_distance ?
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;
524 const void *
const f_endpoints[2] = {f_src, f_dst};
537 faces_prev =
MEM_callocN(
sizeof(*faces_prev) * totface, __func__);
538 cost =
MEM_mallocN(
sizeof(*cost) * totface, __func__);
A min-heap / priority queue ADT.
void BLI_heapsimple_free(HeapSimple *heap, HeapSimpleFreeFP ptrfreefp) ATTR_NONNULL(1)
HeapSimple * BLI_heapsimple_new(void) ATTR_WARN_UNUSED_RESULT
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])
void copy_vn_fl(float *array_tar, const int size, const float val)
MINLINE float len_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE float normalize_v3(float r[3])
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])
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])
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble v1
Read Guarded memory(de)allocation.
#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_INDEX(ele, iter, bm, itype, indexvar)
ATTR_WARN_UNUSED_RESULT BMesh * bm
void BM_mesh_elem_index_ensure(BMesh *bm, const char htype)
LinkNode * BM_mesh_calc_path_vert(BMesh *bm, BMVert *v_src, BMVert *v_dst, const struct BMCalcPathParams *params, bool(*filter_fn)(BMVert *, 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_edge(BMesh *bm, BMEdge *e_src, BMEdge *e_dst, const struct BMCalcPathParams *params, bool(*filter_fn)(BMEdge *, void *user_data), void *user_data)
static void edgetag_add_adjacent(HeapSimple *heap, BMEdge *e_a, BMEdge **edges_prev, float *cost, const struct BMCalcPathParams *params)
static void facetag_add_adjacent(HeapSimple *heap, BMFace *f_a, BMFace **faces_prev, float *cost, const void *const f_endpoints[2], const struct BMCalcPathParams *params)
static float edgetag_cut_cost_vert(BMEdge *e_a, BMEdge *e_b, BMVert *v)
LinkNode * BM_mesh_calc_path_face(BMesh *bm, BMFace *f_src, BMFace *f_dst, const struct BMCalcPathParams *params, bool(*filter_fn)(BMFace *, void *user_data), void *user_data)
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 verttag_add_adjacent(HeapSimple *heap, BMVert *v_a, BMVert **verts_prev, float *cost, const struct 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_freeN)(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
void *(* MEM_mallocN)(size_t len, const char *str)
struct BMLoop * radial_next