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-04-22 14:19:24 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-04-22 14:19:24 +0400
commit49ff0eeec443ebe5003ec09bc655d73abc69a327 (patch)
treeaca038d71936860a7a358f7a1fe8867b8d5f4b75 /source/blender/python/mathutils
parentd5023f0e91d578afa8f7d606edec19f0d8b1d9f9 (diff)
bmesh py api: expose BM_face_split_n() to the python api;
face_fill(..., coords=(v1, v2, ...)) This is the same function the knife tool uses. should be handy for dicing up geometry in py.
Diffstat (limited to 'source/blender/python/mathutils')
-rw-r--r--source/blender/python/mathutils/mathutils.c35
-rw-r--r--source/blender/python/mathutils/mathutils.h1
2 files changed, 36 insertions, 0 deletions
diff --git a/source/blender/python/mathutils/mathutils.c b/source/blender/python/mathutils/mathutils.c
index f78050a7639..8b79301f264 100644
--- a/source/blender/python/mathutils/mathutils.c
+++ b/source/blender/python/mathutils/mathutils.c
@@ -186,6 +186,41 @@ int mathutils_array_parse_alloc(float **array, int array_min, PyObject *value, c
}
}
+/* parse an array of vectors */
+int mathutils_array_parse_alloc_v(float **array, int array_dim, PyObject *value, const char *error_prefix)
+{
+ PyObject *value_fast = NULL;
+ int i, size;
+
+ /* non list/tuple cases */
+ if (!(value_fast = PySequence_Fast(value, error_prefix))) {
+ /* PySequence_Fast sets the error */
+ return -1;
+ }
+
+ size = PySequence_Fast_GET_SIZE(value_fast);
+
+ if (size != 0) {
+ float *fp;
+
+ fp = *array = PyMem_Malloc(size * array_dim * sizeof(float));
+
+ for (i = 0; i < size; i++, fp += array_dim) {
+ PyObject *item = PySequence_Fast_GET_ITEM(value, i);
+
+ if (mathutils_array_parse(fp, array_dim, array_dim, item, error_prefix) == -1) {
+ PyMem_Free(*array);
+ *array = NULL;
+ size = -1;
+ break;
+ }
+ }
+ }
+
+ Py_DECREF(value_fast);
+ return size;
+}
+
int mathutils_any_to_rotmat(float rmat[3][3], PyObject *value, const char *error_prefix)
{
if (EulerObject_Check(value)) {
diff --git a/source/blender/python/mathutils/mathutils.h b/source/blender/python/mathutils/mathutils.h
index b98928eb79d..e8d128b431e 100644
--- a/source/blender/python/mathutils/mathutils.h
+++ b/source/blender/python/mathutils/mathutils.h
@@ -118,6 +118,7 @@ int _BaseMathObject_WriteIndexCallback(BaseMathObject *self, int index);
/* utility func */
int mathutils_array_parse(float *array, int array_min, int array_max, PyObject *value, const char *error_prefix);
int mathutils_array_parse_alloc(float **array, int array_min, PyObject *value, const char *error_prefix);
+int mathutils_array_parse_alloc_v(float **array, int array_dim, PyObject *value, const char *error_prefix);
int mathutils_any_to_rotmat(float rmat[3][3], PyObject *value, const char *error_prefix);
int column_vector_multiplication(float rvec[4], VectorObject *vec, MatrixObject *mat);