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>2012-07-03 00:28:43 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-07-03 00:28:43 +0400
commit2ed69a95f499081aacc15c0295f3461c38430554 (patch)
treea17a6ba86b8e05ae97de5a9a5a02312ae0153553 /source/blender/python
parent2d8a9a0cc393aabb5a3b2bc83ed063098875f799 (diff)
add bmesh/python operator support for vector and matrix args.
also rename BMO_OP_SLOT_PNT to BMO_OP_SLOT_PTR (matches RNA and sounds less like 'point')
Diffstat (limited to 'source/blender/python')
-rw-r--r--source/blender/python/bmesh/bmesh_py_ops.c47
1 files changed, 42 insertions, 5 deletions
diff --git a/source/blender/python/bmesh/bmesh_py_ops.c b/source/blender/python/bmesh/bmesh_py_ops.c
index c0ab4abb677..53ddcecd7a8 100644
--- a/source/blender/python/bmesh/bmesh_py_ops.c
+++ b/source/blender/python/bmesh/bmesh_py_ops.c
@@ -163,6 +163,7 @@ static PyObject *pyrna_op_call(BPy_BMeshOpFunc *self, PyObject *args, PyObject *
PyErr_Format(PyExc_TypeError,
"%.200s: keyword \"%.200s\" expected an int, not %.200s",
self->opname, slot_name, Py_TYPE(value)->tp_name);
+ return NULL;
}
else {
slot->data.i = (int)param;
@@ -176,12 +177,47 @@ static PyObject *pyrna_op_call(BPy_BMeshOpFunc *self, PyObject *args, PyObject *
PyErr_Format(PyExc_TypeError,
"%.200s: keyword \"%.200s\" expected a float, not %.200s",
self->opname, slot_name, Py_TYPE(value)->tp_name);
+ return NULL;
}
else {
slot->data.f = param;
}
break;
}
+ case BMO_OP_SLOT_MAT:
+ {
+ /* XXX - BMesh operator design is crappy here, operator slot should define matrix size,
+ * not the caller! */
+ unsigned short size;
+ if (!MatrixObject_Check(value)) {
+ PyErr_Format(PyExc_TypeError,
+ "%.200s: keyword \"%.200s\" expected a Matrix, not %.200s",
+ self->opname, slot_name, Py_TYPE(value)->tp_name);
+ return NULL;
+ }
+ else if (BaseMath_ReadCallback((MatrixObject *)value) == -1) {
+ return NULL;
+ }
+ else if (((size = ((MatrixObject *)value)->num_col) != ((MatrixObject *)value)->num_row) ||
+ (ELEM(size, 3, 4) == FALSE))
+ {
+ PyErr_Format(PyExc_TypeError,
+ "%.200s: keyword \"%.200s\" expected a 3x3 or 4x4 matrix Matrix",
+ self->opname, slot_name);
+ return NULL;
+ }
+
+ BMO_slot_mat_set(&bmop, slot_name, ((MatrixObject *)value)->matrix, size);
+ break;
+ }
+ case BMO_OP_SLOT_VEC:
+ {
+ /* passing slot name here is a bit non-descriptive */
+ if (mathutils_array_parse(slot->data.vec, 3, 3, value, slot_name) == -1) {
+ return NULL;
+ }
+ break;
+ }
case BMO_OP_SLOT_ELEMENT_BUF:
{
/* there are many ways we could interpret arguments, for now...
@@ -194,12 +230,12 @@ static PyObject *pyrna_op_call(BPy_BMeshOpFunc *self, PyObject *args, PyObject *
* ('VERT', {'TAG'})
*/
-#define BPY_BM_GENERIC_MESH_TEST(type_string) \
+#define BPY_BM_GENERIC_MESH_TEST(type_string) \
if (((BPy_BMGeneric *)value)->bm != bm) { \
- PyErr_Format(PyExc_NotImplementedError, \
- "%.200s: keyword \"%.200s\" " type_string " are from another bmesh", \
- self->opname, slot_name, slot->slot_type); \
- return NULL; \
+ PyErr_Format(PyExc_NotImplementedError, \
+ "%.200s: keyword \"%.200s\" " type_string " are from another bmesh", \
+ self->opname, slot_name, slot->slot_type); \
+ return NULL; \
} (void)0
if (BPy_BMVertSeq_Check(value)) {
@@ -258,6 +294,7 @@ static PyObject *pyrna_op_call(BPy_BMeshOpFunc *self, PyObject *args, PyObject *
"%.200s: keyword \"%.200s\" expected "
"a bmesh sequence, list, (htype, flag) pair, not %.200s",
self->opname, slot_name, Py_TYPE(value)->tp_name);
+ return NULL;
}
#undef BPY_BM_GENERIC_MESH_TEST