diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-02-08 06:37:49 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-02-08 06:37:49 +0300 |
commit | 53afd198084e4bca72d6694708d801a799a2f76f (patch) | |
tree | 551887b832a1be33f0173b825685c063cfe9eeab /source | |
parent | 0242a96f3bc0d844c6ca1c3916671b891de10d9f (diff) |
fix [#25975] Quaternion/Vector.negated() isn't available
theres no need for value.negated(), better use -vec / -quat. however -quat didn't exist.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenlib/BLI_math_vector.h | 1 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_vector_inline.c | 8 | ||||
-rw-r--r-- | source/blender/python/generic/mathutils_quat.c | 16 |
3 files changed, 24 insertions, 1 deletions
diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h index 16b8ff8e472..dcb9311baa0 100644 --- a/source/blender/blenlib/BLI_math_vector.h +++ b/source/blender/blenlib/BLI_math_vector.h @@ -85,6 +85,7 @@ MINLINE void madd_v4_v4fl(float r[4], const float a[4], float f); MINLINE void negate_v3(float r[3]); MINLINE void negate_v3_v3(float r[3], const float a[3]); MINLINE void negate_v4(float r[4]); +MINLINE void negate_v4_v4(float r[4], const float a[3]); MINLINE float dot_v2v2(const float a[2], const float b[2]); MINLINE float dot_v3v3(const float a[3], const float b[3]); diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c index ae1b443bc56..2f808e5d74e 100644 --- a/source/blender/blenlib/intern/math_vector_inline.c +++ b/source/blender/blenlib/intern/math_vector_inline.c @@ -290,6 +290,14 @@ MINLINE void negate_v4(float r[4]) r[3]= -r[3]; } +MINLINE void negate_v4_v4(float r[4], const float a[4]) +{ + r[0]= -a[0]; + r[1]= -a[1]; + r[2]= -a[2]; + r[3]= -a[3]; +} + MINLINE float dot_v2v2(const float a[2], const float b[2]) { return a[0]*b[0] + a[1]*b[1]; diff --git a/source/blender/python/generic/mathutils_quat.c b/source/blender/python/generic/mathutils_quat.c index 56757ae5d2d..b28ef866fea 100644 --- a/source/blender/python/generic/mathutils_quat.c +++ b/source/blender/python/generic/mathutils_quat.c @@ -744,6 +744,20 @@ static PyObject *Quaternion_mul(PyObject *q1, PyObject *q2) return NULL; } +/* -obj + returns the negative of this object*/ +static PyObject *Quaternion_neg(QuaternionObject *self) +{ + float tquat[QUAT_SIZE]; + + if(!BaseMath_ReadCallback(self)) + return NULL; + + negate_v4_v4(tquat, self->quat); + return newQuaternionObject(tquat, Py_NEW, Py_TYPE(self)); +} + + //-----------------PROTOCOL DECLARATIONS-------------------------- static PySequenceMethods Quaternion_SeqMethods = { (lenfunc) Quaternion_len, /* sq_length */ @@ -771,7 +785,7 @@ static PyNumberMethods Quaternion_NumMethods = { 0, /*nb_remainder*/ 0, /*nb_divmod*/ 0, /*nb_power*/ - (unaryfunc) 0, /*nb_negative*/ + (unaryfunc) Quaternion_neg, /*nb_negative*/ (unaryfunc) 0, /*tp_positive*/ (unaryfunc) 0, /*tp_absolute*/ (inquiry) 0, /*tp_bool*/ |