[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [14020] trunk/blender/source/blender/src/ drawimage.c: fixed divide by zero problem with last commit

Campbell Barton ideasman42 at gmail.com
Sun Mar 9 04:55:46 CET 2008


Revision: 14020
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=14020
Author:   campbellbarton
Date:     2008-03-09 04:55:46 +0100 (Sun, 09 Mar 2008)

Log Message:
-----------
fixed divide by zero problem with last commit

Modified Paths:
--------------
    trunk/blender/source/blender/src/drawimage.c

Modified: trunk/blender/source/blender/src/drawimage.c
===================================================================
--- trunk/blender/source/blender/src/drawimage.c	2008-03-09 03:42:59 UTC (rev 14019)
+++ trunk/blender/source/blender/src/drawimage.c	2008-03-09 03:55:46 UTC (rev 14020)
@@ -584,7 +584,7 @@
 			case SI_UVDT_STRETCH_AREA:
 			{
 				float totarea, totuvarea, areadiff, uvarea, area, col[3];
-				
+				int uvarea_error = 0;
 				for (efa= em->faces.first; efa; efa= efa->next) {
 					tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
 					
@@ -600,15 +600,32 @@
 					}
 				}
 				
+				if (totarea==0.0 || totarea==0.0) {
+					col[0] - 1.0;
+					col[1] = col[2] = 0.0;
+					glColor3fv(col);
+					for (efa= em->faces.first; efa; efa= efa->next) {
+						glBegin(efa->v4?GL_QUADS:GL_TRIANGLES);
+							glVertex2fv(tface->uv[0]);
+							glVertex2fv(tface->uv[1]);
+							glVertex2fv(tface->uv[2]);
+							if(efa->v4) glVertex2fv(tface->uv[3]);
+						glEnd();
+					}
+				}
+				
 				for (efa= em->faces.first; efa; efa= efa->next) {
 					if ((tface=(MTFace *)efa->tmp.p)) {
 						area = EM_face_area(efa) / totarea;
 						uvarea = tface_area(tface, efa->v4!=0) / totuvarea;
-						if (area>uvarea) {
+						if (area==0.0 || uvarea==0.0) {
+							areadiff = 1.0;
+						} else if (area>uvarea) {
 							areadiff = 1.0-(uvarea/area);
 						} else {
 							areadiff = 1.0-(area/uvarea);
 						}
+						
 						weight_to_rgb(areadiff, col, col+1, col+2);
 						glColor3fv(col);
 						
@@ -699,11 +716,6 @@
 				break;
 			}
 		}
-		
-		
-		/* draw stretch angles */
-
-		
 	} else if(G.f & G_DRAWFACES) {
 		/* draw transparent faces */
 		BIF_GetThemeColor4ubv(TH_FACE, col1);
@@ -712,7 +724,6 @@
 		glEnable(GL_BLEND);
 		
 		for (efa= em->faces.first; efa; efa= efa->next) {
-			int lastsel=-1;
 			tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
 			
 			if (simaFaceDraw_Check(efa, tface)) {





More information about the Bf-blender-cvs mailing list