Commit: eddffdd3988af768e56243fdffd18813b31b1441 Author: Aleksi Juvani Date: Tue Mar 29 20:57:59 2022 -0500 Branches: master https://developer.blender.org/rBeddffdd3988af768e56243fdffd18813b31b1441
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 =================================================================== M source/blender/editors/uvedit/CMakeLists.txt M source/blender/editors/uvedit/uvedit_islands.c D source/blender/editors/uvedit/uvedit_parametrizer.h M source/blender/editors/uvedit/uvedit_unwrap_ops.c M source/blender/geometry/CMakeLists.txt A source/blender/geometry/GEO_uv_parametrizer.h R097 source/blender/editors/uvedit/uvedit_parametrizer.c source/blender/geometry/intern/uv_parametrizer.c =================================================================== diff --git a/source/blender/editors/uvedit/CMakeLists.txt b/source/blender/editors/uvedit/CMakeLists.txt index f8a192e3254..761e7cd091e 100644 --- a/source/blender/editors/uvedit/CMakeLists.txt +++ b/source/blender/editors/uvedit/CMakeLists.txt @@ -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 diff --git a/source/blender/editors/uvedit/uvedit_islands.c b/source/blender/editors/uvedit/uvedit_islands.c index 59992d23e2e..e1752ae5a29 100644 --- a/source/blender/editors/uvedit/uvedit_islands.c +++ b/source/blender/editors/uvedit/uvedit_islands.c @@ -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. diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.h b/source/blender/editors/uvedit/uvedit_parametrizer.h deleted file mode 100644 index f234fbe2ace..00000000000 --- a/source/blender/editors/uvedit/uvedit_parametrizer.h +++ /dev/null @@ -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 diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index 63300656fda..609fa72d56b 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -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 @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list [email protected] List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
