Changeset View
Changeset View
Standalone View
Standalone View
source/blender/python/gpu/gpu_py_matrix.c
| Show First 20 Lines • Show All 260 Lines • ▼ Show 20 Lines | |||||
| /** \name Manipulate State | /** \name Manipulate State | ||||
| * \{ */ | * \{ */ | ||||
| PyDoc_STRVAR(pygpu_matrix_multiply_matrix_doc, | PyDoc_STRVAR(pygpu_matrix_multiply_matrix_doc, | ||||
| ".. function:: multiply_matrix(matrix)\n" | ".. function:: multiply_matrix(matrix)\n" | ||||
| "\n" | "\n" | ||||
| " Multiply the current stack matrix.\n" | " Multiply the current stack matrix.\n" | ||||
| "\n" | "\n" | ||||
| " :param matrix: A 4x4 matrix.\n" | " :arg matrix: A 4x4 matrix.\n" | ||||
| " :type matrix: :class:`mathutils.Matrix`\n"); | " :type matrix: :class:`mathutils.Matrix`\n"); | ||||
| static PyObject *pygpu_matrix_multiply_matrix(PyObject *UNUSED(self), PyObject *value) | static PyObject *pygpu_matrix_multiply_matrix(PyObject *UNUSED(self), PyObject *value) | ||||
| { | { | ||||
| MatrixObject *pymat; | MatrixObject *pymat; | ||||
| if (!Matrix_Parse4x4(value, &pymat)) { | if (!Matrix_Parse4x4(value, &pymat)) { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| GPU_matrix_mul(pymat->matrix); | GPU_matrix_mul(pymat->matrix); | ||||
| Py_RETURN_NONE; | Py_RETURN_NONE; | ||||
| } | } | ||||
| PyDoc_STRVAR(pygpu_matrix_scale_doc, | PyDoc_STRVAR(pygpu_matrix_scale_doc, | ||||
| ".. function:: scale(scale)\n" | ".. function:: scale(scale)\n" | ||||
| "\n" | "\n" | ||||
| " Scale the current stack matrix.\n" | " Scale the current stack matrix.\n" | ||||
| "\n" | "\n" | ||||
| " :param scale: Scale the current stack matrix.\n" | " :arg scale: Scale the current stack matrix.\n" | ||||
| " :type scale: sequence of 2 or 3 floats\n"); | " :type scale: sequence of 2 or 3 floats\n"); | ||||
| static PyObject *pygpu_matrix_scale(PyObject *UNUSED(self), PyObject *value) | static PyObject *pygpu_matrix_scale(PyObject *UNUSED(self), PyObject *value) | ||||
| { | { | ||||
| float scale[3]; | float scale[3]; | ||||
| int len; | int len; | ||||
| if ((len = mathutils_array_parse( | if ((len = mathutils_array_parse( | ||||
| scale, 2, 3, value, "gpu.matrix.scale(): invalid vector arg")) == -1) { | scale, 2, 3, value, "gpu.matrix.scale(): invalid vector arg")) == -1) { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| if (len == 2) { | if (len == 2) { | ||||
| GPU_matrix_scale_2fv(scale); | GPU_matrix_scale_2fv(scale); | ||||
| } | } | ||||
| else { | else { | ||||
| GPU_matrix_scale_3fv(scale); | GPU_matrix_scale_3fv(scale); | ||||
| } | } | ||||
| Py_RETURN_NONE; | Py_RETURN_NONE; | ||||
| } | } | ||||
| PyDoc_STRVAR(pygpu_matrix_scale_uniform_doc, | PyDoc_STRVAR(pygpu_matrix_scale_uniform_doc, | ||||
| ".. function:: scale_uniform(scale)\n" | ".. function:: scale_uniform(scale)\n" | ||||
| "\n" | "\n" | ||||
| " :param scale: Scale the current stack matrix.\n" | " :arg scale: Scale the current stack matrix.\n" | ||||
| " :type scale: float\n"); | " :type scale: float\n"); | ||||
| static PyObject *pygpu_matrix_scale_uniform(PyObject *UNUSED(self), PyObject *value) | static PyObject *pygpu_matrix_scale_uniform(PyObject *UNUSED(self), PyObject *value) | ||||
| { | { | ||||
| float scalar; | float scalar; | ||||
| if ((scalar = PyFloat_AsDouble(value)) == -1.0f && PyErr_Occurred()) { | if ((scalar = PyFloat_AsDouble(value)) == -1.0f && PyErr_Occurred()) { | ||||
| PyErr_Format(PyExc_TypeError, "expected a number, not %.200s", Py_TYPE(value)->tp_name); | PyErr_Format(PyExc_TypeError, "expected a number, not %.200s", Py_TYPE(value)->tp_name); | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| GPU_matrix_scale_1f(scalar); | GPU_matrix_scale_1f(scalar); | ||||
| Py_RETURN_NONE; | Py_RETURN_NONE; | ||||
| } | } | ||||
| PyDoc_STRVAR(pygpu_matrix_translate_doc, | PyDoc_STRVAR(pygpu_matrix_translate_doc, | ||||
| ".. function:: translate(offset)\n" | ".. function:: translate(offset)\n" | ||||
| "\n" | "\n" | ||||
| " Scale the current stack matrix.\n" | " Scale the current stack matrix.\n" | ||||
| "\n" | "\n" | ||||
| " :param offset: Translate the current stack matrix.\n" | " :arg offset: Translate the current stack matrix.\n" | ||||
| " :type offset: sequence of 2 or 3 floats\n"); | " :type offset: sequence of 2 or 3 floats\n"); | ||||
| static PyObject *pygpu_matrix_translate(PyObject *UNUSED(self), PyObject *value) | static PyObject *pygpu_matrix_translate(PyObject *UNUSED(self), PyObject *value) | ||||
| { | { | ||||
| float offset[3]; | float offset[3]; | ||||
| int len; | int len; | ||||
| if ((len = mathutils_array_parse( | if ((len = mathutils_array_parse( | ||||
| offset, 2, 3, value, "gpu.matrix.translate(): invalid vector arg")) == -1) { | offset, 2, 3, value, "gpu.matrix.translate(): invalid vector arg")) == -1) { | ||||
| return NULL; | return NULL; | ||||
| Show All 33 Lines | static PyObject *pygpu_matrix_load_identity(PyObject *UNUSED(self)) | ||||
| Py_RETURN_NONE; | Py_RETURN_NONE; | ||||
| } | } | ||||
| PyDoc_STRVAR(pygpu_matrix_load_matrix_doc, | PyDoc_STRVAR(pygpu_matrix_load_matrix_doc, | ||||
| ".. function:: load_matrix(matrix)\n" | ".. function:: load_matrix(matrix)\n" | ||||
| "\n" | "\n" | ||||
| " Load a matrix into the stack.\n" | " Load a matrix into the stack.\n" | ||||
| "\n" | "\n" | ||||
| " :param matrix: A 4x4 matrix.\n" | " :arg matrix: A 4x4 matrix.\n" | ||||
| " :type matrix: :class:`mathutils.Matrix`\n"); | " :type matrix: :class:`mathutils.Matrix`\n"); | ||||
| static PyObject *pygpu_matrix_load_matrix(PyObject *UNUSED(self), PyObject *value) | static PyObject *pygpu_matrix_load_matrix(PyObject *UNUSED(self), PyObject *value) | ||||
| { | { | ||||
| MatrixObject *pymat; | MatrixObject *pymat; | ||||
| if (!Matrix_Parse4x4(value, &pymat)) { | if (!Matrix_Parse4x4(value, &pymat)) { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| GPU_matrix_set(pymat->matrix); | GPU_matrix_set(pymat->matrix); | ||||
| Py_RETURN_NONE; | Py_RETURN_NONE; | ||||
| } | } | ||||
| PyDoc_STRVAR(pygpu_matrix_load_projection_matrix_doc, | PyDoc_STRVAR(pygpu_matrix_load_projection_matrix_doc, | ||||
| ".. function:: load_projection_matrix(matrix)\n" | ".. function:: load_projection_matrix(matrix)\n" | ||||
| "\n" | "\n" | ||||
| " Load a projection matrix into the stack.\n" | " Load a projection matrix into the stack.\n" | ||||
| "\n" | "\n" | ||||
| " :param matrix: A 4x4 matrix.\n" | " :arg matrix: A 4x4 matrix.\n" | ||||
| " :type matrix: :class:`mathutils.Matrix`\n"); | " :type matrix: :class:`mathutils.Matrix`\n"); | ||||
| static PyObject *pygpu_matrix_load_projection_matrix(PyObject *UNUSED(self), PyObject *value) | static PyObject *pygpu_matrix_load_projection_matrix(PyObject *UNUSED(self), PyObject *value) | ||||
| { | { | ||||
| MatrixObject *pymat; | MatrixObject *pymat; | ||||
| if (!Matrix_Parse4x4(value, &pymat)) { | if (!Matrix_Parse4x4(value, &pymat)) { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| GPU_matrix_projection_set(pymat->matrix); | GPU_matrix_projection_set(pymat->matrix); | ||||
| ▲ Show 20 Lines • Show All 148 Lines • Show Last 20 Lines | |||||