Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-04-13 10:33:59 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-04-13 10:33:59 +0400
commitb2667970d286761d31a7f9c9969a0b95428da200 (patch)
tree96f18e48268bf5c37bfb79b96d376f376efdbc00 /source/blender/editors/uvedit/uvedit_parametrizer.c
parent60d3b8f27b31fea67a91184868b20ed95bab458a (diff)
style cleanup: uv editor
Diffstat (limited to 'source/blender/editors/uvedit/uvedit_parametrizer.c')
-rw-r--r--source/blender/editors/uvedit/uvedit_parametrizer.c1044
1 files changed, 523 insertions, 521 deletions
diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c
index 7d388e6206c..d2c711fccf3 100644
--- a/source/blender/editors/uvedit/uvedit_parametrizer.c
+++ b/source/blender/editors/uvedit/uvedit_parametrizer.c
@@ -32,24 +32,23 @@
/* Utils */
#if 0
- #define param_assert(condition);
- #define param_warning(message);
- #define param_test_equals_ptr(condition);
- #define param_test_equals_int(condition);
+ #define param_assert(condition)
+ #define param_warning(message)
+ #define param_test_equals_ptr(condition)
+ #define param_test_equals_int(condition)
#else
#define param_assert(condition) \
if (!(condition)) \
- { /*printf("Assertion %s:%d\n", __FILE__, __LINE__); abort();*/ }
+ { /*printf("Assertion %s:%d\n", __FILE__, __LINE__); abort();*/ } (void)0
#define param_warning(message) \
- { /*printf("Warning %s:%d: %s\n", __FILE__, __LINE__, message);*/ }
+ { /*printf("Warning %s:%d: %s\n", __FILE__, __LINE__, message);*/ } (void)0
#define param_test_equals_ptr(str, a, b) \
if (a != b) \
- { /*printf("Equals %s => %p != %p\n", str, a, b);*/ };
+ { /*printf("Equals %s => %p != %p\n", str, a, b);*/ } (void)0
#define param_test_equals_int(str, a, b) \
if (a != b) \
- { /*printf("Equals %s => %d != %d\n", str, a, b);*/ };
+ { /*printf("Equals %s => %d != %d\n", str, a, b);*/ } (void)0
#endif
-
typedef enum PBool {
P_TRUE = 1,
P_FALSE = 0
@@ -84,10 +83,10 @@ typedef struct PVert {
struct PVert *nextlink;
union PVertUnion {
- PHashKey key; /* construct */
- int id; /* abf/lscm matrix index */
- float distortion; /* area smoothing */
- HeapNode *heaplink; /* edge collapsing */
+ PHashKey key; /* construct */
+ int id; /* abf/lscm matrix index */
+ float distortion; /* area smoothing */
+ HeapNode *heaplink; /* edge collapsing */
} u;
struct PEdge *edge;
@@ -101,10 +100,10 @@ typedef struct PEdge {
struct PEdge *nextlink;
union PEdgeUnion {
- PHashKey key; /* construct */
- int id; /* abf matrix index */
- HeapNode *heaplink; /* fill holes */
- struct PEdge *nextcollapse; /* simplification */
+ PHashKey key; /* construct */
+ int id; /* abf matrix index */
+ HeapNode *heaplink; /* fill holes */
+ struct PEdge *nextcollapse; /* simplification */
} u;
struct PVert *vert;
@@ -120,10 +119,10 @@ typedef struct PFace {
struct PFace *nextlink;
union PFaceUnion {
- PHashKey key; /* construct */
- int chart; /* construct splitting*/
- float area3d; /* stretch */
- int id; /* abf matrix index */
+ PHashKey key; /* construct */
+ int chart; /* construct splitting*/
+ float area3d; /* stretch */
+ int id; /* abf matrix index */
} u;
struct PEdge *edge;
@@ -230,12 +229,12 @@ static int PHashSizes[] = {
4194319, 8388617, 16777259, 33554467, 67108879, 134217757, 268435459
};
-#define PHASH_hash(ph, item) (((uintptr_t) (item))%((unsigned int) (ph)->cursize))
-#define PHASH_edge(v1, v2) ((v1)^(v2))
+#define PHASH_hash(ph, item) (((uintptr_t) (item)) % ((unsigned int) (ph)->cursize))
+#define PHASH_edge(v1, v2) ((v1) ^ (v2))
static PHash *phash_new(PHashLink **list, int sizehint)
{
- PHash *ph = (PHash*)MEM_callocN(sizeof(PHash), "PHash");
+ PHash *ph = (PHash *)MEM_callocN(sizeof(PHash), "PHash");
ph->size = 0;
ph->cursize_id = 0;
ph->list = list;
@@ -244,7 +243,7 @@ static PHash *phash_new(PHashLink **list, int sizehint)
ph->cursize_id++;
ph->cursize = PHashSizes[ph->cursize_id];
- ph->buckets = (PHashLink**)MEM_callocN(ph->cursize*sizeof(*ph->buckets), "PHashBuckets");
+ ph->buckets = (PHashLink **)MEM_callocN(ph->cursize * sizeof(*ph->buckets), "PHashBuckets");
return ph;
}
@@ -280,12 +279,12 @@ static void phash_insert(PHash *ph, PHashLink *link)
ph->size++;
- if (ph->size > (size*3)) {
+ if (ph->size > (size * 3)) {
PHashLink *next = NULL, *first = *(ph->list);
ph->cursize = PHashSizes[++ph->cursize_id];
MEM_freeN(ph->buckets);
- ph->buckets = (PHashLink**)MEM_callocN(ph->cursize*sizeof(*ph->buckets), "PHashBuckets");
+ ph->buckets = (PHashLink **)MEM_callocN(ph->cursize * sizeof(*ph->buckets), "PHashBuckets");
ph->size = 0;
*(ph->list) = NULL;
@@ -340,7 +339,7 @@ static float p_vec_angle_cos(float *v1, float *v2, float *v3)
normalize_v3(d1);
normalize_v3(d2);
- return d1[0]*d2[0] + d1[1]*d2[1] + d1[2]*d2[2];
+ return d1[0] * d2[0] + d1[1] * d2[1] + d1[2] * d2[2];
}
static float p_vec_angle(float *v1, float *v2, float *v3)
@@ -391,8 +390,8 @@ static float p_face_area(PFace *f)
static float p_area_signed(float *v1, float *v2, float *v3)
{
- return 0.5f*(((v2[0] - v1[0])*(v3[1] - v1[1])) -
- ((v3[0] - v1[0])*(v2[1] - v1[1])));
+ return 0.5f * (((v2[0] - v1[0]) * (v3[1] - v1[1])) -
+ ((v3[0] - v1[0]) * (v2[1] - v1[1])));
}
static float p_face_uv_area_signed(PFace *f)
@@ -400,8 +399,8 @@ static float p_face_uv_area_signed(PFace *f)
PEdge *e1 = f->edge, *e2 = e1->next, *e3 = e2->next;
PVert *v1 = e1->vert, *v2 = e2->vert, *v3 = e3->vert;
- return 0.5f*(((v2->uv[0] - v1->uv[0])*(v3->uv[1] - v1->uv[1])) -
- ((v3->uv[0] - v1->uv[0])*(v2->uv[1] - v1->uv[1])));
+ return 0.5f * (((v2->uv[0] - v1->uv[0]) * (v3->uv[1] - v1->uv[1])) -
+ ((v3->uv[0] - v1->uv[0]) * (v2->uv[1] - v1->uv[1])));
}
static float p_edge_length(PEdge *e)
@@ -413,7 +412,7 @@ static float p_edge_length(PEdge *e)
d[1] = v2->co[1] - v1->co[1];
d[2] = v2->co[2] - v1->co[2];
- return sqrt(d[0]*d[0] + d[1]*d[1] + d[2]*d[2]);
+ return sqrt(d[0] * d[0] + d[1] * d[1] + d[2] * d[2]);
}
static float p_edge_uv_length(PEdge *e)
@@ -424,7 +423,7 @@ static float p_edge_uv_length(PEdge *e)
d[0] = v2->uv[0] - v1->uv[0];
d[1] = v2->uv[1] - v1->uv[1];
- return sqrt(d[0]*d[0] + d[1]*d[1]);
+ return sqrt(d[0] * d[0] + d[1] * d[1]);
}
static void p_chart_uv_bbox(PChart *chart, float *minv, float *maxv)
@@ -433,7 +432,7 @@ static void p_chart_uv_bbox(PChart *chart, float *minv, float *maxv)
INIT_MINMAX2(minv, maxv);
- for (v=chart->verts; v; v=v->nextlink) {
+ for (v = chart->verts; v; v = v->nextlink) {
DO_MINMAX2(v->uv, minv, maxv);
}
}
@@ -442,7 +441,7 @@ static void p_chart_uv_scale(PChart *chart, float scale)
{
PVert *v;
- for (v=chart->verts; v; v=v->nextlink) {
+ for (v = chart->verts; v; v = v->nextlink) {
v->uv[0] *= scale;
v->uv[1] *= scale;
}
@@ -452,7 +451,7 @@ static void p_chart_uv_scale_xy(PChart *chart, float x, float y)
{
PVert *v;
- for (v=chart->verts; v; v=v->nextlink) {
+ for (v = chart->verts; v; v = v->nextlink) {
v->uv[0] *= x;
v->uv[1] *= y;
}
@@ -462,7 +461,7 @@ static void p_chart_uv_translate(PChart *chart, float trans[2])
{
PVert *v;
- for (v=chart->verts; v; v=v->nextlink) {
+ for (v = chart->verts; v; v = v->nextlink) {
v->uv[0] += trans[0];
v->uv[1] += trans[1];
}
@@ -472,14 +471,14 @@ static PBool p_intersect_line_2d_dir(float *v1, float *dir1, float *v2, float *d
{
float lmbda, div;
- div= dir2[0]*dir1[1] - dir2[1]*dir1[0];
+ div = dir2[0] * dir1[1] - dir2[1] * dir1[0];
if (div == 0.0f)
return P_FALSE;
- 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];
+ 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];
return P_TRUE;
}
@@ -498,8 +497,8 @@ static PBool p_intersect_line_2d(float *v1, float *v2, float *v3, float *v4, flo
if (!p_intersect_line_2d_dir(v1, dir1, v2, dir2, isect)) {
/* parallel - should never happen in theory for polygon kernel, but
* let's give a point nearby in case things go wrong */
- isect[0] = (v1[0] + v2[0])*0.5f;
- isect[1] = (v1[1] + v2[1])*0.5f;
+ isect[0] = (v1[0] + v2[0]) * 0.5f;
+ isect[1] = (v1[1] + v2[1]) * 0.5f;
return P_FALSE;
}
@@ -516,7 +515,7 @@ static PEdge *p_wheel_edge_next(PEdge *e)
static PEdge *p_wheel_edge_prev(PEdge *e)
{
- return (e->pair)? e->pair->next: NULL;
+ return (e->pair) ? e->pair->next : NULL;
}
static PEdge *p_boundary_edge_next(PEdge *e)
@@ -570,10 +569,10 @@ static void p_chart_topological_sanity_check(PChart *chart)
PVert *v;
PEdge *e;
- for (v=chart->verts; v; v=v->nextlink)
+ for (v = chart->verts; v; v = v->nextlink)
param_test_equals_ptr("v->edge->vert", v, v->edge->vert);
- for (e=chart->edges; e; e=e->nextlink) {
+ for (e = chart->edges; e; e = e->nextlink) {
if (e->pair) {
param_test_equals_ptr("e->pair->pair", e, e->pair->pair);
param_test_equals_ptr("pair->vert", e->vert, e->pair->next->vert);
@@ -600,13 +599,13 @@ static void p_vert_load_pin_select_uvs(PHandle *handle, PVert *v)
v->flag |= PVERT_SELECT;
if (e->flag & PEDGE_PIN) {
- pinuv[0] += e->orig_uv[0]*handle->aspx;
- pinuv[1] += e->orig_uv[1]*handle->aspy;
+ pinuv[0] += e->orig_uv[0] * handle->aspx;
+ pinuv[1] += e->orig_uv[1] * handle->aspy;
npins++;
}
else {
- v->uv[0] += e->orig_uv[0]*handle->aspx;
- v->uv[1] += e->orig_uv[1]*handle->aspy;
+ v->uv[0] += e->orig_uv[0] * handle->aspx;
+ v->uv[1] += e->orig_uv[1] * handle->aspy;
}
nedges++;
@@ -616,8 +615,8 @@ static void p_vert_load_pin_select_uvs(PHandle *handle, PVert *v)
} while (e && e != (v->edge));
if (npins > 0) {
- v->uv[0] = pinuv[0]/npins;
- v->uv[1] = pinuv[1]/npins;
+ v->uv[0] = pinuv[0] / npins;
+ v->uv[1] = pinuv[1] / npins;
v->flag |= PVERT_PIN;
}
else if (nedges > 0) {
@@ -630,10 +629,10 @@ static void p_flush_uvs(PHandle *handle, PChart *chart)
{
PEdge *e;
- for (e=chart->edges; e; e=e->nextlink) {
+ for (e = chart->edges; e; e = e->nextlink) {
if (e->orig_uv) {
- e->orig_uv[0] = e->vert->uv[0]/handle->aspx;
- e->orig_uv[1] = e->vert->uv[1]/handle->aspy;
+ e->orig_uv[0] = e->vert->uv[0] / handle->aspx;
+ e->orig_uv[1] = e->vert->uv[1] / handle->aspy;
}
}
}
@@ -643,10 +642,10 @@ static void p_flush_uvs_blend(PHandle *handle, PChart *chart, float blend)
PEdge *e;
float invblend = 1.0f - blend;
- for (e=chart->edges; e; e=e->nextlink) {
+ for (e = chart->edges; e; e = e->nextlink) {
if (e->orig_uv) {
- e->orig_uv[0] = blend*e->old_uv[0] + invblend*e->vert->uv[0]/handle->aspx;
- e->orig_uv[1] = blend*e->old_uv[1] + invblend*e->vert->uv[1]/handle->aspy;
+ e->orig_uv[0] = blend * e->old_uv[0] + invblend * e->vert->uv[0] / handle->aspx;
+ e->orig_uv[1] = blend * e->old_uv[1] + invblend * e->vert->uv[1] / handle->aspy;
}
}
}
@@ -691,20 +690,20 @@ static void p_face_restore_uvs(PFace *f)
static PVert *p_vert_add(PHandle *handle, PHashKey key, float *co, PEdge *e)
{
- PVert *v = (PVert*)BLI_memarena_alloc(handle->arena, sizeof *v);
+ PVert *v = (PVert *)BLI_memarena_alloc(handle->arena, sizeof *v);
copy_v3_v3(v->co, co);
v->u.key = key;
v->edge = e;
v->flag = 0;
- phash_insert(handle->hash_verts, (PHashLink*)v);
+ phash_insert(handle->hash_verts, (PHashLink *)v);
return v;
}
static PVert *p_vert_lookup(PHandle *handle, PHashKey key, float *co, PEdge *e)
{
- PVert *v = (PVert*)phash_lookup(handle->hash_verts, key);
+ PVert *v = (PVert *)phash_lookup(handle->hash_verts, key);
if (v)
return v;
@@ -714,7 +713,7 @@ static PVert *p_vert_lookup(PHandle *handle, PHashKey key, float *co, PEdge *e)
static PVert *p_vert_copy(PChart *chart, PVert *v)
{
- PVert *nv = (PVert*)BLI_memarena_alloc(chart->handle->arena, sizeof *nv);
+ PVert *nv = (PVert *)BLI_memarena_alloc(chart->handle->arena, sizeof *nv);
copy_v3_v3(nv->co, v->co);
nv->uv[0] = v->uv[0];
@@ -729,7 +728,7 @@ static PVert *p_vert_copy(PChart *chart, PVert *v)
static PEdge *p_edge_lookup(PHandle *handle, PHashKey *vkeys)
{
PHashKey key = PHASH_edge(vkeys[0], vkeys[1]);
- PEdge *e = (PEdge*)phash_lookup(handle->hash_edges, key);
+ PEdge *e = (PEdge *)phash_lookup(handle->hash_edges, key);
while (e) {
if ((e->vert->u.key == vkeys[0]) && (e->next->vert->u.key == vkeys[1]))
@@ -737,7 +736,7 @@ static PEdge *p_edge_lookup(PHandle *handle, PHashKey *vkeys)
else if ((e->vert->u.key == vkeys[1]) && (e->next->vert->u.key == vkeys[0]))
return e;
- e = (PEdge*)phash_next(handle->hash_edges, key, (PHashLink*)e);
+ e = (PEdge *)phash_next(handle->hash_edges, key, (PHashLink *)e);
}
return NULL;
@@ -745,10 +744,10 @@ static PEdge *p_edge_lookup(PHandle *handle, PHashKey *vkeys)
int p_face_exists(ParamHandle *phandle, ParamKey *pvkeys, int i1, int i2, int i3)
{
- PHandle *handle = (PHandle*)phandle;
- PHashKey *vkeys = (PHashKey*)pvkeys;
+ PHandle *handle = (PHandle *)phandle;
+ PHashKey *vkeys = (PHashKey *)pvkeys;
PHashKey key = PHASH_edge(vkeys[i1], vkeys[i2]);
- PEdge *e = (PEdge*)phash_lookup(handle->hash_edges, key);
+ PEdge *e = (PEdge *)phash_lookup(handle->hash_edges, key);
while (e) {
if ((e->vert->u.key == vkeys[i1]) && (e->next->vert->u.key == vkeys[i2])) {
@@ -760,7 +759,7 @@ int p_face_exists(ParamHandle *phandle, ParamKey *pvkeys, int i1, int i2, int i3
return P_TRUE;
}
- e = (PEdge*)phash_next(handle->hash_edges, key, (PHashLink*)e);
+ e = (PEdge *)phash_next(handle->hash_edges, key, (PHashLink *)e);
}
return P_FALSE;
@@ -768,7 +767,7 @@ int p_face_exists(ParamHandle *phandle, ParamKey *pvkeys, int i1, int i2, int i3
static PChart *p_chart_new(PHandle *handle)
{
- PChart *chart = (PChart*)MEM_callocN(sizeof*chart, "PChart");
+ PChart *chart = (PChart *)MEM_callocN(sizeof *chart, "PChart");
chart->handle = handle;
return chart;
@@ -800,12 +799,12 @@ static PBool p_edge_implicit_seam(PEdge *e, PEdge *ep)
uvp2 = ep->orig_uv;
}
- if ((fabsf(uv1[0]-uvp1[0]) > limit[0]) || (fabsf(uv1[1]-uvp1[1]) > limit[1])) {
+ if ((fabsf(uv1[0] - uvp1[0]) > limit[0]) || (fabsf(uv1[1] - uvp1[1]) > limit[1])) {
e->flag |= PEDGE_SEAM;
ep->flag |= PEDGE_SEAM;
return P_TRUE;
}
- if ((fabsf(uv2[0]-uvp2[0]) > limit[0]) || (fabsf(uv2[1]-uvp2[1]) > limit[1])) {
+ if ((fabsf(uv2[0] - uvp2[0]) > limit[0]) || (fabsf(uv2[1] - uvp2[1]) > limit[1])) {
e->flag |= PEDGE_SEAM;
ep->flag |= PEDGE_SEAM;
return P_TRUE;
@@ -826,7 +825,7 @@ static PBool p_edge_has_pair(PHandle *handle, PEdge *e, PEdge **pair, PBool impl
return P_FALSE;
key = PHASH_edge(key1, key2);
- pe = (PEdge*)phash_lookup(handle->hash_edges, key);
+ pe = (PEdge *)phash_lookup(handle->hash_edges, key);
*pair = NULL;
while (pe) {
@@ -835,11 +834,13 @@ static PBool p_edge_has_pair(PHandle *handle, PEdge *e, PEdge **pair, PBool impl
v2 = pe->next->vert;
if (((v1->u.key == key1) && (v2->u.key == key2)) ||
- ((v1->u.key == key2) && (v2->u.key == key1))) {
+ ((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))) {
+ (impl && p_edge_implicit_seam(e, pe)))
+ {
*pair = NULL;
return P_FALSE;
}
@@ -848,7 +849,7 @@ static PBool p_edge_has_pair(PHandle *handle, PEdge *e, PEdge **pair, PBool impl
}
}
- pe = (PEdge*)phash_next(handle->hash_edges, key, (PHashLink*)pe);
+ pe = (PEdge *)phash_next(handle->hash_edges, key, (PHashLink *)pe);
}
if (*pair && (e->vert == (*pair)->vert)) {
@@ -884,7 +885,7 @@ static PBool p_edge_connect_pair(PHandle *handle, PEdge *e, PEdge ***stack, PBoo
static int p_connect_pairs(PHandle *handle, PBool impl)
{
- PEdge **stackbase = MEM_mallocN(sizeof*stackbase*phash_size(handle->hash_faces), "Pstackbase");
+ PEdge **stackbase = MEM_mallocN(sizeof *stackbase * phash_size(handle->hash_faces), "Pstackbase");
PEdge **stack = stackbase;
PFace *f, *first;
PEdge *e, *e1, *e2;
@@ -892,7 +893,7 @@ static int p_connect_pairs(PHandle *handle, PBool impl)
int ncharts = 0;
/* connect pairs, count edges, set vertex-edge pointer to a pairless edge */
- for (first=chart->faces; first; first=first->nextlink) {
+ for (first = chart->faces; first; first = first->nextlink) {
if (first->flag & PFACE_CONNECTED)
continue;
@@ -979,7 +980,7 @@ static void p_split_vert(PChart *chart, PEdge *e)
static PChart **p_split_charts(PHandle *handle, PChart *chart, int ncharts)
{
- PChart **charts = MEM_mallocN(sizeof*charts * ncharts, "PCharts"), *nchart;
+ PChart **charts = MEM_mallocN(sizeof *charts * ncharts, "PCharts"), *nchart;
PFace *f, *nextf;
int i;
@@ -1021,12 +1022,12 @@ static PFace *p_face_add(PHandle *handle)
PEdge *e1, *e2, *e3;
/* allocate */
- f = (PFace*)BLI_memarena_alloc(handle->arena, sizeof *f);
- f->flag=0; // init !
+ f = (PFace *)BLI_memarena_alloc(handle->arena, sizeof *f);
+ f->flag = 0; // init !
- e1 = (PEdge*)BLI_memarena_alloc(handle->arena, sizeof *e1);
- e2 = (PEdge*)BLI_memarena_alloc(handle->arena, sizeof *e2);
- e3 = (PEdge*)BLI_memarena_alloc(handle->arena, sizeof *e3);
+ e1 = (PEdge *)BLI_memarena_alloc(handle->arena, sizeof *e1);
+ e2 = (PEdge *)BLI_memarena_alloc(handle->arena, sizeof *e2);
+ e3 = (PEdge *)BLI_memarena_alloc(handle->arena, sizeof *e3);
/* set up edges */
f->edge = e1;
@@ -1040,16 +1041,16 @@ static PFace *p_face_add(PHandle *handle)
e2->pair = NULL;
e3->pair = NULL;
- e1->flag =0;
- e2->flag =0;
- e3->flag =0;
+ e1->flag = 0;
+ e2->flag = 0;
+ e3->flag = 0;
return f;
}
static PFace *p_face_add_construct(PHandle *handle, ParamKey key, ParamKey *vkeys,
- float *co[3], float *uv[3], int i1, int i2, int i3,
- ParamBool *pin, ParamBool *select)
+ float *co[3], float *uv[3], int i1, int i2, int i3,
+ ParamBool *pin, ParamBool *select)
{
PFace *f = p_face_add(handle);
PEdge *e1 = f->edge, *e2 = e1->next, *e3 = e2->next;
@@ -1076,15 +1077,15 @@ static PFace *p_face_add_construct(PHandle *handle, ParamKey key, ParamKey *vkey
/* insert into hash */
f->u.key = key;
- phash_insert(handle->hash_faces, (PHashLink*)f);
+ phash_insert(handle->hash_faces, (PHashLink *)f);
e1->u.key = PHASH_edge(vkeys[i1], vkeys[i2]);
e2->u.key = PHASH_edge(vkeys[i2], vkeys[i3]);
e3->u.key = PHASH_edge(vkeys[i3], vkeys[i1]);
- phash_insert(handle->hash_edges, (PHashLink*)e1);
- phash_insert(handle->hash_edges, (PHashLink*)e2);
- phash_insert(handle->hash_edges, (PHashLink*)e3);
+ phash_insert(handle->hash_edges, (PHashLink *)e1);
+ phash_insert(handle->hash_edges, (PHashLink *)e2);
+ phash_insert(handle->hash_edges, (PHashLink *)e3);
return f;
}
@@ -1117,7 +1118,7 @@ static PFace *p_face_add_fill(PChart *chart, PVert *v1, PVert *v2, PVert *v3)
static PBool p_quad_split_direction(PHandle *handle, float **co, PHashKey *vkeys)
{
- float fac= len_v3v3(co[0], co[2]) - len_v3v3(co[1], co[3]);
+ float fac = len_v3v3(co[0], co[2]) - len_v3v3(co[1], co[3]);
PBool dir = (fac <= 0.0f);
/* the face exists check is there because of a special case: when
@@ -1125,11 +1126,11 @@ static PBool p_quad_split_direction(PHandle *handle, float **co, PHashKey *vkeys
* triangles, resulting in two identical triangles. for example in
* suzanne's nose. */
if (dir) {
- if (p_face_exists(handle,vkeys,0,1,2) || p_face_exists(handle,vkeys,0,2,3))
+ if (p_face_exists(handle, vkeys, 0, 1, 2) || p_face_exists(handle, vkeys, 0, 2, 3))
return !dir;
}
else {
- if (p_face_exists(handle,vkeys,0,1,3) || p_face_exists(handle,vkeys,1,2,3))
+ if (p_face_exists(handle, vkeys, 0, 1, 3) || p_face_exists(handle, vkeys, 1, 2, 3))
return !dir;
}
@@ -1148,7 +1149,7 @@ static void p_chart_boundaries(PChart *chart, int *nboundaries, PEdge **outer)
if (outer)
*outer = NULL;
- for (e=chart->edges; e; e=e->nextlink) {
+ for (e = chart->edges; e; e = e->nextlink) {
if (e->pair || (e->flag & PEDGE_DONE))
continue;
@@ -1170,7 +1171,7 @@ static void p_chart_boundaries(PChart *chart, int *nboundaries, PEdge **outer)
}
}
- for (e=chart->edges; e; e=e->nextlink)
+ for (e = chart->edges; e; e = e->nextlink)
e->flag &= ~PEDGE_DONE;
}
@@ -1228,7 +1229,7 @@ static void p_chart_fill_boundary(PChart *chart, PEdge *be, int nedges)
while (nedges > 2) {
PEdge *ne, *ne1, *ne2;
- e = (PEdge*)BLI_heap_popmin(heap);
+ e = (PEdge *)BLI_heap_popmin(heap);
e1 = p_boundary_edge_prev(e);
e2 = p_boundary_edge_next(e);
@@ -1285,7 +1286,7 @@ static void p_chart_fill_boundaries(PChart *chart, PEdge *outer)
PEdge *e, *be; /* *enext - as yet unused */
int nedges;
- for (e=chart->edges; e; e=e->nextlink) {
+ for (e = chart->edges; e; e = e->nextlink) {
/* enext = e->nextlink; - as yet unused */
if (e->pair || (e->flag & PEDGE_FILLED))
@@ -1322,7 +1323,7 @@ static void p_polygon_kernel_clip(float (*oldpoints)[2], int noldpoints, float (
float *p2, *p1, isect[2];
int i, p2in, p1in;
- p1 = oldpoints[noldpoints-1];
+ p1 = oldpoints[noldpoints - 1];
p1in = p_polygon_point_in(cp1, cp2, p1);
*nnewpoints = 0;
@@ -1364,20 +1365,20 @@ static void p_polygon_kernel_center(float (*points)[2], int npoints, float *cent
int i, size, nnewpoints = npoints;
float (*oldpoints)[2], (*newpoints)[2], *p1, *p2;
- size = npoints*3;
- oldpoints = MEM_mallocN(sizeof(float)*2*size, "PPolygonOldPoints");
- newpoints = MEM_mallocN(sizeof(float)*2*size, "PPolygonNewPoints");
+ size = npoints * 3;
+ oldpoints = MEM_mallocN(sizeof(float) * 2 * size, "PPolygonOldPoints");
+ newpoints = MEM_mallocN(sizeof(float) * 2 * size, "PPolygonNewPoints");
- memcpy(oldpoints, points, sizeof(float)*2*npoints);
+ memcpy(oldpoints, points, sizeof(float) * 2 * npoints);
for (i = 0; i < npoints; i++) {
p1 = points[i];
- p2 = points[(i+1)%npoints];
+ p2 = points[(i + 1) % npoints];
p_polygon_kernel_clip(oldpoints, nnewpoints, newpoints, &nnewpoints, p1, p2);
if (nnewpoints == 0) {
/* degenerate case, use center of original polygon */
- memcpy(oldpoints, points, sizeof(float)*2*npoints);
+ memcpy(oldpoints, points, sizeof(float) * 2 * npoints);
nnewpoints = npoints;
break;
}
@@ -1392,13 +1393,13 @@ static void p_polygon_kernel_center(float (*points)[2], int npoints, float *cent
return;
}
- if (nnewpoints*2 > size) {
+ if (nnewpoints * 2 > size) {
size *= 2;
MEM_freeN(oldpoints);
- oldpoints = MEM_mallocN(sizeof(float)*2*size, "oldpoints");
- memcpy(oldpoints, newpoints, sizeof(float)*2*nnewpoints);
+ oldpoints = MEM_mallocN(sizeof(float) * 2 * size, "oldpoints");
+ memcpy(oldpoints, newpoints, sizeof(float) * 2 * nnewpoints);
MEM_freeN(newpoints);
- newpoints = MEM_mallocN(sizeof(float)*2*size, "newpoints");
+ newpoints = MEM_mallocN(sizeof(float) * 2 * size, "newpoints");
}
else {
float (*sw_points)[2] = oldpoints;
@@ -1441,7 +1442,7 @@ static float p_vert_cotan(float *v1, float *v2, float *v3)
if (clen == 0.0f)
return 0.0f;
- return dot_v3v3(a, b)/clen;
+ return dot_v3v3(a, b) / clen;
}
static PBool p_vert_flipped_wheel_triangle(PVert *v)
@@ -1480,10 +1481,10 @@ static PBool p_vert_map_harmonic_weights(PVert *v)
v2 = e->pair->next->next->vert;
t2 = p_vert_cotan(v2->co, e->pair->vert->co, v1->co);
- weight = 0.5f*(t1 + t2);
+ weight = 0.5f * (t1 + t2);
weightsum += weight;
- positionsum[0] += weight*e->pair->vert->uv[0];
- positionsum[1] += weight*e->pair->vert->uv[1];
+ positionsum[0] += weight * e->pair->vert->uv[0];
+ positionsum[1] += weight * e->pair->vert->uv[1];
e = p_wheel_edge_next(e);
} while (e && (e != v->edge));
@@ -1502,15 +1503,15 @@ static PBool p_vert_map_harmonic_weights(PVert *v)
t2 = p_vert_cotan(v2->co, v->co, v1->co);
weightsum += t1 + t2;
- positionsum[0] += (v2->uv[1] - v1->uv[1]) + (t1*v2->uv[0] + t2*v1->uv[0]);
- positionsum[1] += (v1->uv[0] - v2->uv[0]) + (t1*v2->uv[1] + t2*v1->uv[1]);
+ positionsum[0] += (v2->uv[1] - v1->uv[1]) + (t1 * v2->uv[0] + t2 * v1->uv[0]);
+ positionsum[1] += (v1->uv[0] - v2->uv[0]) + (t1 * v2->uv[1] + t2 * v1->uv[1]);
e = p_wheel_edge_next(e);
} while (e && (e != v->edge));
}
if (weightsum != 0.0f) {
- weightsum = 1.0f/weightsum;
+ weightsum = 1.0f / weightsum;
positionsum[0] *= weightsum;
positionsum[1] *= weightsum;
}
@@ -1551,7 +1552,7 @@ static void p_vert_harmonic_insert(PVert *v)
if (e == NULL)
npoints++;
- points = MEM_mallocN(sizeof(float)*2*npoints, "PHarmonicPoints");
+ points = MEM_mallocN(sizeof(float) * 2 * npoints, "PHarmonicPoints");
e = v->edge;
i = 0;
@@ -1789,7 +1790,7 @@ static PBool p_collapse_allowed_geometric(PEdge *edge, PEdge *pair)
p_collapsing_verts(edge, pair, &oldv, &keepv);
- angulardefect = 2*M_PI;
+ angulardefect = 2 * M_PI;
e = oldv->edge;
do {
@@ -1819,7 +1820,7 @@ static PBool p_collapse_allowed_geometric(PEdge *edge, PEdge *pair)
b[2] = M_PI - b[0] - b[1];
/* abf criterion 1: avoid sharp and obtuse angles */
- minangle = 15.0f*M_PI/180.0f;
+ minangle = 15.0f * M_PI / 180.0f;
maxangle = M_PI - minangle;
for (i = 0; i < 3; i++) {
@@ -1834,7 +1835,7 @@ static PBool p_collapse_allowed_geometric(PEdge *edge, PEdge *pair)
if (p_vert_interior(oldv)) {
/* hlscm criterion: angular defect smaller than threshold */
- if (fabs(angulardefect) > (M_PI*30.0/180.0))
+ if (fabs(angulardefect) > (M_PI * 30.0 / 180.0))
return P_FALSE;
}
else {
@@ -1847,7 +1848,7 @@ static PBool p_collapse_allowed_geometric(PEdge *edge, PEdge *pair)
/* don't collapse significant boundary changes */
angle = p_vec_angle(v1->co, oldv->co, v2->co);
- if (angle < (M_PI*160.0/180.0))
+ if (angle < (M_PI * 160.0 / 180.0))
return P_FALSE;
}
@@ -1864,7 +1865,7 @@ static PBool p_collapse_allowed(PEdge *edge, PEdge *pair)
return P_FALSE;
return (p_collapse_allowed_topologic(edge, pair) &&
- p_collapse_allowed_geometric(edge, pair));
+ p_collapse_allowed_geometric(edge, pair));
}
static float p_collapse_cost(PEdge *edge, PEdge *pair)
@@ -1881,8 +1882,8 @@ static float p_collapse_cost(PEdge *edge, PEdge *pair)
int nshapeold = 0, nshapenew = 0;
p_collapsing_verts(edge, pair, &oldv, &keepv);
- oldf1 = (edge)? edge->face: NULL;
- oldf2 = (pair)? pair->face: NULL;
+ oldf1 = (edge) ? edge->face : NULL;
+ oldf2 = (pair) ? pair->face : NULL;
sub_v3_v3v3(edgevec, keepv->co, oldv->co);
@@ -1900,7 +1901,7 @@ static float p_collapse_cost(PEdge *edge, PEdge *pair)
sub_v3_v3v3(tetrav3, co2, oldv->co);
cross_v3_v3v3(c, tetrav2, tetrav3);
- volumecost += fabs(dot_v3v3(edgevec, c)/6.0f);
+ volumecost += fabs(dot_v3v3(edgevec, c) / 6.0f);
#if 0
shapecost += dot_v3v3(co1, keepv->co);
@@ -1909,19 +1910,19 @@ static float p_collapse_cost(PEdge *edge, PEdge *pair)
#endif
p_triangle_angles(oldv->co, co1, co2, &a1, &a2, &a3);
- a1 = a1 - M_PI/3.0;
- a2 = a2 - M_PI/3.0;
- a3 = a3 - M_PI/3.0;
- shapeold = (a1*a1 + a2*a2 + a3*a3)/((M_PI/2)*(M_PI/2));
+ a1 = a1 - M_PI / 3.0;
+ a2 = a2 - M_PI / 3.0;
+ a3 = a3 - M_PI / 3.0;
+ shapeold = (a1 * a1 + a2 * a2 + a3 * a3) / ((M_PI / 2) * (M_PI / 2));
nshapeold++;
}
else {
p_triangle_angles(keepv->co, co1, co2, &a1, &a2, &a3);
- a1 = a1 - M_PI/3.0;
- a2 = a2 - M_PI/3.0;
- a3 = a3 - M_PI/3.0;
- shapenew = (a1*a1 + a2*a2 + a3*a3)/((M_PI/2)*(M_PI/2));
+ a1 = a1 - M_PI / 3.0;
+ a2 = a2 - M_PI / 3.0;
+ a3 = a3 - M_PI / 3.0;
+ shapenew = (a1 * a1 + a2 * a2 + a3 * a3) / ((M_PI / 2) * (M_PI / 2));
nshapenew++;
}
@@ -1938,13 +1939,13 @@ static float p_collapse_cost(PEdge *edge, PEdge *pair)
elen = len_v3(edgevec);
weight = 1.0f; /* 0.2f */
- cost = weight*volumecost*volumecost + elen*elen*areacost*areacost;
+ cost = weight * volumecost * volumecost + elen * elen * areacost * areacost;
#if 0
cost += shapecost;
#else
shapeold /= nshapeold;
shapenew /= nshapenew;
- shapecost = (shapeold + 0.00001)/(shapenew + 0.00001);
+ shapecost = (shapeold + 0.00001) / (shapenew + 0.00001);
cost *= shapecost;
#endif
@@ -2005,7 +2006,7 @@ static void p_chart_post_collapse_flush(PChart *chart, PEdge *collapsed)
chart->nverts = chart->nedges = chart->nfaces = 0;
- for (v=verts; v; v=nextv) {
+ for (v = verts; v; v = nextv) {
nextv = v->nextlink;
if (v->flag & PVERT_COLLAPSE) {
@@ -2019,7 +2020,7 @@ static void p_chart_post_collapse_flush(PChart *chart, PEdge *collapsed)
}
}
- for (e=edges; e; e=nexte) {
+ for (e = edges; e; e = nexte) {
nexte = e->nextlink;
if (!collapsed || !(e->flag & PEDGE_COLLAPSE_EDGE)) {
@@ -2037,7 +2038,7 @@ static void p_chart_post_collapse_flush(PChart *chart, PEdge *collapsed)
/* these are added last so they can be popped of in the right order
* for splitting */
- for (e=collapsed; e; e=e->nextlink) {
+ for (e = collapsed; e; e = e->nextlink) {
e->nextlink = e->u.nextcollapse;
laste = e;
}
@@ -2046,7 +2047,7 @@ static void p_chart_post_collapse_flush(PChart *chart, PEdge *collapsed)
chart->collapsed_edges = collapsed;
}
- for (f=faces; f; f=nextf) {
+ for (f = faces; f; f = nextf) {
nextf = f->nextlink;
if (f->flag & PFACE_COLLAPSE) {
@@ -2069,21 +2070,21 @@ static void p_chart_post_split_flush(PChart *chart)
PEdge *e, *nexte = NULL;
PFace *f, *nextf = NULL;
- for (v=chart->collapsed_verts; v; v=nextv) {
+ for (v = chart->collapsed_verts; v; v = nextv) {
nextv = v->nextlink;
v->nextlink = chart->verts;
chart->verts = v;
chart->nverts++;
}
- for (e=chart->collapsed_edges; e; e=nexte) {
+ for (e = chart->collapsed_edges; e; e = nexte) {
nexte = e->nextlink;
e->nextlink = chart->edges;
chart->edges = e;
chart->nedges++;
}
- for (f=chart->collapsed_faces; f; f=nextf) {
+ for (f = chart->collapsed_faces; f; f = nextf) {
nextf = f->nextlink;
f->nextlink = chart->faces;
chart->faces = f;
@@ -2107,10 +2108,10 @@ static void p_chart_simplify_compute(PChart *chart)
PEdge *collapsededges = NULL, *e;
int nwheelverts, i, ncollapsed = 0;
- wheelverts = MEM_mallocN(sizeof(PVert*)*chart->nverts, "PChartWheelVerts");
+ wheelverts = MEM_mallocN(sizeof(PVert *) * chart->nverts, "PChartWheelVerts");
/* insert all potential collapses into heap */
- for (v=chart->verts; v; v=v->nextlink) {
+ for (v = chart->verts; v; v = v->nextlink) {
float cost;
PEdge *e = NULL;
@@ -2122,7 +2123,7 @@ static void p_chart_simplify_compute(PChart *chart)
v->u.heaplink = NULL;
}
- for (e=chart->edges; e; e=e->nextlink)
+ for (e = chart->edges; e; e = e->nextlink)
e->u.nextcollapse = NULL;
/* pop edge collapse out of heap one by one */
@@ -2131,7 +2132,7 @@ static void p_chart_simplify_compute(PChart *chart)
break;
HeapNode *link = BLI_heap_top(heap);
- PEdge *edge = (PEdge*)BLI_heap_popmin(heap), *pair = edge->pair;
+ PEdge *edge = (PEdge *)BLI_heap_popmin(heap), *pair = edge->pair;
PVert *oldv, *keepv;
PEdge *wheele, *nexte;
@@ -2140,9 +2141,9 @@ static void p_chart_simplify_compute(PChart *chart)
collapsededges = edge;
if (edge->vert->u.heaplink != link) {
- edge->flag |= (PEDGE_COLLAPSE_EDGE|PEDGE_COLLAPSE_PAIR);
+ edge->flag |= (PEDGE_COLLAPSE_EDGE | PEDGE_COLLAPSE_PAIR);
edge->next->vert->u.heaplink = NULL;
- SWAP(PEdge*, edge, pair);
+ SWAP(PEdge *, edge, pair);
}
else {
edge->flag |= PEDGE_COLLAPSE_EDGE;
@@ -2200,7 +2201,7 @@ static void p_chart_complexify(PChart *chart)
PVert *newv, *keepv;
int x = 0;
- for (e=chart->collapsed_edges; e; e=e->nextlink) {
+ for (e = chart->collapsed_edges; e; e = e->nextlink) {
if (!(e->flag & PEDGE_COLLAPSE_EDGE))
break;
@@ -2208,7 +2209,7 @@ static void p_chart_complexify(PChart *chart)
pair = e->pair;
if (edge->flag & PEDGE_COLLAPSE_PAIR) {
- SWAP(PEdge*, edge, pair);
+ SWAP(PEdge *, edge, pair);
}
p_split_vertex(edge, pair);
@@ -2252,28 +2253,28 @@ static void p_abf_setup_system(PAbfSystem *sys)
{
int i;
- sys->alpha = (float*)MEM_mallocN(sizeof(float)*sys->nangles, "ABFalpha");
- sys->beta = (float*)MEM_mallocN(sizeof(float)*sys->nangles, "ABFbeta");
- sys->sine = (float*)MEM_mallocN(sizeof(float)*sys->nangles, "ABFsine");
- sys->cosine = (float*)MEM_mallocN(sizeof(float)*sys->nangles, "ABFcosine");
- sys->weight = (float*)MEM_mallocN(sizeof(float)*sys->nangles, "ABFweight");
+ sys->alpha = (float *)MEM_mallocN(sizeof(float) * sys->nangles, "ABFalpha");
+ sys->beta = (float *)MEM_mallocN(sizeof(float) * sys->nangles, "ABFbeta");
+ sys->sine = (float *)MEM_mallocN(sizeof(float) * sys->nangles, "ABFsine");
+ sys->cosine = (float *)MEM_mallocN(sizeof(float) * sys->nangles, "ABFcosine");
+ sys->weight = (float *)MEM_mallocN(sizeof(float) * sys->nangles, "ABFweight");
- sys->bAlpha = (float*)MEM_mallocN(sizeof(float)*sys->nangles, "ABFbalpha");
- sys->bTriangle = (float*)MEM_mallocN(sizeof(float)*sys->nfaces, "ABFbtriangle");
- sys->bInterior = (float*)MEM_mallocN(sizeof(float)*2*sys->ninterior, "ABFbinterior");
+ sys->bAlpha = (float *)MEM_mallocN(sizeof(float) * sys->nangles, "ABFbalpha");
+ sys->bTriangle = (float *)MEM_mallocN(sizeof(float) * sys->nfaces, "ABFbtriangle");
+ sys->bInterior = (float *)MEM_mallocN(sizeof(float) * 2 * sys->ninterior, "ABFbinterior");
- sys->lambdaTriangle = (float*)MEM_callocN(sizeof(float)*sys->nfaces, "ABFlambdatri");
- sys->lambdaPlanar = (float*)MEM_callocN(sizeof(float)*sys->ninterior, "ABFlamdaplane");
- sys->lambdaLength = (float*)MEM_mallocN(sizeof(float)*sys->ninterior, "ABFlambdalen");
+ sys->lambdaTriangle = (float *)MEM_callocN(sizeof(float) * sys->nfaces, "ABFlambdatri");
+ sys->lambdaPlanar = (float *)MEM_callocN(sizeof(float) * sys->ninterior, "ABFlamdaplane");
+ sys->lambdaLength = (float *)MEM_mallocN(sizeof(float) * sys->ninterior, "ABFlambdalen");
- sys->J2dt = MEM_mallocN(sizeof(float)*sys->nangles*3, "ABFj2dt");
- sys->bstar = (float*)MEM_mallocN(sizeof(float)*sys->nfaces, "ABFbstar");
- sys->dstar = (float*)MEM_mallocN(sizeof(float)*sys->nfaces, "ABFdstar");
+ sys->J2dt = MEM_mallocN(sizeof(float) * sys->nangles * 3, "ABFj2dt");
+ sys->bstar = (float *)MEM_mallocN(sizeof(float) * sys->nfaces, "ABFbstar");
+ sys->dstar = (float *)MEM_mallocN(sizeof(float) * sys->nfaces, "ABFdstar");
for (i = 0; i < sys->ninterior; i++)
sys->lambdaLength[i] = 1.0;
- sys->minangle = 7.5*M_PI/180.0;
+ sys->minangle = 7.5 * M_PI / 180.0;
sys->maxangle = (float)M_PI - sys->minangle;
}
@@ -2346,7 +2347,7 @@ static float p_abf_compute_grad_alpha(PAbfSystem *sys, PFace *f, PEdge *e)
PVert *v = e->vert, *v1 = e->next->vert, *v2 = e->next->next->vert;
float deriv;
- deriv = (sys->alpha[e->u.id] - sys->beta[e->u.id])*sys->weight[e->u.id];
+ deriv = (sys->alpha[e->u.id] - sys->beta[e->u.id]) * sys->weight[e->u.id];
deriv += sys->lambdaTriangle[f->u.id];
if (v->flag & PVERT_INTERIOR) {
@@ -2355,12 +2356,12 @@ static float p_abf_compute_grad_alpha(PAbfSystem *sys, PFace *f, PEdge *e)
if (v1->flag & PVERT_INTERIOR) {
float product = p_abf_compute_sin_product(sys, v1, e->u.id);
- deriv += sys->lambdaLength[v1->u.id]*product;
+ deriv += sys->lambdaLength[v1->u.id] * product;
}
if (v2->flag & PVERT_INTERIOR) {
float product = p_abf_compute_sin_product(sys, v2, e->u.id);
- deriv += sys->lambdaLength[v2->u.id]*product;
+ deriv += sys->lambdaLength[v2->u.id] * product;
}
return deriv;
@@ -2373,7 +2374,7 @@ static float p_abf_compute_gradient(PAbfSystem *sys, PChart *chart)
PVert *v;
float norm = 0.0;
- for (f=chart->faces; f; f=f->nextlink) {
+ for (f = chart->faces; f; f = f->nextlink) {
PEdge *e1 = f->edge, *e2 = e1->next, *e3 = e2->next;
float gtriangle, galpha1, galpha2, galpha3;
@@ -2385,16 +2386,16 @@ static float p_abf_compute_gradient(PAbfSystem *sys, PChart *chart)
sys->bAlpha[e2->u.id] = -galpha2;
sys->bAlpha[e3->u.id] = -galpha3;
- norm += galpha1*galpha1 + galpha2*galpha2 + galpha3*galpha3;
+ norm += galpha1 * galpha1 + galpha2 * galpha2 + galpha3 * galpha3;
gtriangle = sys->alpha[e1->u.id] + sys->alpha[e2->u.id] + sys->alpha[e3->u.id] - (float)M_PI;
sys->bTriangle[f->u.id] = -gtriangle;
- norm += gtriangle*gtriangle;
+ norm += gtriangle * gtriangle;
}
- for (v=chart->verts; v; v=v->nextlink) {
+ for (v = chart->verts; v; v = v->nextlink) {
if (v->flag & PVERT_INTERIOR) {
- float gplanar = -2*M_PI, glength;
+ float gplanar = -2 * M_PI, glength;
e = v->edge;
do {
@@ -2403,11 +2404,11 @@ static float p_abf_compute_gradient(PAbfSystem *sys, PChart *chart)
} while (e && (e != v->edge));
sys->bInterior[v->u.id] = -gplanar;
- norm += gplanar*gplanar;
+ norm += gplanar * gplanar;
glength = p_abf_compute_sin_product(sys, v, -1);
sys->bInterior[sys->ninterior + v->u.id] = -glength;
- norm += glength*glength;
+ norm += glength * glength;
}
}
@@ -2418,7 +2419,7 @@ static PBool p_abf_matrix_invert(PAbfSystem *sys, PChart *chart)
{
PFace *f;
PEdge *e;
- int i, j, ninterior = sys->ninterior, nvar = 2*sys->ninterior;
+ int i, j, ninterior = sys->ninterior, nvar = 2 * sys->ninterior;
PBool success;
nlNewContext();
@@ -2431,30 +2432,30 @@ static PBool p_abf_matrix_invert(PAbfSystem *sys, PChart *chart)
for (i = 0; i < nvar; i++)
nlRightHandSideAdd(0, i, sys->bInterior[i]);
- for (f=chart->faces; f; f=f->nextlink) {
+ for (f = chart->faces; f; f = f->nextlink) {
float wi1, wi2, wi3, b, si, beta[3], j2[3][3], W[3][3];
float row1[6], row2[6], row3[6];
int vid[6];
PEdge *e1 = f->edge, *e2 = e1->next, *e3 = e2->next;
PVert *v1 = e1->vert, *v2 = e2->vert, *v3 = e3->vert;
- wi1 = 1.0f/sys->weight[e1->u.id];
- wi2 = 1.0f/sys->weight[e2->u.id];
- wi3 = 1.0f/sys->weight[e3->u.id];
+ wi1 = 1.0f / sys->weight[e1->u.id];
+ wi2 = 1.0f / sys->weight[e2->u.id];
+ wi3 = 1.0f / sys->weight[e3->u.id];
/* bstar1 = (J1*dInv*bAlpha - bTriangle) */
- b = sys->bAlpha[e1->u.id]*wi1;
- b += sys->bAlpha[e2->u.id]*wi2;
- b += sys->bAlpha[e3->u.id]*wi3;
+ b = sys->bAlpha[e1->u.id] * wi1;
+ b += sys->bAlpha[e2->u.id] * wi2;
+ b += sys->bAlpha[e3->u.id] * wi3;
b -= sys->bTriangle[f->u.id];
/* si = J1*d*J1t */
- si = 1.0f/(wi1 + wi2 + wi3);
+ si = 1.0f / (wi1 + wi2 + wi3);
/* J1t*si*bstar1 - bAlpha */
- beta[0] = b*si - sys->bAlpha[e1->u.id];
- beta[1] = b*si - sys->bAlpha[e2->u.id];
- beta[2] = b*si - sys->bAlpha[e3->u.id];
+ beta[0] = b * si - sys->bAlpha[e1->u.id];
+ beta[1] = b * si - sys->bAlpha[e2->u.id];
+ beta[2] = b * si - sys->bAlpha[e3->u.id];
/* use this later for computing other lambda's */
sys->bstar[f->u.id] = b;
@@ -2472,59 +2473,59 @@ static PBool p_abf_matrix_invert(PAbfSystem *sys, PChart *chart)
vid[3] = ninterior + v1->u.id;
sys->J2dt[e1->u.id][0] = j2[0][0] = 1.0f * wi1;
- sys->J2dt[e2->u.id][0] = j2[1][0] = p_abf_compute_sin_product(sys, v1, e2->u.id)*wi2;
- sys->J2dt[e3->u.id][0] = j2[2][0] = p_abf_compute_sin_product(sys, v1, e3->u.id)*wi3;
+ sys->J2dt[e2->u.id][0] = j2[1][0] = p_abf_compute_sin_product(sys, v1, e2->u.id) * wi2;
+ sys->J2dt[e3->u.id][0] = j2[2][0] = p_abf_compute_sin_product(sys, v1, e3->u.id) * wi3;
- nlRightHandSideAdd(0, v1->u.id, j2[0][0]*beta[0]);
- nlRightHandSideAdd(0, ninterior + v1->u.id, j2[1][0]*beta[1] + j2[2][0]*beta[2]);
+ nlRightHandSideAdd(0, v1->u.id, j2[0][0] * beta[0]);
+ nlRightHandSideAdd(0, ninterior + v1->u.id, j2[1][0] * beta[1] + j2[2][0] * beta[2]);
- row1[0] = j2[0][0]*W[0][0];
- row2[0] = j2[0][0]*W[1][0];
- row3[0] = j2[0][0]*W[2][0];
+ row1[0] = j2[0][0] * W[0][0];
+ row2[0] = j2[0][0] * W[1][0];
+ row3[0] = j2[0][0] * W[2][0];
- row1[3] = j2[1][0]*W[0][1] + j2[2][0]*W[0][2];
- row2[3] = j2[1][0]*W[1][1] + j2[2][0]*W[1][2];
- row3[3] = j2[1][0]*W[2][1] + j2[2][0]*W[2][2];
+ row1[3] = j2[1][0] * W[0][1] + j2[2][0] * W[0][2];
+ row2[3] = j2[1][0] * W[1][1] + j2[2][0] * W[1][2];
+ row3[3] = j2[1][0] * W[2][1] + j2[2][0] * W[2][2];
}
if (v2->flag & PVERT_INTERIOR) {
vid[1] = v2->u.id;
vid[4] = ninterior + v2->u.id;
- sys->J2dt[e1->u.id][1] = j2[0][1] = p_abf_compute_sin_product(sys, v2, e1->u.id)*wi1;
- sys->J2dt[e2->u.id][1] = j2[1][1] = 1.0f*wi2;
- sys->J2dt[e3->u.id][1] = j2[2][1] = p_abf_compute_sin_product(sys, v2, e3->u.id)*wi3;
+ sys->J2dt[e1->u.id][1] = j2[0][1] = p_abf_compute_sin_product(sys, v2, e1->u.id) * wi1;
+ sys->J2dt[e2->u.id][1] = j2[1][1] = 1.0f * wi2;
+ sys->J2dt[e3->u.id][1] = j2[2][1] = p_abf_compute_sin_product(sys, v2, e3->u.id) * wi3;
- nlRightHandSideAdd(0, v2->u.id, j2[1][1]*beta[1]);
- nlRightHandSideAdd(0, ninterior + v2->u.id, j2[0][1]*beta[0] + j2[2][1]*beta[2]);
+ nlRightHandSideAdd(0, v2->u.id, j2[1][1] * beta[1]);
+ nlRightHandSideAdd(0, ninterior + v2->u.id, j2[0][1] * beta[0] + j2[2][1] * beta[2]);
- row1[1] = j2[1][1]*W[0][1];
- row2[1] = j2[1][1]*W[1][1];
- row3[1] = j2[1][1]*W[2][1];
+ row1[1] = j2[1][1] * W[0][1];
+ row2[1] = j2[1][1] * W[1][1];
+ row3[1] = j2[1][1] * W[2][1];
- row1[4] = j2[0][1]*W[0][0] + j2[2][1]*W[0][2];
- row2[4] = j2[0][1]*W[1][0] + j2[2][1]*W[1][2];
- row3[4] = j2[0][1]*W[2][0] + j2[2][1]*W[2][2];
+ row1[4] = j2[0][1] * W[0][0] + j2[2][1] * W[0][2];
+ row2[4] = j2[0][1] * W[1][0] + j2[2][1] * W[1][2];
+ row3[4] = j2[0][1] * W[2][0] + j2[2][1] * W[2][2];
}
if (v3->flag & PVERT_INTERIOR) {
vid[2] = v3->u.id;
vid[5] = ninterior + v3->u.id;
- sys->J2dt[e1->u.id][2] = j2[0][2] = p_abf_compute_sin_product(sys, v3, e1->u.id)*wi1;
- sys->J2dt[e2->u.id][2] = j2[1][2] = p_abf_compute_sin_product(sys, v3, e2->u.id)*wi2;
+ sys->J2dt[e1->u.id][2] = j2[0][2] = p_abf_compute_sin_product(sys, v3, e1->u.id) * wi1;
+ sys->J2dt[e2->u.id][2] = j2[1][2] = p_abf_compute_sin_product(sys, v3, e2->u.id) * wi2;
sys->J2dt[e3->u.id][2] = j2[2][2] = 1.0f * wi3;
- nlRightHandSideAdd(0, v3->u.id, j2[2][2]*beta[2]);
- nlRightHandSideAdd(0, ninterior + v3->u.id, j2[0][2]*beta[0] + j2[1][2]*beta[1]);
+ nlRightHandSideAdd(0, v3->u.id, j2[2][2] * beta[2]);
+ nlRightHandSideAdd(0, ninterior + v3->u.id, j2[0][2] * beta[0] + j2[1][2] * beta[1]);
- row1[2] = j2[2][2]*W[0][2];
- row2[2] = j2[2][2]*W[1][2];
- row3[2] = j2[2][2]*W[2][2];
+ row1[2] = j2[2][2] * W[0][2];
+ row2[2] = j2[2][2] * W[1][2];
+ row3[2] = j2[2][2] * W[2][2];
- row1[5] = j2[0][2]*W[0][0] + j2[1][2]*W[0][1];
- row2[5] = j2[0][2]*W[1][0] + j2[1][2]*W[1][1];
- row3[5] = j2[0][2]*W[2][0] + j2[1][2]*W[2][1];
+ row1[5] = j2[0][2] * W[0][0] + j2[1][2] * W[0][1];
+ row2[5] = j2[0][2] * W[1][0] + j2[1][2] * W[1][1];
+ row3[5] = j2[0][2] * W[2][0] + j2[1][2] * W[2][1];
}
for (i = 0; i < 3; i++) {
@@ -2540,20 +2541,20 @@ static PBool p_abf_matrix_invert(PAbfSystem *sys, PChart *chart)
continue;
if (i == 0)
- nlMatrixAdd(r, c, j2[0][i]*row1[j]);
+ nlMatrixAdd(r, c, j2[0][i] * row1[j]);
else
- nlMatrixAdd(r + ninterior, c, j2[0][i]*row1[j]);
+ nlMatrixAdd(r + ninterior, c, j2[0][i] * row1[j]);
if (i == 1)
- nlMatrixAdd(r, c, j2[1][i]*row2[j]);
+ nlMatrixAdd(r, c, j2[1][i] * row2[j]);
else
- nlMatrixAdd(r + ninterior, c, j2[1][i]*row2[j]);
+ nlMatrixAdd(r + ninterior, c, j2[1][i] * row2[j]);
if (i == 2)
- nlMatrixAdd(r, c, j2[2][i]*row3[j]);
+ nlMatrixAdd(r, c, j2[2][i] * row3[j]);
else
- nlMatrixAdd(r + ninterior, c, j2[2][i]*row3[j]);
+ nlMatrixAdd(r + ninterior, c, j2[2][i] * row3[j]);
}
}
}
@@ -2565,7 +2566,7 @@ static PBool p_abf_matrix_invert(PAbfSystem *sys, PChart *chart)
success = nlSolve();
if (success) {
- for (f=chart->faces; f; f=f->nextlink) {
+ for (f = chart->faces; f; f = f->nextlink) {
float dlambda1, pre[3], dalpha;
PEdge *e1 = f->edge, *e2 = e1->next, *e3 = e2->next;
PVert *v1 = e1->vert, *v2 = e2->vert, *v3 = e3->vert;
@@ -2575,40 +2576,40 @@ static PBool p_abf_matrix_invert(PAbfSystem *sys, PChart *chart)
if (v1->flag & PVERT_INTERIOR) {
float x = nlGetVariable(0, v1->u.id);
float x2 = nlGetVariable(0, ninterior + v1->u.id);
- pre[0] += sys->J2dt[e1->u.id][0]*x;
- pre[1] += sys->J2dt[e2->u.id][0]*x2;
- pre[2] += sys->J2dt[e3->u.id][0]*x2;
+ pre[0] += sys->J2dt[e1->u.id][0] * x;
+ pre[1] += sys->J2dt[e2->u.id][0] * x2;
+ pre[2] += sys->J2dt[e3->u.id][0] * x2;
}
if (v2->flag & PVERT_INTERIOR) {
float x = nlGetVariable(0, v2->u.id);
float x2 = nlGetVariable(0, ninterior + v2->u.id);
- pre[0] += sys->J2dt[e1->u.id][1]*x2;
- pre[1] += sys->J2dt[e2->u.id][1]*x;
- pre[2] += sys->J2dt[e3->u.id][1]*x2;
+ pre[0] += sys->J2dt[e1->u.id][1] * x2;
+ pre[1] += sys->J2dt[e2->u.id][1] * x;
+ pre[2] += sys->J2dt[e3->u.id][1] * x2;
}
if (v3->flag & PVERT_INTERIOR) {
float x = nlGetVariable(0, v3->u.id);
float x2 = nlGetVariable(0, ninterior + v3->u.id);
- pre[0] += sys->J2dt[e1->u.id][2]*x2;
- pre[1] += sys->J2dt[e2->u.id][2]*x2;
- pre[2] += sys->J2dt[e3->u.id][2]*x;
+ pre[0] += sys->J2dt[e1->u.id][2] * x2;
+ pre[1] += sys->J2dt[e2->u.id][2] * x2;
+ pre[2] += sys->J2dt[e3->u.id][2] * x;
}
dlambda1 = pre[0] + pre[1] + pre[2];
- dlambda1 = sys->dstar[f->u.id]*(sys->bstar[f->u.id] - dlambda1);
+ dlambda1 = sys->dstar[f->u.id] * (sys->bstar[f->u.id] - dlambda1);
sys->lambdaTriangle[f->u.id] += dlambda1;
dalpha = (sys->bAlpha[e1->u.id] - dlambda1);
- sys->alpha[e1->u.id] += dalpha/sys->weight[e1->u.id] - pre[0];
+ sys->alpha[e1->u.id] += dalpha / sys->weight[e1->u.id] - pre[0];
dalpha = (sys->bAlpha[e2->u.id] - dlambda1);
- sys->alpha[e2->u.id] += dalpha/sys->weight[e2->u.id] - pre[1];
+ sys->alpha[e2->u.id] += dalpha / sys->weight[e2->u.id] - pre[1];
dalpha = (sys->bAlpha[e3->u.id] - dlambda1);
- sys->alpha[e3->u.id] += dalpha/sys->weight[e3->u.id] - pre[2];
+ sys->alpha[e3->u.id] += dalpha / sys->weight[e3->u.id] - pre[2];
/* clamp */
e = f->edge;
@@ -2638,12 +2639,12 @@ static PBool p_chart_abf_solve(PChart *chart)
PEdge *e, *e1, *e2, *e3;
PAbfSystem sys;
int i;
- float /* lastnorm, */ /* UNUSED */ limit = (chart->nfaces > 100)? 1.0f: 0.001f;
+ float /* lastnorm, */ /* UNUSED */ limit = (chart->nfaces > 100) ? 1.0f : 0.001f;
/* setup id's */
sys.ninterior = sys.nfaces = sys.nangles = 0;
- for (v=chart->verts; v; v=v->nextlink) {
+ for (v = chart->verts; v; v = v->nextlink) {
if (p_vert_interior(v)) {
v->flag |= PVERT_INTERIOR;
v->u.id = sys.ninterior++;
@@ -2652,7 +2653,7 @@ static PBool p_chart_abf_solve(PChart *chart)
v->flag &= ~PVERT_INTERIOR;
}
- for (f=chart->faces; f; f=f->nextlink) {
+ for (f = chart->faces; f; f = f->nextlink) {
e1 = f->edge; e2 = e1->next; e3 = e2->next;
f->u.id = sys.nfaces++;
@@ -2665,7 +2666,7 @@ static PBool p_chart_abf_solve(PChart *chart)
p_abf_setup_system(&sys);
/* compute initial angles */
- for (f=chart->faces; f; f=f->nextlink) {
+ for (f = chart->faces; f; f = f->nextlink) {
float a1, a2, a3;
e1 = f->edge; e2 = e1->next; e3 = e2->next;
@@ -2688,12 +2689,12 @@ static PBool p_chart_abf_solve(PChart *chart)
sys.alpha[e2->u.id] = sys.beta[e2->u.id] = a2;
sys.alpha[e3->u.id] = sys.beta[e3->u.id] = a3;
- sys.weight[e1->u.id] = 2.0f/(a1*a1);
- sys.weight[e2->u.id] = 2.0f/(a2*a2);
- sys.weight[e3->u.id] = 2.0f/(a3*a3);
+ sys.weight[e1->u.id] = 2.0f / (a1 * a1);
+ sys.weight[e2->u.id] = 2.0f / (a2 * a2);
+ sys.weight[e3->u.id] = 2.0f / (a3 * a3);
}
- for (v=chart->verts; v; v=v->nextlink) {
+ for (v = chart->verts; v; v = v->nextlink) {
if (v->flag & PVERT_INTERIOR) {
float anglesum = 0.0, scale;
@@ -2703,11 +2704,11 @@ static PBool p_chart_abf_solve(PChart *chart)
e = e->next->next->pair;
} while (e && (e != v->edge));
- scale = (anglesum == 0.0f)? 0.0f: 2.0f*(float)M_PI/anglesum;
+ scale = (anglesum == 0.0f) ? 0.0f : 2.0f * (float)M_PI / anglesum;
e = v->edge;
do {
- sys.beta[e->u.id] = sys.alpha[e->u.id] = sys.beta[e->u.id]*scale;
+ sys.beta[e->u.id] = sys.alpha[e->u.id] = sys.beta[e->u.id] * scale;
e = e->next->next->pair;
} while (e && (e != v->edge));
}
@@ -2775,15 +2776,15 @@ static void p_chart_pin_positions(PChart *chart, PVert **pin1, PVert **pin2)
if ((sub[0] > sub[1]) && (sub[0] > sub[2])) {
dirx = 0;
- diry = (sub[1] > sub[2])? 1: 2;
+ diry = (sub[1] > sub[2]) ? 1 : 2;
}
else if ((sub[1] > sub[0]) && (sub[1] > sub[2])) {
dirx = 1;
- diry = (sub[0] > sub[2])? 0: 2;
+ diry = (sub[0] > sub[2]) ? 0 : 2;
}
else {
dirx = 2;
- diry = (sub[0] > sub[1])? 0: 1;
+ diry = (sub[0] > sub[1]) ? 0 : 1;
}
if (dirx == 2) {
@@ -2809,8 +2810,8 @@ static PBool p_chart_symmetry_pins(PChart *chart, PEdge *outer, PVert **pin1, PV
float maxlen = 0.0f, curlen = 0.0f, totlen = 0.0f, firstlen = 0.0f;
float len1, len2;
- /* find longest series of verts split in the chart itself, these are
- * marked during construction */
+ /* find longest series of verts split in the chart itself, these are
+ * marked during construction */
be = outer;
lastbe = p_boundary_edge_prev(be);
do {
@@ -2820,7 +2821,8 @@ static PBool p_chart_symmetry_pins(PChart *chart, PEdge *outer, PVert **pin1, PV
nextbe = p_boundary_edge_next(be);
if ((be->vert->flag & PVERT_SPLIT) ||
- (lastbe->vert->flag & nextbe->vert->flag & PVERT_SPLIT)) {
+ (lastbe->vert->flag & nextbe->vert->flag & PVERT_SPLIT))
+ {
if (!cure) {
if (be == outer)
firste1 = be;
@@ -2860,7 +2862,7 @@ static PBool p_chart_symmetry_pins(PChart *chart, PEdge *outer, PVert **pin1, PV
}
}
- if (!maxe1 || !maxe2 || (maxlen < 0.5f*totlen))
+ if (!maxe1 || !maxe2 || (maxlen < 0.5f * totlen))
return P_FALSE;
/* find pin1 in the split vertices */
@@ -2919,7 +2921,7 @@ static void p_chart_extrema_verts(PChart *chart, PVert **pin1, PVert **pin2)
minvert[0] = minvert[1] = minvert[2] = NULL;
maxvert[0] = maxvert[1] = maxvert[2] = NULL;
- for (v = chart->verts; v; v=v->nextlink) {
+ for (v = chart->verts; v; v = v->nextlink) {
for (i = 0; i < 3; i++) {
if (v->co[i] < minv[i]) {
minv[i] = v->co[i];
@@ -2953,9 +2955,9 @@ static void p_chart_lscm_load_solution(PChart *chart)
{
PVert *v;
- for (v=chart->verts; v; v=v->nextlink) {
- v->uv[0] = nlGetVariable(0, 2*v->u.id);
- v->uv[1] = nlGetVariable(0, 2*v->u.id + 1);
+ for (v = chart->verts; v; v = v->nextlink) {
+ v->uv[0] = nlGetVariable(0, 2 * v->u.id);
+ v->uv[1] = nlGetVariable(0, 2 * v->u.id + 1);
}
}
@@ -2966,7 +2968,7 @@ static void p_chart_lscm_begin(PChart *chart, PBool live, PBool abf)
int npins = 0, id = 0;
/* give vertices matrix indices and count pins */
- for (v=chart->verts; v; v=v->nextlink) {
+ for (v = chart->verts; v; v = v->nextlink) {
if (v->flag & PVERT_PIN) {
npins++;
if (v->flag & PVERT_SELECT)
@@ -3007,12 +3009,12 @@ static void p_chart_lscm_begin(PChart *chart, PBool live, PBool abf)
chart->flag |= PCHART_NOPACK;
}
- for (v=chart->verts; v; v=v->nextlink)
+ for (v = chart->verts; v; v = v->nextlink)
v->u.id = id++;
nlNewContext();
- nlSolverParameteri(NL_NB_VARIABLES, 2*chart->nverts);
- nlSolverParameteri(NL_NB_ROWS, 2*chart->nfaces);
+ nlSolverParameteri(NL_NB_VARIABLES, 2 * chart->nverts);
+ nlSolverParameteri(NL_NB_ROWS, 2 * chart->nfaces);
nlSolverParameteri(NL_LEAST_SQUARES, NL_TRUE);
chart->u.lscm.context = nlGetCurrent();
@@ -3034,30 +3036,30 @@ static PBool p_chart_lscm_solve(PHandle *handle, PChart *chart)
/* TODO: make loading pins work for simplify/complexify. */
#endif
- for (v=chart->verts; v; v=v->nextlink)
+ for (v = chart->verts; v; v = v->nextlink)
if (v->flag & PVERT_PIN)
- p_vert_load_pin_select_uvs(handle, v); /* reload for live */
+ p_vert_load_pin_select_uvs(handle, v); /* reload for live */
if (chart->u.lscm.pin1) {
- nlLockVariable(2*pin1->u.id);
- nlLockVariable(2*pin1->u.id + 1);
- nlLockVariable(2*pin2->u.id);
- nlLockVariable(2*pin2->u.id + 1);
-
- nlSetVariable(0, 2*pin1->u.id, pin1->uv[0]);
- nlSetVariable(0, 2*pin1->u.id + 1, pin1->uv[1]);
- nlSetVariable(0, 2*pin2->u.id, pin2->uv[0]);
- nlSetVariable(0, 2*pin2->u.id + 1, pin2->uv[1]);
+ nlLockVariable(2 * pin1->u.id);
+ nlLockVariable(2 * pin1->u.id + 1);
+ nlLockVariable(2 * pin2->u.id);
+ nlLockVariable(2 * pin2->u.id + 1);
+
+ nlSetVariable(0, 2 * pin1->u.id, pin1->uv[0]);
+ nlSetVariable(0, 2 * pin1->u.id + 1, pin1->uv[1]);
+ nlSetVariable(0, 2 * pin2->u.id, pin2->uv[0]);
+ nlSetVariable(0, 2 * pin2->u.id + 1, pin2->uv[1]);
}
else {
/* set and lock the pins */
- for (v=chart->verts; v; v=v->nextlink) {
+ for (v = chart->verts; v; v = v->nextlink) {
if (v->flag & PVERT_PIN) {
- nlLockVariable(2*v->u.id);
- nlLockVariable(2*v->u.id + 1);
+ nlLockVariable(2 * v->u.id);
+ nlLockVariable(2 * v->u.id + 1);
- nlSetVariable(0, 2*v->u.id, v->uv[0]);
- nlSetVariable(0, 2*v->u.id + 1, v->uv[1]);
+ nlSetVariable(0, 2 * v->u.id, v->uv[0]);
+ nlSetVariable(0, 2 * v->u.id + 1, v->uv[1]);
}
}
}
@@ -3067,7 +3069,7 @@ static PBool p_chart_lscm_solve(PHandle *handle, PChart *chart)
nlBegin(NL_MATRIX);
row = 0;
- for (f=chart->faces; f; f=f->nextlink) {
+ for (f = chart->faces; f; f = f->nextlink) {
PEdge *e1 = f->edge, *e2 = e1->next, *e3 = e2->next;
PVert *v1 = e1->vert, *v2 = e2->vert, *v3 = e3->vert;
float a1, a2, a3, ratio, cosine, sine;
@@ -3090,51 +3092,51 @@ static PBool p_chart_lscm_solve(PHandle *handle, PChart *chart)
/* shift vertices to find most stable order */
if (sina3 != sinmax) {
- SHIFT3(PVert*, v1, v2, v3);
+ SHIFT3(PVert *, v1, v2, v3);
SHIFT3(float, a1, a2, a3);
SHIFT3(float, sina1, sina2, sina3);
if (sina2 == sinmax) {
- SHIFT3(PVert*, v1, v2, v3);
+ SHIFT3(PVert *, v1, v2, v3);
SHIFT3(float, a1, a2, a3);
SHIFT3(float, sina1, sina2, sina3);
}
}
/* angle based lscm formulation */
- ratio = (sina3 == 0.0f)? 1.0f: sina2/sina3;
- cosine = cosf(a1)*ratio;
- sine = sina1*ratio;
+ ratio = (sina3 == 0.0f) ? 1.0f : sina2 / sina3;
+ cosine = cosf(a1) * ratio;
+ sine = sina1 * ratio;
#if 0
nlBegin(NL_ROW);
- nlCoefficient(2*v1->u.id, cosine - 1.0);
- nlCoefficient(2*v1->u.id+1, -sine);
- nlCoefficient(2*v2->u.id, -cosine);
- nlCoefficient(2*v2->u.id+1, sine);
- nlCoefficient(2*v3->u.id, 1.0);
+ nlCoefficient(2 * v1->u.id, cosine - 1.0);
+ nlCoefficient(2 * v1->u.id + 1, -sine);
+ nlCoefficient(2 * v2->u.id, -cosine);
+ nlCoefficient(2 * v2->u.id + 1, sine);
+ nlCoefficient(2 * v3->u.id, 1.0);
nlEnd(NL_ROW);
nlBegin(NL_ROW);
- nlCoefficient(2*v1->u.id, sine);
- nlCoefficient(2*v1->u.id+1, cosine - 1.0);
- nlCoefficient(2*v2->u.id, -sine);
- nlCoefficient(2*v2->u.id+1, -cosine);
- nlCoefficient(2*v3->u.id+1, 1.0);
+ nlCoefficient(2 * v1->u.id, sine);
+ nlCoefficient(2 * v1->u.id + 1, cosine - 1.0);
+ nlCoefficient(2 * v2->u.id, -sine);
+ nlCoefficient(2 * v2->u.id + 1, -cosine);
+ nlCoefficient(2 * v3->u.id + 1, 1.0);
nlEnd(NL_ROW);
#else
- nlMatrixAdd(row, 2*v1->u.id, cosine - 1.0f);
- nlMatrixAdd(row, 2*v1->u.id+1, -sine);
- nlMatrixAdd(row, 2*v2->u.id, -cosine);
- nlMatrixAdd(row, 2*v2->u.id+1, sine);
- nlMatrixAdd(row, 2*v3->u.id, 1.0);
+ nlMatrixAdd(row, 2 * v1->u.id, cosine - 1.0f);
+ nlMatrixAdd(row, 2 * v1->u.id + 1, -sine);
+ nlMatrixAdd(row, 2 * v2->u.id, -cosine);
+ nlMatrixAdd(row, 2 * v2->u.id + 1, sine);
+ nlMatrixAdd(row, 2 * v3->u.id, 1.0);
row++;
- nlMatrixAdd(row, 2*v1->u.id, sine);
- nlMatrixAdd(row, 2*v1->u.id+1, cosine - 1.0f);
- nlMatrixAdd(row, 2*v2->u.id, -sine);
- nlMatrixAdd(row, 2*v2->u.id+1, -cosine);
- nlMatrixAdd(row, 2*v3->u.id+1, 1.0);
+ nlMatrixAdd(row, 2 * v1->u.id, sine);
+ nlMatrixAdd(row, 2 * v1->u.id + 1, cosine - 1.0f);
+ nlMatrixAdd(row, 2 * v2->u.id, -sine);
+ nlMatrixAdd(row, 2 * v2->u.id + 1, -cosine);
+ nlMatrixAdd(row, 2 * v3->u.id + 1, 1.0);
row++;
#endif
}
@@ -3148,7 +3150,7 @@ static PBool p_chart_lscm_solve(PHandle *handle, PChart *chart)
return P_TRUE;
}
else {
- for (v=chart->verts; v; v=v->nextlink) {
+ for (v = chart->verts; v; v = v->nextlink) {
v->uv[0] = 0.0f;
v->uv[1] = 0.0f;
}
@@ -3180,7 +3182,7 @@ static void p_stretch_pin_boundary(PChart *chart)
{
PVert *v;
- for (v=chart->verts; v; v=v->nextlink)
+ for (v = chart->verts; v; v = v->nextlink)
if (v->edge->pair == NULL)
v->flag |= PVERT_PIN;
else
@@ -3200,7 +3202,7 @@ static float p_face_stretch(PFace *f)
if (area <= 0.0f) /* flipped face -> infinite stretch */
return 1e10f;
- w= 1.0f/(2.0f*area);
+ w = 1.0f / (2.0f * area);
/* compute derivatives */
copy_v3_v3(Ps, v1->co);
@@ -3230,10 +3232,10 @@ static float p_face_stretch(PFace *f)
mul_v3_fl(Pt, w);
/* Sander Tensor */
- a= dot_v3v3(Ps, Ps);
- c= dot_v3v3(Pt, Pt);
+ a = dot_v3v3(Ps, Ps);
+ c = dot_v3v3(Pt, Pt);
- T = sqrt(0.5f*(a + c));
+ T = sqrt(0.5f * (a + c));
if (f->flag & PFACE_FILLED)
T *= 0.2f;
@@ -3261,7 +3263,7 @@ static void p_chart_stretch_minimize(PChart *chart, RNG *rng)
float orig_stretch, low, stretch_low, high, stretch_high, mid, stretch;
float orig_uv[2], dir[2], random_angle, trusted_radius;
- for (v=chart->verts; v; v=v->nextlink) {
+ for (v = chart->verts; v; v = v->nextlink) {
if ((v->flag & PVERT_PIN) || !(v->flag & PVERT_SELECT))
continue;
@@ -3298,8 +3300,8 @@ static void p_chart_stretch_minimize(PChart *chart, RNG *rng)
/* binary search for lowest stretch position */
for (j = 0; j < P_STRETCH_ITER; j++) {
mid = 0.5f * (low + high);
- v->uv[0]= orig_uv[0] + mid*dir[0];
- v->uv[1]= orig_uv[1] + mid*dir[1];
+ v->uv[0] = orig_uv[0] + mid * dir[0];
+ v->uv[1] = orig_uv[1] + mid * dir[1];
stretch = p_stretch_compute_vertex(v);
if (stretch_low < stretch_high) {
@@ -3322,8 +3324,8 @@ static void p_chart_stretch_minimize(PChart *chart, RNG *rng)
static int p_compare_geometric_uv(const void *a, const void *b)
{
- PVert *v1 = *(PVert**)a;
- PVert *v2 = *(PVert**)b;
+ PVert *v1 = *(PVert **)a;
+ PVert *v2 = *(PVert **)b;
if (v1->uv[0] < v2->uv[0])
return -1;
@@ -3359,9 +3361,9 @@ static PBool p_chart_convex_hull(PChart *chart, PVert ***verts, int *nverts, int
e = p_boundary_edge_next(e);
} while (e != be);
- p = points = (PVert**)MEM_mallocN(sizeof(PVert*)*npoints*2, "PCHullpoints");
- U = (PVert**)MEM_mallocN(sizeof(PVert*)*npoints, "PCHullU");
- L = (PVert**)MEM_mallocN(sizeof(PVert*)*npoints, "PCHullL");
+ p = points = (PVert **)MEM_mallocN(sizeof(PVert *) * npoints * 2, "PCHullpoints");
+ U = (PVert **)MEM_mallocN(sizeof(PVert *) * npoints, "PCHullU");
+ L = (PVert **)MEM_mallocN(sizeof(PVert *) * npoints, "PCHullL");
e = be;
do {
@@ -3370,13 +3372,13 @@ static PBool p_chart_convex_hull(PChart *chart, PVert ***verts, int *nverts, int
e = p_boundary_edge_next(e);
} while (e != be);
- qsort(points, npoints, sizeof(PVert*), p_compare_geometric_uv);
+ qsort(points, npoints, sizeof(PVert *), p_compare_geometric_uv);
ulen = llen = 0;
- for (p=points, i = 0; i < npoints; i++, p++) {
- while ((ulen > 1) && (p_area_signed(U[ulen-2]->uv, (*p)->uv, U[ulen-1]->uv) <= 0))
+ for (p = points, i = 0; i < npoints; i++, p++) {
+ while ((ulen > 1) && (p_area_signed(U[ulen - 2]->uv, (*p)->uv, U[ulen - 1]->uv) <= 0))
ulen--;
- while ((llen > 1) && (p_area_signed(L[llen-2]->uv, (*p)->uv, L[llen-1]->uv) >= 0))
+ while ((llen > 1) && (p_area_signed(L[llen - 2]->uv, (*p)->uv, L[llen - 1]->uv) >= 0))
llen--;
U[ulen] = *p;
@@ -3386,11 +3388,11 @@ static PBool p_chart_convex_hull(PChart *chart, PVert ***verts, int *nverts, int
}
npoints = 0;
- for (p=points, i = 0; i < ulen; i++, p++, npoints++)
+ for (p = points, i = 0; i < ulen; i++, p++, npoints++)
*p = U[i];
/* the first and last point in L are left out, since they are also in U */
- for (i = llen-2; i > 0; i--, p++, npoints++)
+ for (i = llen - 2; i > 0; i--, p++, npoints++)
*p = L[i];
*verts = points;
@@ -3422,7 +3424,7 @@ static float p_rectangle_area(float *p1, float *dir, float *p2, float *p3, float
if (!p_intersect_line_2d_dir(p3, dir, p4, orthodir, corner3))
return 1e10;
- return len_v2v2(corner1, corner2)*len_v2v2(corner2, corner3);
+ return len_v2v2(corner1, corner2) * len_v2v2(corner2, corner3);
}
static float p_chart_minimum_area_angle(PChart *chart)
@@ -3440,16 +3442,16 @@ static float p_chart_minimum_area_angle(PChart *chart)
return 0.0;
/* find left/top/right/bottom points, and compute angle for each point */
- angles = MEM_mallocN(sizeof(float)*npoints, "PMinAreaAngles");
+ angles = MEM_mallocN(sizeof(float) * npoints, "PMinAreaAngles");
mini = maxi = 0;
miny = 1e10;
maxy = -1e10;
for (i = 0; i < npoints; i++) {
- p1 = (i == 0)? points[npoints-1]: points[i-1];
+ p1 = (i == 0) ? points[npoints - 1] : points[i - 1];
p2 = points[i];
- p3 = (i == npoints-1)? points[0]: points[i+1];
+ p3 = (i == npoints - 1) ? points[0] : points[i + 1];
angles[i] = (float)M_PI - p_vec2_angle(p1->uv, p2->uv, p3->uv);
@@ -3471,19 +3473,19 @@ static float p_chart_minimum_area_angle(PChart *chart)
v[0] = points[idx[0]]->uv[0];
v[1] = points[idx[0]]->uv[1] + 1.0f;
- a[0] = p_vec2_angle(points[(idx[0]+1)%npoints]->uv, points[idx[0]]->uv, v);
+ a[0] = p_vec2_angle(points[(idx[0] + 1) % npoints]->uv, points[idx[0]]->uv, v);
v[0] = points[idx[1]]->uv[0] + 1.0f;
v[1] = points[idx[1]]->uv[1];
- a[1] = p_vec2_angle(points[(idx[1]+1)%npoints]->uv, points[idx[1]]->uv, v);
+ a[1] = p_vec2_angle(points[(idx[1] + 1) % npoints]->uv, points[idx[1]]->uv, v);
v[0] = points[idx[2]]->uv[0];
v[1] = points[idx[2]]->uv[1] - 1.0f;
- a[2] = p_vec2_angle(points[(idx[2]+1)%npoints]->uv, points[idx[2]]->uv, v);
+ a[2] = p_vec2_angle(points[(idx[2] + 1) % npoints]->uv, points[idx[2]]->uv, v);
v[0] = points[idx[3]]->uv[0] - 1.0f;
v[1] = points[idx[3]]->uv[1];
- a[3] = p_vec2_angle(points[(idx[3]+1)%npoints]->uv, points[idx[3]]->uv, v);
+ a[3] = p_vec2_angle(points[(idx[3] + 1) % npoints]->uv, points[idx[3]]->uv, v);
/* 4 rotating calipers */
@@ -3491,7 +3493,7 @@ static float p_chart_minimum_area_angle(PChart *chart)
minarea = 1e10;
minangle = 0.0;
- while (rotated <= (float)(M_PI/2.0)) { /* INVESTIGATE: how far to rotate? */
+ while (rotated <= (float)(M_PI / 2.0)) { /* INVESTIGATE: how far to rotate? */
/* rotate with the smallest angle */
mini = 0;
mina = 1e10;
@@ -3503,26 +3505,26 @@ static float p_chart_minimum_area_angle(PChart *chart)
}
rotated += mina;
- nextidx = (idx[mini]+1)%npoints;
+ nextidx = (idx[mini] + 1) % npoints;
a[mini] = angles[nextidx];
- a[(mini+1)%4] = a[(mini+1)%4] - mina;
- a[(mini+2)%4] = a[(mini+2)%4] - mina;
- a[(mini+3)%4] = a[(mini+3)%4] - mina;
+ a[(mini + 1) % 4] = a[(mini + 1) % 4] - mina;
+ a[(mini + 2) % 4] = a[(mini + 2) % 4] - mina;
+ a[(mini + 3) % 4] = a[(mini + 3) % 4] - mina;
/* compute area */
p1 = points[idx[mini]];
p1n = points[nextidx];
- p2 = points[idx[(mini+1)%4]];
- p3 = points[idx[(mini+2)%4]];
- p4 = points[idx[(mini+3)%4]];
+ p2 = points[idx[(mini + 1) % 4]];
+ p3 = points[idx[(mini + 2) % 4]];
+ p4 = points[idx[(mini + 3) % 4]];
len = len_v2v2(p1->uv, p1n->uv);
if (len > 0.0f) {
- len = 1.0f/len;
- v[0] = (p1n->uv[0] - p1->uv[0])*len;
- v[1] = (p1n->uv[1] - p1->uv[1])*len;
+ len = 1.0f / len;
+ v[0] = (p1n->uv[0] - p1->uv[0]) * len;
+ v[1] = (p1n->uv[1] - p1->uv[1]) * len;
area = p_rectangle_area(p1->uv, v, p2->uv, p3->uv, p4->uv);
@@ -3537,8 +3539,8 @@ static float p_chart_minimum_area_angle(PChart *chart)
}
/* try keeping rotation as small as possible */
- if (minangle > (float)(M_PI/4))
- minangle -= (float)(M_PI/2.0);
+ if (minangle > (float)(M_PI / 4))
+ minangle -= (float)(M_PI / 2.0);
MEM_freeN(angles);
MEM_freeN(points);
@@ -3553,10 +3555,10 @@ static void p_chart_rotate_minimum_area(PChart *chart)
float cosine = cos(angle);
PVert *v;
- for (v = chart->verts; v; v=v->nextlink) {
+ for (v = chart->verts; v; v = v->nextlink) {
float oldu = v->uv[0], oldv = v->uv[1];
- v->uv[0] = cosine*oldu - sine*oldv;
- v->uv[1] = sine*oldu + cosine*oldv;
+ v->uv[0] = cosine * oldu - sine * oldv;
+ v->uv[1] = sine * oldu + cosine * oldv;
}
}
@@ -3585,21 +3587,21 @@ static void p_barycentric_2d(float *v1, float *v2, float *v3, float *p, float *b
c[0] = v3[0] - v1[0];
c[1] = v3[1] - v1[1];
- div = a[0]*c[1] - a[1]*c[0];
+ div = a[0] * c[1] - a[1] * c[0];
if (div == 0.0f) {
- b[0] = 1.0f/3.0f;
- b[1] = 1.0f/3.0f;
- b[2] = 1.0f/3.0f;
+ b[0] = 1.0f / 3.0f;
+ b[1] = 1.0f / 3.0f;
+ b[2] = 1.0f / 3.0f;
}
else {
h[0] = p[0] - v1[0];
h[1] = p[1] - v1[1];
- div = 1.0f/div;
+ div = 1.0f / div;
- b[1] = (h[0]*c[1] - h[1]*c[0])*div;
- b[2] = (a[0]*h[1] - a[1]*h[0])*div;
+ b[1] = (h[0] * c[1] - h[1] * c[0]) * div;
+ b[2] = (a[0] * h[1] - a[1] * h[0]) * div;
b[0] = 1.0f - b[1] - b[2];
}
}
@@ -3611,8 +3613,8 @@ static PBool p_triangle_inside(SmoothTriangle *t, float *co)
p_barycentric_2d(t->co1, t->co2, t->co3, co, b);
if ((b[0] >= 0.0f) && (b[1] >= 0.0f) && (b[2] >= 0.0f)) {
- co[0] = t->oco1[0]*b[0] + t->oco2[0]*b[1] + t->oco3[0]*b[2];
- co[1] = t->oco1[1]*b[0] + t->oco2[1]*b[1] + t->oco3[1]*b[2];
+ co[0] = t->oco1[0] * b[0] + t->oco2[0] * b[1] + t->oco3[0] * b[2];
+ co[1] = t->oco1[1] * b[0] + t->oco2[1] * b[1] + t->oco3[1] * b[2];
return P_TRUE;
}
@@ -3632,11 +3634,11 @@ static SmoothNode *p_node_new(MemArena *arena, SmoothTriangle **tri, int ntri, f
if (ntri <= 10 || depth >= 15)
return node;
- t1 = MEM_mallocN(sizeof(SmoothTriangle)*ntri, "PNodeTri1");
- t2 = MEM_mallocN(sizeof(SmoothTriangle)*ntri, "PNodeTri1");
+ t1 = MEM_mallocN(sizeof(SmoothTriangle) * ntri, "PNodeTri1");
+ t2 = MEM_mallocN(sizeof(SmoothTriangle) * ntri, "PNodeTri1");
- axis = (bmax[0] - bmin[0] > bmax[1] - bmin[1])? 0: 1;
- split = 0.5f*(bmin[axis] + bmax[axis]);
+ axis = (bmax[0] - bmin[0] > bmax[1] - bmin[1]) ? 0 : 1;
+ split = 0.5f * (bmin[axis] + bmax[axis]);
for (i = 0; i < ntri; i++) {
t = tri[i];
@@ -3667,11 +3669,11 @@ static SmoothNode *p_node_new(MemArena *arena, SmoothTriangle **tri, int ntri, f
/* mi = bmin[axis]; */ /* UNUSED */
mx = bmax[axis];
bmax[axis] = split;
- node->c1 = p_node_new(arena, t1, t1size, bmin, bmax, depth+1);
+ node->c1 = p_node_new(arena, t1, t1size, bmin, bmax, depth + 1);
bmin[axis] = bmax[axis];
bmax[axis] = mx;
- node->c2 = p_node_new(arena, t2, t2size, bmin, bmax, depth+1);
+ node->c2 = p_node_new(arena, t2, t2size, bmin, bmax, depth + 1);
return node;
}
@@ -3710,9 +3712,9 @@ static PBool p_node_intersect(SmoothNode *node, float *co)
static int p_compare_float(const void *a, const void *b)
{
- if (*((float*)a) < *((float*)b))
+ if (*((float *)a) < *((float *)b))
return -1;
- else if (*((float*)a) == *((float*)b))
+ else if (*((float *)a) == *((float *)b))
return 0;
else
return 1;
@@ -3721,17 +3723,17 @@ static int p_compare_float(const void *a, const void *b)
static float p_smooth_median_edge_length(PChart *chart)
{
PEdge *e;
- float *lengths = MEM_mallocN(sizeof(chart->edges)*chart->nedges, "PMedianLength");
+ float *lengths = MEM_mallocN(sizeof(chart->edges) * chart->nedges, "PMedianLength");
float median;
int i;
/* ok, so i'm lazy */
- for (i=0, e=chart->edges; e; e=e->nextlink, i++)
+ for (i = 0, e = chart->edges; e; e = e->nextlink, i++)
lengths[i] = p_edge_length(e);
qsort(lengths, i, sizeof(float), p_compare_float);
- median = lengths[i/2];
+ median = lengths[i / 2];
MEM_freeN(lengths);
return median;
@@ -3739,10 +3741,10 @@ static float p_smooth_median_edge_length(PChart *chart)
static float p_smooth_distortion(PEdge *e, float avg2d, float avg3d)
{
- float len2d = p_edge_uv_length(e)*avg3d;
- float len3d = p_edge_length(e)*avg2d;
+ float len2d = p_edge_uv_length(e) * avg3d;
+ float len3d = p_edge_length(e) * avg2d;
- return (len3d == 0.0f)? 0.0f: len2d/len3d;
+ return (len3d == 0.0f) ? 0.0f : len2d / len3d;
}
static void p_smooth(PChart *chart)
@@ -3764,17 +3766,17 @@ static void p_smooth(PChart *chart)
return;
p_chart_uv_bbox(chart, minv, maxv);
- median = p_smooth_median_edge_length(chart)*0.10f;
+ median = p_smooth_median_edge_length(chart) * 0.10f;
if (median == 0.0f)
return;
- invmedian = 1.0f/median;
+ invmedian = 1.0f / median;
/* compute edge distortion */
avglen2d = avglen3d = 0.0;
- for (e=chart->edges; e; e=e->nextlink) {
+ for (e = chart->edges; e; e = e->nextlink) {
avglen2d += p_edge_uv_length(e);
avglen3d += p_edge_length(e);
}
@@ -3782,7 +3784,7 @@ static void p_smooth(PChart *chart)
avglen2d /= nedges;
avglen3d /= nedges;
- for (v=chart->verts; v; v=v->nextlink) {
+ for (v = chart->verts; v; v = v->nextlink) {
v->u.distortion = 0.0;
nwheel = 0;
@@ -3798,43 +3800,43 @@ static void p_smooth(PChart *chart)
}
/* need to do excessive grid size checking still */
- center[0] = 0.5f*(minv[0] + maxv[0]);
- center[1] = 0.5f*(minv[1] + maxv[1]);
+ center[0] = 0.5f * (minv[0] + maxv[0]);
+ center[1] = 0.5f * (minv[1] + maxv[1]);
- dx = 0.5f*(maxv[0] - minv[0]);
- dy = 0.5f*(maxv[1] - minv[1]);
+ dx = 0.5f * (maxv[0] - minv[0]);
+ dy = 0.5f * (maxv[1] - minv[1]);
padding = 0.15f;
- dx += padding*dx + 2.0f*median;
- dy += padding*dy + 2.0f*median;
+ dx += padding * dx + 2.0f * median;
+ dy += padding * dy + 2.0f * median;
- gridx = (int)(dx*invmedian);
- gridy = (int)(dy*invmedian);
+ gridx = (int)(dx * invmedian);
+ gridy = (int)(dy * invmedian);
- minv[0] = center[0] - median*gridx;
- minv[1] = center[1] - median*gridy;
- maxv[0] = center[0] + median*gridx;
- maxv[1] = center[1] + median*gridy;
+ minv[0] = center[0] - median * gridx;
+ minv[1] = center[1] - median * gridy;
+ maxv[0] = center[0] + median * gridx;
+ maxv[1] = center[1] + median * gridy;
/* create grid */
- gridx = gridx*2 + 1;
- gridy = gridy*2 + 1;
+ gridx = gridx * 2 + 1;
+ gridy = gridy * 2 + 1;
if ((gridx <= 2) || (gridy <= 2))
return;
- edgesx = gridx-1;
- edgesy = gridy-1;
- nsize = gridx*gridy;
- esize = edgesx*edgesy;
-
- nodes = MEM_mallocN(sizeof(float)*nsize, "PSmoothNodes");
- nodesx = MEM_mallocN(sizeof(float)*nsize, "PSmoothNodesX");
- nodesy = MEM_mallocN(sizeof(float)*nsize, "PSmoothNodesY");
- oldnodesx = MEM_mallocN(sizeof(float)*nsize, "PSmoothOldNodesX");
- oldnodesy = MEM_mallocN(sizeof(float)*nsize, "PSmoothOldNodesY");
- hedges = MEM_mallocN(sizeof(float)*esize, "PSmoothHEdges");
- vedges = MEM_mallocN(sizeof(float)*esize, "PSmoothVEdges");
+ edgesx = gridx - 1;
+ edgesy = gridy - 1;
+ nsize = gridx * gridy;
+ esize = edgesx * edgesy;
+
+ nodes = MEM_mallocN(sizeof(float) * nsize, "PSmoothNodes");
+ nodesx = MEM_mallocN(sizeof(float) * nsize, "PSmoothNodesX");
+ nodesy = MEM_mallocN(sizeof(float) * nsize, "PSmoothNodesY");
+ oldnodesx = MEM_mallocN(sizeof(float) * nsize, "PSmoothOldNodesX");
+ oldnodesy = MEM_mallocN(sizeof(float) * nsize, "PSmoothOldNodesY");
+ hedges = MEM_mallocN(sizeof(float) * esize, "PSmoothHEdges");
+ vedges = MEM_mallocN(sizeof(float) * esize, "PSmoothVEdges");
if (!nodes || !nodesx || !nodesy || !oldnodesx || !oldnodesy || !hedges || !vedges) {
if (nodes) MEM_freeN(nodes);
@@ -3851,17 +3853,17 @@ static void p_smooth(PChart *chart)
for (x = 0; x < gridx; x++) {
for (y = 0; y < gridy; y++) {
- i = x + y*gridx;
+ i = x + y * gridx;
- nodesx[i] = minv[0] + median*x;
- nodesy[i] = minv[1] + median*y;
+ nodesx[i] = minv[0] + median * x;
+ nodesy[i] = minv[1] + median * y;
nodes[i] = 1.0f;
}
}
/* embed in grid */
- for (f=chart->faces; f; f=f->nextlink) {
+ for (f = chart->faces; f; f = f->nextlink) {
PEdge *e1 = f->edge, *e2 = e1->next, *e3 = e2->next;
float fmin[2], fmax[2];
int bx1, by1, bx2, by2;
@@ -3872,16 +3874,16 @@ static void p_smooth(PChart *chart)
DO_MINMAX2(e2->vert->uv, fmin, fmax);
DO_MINMAX2(e3->vert->uv, fmin, fmax);
- bx1 = (int)((fmin[0] - minv[0])*invmedian);
- by1 = (int)((fmin[1] - minv[1])*invmedian);
- bx2 = (int)((fmax[0] - minv[0])*invmedian + 2);
- by2 = (int)((fmax[1] - minv[1])*invmedian + 2);
+ bx1 = (int)((fmin[0] - minv[0]) * invmedian);
+ by1 = (int)((fmin[1] - minv[1]) * invmedian);
+ bx2 = (int)((fmax[0] - minv[0]) * invmedian + 2);
+ by2 = (int)((fmax[1] - minv[1]) * invmedian + 2);
for (x = bx1; x < bx2; x++) {
for (y = by1; y < by2; y++) {
float p[2], b[3];
- i = x + y*gridx;
+ i = x + y * gridx;
p[0] = nodesx[i];
p[1] = nodesy[i];
@@ -3889,9 +3891,9 @@ static void p_smooth(PChart *chart)
p_barycentric_2d(e1->vert->uv, e2->vert->uv, e3->vert->uv, p, b);
if ((b[0] > 0.0f) && (b[1] > 0.0f) && (b[2] > 0.0f)) {
- nodes[i] = e1->vert->u.distortion*b[0];
- nodes[i] += e2->vert->u.distortion*b[1];
- nodes[i] += e3->vert->u.distortion*b[2];
+ nodes[i] = e1->vert->u.distortion * b[0];
+ nodes[i] += e2->vert->u.distortion * b[1];
+ nodes[i] += e3->vert->u.distortion * b[2];
}
}
}
@@ -3900,22 +3902,22 @@ static void p_smooth(PChart *chart)
/* smooth the grid */
maxiter = 10;
totiter = 0;
- climit = 0.00001f*nsize;
+ climit = 0.00001f * nsize;
for (it = 0; it < maxiter; it++) {
moved = 0.0f;
for (x = 0; x < edgesx; x++) {
for (y = 0; y < edgesy; y++) {
- i = x + y*gridx;
- j = x + y*edgesx;
+ i = x + y * gridx;
+ j = x + y * edgesx;
- hedges[j] = (nodes[i] + nodes[i+1])*0.5f;
- vedges[j] = (nodes[i] + nodes[i+gridx])*0.5f;
+ hedges[j] = (nodes[i] + nodes[i + 1]) * 0.5f;
+ vedges[j] = (nodes[i] + nodes[i + gridx]) * 0.5f;
/* we do *inverse* mapping */
- hedges[j] = 1.0f/hedges[j];
- vedges[j] = 1.0f/vedges[j];
+ hedges[j] = 1.0f / hedges[j];
+ vedges[j] = 1.0f / vedges[j];
}
}
@@ -3926,37 +3928,37 @@ static void p_smooth(PChart *chart)
d = 0.0f;
totiter += 1;
- memcpy(oldnodesx, nodesx, sizeof(float)*nsize);
- memcpy(oldnodesy, nodesy, sizeof(float)*nsize);
+ memcpy(oldnodesx, nodesx, sizeof(float) * nsize);
+ memcpy(oldnodesy, nodesy, sizeof(float) * nsize);
- for (x=1; x < gridx-1; x++) {
- for (y=1; y < gridy-1; y++) {
+ for (x = 1; x < gridx - 1; x++) {
+ for (y = 1; y < gridy - 1; y++) {
float p[2], oldp[2], sum1, sum2, diff[2], length;
- i = x + gridx*y;
- j = x + edgesx*y;
+ i = x + gridx * y;
+ j = x + edgesx * y;
oldp[0] = oldnodesx[i];
oldp[1] = oldnodesy[i];
- sum1 = hedges[j-1]*oldnodesx[i-1];
- sum1 += hedges[j]*oldnodesx[i+1];
- sum1 += vedges[j-edgesx]*oldnodesx[i-gridx];
- sum1 += vedges[j]*oldnodesx[i+gridx];
+ sum1 = hedges[j - 1] * oldnodesx[i - 1];
+ sum1 += hedges[j] * oldnodesx[i + 1];
+ sum1 += vedges[j - edgesx] * oldnodesx[i - gridx];
+ sum1 += vedges[j] * oldnodesx[i + gridx];
- sum2 = hedges[j-1];
+ sum2 = hedges[j - 1];
sum2 += hedges[j];
- sum2 += vedges[j-edgesx];
+ sum2 += vedges[j - edgesx];
sum2 += vedges[j];
- nodesx[i] = sum1/sum2;
+ nodesx[i] = sum1 / sum2;
- sum1 = hedges[j-1]*oldnodesy[i-1];
- sum1 += hedges[j]*oldnodesy[i+1];
- sum1 += vedges[j-edgesx]*oldnodesy[i-gridx];
- sum1 += vedges[j]*oldnodesy[i+gridx];
+ sum1 = hedges[j - 1] * oldnodesy[i - 1];
+ sum1 += hedges[j] * oldnodesy[i + 1];
+ sum1 += vedges[j - edgesx] * oldnodesy[i - gridx];
+ sum1 += vedges[j] * oldnodesy[i + gridx];
- nodesy[i] = sum1/sum2;
+ nodesy[i] = sum1 / sum2;
p[0] = nodesx[i];
p[1] = nodesy[i];
@@ -3964,7 +3966,7 @@ static void p_smooth(PChart *chart)
diff[0] = p[0] - oldp[0];
diff[1] = p[1] - oldp[1];
- length = sqrt(diff[0]*diff[0] + diff[1]*diff[1]);
+ length = sqrt(diff[0] * diff[0] + diff[1] * diff[1]);
d = MAX2(d, length);
moved += length;
}
@@ -3984,8 +3986,8 @@ static void p_smooth(PChart *chart)
MEM_freeN(vedges);
/* create bsp */
- t = triangles = MEM_mallocN(sizeof(SmoothTriangle)*esize*2, "PSmoothTris");
- trip = tri = MEM_mallocN(sizeof(SmoothTriangle*)*esize*2, "PSmoothTriP");
+ t = triangles = MEM_mallocN(sizeof(SmoothTriangle) * esize * 2, "PSmoothTris");
+ trip = tri = MEM_mallocN(sizeof(SmoothTriangle *) * esize * 2, "PSmoothTriP");
if (!triangles || !tri) {
MEM_freeN(nodes);
@@ -4001,33 +4003,33 @@ static void p_smooth(PChart *chart)
for (x = 0; x < edgesx; x++) {
for (y = 0; y < edgesy; y++) {
- i = x + y*gridx;
+ i = x + y * gridx;
t->co1[0] = nodesx[i];
t->co1[1] = nodesy[i];
- t->co2[0] = nodesx[i+1];
- t->co2[1] = nodesy[i+1];
+ t->co2[0] = nodesx[i + 1];
+ t->co2[1] = nodesy[i + 1];
- t->co3[0] = nodesx[i+gridx];
- t->co3[1] = nodesy[i+gridx];
+ t->co3[0] = nodesx[i + gridx];
+ t->co3[1] = nodesy[i + gridx];
- t->oco1[0] = minv[0] + x*median;
- t->oco1[1] = minv[1] + y*median;
+ t->oco1[0] = minv[0] + x * median;
+ t->oco1[1] = minv[1] + y * median;
- t->oco2[0] = minv[0] + (x+1)*median;
- t->oco2[1] = minv[1] + y*median;
+ t->oco2[0] = minv[0] + (x + 1) * median;
+ t->oco2[1] = minv[1] + y * median;
- t->oco3[0] = minv[0] + x*median;
- t->oco3[1] = minv[1] + (y+1)*median;
+ t->oco3[0] = minv[0] + x * median;
+ t->oco3[1] = minv[1] + (y + 1) * median;
- t2 = t+1;
+ t2 = t + 1;
- t2->co1[0] = nodesx[i+gridx+1];
- t2->co1[1] = nodesy[i+gridx+1];
+ t2->co1[0] = nodesx[i + gridx + 1];
+ t2->co1[1] = nodesy[i + gridx + 1];
- t2->oco1[0] = minv[0] + (x+1)*median;
- t2->oco1[1] = minv[1] + (y+1)*median;
+ t2->oco1[0] = minv[0] + (x + 1) * median;
+ t2->oco1[1] = minv[1] + (y + 1) * median;
t2->co2[0] = t->co2[0]; t2->co2[1] = t->co2[1];
t2->oco2[0] = t->oco2[0]; t2->oco2[1] = t->oco2[1];
@@ -4044,10 +4046,10 @@ static void p_smooth(PChart *chart)
MEM_freeN(nodesx);
MEM_freeN(nodesy);
- arena = BLI_memarena_new(1<<16, "param smooth arena");
- root = p_node_new(arena, tri, esize*2, minv, maxv, 0);
+ arena = BLI_memarena_new(1 << 16, "param smooth arena");
+ root = p_node_new(arena, tri, esize * 2, minv, maxv, 0);
- for (v=chart->verts; v; v=v->nextlink)
+ for (v = chart->verts; v; v = v->nextlink)
if (!p_node_intersect(root, v->uv))
param_warning("area smoothing error: couldn't find mapping triangle\n");
@@ -4061,23 +4063,23 @@ static void p_smooth(PChart *chart)
ParamHandle *param_construct_begin(void)
{
- PHandle *handle = MEM_callocN(sizeof*handle, "PHandle");
+ PHandle *handle = MEM_callocN(sizeof *handle, "PHandle");
handle->construction_chart = p_chart_new(handle);
handle->state = PHANDLE_STATE_ALLOCATED;
- handle->arena = BLI_memarena_new((1<<16), "param construct arena");
+ handle->arena = BLI_memarena_new((1 << 16), "param construct arena");
handle->aspx = 1.0f;
handle->aspy = 1.0f;
- handle->hash_verts = phash_new((PHashLink**)&handle->construction_chart->verts, 1);
- handle->hash_edges = phash_new((PHashLink**)&handle->construction_chart->edges, 1);
- handle->hash_faces = phash_new((PHashLink**)&handle->construction_chart->faces, 1);
+ handle->hash_verts = phash_new((PHashLink **)&handle->construction_chart->verts, 1);
+ handle->hash_edges = phash_new((PHashLink **)&handle->construction_chart->edges, 1);
+ handle->hash_faces = phash_new((PHashLink **)&handle->construction_chart->faces, 1);
- return (ParamHandle*)handle;
+ return (ParamHandle *)handle;
}
void param_aspect_ratio(ParamHandle *handle, float aspx, float aspy)
{
- PHandle *phandle = (PHandle*)handle;
+ PHandle *phandle = (PHandle *)handle;
phandle->aspx = aspx;
phandle->aspy = aspy;
@@ -4085,11 +4087,11 @@ void param_aspect_ratio(ParamHandle *handle, float aspx, float aspy)
void param_delete(ParamHandle *handle)
{
- PHandle *phandle = (PHandle*)handle;
+ PHandle *phandle = (PHandle *)handle;
int i;
param_assert((phandle->state == PHANDLE_STATE_ALLOCATED) ||
- (phandle->state == PHANDLE_STATE_CONSTRUCTED));
+ (phandle->state == PHANDLE_STATE_CONSTRUCTED));
for (i = 0; i < phandle->ncharts; i++)
p_chart_delete(phandle->charts[i]);
@@ -4110,10 +4112,10 @@ void param_delete(ParamHandle *handle)
}
void param_face_add(ParamHandle *handle, ParamKey key, int nverts,
- ParamKey *vkeys, float **co, float **uv,
- ParamBool *pin, ParamBool *select)
+ ParamKey *vkeys, float **co, float **uv,
+ ParamBool *pin, ParamBool *select)
{
- PHandle *phandle = (PHandle*)handle;
+ PHandle *phandle = (PHandle *)handle;
param_assert(phash_lookup(phandle->hash_faces, key) == NULL);
param_assert(phandle->state == PHANDLE_STATE_ALLOCATED);
@@ -4135,7 +4137,7 @@ void param_face_add(ParamHandle *handle, ParamKey key, int nverts,
void param_edge_set_seam(ParamHandle *handle, ParamKey *vkeys)
{
- PHandle *phandle = (PHandle*)handle;
+ PHandle *phandle = (PHandle *)handle;
PEdge *e;
param_assert(phandle->state == PHANDLE_STATE_ALLOCATED);
@@ -4147,7 +4149,7 @@ void param_edge_set_seam(ParamHandle *handle, ParamKey *vkeys)
void param_construct_end(ParamHandle *handle, ParamBool fill, ParamBool impl)
{
- PHandle *phandle = (PHandle*)handle;
+ PHandle *phandle = (PHandle *)handle;
PChart *chart = phandle->construction_chart;
int i, j, nboundaries = 0;
PEdge *outer;
@@ -4182,7 +4184,7 @@ void param_construct_end(ParamHandle *handle, ParamBool fill, ParamBool impl)
if (fill && (nboundaries > 1))
p_chart_fill_boundaries(chart, outer);
- for (v=chart->verts; v; v=v->nextlink)
+ for (v = chart->verts; v; v = v->nextlink)
p_vert_load_pin_select_uvs(handle, v);
}
@@ -4193,7 +4195,7 @@ void param_construct_end(ParamHandle *handle, ParamBool fill, ParamBool impl)
void param_lscm_begin(ParamHandle *handle, ParamBool live, ParamBool abf)
{
- PHandle *phandle = (PHandle*)handle;
+ PHandle *phandle = (PHandle *)handle;
PFace *f;
int i;
@@ -4201,7 +4203,7 @@ void param_lscm_begin(ParamHandle *handle, ParamBool live, ParamBool abf)
phandle->state = PHANDLE_STATE_LSCM;
for (i = 0; i < phandle->ncharts; i++) {
- for (f=phandle->charts[i]->faces; f; f=f->nextlink)
+ for (f = phandle->charts[i]->faces; f; f = f->nextlink)
p_face_backup_uvs(f);
p_chart_lscm_begin(phandle->charts[i], (PBool)live, (PBool)abf);
}
@@ -4209,7 +4211,7 @@ void param_lscm_begin(ParamHandle *handle, ParamBool live, ParamBool abf)
void param_lscm_solve(ParamHandle *handle)
{
- PHandle *phandle = (PHandle*)handle;
+ PHandle *phandle = (PHandle *)handle;
PChart *chart;
int i;
PBool result;
@@ -4233,7 +4235,7 @@ void param_lscm_solve(ParamHandle *handle)
void param_lscm_end(ParamHandle *handle)
{
- PHandle *phandle = (PHandle*)handle;
+ PHandle *phandle = (PHandle *)handle;
int i;
param_assert(phandle->state == PHANDLE_STATE_LSCM);
@@ -4250,7 +4252,7 @@ void param_lscm_end(ParamHandle *handle)
void param_stretch_begin(ParamHandle *handle)
{
- PHandle *phandle = (PHandle*)handle;
+ PHandle *phandle = (PHandle *)handle;
PChart *chart;
PVert *v;
PFace *f;
@@ -4265,12 +4267,12 @@ void param_stretch_begin(ParamHandle *handle)
for (i = 0; i < phandle->ncharts; i++) {
chart = phandle->charts[i];
- for (v=chart->verts; v; v=v->nextlink)
- v->flag &= ~PVERT_PIN; /* don't use user-defined pins */
+ for (v = chart->verts; v; v = v->nextlink)
+ v->flag &= ~PVERT_PIN; /* don't use user-defined pins */
p_stretch_pin_boundary(chart);
- for (f=chart->faces; f; f=f->nextlink) {
+ for (f = chart->faces; f; f = f->nextlink) {
p_face_backup_uvs(f);
f->u.area3d = p_face_area(f);
}
@@ -4279,7 +4281,7 @@ void param_stretch_begin(ParamHandle *handle)
void param_stretch_blend(ParamHandle *handle, float blend)
{
- PHandle *phandle = (PHandle*)handle;
+ PHandle *phandle = (PHandle *)handle;
param_assert(phandle->state == PHANDLE_STATE_STRETCH);
phandle->blend = blend;
@@ -4287,7 +4289,7 @@ void param_stretch_blend(ParamHandle *handle, float blend)
void param_stretch_iter(ParamHandle *handle)
{
- PHandle *phandle = (PHandle*)handle;
+ PHandle *phandle = (PHandle *)handle;
PChart *chart;
int i;
@@ -4301,7 +4303,7 @@ void param_stretch_iter(ParamHandle *handle)
void param_stretch_end(ParamHandle *handle)
{
- PHandle *phandle = (PHandle*)handle;
+ PHandle *phandle = (PHandle *)handle;
param_assert(phandle->state == PHANDLE_STATE_STRETCH);
phandle->state = PHANDLE_STATE_CONSTRUCTED;
@@ -4312,7 +4314,7 @@ void param_stretch_end(ParamHandle *handle)
void param_smooth_area(ParamHandle *handle)
{
- PHandle *phandle = (PHandle*)handle;
+ PHandle *phandle = (PHandle *)handle;
int i;
param_assert(phandle->state == PHANDLE_STATE_CONSTRUCTED);
@@ -4321,7 +4323,7 @@ void param_smooth_area(ParamHandle *handle)
PChart *chart = phandle->charts[i];
PVert *v;
- for (v=chart->verts; v; v=v->nextlink)
+ for (v = chart->verts; v; v = v->nextlink)
v->flag &= ~PVERT_PIN;
p_smooth(chart);
@@ -4335,20 +4337,20 @@ void param_pack(ParamHandle *handle, float margin)
float tot_width, tot_height, scale;
PChart *chart;
- int i, unpacked=0;
+ int i, unpacked = 0;
float trans[2];
- double area= 0.0;
+ double area = 0.0;
- PHandle *phandle = (PHandle*)handle;
+ PHandle *phandle = (PHandle *)handle;
if (phandle->ncharts == 0)
return;
if (phandle->aspx != phandle->aspy)
- param_scale(handle, 1.0f/phandle->aspx, 1.0f/phandle->aspy);
+ param_scale(handle, 1.0f / phandle->aspx, 1.0f / phandle->aspy);
/* we may not use all these boxes */
- boxarray = MEM_mallocN( phandle->ncharts*sizeof(boxPack), "boxPack box");
+ boxarray = MEM_mallocN(phandle->ncharts * sizeof(boxPack), "boxPack box");
for (i = 0; i < phandle->ncharts; i++) {
@@ -4359,7 +4361,7 @@ void param_pack(ParamHandle *handle, float margin)
continue;
}
- box = boxarray+(i-unpacked);
+ box = boxarray + (i - unpacked);
p_chart_uv_bbox(chart, trans, chart->u.pack.size);
@@ -4372,16 +4374,16 @@ void param_pack(ParamHandle *handle, float margin)
box->h = chart->u.pack.size[1] + trans[1];
box->index = i; /* warning this index skips PCHART_NOPACK boxes */
- if (margin>0.0f)
- area += sqrt(box->w*box->h);
+ if (margin > 0.0f)
+ area += sqrt(box->w * box->h);
}
- if (margin>0.0f) {
+ if (margin > 0.0f) {
/* multiply the margin by the area to give predictable results not dependent on UV scale,
* ...Without using the area running pack multiple times also gives a bad feedback loop.
* multiply by 0.1 so the margin value from the UI can be from 0.0 to 1.0 but not give a massive margin */
- margin = (margin*(float)area) * 0.1f;
- unpacked= 0;
+ margin = (margin * (float)area) * 0.1f;
+ unpacked = 0;
for (i = 0; i < phandle->ncharts; i++) {
chart = phandle->charts[i];
@@ -4390,24 +4392,24 @@ void param_pack(ParamHandle *handle, float margin)
continue;
}
- box = boxarray+(i-unpacked);
+ box = boxarray + (i - unpacked);
trans[0] = margin;
trans[1] = margin;
p_chart_uv_translate(chart, trans);
- box->w += margin*2;
- box->h += margin*2;
+ box->w += margin * 2;
+ box->h += margin * 2;
}
}
- boxPack2D(boxarray, phandle->ncharts-unpacked, &tot_width, &tot_height);
+ boxPack2D(boxarray, phandle->ncharts - unpacked, &tot_width, &tot_height);
- if (tot_height>tot_width)
- scale = 1.0f/tot_height;
+ if (tot_height > tot_width)
+ scale = 1.0f / tot_height;
else
- scale = 1.0f/tot_width;
+ scale = 1.0f / tot_width;
- for (i = 0; i < phandle->ncharts-unpacked; i++) {
- box = boxarray+i;
+ for (i = 0; i < phandle->ncharts - unpacked; i++) {
+ box = boxarray + i;
trans[0] = box->x;
trans[1] = box->y;
@@ -4428,7 +4430,7 @@ void param_average(ParamHandle *handle)
float tot_uvarea = 0.0f, tot_facearea = 0.0f;
float tot_fac, fac;
float minv[2], maxv[2], trans[2];
- PHandle *phandle = (PHandle*)handle;
+ PHandle *phandle = (PHandle *)handle;
if (phandle->ncharts == 0)
return;
@@ -4440,7 +4442,7 @@ void param_average(ParamHandle *handle)
chart->u.pack.area = 0.0f; /* 3d area */
chart->u.pack.rescale = 0.0f; /* UV area, abusing rescale for tmp storage, oh well :/ */
- for (f=chart->faces; f; f=f->nextlink) {
+ for (f = chart->faces; f; f = f->nextlink) {
chart->u.pack.area += p_face_area(f);
chart->u.pack.rescale += fabsf(p_face_uv_area_signed(f));
}
@@ -4449,12 +4451,12 @@ void param_average(ParamHandle *handle)
tot_uvarea += chart->u.pack.rescale;
}
- if (tot_facearea == tot_uvarea || tot_facearea==0.0f || tot_uvarea==0.0f) {
+ if (tot_facearea == tot_uvarea || tot_facearea == 0.0f || tot_uvarea == 0.0f) {
/* nothing to do */
return;
}
- tot_fac = tot_facearea/tot_uvarea;
+ tot_fac = tot_facearea / tot_uvarea;
for (i = 0; i < phandle->ncharts; i++) {
chart = phandle->charts[i];
@@ -4463,8 +4465,8 @@ void param_average(ParamHandle *handle)
/* Get the island center */
p_chart_uv_bbox(chart, minv, maxv);
- trans[0] = (minv[0] + maxv[0]) /-2.0f;
- trans[1] = (minv[1] + maxv[1]) /-2.0f;
+ trans[0] = (minv[0] + maxv[0]) / -2.0f;
+ trans[1] = (minv[1] + maxv[1]) / -2.0f;
/* Move center to 0,0 */
p_chart_uv_translate(chart, trans);
@@ -4480,7 +4482,7 @@ void param_average(ParamHandle *handle)
void param_scale(ParamHandle *handle, float x, float y)
{
- PHandle *phandle = (PHandle*)handle;
+ PHandle *phandle = (PHandle *)handle;
PChart *chart;
int i;
@@ -4492,7 +4494,7 @@ void param_scale(ParamHandle *handle, float x, float y)
void param_flush(ParamHandle *handle)
{
- PHandle *phandle = (PHandle*)handle;
+ PHandle *phandle = (PHandle *)handle;
PChart *chart;
int i;
@@ -4511,7 +4513,7 @@ void param_flush(ParamHandle *handle)
void param_flush_restore(ParamHandle *handle)
{
- PHandle *phandle = (PHandle*)handle;
+ PHandle *phandle = (PHandle *)handle;
PChart *chart;
PFace *f;
int i;
@@ -4519,7 +4521,7 @@ void param_flush_restore(ParamHandle *handle)
for (i = 0; i < phandle->ncharts; i++) {
chart = phandle->charts[i];
- for (f=chart->faces; f; f=f->nextlink)
+ for (f = chart->faces; f; f = f->nextlink)
p_face_restore_uvs(f);
}
}