29 #include "../mathutils/mathutils.h"
42 #include "../generic/py_capi_utils.h"
43 #include "../generic/python_utildefines.h"
48 #define BPy_BMLoopUV_Check(v) (Py_TYPE(v) == &BPy_BMLoopUV_Type)
56 "Loops UV (as a 2D Vector).\n\n:type: :class:`mathutils.Vector`");
73 PyDoc_STRVAR(bpy_bmloopuv_flag__pin_uv_doc,
"UV pin state.\n\n:type: boolean");
74 PyDoc_STRVAR(bpy_bmloopuv_flag__select_doc,
"UV select state.\n\n:type: boolean");
79 return PyBool_FromLong(
self->data->flag & flag);
88 self->data->flag |= flag;
91 self->data->flag &= ~flag;
105 bpy_bmloopuv_flag__pin_uv_doc,
110 bpy_bmloopuv_flag__select_doc,
136 PyErr_Format(PyExc_TypeError,
"expected BMLoopUV, not a %.200s", Py_TYPE(value)->tp_name);
147 self->data = mloopuv;
148 return (PyObject *)
self;
156 #define BPy_BMVertSkin_Check(v) (Py_TYPE(v) == &BPy_BMVertSkin_Type)
164 "Vert skin radii (as a 2D Vector).\n\n:type: :class:`mathutils.Vector`");
182 "Use as root vertex. Setting this flag does not clear other roots in the same mesh "
183 "island.\n\n:type: boolean");
184 PyDoc_STRVAR(bpy_bmvertskin_flag__use_loose_doc,
"Use loose vertex.\n\n:type: boolean");
189 return PyBool_FromLong(
self->data->flag & flag);
198 self->data->flag |= flag;
201 self->data->flag &= ~flag;
214 bpy_bmvertskin_radius_doc,
219 bpy_bmvertskin_flag__use_root_doc,
224 bpy_bmvertskin_flag__use_loose_doc,
250 PyErr_Format(PyExc_TypeError,
"expected BMVertSkin, not a %.200s", Py_TYPE(value)->tp_name);
261 self->data = mvertskin;
262 return (PyObject *)
self;
274 #define MLOOPCOL_FROM_CAPSULE(color_capsule) \
275 ((MLoopCol *)PyCapsule_GetPointer(color_capsule, NULL))
320 const float f = bmo->data[index];
327 bmo->data[index] = f;
358 PyObject *color_capsule;
359 color_capsule = PyCapsule_New(mloopcol,
NULL,
NULL);
363 #undef MLOOPCOL_FROM_CAPSULE
394 #define BPy_BMDeformVert_Check(v) (Py_TYPE(v) == &BPy_BMDeformVert_Type)
406 return self->data->totweight;
411 if (PyIndex_Check(key)) {
413 i = PyNumber_AsSsize_t(key, PyExc_IndexError);
414 if (i == -1 && PyErr_Occurred()) {
421 PyErr_SetString(PyExc_KeyError,
422 "BMDeformVert[key] = x: "
427 return PyFloat_FromDouble(dw->
weight);
431 PyExc_TypeError,
"BMDeformVert keys must be integers, not %.200s", Py_TYPE(key)->tp_name);
437 if (PyIndex_Check(key)) {
440 i = PyNumber_AsSsize_t(key, PyExc_IndexError);
441 if (i == -1 && PyErr_Occurred()) {
448 PyErr_SetString(PyExc_KeyError,
449 "BMDeformVert[key] = x: "
450 "weight keys can't be negative");
455 const float f = PyFloat_AsDouble(value);
456 if (f == -1 && PyErr_Occurred()) {
457 PyErr_SetString(PyExc_TypeError,
458 "BMDeformVert[key] = x: "
459 "assigned value not a number");
470 PyErr_SetString(PyExc_KeyError,
471 "del BMDeformVert[key]: "
481 PyExc_TypeError,
"BMDeformVert keys must be integers, not %.200s", Py_TYPE(key)->tp_name);
487 const int key = PyLong_AsSsize_t(value);
489 if (key == -1 && PyErr_Occurred()) {
490 PyErr_SetString(PyExc_TypeError,
"BMDeformVert.__contains__: expected an int");
525 ".. method:: keys()\n"
527 " Return the group indices used by this vertex\n"
528 " (matching pythons dict.keys() functionality).\n"
530 " :return: the deform group this vertex uses\n"
531 " :rtype: list of ints\n");
538 ret = PyList_New(
self->data->totweight);
539 for (i = 0; i <
self->data->totweight; i++, dw++) {
540 PyList_SET_ITEM(
ret, i, PyLong_FromLong(dw->
def_nr));
547 ".. method:: values()\n"
549 " Return the weights of the deform vertex\n"
550 " (matching pythons dict.values() functionality).\n"
552 " :return: The weights that influence this vertex\n"
553 " :rtype: list of floats\n");
560 ret = PyList_New(
self->data->totweight);
561 for (i = 0; i <
self->data->totweight; i++, dw++) {
562 PyList_SET_ITEM(
ret, i, PyFloat_FromDouble(dw->
weight));
569 ".. method:: items()\n"
571 " Return (group, weight) pairs for this vertex\n"
572 " (matching pythons dict.items() functionality).\n"
574 " :return: (key, value) pairs for each deform weight of this vertex.\n"
575 " :rtype: list of tuples\n");
583 ret = PyList_New(
self->data->totweight);
584 for (i = 0; i <
self->data->totweight; i++, dw++) {
585 item = PyTuple_New(2);
587 PyList_SET_ITEM(
ret, i, item);
594 ".. method:: get(key, default=None)\n"
596 " Returns the deform weight matching the key or default\n"
597 " when not found (matches pythons dictionary function of the same name).\n"
599 " :arg key: The key associated with deform weight.\n"
601 " :arg default: Optional argument for the value to return if\n"
602 " *key* is not found.\n"
603 " :type default: Undefined\n");
607 PyObject *def = Py_None;
609 if (!PyArg_ParseTuple(args,
"i|O:get", &key, &def)) {
616 return PyFloat_FromDouble(dw->
weight);
619 return Py_INCREF_RET(def);
623 ".. method:: clear()\n"
625 " Clears all weights.\n");
666 PyErr_Format(PyExc_TypeError,
"expected BMDeformVert, not a %.200s", Py_TYPE(value)->tp_name);
671 if (
LIKELY(dvert != dvert_src)) {
681 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
uchar Mathutils_RegisterCallback(Mathutils_Callback *cb)
int mathutils_array_parse(float *array, int array_min, int array_max, PyObject *value, const char *error_prefix)
PyObject * Vector_CreatePyObject_cb(PyObject *cb_user, int size, uchar cb_type, uchar cb_subtype)
PyObject * Vector_CreatePyObject_wrap(float *vec, const int size, PyTypeObject *base_type)
int PyC_Long_AsBool(PyObject *value)
#define PyTuple_SET_ITEMS(op_arg,...)
PyObject_VAR_HEAD MLoopUV * data
PyObject_VAR_HEAD MVertSkin * data