diff options
author | Lukas Tönne <lukas.toenne@gmail.com> | 2017-10-16 12:16:13 +0300 |
---|---|---|
committer | Lukas Tönne <lukas.toenne@gmail.com> | 2017-10-16 12:22:35 +0300 |
commit | a78b3ee53aa53020b086a6df25c0e28491223dcc (patch) | |
tree | bd883e95580f5777f7eae7cac4e47f182ac9fc00 /source/blender/python/mathutils/mathutils_Matrix.c | |
parent | 4842cc017c3bb7df2070c2f96605190ff88e6a2e (diff) | |
parent | 49f4ac17bf704614de59a4db7a65c205c085d694 (diff) |
Merge remote-tracking branch 'origin/master' into openvdbopenvdb
Diffstat (limited to 'source/blender/python/mathutils/mathutils_Matrix.c')
-rw-r--r-- | source/blender/python/mathutils/mathutils_Matrix.c | 97 |
1 files changed, 82 insertions, 15 deletions
diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c index 4e980e4c0e6..2578b19d5ec 100644 --- a/source/blender/python/mathutils/mathutils_Matrix.c +++ b/source/blender/python/mathutils/mathutils_Matrix.c @@ -1301,7 +1301,7 @@ PyDoc_STRVAR(Matrix_to_scale_doc, " :return: Return the scale of a matrix.\n" " :rtype: :class:`Vector`\n" "\n" -" .. note:: This method does not return negative a scale on any axis because it is not possible to obtain this data from the matrix alone.\n" +" .. note:: This method does not return a negative scale on any axis because it is not possible to obtain this data from the matrix alone.\n" ); static PyObject *Matrix_to_scale(MatrixObject *self) { @@ -1390,11 +1390,11 @@ PyDoc_STRVAR(Matrix_invert_doc, "\n" " Set the matrix to its inverse.\n" "\n" -" :arg fallback: Set the matrix to this value when the inverse can't be calculated\n" +" :arg fallback: Set the matrix to this value when the inverse cannot be calculated\n" " (instead of raising a :exc:`ValueError` exception).\n" " :type fallback: :class:`Matrix`\n" "\n" -" .. seealso:: <https://en.wikipedia.org/wiki/Inverse_matrix>\n" +" .. seealso:: `Inverse matrix <https://en.wikipedia.org/wiki/Inverse_matrix>` on Wikipedia.\n" ); static PyObject *Matrix_invert(MatrixObject *self, PyObject *args) { @@ -1505,7 +1505,7 @@ PyDoc_STRVAR(Matrix_invert_safe_doc, " If degenerated (e.g. zero scale on an axis), add some epsilon to its diagonal, to get an invertible one.\n" " If tweaked matrix is still degenerated, set to the identity matrix instead.\n" "\n" -" .. seealso:: <https://en.wikipedia.org/wiki/Inverse_matrix>\n" +" .. seealso:: `Inverse Matrix <https://en.wikipedia.org/wiki/Inverse_matrix>` on Wikipedia.\n" ); static PyObject *Matrix_invert_safe(MatrixObject *self) { @@ -1554,9 +1554,9 @@ PyDoc_STRVAR(Matrix_adjugate_doc, "\n" " Set the matrix to its adjugate.\n" "\n" -" .. note:: When the matrix cant be adjugated a :exc:`ValueError` exception is raised.\n" +" .. note:: When the matrix cannot be adjugated a :exc:`ValueError` exception is raised.\n" "\n" -" .. seealso:: <https://en.wikipedia.org/wiki/Adjugate_matrix>\n" +" .. seealso:: `Adjugate matrix <https://en.wikipedia.org/wiki/Adjugate_matrix>` on Wikipedia.\n" ); static PyObject *Matrix_adjugate(MatrixObject *self) { @@ -1641,9 +1641,9 @@ static PyObject *Matrix_rotate(MatrixObject *self, PyObject *value) PyDoc_STRVAR(Matrix_decompose_doc, ".. method:: decompose()\n" "\n" -" Return the location, rotation and scale components of this matrix.\n" +" Return the translation, rotation and scale components of this matrix.\n" "\n" -" :return: loc, rot, scale triple.\n" +" :return: trans, rot, scale triple.\n" " :rtype: (:class:`Vector`, :class:`Quaternion`, :class:`Vector`)" ); static PyObject *Matrix_decompose(MatrixObject *self) @@ -1709,10 +1709,10 @@ static PyObject *Matrix_lerp(MatrixObject *self, PyObject *args) /* TODO, different sized matrix */ if (self->num_col == 4 && self->num_row == 4) { - blend_m4_m4m4((float (*)[4])mat, (float (*)[4])self->matrix, (float (*)[4])mat2->matrix, fac); + interp_m4_m4m4((float (*)[4])mat, (float (*)[4])self->matrix, (float (*)[4])mat2->matrix, fac); } else if (self->num_col == 3 && self->num_row == 3) { - blend_m3_m3m3((float (*)[3])mat, (float (*)[3])self->matrix, (float (*)[3])mat2->matrix, fac); + interp_m3_m3m3((float (*)[3])mat, (float (*)[3])self->matrix, (float (*)[3])mat2->matrix, fac); } else { PyErr_SetString(PyExc_ValueError, @@ -1733,7 +1733,7 @@ PyDoc_STRVAR(Matrix_determinant_doc, " :return: Return the determinant of a matrix.\n" " :rtype: float\n" "\n" -" .. seealso:: <https://en.wikipedia.org/wiki/Determinant>\n" +" .. seealso:: `Determinant <https://en.wikipedia.org/wiki/Determinant>` on Wikipedia.\n" ); static PyObject *Matrix_determinant(MatrixObject *self) { @@ -1755,7 +1755,7 @@ PyDoc_STRVAR(Matrix_transpose_doc, "\n" " Set the matrix to its transpose.\n" "\n" -" .. seealso:: <https://en.wikipedia.org/wiki/Transpose>\n" +" .. seealso:: `Transpose <https://en.wikipedia.org/wiki/Transpose>` on Wikipedia.\n" ); static PyObject *Matrix_transpose(MatrixObject *self) { @@ -1887,10 +1887,10 @@ PyDoc_STRVAR(Matrix_identity_doc, "\n" " Set the matrix to the identity matrix.\n" "\n" -" .. note:: An object with zero location and rotation, a scale of one,\n" +" .. note:: An object with a location and rotation of zero, and a scale of one\n" " will have an identity matrix.\n" "\n" -" .. seealso:: <https://en.wikipedia.org/wiki/Identity_matrix>\n" +" .. seealso:: `Identity matrix <https://en.wikipedia.org/wiki/Identity_matrix>` on Wikipedia.\n" ); static PyObject *Matrix_identity(MatrixObject *self) { @@ -2034,7 +2034,7 @@ static PyObject *Matrix_richcmpr(PyObject *a, PyObject *b, int op) switch (op) { case Py_NE: ok = !ok; - /* fall-through */ + ATTR_FALLTHROUGH; case Py_EQ: res = ok ? Py_False : Py_True; break; @@ -2914,6 +2914,73 @@ PyObject *Matrix_CreatePyObject_cb(PyObject *cb_user, return (PyObject *) self; } +/** + * Use with PyArg_ParseTuple's "O&" formatting. + */ +static bool Matrix_ParseCheck(MatrixObject *pymat) +{ + if (!MatrixObject_Check(pymat)) { + PyErr_Format(PyExc_TypeError, + "expected a mathutils.Matrix, not a %.200s", + Py_TYPE(pymat)->tp_name); + return 0; + } + /* sets error */ + if (BaseMath_ReadCallback(pymat) == -1) { + return 0; + } + return 1; +} + +int Matrix_ParseAny(PyObject *o, void *p) +{ + MatrixObject **pymat_p = p; + MatrixObject *pymat = (MatrixObject *)o; + + if (!Matrix_ParseCheck(pymat)) { + return 0; + } + *pymat_p = pymat; + return 1; +} + +int Matrix_Parse3x3(PyObject *o, void *p) +{ + MatrixObject **pymat_p = p; + MatrixObject *pymat = (MatrixObject *)o; + + if (!Matrix_ParseCheck(pymat)) { + return 0; + } + if ((pymat->num_col != 3) || + (pymat->num_row != 3)) + { + PyErr_SetString(PyExc_ValueError, "matrix must be 3x3"); + return 0; + } + + *pymat_p = pymat; + return 1; +} + +int Matrix_Parse4x4(PyObject *o, void *p) +{ + MatrixObject **pymat_p = p; + MatrixObject *pymat = (MatrixObject *)o; + + if (!Matrix_ParseCheck(pymat)) { + return 0; + } + if ((pymat->num_col != 4) || + (pymat->num_row != 4)) + { + PyErr_SetString(PyExc_ValueError, "matrix must be 4x4"); + return 0; + } + + *pymat_p = pymat; + return 1; +} /* ---------------------------------------------------------------------------- * special type for alternate access */ |