diff options
Diffstat (limited to 'source/blender/editors/uvedit/uvedit_parametrizer.c')
-rw-r--r-- | source/blender/editors/uvedit/uvedit_parametrizer.c | 155 |
1 files changed, 82 insertions, 73 deletions
diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c index 5a36c83b62e..936ba750266 100644 --- a/source/blender/editors/uvedit/uvedit_parametrizer.c +++ b/source/blender/editors/uvedit/uvedit_parametrizer.c @@ -347,7 +347,7 @@ static PHashLink *phash_next(PHash *ph, PHashKey key, PHashLink *link) /* Geometry */ -static float p_vec_angle_cos(float *v1, float *v2, float *v3) +static float p_vec_angle_cos(const float v1[3], const float v2[3], const float v3[3]) { float d1[3], d2[3]; @@ -365,7 +365,7 @@ static float p_vec_angle_cos(float *v1, float *v2, float *v3) return d1[0] * d2[0] + d1[1] * d2[1] + d1[2] * d2[2]; } -static float p_vec_angle(float *v1, float *v2, float *v3) +static float p_vec_angle(const float v1[3], const float v2[3], const float v3[3]) { float dot = p_vec_angle_cos(v1, v2, v3); @@ -380,7 +380,7 @@ static float p_vec_angle(float *v1, float *v2, float *v3) } } -static float p_vec2_angle(float *v1, float *v2, float *v3) +static float p_vec2_angle(const float v1[2], const float v2[2], const float v3[2]) { float u1[3], u2[3], u3[3]; @@ -397,19 +397,20 @@ static float p_vec2_angle(float *v1, float *v2, float *v3) return p_vec_angle(u1, u2, u3); } -static void p_triangle_angles(float *v1, float *v2, float *v3, float *a1, float *a2, float *a3) +static void p_triangle_angles( + const float v1[3], const float v2[3], const float v3[3], float *r_a1, float *r_a2, float *r_a3) { - *a1 = p_vec_angle(v3, v1, v2); - *a2 = p_vec_angle(v1, v2, v3); - *a3 = (float)M_PI - *a2 - *a1; + *r_a1 = p_vec_angle(v3, v1, v2); + *r_a2 = p_vec_angle(v1, v2, v3); + *r_a3 = (float)M_PI - *r_a2 - *r_a1; } -static void p_face_angles(PFace *f, float *a1, float *a2, float *a3) +static void p_face_angles(PFace *f, float *r_a1, float *r_a2, float *r_a3) { PEdge *e1 = f->edge, *e2 = e1->next, *e3 = e2->next; PVert *v1 = e1->vert, *v2 = e2->vert, *v3 = e3->vert; - p_triangle_angles(v1->co, v2->co, v3->co, a1, a2, a3); + p_triangle_angles(v1->co, v2->co, v3->co, r_a1, r_a2, r_a3); } static float p_face_area(PFace *f) @@ -420,7 +421,7 @@ static float p_face_area(PFace *f) return area_tri_v3(v1->co, v2->co, v3->co); } -static float p_area_signed(float *v1, float *v2, float *v3) +static float p_area_signed(const float v1[2], const float v2[2], const float v3[2]) { return 0.5f * (((v2[0] - v1[0]) * (v3[1] - v1[1])) - ((v3[0] - v1[0]) * (v2[1] - v1[1]))); } @@ -527,7 +528,11 @@ static void UNUSED_FUNCTION(p_chart_uv_from_array)(PChart *chart, float (*points } } -static PBool p_intersect_line_2d_dir(float *v1, float *dir1, float *v2, float *dir2, float *isect) +static PBool p_intersect_line_2d_dir(const float v1[2], + const float dir1[2], + const float v2[2], + const float dir2[2], + float r_isect[2]) { float lmbda, div; @@ -538,14 +543,18 @@ static PBool p_intersect_line_2d_dir(float *v1, float *dir1, float *v2, float *d } lmbda = ((v1[1] - v2[1]) * dir1[0] - (v1[0] - v2[0]) * dir1[1]) / div; - isect[0] = v1[0] + lmbda * dir2[0]; - isect[1] = v1[1] + lmbda * dir2[1]; + r_isect[0] = v1[0] + lmbda * dir2[0]; + r_isect[1] = v1[1] + lmbda * dir2[1]; return P_TRUE; } #if 0 -static PBool p_intersect_line_2d(float *v1, float *v2, float *v3, float *v4, float *isect) +static PBool p_intersect_line_2d(const float v1[2], + const float v2[2], + const float v3[2], + const float v4[2], + const float r_isect[2]) { float dir1[2], dir2[2]; @@ -892,7 +901,7 @@ static PBool p_edge_implicit_seam(PEdge *e, PEdge *ep) return P_FALSE; } -static PBool p_edge_has_pair(PHandle *handle, PEdge *e, PEdge **pair, PBool impl) +static PBool p_edge_has_pair(PHandle *handle, PEdge *e, PBool impl, PEdge **r_pair) { PHashKey key; PEdge *pe; @@ -906,7 +915,7 @@ static PBool p_edge_has_pair(PHandle *handle, PEdge *e, PEdge **pair, PBool impl key = PHASH_edge(key1, key2); pe = (PEdge *)phash_lookup(handle->hash_edges, key); - *pair = NULL; + *r_pair = NULL; while (pe) { if (pe != e) { @@ -917,34 +926,34 @@ static PBool p_edge_has_pair(PHandle *handle, PEdge *e, PEdge **pair, PBool impl ((v1->u.key == key2) && (v2->u.key == key1))) { /* don't connect seams and t-junctions */ - if ((pe->flag & PEDGE_SEAM) || *pair || (impl && p_edge_implicit_seam(e, pe))) { - *pair = NULL; + if ((pe->flag & PEDGE_SEAM) || *r_pair || (impl && p_edge_implicit_seam(e, pe))) { + *r_pair = NULL; return P_FALSE; } - *pair = pe; + *r_pair = pe; } } pe = (PEdge *)phash_next(handle->hash_edges, key, (PHashLink *)pe); } - if (*pair && (e->vert == (*pair)->vert)) { - if ((*pair)->next->pair || (*pair)->next->next->pair) { + if (*r_pair && (e->vert == (*r_pair)->vert)) { + if ((*r_pair)->next->pair || (*r_pair)->next->next->pair) { /* non unfoldable, maybe mobius ring or klein bottle */ - *pair = NULL; + *r_pair = NULL; return P_FALSE; } } - return (*pair != NULL); + return (*r_pair != NULL); } -static PBool p_edge_connect_pair(PHandle *handle, PEdge *e, PEdge ***stack, PBool impl) +static PBool p_edge_connect_pair(PHandle *handle, PEdge *e, PBool impl, PEdge ***stack) { PEdge *pair = NULL; - if (!e->pair && p_edge_has_pair(handle, e, &pair, impl)) { + if (!e->pair && p_edge_has_pair(handle, e, impl, &pair)) { if (e->vert == pair->vert) { p_face_flip(pair->face); } @@ -992,13 +1001,13 @@ static int p_connect_pairs(PHandle *handle, PBool impl) /* assign verts to charts so we can sort them later */ f->u.chart = ncharts; - if (!p_edge_connect_pair(handle, e, &stack, impl)) { + if (!p_edge_connect_pair(handle, e, impl, &stack)) { e->vert->edge = e; } - if (!p_edge_connect_pair(handle, e1, &stack, impl)) { + if (!p_edge_connect_pair(handle, e1, impl, &stack)) { e1->vert->edge = e1; } - if (!p_edge_connect_pair(handle, e2, &stack, impl)) { + if (!p_edge_connect_pair(handle, e2, impl, &stack)) { e2->vert->edge = e2; } } @@ -1255,16 +1264,16 @@ static PBool p_quad_split_direction(PHandle *handle, float **co, PHashKey *vkeys /* Construction: boundary filling */ -static void p_chart_boundaries(PChart *chart, int *nboundaries, PEdge **outer) +static void p_chart_boundaries(PChart *chart, int *r_nboundaries, PEdge **r_outer) { PEdge *e, *be; float len, maxlen = -1.0; - if (nboundaries) { - *nboundaries = 0; + if (r_nboundaries) { + *r_nboundaries = 0; } - if (outer) { - *outer = NULL; + if (r_outer) { + *r_outer = NULL; } for (e = chart->edges; e; e = e->nextlink) { @@ -1272,8 +1281,8 @@ static void p_chart_boundaries(PChart *chart, int *nboundaries, PEdge **outer) continue; } - if (nboundaries) { - (*nboundaries)++; + if (r_nboundaries) { + (*r_nboundaries)++; } len = 0.0f; @@ -1285,8 +1294,8 @@ static void p_chart_boundaries(PChart *chart, int *nboundaries, PEdge **outer) be = be->next->vert->edge; } while (be != e); - if (outer && (len > maxlen)) { - *outer = e; + if (r_outer && (len > maxlen)) { + *r_outer = e; maxlen = len; } } @@ -1427,7 +1436,7 @@ static void p_chart_fill_boundaries(PChart *chart, PEdge *outer) #if 0 /* Polygon kernel for inserting uv's non overlapping */ -static int p_polygon_point_in(float *cp1, float *cp2, float *p) +static int p_polygon_point_in(const float cp1[2], const float cp2[2], const float p[2]) { if ((cp1[0] == p[0]) && (cp1[1] == p[1])) { return 2; @@ -1443,43 +1452,43 @@ static int p_polygon_point_in(float *cp1, float *cp2, float *p) static void p_polygon_kernel_clip(float (*oldpoints)[2], int noldpoints, float (*newpoints)[2], - int *nnewpoints, - float *cp1, - float *cp2) + int *r_nnewpoints, + const float cp1[2], + const float cp2[2]) { float *p2, *p1, isect[2]; int i, p2in, p1in; p1 = oldpoints[noldpoints - 1]; p1in = p_polygon_point_in(cp1, cp2, p1); - *nnewpoints = 0; + *r_nnewpoints = 0; for (i = 0; i < noldpoints; i++) { p2 = oldpoints[i]; p2in = p_polygon_point_in(cp1, cp2, p2); if ((p2in >= 2) || (p1in && p2in)) { - newpoints[*nnewpoints][0] = p2[0]; - newpoints[*nnewpoints][1] = p2[1]; - (*nnewpoints)++; + newpoints[*r_nnewpoints][0] = p2[0]; + newpoints[*r_nnewpoints][1] = p2[1]; + (*r_nnewpoints)++; } else if (p1in && !p2in) { if (p1in != 3) { p_intersect_line_2d(p1, p2, cp1, cp2, isect); - newpoints[*nnewpoints][0] = isect[0]; - newpoints[*nnewpoints][1] = isect[1]; - (*nnewpoints)++; + newpoints[*r_nnewpoints][0] = isect[0]; + newpoints[*r_nnewpoints][1] = isect[1]; + (*r_nnewpoints)++; } } else if (!p1in && p2in) { p_intersect_line_2d(p1, p2, cp1, cp2, isect); - newpoints[*nnewpoints][0] = isect[0]; - newpoints[*nnewpoints][1] = isect[1]; - (*nnewpoints)++; + newpoints[*r_nnewpoints][0] = isect[0]; + newpoints[*r_nnewpoints][1] = isect[1]; + (*r_nnewpoints)++; - newpoints[*nnewpoints][0] = p2[0]; - newpoints[*nnewpoints][1] = p2[1]; - (*nnewpoints)++; + newpoints[*r_nnewpoints][0] = p2[0]; + newpoints[*r_nnewpoints][1] = p2[1]; + (*r_nnewpoints)++; } p1in = p2in; @@ -1556,7 +1565,7 @@ static void p_polygon_kernel_center(float (*points)[2], int npoints, float *cent int NCOLLAPSE = 1; int NCOLLAPSEX = 0; -static float p_vert_cotan(float *v1, float *v2, float *v3) +static float p_vert_cotan(const float v1[3], const float v2[3], const float v3[3]) { float a[3], b[3], c[3], clen; @@ -1733,16 +1742,16 @@ static void p_vert_fix_edge_pointer(PVert *v) } } -static void p_collapsing_verts(PEdge *edge, PEdge *pair, PVert **newv, PVert **keepv) +static void p_collapsing_verts(PEdge *edge, PEdge *pair, PVert **r_newv, PVert **r_keepv) { /* the two vertices that are involved in the collapse */ if (edge) { - *newv = edge->vert; - *keepv = edge->next->vert; + *r_newv = edge->vert; + *r_keepv = edge->next->vert; } else { - *newv = pair->next->vert; - *keepv = pair->vert; + *r_newv = pair->next->vert; + *r_keepv = pair->vert; } } @@ -2107,20 +2116,20 @@ static float p_collapse_cost(PEdge *edge, PEdge *pair) return cost; } -static void p_collapse_cost_vertex(PVert *vert, float *mincost, PEdge **mine) +static void p_collapse_cost_vertex(PVert *vert, float *r_mincost, PEdge **r_mine) { PEdge *e, *enext, *pair; - *mine = NULL; - *mincost = 0.0f; + *r_mine = NULL; + *r_mincost = 0.0f; e = vert->edge; do { if (p_collapse_allowed(e, e->pair)) { float cost = p_collapse_cost(e, e->pair); - if ((*mine == NULL) || (cost < *mincost)) { - *mincost = cost; - *mine = e; + if ((*r_mine == NULL) || (cost < *r_mincost)) { + *r_mincost = cost; + *r_mine = e; } } @@ -2133,9 +2142,9 @@ static void p_collapse_cost_vertex(PVert *vert, float *mincost, PEdge **mine) if (p_collapse_allowed(NULL, pair)) { float cost = p_collapse_cost(NULL, pair); - if ((*mine == NULL) || (cost < *mincost)) { - *mincost = cost; - *mine = pair; + if ((*r_mine == NULL) || (cost < *r_mincost)) { + *r_mincost = cost; + *r_mine = pair; } } @@ -3549,7 +3558,7 @@ static int p_compare_geometric_uv(const void *a, const void *b) } } -static PBool p_chart_convex_hull(PChart *chart, PVert ***verts, int *nverts, int *right) +static PBool p_chart_convex_hull(PChart *chart, PVert ***r_verts, int *r_nverts, int *r_right) { /* Graham algorithm, taken from: * http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/117225 */ @@ -3608,9 +3617,9 @@ static PBool p_chart_convex_hull(PChart *chart, PVert ***verts, int *nverts, int *p = L[i]; } - *verts = points; - *nverts = npoints; - *right = ulen - 1; + *r_verts = points; + *r_nverts = npoints; + *r_right = ulen - 1; MEM_freeN(U); MEM_freeN(L); |