[Bf-blender-cvs] [f3f2de8] soc-2016-uv_tools: First part of solution evaluation rewrite

Phil Gosch noreply at git.blender.org
Tue Oct 4 08:48:10 CEST 2016


Commit: f3f2de8d01fcbc616882e67ae569f617d1b438ae
Author: Phil Gosch
Date:   Tue Oct 4 08:47:48 2016 +0200
Branches: soc-2016-uv_tools
https://developer.blender.org/rBf3f2de8d01fcbc616882e67ae569f617d1b438ae

First part of solution evaluation rewrite

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

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/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c
index 0a4fe6d..75c3387 100644
--- a/source/blender/editors/uvedit/uvedit_parametrizer.c
+++ b/source/blender/editors/uvedit/uvedit_parametrizer.c
@@ -236,8 +236,8 @@ typedef struct PChart {
 		struct PChartIrregularPack {
 			PConvexHull *convex_hull; /* ToDo (SaphireS): Only convex for now */
 			PConvexHull **tris;
-			PPointUV *best_pos;
-			float area, scale;
+			PPointUV *best_pos, *cur_pos;
+			float area, last_scale;
 			float sa_params[3]; /* 0 = Theta, 1 = r, 2 = f  according to Rotational placement of irregular polygons over containers with fixed dimensions using simulated annealing and no-fit polygons*/
 			int ntris;
 			bool decomposed;
@@ -528,6 +528,8 @@ static void p_chart_uv_scale(PChart *chart, float scale)
 {
 	PVert *v;
 
+	printf("--uv_scaling chart with factor %f\n", scale);
+
 	for (v = chart->verts; v; v = v->nextlink) {
 		v->uv[0] *= scale;
 		v->uv[1] *= scale;
@@ -5008,7 +5010,7 @@ static PConvexHull *p_convex_hull_new_tri(PChart *chart, const float(*coords)[2]
 	float pos[2], maxy = -1.0e30f;
 	int npoint = 3, right = 0, i;
 
-	printf("p_convex_hull_new_tri!\n");
+	//printf("p_convex_hull_new_tri!\n");
 
 	conv_hull->h_verts = (PVert **)MEM_callocN(sizeof(conv_hull->h_verts) * npoint, "PConvHullPVerts");
 	conv_hull->verts = (PPointUV **)MEM_callocN(sizeof(*conv_hull->verts) * npoint, "PConvexHullVerts");
@@ -5021,7 +5023,7 @@ static PConvexHull *p_convex_hull_new_tri(PChart *chart, const float(*coords)[2]
 	/* p_chart_uv_bbox(chart, conv_hull->min_v, conv_hull->max_v); */
 	INIT_MINMAX2(conv_hull->min_v, conv_hull->max_v);
 	
-	printf("-p_convex_hull_new_tri: inits done!\n");
+	//printf("-p_convex_hull_new_tri: inits done!\n");
 
 	/* get reference vertex */
 	for (i = 0; i < conv_hull->nverts; i++) {
@@ -5030,9 +5032,9 @@ static PConvexHull *p_convex_hull_new_tri(PChart *chart, const float(*coords)[2]
 		PPointUV *p = (PPointUV *)MEM_callocN(sizeof(*p), "PPointUV");
 		p->x = coords[i][0];
 		p->y = coords[i][1];
-		printf("-p_convex_hull_new_tri: p coords updated!\n");
+		//printf("-p_convex_hull_new_tri: p coords updated!\n");
 		conv_hull->verts[i] = p;
-		printf("-p_convex_hull_new_tri: p assigned to verts!\n");
+		//printf("-p_convex_hull_new_tri: p assigned to verts!\n");
 
 		/*PVert *v = (PVert *)MEM_callocN(sizeof(*v), "PVert");
 		v->uv[0] = coords[i][0];
@@ -5044,7 +5046,7 @@ static PConvexHull *p_convex_hull_new_tri(PChart *chart, const float(*coords)[2]
 			if (compare_ff(v->uv[0],coords[i][0], 0.0001f)) {
 				if (compare_ff(v->uv[1], coords[i][1], 0.0001f)) {
 					conv_hull->h_verts[i] = v;
-					printf("-p_convex_hull_new_tri: v assigned to verts_h!\n"); 
+					//printf("-p_convex_hull_new_tri: v assigned to verts_h!\n"); 
 				}
 			}
 		}
@@ -5053,7 +5055,7 @@ static PConvexHull *p_convex_hull_new_tri(PChart *chart, const float(*coords)[2]
 		pos[0] = conv_hull->verts[i]->x;
 		pos[1] = conv_hull->verts[i]->y;
 		minmax_v2v2_v2(conv_hull->min_v, conv_hull->max_v, pos);
-		printf("-p_convex_hull_new_tri: bounds updated!\n");
+		//printf("-p_convex_hull_new_tri: bounds updated!\n");
 
 		/* Note: FLT_EPSILON is to exact and produces wrong results in this context, use custom max_diff instead */
 		if (compare_ff(maxy, conv_hull->verts[i]->y, 0.00001f)) {
@@ -5068,7 +5070,7 @@ static PConvexHull *p_convex_hull_new_tri(PChart *chart, const float(*coords)[2]
 			maxy = conv_hull->verts[i]->y;
 			conv_hull->ref_vert_index = i;
 		}
-		printf("-p_convex_hull_new_tri: ref vert updated!\n");
+		//printf("-p_convex_hull_new_tri: ref vert updated!\n");
 	}
 
 	return conv_hull;
@@ -5154,7 +5156,7 @@ static bool p_convex_hull_intersect(PConvexHull *chull_a, PConvexHull *chull_b)
 static void p_convex_hull_compute_horizontal_angles(PConvexHull *hull)
 {
 	int j;
-	printf("*p_convex_hull_compute_horizontal_angles\n");
+	//printf("*p_convex_hull_compute_horizontal_angles\n");
 	for (j = 0; j < hull->nverts; j++) {
 
 		/* Compute horizontal angle for each edge of hull (Needed for NFP) */
@@ -5184,7 +5186,7 @@ static void p_convex_hull_compute_horizontal_angles(PConvexHull *hull)
 static void p_convex_hull_compute_edge_components(PConvexHull *hull)
 {
 	int j;
-	printf("*p_convex_hull_compute_edge_lengths\n");
+	//printf("*p_convex_hull_compute_edge_lengths\n");
 	for (j = 0; j < hull->nverts; j++) {
 
 		/* Compute edge components for each edge of hull (Needed for NFP) */
@@ -5242,14 +5244,14 @@ static PConvexHull *p_convex_hull_reverse_vert_order(PConvexHull *hull)
 			if (conv_hull_inv->verts[i]->x > conv_hull_inv->verts[conv_hull_inv->ref_vert_index]->x) {
 				miny = conv_hull_inv->verts[i]->y;
 				conv_hull_inv->ref_vert_index = i;
-				printf("--p_convex_hull_reverse_vert_order: EQUAL min_y : x = %f, y = %f\n", conv_hull_inv->verts[i]->x, conv_hull_inv->verts[i]->y);
+				//printf("--p_convex_hull_reverse_vert_order: EQUAL min_y : x = %f, y = %f\n", conv_hull_inv->verts[i]->x, conv_hull_inv->verts[i]->y);
 			}
 		}
 		else if (conv_hull_inv->verts[i]->y < miny) {
 			/* lower y value */
 			miny = conv_hull_inv->verts[i]->y;
 			conv_hull_inv->ref_vert_index = i;
-			printf("--p_convex_hull_reverse_vert_order: SMALLER min_y : x = %f, y = %f\n", conv_hull_inv->verts[i]->x, conv_hull_inv->verts[i]->y);
+			//printf("--p_convex_hull_reverse_vert_order: SMALLER min_y : x = %f, y = %f\n", conv_hull_inv->verts[i]->x, conv_hull_inv->verts[i]->y);
 		}
 
 		/* compute bounds */
@@ -5258,7 +5260,7 @@ static PConvexHull *p_convex_hull_reverse_vert_order(PConvexHull *hull)
 		minmax_v2v2_v2(conv_hull_inv->min_v, conv_hull_inv->max_v, b);
 	}
 
-	printf("--p_convex_hull_reverse_vert_order: FINAL min_y: x: %f, y: %f\n", conv_hull_inv->verts[conv_hull_inv->ref_vert_index]->x, conv_hull_inv->verts[conv_hull_inv->ref_vert_index]->y);
+	//printf("--p_convex_hull_reverse_vert_order: FINAL min_y: x: %f, y: %f\n", conv_hull_inv->verts[conv_hull_inv->ref_vert_index]->x, conv_hull_inv->verts[conv_hull_inv->ref_vert_index]->y);
 
 	return conv_hull_inv;
 }
@@ -5334,14 +5336,14 @@ static void p_convex_hull_grow(PConvexHull *chull, float margin)
 static PConvexHull *p_convex_hull_reverse_direction(PConvexHull *item)
 {
 	/* Invert direction of one convex hull -> CCW */
-	printf("inversing direction start\n");
+	//printf("inversing direction start\n");
 	/* ref_vert_index now contains the vert with the lowest y value */
 	PConvexHull *item_inv = p_convex_hull_reverse_vert_order(item);
-	printf("angles start\n");
+	//printf("angles start\n");
 	p_convex_hull_compute_horizontal_angles(item_inv);
-	printf("components start\n");
+	//printf("components start\n");
 	p_convex_hull_compute_edge_components(item_inv);
-	printf("inversing direction done!\n");
+	//printf("inversing direction done!\n");
 
 	return item_inv;
 }
@@ -5377,7 +5379,7 @@ static PNoFitPolygon *p_inner_fit_polygon_create(PHandle *phandle, PConvexHull *
 	float bounds_width = phandle->aspx;
 	
 	p1->x = item->verts[item->ref_vert_index]->x - item->min_v[0];
-	printf("item_ref_x: %f, %f, min_v[0]: %f\n", item->verts[item->ref_vert_index]->x, item->verts[item->ref_vert_index]->y, item->min_v[0]);
+	//printf("item_ref_x: %f, %f, min_v[0]: %f\n", item->verts[item->ref_vert_index]->x, item->verts[item->ref_vert_index]->y, item->min_v[0]);
 	p1->y = 0.0f;
 	nfp->final_pos[0] = p1;
 
@@ -5408,7 +5410,7 @@ static PConvexHull** p_decompose_triangulate_chart(PChart *chart, const float(*h
 	PConvexHull **chull_tris = (PConvexHull **)MEM_mallocN(sizeof(PConvexHull *) * ntris, "PNFPs");
 	chart->u.ipack.ntris = ntris;
 
-	printf("p_decompose_triangulate_chart!\n");
+	//printf("p_decompose_triangulate_chart!\n");
 
 	/* triangulate */
 	BLI_polyfill_calc((const float(*)[2])hull_points, nbounds, -1, r_tris);
@@ -5417,15 +5419,15 @@ static PConvexHull** p_decompose_triangulate_chart(PChart *chart, const float(*h
 	for (i = 0; i < ntris; i++){
 		cur_tri[0][0] = hull_points[r_tris[i][0]][0];
 		cur_tri[0][1] = hull_points[r_tris[i][0]][1];
-		printf("p_decompose_triangulate_chart: tri[0]x: %f, y: %f\n", hull_points[r_tris[i][0]][0], hull_points[r_tris[i][0]][1]);
+		//printf("p_decompose_triangulate_chart: tri[0]x: %f, y: %f\n", hull_points[r_tris[i][0]][0], hull_points[r_tris[i][0]][1]);
 
 		cur_tri[1][0] = hull_points[r_tris[i][1]][0];
 		cur_tri[1][1] = hull_points[r_tris[i][1]][1];
-		printf("p_decompose_triangulate_chart: tri[0]x: %f, y: %f\n", hull_points[r_tris[i][1]][0], hull_points[r_tris[i][1]][1]);
+		//printf("p_decompose_triangulate_chart: tri[0]x: %f, y: %f\n", hull_points[r_tris[i][1]][0], hull_points[r_tris[i][1]][1]);
 
 		cur_tri[2][0] = hull_points[r_tris[i][2]][0];
 		cur_tri[2][1] = hull_points[r_tris[i][2]][1];
-		printf("p_decompose_triangulate_chart: tri[0]x: %f, y: %f\n", hull_points[r_tris[i][2]][0], hull_points[r_tris[i][2]][1]);
+		//printf("p_decompose_triangulate_chart: tri[0]x: %f, y: %f\n", hull_points[r_tris[i][2]][0], hull_points[r_tris[i][2]][1]);
 
 		chull_tris[i] = p_convex_hull_new_tri(chart, cur_tri);
 	}
@@ -5450,17 +5452,17 @@ static bool p_point_inside_nfp(PNoFitPolygon *nfp, float p[2])
 static bool p_is_concave(PChart *chart, const float(*hull_points)[2], int nboundaries)
 {
 	if (nboundaries <= 4) {
-		printf("<= 4 boundary edges, convex\n");
+		//printf("<= 4 boundary edges, convex\n");
 		return false;
 	}
 
 	/* ToDo SaphireS */
 	if (is_poly_convex_v2((const float(*)[2])hull_points, nboundaries)){
-		printf("is_poly_convex true, convex\n");
+		//printf("is_poly_convex true, convex\n");
 		return false;
 	}
 	else {
-		printf("is_poly_convex false, concave\n");
+		//printf("is_poly_convex false, concave\n");
 		return true; 
 	}
 }
@@ -5579,26 +5581,26 @@ static PNoFitPolygon *p_no_fit_polygon_create(PConvexHull *item, PConvexHull *fi
 			fpoints[i] = fixed->verts[i - item->nverts];
 		}
 	}
-	printf("-Assignment to points done\n");
+	//printf("-Assignment to points done\n");
 
 	/* sort edges according to horizontal angle, biggest to smallest */
 	/*qsort(points, (size_t)nfp->nverts, sizeof(PVert *), vert_anglesort);*/
 	qsort(fpoints, (size_t)nfp->nverts, sizeof(PPointUV *), point_anglesort);
-	printf("-Sorting don

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list