Changeset View
Changeset View
Standalone View
Standalone View
source/blender/python/bmesh/bmesh_py_types.c
| Show First 20 Lines • Show All 3,631 Lines • ▼ Show 20 Lines | PyObject *BPy_BMVert_CreatePyObject(BMesh *bm, BMVert *v) | ||||
| void **ptr = CustomData_bmesh_get(&bm->vdata, v->head.data, CD_BM_ELEM_PYPTR); | void **ptr = CustomData_bmesh_get(&bm->vdata, v->head.data, CD_BM_ELEM_PYPTR); | ||||
| /* bmesh may free layers, ensure we have one to store ourself */ | /* bmesh may free layers, ensure we have one to store ourself */ | ||||
| if (UNLIKELY(ptr == NULL)) { | if (UNLIKELY(ptr == NULL)) { | ||||
| BM_data_layer_add(bm, &bm->vdata, CD_BM_ELEM_PYPTR); | BM_data_layer_add(bm, &bm->vdata, CD_BM_ELEM_PYPTR); | ||||
| ptr = CustomData_bmesh_get(&bm->vdata, v->head.data, CD_BM_ELEM_PYPTR); | ptr = CustomData_bmesh_get(&bm->vdata, v->head.data, CD_BM_ELEM_PYPTR); | ||||
| } | } | ||||
| if (*ptr != NULL) { | if (ptr != NULL && *ptr != NULL) { | ||||
| self = *ptr; | self = *ptr; | ||||
| Py_INCREF(self); | Py_INCREF(self); | ||||
| } | } | ||||
| else { | else { | ||||
| self = PyObject_New(BPy_BMVert, &BPy_BMVert_Type); | self = PyObject_New(BPy_BMVert, &BPy_BMVert_Type); | ||||
| BLI_assert(v != NULL); | BLI_assert(v != NULL); | ||||
| self->bm = bm; | self->bm = bm; | ||||
| self->v = v; | self->v = v; | ||||
| *ptr = self; | ptr = &self; | ||||
| } | } | ||||
| return (PyObject *)self; | return (PyObject *)self; | ||||
| } | } | ||||
| PyObject *BPy_BMEdge_CreatePyObject(BMesh *bm, BMEdge *e) | PyObject *BPy_BMEdge_CreatePyObject(BMesh *bm, BMEdge *e) | ||||
| { | { | ||||
| BPy_BMEdge *self; | BPy_BMEdge *self; | ||||
| void **ptr = CustomData_bmesh_get(&bm->edata, e->head.data, CD_BM_ELEM_PYPTR); | void **ptr = CustomData_bmesh_get(&bm->edata, e->head.data, CD_BM_ELEM_PYPTR); | ||||
| /* bmesh may free layers, ensure we have one to store ourself */ | /* bmesh may free layers, ensure we have one to store ourself */ | ||||
| if (UNLIKELY(ptr == NULL)) { | if (UNLIKELY(ptr == NULL)) { | ||||
| BM_data_layer_add(bm, &bm->edata, CD_BM_ELEM_PYPTR); | BM_data_layer_add(bm, &bm->edata, CD_BM_ELEM_PYPTR); | ||||
| ptr = CustomData_bmesh_get(&bm->edata, e->head.data, CD_BM_ELEM_PYPTR); | ptr = CustomData_bmesh_get(&bm->edata, e->head.data, CD_BM_ELEM_PYPTR); | ||||
| } | } | ||||
| if (*ptr != NULL) { | if (ptr != NULL && *ptr != NULL) { | ||||
| self = *ptr; | self = *ptr; | ||||
| Py_INCREF(self); | Py_INCREF(self); | ||||
| } | } | ||||
| else { | else { | ||||
| self = PyObject_New(BPy_BMEdge, &BPy_BMEdge_Type); | self = PyObject_New(BPy_BMEdge, &BPy_BMEdge_Type); | ||||
| BLI_assert(e != NULL); | BLI_assert(e != NULL); | ||||
| self->bm = bm; | self->bm = bm; | ||||
| self->e = e; | self->e = e; | ||||
| *ptr = self; | ptr = &self; | ||||
| } | } | ||||
| return (PyObject *)self; | return (PyObject *)self; | ||||
| } | } | ||||
| PyObject *BPy_BMFace_CreatePyObject(BMesh *bm, BMFace *f) | PyObject *BPy_BMFace_CreatePyObject(BMesh *bm, BMFace *f) | ||||
| { | { | ||||
| BPy_BMFace *self; | BPy_BMFace *self; | ||||
| void **ptr = CustomData_bmesh_get(&bm->pdata, f->head.data, CD_BM_ELEM_PYPTR); | void **ptr = CustomData_bmesh_get(&bm->pdata, f->head.data, CD_BM_ELEM_PYPTR); | ||||
| /* bmesh may free layers, ensure we have one to store ourself */ | /* bmesh may free layers, ensure we have one to store ourself */ | ||||
| if (UNLIKELY(ptr == NULL)) { | if (UNLIKELY(ptr == NULL)) { | ||||
| BM_data_layer_add(bm, &bm->pdata, CD_BM_ELEM_PYPTR); | BM_data_layer_add(bm, &bm->pdata, CD_BM_ELEM_PYPTR); | ||||
| ptr = CustomData_bmesh_get(&bm->pdata, f->head.data, CD_BM_ELEM_PYPTR); | ptr = CustomData_bmesh_get(&bm->pdata, f->head.data, CD_BM_ELEM_PYPTR); | ||||
| } | } | ||||
| if (*ptr != NULL) { | if (ptr != NULL && *ptr != NULL) { | ||||
| self = *ptr; | self = *ptr; | ||||
| Py_INCREF(self); | Py_INCREF(self); | ||||
| } | } | ||||
| else { | else { | ||||
| self = PyObject_New(BPy_BMFace, &BPy_BMFace_Type); | self = PyObject_New(BPy_BMFace, &BPy_BMFace_Type); | ||||
| BLI_assert(f != NULL); | BLI_assert(f != NULL); | ||||
| self->bm = bm; | self->bm = bm; | ||||
| self->f = f; | self->f = f; | ||||
| *ptr = self; | ptr = &self; | ||||
| } | } | ||||
| return (PyObject *)self; | return (PyObject *)self; | ||||
| } | } | ||||
| PyObject *BPy_BMLoop_CreatePyObject(BMesh *bm, BMLoop *l) | PyObject *BPy_BMLoop_CreatePyObject(BMesh *bm, BMLoop *l) | ||||
| { | { | ||||
| BPy_BMLoop *self; | BPy_BMLoop *self; | ||||
| void **ptr = CustomData_bmesh_get(&bm->ldata, l->head.data, CD_BM_ELEM_PYPTR); | void **ptr = CustomData_bmesh_get(&bm->ldata, l->head.data, CD_BM_ELEM_PYPTR); | ||||
| /* bmesh may free layers, ensure we have one to store ourself */ | /* bmesh may free layers, ensure we have one to store ourself */ | ||||
| if (UNLIKELY(ptr == NULL)) { | if (UNLIKELY(ptr == NULL)) { | ||||
| BM_data_layer_add(bm, &bm->ldata, CD_BM_ELEM_PYPTR); | BM_data_layer_add(bm, &bm->ldata, CD_BM_ELEM_PYPTR); | ||||
| ptr = CustomData_bmesh_get(&bm->ldata, l->head.data, CD_BM_ELEM_PYPTR); | ptr = CustomData_bmesh_get(&bm->ldata, l->head.data, CD_BM_ELEM_PYPTR); | ||||
| } | } | ||||
| if (*ptr != NULL) { | if (ptr != NULL && *ptr != NULL) { | ||||
| self = *ptr; | self = *ptr; | ||||
| Py_INCREF(self); | Py_INCREF(self); | ||||
| } | } | ||||
| else { | else { | ||||
| self = PyObject_New(BPy_BMLoop, &BPy_BMLoop_Type); | self = PyObject_New(BPy_BMLoop, &BPy_BMLoop_Type); | ||||
| BLI_assert(l != NULL); | BLI_assert(l != NULL); | ||||
| self->bm = bm; | self->bm = bm; | ||||
| self->l = l; | self->l = l; | ||||
| *ptr = self; | ptr = &self; | ||||
| } | } | ||||
| return (PyObject *)self; | return (PyObject *)self; | ||||
| } | } | ||||
| PyObject *BPy_BMElemSeq_CreatePyObject(BMesh *bm, BPy_BMElem *py_ele, const char itype) | PyObject *BPy_BMElemSeq_CreatePyObject(BMesh *bm, BPy_BMElem *py_ele, const char itype) | ||||
| { | { | ||||
| BPy_BMElemSeq *self = PyObject_New(BPy_BMElemSeq, &BPy_BMElemSeq_Type); | BPy_BMElemSeq *self = PyObject_New(BPy_BMElemSeq, &BPy_BMElemSeq_Type); | ||||
| self->bm = bm; | self->bm = bm; | ||||
| ▲ Show 20 Lines • Show All 354 Lines • Show Last 20 Lines | |||||