Cleanup: Move UV edit parameterize code to geometry module
This will allow reusing it elsewhere, such as in a geometry node. Differential Revision: https://developer.blender.org/D14453
This commit is contained in:
parent
4a93c4bf1d
commit
eddffdd398
|
@ -7,6 +7,7 @@ set(INC
|
|||
../../blentranslation
|
||||
../../bmesh
|
||||
../../depsgraph
|
||||
../../geometry
|
||||
../../gpu
|
||||
../../makesdna
|
||||
../../makesrna
|
||||
|
@ -24,7 +25,6 @@ set(SRC
|
|||
uvedit_draw.c
|
||||
uvedit_islands.c
|
||||
uvedit_ops.c
|
||||
uvedit_parametrizer.c
|
||||
uvedit_path.c
|
||||
uvedit_rip.c
|
||||
uvedit_select.c
|
||||
|
@ -32,7 +32,6 @@ set(SRC
|
|||
uvedit_unwrap_ops.c
|
||||
|
||||
uvedit_intern.h
|
||||
uvedit_parametrizer.h
|
||||
)
|
||||
|
||||
set(LIB
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*
|
||||
* Utilities for manipulating UV islands.
|
||||
*
|
||||
* \note This is similar to `uvedit_parametrizer.c`,
|
||||
* \note This is similar to `GEO_uv_parametrizer.h`,
|
||||
* however the data structures there don't support arbitrary topology
|
||||
* such as an edge with 3 or more faces using it.
|
||||
* This API uses #BMesh data structures and doesn't have limitations for manifold meshes.
|
||||
|
|
|
@ -1,99 +0,0 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#pragma once
|
||||
|
||||
/** \file
|
||||
* \ingroup eduv
|
||||
*/
|
||||
|
||||
#include "BLI_sys_types.h" /* for intptr_t support */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void ParamHandle; /* handle to a set of charts */
|
||||
typedef intptr_t ParamKey; /* (hash) key for identifying verts and faces */
|
||||
typedef enum ParamBool {
|
||||
PARAM_TRUE = 1,
|
||||
PARAM_FALSE = 0,
|
||||
} ParamBool;
|
||||
|
||||
/* Chart construction:
|
||||
* -------------------
|
||||
* - faces and seams may only be added between construct_{begin|end}
|
||||
* - the pointers to co and uv are stored, rather than being copied
|
||||
* - vertices are implicitly created
|
||||
* - in construct_end the mesh will be split up according to the seams
|
||||
* - the resulting charts must be:
|
||||
* - manifold, connected, open (at least one boundary loop)
|
||||
* - output will be written to the uv pointers
|
||||
*/
|
||||
|
||||
ParamHandle *param_construct_begin(void);
|
||||
|
||||
void param_aspect_ratio(ParamHandle *handle, float aspx, float aspy);
|
||||
|
||||
void param_face_add(ParamHandle *handle,
|
||||
ParamKey key,
|
||||
int nverts,
|
||||
ParamKey *vkeys,
|
||||
float *co[4],
|
||||
float *uv[4],
|
||||
ParamBool *pin,
|
||||
ParamBool *select);
|
||||
|
||||
void param_edge_set_seam(ParamHandle *handle, ParamKey *vkeys);
|
||||
|
||||
void param_construct_end(ParamHandle *handle,
|
||||
ParamBool fill,
|
||||
ParamBool topology_from_uvs,
|
||||
int *count_fail);
|
||||
void param_delete(ParamHandle *handle);
|
||||
|
||||
/* Least Squares Conformal Maps:
|
||||
* -----------------------------
|
||||
* - charts with less than two pinned vertices are assigned 2 pins
|
||||
* - lscm is divided in three steps:
|
||||
* - begin: compute matrix and its factorization (expensive)
|
||||
* - solve using pinned coordinates (cheap)
|
||||
* - end: clean up
|
||||
* - uv coordinates are allowed to change within begin/end, for
|
||||
* quick re-solving
|
||||
*/
|
||||
|
||||
void param_lscm_begin(ParamHandle *handle, ParamBool live, ParamBool abf);
|
||||
void param_lscm_solve(ParamHandle *handle, int *count_changed, int *count_failed);
|
||||
void param_lscm_end(ParamHandle *handle);
|
||||
|
||||
/* Stretch */
|
||||
|
||||
void param_stretch_begin(ParamHandle *handle);
|
||||
void param_stretch_blend(ParamHandle *handle, float blend);
|
||||
void param_stretch_iter(ParamHandle *handle);
|
||||
void param_stretch_end(ParamHandle *handle);
|
||||
|
||||
/* Area Smooth */
|
||||
|
||||
void param_smooth_area(ParamHandle *handle);
|
||||
|
||||
/* Packing */
|
||||
|
||||
void param_pack(ParamHandle *handle, float margin, bool do_rotate, bool ignore_pinned);
|
||||
|
||||
/* Average area for all charts */
|
||||
|
||||
void param_average(ParamHandle *handle, bool ignore_pinned);
|
||||
|
||||
/* Simple x,y scale */
|
||||
|
||||
void param_scale(ParamHandle *handle, float x, float y);
|
||||
|
||||
/* Flushing */
|
||||
|
||||
void param_flush(ParamHandle *handle);
|
||||
void param_flush_restore(ParamHandle *handle);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -46,6 +46,8 @@
|
|||
|
||||
#include "DEG_depsgraph.h"
|
||||
|
||||
#include "GEO_uv_parametrizer.h"
|
||||
|
||||
#include "PIL_time.h"
|
||||
|
||||
#include "UI_interface.h"
|
||||
|
@ -64,7 +66,6 @@
|
|||
#include "WM_types.h"
|
||||
|
||||
#include "uvedit_intern.h"
|
||||
#include "uvedit_parametrizer.h"
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Utility Functions
|
||||
|
@ -319,7 +320,7 @@ static void construct_param_handle_face_add(ParamHandle *handle,
|
|||
select[i] = uvedit_uv_select_test(scene, l, cd_loop_uv_offset);
|
||||
}
|
||||
|
||||
param_face_add(handle, key, i, vkeys, co, uv, pin, select);
|
||||
GEO_uv_parametrizer_face_add(handle, key, i, vkeys, co, uv, pin, select);
|
||||
}
|
||||
|
||||
/* See: construct_param_handle_multi to handle multiple objects at once. */
|
||||
|
@ -338,7 +339,7 @@ static ParamHandle *construct_param_handle(const Scene *scene,
|
|||
|
||||
const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPUV);
|
||||
|
||||
handle = param_construct_begin();
|
||||
handle = GEO_uv_parametrizer_construct_begin();
|
||||
|
||||
if (options->correct_aspect) {
|
||||
float aspx, aspy;
|
||||
|
@ -346,7 +347,7 @@ static ParamHandle *construct_param_handle(const Scene *scene,
|
|||
ED_uvedit_get_aspect(ob, &aspx, &aspy);
|
||||
|
||||
if (aspx != aspy) {
|
||||
param_aspect_ratio(handle, aspx, aspy);
|
||||
GEO_uv_parametrizer_aspect_ratio(handle, aspx, aspy);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -385,15 +386,15 @@ static ParamHandle *construct_param_handle(const Scene *scene,
|
|||
ParamKey vkeys[2];
|
||||
vkeys[0] = (ParamKey)BM_elem_index_get(eed->v1);
|
||||
vkeys[1] = (ParamKey)BM_elem_index_get(eed->v2);
|
||||
param_edge_set_seam(handle, vkeys);
|
||||
GEO_uv_parametrizer_edge_set_seam(handle, vkeys);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
param_construct_end(handle,
|
||||
options->fill_holes,
|
||||
options->topology_from_uvs,
|
||||
result_info ? &result_info->count_failed : NULL);
|
||||
GEO_uv_parametrizer_construct_end(handle,
|
||||
options->fill_holes,
|
||||
options->topology_from_uvs,
|
||||
result_info ? &result_info->count_failed : NULL);
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
@ -414,7 +415,7 @@ static ParamHandle *construct_param_handle_multi(const Scene *scene,
|
|||
BMIter iter, liter;
|
||||
int i;
|
||||
|
||||
handle = param_construct_begin();
|
||||
handle = GEO_uv_parametrizer_construct_begin();
|
||||
|
||||
if (options->correct_aspect) {
|
||||
Object *ob = objects[0];
|
||||
|
@ -422,7 +423,7 @@ static ParamHandle *construct_param_handle_multi(const Scene *scene,
|
|||
|
||||
ED_uvedit_get_aspect(ob, &aspx, &aspy);
|
||||
if (aspx != aspy) {
|
||||
param_aspect_ratio(handle, aspx, aspy);
|
||||
GEO_uv_parametrizer_aspect_ratio(handle, aspx, aspy);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -474,14 +475,15 @@ static ParamHandle *construct_param_handle_multi(const Scene *scene,
|
|||
ParamKey vkeys[2];
|
||||
vkeys[0] = (ParamKey)BM_elem_index_get(eed->v1);
|
||||
vkeys[1] = (ParamKey)BM_elem_index_get(eed->v2);
|
||||
param_edge_set_seam(handle, vkeys);
|
||||
GEO_uv_parametrizer_edge_set_seam(handle, vkeys);
|
||||
}
|
||||
}
|
||||
}
|
||||
offset += bm->totface;
|
||||
}
|
||||
|
||||
param_construct_end(handle, options->fill_holes, options->topology_from_uvs, count_fail);
|
||||
GEO_uv_parametrizer_construct_end(
|
||||
handle, options->fill_holes, options->topology_from_uvs, count_fail);
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
@ -560,7 +562,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 = param_construct_begin();
|
||||
handle = GEO_uv_parametrizer_construct_begin();
|
||||
|
||||
if (options->correct_aspect) {
|
||||
float aspx, aspy;
|
||||
|
@ -568,7 +570,7 @@ static ParamHandle *construct_param_handle_subsurfed(const Scene *scene,
|
|||
ED_uvedit_get_aspect(ob, &aspx, &aspy);
|
||||
|
||||
if (aspx != aspy) {
|
||||
param_aspect_ratio(handle, aspx, aspy);
|
||||
GEO_uv_parametrizer_aspect_ratio(handle, aspx, aspy);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -689,7 +691,7 @@ static ParamHandle *construct_param_handle_subsurfed(const Scene *scene,
|
|||
&pin[3],
|
||||
&select[3]);
|
||||
|
||||
param_face_add(handle, key, 4, vkeys, co, uv, pin, select);
|
||||
GEO_uv_parametrizer_face_add(handle, key, 4, vkeys, co, uv, pin, select);
|
||||
}
|
||||
|
||||
/* these are calculated from original mesh too */
|
||||
|
@ -698,14 +700,14 @@ static ParamHandle *construct_param_handle_subsurfed(const Scene *scene,
|
|||
ParamKey vkeys[2];
|
||||
vkeys[0] = (ParamKey)edge->v1;
|
||||
vkeys[1] = (ParamKey)edge->v2;
|
||||
param_edge_set_seam(handle, vkeys);
|
||||
GEO_uv_parametrizer_edge_set_seam(handle, vkeys);
|
||||
}
|
||||
}
|
||||
|
||||
param_construct_end(handle,
|
||||
options->fill_holes,
|
||||
options->topology_from_uvs,
|
||||
result_info ? &result_info->count_failed : NULL);
|
||||
GEO_uv_parametrizer_construct_end(handle,
|
||||
options->fill_holes,
|
||||
options->topology_from_uvs,
|
||||
result_info ? &result_info->count_failed : NULL);
|
||||
|
||||
/* cleanup */
|
||||
MEM_freeN(faceMap);
|
||||
|
@ -764,9 +766,9 @@ static bool minimize_stretch_init(bContext *C, wmOperator *op)
|
|||
ms->handle = construct_param_handle_multi(scene, objects, objects_len, &options, NULL);
|
||||
ms->lasttime = PIL_check_seconds_timer();
|
||||
|
||||
param_stretch_begin(ms->handle);
|
||||
GEO_uv_parametrizer_stretch_begin(ms->handle);
|
||||
if (ms->blend != 0.0f) {
|
||||
param_stretch_blend(ms->handle, ms->blend);
|
||||
GEO_uv_parametrizer_stretch_blend(ms->handle, ms->blend);
|
||||
}
|
||||
|
||||
op->customdata = ms;
|
||||
|
@ -782,8 +784,8 @@ static void minimize_stretch_iteration(bContext *C, wmOperator *op, bool interac
|
|||
ToolSettings *ts = scene->toolsettings;
|
||||
const bool synced_selection = (ts->uv_flag & UV_SYNC_SELECTION) != 0;
|
||||
|
||||
param_stretch_blend(ms->handle, ms->blend);
|
||||
param_stretch_iter(ms->handle);
|
||||
GEO_uv_parametrizer_stretch_blend(ms->handle, ms->blend);
|
||||
GEO_uv_parametrizer_stretch_iter(ms->handle);
|
||||
|
||||
ms->i++;
|
||||
RNA_int_set(op->ptr, "iterations", ms->i);
|
||||
|
@ -791,7 +793,7 @@ static void minimize_stretch_iteration(bContext *C, wmOperator *op, bool interac
|
|||
if (interactive && (PIL_check_seconds_timer() - ms->lasttime > 0.5)) {
|
||||
char str[UI_MAX_DRAW_STR];
|
||||
|
||||
param_flush(ms->handle);
|
||||
GEO_uv_parametrizer_flush(ms->handle);
|
||||
|
||||
if (area) {
|
||||
BLI_snprintf(str, sizeof(str), TIP_("Minimize Stretch. Blend %.2f"), ms->blend);
|
||||
|
@ -831,14 +833,14 @@ static void minimize_stretch_exit(bContext *C, wmOperator *op, bool cancel)
|
|||
}
|
||||
|
||||
if (cancel) {
|
||||
param_flush_restore(ms->handle);
|
||||
GEO_uv_parametrizer_flush_restore(ms->handle);
|
||||
}
|
||||
else {
|
||||
param_flush(ms->handle);
|
||||
GEO_uv_parametrizer_flush(ms->handle);
|
||||
}
|
||||
|
||||
param_stretch_end(ms->handle);
|
||||
param_delete(ms->handle);
|
||||
GEO_uv_parametrizer_stretch_end(ms->handle);
|
||||
GEO_uv_parametrizer_delete(ms->handle);
|
||||
|
||||
for (uint ob_index = 0; ob_index < ms->objects_len; ob_index++) {
|
||||
Object *obedit = ms->objects_edit[ob_index];
|
||||
|
@ -1014,9 +1016,9 @@ static void uvedit_pack_islands(const Scene *scene, Object *ob, BMesh *bm)
|
|||
|
||||
ParamHandle *handle;
|
||||
handle = construct_param_handle(scene, ob, bm, &options, NULL);
|
||||
param_pack(handle, scene->toolsettings->uvcalc_margin, rotate, ignore_pinned);
|
||||
param_flush(handle);
|
||||
param_delete(handle);
|
||||
GEO_uv_parametrizer_pack(handle, scene->toolsettings->uvcalc_margin, rotate, ignore_pinned);
|
||||
GEO_uv_parametrizer_flush(handle);
|
||||
GEO_uv_parametrizer_delete(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1034,9 +1036,9 @@ static void uvedit_pack_islands_multi(const Scene *scene,
|
|||
{
|
||||
ParamHandle *handle;
|
||||
handle = construct_param_handle_multi(scene, objects, objects_len, options, NULL);
|
||||
param_pack(handle, scene->toolsettings->uvcalc_margin, rotate, ignore_pinned);
|
||||
param_flush(handle);
|
||||
param_delete(handle);
|
||||
GEO_uv_parametrizer_pack(handle, scene->toolsettings->uvcalc_margin, rotate, ignore_pinned);
|
||||
GEO_uv_parametrizer_flush(handle);
|
||||
GEO_uv_parametrizer_delete(handle);
|
||||
|
||||
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
|
||||
Object *obedit = objects[ob_index];
|
||||
|
@ -1167,9 +1169,9 @@ static int average_islands_scale_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
}
|
||||
|
||||
ParamHandle *handle = construct_param_handle_multi(scene, objects, objects_len, &options, NULL);
|
||||
param_average(handle, false);
|
||||
param_flush(handle);
|
||||
param_delete(handle);
|
||||
GEO_uv_parametrizer_average(handle, false);
|
||||
GEO_uv_parametrizer_flush(handle);
|
||||
GEO_uv_parametrizer_delete(handle);
|
||||
|
||||
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
|
||||
Object *obedit = objects[ob_index];
|
||||
|
@ -1239,7 +1241,7 @@ void ED_uvedit_live_unwrap_begin(Scene *scene, Object *obedit)
|
|||
handle = construct_param_handle(scene, obedit, em->bm, &options, NULL);
|
||||
}
|
||||
|
||||
param_lscm_begin(handle, PARAM_TRUE, abf);
|
||||
GEO_uv_parametrizer_lscm_begin(handle, PARAM_TRUE, abf);
|
||||
|
||||
/* Create or increase size of g_live_unwrap.handles array */
|
||||
if (g_live_unwrap.handles == NULL) {
|
||||
|
@ -1261,8 +1263,8 @@ void ED_uvedit_live_unwrap_re_solve(void)
|
|||
{
|
||||
if (g_live_unwrap.handles) {
|
||||
for (int i = 0; i < g_live_unwrap.len; i++) {
|
||||
param_lscm_solve(g_live_unwrap.handles[i], NULL, NULL);
|
||||
param_flush(g_live_unwrap.handles[i]);
|
||||
GEO_uv_parametrizer_lscm_solve(g_live_unwrap.handles[i], NULL, NULL);
|
||||
GEO_uv_parametrizer_flush(g_live_unwrap.handles[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1271,11 +1273,11 @@ void ED_uvedit_live_unwrap_end(short cancel)
|
|||
{
|
||||
if (g_live_unwrap.handles) {
|
||||
for (int i = 0; i < g_live_unwrap.len; i++) {
|
||||
param_lscm_end(g_live_unwrap.handles[i]);
|
||||
GEO_uv_parametrizer_lscm_end(g_live_unwrap.handles[i]);
|
||||
if (cancel) {
|
||||
param_flush_restore(g_live_unwrap.handles[i]);
|
||||
GEO_uv_parametrizer_flush_restore(g_live_unwrap.handles[i]);
|
||||
}
|
||||
param_delete(g_live_unwrap.handles[i]);
|
||||
GEO_uv_parametrizer_delete(g_live_unwrap.handles[i]);
|
||||
}
|
||||
MEM_freeN(g_live_unwrap.handles);
|
||||
g_live_unwrap.handles = NULL;
|
||||
|
@ -1731,17 +1733,17 @@ static void uvedit_unwrap(const Scene *scene,
|
|||
handle = construct_param_handle(scene, obedit, em->bm, options, result_info);
|
||||
}
|
||||
|
||||
param_lscm_begin(handle, PARAM_FALSE, scene->toolsettings->unwrapper == 0);
|
||||
param_lscm_solve(handle,
|
||||
result_info ? &result_info->count_changed : NULL,
|
||||
result_info ? &result_info->count_failed : NULL);
|
||||
param_lscm_end(handle);
|
||||
GEO_uv_parametrizer_lscm_begin(handle, PARAM_FALSE, scene->toolsettings->unwrapper == 0);
|
||||
GEO_uv_parametrizer_lscm_solve(handle,
|
||||
result_info ? &result_info->count_changed : NULL,
|
||||
result_info ? &result_info->count_failed : NULL);
|
||||
GEO_uv_parametrizer_lscm_end(handle);
|
||||
|
||||
param_average(handle, true);
|
||||
GEO_uv_parametrizer_average(handle, true);
|
||||
|
||||
param_flush(handle);
|
||||
GEO_uv_parametrizer_flush(handle);
|
||||
|
||||
param_delete(handle);
|
||||
GEO_uv_parametrizer_delete(handle);
|
||||
}
|
||||
|
||||
static void uvedit_unwrap_multi(const Scene *scene,
|
||||
|
|
|
@ -9,6 +9,7 @@ set(INC
|
|||
../functions
|
||||
../makesdna
|
||||
../makesrna
|
||||
../../../intern/eigen
|
||||
../../../intern/guardedalloc
|
||||
${CMAKE_BINARY_DIR}/source/blender/makesdna/intern
|
||||
)
|
||||
|
@ -18,11 +19,13 @@ set(SRC
|
|||
intern/mesh_to_curve_convert.cc
|
||||
intern/point_merge_by_distance.cc
|
||||
intern/realize_instances.cc
|
||||
intern/uv_parametrizer.c
|
||||
|
||||
GEO_mesh_merge_by_distance.hh
|
||||
GEO_mesh_to_curve.hh
|
||||
GEO_point_merge_by_distance.hh
|
||||
GEO_realize_instances.hh
|
||||
GEO_uv_parametrizer.h
|
||||
)
|
||||
|
||||
set(LIB
|
||||
|
|
|
@ -0,0 +1,134 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "BLI_sys_types.h" /* for intptr_t support */
|
||||
|
||||
/** \file
|
||||
* \ingroup geo
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void ParamHandle; /* handle to a set of charts */
|
||||
typedef intptr_t ParamKey; /* (hash) key for identifying verts and faces */
|
||||
typedef enum ParamBool {
|
||||
PARAM_TRUE = 1,
|
||||
PARAM_FALSE = 0,
|
||||
} ParamBool;
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Chart Construction:
|
||||
*
|
||||
* Faces and seams may only be added between #GEO_uv_parametrizer_construct_begin and
|
||||
* #GEO_uv_parametrizer_construct_end.
|
||||
*
|
||||
* The pointers to `co` and `uv` are stored, rather than being copied. Vertices are implicitly
|
||||
* created.
|
||||
*
|
||||
* In #GEO_uv_parametrizer_construct_end the mesh will be split up according to the seams. The
|
||||
* resulting charts must be manifold, connected and open (at least one boundary loop). The output
|
||||
* will be written to the `uv` pointers.
|
||||
*
|
||||
* \{ */
|
||||
|
||||
ParamHandle *GEO_uv_parametrizer_construct_begin(void);
|
||||
|
||||
void GEO_uv_parametrizer_aspect_ratio(ParamHandle *handle, float aspx, float aspy);
|
||||
|
||||
void GEO_uv_parametrizer_face_add(ParamHandle *handle,
|
||||
ParamKey key,
|
||||
int nverts,
|
||||
ParamKey *vkeys,
|
||||
float *co[4],
|
||||
float *uv[4],
|
||||
ParamBool *pin,
|
||||
ParamBool *select);
|
||||
|
||||
void GEO_uv_parametrizer_edge_set_seam(ParamHandle *handle, ParamKey *vkeys);
|
||||
|
||||
void GEO_uv_parametrizer_construct_end(ParamHandle *handle,
|
||||
ParamBool fill,
|
||||
ParamBool topology_from_uvs,
|
||||
int *count_fail);
|
||||
void GEO_uv_parametrizer_delete(ParamHandle *handle);
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Least Squares Conformal Maps:
|
||||
*
|
||||
* Charts with less than two pinned vertices are assigned two pins. LSCM is divided to three steps:
|
||||
*
|
||||
* 1. Begin: compute matrix and its factorization (expensive).
|
||||
* 2. Solve using pinned coordinates (cheap).
|
||||
* 3. End: clean up.
|
||||
*
|
||||
* UV coordinates are allowed to change within begin/end, for quick re-solving.
|
||||
*
|
||||
* \{ */
|
||||
|
||||
void GEO_uv_parametrizer_lscm_begin(ParamHandle *handle, ParamBool live, ParamBool abf);
|
||||
void GEO_uv_parametrizer_lscm_solve(ParamHandle *handle, int *count_changed, int *count_failed);
|
||||
void GEO_uv_parametrizer_lscm_end(ParamHandle *handle);
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Stretch
|
||||
* \{ */
|
||||
|
||||
void GEO_uv_parametrizer_stretch_begin(ParamHandle *handle);
|
||||
void GEO_uv_parametrizer_stretch_blend(ParamHandle *handle, float blend);
|
||||
void GEO_uv_parametrizer_stretch_iter(ParamHandle *handle);
|
||||
void GEO_uv_parametrizer_stretch_end(ParamHandle *handle);
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Area Smooth
|
||||
* \{ */
|
||||
|
||||
void GEO_uv_parametrizer_smooth_area(ParamHandle *handle);
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Packing
|
||||
* \{ */
|
||||
|
||||
void GEO_uv_parametrizer_pack(ParamHandle *handle,
|
||||
float margin,
|
||||
bool do_rotate,
|
||||
bool ignore_pinned);
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Average area for all charts
|
||||
* \{ */
|
||||
|
||||
void GEO_uv_parametrizer_average(ParamHandle *handle, bool ignore_pinned);
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Simple x,y scale
|
||||
* \{ */
|
||||
|
||||
void GEO_uv_parametrizer_scale(ParamHandle *handle, float x, float y);
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Flushing
|
||||
* \{ */
|
||||
|
||||
void GEO_uv_parametrizer_flush(ParamHandle *handle);
|
||||
void GEO_uv_parametrizer_flush_restore(ParamHandle *handle);
|
||||
|
||||
/** \} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -16,7 +16,7 @@
|
|||
#include "BLI_rand.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "uvedit_parametrizer.h"
|
||||
#include "GEO_uv_parametrizer.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
|
@ -622,14 +622,14 @@ static void p_chart_topological_sanity_check(PChart *chart)
|
|||
PEdge *e;
|
||||
|
||||
for (v = chart->verts; v; v = v->nextlink) {
|
||||
param_test_equals_ptr("v->edge->vert", v, v->edge->vert);
|
||||
GEO_uv_parametrizer_test_equals_ptr("v->edge->vert", v, v->edge->vert);
|
||||
}
|
||||
|
||||
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);
|
||||
param_test_equals_ptr("pair->next->vert", e->next->vert, e->pair->vert);
|
||||
GEO_uv_parametrizer_test_equals_ptr("e->pair->pair", e, e->pair->pair);
|
||||
GEO_uv_parametrizer_test_equals_ptr("pair->vert", e->vert, e->pair->next->vert);
|
||||
GEO_uv_parametrizer_test_equals_ptr("pair->next->vert", e->next->vert, e->pair->vert);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4359,7 +4359,7 @@ static void p_smooth(PChart *chart)
|
|||
|
||||
/* Exported */
|
||||
|
||||
ParamHandle *param_construct_begin(void)
|
||||
ParamHandle *GEO_uv_parametrizer_construct_begin(void)
|
||||
{
|
||||
PHandle *handle = MEM_callocN(sizeof(*handle), "PHandle");
|
||||
handle->construction_chart = p_chart_new(handle);
|
||||
|
@ -4378,7 +4378,7 @@ ParamHandle *param_construct_begin(void)
|
|||
return (ParamHandle *)handle;
|
||||
}
|
||||
|
||||
void param_aspect_ratio(ParamHandle *handle, float aspx, float aspy)
|
||||
void GEO_uv_parametrizer_aspect_ratio(ParamHandle *handle, float aspx, float aspy)
|
||||
{
|
||||
PHandle *phandle = (PHandle *)handle;
|
||||
|
||||
|
@ -4387,7 +4387,7 @@ void param_aspect_ratio(ParamHandle *handle, float aspx, float aspy)
|
|||
phandle->do_aspect = true;
|
||||
}
|
||||
|
||||
void param_delete(ParamHandle *handle)
|
||||
void GEO_uv_parametrizer_delete(ParamHandle *handle)
|
||||
{
|
||||
PHandle *phandle = (PHandle *)handle;
|
||||
int i;
|
||||
|
@ -4472,20 +4472,20 @@ static void p_add_ngon(ParamHandle *handle,
|
|||
ParamBool tri_pin[3] = {pin[v0], pin[v1], pin[v2]};
|
||||
ParamBool tri_select[3] = {select[v0], select[v1], select[v2]};
|
||||
|
||||
param_face_add(handle, key, 3, tri_vkeys, tri_co, tri_uv, tri_pin, tri_select);
|
||||
GEO_uv_parametrizer_face_add(handle, key, 3, tri_vkeys, tri_co, tri_uv, tri_pin, tri_select);
|
||||
}
|
||||
|
||||
BLI_memarena_clear(arena);
|
||||
}
|
||||
|
||||
void param_face_add(ParamHandle *handle,
|
||||
ParamKey key,
|
||||
int nverts,
|
||||
ParamKey *vkeys,
|
||||
float *co[4],
|
||||
float *uv[4],
|
||||
ParamBool *pin,
|
||||
ParamBool *select)
|
||||
void GEO_uv_parametrizer_face_add(ParamHandle *handle,
|
||||
ParamKey key,
|
||||
int nverts,
|
||||
ParamKey *vkeys,
|
||||
float *co[4],
|
||||
float *uv[4],
|
||||
ParamBool *pin,
|
||||
ParamBool *select)
|
||||
{
|
||||
PHandle *phandle = (PHandle *)handle;
|
||||
|
||||
|
@ -4514,7 +4514,7 @@ void param_face_add(ParamHandle *handle,
|
|||
}
|
||||
}
|
||||
|
||||
void param_edge_set_seam(ParamHandle *handle, ParamKey *vkeys)
|
||||
void GEO_uv_parametrizer_edge_set_seam(ParamHandle *handle, ParamKey *vkeys)
|
||||
{
|
||||
PHandle *phandle = (PHandle *)handle;
|
||||
PEdge *e;
|
||||
|
@ -4527,10 +4527,10 @@ void param_edge_set_seam(ParamHandle *handle, ParamKey *vkeys)
|
|||
}
|
||||
}
|
||||
|
||||
void param_construct_end(ParamHandle *handle,
|
||||
ParamBool fill,
|
||||
ParamBool topology_from_uvs,
|
||||
int *count_fail)
|
||||
void GEO_uv_parametrizer_construct_end(ParamHandle *handle,
|
||||
ParamBool fill,
|
||||
ParamBool topology_from_uvs,
|
||||
int *count_fail)
|
||||
{
|
||||
PHandle *phandle = (PHandle *)handle;
|
||||
PChart *chart = phandle->construction_chart;
|
||||
|
@ -4581,7 +4581,7 @@ void param_construct_end(ParamHandle *handle,
|
|||
phandle->state = PHANDLE_STATE_CONSTRUCTED;
|
||||
}
|
||||
|
||||
void param_lscm_begin(ParamHandle *handle, ParamBool live, ParamBool abf)
|
||||
void GEO_uv_parametrizer_lscm_begin(ParamHandle *handle, ParamBool live, ParamBool abf)
|
||||
{
|
||||
PHandle *phandle = (PHandle *)handle;
|
||||
PFace *f;
|
||||
|
@ -4598,7 +4598,7 @@ void param_lscm_begin(ParamHandle *handle, ParamBool live, ParamBool abf)
|
|||
}
|
||||
}
|
||||
|
||||
void param_lscm_solve(ParamHandle *handle, int *count_changed, int *count_failed)
|
||||
void GEO_uv_parametrizer_lscm_solve(ParamHandle *handle, int *count_changed, int *count_failed)
|
||||
{
|
||||
PHandle *phandle = (PHandle *)handle;
|
||||
PChart *chart;
|
||||
|
@ -4638,7 +4638,7 @@ void param_lscm_solve(ParamHandle *handle, int *count_changed, int *count_failed
|
|||
}
|
||||
}
|
||||
|
||||
void param_lscm_end(ParamHandle *handle)
|
||||
void GEO_uv_parametrizer_lscm_end(ParamHandle *handle)
|
||||
{
|
||||
PHandle *phandle = (PHandle *)handle;
|
||||
int i;
|
||||
|
@ -4655,7 +4655,7 @@ void param_lscm_end(ParamHandle *handle)
|
|||
phandle->state = PHANDLE_STATE_CONSTRUCTED;
|
||||
}
|
||||
|
||||
void param_stretch_begin(ParamHandle *handle)
|
||||
void GEO_uv_parametrizer_stretch_begin(ParamHandle *handle)
|
||||
{
|
||||
PHandle *phandle = (PHandle *)handle;
|
||||
PChart *chart;
|
||||
|
@ -4685,7 +4685,7 @@ void param_stretch_begin(ParamHandle *handle)
|
|||
}
|
||||
}
|
||||
|
||||
void param_stretch_blend(ParamHandle *handle, float blend)
|
||||
void GEO_uv_parametrizer_stretch_blend(ParamHandle *handle, float blend)
|
||||
{
|
||||
PHandle *phandle = (PHandle *)handle;
|
||||
|
||||
|
@ -4693,7 +4693,7 @@ void param_stretch_blend(ParamHandle *handle, float blend)
|
|||
phandle->blend = blend;
|
||||
}
|
||||
|
||||
void param_stretch_iter(ParamHandle *handle)
|
||||
void GEO_uv_parametrizer_stretch_iter(ParamHandle *handle)
|
||||
{
|
||||
PHandle *phandle = (PHandle *)handle;
|
||||
PChart *chart;
|
||||
|
@ -4707,7 +4707,7 @@ void param_stretch_iter(ParamHandle *handle)
|
|||
}
|
||||
}
|
||||
|
||||
void param_stretch_end(ParamHandle *handle)
|
||||
void GEO_uv_parametrizer_stretch_end(ParamHandle *handle)
|
||||
{
|
||||
PHandle *phandle = (PHandle *)handle;
|
||||
|
||||
|
@ -4718,7 +4718,7 @@ void param_stretch_end(ParamHandle *handle)
|
|||
phandle->rng = NULL;
|
||||
}
|
||||
|
||||
void param_smooth_area(ParamHandle *handle)
|
||||
void GEO_uv_parametrizer_smooth_area(ParamHandle *handle)
|
||||
{
|
||||
PHandle *phandle = (PHandle *)handle;
|
||||
int i;
|
||||
|
@ -4738,7 +4738,7 @@ void param_smooth_area(ParamHandle *handle)
|
|||
}
|
||||
|
||||
/* don't pack, just rotate (used for better packing) */
|
||||
static void param_pack_rotate(ParamHandle *handle, bool ignore_pinned)
|
||||
static void GEO_uv_parametrizer_pack_rotate(ParamHandle *handle, bool ignore_pinned)
|
||||
{
|
||||
PChart *chart;
|
||||
int i;
|
||||
|
@ -4756,7 +4756,10 @@ static void param_pack_rotate(ParamHandle *handle, bool ignore_pinned)
|
|||
}
|
||||
}
|
||||
|
||||
void param_pack(ParamHandle *handle, float margin, bool do_rotate, bool ignore_pinned)
|
||||
void GEO_uv_parametrizer_pack(ParamHandle *handle,
|
||||
float margin,
|
||||
bool do_rotate,
|
||||
bool ignore_pinned)
|
||||
{
|
||||
/* box packing variables */
|
||||
BoxPack *boxarray, *box;
|
||||
|
@ -4775,11 +4778,11 @@ void param_pack(ParamHandle *handle, float margin, bool do_rotate, bool ignore_p
|
|||
|
||||
/* this could be its own function */
|
||||
if (do_rotate) {
|
||||
param_pack_rotate(handle, ignore_pinned);
|
||||
GEO_uv_parametrizer_pack_rotate(handle, ignore_pinned);
|
||||
}
|
||||
|
||||
if (phandle->aspx != phandle->aspy) {
|
||||
param_scale(handle, 1.0f / phandle->aspx, 1.0f / phandle->aspy);
|
||||
GEO_uv_parametrizer_scale(handle, 1.0f / phandle->aspx, 1.0f / phandle->aspy);
|
||||
}
|
||||
|
||||
/* we may not use all these boxes */
|
||||
|
@ -4856,11 +4859,11 @@ void param_pack(ParamHandle *handle, float margin, bool do_rotate, bool ignore_p
|
|||
MEM_freeN(boxarray);
|
||||
|
||||
if (phandle->aspx != phandle->aspy) {
|
||||
param_scale(handle, phandle->aspx, phandle->aspy);
|
||||
GEO_uv_parametrizer_scale(handle, phandle->aspx, phandle->aspy);
|
||||
}
|
||||
}
|
||||
|
||||
void param_average(ParamHandle *handle, bool ignore_pinned)
|
||||
void GEO_uv_parametrizer_average(ParamHandle *handle, bool ignore_pinned)
|
||||
{
|
||||
PChart *chart;
|
||||
int i;
|
||||
|
@ -4927,7 +4930,7 @@ void param_average(ParamHandle *handle, bool ignore_pinned)
|
|||
}
|
||||
}
|
||||
|
||||
void param_scale(ParamHandle *handle, float x, float y)
|
||||
void GEO_uv_parametrizer_scale(ParamHandle *handle, float x, float y)
|
||||
{
|
||||
PHandle *phandle = (PHandle *)handle;
|
||||
PChart *chart;
|
||||
|
@ -4939,7 +4942,7 @@ void param_scale(ParamHandle *handle, float x, float y)
|
|||
}
|
||||
}
|
||||
|
||||
void param_flush(ParamHandle *handle)
|
||||
void GEO_uv_parametrizer_flush(ParamHandle *handle)
|
||||
{
|
||||
PHandle *phandle = (PHandle *)handle;
|
||||
PChart *chart;
|
||||
|
@ -4961,7 +4964,7 @@ void param_flush(ParamHandle *handle)
|
|||
}
|
||||
}
|
||||
|
||||
void param_flush_restore(ParamHandle *handle)
|
||||
void GEO_uv_parametrizer_flush_restore(ParamHandle *handle)
|
||||
{
|
||||
PHandle *phandle = (PHandle *)handle;
|
||||
PChart *chart;
|
Loading…
Reference in New Issue