From 6d9c02be4cfd61b985af789e167f7fa78dbc0868 Mon Sep 17 00:00:00 2001 From: Willian Padovani Germano Date: Tue, 30 Nov 2004 02:27:46 +0000 Subject: Scripts: - Fixes by Jean-Michel Soler: mod_ai2obj.py, mod_svg2obj.py; - Fixes by Campbell Barton: obj_import.py; - Small fix to mod_meshtools.py (fixes bug #1605: http://projects.blender.org/tracker/?func=detail&atid=125&aid=1605&group_id=9); - Updates by Jean-Baptiste (Jiba) to his blender2cal3d.py; - Updates to all his import / export scripts (added doc data) by Anthony D'Agostino; - Update to off_import: support for uv data, by Arne Schmitz. BPython: - Removed Object.get and .getSelected (deprecated long ago, we use .Get and .GetSelected) -- fixes #1861: http://projects.blender.org/tracker/?func=detail&atid=125&aid=1861&group_id=9 - Applied patch by Michael Reimpell: quat.c - fix for wrong initialization with newQuaternionObject; Mathutils documentation improvements. - Stani reported a wrong return msg in IpoCurve.Get (that is unimplemented). Thanks to all coders mentioned above! --- source/blender/python/api2_2x/Ipocurve.c | 3 ++- source/blender/python/api2_2x/Object.c | 33 +------------------------- source/blender/python/api2_2x/doc/Mathutils.py | 25 ++++++++++--------- source/blender/python/api2_2x/quat.c | 23 +++++++++--------- 4 files changed, 29 insertions(+), 55 deletions(-) (limited to 'source/blender/python') diff --git a/source/blender/python/api2_2x/Ipocurve.c b/source/blender/python/api2_2x/Ipocurve.c index 9a50345fb39..8bebce34529 100644 --- a/source/blender/python/api2_2x/Ipocurve.c +++ b/source/blender/python/api2_2x/Ipocurve.c @@ -195,7 +195,8 @@ PyObject *IpoCurve_Init( void ) /*****************************************************************************/ static PyObject *M_IpoCurve_Get( PyObject * self, PyObject * args ) { - return 0; + Py_INCREF(Py_None); + return Py_None; } /*****************************************************************************/ diff --git a/source/blender/python/api2_2x/Object.c b/source/blender/python/api2_2x/Object.c index e9048ffad3a..ec352061268 100644 --- a/source/blender/python/api2_2x/Object.c +++ b/source/blender/python/api2_2x/Object.c @@ -57,9 +57,7 @@ /*****************************************************************************/ static PyObject *M_Object_New( PyObject * self, PyObject * args ); PyObject *M_Object_Get( PyObject * self, PyObject * args ); -PyObject *M_Object_get( PyObject * self, PyObject * args ); static PyObject *M_Object_GetSelected( PyObject * self, PyObject * args ); -static PyObject *M_Object_getSelected( PyObject * self, PyObject * args ); /*****************************************************************************/ /* The following string definitions are used for documentation strings. */ @@ -90,12 +88,8 @@ struct PyMethodDef M_Object_methods[] = { M_Object_New_doc}, {"Get", ( PyCFunction ) M_Object_Get, METH_VARARGS, M_Object_Get_doc}, - {"get", ( PyCFunction ) M_Object_get, METH_VARARGS, - M_Object_Get_doc}, {"GetSelected", ( PyCFunction ) M_Object_GetSelected, METH_VARARGS, M_Object_GetSelected_doc}, - {"getSelected", ( PyCFunction ) M_Object_getSelected, METH_VARARGS, - M_Object_GetSelected_doc}, {NULL, NULL, 0, NULL} }; @@ -516,21 +510,9 @@ PyObject *M_Object_Get( PyObject * self, PyObject * args ) } } -/*****************************************************************************/ -/* Function: M_Object_get */ -/* Python equivalent: Blender.Object.get */ -/*****************************************************************************/ -PyObject *M_Object_get( PyObject * self, PyObject * args ) -{ - PyErr_Warn( PyExc_DeprecationWarning, - "The Object.get() function will be removed in Blender 2.29\n" - "Please update the script to use Object.Get" ); - return ( M_Object_Get( self, args ) ); -} - /*****************************************************************************/ /* Function: M_Object_GetSelected */ -/* Python equivalent: Blender.Object.getSelected */ +/* Python equivalent: Blender.Object.GetSelected */ /*****************************************************************************/ static PyObject *M_Object_GetSelected( PyObject * self, PyObject * args ) { @@ -583,19 +565,6 @@ static PyObject *M_Object_GetSelected( PyObject * self, PyObject * args ) return ( list ); } -/*****************************************************************************/ -/* Function: M_Object_getSelected */ -/* Python equivalent: Blender.Object.getSelected */ -/*****************************************************************************/ -static PyObject *M_Object_getSelected( PyObject * self, PyObject * args ) -{ - PyErr_Warn( PyExc_DeprecationWarning, - "The Object.getSelected() function will be removed in " - "Blender 2.29\n" - "Please update the script to use Object.GetSelected" ); - return ( M_Object_GetSelected( self, args ) ); -} - /*****************************************************************************/ /* Function: initObject */ /*****************************************************************************/ diff --git a/source/blender/python/api2_2x/doc/Mathutils.py b/source/blender/python/api2_2x/doc/Mathutils.py index b5586fb2bfe..70427b6c074 100644 --- a/source/blender/python/api2_2x/doc/Mathutils.py +++ b/source/blender/python/api2_2x/doc/Mathutils.py @@ -319,7 +319,7 @@ class Vector: v = Blender.Mathutils.Vector([1,0,0]) @type list: PyList of float or int @param list: The list of values for the Vector object. - Must be 2, 3, or 4 values. + Must be 2, 3, or 4 values. The list is mapped to the parameters as [x,y,z,w]. @rtype: Vector object. @return: It depends wheter a parameter was passed: - (list): Vector object initialized with the given values; @@ -420,16 +420,16 @@ class Quaternion: in degrees. """ - def __init__(list = None, angle = None): + def __init__(list, angle = None): """ Create a new quaternion object from initialized values. Example:: - quat = Mathutils.Quaternion() + quat = Mathutils.Quaternion([1.0,0.0,0.0]) @type list: PyList of int/float @param list: A 3d or 4d list to initialize quaternion. - 4d if intializing, 3d if will be used as an axis of rotation. + 4d if intializing [w,x,y,z], 3d if used as an axis of rotation. @type angle: float (optional) @param angle: An arbitrary rotation amount around 'list'. List is used as an axis of rotation in this case. @@ -527,7 +527,7 @@ class Matrix: def determinant(): """ - Return a the determinant of a matrix. + Return the determinant of a matrix. @rtype: int @return: Return a the determinant of a matrix. @@ -540,9 +540,12 @@ class Matrix: def rotationPart(): """ - Return the 3d rotation matrix. + Return the 3d submatrix corresponding to the linear term of the + embedded affine transformation in 3d. This matrix represents rotation + and scale. Note that the (4,4) element of a matrix can be used for uniform + scaling, too. @rtype: Matrix object. - @return: Return the 3d rotation matrix. + @return: Return the 3d matrix for rotation and scale. """ @@ -561,17 +564,17 @@ class Matrix: def toEuler(): """ - Return a euler representing the rotation matrix. + Return an Euler representation of the rotation matrix. @rtype: Euler object - @return: Return a euler representing the rotation matrix. + @return: Euler representation of the rotation matrix. """ def toQuat(): """ - Return a quaternion representation the rotation matrix + Return a quaternion representation of the rotation matrix @rtype: Quaternion object - @return: Quaternion representation the rotation matrix + @return: Quaternion representation of the rotation matrix """ diff --git a/source/blender/python/api2_2x/quat.c b/source/blender/python/api2_2x/quat.c index a6974ef5086..e87050b29ea 100644 --- a/source/blender/python/api2_2x/quat.c +++ b/source/blender/python/api2_2x/quat.c @@ -531,13 +531,17 @@ PyTypeObject quaternion_Type = { &Quaternion_SeqMethods, /*tp_as_sequence */ }; -/* - newQuaternionObject - - if the quat arg is not null, this method allocates memory and copies *quat into it. - we will free the memory in the dealloc routine. -*/ - +/** Creates a new quaternion object. + * + * Memory for a new quaternion is allocated. The quaternion copies the given + * list of parameters or initializes to the identity, if a NULL + * pointer is given as parameter. The memory will be freed in the dealloc + * routine. + * + * @param quat Pointer to a list of floats for the quanternion parameters w, x, y, z. + * @return Quaternion Python object. + * @see Quaternion_Identity + */ PyObject *newQuaternionObject( float *quat ) { QuaternionObject *self; @@ -550,10 +554,7 @@ PyObject *newQuaternionObject( float *quat ) self->quat = PyMem_Malloc( 4 * sizeof( float ) ); if( !quat ) { - for( x = 0; x < 4; x++ ) { - self->quat[x] = 0.0f; - } - self->quat[3] = 1.0f; + Quaternion_Identity(self); } else { for( x = 0; x < 4; x++ ) { self->quat[x] = quat[x]; -- cgit v1.2.3