From af431c5a687922f95b12949c3fd982b7e3e51000 Mon Sep 17 00:00:00 2001 From: Joseph Gilbert Date: Tue, 27 Sep 2005 18:41:39 +0000 Subject: [PATCH] -fix for angleBetweenVecs * adds a test to check for zero-length vectors --- source/blender/python/api2_2x/Mathutils.c | 10 ++++++++++ 1 file changed, 10 insertions(+) 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;