Merged changes in the trunk up to revision 46045.
Conflicts resolved: doc/python_api/sphinx_doc_gen.py source/blender/blenkernel/intern/subsurf_ccg.c source/blender/editors/mesh/editmesh_tools.c source/blender/makesdna/DNA_scene_types.h
This commit is contained in:
@@ -10,7 +10,7 @@ incs += ' ../freestyle/intern/python'
|
||||
incs += ' #intern/guardedalloc #intern/memutil #extern/glew/include #intern/cycles/blender'
|
||||
incs += ' #intern/audaspace/intern ' + env['BF_PYTHON_INC']
|
||||
|
||||
is_debug = (env['OURPLATFORM'] in ('win32-mingw', 'win32-vc','win64-vc') and env['BF_DEBUG'])
|
||||
is_debug = (env['OURPLATFORM'] in ('win32-mingw', 'win32-vc','win64-vc', 'win64-mingw') and env['BF_DEBUG'])
|
||||
|
||||
# bmesh
|
||||
defs = []
|
||||
@@ -57,7 +57,7 @@ if env['WITH_BF_FFMPEG']:
|
||||
defs.append('WITH_FFMPEG')
|
||||
incs += ' ' + env['BF_FFMPEG_INC']
|
||||
|
||||
if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc'):
|
||||
if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'win64-mingw', 'linuxcross', 'win64-vc'):
|
||||
incs += ' ' + env['BF_PTHREADS_INC']
|
||||
|
||||
sources = env.Glob('intern/*.c')
|
||||
|
||||
@@ -99,6 +99,7 @@ PyDoc_STRVAR(bpy_bm_elem_select_doc, "Selected state of this element.\n\n:type:
|
||||
PyDoc_STRVAR(bpy_bm_elem_hide_doc, "Hidden state of this element.\n\n:type: boolean");
|
||||
PyDoc_STRVAR(bpy_bm_elem_tag_doc, "Generic attribute scripts can use for own logic\n\n:type: boolean");
|
||||
PyDoc_STRVAR(bpy_bm_elem_smooth_doc, "Smooth state of this element.\n\n:type: boolean");
|
||||
PyDoc_STRVAR(bpy_bm_elem_seam_doc, "Seam for UV unwrapping.\n\n:type: boolean");
|
||||
|
||||
|
||||
static PyObject *bpy_bm_elem_hflag_get(BPy_BMElem *self, void *flag)
|
||||
@@ -601,7 +602,7 @@ static PyGetSetDef bpy_bmedge_getseters[] = {
|
||||
{(char *)"index", (getter)bpy_bm_elem_index_get, (setter)bpy_bm_elem_index_set, (char *)bpy_bm_elem_index_doc, NULL},
|
||||
|
||||
{(char *)"smooth", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_smooth_doc, (void *)BM_ELEM_SMOOTH},
|
||||
{(char *)"seam", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_smooth_doc, (void *)BM_ELEM_SEAM},
|
||||
{(char *)"seam", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_seam_doc, (void *)BM_ELEM_SEAM},
|
||||
|
||||
/* connectivity data */
|
||||
{(char *)"verts", (getter)bpy_bmelemseq_elem_get, (setter)NULL, (char *)bpy_bmedge_verts_doc, (void *)BM_VERTS_OF_EDGE},
|
||||
@@ -1197,7 +1198,7 @@ PyDoc_STRVAR(bpy_bmvert_calc_edge_angle_doc,
|
||||
static PyObject *bpy_bmvert_calc_edge_angle(BPy_BMVert *self)
|
||||
{
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
return PyFloat_FromDouble(BM_vert_edge_angle(self->v));
|
||||
return PyFloat_FromDouble(BM_vert_calc_edge_angle(self->v));
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_bmvert_calc_shell_factor_doc,
|
||||
@@ -1213,7 +1214,7 @@ PyDoc_STRVAR(bpy_bmvert_calc_shell_factor_doc,
|
||||
static PyObject *bpy_bmvert_calc_shell_factor(BPy_BMVert *self)
|
||||
{
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
return PyFloat_FromDouble(BM_vert_shell_factor(self->v));
|
||||
return PyFloat_FromDouble(BM_vert_calc_shell_factor(self->v));
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_bmvert_normal_update_doc,
|
||||
@@ -1255,7 +1256,7 @@ PyDoc_STRVAR(bpy_bmedge_calc_face_angle_doc,
|
||||
static PyObject *bpy_bmedge_calc_face_angle(BPy_BMEdge *self)
|
||||
{
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
return PyFloat_FromDouble(BM_edge_face_angle(self->e));
|
||||
return PyFloat_FromDouble(BM_edge_calc_face_angle(self->e));
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_bmedge_calc_tangent_doc,
|
||||
@@ -1283,7 +1284,7 @@ static PyObject *bpy_bmedge_calc_tangent(BPy_BMEdge *self, PyObject *args)
|
||||
float vec[3];
|
||||
BPY_BM_CHECK_OBJ(py_loop);
|
||||
/* no need to check if they are from the same mesh or even connected */
|
||||
BM_edge_face_tangent(self->e, py_loop->l, vec);
|
||||
BM_edge_calc_face_tangent(self->e, py_loop->l, vec);
|
||||
return Vector_CreatePyObject(vec, 3, Py_NEW, NULL);
|
||||
}
|
||||
}
|
||||
@@ -1441,7 +1442,7 @@ PyDoc_STRVAR(bpy_bmface_calc_area_doc,
|
||||
static PyObject *bpy_bmface_calc_area(BPy_BMFace *self)
|
||||
{
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
return PyFloat_FromDouble(BM_face_area_calc(self->f));
|
||||
return PyFloat_FromDouble(BM_face_calc_area(self->f));
|
||||
}
|
||||
|
||||
|
||||
@@ -1456,7 +1457,7 @@ PyDoc_STRVAR(bpy_bmface_calc_perimeter_doc,
|
||||
static PyObject *bpy_bmface_calc_perimeter(BPy_BMFace *self)
|
||||
{
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
return PyFloat_FromDouble(BM_face_perimeter_calc(self->f));
|
||||
return PyFloat_FromDouble(BM_face_calc_perimeter(self->f));
|
||||
}
|
||||
|
||||
|
||||
@@ -1473,7 +1474,7 @@ static PyObject *bpy_bmface_calc_center_mean(BPy_BMFace *self)
|
||||
float cent[3];
|
||||
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
BM_face_center_mean_calc(self->f, cent);
|
||||
BM_face_calc_center_mean(self->f, cent);
|
||||
return Vector_CreatePyObject(cent, 3, Py_NEW, NULL);
|
||||
}
|
||||
|
||||
@@ -1491,7 +1492,7 @@ static PyObject *bpy_bmface_calc_center_bounds(BPy_BMFace *self)
|
||||
float cent[3];
|
||||
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
BM_face_center_bounds_calc(self->f, cent);
|
||||
BM_face_calc_center_bounds(self->f, cent);
|
||||
return Vector_CreatePyObject(cent, 3, Py_NEW, NULL);
|
||||
}
|
||||
|
||||
@@ -1570,7 +1571,7 @@ PyDoc_STRVAR(bpy_bmloop_calc_angle_doc,
|
||||
static PyObject *bpy_bmloop_calc_angle(BPy_BMLoop *self)
|
||||
{
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
return PyFloat_FromDouble(BM_loop_face_angle(self->l));
|
||||
return PyFloat_FromDouble(BM_loop_calc_face_angle(self->l));
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_bmloop_calc_normal_doc,
|
||||
@@ -1586,7 +1587,7 @@ static PyObject *bpy_bmloop_calc_normal(BPy_BMLoop *self)
|
||||
{
|
||||
float vec[3];
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
BM_loop_face_normal(self->l, vec);
|
||||
BM_loop_calc_face_normal(self->l, vec);
|
||||
return Vector_CreatePyObject(vec, 3, Py_NEW, NULL);
|
||||
}
|
||||
|
||||
@@ -1603,7 +1604,7 @@ static PyObject *bpy_bmloop_calc_tangent(BPy_BMLoop *self)
|
||||
{
|
||||
float vec[3];
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
BM_loop_face_tangent(self->l, vec);
|
||||
BM_loop_calc_face_tangent(self->l, vec);
|
||||
return Vector_CreatePyObject(vec, 3, Py_NEW, NULL);
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,15 @@ static CustomData *bpy_bm_customdata_get(BMesh *bm, char htype)
|
||||
static CustomDataLayer *bpy_bmlayeritem_get(BPy_BMLayerItem *self)
|
||||
{
|
||||
CustomData *data = bpy_bm_customdata_get(self->bm, self->htype);
|
||||
return &data->layers[CustomData_get_layer_index_n(data, self->type, self->index)];
|
||||
const int index_absolute = CustomData_get_layer_index_n(data, self->type, self->index);
|
||||
if (index_absolute != -1) {
|
||||
return &data->layers[index_absolute];
|
||||
}
|
||||
else {
|
||||
PyErr_SetString(PyExc_RuntimeError,
|
||||
"layer has become invalid");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* py-type definitions
|
||||
@@ -126,9 +134,10 @@ static PyObject *bpy_bmlayercollection_active_get(BPy_BMLayerItem *self, void *U
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
|
||||
data = bpy_bm_customdata_get(self->bm, self->htype);
|
||||
index = CustomData_get_active_layer_index(data, self->type);
|
||||
index = CustomData_get_active_layer_index(data, self->type); /* absolute */
|
||||
|
||||
if (index != -1) {
|
||||
index -= CustomData_get_layer_index(data, self->type); /* make relative */
|
||||
return BPy_BMLayerItem_CreatePyObject(self->bm, self->htype, self->type, index);
|
||||
}
|
||||
else {
|
||||
@@ -146,7 +155,12 @@ static PyObject *bpy_bmlayeritem_name_get(BPy_BMLayerItem *self, void *UNUSED(fl
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
|
||||
layer = bpy_bmlayeritem_get(self);
|
||||
return PyUnicode_FromString(layer->name);
|
||||
if (layer) {
|
||||
return PyUnicode_FromString(layer->name);
|
||||
}
|
||||
else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static PyGetSetDef bpy_bmlayeraccess_vert_getseters[] = {
|
||||
@@ -216,6 +230,82 @@ static PyGetSetDef bpy_bmlayeritem_getseters[] = {
|
||||
/* BMLayerCollection
|
||||
* ----------------- */
|
||||
|
||||
|
||||
PyDoc_STRVAR(bpy_bmlayercollection_new_doc,
|
||||
".. method:: new(name)\n"
|
||||
"\n"
|
||||
" Create a new layer\n"
|
||||
"\n"
|
||||
" :arg name: Optional name argument (will be made unique).\n"
|
||||
" :type name: string\n"
|
||||
" :return: The newly created layer.\n"
|
||||
" :rtype: :class:`BMLayerItem`\n"
|
||||
);
|
||||
static PyObject *bpy_bmlayercollection_new(BPy_BMLayerCollection *self, PyObject *args)
|
||||
{
|
||||
const char *name = NULL;
|
||||
int index;
|
||||
CustomData *data;
|
||||
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
|
||||
if (!PyArg_ParseTuple(args, "|s:new", &name)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data = bpy_bm_customdata_get(self->bm, self->htype);
|
||||
|
||||
if (name) {
|
||||
BM_data_layer_add_named(self->bm, data, self->type, name);
|
||||
}
|
||||
else {
|
||||
BM_data_layer_add(self->bm, data, self->type);
|
||||
}
|
||||
|
||||
index = CustomData_number_of_layers(data, self->type) - 1;
|
||||
BLI_assert(index >= 0);
|
||||
|
||||
return BPy_BMLayerItem_CreatePyObject(self->bm, self->htype, self->type, index);
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_bmlayercollection_remove_doc,
|
||||
".. method:: remove(layer)\n"
|
||||
"\n"
|
||||
" Remove a layer\n"
|
||||
"\n"
|
||||
" :arg layer: The layer to remove.\n"
|
||||
" :type layer: :class:`BMLayerItem`\n"
|
||||
);
|
||||
static PyObject *bpy_bmlayercollection_remove(BPy_BMLayerCollection *self, BPy_BMLayerItem *value)
|
||||
{
|
||||
CustomData *data;
|
||||
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
|
||||
if (!BPy_BMLayerItem_Check(value)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"layers.remove(x): expected BMLayerItem, not '%.200s'",
|
||||
Py_TYPE(value)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
BPY_BM_CHECK_OBJ(value);
|
||||
|
||||
if ((self->bm != value->bm) ||
|
||||
(self->type != value->type) ||
|
||||
(self->htype != value->htype))
|
||||
{
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"layers.remove(x): x not in layers");
|
||||
}
|
||||
|
||||
data = bpy_bm_customdata_get(self->bm, self->htype);
|
||||
BM_data_layer_free_n(self->bm, data, self->type, value->index);
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
|
||||
PyDoc_STRVAR(bpy_bmlayercollection_keys_doc,
|
||||
".. method:: keys()\n"
|
||||
"\n"
|
||||
@@ -235,7 +325,7 @@ static PyObject *bpy_bmlayercollection_keys(BPy_BMLayerCollection *self)
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
|
||||
data = bpy_bm_customdata_get(self->bm, self->htype);
|
||||
index = CustomData_get_layer_index(data, self->type);
|
||||
index = CustomData_get_layer_index(data, self->type); /* absolute, but no need to make relative */
|
||||
|
||||
ret = PyList_New(0);
|
||||
|
||||
@@ -350,9 +440,10 @@ static PyObject *bpy_bmlayercollection_get(BPy_BMLayerCollection *self, PyObject
|
||||
int index;
|
||||
|
||||
data = bpy_bm_customdata_get(self->bm, self->htype);
|
||||
index = CustomData_get_named_layer_index(data, self->type, key);
|
||||
index = CustomData_get_named_layer_index(data, self->type, key); /* absolute index */
|
||||
|
||||
if (index != -1) {
|
||||
index -= CustomData_get_layer_index(data, self->type); /* make relative */
|
||||
return BPy_BMLayerItem_CreatePyObject(self->bm, self->htype, self->type, index);
|
||||
}
|
||||
}
|
||||
@@ -361,17 +452,13 @@ static PyObject *bpy_bmlayercollection_get(BPy_BMLayerCollection *self, PyObject
|
||||
}
|
||||
|
||||
static struct PyMethodDef bpy_bmelemseq_methods[] = {
|
||||
{"new", (PyCFunction)bpy_bmlayercollection_new, METH_VARARGS, bpy_bmlayercollection_new_doc},
|
||||
{"remove", (PyCFunction)bpy_bmlayercollection_remove, METH_O, bpy_bmlayercollection_remove_doc},
|
||||
|
||||
{"keys", (PyCFunction)bpy_bmlayercollection_keys, METH_NOARGS, bpy_bmlayercollection_keys_doc},
|
||||
{"values", (PyCFunction)bpy_bmlayercollection_values, METH_NOARGS, bpy_bmlayercollection_values_doc},
|
||||
{"items", (PyCFunction)bpy_bmlayercollection_items, METH_NOARGS, bpy_bmlayercollection_items_doc},
|
||||
{"get", (PyCFunction)bpy_bmlayercollection_get, METH_VARARGS, bpy_bmlayercollection_get_doc},
|
||||
|
||||
/* for later! */
|
||||
#if 0
|
||||
|
||||
{"new", (PyCFunction)bpy_bmlayercollection_new, METH_O, bpy_bmlayercollection_new_doc},
|
||||
{"remove", (PyCFunction)bpy_bmlayercollection_new, METH_O, bpy_bmlayercollection_remove_doc},
|
||||
#endif
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
@@ -399,9 +486,10 @@ static PyObject *bpy_bmlayercollection_subscript_str(BPy_BMLayerCollection *self
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
|
||||
data = bpy_bm_customdata_get(self->bm, self->htype);
|
||||
index = CustomData_get_named_layer_index(data, self->type, keyname);
|
||||
index = CustomData_get_named_layer_index(data, self->type, keyname); /* absolute */
|
||||
|
||||
if (index != -1) {
|
||||
index -= CustomData_get_layer_index(data, self->type); /* make relative */
|
||||
return BPy_BMLayerItem_CreatePyObject(self->bm, self->htype, self->type, index);
|
||||
}
|
||||
else {
|
||||
@@ -439,8 +527,8 @@ static PyObject *bpy_bmlayercollection_subscript_slice(BPy_BMLayerCollection *se
|
||||
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
|
||||
if (start >= start) start = len - 1;
|
||||
if (stop >= stop) stop = len - 1;
|
||||
if (start >= len) start = len - 1;
|
||||
if (stop >= len) stop = len - 1;
|
||||
|
||||
tuple = PyTuple_New(stop - start);
|
||||
|
||||
|
||||
@@ -36,6 +36,8 @@
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "../mathutils/mathutils.h"
|
||||
|
||||
#include "bmesh.h"
|
||||
|
||||
#include "bmesh_py_types.h"
|
||||
@@ -366,7 +368,7 @@ static PyObject *bpy_bm_utils_edge_rotate(PyObject *UNUSED(self), PyObject *args
|
||||
|
||||
|
||||
PyDoc_STRVAR(bpy_bm_utils_face_split_doc,
|
||||
".. method:: face_split(face, vert, vert_a, vert_b, edge_example)\n"
|
||||
".. method:: face_split(face, vert_a, vert_b, coords=(), use_exist=True, example=None)\n"
|
||||
"\n"
|
||||
" Split an edge, return the newly created data.\n"
|
||||
"\n"
|
||||
@@ -376,25 +378,43 @@ PyDoc_STRVAR(bpy_bm_utils_face_split_doc,
|
||||
" :type vert_a: :class:`bmesh.types.BMVert`\n"
|
||||
" :arg vert_b: Second vertex to cut in the face (face must contain the vert).\n"
|
||||
" :type vert_b: :class:`bmesh.types.BMVert`\n"
|
||||
" :arg edge_example: Optional edge argument, newly created edge will copy settings from this one.\n"
|
||||
" :type edge_example: :class:`bmesh.types.BMEdge`\n"
|
||||
" :arg coords: Optional argument to define points inbetween *vert_a* and *vert_b*.\n"
|
||||
" :type coords: sequence of float triplets\n"
|
||||
" :arg use_exist: .Use an existing edge if it exists (Only used when *coords* argument is empty or omitted)\n"
|
||||
" :type use_exist: boolean\n"
|
||||
" :arg example: Newly created edge will copy settings from this one.\n"
|
||||
" :type example: :class:`bmesh.types.BMEdge`\n"
|
||||
" :return: The newly created face or None on failure.\n"
|
||||
" :rtype: (:class:`bmesh.types.BMFace`, :class:`bmesh.types.BMLoop`) pair\n"
|
||||
);
|
||||
static PyObject *bpy_bm_utils_face_split(PyObject *UNUSED(self), PyObject *args)
|
||||
static PyObject *bpy_bm_utils_face_split(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
|
||||
{
|
||||
static const char *kwlist[] = {"face", "vert_a", "vert_b",
|
||||
"coords", "use_exist", "example", NULL};
|
||||
|
||||
BPy_BMFace *py_face;
|
||||
BPy_BMVert *py_vert_a;
|
||||
BPy_BMVert *py_vert_b;
|
||||
BPy_BMEdge *py_edge_example = NULL; /* optional */
|
||||
|
||||
/* optional */
|
||||
PyObject *py_coords = NULL;
|
||||
int edge_exists = TRUE;
|
||||
BPy_BMEdge *py_edge_example = NULL;
|
||||
|
||||
float *coords;
|
||||
int ncoords = 0;
|
||||
|
||||
BMesh *bm;
|
||||
BMFace *f_new = NULL;
|
||||
BMLoop *l_new = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O!O!O!|O!:face_split",
|
||||
&BPy_BMFace_Type, &py_face,
|
||||
&BPy_BMVert_Type, &py_vert_a,
|
||||
&BPy_BMVert_Type, &py_vert_b,
|
||||
&BPy_BMEdge_Type, &py_edge_example))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kw, "O!O!O!|OiO!:face_split", (char **)kwlist,
|
||||
&BPy_BMFace_Type, &py_face,
|
||||
&BPy_BMVert_Type, &py_vert_a,
|
||||
&BPy_BMVert_Type, &py_vert_b,
|
||||
&py_coords,
|
||||
&edge_exists,
|
||||
&BPy_BMEdge_Type, &py_edge_example))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@@ -422,11 +442,27 @@ static PyObject *bpy_bm_utils_face_split(PyObject *UNUSED(self), PyObject *args)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (py_coords) {
|
||||
ncoords = mathutils_array_parse_alloc_v(&coords, 3, py_coords, "face_split(...): ");
|
||||
if (ncoords == -1) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* --- main function body --- */
|
||||
bm = py_face->bm;
|
||||
|
||||
f_new = BM_face_split(bm, py_face->f,
|
||||
py_vert_a->v, py_vert_b->v,
|
||||
&l_new, py_edge_example ? py_edge_example->e : NULL, FALSE); /* BMESH_TODO, make arg */
|
||||
if (ncoords) {
|
||||
f_new = BM_face_split_n(bm, py_face->f,
|
||||
py_vert_a->v, py_vert_b->v,
|
||||
(float (*)[3])coords, ncoords,
|
||||
&l_new, py_edge_example ? py_edge_example->e : NULL);
|
||||
}
|
||||
else {
|
||||
f_new = BM_face_split(bm, py_face->f,
|
||||
py_vert_a->v, py_vert_b->v,
|
||||
&l_new, py_edge_example ? py_edge_example->e : NULL, edge_exists);
|
||||
}
|
||||
|
||||
if (f_new && l_new) {
|
||||
PyObject *ret = PyTuple_New(2);
|
||||
@@ -622,7 +658,7 @@ static struct PyMethodDef BPy_BM_utils_methods[] = {
|
||||
{"vert_separate", (PyCFunction)bpy_bm_utils_vert_separate, METH_VARARGS, bpy_bm_utils_vert_separate_doc},
|
||||
{"edge_split", (PyCFunction)bpy_bm_utils_edge_split, METH_VARARGS, bpy_bm_utils_edge_split_doc},
|
||||
{"edge_rotate", (PyCFunction)bpy_bm_utils_edge_rotate, METH_VARARGS, bpy_bm_utils_edge_rotate_doc},
|
||||
{"face_split", (PyCFunction)bpy_bm_utils_face_split, METH_VARARGS, bpy_bm_utils_face_split_doc},
|
||||
{"face_split", (PyCFunction)bpy_bm_utils_face_split, METH_VARARGS | METH_KEYWORDS, bpy_bm_utils_face_split_doc},
|
||||
{"face_join", (PyCFunction)bpy_bm_utils_face_join, METH_VARARGS, bpy_bm_utils_face_join_doc},
|
||||
{"face_vert_separate", (PyCFunction)bpy_bm_utils_face_vert_separate, METH_VARARGS, bpy_bm_utils_face_vert_separate_doc},
|
||||
{"face_flip", (PyCFunction)bpy_bm_utils_face_flip, METH_O, bpy_bm_utils_face_flip_doc},
|
||||
|
||||
@@ -197,7 +197,7 @@ static PyObject *bpy_resource_path(PyObject *UNUSED(self), PyObject *args, PyObj
|
||||
return NULL;
|
||||
|
||||
/* stupid string compare */
|
||||
if (!strcmp(type, "USER")) folder_id = BLENDER_RESOURCE_PATH_USER;
|
||||
if (!strcmp(type, "USER")) folder_id = BLENDER_RESOURCE_PATH_USER;
|
||||
else if (!strcmp(type, "LOCAL")) folder_id = BLENDER_RESOURCE_PATH_LOCAL;
|
||||
else if (!strcmp(type, "SYSTEM")) folder_id = BLENDER_RESOURCE_PATH_SYSTEM;
|
||||
else {
|
||||
|
||||
@@ -99,9 +99,9 @@ static double bpy_timer_run_tot; /* accumulate python runs */
|
||||
void bpy_context_update(bContext *C)
|
||||
{
|
||||
/* don't do this from a non-main (e.g. render) thread, it can cause a race
|
||||
condition on C->data.recursion. ideal solution would be to disable
|
||||
context entirely from non-main threads, but that's more complicated */
|
||||
if(!BLI_thread_is_main())
|
||||
* condition on C->data.recursion. ideal solution would be to disable
|
||||
* context entirely from non-main threads, but that's more complicated */
|
||||
if (!BLI_thread_is_main())
|
||||
return;
|
||||
|
||||
BPy_SetContext(C);
|
||||
|
||||
@@ -1424,7 +1424,7 @@ int pyrna_pydict_to_props(PointerRNA *ptr, PyObject *kw, int all_args, const cha
|
||||
|
||||
totkw = kw ? PyDict_Size(kw) : 0;
|
||||
|
||||
RNA_STRUCT_BEGIN(ptr, prop) {
|
||||
RNA_STRUCT_BEGIN (ptr, prop) {
|
||||
arg_name = RNA_property_identifier(prop);
|
||||
|
||||
if (strcmp(arg_name, "rna_type") == 0) continue;
|
||||
@@ -2203,7 +2203,7 @@ int pyrna_prop_collection_subscript_str_lib_pair_ptr(BPy_PropertyRNA *self, PyOb
|
||||
/* lib is either a valid poniter or NULL,
|
||||
* either way can do direct comparison with id.lib */
|
||||
|
||||
RNA_PROP_BEGIN(&self->ptr, itemptr, self->prop) {
|
||||
RNA_PROP_BEGIN (&self->ptr, itemptr, self->prop) {
|
||||
ID *id = itemptr.data; /* always an ID */
|
||||
if (id->lib == lib && (strncmp(keyname, id->name + 2, sizeof(id->name) - 2) == 0)) {
|
||||
found = TRUE;
|
||||
@@ -3346,7 +3346,7 @@ static void pyrna_dir_members_rna(PyObject *list, PointerRNA *ptr)
|
||||
RNA_pointer_create(NULL, &RNA_Struct, ptr->type, &tptr);
|
||||
iterprop = RNA_struct_find_property(&tptr, "functions");
|
||||
|
||||
RNA_PROP_BEGIN(&tptr, itemptr, iterprop) {
|
||||
RNA_PROP_BEGIN (&tptr, itemptr, iterprop) {
|
||||
idname = RNA_function_identifier(itemptr.data);
|
||||
|
||||
pystring = PyUnicode_FromString(idname);
|
||||
@@ -3365,7 +3365,7 @@ static void pyrna_dir_members_rna(PyObject *list, PointerRNA *ptr)
|
||||
|
||||
iterprop = RNA_struct_iterator_property(ptr->type);
|
||||
|
||||
RNA_PROP_BEGIN(ptr, itemptr, iterprop) {
|
||||
RNA_PROP_BEGIN (ptr, itemptr, iterprop) {
|
||||
nameptr = RNA_struct_name_get_alloc(&itemptr, name, sizeof(name), &namelen);
|
||||
|
||||
if (nameptr) {
|
||||
@@ -3980,7 +3980,7 @@ static PyObject *pyrna_prop_collection_keys(BPy_PropertyRNA *self)
|
||||
char name[256], *nameptr;
|
||||
int namelen;
|
||||
|
||||
RNA_PROP_BEGIN(&self->ptr, itemptr, self->prop) {
|
||||
RNA_PROP_BEGIN (&self->ptr, itemptr, self->prop) {
|
||||
nameptr = RNA_struct_name_get_alloc(&itemptr, name, sizeof(name), &namelen);
|
||||
|
||||
if (nameptr) {
|
||||
@@ -4017,7 +4017,7 @@ static PyObject *pyrna_prop_collection_items(BPy_PropertyRNA *self)
|
||||
int namelen;
|
||||
int i = 0;
|
||||
|
||||
RNA_PROP_BEGIN(&self->ptr, itemptr, self->prop) {
|
||||
RNA_PROP_BEGIN (&self->ptr, itemptr, self->prop) {
|
||||
if (itemptr.data) {
|
||||
/* add to python list */
|
||||
item = PyTuple_New(2);
|
||||
@@ -4189,7 +4189,7 @@ static PyObject *pyrna_prop_collection_find(BPy_PropertyRNA *self, PyObject *key
|
||||
|
||||
PYRNA_PROP_CHECK_OBJ(self);
|
||||
|
||||
RNA_PROP_BEGIN(&self->ptr, itemptr, self->prop) {
|
||||
RNA_PROP_BEGIN (&self->ptr, itemptr, self->prop) {
|
||||
nameptr = RNA_struct_name_get_alloc(&itemptr, name, sizeof(name), &namelen);
|
||||
|
||||
if (nameptr) {
|
||||
@@ -4220,7 +4220,7 @@ static void foreach_attr_type(BPy_PropertyRNA *self, const char *attr,
|
||||
*attr_signed = FALSE;
|
||||
|
||||
/* note: this is fail with zero length lists, so don't let this get caled in that case */
|
||||
RNA_PROP_BEGIN(&self->ptr, itemptr, self->prop) {
|
||||
RNA_PROP_BEGIN (&self->ptr, itemptr, self->prop) {
|
||||
prop = RNA_struct_find_property(&itemptr, attr);
|
||||
*raw_type = RNA_property_raw_type(prop);
|
||||
*attr_tot = RNA_property_array_length(&itemptr, prop);
|
||||
@@ -6401,7 +6401,7 @@ static PyObject *pyrna_basetype_dir(BPy_BaseTypeRNA *self)
|
||||
PyObject *ret = PyList_New(0);
|
||||
PyObject *item;
|
||||
|
||||
RNA_PROP_BEGIN(&self->ptr, itemptr, self->prop) {
|
||||
RNA_PROP_BEGIN (&self->ptr, itemptr, self->prop) {
|
||||
StructRNA *srna = itemptr.data;
|
||||
StructRNA *srna_base = RNA_struct_base(itemptr.data);
|
||||
/* skip own operators, these double up [#29666] */
|
||||
@@ -7189,7 +7189,7 @@ void pyrna_alloc_types(void)
|
||||
RNA_blender_rna_pointer_create(&ptr);
|
||||
prop = RNA_struct_find_property(&ptr, "structs");
|
||||
|
||||
RNA_PROP_BEGIN(&ptr, itemptr, prop) {
|
||||
RNA_PROP_BEGIN (&ptr, itemptr, prop) {
|
||||
PyObject *item = pyrna_struct_Subtype(&itemptr);
|
||||
if (item == NULL) {
|
||||
if (PyErr_Occurred()) {
|
||||
@@ -7217,7 +7217,7 @@ void pyrna_free_types(void)
|
||||
prop = RNA_struct_find_property(&ptr, "structs");
|
||||
|
||||
|
||||
RNA_PROP_BEGIN(&ptr, itemptr, prop) {
|
||||
RNA_PROP_BEGIN (&ptr, itemptr, prop) {
|
||||
StructRNA *srna = srna_from_ptr(&itemptr);
|
||||
void *py_ptr = RNA_struct_py_type_get(srna);
|
||||
|
||||
@@ -7477,7 +7477,7 @@ static PyObject *pyrna_unregister_class(PyObject *UNUSED(self), PyObject *py_cla
|
||||
|
||||
|
||||
/* loop over all structs */
|
||||
RNA_PROP_BEGIN(&ptr_rna, itemptr, prop_rna) {
|
||||
RNA_PROP_BEGIN (&ptr_rna, itemptr, prop_rna) {
|
||||
srna_iter = itemptr.data;
|
||||
if (pyrna_srna_contains_pointer_prop_srna(srna_iter, srna, &prop_identifier)) {
|
||||
break;
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -444,7 +444,8 @@ static PyObject *M_Geometry_intersect_line_line_2d(PyObject *UNUSED(self), PyObj
|
||||
PyDoc_STRVAR(M_Geometry_intersect_line_plane_doc,
|
||||
".. function:: intersect_line_plane(line_a, line_b, plane_co, plane_no, no_flip=False)\n"
|
||||
"\n"
|
||||
" Takes 2 lines (as 4 vectors) and returns a vector for their point of intersection or None.\n"
|
||||
" Calculate the intersection between a line (as 2 vectors) and a plane.\n"
|
||||
" Returns a vector for the intersection or None.\n"
|
||||
"\n"
|
||||
" :arg line_a: First point of the first line\n"
|
||||
" :type line_a: :class:`mathutils.Vector`\n"
|
||||
@@ -1010,7 +1011,7 @@ static PyObject *M_Geometry_interpolate_bezier(PyObject *UNUSED(self), PyObject
|
||||
|
||||
coord_array = MEM_callocN(dims * (resolu) * sizeof(float), "interpolate_bezier");
|
||||
for (i = 0; i < dims; i++) {
|
||||
forward_diff_bezier(k1[i], h1[i], h2[i], k2[i], coord_array + i, resolu - 1, sizeof(float) * dims);
|
||||
BKE_curve_forward_diff_bezier(k1[i], h1[i], h2[i], k2[i], coord_array + i, resolu - 1, sizeof(float) * dims);
|
||||
}
|
||||
|
||||
list = PyList_New(resolu);
|
||||
|
||||
Reference in New Issue
Block a user