diff options
author | Joseph Gilbert <ascotan@gmail.com> | 2005-09-27 22:41:39 +0400 |
---|---|---|
committer | Joseph Gilbert <ascotan@gmail.com> | 2005-09-27 22:41:39 +0400 |
commit | af431c5a687922f95b12949c3fd982b7e3e51000 (patch) | |
tree | 620ff751b68d7fd65b2407e068e637a69c6198f4 /source/blender/python/api2_2x/Mathutils.c | |
parent | 39a243f8d2ab2f3bac870ffcaf2ccb0e896c7371 (diff) |
-fix for angleBetweenVecs
* adds a test to check for zero-length vectors
Diffstat (limited to 'source/blender/python/api2_2x/Mathutils.c')
-rw-r--r-- | source/blender/python/api2_2x/Mathutils.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/source/blender/python/api2_2x/Mathutils.c b/source/blender/python/api2_2x/Mathutils.c index f36f7337808..e8bf2b49af2 100644 --- a/source/blender/python/api2_2x/Mathutils.c +++ b/source/blender/python/api2_2x/Mathutils.c @@ -465,6 +465,7 @@ PyObject *M_Mathutils_AngleBetweenVecs(PyObject * self, PyObject * args) double norm_a = 0.0f, norm_b = 0.0f; double vec_a[4], vec_b[4]; int x, size; + PyObject *test = NULL; if(!PyArg_ParseTuple(args, "O!O!", &vector_Type, &vec1, &vector_Type, &vec2)) return EXPP_ReturnPyObjError(PyExc_TypeError, @@ -473,6 +474,15 @@ PyObject *M_Mathutils_AngleBetweenVecs(PyObject * self, PyObject * args) return EXPP_ReturnPyObjError(PyExc_AttributeError, "Mathutils.AngleBetweenVecs(): expects (2) vector objects of the same size\n"); + //test to make sure that we don't have a zero vector + test = M_Mathutils_DotVecs(self, args); + if(!PyFloat_AS_DOUBLE(test)){ + Py_DECREF(test); + return EXPP_ReturnPyObjError(PyExc_AttributeError, + "Mathutils.AngleBetweenVecs(): zero-length vectors not acceptable\n"); + } + Py_DECREF(test); + //since size is the same.... size = vec1->size; |