diff options
-rw-r--r-- | source/blender/python/api2_2x/Mesh.c | 31 | ||||
-rw-r--r-- | source/blender/python/api2_2x/doc/Mathutils.py | 29 | ||||
-rw-r--r-- | source/blender/python/api2_2x/euler.c | 11 | ||||
-rw-r--r-- | source/blender/python/api2_2x/euler.h | 1 | ||||
-rw-r--r-- | source/blender/python/api2_2x/quat.c | 10 | ||||
-rw-r--r-- | source/blender/python/api2_2x/quat.h | 1 |
6 files changed, 74 insertions, 9 deletions
diff --git a/source/blender/python/api2_2x/Mesh.c b/source/blender/python/api2_2x/Mesh.c index 2d43713fa62..7bdcb377dae 100644 --- a/source/blender/python/api2_2x/Mesh.c +++ b/source/blender/python/api2_2x/Mesh.c @@ -6740,6 +6740,33 @@ static PyObject *Mesh_getUsers( BPy_Mesh * self ) "couldn't get Mesh.users attribute" ); } +static PyObject *Mesh_getFakeUser( BPy_Mesh * self ) +{ + if (self->mesh->id.flag & LIB_FAKEUSER) + EXPP_incr_ret_True(); + else + EXPP_incr_ret_False(); +} + +static int Mesh_setFakeUser( BPy_Mesh * self, PyObject * value ) +{ + int param; + + param = PyObject_IsTrue( value ); + + if( param == -1 ) + return EXPP_ReturnIntError( PyExc_TypeError, + "expected int argument in range [0,1]" ); + if (param) { + self->mesh->id.flag |= LIB_FAKEUSER; + self->mesh->id.us++; + } else { + self->mesh->id.flag &= ~LIB_FAKEUSER; + self->mesh->id.us--; + } + return 0; +} + static PyObject *Mesh_getFlag( BPy_Mesh * self, void *type ) { PyObject *attr; @@ -7145,6 +7172,10 @@ static PyGetSetDef BPy_Mesh_getseters[] = { (getter)Mesh_getUsers, (setter)NULL, "Number of users of the mesh", NULL}, + {"fakeUser", + (getter)Mesh_getFakeUser, (setter)Mesh_setFakeUser, + "The fake user status of this mesh", + NULL}, {"activeGroup", (getter)Mesh_getActiveGroup, (setter)Mesh_setActiveGroup, "Active group for the mesh", diff --git a/source/blender/python/api2_2x/doc/Mathutils.py b/source/blender/python/api2_2x/doc/Mathutils.py index 41b2f04de6b..ffe8a53ed01 100644 --- a/source/blender/python/api2_2x/doc/Mathutils.py +++ b/source/blender/python/api2_2x/doc/Mathutils.py @@ -496,20 +496,20 @@ class Vector: def resize2D(): """ Resize the vector to 2d. - @return: a copy of itself + @return: an instance of itself """ def resize3D(): """ Resize the vector to 3d. New axis will be 0.0. - @return: a copy of itself + @return: an instance of itself """ def resize4D(): """ Resize the vector to 4d. New axis will be 0.0. The last component will be 1.0, to make multiplying 3d vectors by 4x4 matrices easier. - @return: a copy of itself + @return: an instance of itself """ def toTrackQuat(track, up): @@ -580,13 +580,18 @@ class Euler: def zero(): """ Set all values to zero. - @return: a copy of itself + @return: an instance of itself + """ + + def copy(): + """ + @return: a copy of this euler. """ def unique(): """ Calculate a unique rotation for this euler. Avoids gimble lock. - @return: a copy of itself + @return: an instance of itself """ def toMatrix(): @@ -669,31 +674,37 @@ class Quaternion: def identity(): """ Set the quaternion to the identity quaternion. + @return: an instance of itself + """ + + def copy(): + """ + make a copy of the quaternion. @return: a copy of itself """ def negate(): """ Set the quaternion to its negative. - @return: a copy of itself + @return: an instance of itself """ def conjugate(): """ Set the quaternion to its conjugate. - @return: a copy of itself + @return: an instance of itself """ def inverse(): """ Set the quaternion to its inverse - @return: a copy of itself + @return: an instance of itself """ def normalize(): """ Normalize the quaternion. - @return: a copy of itself + @return: an instance of itself """ def toEuler(): diff --git a/source/blender/python/api2_2x/euler.c b/source/blender/python/api2_2x/euler.c index 99855f93b0d..6956bf42ffe 100644 --- a/source/blender/python/api2_2x/euler.c +++ b/source/blender/python/api2_2x/euler.c @@ -43,6 +43,7 @@ char Euler_Unique_doc[] ="() - sets the euler rotation a unique shortest arc rot char Euler_ToMatrix_doc[] = "() - returns a rotation matrix representing the euler rotation"; char Euler_ToQuat_doc[] = "() - returns a quaternion representing the euler rotation"; char Euler_Rotate_doc[] = "() - rotate a euler by certain amount around an axis of rotation"; +char Euler_copy_doc[] = "() - returns a copy of the euler."; //-----------------------METHOD DEFINITIONS ---------------------- struct PyMethodDef Euler_methods[] = { {"zero", (PyCFunction) Euler_Zero, METH_NOARGS, Euler_Zero_doc}, @@ -50,6 +51,8 @@ struct PyMethodDef Euler_methods[] = { {"toMatrix", (PyCFunction) Euler_ToMatrix, METH_NOARGS, Euler_ToMatrix_doc}, {"toQuat", (PyCFunction) Euler_ToQuat, METH_NOARGS, Euler_ToQuat_doc}, {"rotate", (PyCFunction) Euler_Rotate, METH_VARARGS, Euler_Rotate_doc}, + {"__copy__", (PyCFunction) Euler_copy, METH_VARARGS, Euler_copy_doc}, + {"copy", (PyCFunction) Euler_copy, METH_VARARGS, Euler_copy_doc}, {NULL, NULL, 0, NULL} }; //-----------------------------METHODS---------------------------- @@ -171,6 +174,14 @@ PyObject *Euler_Rotate(EulerObject * self, PyObject *args) return EXPP_incr_ret((PyObject*)self); } +//----------------------------Euler.rotate()----------------------- +// return a copy of the euler +PyObject *Euler_copy(EulerObject * self, PyObject *args) +{ + return newEulerObject(self->eul, Py_NEW); +} + + //----------------------------dealloc()(internal) ------------------ //free the py_object static void Euler_dealloc(EulerObject * self) diff --git a/source/blender/python/api2_2x/euler.h b/source/blender/python/api2_2x/euler.h index 70a4affb086..62e5855891b 100644 --- a/source/blender/python/api2_2x/euler.h +++ b/source/blender/python/api2_2x/euler.h @@ -61,6 +61,7 @@ PyObject *Euler_Unique( EulerObject * self ); PyObject *Euler_ToMatrix( EulerObject * self ); PyObject *Euler_ToQuat( EulerObject * self ); PyObject *Euler_Rotate( EulerObject * self, PyObject *args ); +PyObject *Euler_copy( EulerObject * self, PyObject *args ); PyObject *newEulerObject( float *eul, int type ); #endif /* EXPP_euler_h */ diff --git a/source/blender/python/api2_2x/quat.c b/source/blender/python/api2_2x/quat.c index af778d27f07..43aa7422101 100644 --- a/source/blender/python/api2_2x/quat.c +++ b/source/blender/python/api2_2x/quat.c @@ -45,6 +45,7 @@ char Quaternion_Inverse_doc[] = "() - set the quaternion to it's inverse"; char Quaternion_Normalize_doc[] = "() - normalize the vector portion of the quaternion"; char Quaternion_ToEuler_doc[] = "() - return a euler rotation representing the quaternion"; char Quaternion_ToMatrix_doc[] = "() - return a rotation matrix representing the quaternion"; +char Quaternion_copy_doc[] = "() - return a copy of the quat"; //-----------------------METHOD DEFINITIONS ---------------------- struct PyMethodDef Quaternion_methods[] = { {"identity", (PyCFunction) Quaternion_Identity, METH_NOARGS, Quaternion_Identity_doc}, @@ -54,6 +55,8 @@ struct PyMethodDef Quaternion_methods[] = { {"normalize", (PyCFunction) Quaternion_Normalize, METH_NOARGS, Quaternion_Normalize_doc}, {"toEuler", (PyCFunction) Quaternion_ToEuler, METH_NOARGS, Quaternion_ToEuler_doc}, {"toMatrix", (PyCFunction) Quaternion_ToMatrix, METH_NOARGS, Quaternion_ToMatrix_doc}, + {"__copy__", (PyCFunction) Quaternion_copy, METH_NOARGS, Quaternion_copy_doc}, + {"copy", (PyCFunction) Quaternion_copy, METH_NOARGS, Quaternion_copy_doc}, {NULL, NULL, 0, NULL} }; //-----------------------------METHODS------------------------------ @@ -137,6 +140,13 @@ PyObject *Quaternion_Conjugate(QuaternionObject * self) } return EXPP_incr_ret((PyObject*)self); } +//----------------------------Quaternion.copy()---------------- +//return a copy of the quat +PyObject *Quaternion_copy(QuaternionObject * self) +{ + return newQuaternionObject(self->quat, Py_NEW); +} + //----------------------------dealloc()(internal) ------------------ //free the py_object static void Quaternion_dealloc(QuaternionObject * self) diff --git a/source/blender/python/api2_2x/quat.h b/source/blender/python/api2_2x/quat.h index da7e053d99a..2e5f6788b2e 100644 --- a/source/blender/python/api2_2x/quat.h +++ b/source/blender/python/api2_2x/quat.h @@ -67,6 +67,7 @@ PyObject *Quaternion_Inverse( QuaternionObject * self ); PyObject *Quaternion_Normalize( QuaternionObject * self ); PyObject *Quaternion_ToEuler( QuaternionObject * self ); PyObject *Quaternion_ToMatrix( QuaternionObject * self ); +PyObject *Quaternion_copy( QuaternionObject * self ); PyObject *newQuaternionObject( float *quat, int type ); #endif /* EXPP_quat_h */ |