Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2018-10-24 10:45:47 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-10-24 10:47:36 +0300
commit058936861591d16703f67e5c4b1dd8cb593630ed (patch)
tree02214145247c843d3777f285efe92652dcd549bd /source/blender/python/gpu
parentc8ab88fb89146a6bdc2a8825b9a8e2454aeb1ced (diff)
GPUShader: shader.uniform_float, matrix parsing
Add checks to parse 3x3 or 4x4 matrices, also use error from `mathutils_array_parse` instead of overwriting.
Diffstat (limited to 'source/blender/python/gpu')
-rw-r--r--source/blender/python/gpu/gpu_py_shader.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/source/blender/python/gpu/gpu_py_shader.c b/source/blender/python/gpu/gpu_py_shader.c
index 83ed8ce7362..f62e9b775b1 100644
--- a/source/blender/python/gpu/gpu_py_shader.c
+++ b/source/blender/python/gpu/gpu_py_shader.c
@@ -450,8 +450,24 @@ static PyObject *bpygpu_shader_uniform_float(
values[0] = (float)PyLong_AsDouble(params.seq);
length = 1;
}
+ else if (MatrixObject_Check(params.seq)) {
+ MatrixObject *mat = (MatrixObject *)params.seq;
+ if (BaseMath_ReadCallback(mat) == -1) {
+ return NULL;
+ }
+ if ((mat->num_row != mat->num_col) || !ELEM(mat->num_row, 3, 4)) {
+ PyErr_SetString(PyExc_ValueError,
+ "Expected 3x3 or 4x4 matrix");
+ return NULL;
+ }
+ length = mat->num_row * mat->num_col;
+ memcpy(values, mat->matrix, sizeof(float) * length);
+ }
else {
length = mathutils_array_parse(values, 2, 16, params.seq, "");
+ if (length == -1) {
+ return NULL;
+ }
}
if (!ELEM(length, 1, 2, 3, 4, 9, 16)) {