Changeset View
Changeset View
Standalone View
Standalone View
source/blender/bmesh/tools/bmesh_path_uv.c
| Show First 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | static void verttag_add_adjacent_uv(HeapSimple *heap, | ||||
| BMLoop *l_a, | BMLoop *l_a, | ||||
| BMLoop **loops_prev, | BMLoop **loops_prev, | ||||
| float *cost, | float *cost, | ||||
| const struct BMCalcPathUVParams *params) | const struct BMCalcPathUVParams *params) | ||||
| { | { | ||||
| BLI_assert(params->aspect_y != 0.0f); | BLI_assert(params->aspect_y != 0.0f); | ||||
| const int cd_loop_uv_offset = params->cd_loop_uv_offset; | const int cd_loop_uv_offset = params->cd_loop_uv_offset; | ||||
| const int l_a_index = BM_elem_index_get(l_a); | const int l_a_index = BM_elem_index_get(l_a); | ||||
| const MLoopUV *luv_a = BM_ELEM_CD_GET_VOID_P(l_a, cd_loop_uv_offset); | const float *luv_a = BM_ELEM_CD_GET_FLOAT_P(l_a, cd_loop_uv_offset); | ||||
| const float uv_a[2] = {luv_a->uv[0], luv_a->uv[1] / params->aspect_y}; | const float uv_a[2] = {luv_a[0], luv_a[1] / params->aspect_y}; | ||||
| { | { | ||||
| BMIter liter; | BMIter liter; | ||||
| BMLoop *l; | BMLoop *l; | ||||
| /* Loop over faces of face, but do so by first looping over loops. */ | /* Loop over faces of face, but do so by first looping over loops. */ | ||||
| BM_ITER_ELEM (l, &liter, l_a->v, BM_LOOPS_OF_VERT) { | BM_ITER_ELEM (l, &liter, l_a->v, BM_LOOPS_OF_VERT) { | ||||
| const MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); | const float *luv = BM_ELEM_CD_GET_FLOAT_P(l, cd_loop_uv_offset); | ||||
| if (equals_v2v2(luv_a->uv, luv->uv)) { | if (equals_v2v2(luv_a, luv)) { | ||||
| /* 'l_a' is already tagged, tag all adjacent. */ | /* 'l_a' is already tagged, tag all adjacent. */ | ||||
| BM_elem_flag_enable(l, BM_ELEM_TAG); | BM_elem_flag_enable(l, BM_ELEM_TAG); | ||||
| BMLoop *l_b = l->next; | BMLoop *l_b = l->next; | ||||
| do { | do { | ||||
| if (!BM_elem_flag_test(l_b, BM_ELEM_TAG)) { | if (!BM_elem_flag_test(l_b, BM_ELEM_TAG)) { | ||||
| const MLoopUV *luv_b = BM_ELEM_CD_GET_VOID_P(l_b, cd_loop_uv_offset); | const float *luv_b = BM_ELEM_CD_GET_FLOAT_P(l_b, cd_loop_uv_offset); | ||||
| const float uv_b[2] = {luv_b->uv[0], luv_b->uv[1] / params->aspect_y}; | const float uv_b[2] = {luv_b[0], luv_b[1] / params->aspect_y}; | ||||
| /* We know 'l_b' is not visited, check it out! */ | /* We know 'l_b' is not visited, check it out! */ | ||||
| const int l_b_index = BM_elem_index_get(l_b); | const int l_b_index = BM_elem_index_get(l_b); | ||||
| const float cost_cut = params->use_topology_distance ? 1.0f : len_v2v2(uv_a, uv_b); | const float cost_cut = params->use_topology_distance ? 1.0f : len_v2v2(uv_a, uv_b); | ||||
| const float cost_new = cost[l_a_index] + cost_cut; | const float cost_new = cost[l_a_index] + cost_cut; | ||||
| if (cost[l_b_index] > cost_new) { | if (cost[l_b_index] > cost_new) { | ||||
| cost[l_b_index] = cost_new; | cost[l_b_index] = cost_new; | ||||
| loops_prev[l_b_index] = l_a; | loops_prev[l_b_index] = l_a; | ||||
| ▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Lines | |||||
| * \{ */ | * \{ */ | ||||
| static float edgetag_cut_cost_vert_uv( | 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) | BMLoop *l_e_a, BMLoop *l_e_b, BMLoop *l_v, const float aspect_y, const int cd_loop_uv_offset) | ||||
| { | { | ||||
| BMLoop *l_v1 = (l_v->v == l_e_a->v) ? l_e_a->next : l_e_a; | BMLoop *l_v1 = (l_v->v == l_e_a->v) ? l_e_a->next : l_e_a; | ||||
| BMLoop *l_v2 = (l_v->v == l_e_b->v) ? l_e_b->next : l_e_b; | BMLoop *l_v2 = (l_v->v == l_e_b->v) ? l_e_b->next : l_e_b; | ||||
| MLoopUV *luv_v1 = BM_ELEM_CD_GET_VOID_P(l_v1, cd_loop_uv_offset); | float *luv_v1 = BM_ELEM_CD_GET_FLOAT_P(l_v1, cd_loop_uv_offset); | ||||
| MLoopUV *luv_v2 = BM_ELEM_CD_GET_VOID_P(l_v2, cd_loop_uv_offset); | float *luv_v2 = BM_ELEM_CD_GET_FLOAT_P(l_v2, cd_loop_uv_offset); | ||||
| MLoopUV *luv_v = BM_ELEM_CD_GET_VOID_P(l_v, cd_loop_uv_offset); | float *luv_v = BM_ELEM_CD_GET_FLOAT_P(l_v, cd_loop_uv_offset); | ||||
| float uv_v1[2] = {luv_v1->uv[0], luv_v1->uv[1] / aspect_y}; | float uv_v1[2] = {luv_v1[0], luv_v1[1] / aspect_y}; | ||||
| float uv_v2[2] = {luv_v2->uv[0], luv_v2->uv[1] / aspect_y}; | float uv_v2[2] = {luv_v2[0], luv_v2[1] / aspect_y}; | ||||
| float uv_v[2] = {luv_v->uv[0], luv_v->uv[1] / aspect_y}; | float uv_v[2] = {luv_v[0], luv_v[1] / aspect_y}; | ||||
| return step_cost_3_v2(uv_v1, uv_v, uv_v2); | return step_cost_3_v2(uv_v1, uv_v, uv_v2); | ||||
| } | } | ||||
| static float edgetag_cut_cost_face_uv( | 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) | BMLoop *l_e_a, BMLoop *l_e_b, BMFace *f, const float aspect_v2[2], const int cd_loop_uv_offset) | ||||
| { | { | ||||
| float l_e_a_cent[2], l_e_b_cent[2], f_cent[2]; | float l_e_a_cent[2], l_e_b_cent[2], f_cent[2]; | ||||
| MLoopUV *luv_e_a = BM_ELEM_CD_GET_VOID_P(l_e_a, cd_loop_uv_offset); | float *luv_e_a = BM_ELEM_CD_GET_FLOAT_P(l_e_a, cd_loop_uv_offset); | ||||
| MLoopUV *luv_e_b = BM_ELEM_CD_GET_VOID_P(l_e_b, cd_loop_uv_offset); | float *luv_e_b = BM_ELEM_CD_GET_FLOAT_P(l_e_b, cd_loop_uv_offset); | ||||
| mid_v2_v2v2(l_e_a_cent, luv_e_a->uv, luv_e_a->uv); | mid_v2_v2v2(l_e_a_cent, luv_e_a, luv_e_a); | ||||
| mid_v2_v2v2(l_e_b_cent, luv_e_b->uv, luv_e_b->uv); | mid_v2_v2v2(l_e_b_cent, luv_e_b, luv_e_b); | ||||
| mul_v2_v2(l_e_a_cent, aspect_v2); | mul_v2_v2(l_e_a_cent, aspect_v2); | ||||
| mul_v2_v2(l_e_b_cent, aspect_v2); | mul_v2_v2(l_e_b_cent, aspect_v2); | ||||
| BM_face_uv_calc_center_median_weighted(f, aspect_v2, cd_loop_uv_offset, f_cent); | BM_face_uv_calc_center_median_weighted(f, aspect_v2, cd_loop_uv_offset, f_cent); | ||||
| return step_cost_3_v2(l_e_a_cent, l_e_b_cent, f_cent); | return step_cost_3_v2(l_e_a_cent, l_e_b_cent, f_cent); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 172 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| float f_a_cent[2]; | float f_a_cent[2]; | ||||
| float f_b_cent[2]; | float f_b_cent[2]; | ||||
| float e_cent[2]; | float e_cent[2]; | ||||
| BM_face_uv_calc_center_median_weighted(f_a, aspect_v2, cd_loop_uv_offset, f_a_cent); | BM_face_uv_calc_center_median_weighted(f_a, aspect_v2, cd_loop_uv_offset, f_a_cent); | ||||
| BM_face_uv_calc_center_median_weighted(f_b, aspect_v2, cd_loop_uv_offset, f_b_cent); | BM_face_uv_calc_center_median_weighted(f_b, aspect_v2, cd_loop_uv_offset, f_b_cent); | ||||
| const float *co_v1 = ((const MLoopUV *)BM_ELEM_CD_GET_VOID_P(l_edge, cd_loop_uv_offset))->uv; | const float *co_v1 = BM_ELEM_CD_GET_FLOAT_P(l_edge, cd_loop_uv_offset); | ||||
| const float *co_v2 = | const float *co_v2 = BM_ELEM_CD_GET_FLOAT_P(l_edge->next, cd_loop_uv_offset); | ||||
| ((const MLoopUV *)BM_ELEM_CD_GET_VOID_P(l_edge->next, cd_loop_uv_offset))->uv; | |||||
| #if 0 | #if 0 | ||||
| mid_v2_v2v2(e_cent, co_v1, co_v2); | mid_v2_v2v2(e_cent, co_v1, co_v2); | ||||
| #else | #else | ||||
| /* For triangle fans it gives better results to pick a point on the edge. */ | /* For triangle fans it gives better results to pick a point on the edge. */ | ||||
| { | { | ||||
| float ix_e[2]; | float ix_e[2]; | ||||
| isect_line_line_v2_point(co_v1, co_v2, f_a_cent, f_b_cent, ix_e); | isect_line_line_v2_point(co_v1, co_v2, f_a_cent, f_b_cent, ix_e); | ||||
| Show All 28 Lines | |||||
| { | { | ||||
| float f_a_cent[2]; | float f_a_cent[2]; | ||||
| float f_b_cent[2]; | float f_b_cent[2]; | ||||
| float v_cent[2]; | float v_cent[2]; | ||||
| BM_face_uv_calc_center_median_weighted(f_a, aspect_v2, cd_loop_uv_offset, f_a_cent); | BM_face_uv_calc_center_median_weighted(f_a, aspect_v2, cd_loop_uv_offset, f_a_cent); | ||||
| BM_face_uv_calc_center_median_weighted(f_b, aspect_v2, cd_loop_uv_offset, f_b_cent); | BM_face_uv_calc_center_median_weighted(f_b, aspect_v2, cd_loop_uv_offset, f_b_cent); | ||||
| copy_v2_v2(v_cent, ((const MLoopUV *)BM_ELEM_CD_GET_VOID_P(l_vert, cd_loop_uv_offset))->uv); | copy_v2_v2(v_cent, BM_ELEM_CD_GET_FLOAT_P(l_vert, cd_loop_uv_offset)); | ||||
| mul_v2_v2(f_a_cent, aspect_v2); | mul_v2_v2(f_a_cent, aspect_v2); | ||||
| mul_v2_v2(f_b_cent, aspect_v2); | mul_v2_v2(f_b_cent, aspect_v2); | ||||
| mul_v2_v2(v_cent, aspect_v2); | mul_v2_v2(v_cent, aspect_v2); | ||||
| return step_cost_3_v2_ex( | return step_cost_3_v2_ex( | ||||
| f_a_cent, v_cent, f_b_cent, (f_a == f_endpoints[0]), (f_b == f_endpoints[1])); | f_a_cent, v_cent, f_b_cent, (f_a == f_endpoints[0]), (f_b == f_endpoints[1])); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 155 Lines • Show Last 20 Lines | |||||