[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15766] trunk/blender/source: added exception messages to game engine matrix and vector conversions.

Campbell Barton ideasman42 at gmail.com
Fri Jul 25 23:14:24 CEST 2008


Revision: 15766
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15766
Author:   campbellbarton
Date:     2008-07-25 23:14:23 +0200 (Fri, 25 Jul 2008)

Log Message:
-----------
added exception messages to game engine matrix and vector conversions. also removed own unneeded defines in arithb.c

Modified Paths:
--------------
    trunk/blender/source/blender/blenlib/intern/arithb.c
    trunk/blender/source/gameengine/Ketsji/KX_PyMath.h

Modified: trunk/blender/source/blender/blenlib/intern/arithb.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/arithb.c	2008-07-25 18:57:16 UTC (rev 15765)
+++ trunk/blender/source/blender/blenlib/intern/arithb.c	2008-07-25 21:14:23 UTC (rev 15766)
@@ -2536,11 +2536,6 @@
 }
 
 
-
-			/* copied from Geometry.c - todo - move to arithb.c or some other generic place we can reuse */
-#define SIDE_OF_LINE(pa,pb,pp)	((pa[0]-pp[0])*(pb[1]-pp[1]))-((pb[0]-pp[0])*(pa[1]-pp[1]))
-#define POINT_IN_TRI(p0,p1,p2,p3)	((SIDE_OF_LINE(p1,p2,p0)>=0) && (SIDE_OF_LINE(p2,p3,p0)>=0) && (SIDE_OF_LINE(p3,p1,p0)>=0))
-
 /**
  * 
  * @param min 

Modified: trunk/blender/source/gameengine/Ketsji/KX_PyMath.h
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_PyMath.h	2008-07-25 18:57:16 UTC (rev 15765)
+++ trunk/blender/source/gameengine/Ketsji/KX_PyMath.h	2008-07-25 21:14:23 UTC (rev 15766)
@@ -84,7 +84,10 @@
 		}
 	} else 
 		noerror = false;
-	 
+	
+	if (noerror==false)
+		PyErr_SetString(PyExc_TypeError, "could not be converted to a matrix (sequence of sequences)");
+	
 	return noerror;
 }
 
@@ -97,9 +100,13 @@
 	if (PySequence_Check(pyval))
 	{
 		unsigned int numitems = PySequence_Size(pyval);
-		if (numitems != Size(vec))
+		if (numitems != Size(vec)) {
+			char err[128];
+			sprintf(err, "error setting vector, %d args, should be %d", numitems, Size(vec));
+			PyErr_SetString(PyExc_AttributeError, err);
 			return false;
-			
+		}
+		
 		for (unsigned int x = 0; x < numitems; x++)
 		{
 			PyObject *item = PySequence_GetItem(pyval, x); /* new ref */
@@ -107,7 +114,17 @@
 			Py_DECREF(item);
 		}
 		
+		if (PyErr_Occurred()) {
+			PyErr_SetString(PyExc_AttributeError, "one or more of the items in the sequence was not a float");
+			return false;
+		}
+		
 		return true;
+	} else
+	{
+		char err[128];
+		sprintf(err, "not a sequence type, expected a sequence of numbers size %d", Size(vec));
+		PyErr_SetString(PyExc_AttributeError, err);
 	}
 	
 	return false;





More information about the Bf-blender-cvs mailing list