[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [34709] trunk/blender/source/blender: fix [#25975] Quaternion/Vector.negated() isn't available

Campbell Barton ideasman42 at gmail.com
Tue Feb 8 04:37:50 CET 2011


Revision: 34709
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=34709
Author:   campbellbarton
Date:     2011-02-08 03:37:49 +0000 (Tue, 08 Feb 2011)
Log Message:
-----------
fix [#25975] Quaternion/Vector.negated() isn't available
theres no need for value.negated(), better use -vec / -quat. however -quat didn't exist.

Modified Paths:
--------------
    trunk/blender/source/blender/blenlib/BLI_math_vector.h
    trunk/blender/source/blender/blenlib/intern/math_vector_inline.c
    trunk/blender/source/blender/python/generic/mathutils_quat.c

Modified: trunk/blender/source/blender/blenlib/BLI_math_vector.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_math_vector.h	2011-02-08 02:09:59 UTC (rev 34708)
+++ trunk/blender/source/blender/blenlib/BLI_math_vector.h	2011-02-08 03:37:49 UTC (rev 34709)
@@ -85,6 +85,7 @@
 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]);

Modified: trunk/blender/source/blender/blenlib/intern/math_vector_inline.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/math_vector_inline.c	2011-02-08 02:09:59 UTC (rev 34708)
+++ trunk/blender/source/blender/blenlib/intern/math_vector_inline.c	2011-02-08 03:37:49 UTC (rev 34709)
@@ -290,6 +290,14 @@
 	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];

Modified: trunk/blender/source/blender/python/generic/mathutils_quat.c
===================================================================
--- trunk/blender/source/blender/python/generic/mathutils_quat.c	2011-02-08 02:09:59 UTC (rev 34708)
+++ trunk/blender/source/blender/python/generic/mathutils_quat.c	2011-02-08 03:37:49 UTC (rev 34709)
@@ -744,6 +744,20 @@
 	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 @@
 	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*/




More information about the Bf-blender-cvs mailing list