From 989740aae94a72add6c58228a1432516314c3524 Mon Sep 17 00:00:00 2001 From: Aurel Gruber Date: Thu, 26 Jan 2017 10:06:38 +0100 Subject: Category: UV Unwrapping SLIM Algorithm Integration fixing bug that causes weight-per-vertex mapping to be wrong --- intern/SLIM | 2 +- .../blender/editors/uvedit/uvedit_parametrizer.c | 26 +++++++++++----------- .../blender/editors/uvedit/uvedit_parametrizer.h | 2 -- source/blender/editors/uvedit/uvedit_unwrap_ops.c | 17 ++++++++------ 4 files changed, 24 insertions(+), 23 deletions(-) diff --git a/intern/SLIM b/intern/SLIM index 7da79fe62d7..fdce9c05a45 160000 --- a/intern/SLIM +++ b/intern/SLIM @@ -1 +1 @@ -Subproject commit 7da79fe62d79adc1189fee09a96ecf592b92284a +Subproject commit fdce9c05a458dc7109f11c52b67f1f2f5f734f47 diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c index cc4511606ec..ea8bf4df4af 100644 --- a/source/blender/editors/uvedit/uvedit_parametrizer.c +++ b/source/blender/editors/uvedit/uvedit_parametrizer.c @@ -246,8 +246,8 @@ typedef struct PHandle { matrix_transfer *mt; int n_iterations; + int slim_global_method; bool skip_initialization; - bool fixed_boundary; bool pack_islands; bool with_weighted_parameterization; MDeformVert *weightMapData; @@ -4348,7 +4348,7 @@ void param_construct_end(ParamHandle *handle, ParamBool fill, ParamBool impl) } void add_index_to_vertices(BMEditMesh *em){ - + // AUREL THESIS iterate over bm edit mesh and set indices for weight retrieval, // This allows for later matching of vertices to weights. BMVert *vert; @@ -4372,7 +4372,6 @@ void param_slim_enrich_handle(Object *obedit, int weightMapIndex, int n_iterations, bool skip_initialization, - bool fixed_boundary, bool pack_islands, bool with_weighted_parameterization){ @@ -4381,7 +4380,6 @@ void param_slim_enrich_handle(Object *obedit, phandle->mt = mt; phandle->n_iterations = n_iterations; phandle->skip_initialization = skip_initialization; - phandle->fixed_boundary = fixed_boundary; phandle->pack_islands = pack_islands; phandle->with_weighted_parameterization = with_weighted_parameterization; phandle->weightMapData = dvert; @@ -4420,7 +4418,7 @@ void param_slim_begin(ParamHandle *handle) { void param_slim_solve(ParamHandle *handle) { PHandle *phandle = (PHandle *) handle; matrix_transfer *mt = phandle->mt; - param_slim_C(mt, phandle->n_iterations, phandle->fixed_boundary, phandle->skip_initialization); + param_slim_C(mt, phandle->n_iterations, mt->fixed_boundary, phandle->skip_initialization); } void param_slim_end(ParamHandle *handle) { @@ -5011,13 +5009,14 @@ void transfer_vertices(const int chartNr, const PHandle *phandle, matrix_transfe for (v = chart->verts; v; v = v->nextlink){ if (!v->on_boundary_flag){ - v->slimId = vid; - + // set v->slim_id to vid ONLY AFTER assigning weight! if (mt->with_weighted_parameterization){ weight = tempW[v->slimId]; - W[v->slimId] = weight; + W[vid] = weight; } + v->slimId = vid; + vid++; } @@ -5076,16 +5075,17 @@ void transfer_boundary_vertices(const int chartNr, const PHandle *phandle, const PEdge *be = outer; do{ - mt->nBoundaryVertices[chartNr] += 1; - be->vert->slimId = vid; - be->vert->on_boundary_flag = true; - B[vid] = vid; - + // set be->vert->slim_id to vid ONLY AFTER assigning weight! if (mt->with_weighted_parameterization){ weight = tempW[be->vert->slimId]; W[vid] = weight; } + mt->nBoundaryVertices[chartNr] += 1; + be->vert->slimId = vid; + be->vert->on_boundary_flag = true; + B[vid] = vid; + vid += 1; be = p_boundary_edge_next(be); diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.h b/source/blender/editors/uvedit/uvedit_parametrizer.h index e939a3660ae..bb5b9e16f4c 100644 --- a/source/blender/editors/uvedit/uvedit_parametrizer.h +++ b/source/blender/editors/uvedit/uvedit_parametrizer.h @@ -99,7 +99,6 @@ void param_slim_enrich_handle(Object *obedit, int weightMapIndex, int n_iterations, bool skip_initialization, - bool fixed_boundary, bool pack_islands, bool with_weighted_parameterization); /* unwrapping: @@ -126,7 +125,6 @@ void param_slim_begin(ParamHandle *handle); void param_slim_solve(ParamHandle *handle); void param_slim_end(ParamHandle *handle); - /* Least Squares Conformal Maps: * ----------------------------- * - charts with less than two pinned vertices are assigned 2 pins diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index b01f9a2b24f..6dd754c96d8 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -516,7 +516,7 @@ int setup_weight_transfer(Object *obedit, BMEditMesh *em){ int defgrp_index = retrieve_weightmap_index(obedit); if (defgrp_index >= 0) { - add_index_to_vertices(em); + //add_index_to_vertices(em); } return defgrp_index; @@ -529,7 +529,6 @@ void enrich_handle_slim(Scene *scene, Object *obedit, BMEditMesh *em, ParamHandl int n_iterations = scene->toolsettings->slim_n_iterations; bool skip_initialization = scene->toolsettings->slim_skip_initialization; - bool fixed_boundary = scene->toolsettings->slim_fixed_boundary; bool pack_islands = scene->toolsettings->slim_pack_islands; MDeformVert *weightMapData = NULL; @@ -548,7 +547,6 @@ void enrich_handle_slim(Scene *scene, Object *obedit, BMEditMesh *em, ParamHandl weightMapIndex, n_iterations, skip_initialization, - fixed_boundary, pack_islands, with_weighted_parameterization); } @@ -800,7 +798,7 @@ static bool minimize_stretch_SLIM_init(bContext *C, wmOperator *op) Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BKE_editmesh_from_object(obedit); - const bool fill_holes = RNA_boolean_get(op->ptr, "fill_holes"); + add_index_to_vertices(em); ParamHandle *handle = construct_param_handle(scene, obedit, em->bm, false, true, 1, 1); @@ -810,7 +808,7 @@ static bool minimize_stretch_SLIM_init(bContext *C, wmOperator *op) mss->obedit = obedit; mss->firstIteration = true; mss->fixBorder = true; - //fills in mt + mss->mt->fixed_boundary = true; enrich_handle_slim(scene, obedit, em, handle, mss->mt); param_slim_begin(handle); @@ -1460,6 +1458,12 @@ void ED_unwrap_lscm(Scene *scene, Object *obedit, const short sel) const bool correct_aspect = (scene->toolsettings->uvcalc_flag & UVCALC_NO_ASPECT_CORRECT) == 0; bool use_subsurf; + bool use_slim_method = (scene->toolsettings->unwrapper == 2); + + if(use_slim_method){ + add_index_to_vertices(em); + } + modifier_unwrap_state(obedit, scene, &use_subsurf); if (use_subsurf) @@ -1467,9 +1471,8 @@ void ED_unwrap_lscm(Scene *scene, Object *obedit, const short sel) else handle = construct_param_handle(scene, obedit, em->bm, false, fill_holes, sel, correct_aspect); - bool use_slim_method = (scene->toolsettings->unwrapper == 2); if (use_slim_method){ - matrix_transfer *mt = mt = MEM_mallocN(sizeof(matrix_transfer), "matrix transfer data"); + matrix_transfer *mt = MEM_mallocN(sizeof(matrix_transfer), "matrix transfer data"); enrich_handle_slim(scene, obedit, em, handle, mt); } -- cgit v1.2.3