13 #include "../mathutils/mathutils.h"
26 #include "../generic/py_capi_utils.h"
27 #include "../generic/python_utildefines.h"
32 #define BPy_BMLoopUV_Check(v) (Py_TYPE(v) == &BPy_BMLoopUV_Type)
40 "Loops UV (as a 2D Vector).\n\n:type: :class:`mathutils.Vector`");
57 PyDoc_STRVAR(bpy_bmloopuv_flag__pin_uv_doc,
"UV pin state.\n\n:type: boolean");
58 PyDoc_STRVAR(bpy_bmloopuv_flag__select_doc,
"UV select state.\n\n:type: boolean");
59 PyDoc_STRVAR(bpy_bmloopuv_flag__select_edge_doc,
"UV edge select state.\n\n:type: boolean");
64 return PyBool_FromLong(
self->data->flag & flag);
73 self->data->flag |= flag;
76 self->data->flag &= ~flag;
90 bpy_bmloopuv_flag__pin_uv_doc,
95 bpy_bmloopuv_flag__select_doc,
100 bpy_bmloopuv_flag__select_edge_doc,
126 PyErr_Format(PyExc_TypeError,
"expected BMLoopUV, not a %.200s", Py_TYPE(value)->tp_name);
137 self->data = mloopuv;
138 return (PyObject *)
self;
146 #define BPy_BMVertSkin_Check(v) (Py_TYPE(v) == &BPy_BMVertSkin_Type)
154 "Vert skin radii (as a 2D Vector).\n\n:type: :class:`mathutils.Vector`");
172 "Use as root vertex. Setting this flag does not clear other roots in the same mesh "
173 "island.\n\n:type: boolean");
174 PyDoc_STRVAR(bpy_bmvertskin_flag__use_loose_doc,
"Use loose vertex.\n\n:type: boolean");
179 return PyBool_FromLong(
self->data->flag & flag);
188 self->data->flag |= flag;
191 self->data->flag &= ~flag;
204 bpy_bmvertskin_radius_doc,
209 bpy_bmvertskin_flag__use_root_doc,
214 bpy_bmvertskin_flag__use_loose_doc,
240 PyErr_Format(PyExc_TypeError,
"expected BMVertSkin, not a %.200s", Py_TYPE(value)->tp_name);
251 self->data = mvertskin;
252 return (PyObject *)
self;
264 #define MLOOPCOL_FROM_CAPSULE(color_capsule) \
265 ((MLoopCol *)PyCapsule_GetPointer(color_capsule, NULL))
310 const float f = bmo->data[index];
317 bmo->data[index] = f;
348 PyObject *color_capsule;
349 color_capsule = PyCapsule_New(mloopcol,
NULL,
NULL);
353 #undef MLOOPCOL_FROM_CAPSULE
384 #define BPy_BMDeformVert_Check(v) (Py_TYPE(v) == &BPy_BMDeformVert_Type)
396 return self->data->totweight;
401 if (PyIndex_Check(key)) {
403 i = PyNumber_AsSsize_t(key, PyExc_IndexError);
404 if (i == -1 && PyErr_Occurred()) {
411 PyErr_SetString(PyExc_KeyError,
412 "BMDeformVert[key] = x: "
417 return PyFloat_FromDouble(dw->
weight);
421 PyExc_TypeError,
"BMDeformVert keys must be integers, not %.200s", Py_TYPE(key)->tp_name);
427 if (PyIndex_Check(key)) {
430 i = PyNumber_AsSsize_t(key, PyExc_IndexError);
431 if (i == -1 && PyErr_Occurred()) {
438 PyErr_SetString(PyExc_KeyError,
439 "BMDeformVert[key] = x: "
440 "weight keys can't be negative");
445 const float f = PyFloat_AsDouble(value);
446 if (f == -1 && PyErr_Occurred()) {
447 PyErr_SetString(PyExc_TypeError,
448 "BMDeformVert[key] = x: "
449 "assigned value not a number");
460 PyErr_SetString(PyExc_KeyError,
461 "del BMDeformVert[key]: "
471 PyExc_TypeError,
"BMDeformVert keys must be integers, not %.200s", Py_TYPE(key)->tp_name);
477 const int key = PyLong_AsSsize_t(value);
479 if (key == -1 && PyErr_Occurred()) {
480 PyErr_SetString(PyExc_TypeError,
"BMDeformVert.__contains__: expected an int");
515 ".. method:: keys()\n"
517 " Return the group indices used by this vertex\n"
518 " (matching pythons dict.keys() functionality).\n"
520 " :return: the deform group this vertex uses\n"
521 " :rtype: list of ints\n");
528 ret = PyList_New(
self->data->totweight);
529 for (i = 0; i <
self->data->totweight; i++, dw++) {
530 PyList_SET_ITEM(
ret, i, PyLong_FromLong(dw->
def_nr));
537 ".. method:: values()\n"
539 " Return the weights of the deform vertex\n"
540 " (matching pythons dict.values() functionality).\n"
542 " :return: The weights that influence this vertex\n"
543 " :rtype: list of floats\n");
550 ret = PyList_New(
self->data->totweight);
551 for (i = 0; i <
self->data->totweight; i++, dw++) {
552 PyList_SET_ITEM(
ret, i, PyFloat_FromDouble(dw->
weight));
559 ".. method:: items()\n"
561 " Return (group, weight) pairs for this vertex\n"
562 " (matching pythons dict.items() functionality).\n"
564 " :return: (key, value) pairs for each deform weight of this vertex.\n"
565 " :rtype: list of tuples\n");
573 ret = PyList_New(
self->data->totweight);
574 for (i = 0; i <
self->data->totweight; i++, dw++) {
575 item = PyTuple_New(2);
577 PyList_SET_ITEM(
ret, i, item);
584 ".. method:: get(key, default=None)\n"
586 " Returns the deform weight matching the key or default\n"
587 " when not found (matches pythons dictionary function of the same name).\n"
589 " :arg key: The key associated with deform weight.\n"
591 " :arg default: Optional argument for the value to return if\n"
592 " *key* is not found.\n"
593 " :type default: Undefined\n");
597 PyObject *def = Py_None;
599 if (!PyArg_ParseTuple(args,
"i|O:get", &key, &def)) {
606 return PyFloat_FromDouble(dw->
weight);
609 return Py_INCREF_RET(def);
613 ".. method:: clear()\n"
615 " Clears all weights.\n");
656 PyErr_Format(PyExc_TypeError,
"expected BMDeformVert, not a %.200s", Py_TYPE(value)->tp_name);
661 if (
LIKELY(dvert != dvert_src)) {
671 return (PyObject *)
self;
MINLINE float clamp_f(float value, float min, float max)
void rgba_uchar_to_float(float r_col[4], const unsigned char col_ub[4])
void rgba_float_to_uchar(unsigned char r_col[4], const float col_f[4])
MINLINE void copy_v2_v2(float r[2], const float a[2])
#define POINTER_AS_INT(i)
Object is a sort of wrapper for general info.
static PySequenceMethods bpy_bmdeformvert_as_sequence
static PyObject * bpy_bmvertskin_radius_get(BPy_BMVertSkin *self, void *UNUSED(closure))
static int bpy_bmloopuv_uv_set(BPy_BMLoopUV *self, PyObject *value, void *UNUSED(closure))
int BPy_BMLoopColor_AssignPyObject(struct MLoopCol *mloopcol, PyObject *value)
static void bm_init_types_bmdvert(void)
static void bm_init_types_bmloopuv(void)
static int mathutils_bmloopcol_get(BaseMathObject *bmo, int UNUSED(subtype))
PyObject * BPy_BMLoopColor_CreatePyObject(struct MLoopCol *mloopcol)
struct BPy_BMDeformVert BPy_BMDeformVert
static int bpy_bmvertskin_flag_set(BPy_BMVertSkin *self, PyObject *value, void *flag_p)
static void bm_init_types_bmloopcol(void)
int BPy_BMDeformVert_AssignPyObject(struct MDeformVert *dvert, PyObject *value)
static int bpy_bmdeformvert_len(BPy_BMDeformVert *self)
static void mloopcol_to_float(const MLoopCol *mloopcol, float r_col[4])
int BPy_BMVertSkin_AssignPyObject(struct MVertSkin *mvertskin, PyObject *value)
static int mathutils_bmloopcol_check(BaseMathObject *UNUSED(bmo))
static PyObject * bpy_bmdeformvert_values(BPy_BMDeformVert *self)
#define MLOOPCOL_FROM_CAPSULE(color_capsule)
void BPy_BM_init_types_meshdata(void)
struct BPy_BMLoopUV BPy_BMLoopUV
static int bpy_bmvertskin_radius_set(BPy_BMVertSkin *self, PyObject *value, void *UNUSED(closure))
static PyObject * bpy_bmloopuv_flag_get(BPy_BMLoopUV *self, void *flag_p)
PyObject * BPy_BMDeformVert_CreatePyObject(struct MDeformVert *dvert)
static int mathutils_bmloopcol_set_index(BaseMathObject *bmo, int subtype, int index)
static Mathutils_Callback mathutils_bmloopcol_cb
static PyObject * bpy_bmloopuv_uv_get(BPy_BMLoopUV *self, void *UNUSED(closure))
static PyGetSetDef bpy_bmloopuv_getseters[]
struct BPy_BMVertSkin BPy_BMVertSkin
static int bpy_bmloopuv_flag_set(BPy_BMLoopUV *self, PyObject *value, void *flag_p)
static PyObject * bpy_bmdeformvert_clear(BPy_BMDeformVert *self)
int BPy_BMLoopUV_AssignPyObject(struct MLoopUV *mloopuv, PyObject *value)
static PyObject * bpy_bmdeformvert_subscript(BPy_BMDeformVert *self, PyObject *key)
static int bpy_bmdeformvert_contains(BPy_BMDeformVert *self, PyObject *value)
static int bpy_bmdeformvert_ass_subscript(BPy_BMDeformVert *self, PyObject *key, PyObject *value)
PyTypeObject BPy_BMDeformVert_Type
static void bm_init_types_bmvertskin(void)
static int mathutils_bmloopcol_get_index(BaseMathObject *bmo, int subtype, int UNUSED(index))
PyObject * BPy_BMLoopUV_CreatePyObject(struct MLoopUV *mloopuv)
static PyGetSetDef bpy_bmvertskin_getseters[]
#define BPy_BMVertSkin_Check(v)
static PyObject * bpy_bmdeformvert_items(BPy_BMDeformVert *self)
static void mloopcol_from_float(MLoopCol *mloopcol, const float col[4])
#define BPy_BMDeformVert_Check(v)
static uchar mathutils_bmloopcol_cb_index
static int mathutils_bmloopcol_set(BaseMathObject *bmo, int UNUSED(subtype))
static PyObject * bpy_bmvertskin_flag_get(BPy_BMVertSkin *self, void *flag_p)
PyTypeObject BPy_BMLoopUV_Type
static PyObject * bpy_bmdeformvert_keys(BPy_BMDeformVert *self)
#define BPy_BMLoopUV_Check(v)
static struct PyMethodDef bpy_bmdeformvert_methods[]
static PyObject * bpy_bmdeformvert_get(BPy_BMDeformVert *self, PyObject *args)
static PyMappingMethods bpy_bmdeformvert_as_mapping
PyObject * BPy_BMVertSkin_CreatePyObject(struct MVertSkin *mvertskin)
PyDoc_STRVAR(bpy_bmloopuv_uv_doc, "Loops UV (as a 2D Vector).\n\n:type: :class:`mathutils.Vector`")
static PyTypeObject BPy_BMVertSkin_Type
int mathutils_array_parse(float *array, int array_num_min, int array_num_max, PyObject *value, const char *error_prefix)
uchar Mathutils_RegisterCallback(Mathutils_Callback *cb)
PyObject * Vector_CreatePyObject_wrap(float *vec, const int vec_num, PyTypeObject *base_type)
PyObject * Vector_CreatePyObject_cb(PyObject *cb_user, int vec_num, uchar cb_type, uchar cb_subtype)
int PyC_Long_AsBool(PyObject *value)
#define PyTuple_SET_ITEMS(op_arg,...)
PyObject_VAR_HEAD MLoopUV * data
PyObject_VAR_HEAD MVertSkin * data