diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-01-30 16:15:39 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-01-30 16:15:39 +0300 |
commit | ec48cbd267818f444e942aebd876897314165762 (patch) | |
tree | c2548c58f90ade1ce0be637cd9bb828f2107bbc9 /source/blender/python/generic | |
parent | 7a76bc9a361e6cb45e4292c0ac5c7bb08936b829 (diff) |
utility functions is_negative_m3 & is_negative_m4, added python Mathutils access Matrix.is_negative
renamed Mathutils attribute wrapped -> is_wrapped
Diffstat (limited to 'source/blender/python/generic')
-rw-r--r-- | source/blender/python/generic/euler.c | 2 | ||||
-rw-r--r-- | source/blender/python/generic/matrix.c | 24 | ||||
-rw-r--r-- | source/blender/python/generic/quat.c | 2 | ||||
-rw-r--r-- | source/blender/python/generic/vector.c | 2 |
4 files changed, 25 insertions, 5 deletions
diff --git a/source/blender/python/generic/euler.c b/source/blender/python/generic/euler.c index 82bd2ebe70a..c41107286e0 100644 --- a/source/blender/python/generic/euler.c +++ b/source/blender/python/generic/euler.c @@ -571,7 +571,7 @@ static PyGetSetDef Euler_getseters[] = { {"y", (getter)Euler_getAxis, (setter)Euler_setAxis, "Euler Y axis in radians. **type** float", (void *)1}, {"z", (getter)Euler_getAxis, (setter)Euler_setAxis, "Euler Z axis in radians. **type** float", (void *)2}, - {"wrapped", (getter)BaseMathObject_getWrapped, (setter)NULL, BaseMathObject_Wrapped_doc, NULL}, + {"is_wrapped", (getter)BaseMathObject_getWrapped, (setter)NULL, BaseMathObject_Wrapped_doc, NULL}, {"_owner", (getter)BaseMathObject_getOwner, (setter)NULL, BaseMathObject_Owner_doc, NULL}, {NULL,NULL,NULL,NULL,NULL} /* Sentinel */ }; diff --git a/source/blender/python/generic/matrix.c b/source/blender/python/generic/matrix.c index a61cf4a2d41..0928a93f13d 100644 --- a/source/blender/python/generic/matrix.c +++ b/source/blender/python/generic/matrix.c @@ -1231,14 +1231,34 @@ static PyObject *Matrix_getMedianScale( MatrixObject * self, void *type ) return PyFloat_FromDouble(mat3_to_scale(mat)); } +static PyObject *Matrix_getIsNegative( MatrixObject * self, void *type ) +{ + float vec[3]; + + if(!BaseMath_ReadCallback(self)) + return NULL; + + /*must be 3-4 cols, 3-4 rows, square matrix*/ + if(self->colSize == 4 && self->rowSize == 4) + return PyBool_FromLong(is_negative_m4((float (*)[4])*self->matrix)); + else if(self->colSize == 3 && self->rowSize == 3) + return PyBool_FromLong(is_negative_m3((float (*)[3])*self->matrix)); + else { + PyErr_SetString(PyExc_AttributeError, "Matrix.is_negative: inappropriate matrix size - expects 3x3 or 4x4 matrix\n"); + return NULL; + } +} + + /*****************************************************************************/ /* Python attributes get/set structure: */ /*****************************************************************************/ static PyGetSetDef Matrix_getseters[] = { {"row_size", (getter)Matrix_getRowSize, (setter)NULL, "The row size of the matrix (readonly). **type** int", NULL}, {"col_size", (getter)Matrix_getColSize, (setter)NULL, "The column size of the matrix (readonly). **type** int", NULL}, - {"median_scale", (getter)Matrix_getMedianScale, (setter)NULL, "The average scale applied to each axis (readonly). **type** float", NULL}, - {"wrapped", (getter)BaseMathObject_getWrapped, (setter)NULL, BaseMathObject_Wrapped_doc, NULL}, + {"median_scale", (getter)Matrix_getMedianScale, (setter)NULL, "The average scale applied to each axis (readonly). **type** float", NULL}, + {"is_negative", (getter)Matrix_getIsNegative, (setter)NULL, "True if this matrix results in a negative scale, (3x3, 4x4 only) (readonly). **type** bool", NULL}, + {"is_wrapped", (getter)BaseMathObject_getWrapped, (setter)NULL, BaseMathObject_Wrapped_doc, NULL}, {"_owner",(getter)BaseMathObject_getOwner, (setter)NULL, BaseMathObject_Owner_doc, NULL}, {NULL,NULL,NULL,NULL,NULL} /* Sentinel */ }; diff --git a/source/blender/python/generic/quat.c b/source/blender/python/generic/quat.c index 9b5016b91d7..33d35da5175 100644 --- a/source/blender/python/generic/quat.c +++ b/source/blender/python/generic/quat.c @@ -854,7 +854,7 @@ static PyGetSetDef Quaternion_getseters[] = { {"magnitude", (getter)Quaternion_getMagnitude, (setter)NULL, "Size of the quaternion (readonly). **type** float", NULL}, {"angle", (getter)Quaternion_getAngle, (setter)NULL, "angle of the quaternion (readonly). **type** float", NULL}, {"axis",(getter)Quaternion_getAxisVec, (setter)NULL, "quaternion axis as a vector (readonly). **type** :class:`Vector`", NULL}, - {"wrapped", (getter)BaseMathObject_getWrapped, (setter)NULL, BaseMathObject_Wrapped_doc, NULL}, + {"is_wrapped", (getter)BaseMathObject_getWrapped, (setter)NULL, BaseMathObject_Wrapped_doc, NULL}, {"_owner", (getter)BaseMathObject_getOwner, (setter)NULL, BaseMathObject_Owner_doc, NULL}, {NULL,NULL,NULL,NULL,NULL} /* Sentinel */ }; diff --git a/source/blender/python/generic/vector.c b/source/blender/python/generic/vector.c index 784ea1a153f..4efd168eb87 100644 --- a/source/blender/python/generic/vector.c +++ b/source/blender/python/generic/vector.c @@ -1635,7 +1635,7 @@ static PyGetSetDef Vector_getseters[] = { {"w", (getter)Vector_getAxis, (setter)Vector_setAxis, "Vector W axis (4D Vectors only). **type** float", (void *)3}, {"length", (getter)Vector_getLength, (setter)Vector_setLength, "Vector Length. **type** float", NULL}, {"magnitude", (getter)Vector_getLength, (setter)Vector_setLength, "Vector Length. **type** float", NULL}, - {"wrapped", (getter)BaseMathObject_getWrapped, (setter)NULL, BaseMathObject_Wrapped_doc, NULL}, + {"is_wrapped", (getter)BaseMathObject_getWrapped, (setter)NULL, BaseMathObject_Wrapped_doc, NULL}, {"_owner", (getter)BaseMathObject_getOwner, (setter)NULL, BaseMathObject_Owner_doc, NULL}, /* autogenerated swizzle attrs, see python script below */ |