[Bf-blender-cvs] [9aee5cd8d2] uv_unwrapping_slim_and_ceres: Category: UV Unwrapping SLIM Algorithm Integration

Aurel Gruber noreply at git.blender.org
Mon Feb 27 11:27:16 CET 2017


Commit: 9aee5cd8d2b8b1b774738b59b06ac9b6313a5488
Author: Aurel Gruber
Date:   Thu Jan 19 16:03:34 2017 +0100
Branches: uv_unwrapping_slim_and_ceres
https://developer.blender.org/rB9aee5cd8d2b8b1b774738b59b06ac9b6313a5488

Category: UV Unwrapping SLIM Algorithm Integration

preserving vertex ids and gathering weights

===================================================================

M	intern/SLIM
M	source/blender/editors/uvedit/uvedit_parametrizer.c
M	source/blender/editors/uvedit/uvedit_parametrizer.h
M	source/blender/editors/uvedit/uvedit_unwrap_ops.c

===================================================================

diff --git a/intern/SLIM b/intern/SLIM
index e897ae04d5..62a96ad0e8 160000
--- a/intern/SLIM
+++ b/intern/SLIM
@@ -1 +1 @@
-Subproject commit e897ae04d52607970344a601fc85c1329f2314ed
+Subproject commit 62a96ad0e853e1008bd971272e5f79231cd4308c
diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c
index 759af69fd3..0e3d343401 100644
--- a/source/blender/editors/uvedit/uvedit_parametrizer.c
+++ b/source/blender/editors/uvedit/uvedit_parametrizer.c
@@ -744,7 +744,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(PHandle *handle, PHashKey key, const float co[3], float id, PEdge *e)
 {
 	PVert *v = (PVert *)BLI_memarena_alloc(handle->arena, sizeof(*v));
 	copy_v3_v3(v->co, co);
@@ -761,20 +761,21 @@ static PVert *p_vert_add(PHandle *handle, PHashKey key, const float co[3], PEdge
 	v->u.key = key;
 	v->edge = e;
 	v->flag = 0;
+	v->slimId = id;
 
 	phash_insert(handle->hash_verts, (PHashLink *)v);
 
 	return v;
 }
 
-static PVert *p_vert_lookup(PHandle *handle, PHashKey key, const float co[3], PEdge *e)
+static PVert *p_vert_lookup(PHandle *handle, PHashKey key, const float co[3], float id, PEdge *e)
 {
 	PVert *v = (PVert *)phash_lookup(handle->hash_verts, key);
 
 	if (v)
 		return v;
 	else
-		return p_vert_add(handle, key, co, e);
+		return p_vert_add(handle, key, co, id, e);
 }
 
 static PVert *p_vert_copy(PChart *chart, PVert *v)
@@ -1115,15 +1116,15 @@ static PFace *p_face_add(PHandle *handle)
 }
 
 static PFace *p_face_add_construct(PHandle *handle, ParamKey key, ParamKey *vkeys,
-                                   float *co[4], float *uv[4], int i1, int i2, int i3,
+                                   float *co[4], float *uv[4], float id[4], 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;
 
-	e1->vert = p_vert_lookup(handle, vkeys[i1], co[i1], e1);
-	e2->vert = p_vert_lookup(handle, vkeys[i2], co[i2], e2);
-	e3->vert = p_vert_lookup(handle, vkeys[i3], co[i3], e3);
+	e1->vert = p_vert_lookup(handle, vkeys[i1], co[i1], id[i1], e1);
+	e2->vert = p_vert_lookup(handle, vkeys[i2], co[i2], id[i2], e2);
+	e3->vert = p_vert_lookup(handle, vkeys[i3], co[i3], id[i3], e3);
 
 	e1->orig_uv = uv[i1];
 	e2->orig_uv = uv[i2];
@@ -4174,7 +4175,7 @@ void param_delete(ParamHandle *handle)
 }
 
 static void p_add_ngon(ParamHandle *handle, ParamKey key, int nverts,
-                       ParamKey *vkeys, float **co, float **uv,
+                       ParamKey *vkeys, float **co, float **uv, float *id,
                        ParamBool *pin, ParamBool *select, const float normal[3])
 {
 	int *boundary = BLI_array_alloca(boundary, nverts);
@@ -4229,10 +4230,11 @@ static void p_add_ngon(ParamHandle *handle, ParamKey key, int nverts,
 			ParamKey tri_vkeys[3] = {vkeys[v0], vkeys[v1], vkeys[v2]};
 			float *tri_co[3] = {co[v0], co[v1], co[v2]};
 			float *tri_uv[3] = {uv[v0], uv[v1], uv[v2]};
+			float tri_id[3] = {id[v0], id[v1], id[v2]};
 			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, NULL);
+			param_face_add(handle, key, 3, tri_vkeys, tri_co, tri_uv, tri_id, tri_pin, tri_select, NULL);
 		}
 
 		/* remove corner */
@@ -4244,7 +4246,7 @@ static void p_add_ngon(ParamHandle *handle, ParamKey key, int nverts,
 }
 
 void param_face_add(ParamHandle *handle, ParamKey key, int nverts,
-                    ParamKey *vkeys, float *co[4], float *uv[4],
+                    ParamKey *vkeys, float *co[4], float *uv[4], float id[4],
                     ParamBool *pin, ParamBool *select, float normal[3])
 {
 	PHandle *phandle = (PHandle *)handle;
@@ -4255,22 +4257,22 @@ void param_face_add(ParamHandle *handle, ParamKey key, int nverts,
 
 	if (nverts > 4) {
 		/* ngon */
-		p_add_ngon(handle, key, nverts, vkeys, co, uv, pin, select, normal);
+		p_add_ngon(handle, key, nverts, vkeys, co, uv, id, pin, select, normal);
 	}
 	else if (nverts == 4) {
 		/* quad */
 		if (p_quad_split_direction(phandle, co, vkeys)) {
-			p_face_add_construct(phandle, key, vkeys, co, uv, 0, 1, 2, pin, select);
-			p_face_add_construct(phandle, key, vkeys, co, uv, 0, 2, 3, pin, select);
+			p_face_add_construct(phandle, key, vkeys, co, uv, id, 0, 1, 2, pin, select);
+			p_face_add_construct(phandle, key, vkeys, co, uv, id, 0, 2, 3, pin, select);
 		}
 		else {
-			p_face_add_construct(phandle, key, vkeys, co, uv, 0, 1, 3, pin, select);
-			p_face_add_construct(phandle, key, vkeys, co, uv, 1, 2, 3, pin, select);
+			p_face_add_construct(phandle, key, vkeys, co, uv, id, 0, 1, 3, pin, select);
+			p_face_add_construct(phandle, key, vkeys, co, uv, id, 1, 2, 3, pin, select);
 		}
 	}
 	else if (!p_face_exists(phandle, vkeys, 0, 1, 2)) {
 		/* triangle */
-		p_face_add_construct(phandle, key, vkeys, co, uv, 0, 1, 2, pin, select);
+		p_face_add_construct(phandle, key, vkeys, co, uv, id, 0, 1, 2, pin, select);
 	}
 }
 
@@ -4740,7 +4742,6 @@ void convert_blender_slim(ParamHandle *handle, matrix_transfer *mt, bool selecti
 
 	/*For each chart, fill up matrices*/
 
-	//printf("number of charts: %d \n", mt->nCharts);
 	for (chartNr = 0; chartNr < phandle->ncharts; chartNr++) {
 		mt->nPinnedVertices[chartNr] = 0;
 		mt->nBoundaryVertices[chartNr] = 0;
@@ -4818,13 +4819,11 @@ void create_weight_matrix(const int chartNr, const PHandle *phandle, matrix_tran
 	int i;
 	double weight;
 
-	/*
+
 	BM_ITER_MESH_INDEX(vert, &iter, em->bm, BM_VERTS_OF_MESH, i){
 		weight = defvert_find_weight(dvert + i, defgrp_index);
 		tempW[i] = weight;
-		//printf("tempW[%d] = %f \n",i, weight);
-	}*/
-
+	}
 }
 
 /*	AUREL THESIS	Transfer edges and edge lengths */
@@ -4891,10 +4890,9 @@ void transfer_vertices(const int chartNr, const PHandle *phandle, matrix_transfe
 	for (v = chart->verts; v; v = v->nextlink){
 
 		if (!v->on_boundary_flag){
-			//weight = tempW[v->slimId];
-			//printf("weights as used internal verts: %f  id, x,y,z: %d, %f, %f, %f \n", weight, v->slimId, v->co[0], v->co[1], v->co[2]);
+			weight = tempW[v->slimId];
 			v->slimId = vid;
-			W[v->slimId] = 0;
+			W[v->slimId] = weight;
 			vid++;
 		}
 
@@ -4952,7 +4950,7 @@ void transfer_boundary_vertices(const int chartNr, const PHandle *phandle, const
 	p_chart_boundaries(chart, NULL, &outer);
 	PEdge *be = outer;
 	do{
-		weight = 0; //tempW[be->vert->slimId];
+		weight = tempW[be->vert->slimId];
 
 		mt->nBoundaryVertices[chartNr] += 1;
 		be->vert->slimId = vid;
diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.h b/source/blender/editors/uvedit/uvedit_parametrizer.h
index 1ca9e8b6df..37f66af7c6 100644
--- a/source/blender/editors/uvedit/uvedit_parametrizer.h
+++ b/source/blender/editors/uvedit/uvedit_parametrizer.h
@@ -71,6 +71,7 @@ void param_face_add(ParamHandle *handle,
                     ParamKey *vkeys,
                     float *co[4],
                     float *uv[4],
+					float id[4],
                     ParamBool *pin,
                     ParamBool *select,
                     float face_normal[3]);
diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
index 7162d51ddc..a7377691cc 100644
--- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c
+++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
@@ -83,7 +83,7 @@
 #include "uvedit_parametrizer.h"
 
 #include "matrix_transfer.h"
-#include "slim_parametrizer.h"
+#include "slim_C_interface.h"
 
 #define max(x, y) (((x) > (y)) ? (x) : (y))
 #define min(x, y) (((x) < (y)) ? (x) : (y))
@@ -241,6 +241,7 @@ static void construct_param_handle_face_add(ParamHandle *handle, Scene *scene,
 	ParamBool *select = BLI_array_alloca(select, efa->len);
 	float **co = BLI_array_alloca(co, efa->len);
 	float **uv = BLI_array_alloca(uv, efa->len);
+	float *id = BLI_array_alloca(id, efa->len);
 	int i;
 
 	BMIter liter;
@@ -256,11 +257,12 @@ static void construct_param_handle_face_add(ParamHandle *handle, Scene *scene,
 		vkeys[i] = (ParamKey)BM_elem_index_get(l->v);
 		co[i] = l->v->co;
 		uv[i] = luv->uv;
+		id[i] = l->v->id;
 		pin[i] = (luv->flag & MLOOPUV_PINNED) != 0;
 		select[i] = uvedit_uv_select_test(scene, l, cd_loop_uv_offset);
 	}
 
-	param_face_add(handle, key, i, vkeys, co, uv, pin, select, efa->no);
+	param_face_add(handle, key, i, vkeys, co, uv, id, pin, select, efa->no);
 }
 
 static ParamHandle *construct_param_handle(Scene *scene, Object *ob, BMesh *bm,
@@ -330,8 +332,7 @@ static ParamHandle *construct_param_handle(Scene *scene, Object *ob, BMesh *bm,
 }
 
 
-static void texface_from_original_index(BMFace *efa, int index, float **uv, ParamBool *pin, ParamBool *select,
-                                        Scene *scene, const int cd_loop_uv_offset)
+static void texface_from_original_index(BMFace *efa, int index, float **uv, ParamBool *pin, ParamBool *select, float *id, Scene *scene, const int cd_loop_uv_offset)
 {
 	BMLoop *l;
 	BMIter liter;
@@ -340,6 +341,7 @@ static void texface_from_original_index(BMFace *efa, int index, float **uv, Para
 	*uv = NULL;
 	*pin = 0;
 	*select = 1;
+	*id = 0;
 
 	if (index == ORIGINDEX_NONE)
 		return;
@@ -348,6 +350,7 @@ static void texface_from_original_index(BMFace *efa, int index, float **uv, Para
 		if (BM_elem_index_get(l->v) == index) {
 			luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
 			*uv = luv->uv;
+			*id = l->v->id;
 			*pin = (luv->flag & MLOOPUV_PINNED) ? 1 : 0;
 			*select = uvedit_uv_select_test(scene, l, cd_loop_uv_offset);
 			break;
@@ -451,6 +454,7 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, Object *ob, B
 		ParamBool pin[4], select[4];
 		float *co[4];
 		float *uv[4];
+		float *id[4];
 		BMFace *origFace = faceMap[i];
 
 		if (scene->toolsettings->uv_flag & UV_SYNC_SELECTION) {
@@ -479,12 +483,12 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, Object *ob, B
 		
 		/* This

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list