diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-03-31 04:17:46 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-03-31 04:19:32 +0400 |
commit | 6aa75d3b2c3d4a5dc58120a51fdee0a7c12ab93c (patch) | |
tree | 86898d7de3be6a175d8cfe6190dd6750a40c0eb1 /source/blender/python/mathutils/mathutils_Vector.c | |
parent | e001b5b33ec1fa8897b5fdc0b125a813ec6a4cd1 (diff) |
Fix for error in normalize_vn_vn(), add len_squared_vn
Diffstat (limited to 'source/blender/python/mathutils/mathutils_Vector.c')
-rw-r--r-- | source/blender/python/mathutils/mathutils_Vector.c | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c index 3dc953e22e9..96e68317e2d 100644 --- a/source/blender/python/mathutils/mathutils_Vector.c +++ b/source/blender/python/mathutils/mathutils_Vector.c @@ -1888,17 +1888,6 @@ static PyObject *Vector_neg(VectorObject *self) return Vector_CreatePyObject_alloc(tvec, self->size, Py_TYPE(self)); } -/*------------------------vec_magnitude_nosqrt (internal) - for comparing only */ -static double vec_magnitude_nosqrt(const float *data, int size) -{ - /* return (double)sqrt(dot);*/ - /* warning, line above removed because we are not using the length, - * rather the comparing the sizes and for this we do not need the sqrt - * for the actual length, the dot must be sqrt'd */ - return dot_vn_vn(data, data, size); -} - - /*------------------------tp_richcmpr * returns -1 exception, 0 false, 1 true */ static PyObject *Vector_richcmpr(PyObject *objectA, PyObject *objectB, int comparison_type) @@ -1933,15 +1922,15 @@ static PyObject *Vector_richcmpr(PyObject *objectA, PyObject *objectB, int compa switch (comparison_type) { case Py_LT: - lenA = vec_magnitude_nosqrt(vecA->vec, vecA->size); - lenB = vec_magnitude_nosqrt(vecB->vec, vecB->size); + lenA = len_squared_vn(vecA->vec, vecA->size); + lenB = len_squared_vn(vecB->vec, vecB->size); if (lenA < lenB) { result = 1; } break; case Py_LE: - lenA = vec_magnitude_nosqrt(vecA->vec, vecA->size); - lenB = vec_magnitude_nosqrt(vecB->vec, vecB->size); + lenA = len_squared_vn(vecA->vec, vecA->size); + lenB = len_squared_vn(vecB->vec, vecB->size); if (lenA < lenB) { result = 1; } @@ -1956,15 +1945,15 @@ static PyObject *Vector_richcmpr(PyObject *objectA, PyObject *objectB, int compa result = !EXPP_VectorsAreEqual(vecA->vec, vecB->vec, vecA->size, 1); break; case Py_GT: - lenA = vec_magnitude_nosqrt(vecA->vec, vecA->size); - lenB = vec_magnitude_nosqrt(vecB->vec, vecB->size); + lenA = len_squared_vn(vecA->vec, vecA->size); + lenB = len_squared_vn(vecB->vec, vecB->size); if (lenA > lenB) { result = 1; } break; case Py_GE: - lenA = vec_magnitude_nosqrt(vecA->vec, vecA->size); - lenB = vec_magnitude_nosqrt(vecB->vec, vecB->size); + lenA = len_squared_vn(vecA->vec, vecA->size); + lenB = len_squared_vn(vecB->vec, vecB->size); if (lenA > lenB) { result = 1; } |