mathutils: refactor instantiation
remove 'type' argument, very few mathutils objects are wrapped, add new function for creating wrapped objects. also fixes unlikely memory leak if the data-array can't be allocated.
This commit is contained in:
@@ -540,10 +540,10 @@ static PyObject *bpy_slot_to_py(BMesh *bm, BMOpSlot *slot)
|
||||
item = PyFloat_FromDouble((double)BMO_SLOT_AS_FLOAT(slot));
|
||||
break;
|
||||
case BMO_OP_SLOT_MAT:
|
||||
item = Matrix_CreatePyObject((float *)BMO_SLOT_AS_MATRIX(slot), 4, 4, Py_NEW, NULL);
|
||||
item = Matrix_CreatePyObject((float *)BMO_SLOT_AS_MATRIX(slot), 4, 4, NULL);
|
||||
break;
|
||||
case BMO_OP_SLOT_VEC:
|
||||
item = Vector_CreatePyObject(BMO_SLOT_AS_VECTOR(slot), slot->len, Py_NEW, NULL);
|
||||
item = Vector_CreatePyObject(BMO_SLOT_AS_VECTOR(slot), slot->len, NULL);
|
||||
break;
|
||||
case BMO_OP_SLOT_PTR:
|
||||
BLI_assert(0); /* currently we don't have any pointer return values in use */
|
||||
|
||||
@@ -342,7 +342,7 @@ PyDoc_STRVAR(bpy_bmvert_co_doc,
|
||||
static PyObject *bpy_bmvert_co_get(BPy_BMVert *self)
|
||||
{
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
return Vector_CreatePyObject(self->v->co, 3, Py_WRAP, NULL);
|
||||
return Vector_CreatePyObject_wrap(self->v->co, 3, NULL);
|
||||
}
|
||||
|
||||
static int bpy_bmvert_co_set(BPy_BMVert *self, PyObject *value)
|
||||
@@ -364,7 +364,7 @@ PyDoc_STRVAR(bpy_bmvert_normal_doc,
|
||||
static PyObject *bpy_bmvert_normal_get(BPy_BMVert *self)
|
||||
{
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
return Vector_CreatePyObject(self->v->no, 3, Py_WRAP, NULL);
|
||||
return Vector_CreatePyObject_wrap(self->v->no, 3, NULL);
|
||||
}
|
||||
|
||||
static int bpy_bmvert_normal_set(BPy_BMVert *self, PyObject *value)
|
||||
@@ -468,7 +468,7 @@ PyDoc_STRVAR(bpy_bmface_normal_doc,
|
||||
static PyObject *bpy_bmface_normal_get(BPy_BMFace *self)
|
||||
{
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
return Vector_CreatePyObject(self->f->no, 3, Py_WRAP, NULL);
|
||||
return Vector_CreatePyObject_wrap(self->f->no, 3, NULL);
|
||||
}
|
||||
|
||||
static int bpy_bmface_normal_set(BPy_BMFace *self, PyObject *value)
|
||||
@@ -1530,7 +1530,7 @@ static PyObject *bpy_bmedge_calc_tangent(BPy_BMEdge *self, PyObject *args)
|
||||
BPY_BM_CHECK_OBJ(py_loop);
|
||||
/* no need to check if they are from the same mesh or even connected */
|
||||
BM_edge_calc_face_tangent(self->e, py_loop->l, vec);
|
||||
return Vector_CreatePyObject(vec, 3, Py_NEW, NULL);
|
||||
return Vector_CreatePyObject(vec, 3, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1711,7 +1711,7 @@ static PyObject *bpy_bmface_calc_center_mean(BPy_BMFace *self)
|
||||
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
BM_face_calc_center_mean(self->f, cent);
|
||||
return Vector_CreatePyObject(cent, 3, Py_NEW, NULL);
|
||||
return Vector_CreatePyObject(cent, 3, NULL);
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_bmface_calc_center_mean_weighted_doc,
|
||||
@@ -1728,7 +1728,7 @@ static PyObject *bpy_bmface_calc_center_mean_weighted(BPy_BMFace *self)
|
||||
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
BM_face_calc_center_mean_weighted(self->f, cent);
|
||||
return Vector_CreatePyObject(cent, 3, Py_NEW, NULL);
|
||||
return Vector_CreatePyObject(cent, 3, NULL);
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_bmface_calc_center_bounds_doc,
|
||||
@@ -1745,7 +1745,7 @@ static PyObject *bpy_bmface_calc_center_bounds(BPy_BMFace *self)
|
||||
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
BM_face_calc_center_bounds(self->f, cent);
|
||||
return Vector_CreatePyObject(cent, 3, Py_NEW, NULL);
|
||||
return Vector_CreatePyObject(cent, 3, NULL);
|
||||
}
|
||||
|
||||
|
||||
@@ -1849,7 +1849,7 @@ static PyObject *bpy_bmloop_calc_normal(BPy_BMLoop *self)
|
||||
float vec[3];
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
BM_loop_calc_face_normal(self->l, vec);
|
||||
return Vector_CreatePyObject(vec, 3, Py_NEW, NULL);
|
||||
return Vector_CreatePyObject(vec, 3, NULL);
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_bmloop_calc_tangent_doc,
|
||||
@@ -1866,7 +1866,7 @@ static PyObject *bpy_bmloop_calc_tangent(BPy_BMLoop *self)
|
||||
float vec[3];
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
BM_loop_calc_face_tangent(self->l, vec);
|
||||
return Vector_CreatePyObject(vec, 3, Py_NEW, NULL);
|
||||
return Vector_CreatePyObject(vec, 3, NULL);
|
||||
}
|
||||
|
||||
/* Vert Seq
|
||||
|
||||
@@ -1014,7 +1014,7 @@ PyObject *BPy_BMLayerItem_GetItem(BPy_BMElem *py_ele, BPy_BMLayerItem *py_layer)
|
||||
}
|
||||
case CD_SHAPEKEY:
|
||||
{
|
||||
ret = Vector_CreatePyObject((float *)value, 3, Py_WRAP, NULL);
|
||||
ret = Vector_CreatePyObject_wrap((float *)value, 3, NULL);
|
||||
break;
|
||||
}
|
||||
case CD_BWEIGHT:
|
||||
|
||||
@@ -150,7 +150,7 @@ PyDoc_STRVAR(bpy_bmloopuv_uv_doc,
|
||||
);
|
||||
static PyObject *bpy_bmloopuv_uv_get(BPy_BMLoopUV *self, void *UNUSED(closure))
|
||||
{
|
||||
return Vector_CreatePyObject(self->data->uv, 2, Py_WRAP, NULL);
|
||||
return Vector_CreatePyObject_wrap(self->data->uv, 2, NULL);
|
||||
}
|
||||
|
||||
static int bpy_bmloopuv_uv_set(BPy_BMLoopUV *self, PyObject *value, void *UNUSED(closure))
|
||||
@@ -263,7 +263,7 @@ PyDoc_STRVAR(bpy_bmvertskin_radius_doc,
|
||||
);
|
||||
static PyObject *bpy_bmvertskin_radius_get(BPy_BMVertSkin *self, void *UNUSED(closure))
|
||||
{
|
||||
return Vector_CreatePyObject(self->data->radius, 2, Py_WRAP, NULL);
|
||||
return Vector_CreatePyObject_wrap(self->data->radius, 2, NULL);
|
||||
}
|
||||
|
||||
static int bpy_bmvertskin_radius_set(BPy_BMVertSkin *self, PyObject *value, void *UNUSED(closure))
|
||||
|
||||
Reference in New Issue
Block a user