[Bf-blender-cvs] [4c2ead4] soc-2016-uv_tools: Added hack-ish check for point being inside other NFP until union algorithm is implemented
Phil Gosch
noreply at git.blender.org
Sat Jul 9 23:57:22 CEST 2016
Commit: 4c2ead486b229e719f3ac7794c0b23e56b61efae
Author: Phil Gosch
Date: Sat Jul 9 23:56:41 2016 +0200
Branches: soc-2016-uv_tools
https://developer.blender.org/rB4c2ead486b229e719f3ac7794c0b23e56b61efae
Added hack-ish check for point being inside other NFP until union algorithm is implemented
===================================================================
M source/blender/editors/uvedit/uvedit_parametrizer.c
===================================================================
diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c
index 937102b..ba9a12d 100644
--- a/source/blender/editors/uvedit/uvedit_parametrizer.c
+++ b/source/blender/editors/uvedit/uvedit_parametrizer.c
@@ -5024,9 +5024,24 @@ PNoFitPolygon *p_collision_free_region_create(PNoFitPolygon **nfps, PNoFitPolygo
return cfr;
}
-bool p_temp_cfr_check(PNoFitPolygon **nfps, PNoFitPolygon *ifp, float p[2])
+bool p_point_inside_nfp(PNoFitPolygon *nfp, float p[2])
+{
+ /* raycast to the right of vert, odd number of intersections means inside */
+ int i, j, c = 0;
+
+ for (i = 0, j = nfp->nverts - 1; i < nfp->nverts; j = i++) {
+ if (((nfp->final_pos[i]->y > p[1]) != (nfp->final_pos[j]->y > p[1])) &&
+ (p[0] < (nfp->final_pos[j]->x - nfp->final_pos[i]->x) * (p[1] - nfp->final_pos[i]->y) / (nfp->final_pos[j]->y - nfp->final_pos[i]->y) + nfp->final_pos[i]->x))
+ c = !c;
+ }
+
+ return c;
+}
+
+bool p_temp_cfr_check(PNoFitPolygon **nfps, PNoFitPolygon *ifp, float p[2], int nfp_count, int index)
{
float min[2], max[2];
+ int i;
/* Make sure point is inside IFP */
if (p[0] < ifp->final_pos[0]->x ||
@@ -5036,6 +5051,13 @@ bool p_temp_cfr_check(PNoFitPolygon **nfps, PNoFitPolygon *ifp, float p[2])
return false;
}
+ for (i = 0; i < nfp_count; i++) {
+ if (nfps[i] && (i != index)) {
+ if (p_point_inside_nfp(nfps[i], p)) {
+ return false;
+ }
+ }
+ }
return true;
}
@@ -5201,7 +5223,7 @@ bool p_chart_pack_individual(PHandle *phandle, PChart *item)
if (nfps[rand1]->final_pos[rand2]) {
end_pos[0] = nfps[rand1]->final_pos[rand2]->x;
end_pos[1] = nfps[rand1]->final_pos[rand2]->y;
- found = p_temp_cfr_check(nfps, ifp, end_pos);
+ found = p_temp_cfr_check(nfps, ifp, end_pos, phandle->ncharts, rand1);
}
}
}
More information about the Bf-blender-cvs
mailing list