fix [#25975] Quaternion/Vector.negated() isn't available

theres no need for value.negated(), better use -vec / -quat. however -quat didn't exist.
This commit is contained in:
2011-02-08 03:37:49 +00:00
parent 0242a96f3b
commit 53afd19808
3 changed files with 24 additions and 1 deletions

View File

@@ -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*/