[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [44556] trunk/blender/source/blender/bmesh /intern/bmesh_polygon.c: use floats rather then doubles for bmesh poly functions.

Campbell Barton ideasman42 at gmail.com
Wed Feb 29 16:21:13 CET 2012


Revision: 44556
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=44556
Author:   campbellbarton
Date:     2012-02-29 15:21:09 +0000 (Wed, 29 Feb 2012)
Log Message:
-----------
use floats rather then doubles for bmesh poly functions.

Modified Paths:
--------------
    trunk/blender/source/blender/bmesh/intern/bmesh_polygon.c

Modified: trunk/blender/source/blender/bmesh/intern/bmesh_polygon.c
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_polygon.c	2012-02-29 15:10:01 UTC (rev 44555)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_polygon.c	2012-02-29 15:21:09 UTC (rev 44556)
@@ -49,24 +49,7 @@
  * Point in triangle tests stolen from scanfill.c.
  * Used for tesselator
  */
-static short testedgeside(const double v1[2], const double v2[2], const double v3[2])
-{
-	/* is v3 to the right of v1 - v2 ? With exception: v3 == v1 || v3 == v2 */
-	double inp;
 
-	//inp = (v2[cox] - v1[cox]) * (v1[coy] - v3[coy]) + (v1[coy] - v2[coy]) * (v1[cox] - v3[cox]);
-	inp = (v2[0] - v1[0]) * (v1[1] - v3[1]) + (v1[1] - v2[1]) * (v1[0] - v3[0]);
-
-	if (inp < 0.0) {
-		return FALSE;
-	}
-	else if (inp == 0) {
-		if (v1[0] == v3[0] && v1[1] == v3[1]) return FALSE;
-		if (v2[0] == v3[0] && v2[1] == v3[1]) return FALSE;
-	}
-	return TRUE;
-}
-
 static short testedgesidef(const float v1[2], const float v2[2], const float v3[2])
 {
 	/* is v3 to the right of v1 - v2 ? With exception: v3 == v1 || v3 == v2 */
@@ -85,14 +68,6 @@
 	return TRUE;
 }
 
-static int point_in_triangle(const double v1[2], const double v2[2], const double v3[2], const double pt[2])
-{
-	if (testedgeside(v1, v2, pt) && testedgeside(v2, v3, pt) && testedgeside(v3, v1, pt)) {
-		return TRUE;
-	}
-	return FALSE;
-}
-
 /**
  * \brief COMPUTE POLY NORMAL
  *
@@ -694,14 +669,14 @@
 {
 	BMLoop *l_iter;
 	BMLoop *l_first;
-	double v1[3], v2[3], v3[3], pv1[3], pv2[3];
+	float v1[3], v2[3], v3[3], pv1[3], pv2[3];
 	int i;
 
-	VECCOPY(v1, projectverts[v1i])
-	VECCOPY(v2, projectverts[v2i]);
-	VECCOPY(v3, projectverts[v3i]);
+	copy_v3_v3(v1, projectverts[v1i]);
+	copy_v3_v3(v2, projectverts[v2i]);
+	copy_v3_v3(v3, projectverts[v3i]);
 	
-	if (testedgeside(v1, v2, v3)) {
+	if (testedgesidef(v1, v2, v3)) {
 		return FALSE;
 	}
 
@@ -713,13 +688,13 @@
 			continue;
 		}
 		
-		VECCOPY(pv1, projectverts[BM_elem_index_get(l_iter->v)]);
-		VECCOPY(pv2, projectverts[BM_elem_index_get(l_iter->next->v)]);
+		copy_v3_v3(pv1, projectverts[BM_elem_index_get(l_iter->v)]);
+		copy_v3_v3(pv2, projectverts[BM_elem_index_get(l_iter->next->v)]);
 		
-		//if (linecrosses(pv1, pv2, v1, v3)) return FALSE;
+		//if (linecrossesf(pv1, pv2, v1, v3)) return FALSE;
 
-		if (point_in_triangle(v1, v2, v3, pv1) ||
-		    point_in_triangle(v3, v2, v1, pv1))
+		if (isect_point_tri_v2(pv1, v1, v2, v3) ||
+		    isect_point_tri_v2(pv1, v3, v2, v1))
 		{
 			return FALSE;
 		}




More information about the Bf-blender-cvs mailing list