Cleanup: `struct PHandle` merged with alias `typedef void ParamHandle`
Reviewed By: brecht Ref D15021
This commit is contained in:
parent
374ce5dcb4
commit
fdb1a7b5e1
|
@ -339,7 +339,6 @@ static ParamHandle *construct_param_handle(const Scene *scene,
|
|||
const UnwrapOptions *options,
|
||||
UnwrapResultInfo *result_info)
|
||||
{
|
||||
ParamHandle *handle;
|
||||
BMFace *efa;
|
||||
BMLoop *l;
|
||||
BMEdge *eed;
|
||||
|
@ -348,7 +347,7 @@ static ParamHandle *construct_param_handle(const Scene *scene,
|
|||
|
||||
const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPUV);
|
||||
|
||||
handle = GEO_uv_parametrizer_construct_begin();
|
||||
ParamHandle *handle = GEO_uv_parametrizer_construct_begin();
|
||||
|
||||
if (options->correct_aspect) {
|
||||
float aspx, aspy;
|
||||
|
@ -417,14 +416,13 @@ static ParamHandle *construct_param_handle_multi(const Scene *scene,
|
|||
const UnwrapOptions *options,
|
||||
int *count_fail)
|
||||
{
|
||||
ParamHandle *handle;
|
||||
BMFace *efa;
|
||||
BMLoop *l;
|
||||
BMEdge *eed;
|
||||
BMIter iter, liter;
|
||||
int i;
|
||||
|
||||
handle = GEO_uv_parametrizer_construct_begin();
|
||||
ParamHandle *handle = GEO_uv_parametrizer_construct_begin();
|
||||
|
||||
if (options->correct_aspect) {
|
||||
Object *ob = objects[0];
|
||||
|
@ -539,7 +537,6 @@ static ParamHandle *construct_param_handle_subsurfed(const Scene *scene,
|
|||
const UnwrapOptions *options,
|
||||
UnwrapResultInfo *result_info)
|
||||
{
|
||||
ParamHandle *handle;
|
||||
/* index pointers */
|
||||
MPoly *mpoly;
|
||||
MLoop *mloop;
|
||||
|
@ -571,7 +568,7 @@ static ParamHandle *construct_param_handle_subsurfed(const Scene *scene,
|
|||
|
||||
const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
|
||||
|
||||
handle = GEO_uv_parametrizer_construct_begin();
|
||||
ParamHandle *handle = GEO_uv_parametrizer_construct_begin();
|
||||
|
||||
if (options->correct_aspect) {
|
||||
float aspx, aspy;
|
||||
|
@ -1023,8 +1020,7 @@ static void uvedit_pack_islands(const Scene *scene, Object *ob, BMesh *bm)
|
|||
bool rotate = true;
|
||||
bool ignore_pinned = false;
|
||||
|
||||
ParamHandle *handle;
|
||||
handle = construct_param_handle(scene, ob, bm, &options, NULL);
|
||||
ParamHandle *handle = construct_param_handle(scene, ob, bm, &options, NULL);
|
||||
GEO_uv_parametrizer_pack(handle, scene->toolsettings->uvcalc_margin, rotate, ignore_pinned);
|
||||
GEO_uv_parametrizer_flush(handle);
|
||||
GEO_uv_parametrizer_delete(handle);
|
||||
|
@ -1043,8 +1039,7 @@ static void uvedit_pack_islands_multi(const Scene *scene,
|
|||
bool rotate,
|
||||
bool ignore_pinned)
|
||||
{
|
||||
ParamHandle *handle;
|
||||
handle = construct_param_handle_multi(scene, objects, objects_len, options, NULL);
|
||||
ParamHandle *handle = construct_param_handle_multi(scene, objects, objects_len, options, NULL);
|
||||
GEO_uv_parametrizer_pack(handle, scene->toolsettings->uvcalc_margin, rotate, ignore_pinned);
|
||||
GEO_uv_parametrizer_flush(handle);
|
||||
GEO_uv_parametrizer_delete(handle);
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void ParamHandle; /* handle to a set of charts */
|
||||
typedef intptr_t ParamKey; /* (hash) key for identifying verts and faces */
|
||||
typedef struct ParamHandle ParamHandle; /* Handle to an array of charts. */
|
||||
typedef intptr_t ParamKey; /* Key (hash) for identifying verts and faces. */
|
||||
typedef enum ParamBool {
|
||||
PARAM_TRUE = 1,
|
||||
PARAM_FALSE = 0,
|
||||
|
|
|
@ -59,7 +59,6 @@ typedef struct PHash {
|
|||
struct PChart;
|
||||
struct PEdge;
|
||||
struct PFace;
|
||||
struct PHandle;
|
||||
struct PVert;
|
||||
|
||||
/* Simplices */
|
||||
|
@ -171,7 +170,7 @@ typedef struct PChart {
|
|||
} u;
|
||||
|
||||
uchar flag;
|
||||
struct PHandle *handle;
|
||||
ParamHandle *handle;
|
||||
} PChart;
|
||||
|
||||
enum PChartFlag {
|
||||
|
@ -185,7 +184,7 @@ enum PHandleState {
|
|||
PHANDLE_STATE_STRETCH,
|
||||
};
|
||||
|
||||
typedef struct PHandle {
|
||||
typedef struct ParamHandle {
|
||||
enum PHandleState state;
|
||||
MemArena *arena;
|
||||
MemArena *polyfill_arena;
|
||||
|
@ -204,7 +203,7 @@ typedef struct PHandle {
|
|||
RNG *rng;
|
||||
float blend;
|
||||
bool do_aspect;
|
||||
} PHandle;
|
||||
} ParamHandle;
|
||||
|
||||
/* PHash
|
||||
* - special purpose hash that keeps all its elements in a single linked list.
|
||||
|
@ -637,7 +636,7 @@ static void p_chart_topological_sanity_check(PChart *chart)
|
|||
|
||||
/* Loading / Flushing */
|
||||
|
||||
static void p_vert_load_pin_select_uvs(PHandle *handle, PVert *v)
|
||||
static void p_vert_load_pin_select_uvs(ParamHandle *handle, PVert *v)
|
||||
{
|
||||
PEdge *e;
|
||||
int nedges = 0, npins = 0;
|
||||
|
@ -679,7 +678,7 @@ static void p_vert_load_pin_select_uvs(PHandle *handle, PVert *v)
|
|||
}
|
||||
}
|
||||
|
||||
static void p_flush_uvs(PHandle *handle, PChart *chart)
|
||||
static void p_flush_uvs(ParamHandle *handle, PChart *chart)
|
||||
{
|
||||
PEdge *e;
|
||||
|
||||
|
@ -691,7 +690,7 @@ static void p_flush_uvs(PHandle *handle, PChart *chart)
|
|||
}
|
||||
}
|
||||
|
||||
static void p_flush_uvs_blend(PHandle *handle, PChart *chart, float blend)
|
||||
static void p_flush_uvs_blend(ParamHandle *handle, PChart *chart, float blend)
|
||||
{
|
||||
PEdge *e;
|
||||
float invblend = 1.0f - blend;
|
||||
|
@ -742,7 +741,7 @@ static void p_face_restore_uvs(PFace *f)
|
|||
|
||||
/* Construction (use only during construction, relies on u.key being set */
|
||||
|
||||
static PVert *p_vert_add(PHandle *handle, PHashKey key, const float co[3], PEdge *e)
|
||||
static PVert *p_vert_add(ParamHandle *handle, PHashKey key, const float co[3], PEdge *e)
|
||||
{
|
||||
PVert *v = (PVert *)BLI_memarena_alloc(handle->arena, sizeof(*v));
|
||||
copy_v3_v3(v->co, co);
|
||||
|
@ -765,7 +764,7 @@ static PVert *p_vert_add(PHandle *handle, PHashKey key, const float co[3], PEdge
|
|||
return v;
|
||||
}
|
||||
|
||||
static PVert *p_vert_lookup(PHandle *handle, PHashKey key, const float co[3], PEdge *e)
|
||||
static PVert *p_vert_lookup(ParamHandle *handle, PHashKey key, const float co[3], PEdge *e)
|
||||
{
|
||||
PVert *v = (PVert *)phash_lookup(handle->hash_verts, key);
|
||||
|
||||
|
@ -789,7 +788,7 @@ static PVert *p_vert_copy(PChart *chart, PVert *v)
|
|||
return nv;
|
||||
}
|
||||
|
||||
static PEdge *p_edge_lookup(PHandle *handle, const PHashKey *vkeys)
|
||||
static PEdge *p_edge_lookup(ParamHandle *handle, const PHashKey *vkeys)
|
||||
{
|
||||
PHashKey key = PHASH_edge(vkeys[0], vkeys[1]);
|
||||
PEdge *e = (PEdge *)phash_lookup(handle->hash_edges, key);
|
||||
|
@ -808,9 +807,8 @@ static PEdge *p_edge_lookup(PHandle *handle, const PHashKey *vkeys)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static int p_face_exists(ParamHandle *phandle, ParamKey *pvkeys, int i1, int i2, int i3)
|
||||
static int p_face_exists(ParamHandle *handle, ParamKey *pvkeys, int i1, int i2, int i3)
|
||||
{
|
||||
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);
|
||||
|
@ -833,7 +831,7 @@ static int p_face_exists(ParamHandle *phandle, ParamKey *pvkeys, int i1, int i2,
|
|||
return P_FALSE;
|
||||
}
|
||||
|
||||
static PChart *p_chart_new(PHandle *handle)
|
||||
static PChart *p_chart_new(ParamHandle *handle)
|
||||
{
|
||||
PChart *chart = (PChart *)MEM_callocN(sizeof(*chart), "PChart");
|
||||
chart->handle = handle;
|
||||
|
@ -881,7 +879,10 @@ static PBool p_edge_implicit_seam(PEdge *e, PEdge *ep)
|
|||
return P_FALSE;
|
||||
}
|
||||
|
||||
static PBool p_edge_has_pair(PHandle *handle, PEdge *e, PBool topology_from_uvs, PEdge **r_pair)
|
||||
static PBool p_edge_has_pair(ParamHandle *handle,
|
||||
PEdge *e,
|
||||
PBool topology_from_uvs,
|
||||
PEdge **r_pair)
|
||||
{
|
||||
PHashKey key;
|
||||
PEdge *pe;
|
||||
|
@ -930,7 +931,7 @@ static PBool p_edge_has_pair(PHandle *handle, PEdge *e, PBool topology_from_uvs,
|
|||
return (*r_pair != NULL);
|
||||
}
|
||||
|
||||
static PBool p_edge_connect_pair(PHandle *handle,
|
||||
static PBool p_edge_connect_pair(ParamHandle *handle,
|
||||
PEdge *e,
|
||||
PBool topology_from_uvs,
|
||||
PEdge ***stack)
|
||||
|
@ -954,7 +955,7 @@ static PBool p_edge_connect_pair(PHandle *handle,
|
|||
return (e->pair != NULL);
|
||||
}
|
||||
|
||||
static int p_connect_pairs(PHandle *handle, PBool topology_from_uvs)
|
||||
static int p_connect_pairs(ParamHandle *handle, PBool topology_from_uvs)
|
||||
{
|
||||
PEdge **stackbase = MEM_mallocN(sizeof(*stackbase) * phash_size(handle->hash_faces),
|
||||
"Pstackbase");
|
||||
|
@ -1061,7 +1062,7 @@ static void p_split_vert(PChart *chart, PEdge *e)
|
|||
}
|
||||
}
|
||||
|
||||
static PChart **p_split_charts(PHandle *handle, PChart *chart, int ncharts)
|
||||
static PChart **p_split_charts(ParamHandle *handle, PChart *chart, int ncharts)
|
||||
{
|
||||
PChart **charts = MEM_mallocN(sizeof(*charts) * ncharts, "PCharts"), *nchart;
|
||||
PFace *f, *nextf;
|
||||
|
@ -1100,7 +1101,7 @@ static PChart **p_split_charts(PHandle *handle, PChart *chart, int ncharts)
|
|||
return charts;
|
||||
}
|
||||
|
||||
static PFace *p_face_add(PHandle *handle)
|
||||
static PFace *p_face_add(ParamHandle *handle)
|
||||
{
|
||||
PFace *f;
|
||||
PEdge *e1, *e2, *e3;
|
||||
|
@ -1132,7 +1133,7 @@ static PFace *p_face_add(PHandle *handle)
|
|||
return f;
|
||||
}
|
||||
|
||||
static PFace *p_face_add_construct(PHandle *handle,
|
||||
static PFace *p_face_add_construct(ParamHandle *handle,
|
||||
ParamKey key,
|
||||
const ParamKey *vkeys,
|
||||
float *co[4],
|
||||
|
@ -1219,7 +1220,7 @@ static PFace *p_face_add_fill(PChart *chart, PVert *v1, PVert *v2, PVert *v3)
|
|||
return f;
|
||||
}
|
||||
|
||||
static PBool p_quad_split_direction(PHandle *handle, float **co, PHashKey *vkeys)
|
||||
static PBool p_quad_split_direction(ParamHandle *handle, float **co, PHashKey *vkeys)
|
||||
{
|
||||
/* Slight bias to prefer one edge over the other in case they are equal, so
|
||||
* that in symmetric models we choose the same split direction instead of
|
||||
|
@ -3212,7 +3213,7 @@ static void p_chart_lscm_begin(PChart *chart, PBool live, PBool abf)
|
|||
}
|
||||
}
|
||||
|
||||
static PBool p_chart_lscm_solve(PHandle *handle, PChart *chart)
|
||||
static PBool p_chart_lscm_solve(ParamHandle *handle, PChart *chart)
|
||||
{
|
||||
LinearSolver *context = chart->u.lscm.context;
|
||||
PVert *v, *pin1 = chart->u.lscm.pin1, *pin2 = chart->u.lscm.pin2;
|
||||
|
@ -4361,7 +4362,7 @@ static void p_smooth(PChart *chart)
|
|||
|
||||
ParamHandle *GEO_uv_parametrizer_construct_begin(void)
|
||||
{
|
||||
PHandle *handle = MEM_callocN(sizeof(*handle), "PHandle");
|
||||
ParamHandle *handle = MEM_callocN(sizeof(*handle), "ParamHandle");
|
||||
handle->construction_chart = p_chart_new(handle);
|
||||
handle->state = PHANDLE_STATE_ALLOCATED;
|
||||
handle->arena = BLI_memarena_new(MEM_SIZE_OPTIMAL(1 << 16), "param construct arena");
|
||||
|
@ -4375,21 +4376,18 @@ ParamHandle *GEO_uv_parametrizer_construct_begin(void)
|
|||
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 handle;
|
||||
}
|
||||
|
||||
void GEO_uv_parametrizer_aspect_ratio(ParamHandle *handle, float aspx, float aspy)
|
||||
void GEO_uv_parametrizer_aspect_ratio(ParamHandle *phandle, float aspx, float aspy)
|
||||
{
|
||||
PHandle *phandle = (PHandle *)handle;
|
||||
|
||||
phandle->aspx = aspx;
|
||||
phandle->aspy = aspy;
|
||||
phandle->do_aspect = true;
|
||||
}
|
||||
|
||||
void GEO_uv_parametrizer_delete(ParamHandle *handle)
|
||||
void GEO_uv_parametrizer_delete(ParamHandle *phandle)
|
||||
{
|
||||
PHandle *phandle = (PHandle *)handle;
|
||||
int i;
|
||||
|
||||
param_assert(ELEM(phandle->state, PHANDLE_STATE_ALLOCATED, PHANDLE_STATE_CONSTRUCTED));
|
||||
|
@ -4426,9 +4424,8 @@ static void p_add_ngon(ParamHandle *handle,
|
|||
ParamBool *select)
|
||||
{
|
||||
/* Allocate memory for polyfill. */
|
||||
PHandle *phandle = (PHandle *)handle;
|
||||
MemArena *arena = phandle->polyfill_arena;
|
||||
Heap *heap = phandle->polyfill_heap;
|
||||
MemArena *arena = handle->polyfill_arena;
|
||||
Heap *heap = handle->polyfill_heap;
|
||||
uint nfilltri = nverts - 2;
|
||||
uint(*tris)[3] = BLI_memarena_alloc(arena, sizeof(*tris) * (size_t)nfilltri);
|
||||
float(*projverts)[2] = BLI_memarena_alloc(arena, sizeof(*projverts) * (size_t)nverts);
|
||||
|
@ -4478,7 +4475,7 @@ static void p_add_ngon(ParamHandle *handle,
|
|||
BLI_memarena_clear(arena);
|
||||
}
|
||||
|
||||
void GEO_uv_parametrizer_face_add(ParamHandle *handle,
|
||||
void GEO_uv_parametrizer_face_add(ParamHandle *phandle,
|
||||
ParamKey key,
|
||||
int nverts,
|
||||
ParamKey *vkeys,
|
||||
|
@ -4487,15 +4484,13 @@ void GEO_uv_parametrizer_face_add(ParamHandle *handle,
|
|||
ParamBool *pin,
|
||||
ParamBool *select)
|
||||
{
|
||||
PHandle *phandle = (PHandle *)handle;
|
||||
|
||||
param_assert(phash_lookup(phandle->hash_faces, key) == NULL);
|
||||
param_assert(phandle->state == PHANDLE_STATE_ALLOCATED);
|
||||
param_assert(ELEM(nverts, 3, 4));
|
||||
|
||||
if (nverts > 4) {
|
||||
/* ngon */
|
||||
p_add_ngon(handle, key, nverts, vkeys, co, uv, pin, select);
|
||||
p_add_ngon(phandle, key, nverts, vkeys, co, uv, pin, select);
|
||||
}
|
||||
else if (nverts == 4) {
|
||||
/* quad */
|
||||
|
@ -4514,9 +4509,8 @@ void GEO_uv_parametrizer_face_add(ParamHandle *handle,
|
|||
}
|
||||
}
|
||||
|
||||
void GEO_uv_parametrizer_edge_set_seam(ParamHandle *handle, ParamKey *vkeys)
|
||||
void GEO_uv_parametrizer_edge_set_seam(ParamHandle *phandle, ParamKey *vkeys)
|
||||
{
|
||||
PHandle *phandle = (PHandle *)handle;
|
||||
PEdge *e;
|
||||
|
||||
param_assert(phandle->state == PHANDLE_STATE_ALLOCATED);
|
||||
|
@ -4527,12 +4521,11 @@ void GEO_uv_parametrizer_edge_set_seam(ParamHandle *handle, ParamKey *vkeys)
|
|||
}
|
||||
}
|
||||
|
||||
void GEO_uv_parametrizer_construct_end(ParamHandle *handle,
|
||||
void GEO_uv_parametrizer_construct_end(ParamHandle *phandle,
|
||||
ParamBool fill,
|
||||
ParamBool topology_from_uvs,
|
||||
int *count_fail)
|
||||
{
|
||||
PHandle *phandle = (PHandle *)handle;
|
||||
PChart *chart = phandle->construction_chart;
|
||||
int i, j, nboundaries = 0;
|
||||
PEdge *outer;
|
||||
|
@ -4572,7 +4565,7 @@ void GEO_uv_parametrizer_construct_end(ParamHandle *handle,
|
|||
}
|
||||
|
||||
for (v = chart->verts; v; v = v->nextlink) {
|
||||
p_vert_load_pin_select_uvs(handle, v);
|
||||
p_vert_load_pin_select_uvs(phandle, v);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4581,9 +4574,8 @@ void GEO_uv_parametrizer_construct_end(ParamHandle *handle,
|
|||
phandle->state = PHANDLE_STATE_CONSTRUCTED;
|
||||
}
|
||||
|
||||
void GEO_uv_parametrizer_lscm_begin(ParamHandle *handle, ParamBool live, ParamBool abf)
|
||||
void GEO_uv_parametrizer_lscm_begin(ParamHandle *phandle, ParamBool live, ParamBool abf)
|
||||
{
|
||||
PHandle *phandle = (PHandle *)handle;
|
||||
PFace *f;
|
||||
int i;
|
||||
|
||||
|
@ -4598,9 +4590,8 @@ void GEO_uv_parametrizer_lscm_begin(ParamHandle *handle, ParamBool live, ParamBo
|
|||
}
|
||||
}
|
||||
|
||||
void GEO_uv_parametrizer_lscm_solve(ParamHandle *handle, int *count_changed, int *count_failed)
|
||||
void GEO_uv_parametrizer_lscm_solve(ParamHandle *phandle, int *count_changed, int *count_failed)
|
||||
{
|
||||
PHandle *phandle = (PHandle *)handle;
|
||||
PChart *chart;
|
||||
int i;
|
||||
|
||||
|
@ -4638,9 +4629,8 @@ void GEO_uv_parametrizer_lscm_solve(ParamHandle *handle, int *count_changed, int
|
|||
}
|
||||
}
|
||||
|
||||
void GEO_uv_parametrizer_lscm_end(ParamHandle *handle)
|
||||
void GEO_uv_parametrizer_lscm_end(ParamHandle *phandle)
|
||||
{
|
||||
PHandle *phandle = (PHandle *)handle;
|
||||
int i;
|
||||
|
||||
param_assert(phandle->state == PHANDLE_STATE_LSCM);
|
||||
|
@ -4655,9 +4645,8 @@ void GEO_uv_parametrizer_lscm_end(ParamHandle *handle)
|
|||
phandle->state = PHANDLE_STATE_CONSTRUCTED;
|
||||
}
|
||||
|
||||
void GEO_uv_parametrizer_stretch_begin(ParamHandle *handle)
|
||||
void GEO_uv_parametrizer_stretch_begin(ParamHandle *phandle)
|
||||
{
|
||||
PHandle *phandle = (PHandle *)handle;
|
||||
PChart *chart;
|
||||
PVert *v;
|
||||
PFace *f;
|
||||
|
@ -4685,17 +4674,14 @@ void GEO_uv_parametrizer_stretch_begin(ParamHandle *handle)
|
|||
}
|
||||
}
|
||||
|
||||
void GEO_uv_parametrizer_stretch_blend(ParamHandle *handle, float blend)
|
||||
void GEO_uv_parametrizer_stretch_blend(ParamHandle *phandle, float blend)
|
||||
{
|
||||
PHandle *phandle = (PHandle *)handle;
|
||||
|
||||
param_assert(phandle->state == PHANDLE_STATE_STRETCH);
|
||||
phandle->blend = blend;
|
||||
}
|
||||
|
||||
void GEO_uv_parametrizer_stretch_iter(ParamHandle *handle)
|
||||
void GEO_uv_parametrizer_stretch_iter(ParamHandle *phandle)
|
||||
{
|
||||
PHandle *phandle = (PHandle *)handle;
|
||||
PChart *chart;
|
||||
int i;
|
||||
|
||||
|
@ -4707,10 +4693,8 @@ void GEO_uv_parametrizer_stretch_iter(ParamHandle *handle)
|
|||
}
|
||||
}
|
||||
|
||||
void GEO_uv_parametrizer_stretch_end(ParamHandle *handle)
|
||||
void GEO_uv_parametrizer_stretch_end(ParamHandle *phandle)
|
||||
{
|
||||
PHandle *phandle = (PHandle *)handle;
|
||||
|
||||
param_assert(phandle->state == PHANDLE_STATE_STRETCH);
|
||||
phandle->state = PHANDLE_STATE_CONSTRUCTED;
|
||||
|
||||
|
@ -4718,9 +4702,8 @@ void GEO_uv_parametrizer_stretch_end(ParamHandle *handle)
|
|||
phandle->rng = NULL;
|
||||
}
|
||||
|
||||
void GEO_uv_parametrizer_smooth_area(ParamHandle *handle)
|
||||
void GEO_uv_parametrizer_smooth_area(ParamHandle *phandle)
|
||||
{
|
||||
PHandle *phandle = (PHandle *)handle;
|
||||
int i;
|
||||
|
||||
param_assert(phandle->state == PHANDLE_STATE_CONSTRUCTED);
|
||||
|
@ -4738,13 +4721,11 @@ void GEO_uv_parametrizer_smooth_area(ParamHandle *handle)
|
|||
}
|
||||
|
||||
/* don't pack, just rotate (used for better packing) */
|
||||
static void GEO_uv_parametrizer_pack_rotate(ParamHandle *handle, bool ignore_pinned)
|
||||
static void GEO_uv_parametrizer_pack_rotate(ParamHandle *phandle, bool ignore_pinned)
|
||||
{
|
||||
PChart *chart;
|
||||
int i;
|
||||
|
||||
PHandle *phandle = (PHandle *)handle;
|
||||
|
||||
for (i = 0; i < phandle->ncharts; i++) {
|
||||
chart = phandle->charts[i];
|
||||
|
||||
|
@ -4770,9 +4751,7 @@ void GEO_uv_parametrizer_pack(ParamHandle *handle,
|
|||
float trans[2];
|
||||
double area = 0.0;
|
||||
|
||||
PHandle *phandle = (PHandle *)handle;
|
||||
|
||||
if (phandle->ncharts == 0) {
|
||||
if (handle->ncharts == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -4781,15 +4760,15 @@ void GEO_uv_parametrizer_pack(ParamHandle *handle,
|
|||
GEO_uv_parametrizer_pack_rotate(handle, ignore_pinned);
|
||||
}
|
||||
|
||||
if (phandle->aspx != phandle->aspy) {
|
||||
GEO_uv_parametrizer_scale(handle, 1.0f / phandle->aspx, 1.0f / phandle->aspy);
|
||||
if (handle->aspx != handle->aspy) {
|
||||
GEO_uv_parametrizer_scale(handle, 1.0f / handle->aspx, 1.0f / handle->aspy);
|
||||
}
|
||||
|
||||
/* we may not use all these boxes */
|
||||
boxarray = MEM_mallocN(phandle->ncharts * sizeof(BoxPack), "BoxPack box");
|
||||
boxarray = MEM_mallocN(handle->ncharts * sizeof(BoxPack), "BoxPack box");
|
||||
|
||||
for (i = 0; i < phandle->ncharts; i++) {
|
||||
chart = phandle->charts[i];
|
||||
for (i = 0; i < handle->ncharts; i++) {
|
||||
chart = handle->charts[i];
|
||||
|
||||
if (ignore_pinned && (chart->flag & PCHART_HAS_PINS)) {
|
||||
unpacked++;
|
||||
|
@ -4821,8 +4800,8 @@ void GEO_uv_parametrizer_pack(ParamHandle *handle,
|
|||
* 0.0 to 1.0 but not give a massive margin */
|
||||
margin = (margin * (float)area) * 0.1f;
|
||||
unpacked = 0;
|
||||
for (i = 0; i < phandle->ncharts; i++) {
|
||||
chart = phandle->charts[i];
|
||||
for (i = 0; i < handle->ncharts; i++) {
|
||||
chart = handle->charts[i];
|
||||
|
||||
if (ignore_pinned && (chart->flag & PCHART_HAS_PINS)) {
|
||||
unpacked++;
|
||||
|
@ -4838,7 +4817,7 @@ void GEO_uv_parametrizer_pack(ParamHandle *handle,
|
|||
}
|
||||
}
|
||||
|
||||
BLI_box_pack_2d(boxarray, phandle->ncharts - unpacked, &tot_width, &tot_height);
|
||||
BLI_box_pack_2d(boxarray, handle->ncharts - unpacked, &tot_width, &tot_height);
|
||||
|
||||
if (tot_height > tot_width) {
|
||||
scale = tot_height != 0.0f ? (1.0f / tot_height) : 1.0f;
|
||||
|
@ -4847,30 +4826,29 @@ void GEO_uv_parametrizer_pack(ParamHandle *handle,
|
|||
scale = tot_width != 0.0f ? (1.0f / tot_width) : 1.0f;
|
||||
}
|
||||
|
||||
for (i = 0; i < phandle->ncharts - unpacked; i++) {
|
||||
for (i = 0; i < handle->ncharts - unpacked; i++) {
|
||||
box = boxarray + i;
|
||||
trans[0] = box->x;
|
||||
trans[1] = box->y;
|
||||
|
||||
chart = phandle->charts[box->index];
|
||||
chart = handle->charts[box->index];
|
||||
p_chart_uv_translate(chart, trans);
|
||||
p_chart_uv_scale(chart, scale);
|
||||
}
|
||||
MEM_freeN(boxarray);
|
||||
|
||||
if (phandle->aspx != phandle->aspy) {
|
||||
GEO_uv_parametrizer_scale(handle, phandle->aspx, phandle->aspy);
|
||||
if (handle->aspx != handle->aspy) {
|
||||
GEO_uv_parametrizer_scale(handle, handle->aspx, handle->aspy);
|
||||
}
|
||||
}
|
||||
|
||||
void GEO_uv_parametrizer_average(ParamHandle *handle, bool ignore_pinned)
|
||||
void GEO_uv_parametrizer_average(ParamHandle *phandle, bool ignore_pinned)
|
||||
{
|
||||
PChart *chart;
|
||||
int i;
|
||||
float tot_uvarea = 0.0f, tot_facearea = 0.0f;
|
||||
float tot_fac, fac;
|
||||
float minv[2], maxv[2], trans[2];
|
||||
PHandle *phandle = (PHandle *)handle;
|
||||
|
||||
if (phandle->ncharts == 0) {
|
||||
return;
|
||||
|
@ -4930,9 +4908,8 @@ void GEO_uv_parametrizer_average(ParamHandle *handle, bool ignore_pinned)
|
|||
}
|
||||
}
|
||||
|
||||
void GEO_uv_parametrizer_scale(ParamHandle *handle, float x, float y)
|
||||
void GEO_uv_parametrizer_scale(ParamHandle *phandle, float x, float y)
|
||||
{
|
||||
PHandle *phandle = (PHandle *)handle;
|
||||
PChart *chart;
|
||||
int i;
|
||||
|
||||
|
@ -4942,9 +4919,8 @@ void GEO_uv_parametrizer_scale(ParamHandle *handle, float x, float y)
|
|||
}
|
||||
}
|
||||
|
||||
void GEO_uv_parametrizer_flush(ParamHandle *handle)
|
||||
void GEO_uv_parametrizer_flush(ParamHandle *phandle)
|
||||
{
|
||||
PHandle *phandle = (PHandle *)handle;
|
||||
PChart *chart;
|
||||
int i;
|
||||
|
||||
|
@ -4964,9 +4940,8 @@ void GEO_uv_parametrizer_flush(ParamHandle *handle)
|
|||
}
|
||||
}
|
||||
|
||||
void GEO_uv_parametrizer_flush_restore(ParamHandle *handle)
|
||||
void GEO_uv_parametrizer_flush_restore(ParamHandle *phandle)
|
||||
{
|
||||
PHandle *phandle = (PHandle *)handle;
|
||||
PChart *chart;
|
||||
PFace *f;
|
||||
int i;
|
||||
|
|
Loading…
Reference in New Issue