[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [49818] branches/soc-2012-bratwurst/source /blender/editors/uvedit/uvedit_parametrizer.c: Isomap unwrapper

Antony Riakiotakis kalast at gmail.com
Sat Aug 11 20:40:16 CEST 2012


Revision: 49818
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=49818
Author:   psy-fi
Date:     2012-08-11 18:40:15 +0000 (Sat, 11 Aug 2012)
Log Message:
-----------
Isomap unwrapper
================
* Robustness: Avoid nan in sqrt calculation
* Do a much simpler calculation of projected point.

Modified Paths:
--------------
    branches/soc-2012-bratwurst/source/blender/editors/uvedit/uvedit_parametrizer.c

Modified: branches/soc-2012-bratwurst/source/blender/editors/uvedit/uvedit_parametrizer.c
===================================================================
--- branches/soc-2012-bratwurst/source/blender/editors/uvedit/uvedit_parametrizer.c	2012-08-11 18:40:08 UTC (rev 49817)
+++ branches/soc-2012-bratwurst/source/blender/editors/uvedit/uvedit_parametrizer.c	2012-08-11 18:40:15 UTC (rev 49818)
@@ -3138,10 +3138,8 @@
 		float norm[3];
 		float x_local[3];
 		float y_local[3];
-		float v2x, sqv2x, v3x, v3y, projx, projy;
+		float v2x, v3x, v3y, projx, projy;
 
-		/* temp variables for solution of projected distance point */
-		float alpha, beta;
 		float T1 = dist_map[i_center*nverts + i0], T2 = dist_map[i_sec*nverts + i0];
 
 		c[0] = v_secondary->co[0] - v_cent->co[0];
@@ -3161,14 +3159,10 @@
 
 		/* now we will find the nexus of the two circles with loci v1, v2 and radii T1 T2.
 		 * The farthest solution from v3 will give the distance T3 */
-		sqv2x = v2x*v2x;
+		projx = 0.5*(v2x*v2x + T1*T1 - T2*T2)/v2x;
+		/* taking max because there's a tendency for precision floating point errors */
+		projy = sqrt(maxf(T1*T1 - projx*projx, 0.0));
 
-		alpha = 2*T1*T1*sqv2x - sqv2x*sqv2x + 2*T2*T2*sqv2x;
-		beta = T1*T1 - T2*T2;
-		projx = 0.5*(sqv2x + beta)/v2x;
-		beta *= beta;
-		projy = 0.5*sqrt(alpha - beta)/v2x;
-
 		/* compare solution and choose the greater of the two */
 		if(fabs(v3y + projy) > fabs(v3y - projy)) {
 			projy = -projy;




More information about the Bf-blender-cvs mailing list