Cleanup: Python, Clang-Tidy else-after-return fixes
This addresses warnings from Clang-Tidy's `readability-else-after-return` rule in the `source/blender/python` module. No functional changes.
This commit is contained in:
parent
44b7354742
commit
3d48d99647
|
@ -250,11 +250,9 @@ static PyObject *bpy_bmesh_ops_fakemod_getattro(PyObject *UNUSED(self), PyObject
|
|||
if (BMO_opcode_from_opname(opname) != -1) {
|
||||
return bpy_bmesh_op_CreatePyObject(opname);
|
||||
}
|
||||
else {
|
||||
PyErr_Format(
|
||||
PyExc_AttributeError, "BMeshOpsModule: operator \"%.200s\" doesn't exist", opname);
|
||||
|
||||
PyErr_Format(PyExc_AttributeError, "BMeshOpsModule: operator \"%.200s\" doesn't exist", opname);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static PyObject *bpy_bmesh_ops_fakemod_dir(PyObject *UNUSED(self))
|
||||
|
|
|
@ -82,7 +82,7 @@ static int bpy_slot_from_py_elem_check(BPy_BMElem *value,
|
|||
Py_TYPE(value)->tp_name);
|
||||
return -1;
|
||||
}
|
||||
else if (value->bm == NULL) {
|
||||
if (value->bm == NULL) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"%.200s: keyword \"%.200s\" %.200s invalidated element",
|
||||
opname,
|
||||
|
@ -90,7 +90,7 @@ static int bpy_slot_from_py_elem_check(BPy_BMElem *value,
|
|||
descr);
|
||||
return -1;
|
||||
}
|
||||
else if (value->bm != bm) { /* we may want to make this check optional by setting 'bm' to NULL */
|
||||
if (value->bm != bm) { /* we may want to make this check optional by setting 'bm' to NULL */
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"%.200s: keyword \"%.200s\" %.200s invalidated element",
|
||||
opname,
|
||||
|
@ -127,7 +127,7 @@ static int bpy_slot_from_py_elemseq_check(BPy_BMGeneric *value,
|
|||
descr);
|
||||
return -1;
|
||||
}
|
||||
else if (value->bm != bm) { /* we may want to make this check optional by setting 'bm' to NULL */
|
||||
if (value->bm != bm) { /* we may want to make this check optional by setting 'bm' to NULL */
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"%.200s: keyword \"%.200s\" %.200s, invalidated sequence",
|
||||
opname,
|
||||
|
@ -135,7 +135,7 @@ static int bpy_slot_from_py_elemseq_check(BPy_BMGeneric *value,
|
|||
descr);
|
||||
return -1;
|
||||
}
|
||||
else if ((htype_py & htype_bmo) == 0) {
|
||||
if ((htype_py & htype_bmo) == 0) {
|
||||
char str_bmo[32];
|
||||
char str_py[32];
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
|
@ -175,9 +175,8 @@ static int bpy_slot_from_py(BMesh *bm,
|
|||
Py_TYPE(value)->tp_name);
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
|
||||
BMO_SLOT_AS_BOOL(slot) = param;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -223,10 +222,9 @@ static int bpy_slot_from_py(BMesh *bm,
|
|||
Py_TYPE(value)->tp_name);
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
|
||||
BMO_SLOT_AS_INT(slot) = param;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BMO_OP_SLOT_FLT: {
|
||||
|
@ -239,9 +237,9 @@ static int bpy_slot_from_py(BMesh *bm,
|
|||
Py_TYPE(value)->tp_name);
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
|
||||
BMO_SLOT_AS_FLOAT(slot) = param;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case BMO_OP_SLOT_MAT: {
|
||||
|
|
|
@ -292,14 +292,13 @@ static int bpy_bmesh_select_mode_set(BPy_BMesh *self, PyObject *value)
|
|||
-1) {
|
||||
return -1;
|
||||
}
|
||||
else if (flag == 0) {
|
||||
if (flag == 0) {
|
||||
PyErr_SetString(PyExc_TypeError, "bm.select_mode: cant assignt an empty value");
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
|
||||
self->bm->selectmode = flag;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_bmesh_select_history_doc,
|
||||
|
@ -338,9 +337,8 @@ static int bpy_bmvert_co_set(BPy_BMVert *self, PyObject *value)
|
|||
if (mathutils_array_parse(self->v->co, 3, 3, value, "BMVert.co") != -1) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(
|
||||
|
@ -359,9 +357,8 @@ static int bpy_bmvert_normal_set(BPy_BMVert *self, PyObject *value)
|
|||
if (mathutils_array_parse(self->v->no, 3, 3, value, "BMVert.normal") != -1) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_bmvert_is_manifold_doc,
|
||||
|
@ -453,9 +450,8 @@ static int bpy_bmface_normal_set(BPy_BMFace *self, PyObject *value)
|
|||
if (mathutils_array_parse(self->f->no, 3, 3, value, "BMFace.normal") != -1) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_bmface_material_index_doc, "The face's material index.\n\n:type: int");
|
||||
|
@ -481,10 +477,9 @@ static int bpy_bmface_material_index_set(BPy_BMFace *self, PyObject *value)
|
|||
PyErr_SetString(PyExc_ValueError, "material index outside of usable range (0 - 32766)");
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
|
||||
self->f->mat_nr = (short)param;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Loop
|
||||
|
@ -586,9 +581,8 @@ static PyObject *bpy_bmfaceseq_active_get(BPy_BMElemSeq *self, void *UNUSED(clos
|
|||
if (bm->act_face) {
|
||||
return BPy_BMElem_CreatePyObject(bm, (BMHeader *)bm->act_face);
|
||||
}
|
||||
else {
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
static int bpy_bmfaceseq_active_set(BPy_BMElem *self, PyObject *value, void *UNUSED(closure))
|
||||
|
@ -598,18 +592,17 @@ static int bpy_bmfaceseq_active_set(BPy_BMElem *self, PyObject *value, void *UNU
|
|||
bm->act_face = NULL;
|
||||
return 0;
|
||||
}
|
||||
else if (BPy_BMFace_Check(value)) {
|
||||
if (BPy_BMFace_Check(value)) {
|
||||
BPY_BM_CHECK_SOURCE_INT(bm, "faces.active = f", value);
|
||||
|
||||
bm->act_face = ((BPy_BMFace *)value)->f;
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"faces.active = f: expected BMFace or None, not %.200s",
|
||||
Py_TYPE(value)->tp_name);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
static PyGetSetDef bpy_bmesh_getseters[] = {
|
||||
|
@ -971,10 +964,9 @@ static PyObject *bpy_bmesh_copy(BPy_BMesh *self)
|
|||
if (bm_copy) {
|
||||
return BPy_BMesh_CreatePyObject(bm_copy, BPY_BMFLAG_NOP);
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_SetString(PyExc_SystemError, "Unable to copy BMesh, internal error");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_bmesh_clear_doc,
|
||||
|
@ -1141,10 +1133,9 @@ static PyObject *bpy_bmesh_from_object(BPy_BMesh *self, PyObject *args, PyObject
|
|||
"evaluation mode is RENDER");
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
||||
me_eval = mesh_create_eval_final_render(depsgraph, scene_eval, ob_eval, &data_masks);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (use_cage) {
|
||||
me_eval = mesh_get_eval_deform(depsgraph, scene_eval, ob_eval, &data_masks);
|
||||
|
@ -1161,7 +1152,7 @@ static PyObject *bpy_bmesh_from_object(BPy_BMesh *self, PyObject *args, PyObject
|
|||
"from_object(...): cage arg is unsupported when deform=False");
|
||||
return NULL;
|
||||
}
|
||||
else if (use_render) {
|
||||
if (use_render) {
|
||||
me_eval = mesh_create_eval_no_deform_render(depsgraph, scene_eval, ob, &data_masks);
|
||||
}
|
||||
else {
|
||||
|
@ -1329,7 +1320,7 @@ static PyObject *bpy_bmesh_transform(BPy_BMElem *self, PyObject *args, PyObject
|
|||
&filter)) {
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
||||
BMVert *eve;
|
||||
BMIter iter;
|
||||
void *mat_ptr;
|
||||
|
@ -1337,14 +1328,13 @@ static PyObject *bpy_bmesh_transform(BPy_BMElem *self, PyObject *args, PyObject
|
|||
if (BaseMath_ReadCallback(mat) == -1) {
|
||||
return NULL;
|
||||
}
|
||||
else if (mat->num_col != 4 || mat->num_row != 4) {
|
||||
if (mat->num_col != 4 || mat->num_row != 4) {
|
||||
PyErr_SetString(PyExc_ValueError, "expected a 4x4 matrix");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (filter != NULL &&
|
||||
PyC_FlagSet_ToBitfield(bpy_bm_hflag_all_flags, filter, &filter_flags, "bm.transform") ==
|
||||
-1) {
|
||||
if (filter != NULL && PyC_FlagSet_ToBitfield(
|
||||
bpy_bm_hflag_all_flags, filter, &filter_flags, "bm.transform") == -1) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1363,7 +1353,6 @@ static PyObject *bpy_bmesh_transform(BPy_BMElem *self, PyObject *args, PyObject
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
@ -1388,9 +1377,8 @@ static PyObject *bpy_bmesh_calc_volume(BPy_BMElem *self, PyObject *args, PyObjec
|
|||
args, kw, "|O!:calc_volume", (char **)kwlist, &PyBool_Type, &is_signed)) {
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
||||
return PyFloat_FromDouble(BM_mesh_calc_volume(self->bm, is_signed != Py_False));
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_bmesh_calc_loop_triangles_doc,
|
||||
|
@ -1531,7 +1519,7 @@ static PyObject *bpy_bmvert_copy_from_vert_interp(BPy_BMVert *self, PyObject *ar
|
|||
if (!PyArg_ParseTuple(args, "Of:BMVert.copy_from_vert_interp", &vert_seq, &fac)) {
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
||||
BMesh *bm = self->bm;
|
||||
BMVert **vert_array = NULL;
|
||||
Py_ssize_t vert_seq_len; /* always 2 */
|
||||
|
@ -1554,7 +1542,6 @@ static PyObject *bpy_bmvert_copy_from_vert_interp(BPy_BMVert *self, PyObject *ar
|
|||
|
||||
PyMem_FREE(vert_array);
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_bmvert_copy_from_face_interp_doc,
|
||||
|
@ -1574,7 +1561,7 @@ static PyObject *bpy_bmvert_copy_from_face_interp(BPy_BMVert *self, PyObject *ar
|
|||
if (!PyArg_ParseTuple(args, "O!:BMVert.copy_from_face_interp", &BPy_BMFace_Type, &py_face)) {
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
||||
BMesh *bm = self->bm;
|
||||
|
||||
BPY_BM_CHECK_SOURCE_OBJ(bm, "copy_from_face_interp()", py_face);
|
||||
|
@ -1582,7 +1569,6 @@ static PyObject *bpy_bmvert_copy_from_face_interp(BPy_BMVert *self, PyObject *ar
|
|||
BM_vert_interp_from_face(bm, self->v, py_face->f);
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_bmvert_calc_edge_angle_doc,
|
||||
|
@ -1615,13 +1601,12 @@ static PyObject *bpy_bmvert_calc_edge_angle(BPy_BMVert *self, PyObject *args)
|
|||
Py_INCREF(fallback);
|
||||
return fallback;
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"BMVert.calc_edge_angle(): "
|
||||
"vert must connect to exactly 2 edges");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return PyFloat_FromDouble(angle);
|
||||
}
|
||||
|
@ -1697,13 +1682,12 @@ static PyObject *bpy_bmedge_calc_face_angle(BPy_BMEdge *self, PyObject *args)
|
|||
Py_INCREF(fallback);
|
||||
return fallback;
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"BMEdge.calc_face_angle(): "
|
||||
"edge doesn't use 2 faces");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return PyFloat_FromDouble(angle);
|
||||
}
|
||||
|
@ -1737,13 +1721,12 @@ static PyObject *bpy_bmedge_calc_face_angle_signed(BPy_BMEdge *self, PyObject *a
|
|||
Py_INCREF(fallback);
|
||||
return fallback;
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"BMEdge.calc_face_angle_signed(): "
|
||||
"edge doesn't use 2 faces");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return PyFloat_FromDouble(angle);
|
||||
}
|
||||
|
@ -1767,13 +1750,12 @@ static PyObject *bpy_bmedge_calc_tangent(BPy_BMEdge *self, PyObject *args)
|
|||
if (!PyArg_ParseTuple(args, "O!:BMEdge.calc_face_tangent", &BPy_BMLoop_Type, &py_loop)) {
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
||||
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_calc_face_tangent(self->e, py_loop->l, vec);
|
||||
return Vector_CreatePyObject(vec, 3, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(
|
||||
|
@ -1805,10 +1787,9 @@ static PyObject *bpy_bmedge_other_vert(BPy_BMEdge *self, BPy_BMVert *value)
|
|||
if (other) {
|
||||
return BPy_BMVert_CreatePyObject(self->bm, other);
|
||||
}
|
||||
else {
|
||||
|
||||
/* could raise an exception here */
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_bmedge_normal_update_doc,
|
||||
|
@ -1852,7 +1833,7 @@ static PyObject *bpy_bmface_copy_from_face_interp(BPy_BMFace *self, PyObject *ar
|
|||
&do_vertex)) {
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
||||
BMesh *bm = self->bm;
|
||||
|
||||
BPY_BM_CHECK_SOURCE_OBJ(bm, "BMFace.copy_from_face_interp(face)", py_face);
|
||||
|
@ -1860,7 +1841,6 @@ static PyObject *bpy_bmface_copy_from_face_interp(BPy_BMFace *self, PyObject *ar
|
|||
BM_face_interp_from_face(bm, self->f, py_face->f, do_vertex);
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_bmface_copy_doc,
|
||||
|
@ -1901,11 +1881,9 @@ static PyObject *bpy_bmface_copy(BPy_BMFace *self, PyObject *args, PyObject *kw)
|
|||
if (f_cpy) {
|
||||
return BPy_BMFace_CreatePyObject(bm, f_cpy);
|
||||
}
|
||||
else {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"BMFace.copy(): couldn't create the new face, internal error");
|
||||
|
||||
PyErr_SetString(PyExc_ValueError, "BMFace.copy(): couldn't create the new face, internal error");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_bmface_calc_area_doc,
|
||||
|
@ -2109,7 +2087,7 @@ static PyObject *bpy_bmloop_copy_from_face_interp(BPy_BMLoop *self, PyObject *ar
|
|||
&do_multires)) {
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
||||
BMesh *bm = self->bm;
|
||||
|
||||
BPY_BM_CHECK_SOURCE_OBJ(bm, "BMLoop.copy_from_face_interp(face)", py_face);
|
||||
|
@ -2117,7 +2095,6 @@ static PyObject *bpy_bmloop_copy_from_face_interp(BPy_BMLoop *self, PyObject *ar
|
|||
BM_loop_interp_from_face(bm, self->l, py_face->f, do_vertex, do_multires);
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_bmloop_calc_angle_doc,
|
||||
|
@ -2190,7 +2167,7 @@ static PyObject *bpy_bmvertseq_new(BPy_BMElemSeq *self, PyObject *args)
|
|||
if (!PyArg_ParseTuple(args, "|OO!:verts.new", &py_co, &BPy_BMVert_Type, &py_vert_example)) {
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
||||
BMesh *bm = self->bm;
|
||||
BMVert *v;
|
||||
float co[3] = {0.0f, 0.0f, 0.0f};
|
||||
|
@ -2216,7 +2193,6 @@ static PyObject *bpy_bmvertseq_new(BPy_BMElemSeq *self, PyObject *args)
|
|||
}
|
||||
|
||||
return BPy_BMVert_CreatePyObject(bm, v);
|
||||
}
|
||||
}
|
||||
|
||||
/* Edge Seq
|
||||
|
@ -2242,7 +2218,7 @@ static PyObject *bpy_bmedgeseq_new(BPy_BMElemSeq *self, PyObject *args)
|
|||
if (!PyArg_ParseTuple(args, "O|O!:edges.new", &vert_seq, &BPy_BMEdge_Type, &py_edge_example)) {
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
||||
BMesh *bm = self->bm;
|
||||
BMEdge *e;
|
||||
BMVert **vert_array = NULL;
|
||||
|
@ -2279,12 +2255,11 @@ static PyObject *bpy_bmedgeseq_new(BPy_BMElemSeq *self, PyObject *args)
|
|||
|
||||
ret = BPy_BMEdge_CreatePyObject(bm, e);
|
||||
|
||||
cleanup:
|
||||
cleanup:
|
||||
if (vert_array) {
|
||||
PyMem_FREE(vert_array);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
/* Face Seq
|
||||
|
@ -2310,7 +2285,7 @@ static PyObject *bpy_bmfaceseq_new(BPy_BMElemSeq *self, PyObject *args)
|
|||
if (!PyArg_ParseTuple(args, "O|O!:faces.new", &vert_seq, &BPy_BMFace_Type, &py_face_example)) {
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
||||
BMesh *bm = self->bm;
|
||||
Py_ssize_t vert_seq_len;
|
||||
|
||||
|
@ -2356,12 +2331,11 @@ static PyObject *bpy_bmfaceseq_new(BPy_BMElemSeq *self, PyObject *args)
|
|||
ret = BPy_BMFace_CreatePyObject(bm, f_new);
|
||||
|
||||
/* pass through */
|
||||
cleanup:
|
||||
cleanup:
|
||||
if (vert_array) {
|
||||
PyMem_FREE(vert_array);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
/* Elem Seq
|
||||
|
@ -2378,7 +2352,7 @@ static PyObject *bpy_bmvertseq_remove(BPy_BMElemSeq *self, BPy_BMVert *value)
|
|||
if (!BPy_BMVert_Check(value)) {
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
||||
BMesh *bm = self->bm;
|
||||
|
||||
BPY_BM_CHECK_SOURCE_OBJ(bm, "verts.remove(vert)", value);
|
||||
|
@ -2387,7 +2361,6 @@ static PyObject *bpy_bmvertseq_remove(BPy_BMElemSeq *self, BPy_BMVert *value)
|
|||
bpy_bm_generic_invalidate((BPy_BMGeneric *)value);
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_bmedgeseq_remove_doc,
|
||||
|
@ -2401,7 +2374,7 @@ static PyObject *bpy_bmedgeseq_remove(BPy_BMElemSeq *self, BPy_BMEdge *value)
|
|||
if (!BPy_BMEdge_Check(value)) {
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
||||
BMesh *bm = self->bm;
|
||||
|
||||
BPY_BM_CHECK_SOURCE_OBJ(bm, "edges.remove(edges)", value);
|
||||
|
@ -2410,7 +2383,6 @@ static PyObject *bpy_bmedgeseq_remove(BPy_BMElemSeq *self, BPy_BMEdge *value)
|
|||
bpy_bm_generic_invalidate((BPy_BMGeneric *)value);
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_bmfaceseq_remove_doc,
|
||||
|
@ -2424,7 +2396,7 @@ static PyObject *bpy_bmfaceseq_remove(BPy_BMElemSeq *self, BPy_BMFace *value)
|
|||
if (!BPy_BMFace_Check(value)) {
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
||||
BMesh *bm = self->bm;
|
||||
|
||||
BPY_BM_CHECK_SOURCE_OBJ(bm, "faces.remove(face)", value);
|
||||
|
@ -2433,7 +2405,6 @@ static PyObject *bpy_bmfaceseq_remove(BPy_BMElemSeq *self, BPy_BMFace *value)
|
|||
bpy_bm_generic_invalidate((BPy_BMGeneric *)value);
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_bmedgeseq_get__method_doc,
|
||||
|
@ -2456,7 +2427,7 @@ static PyObject *bpy_bmedgeseq_get__method(BPy_BMElemSeq *self, PyObject *args)
|
|||
if (!PyArg_ParseTuple(args, "O|O:edges.get", &vert_seq, &fallback)) {
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
||||
BMesh *bm = self->bm;
|
||||
BMEdge *e;
|
||||
BMVert **vert_array = NULL;
|
||||
|
@ -2480,7 +2451,6 @@ static PyObject *bpy_bmedgeseq_get__method(BPy_BMElemSeq *self, PyObject *args)
|
|||
|
||||
PyMem_FREE(vert_array);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_bmfaceseq_get__method_doc,
|
||||
|
@ -2503,7 +2473,7 @@ static PyObject *bpy_bmfaceseq_get__method(BPy_BMElemSeq *self, PyObject *args)
|
|||
if (!PyArg_ParseTuple(args, "O|O:faces.get", &vert_seq, &fallback)) {
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
||||
BMesh *bm = self->bm;
|
||||
BMFace *f = NULL;
|
||||
BMVert **vert_array = NULL;
|
||||
|
@ -2528,7 +2498,6 @@ static PyObject *bpy_bmfaceseq_get__method(BPy_BMElemSeq *self, PyObject *args)
|
|||
|
||||
PyMem_FREE(vert_array);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(
|
||||
|
@ -2651,12 +2620,11 @@ static int bpy_bmelemseq_sort_cmp_by_keys_ascending(const void *index1_v,
|
|||
if (keys[*index1] < keys[*index2]) {
|
||||
return -1;
|
||||
}
|
||||
else if (keys[*index1] > keys[*index2]) {
|
||||
if (keys[*index1] > keys[*index2]) {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int bpy_bmelemseq_sort_cmp_by_keys_descending(const void *index1_v,
|
||||
|
@ -3260,21 +3228,21 @@ static PyObject *bpy_bmelemseq_subscript(BPy_BMElemSeq *self, PyObject *key)
|
|||
}
|
||||
return bpy_bmelemseq_subscript_int(self, i);
|
||||
}
|
||||
else if (PySlice_Check(key)) {
|
||||
if (PySlice_Check(key)) {
|
||||
PySliceObject *key_slice = (PySliceObject *)key;
|
||||
Py_ssize_t step = 1;
|
||||
|
||||
if (key_slice->step != Py_None && !_PyEval_SliceIndex(key, &step)) {
|
||||
return NULL;
|
||||
}
|
||||
else if (step != 1) {
|
||||
if (step != 1) {
|
||||
PyErr_SetString(PyExc_TypeError, "BMElemSeq[slice]: slice steps not supported");
|
||||
return NULL;
|
||||
}
|
||||
else if (key_slice->start == Py_None && key_slice->stop == Py_None) {
|
||||
if (key_slice->start == Py_None && key_slice->stop == Py_None) {
|
||||
return bpy_bmelemseq_subscript_slice(self, 0, PY_SSIZE_T_MAX);
|
||||
}
|
||||
else {
|
||||
|
||||
Py_ssize_t start = 0, stop = PY_SSIZE_T_MAX;
|
||||
|
||||
/* avoid PySlice_GetIndicesEx because it needs to know the length ahead of time. */
|
||||
|
@ -3299,15 +3267,12 @@ static PyObject *bpy_bmelemseq_subscript(BPy_BMElemSeq *self, PyObject *key)
|
|||
if (stop - start <= 0) {
|
||||
return PyList_New(0);
|
||||
}
|
||||
else {
|
||||
|
||||
return bpy_bmelemseq_subscript_slice(self, start, stop);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_SetString(PyExc_AttributeError, "BMElemSeq[key]: invalid key, key must be an int");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static int bpy_bmelemseq_contains(BPy_BMElemSeq *self, PyObject *value)
|
||||
|
@ -3395,9 +3360,8 @@ static PyObject *bpy_bmiter_next(BPy_BMIter *self)
|
|||
PyErr_SetNone(PyExc_StopIteration);
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
||||
return (PyObject *)BPy_BMElem_CreatePyObject(self->bm, ele);
|
||||
}
|
||||
}
|
||||
|
||||
/* Dealloc Functions
|
||||
|
@ -3532,9 +3496,8 @@ static PyObject *bpy_bmesh_repr(BPy_BMesh *self)
|
|||
bm->totface,
|
||||
bm->totloop);
|
||||
}
|
||||
else {
|
||||
|
||||
return PyUnicode_FromFormat("<BMesh dead at %p>", self);
|
||||
}
|
||||
}
|
||||
|
||||
static PyObject *bpy_bmvert_repr(BPy_BMVert *self)
|
||||
|
@ -3545,9 +3508,8 @@ static PyObject *bpy_bmvert_repr(BPy_BMVert *self)
|
|||
BMVert *v = self->v;
|
||||
return PyUnicode_FromFormat("<BMVert(%p), index=%d>", v, BM_elem_index_get(v));
|
||||
}
|
||||
else {
|
||||
|
||||
return PyUnicode_FromFormat("<BMVert dead at %p>", self);
|
||||
}
|
||||
}
|
||||
|
||||
static PyObject *bpy_bmedge_repr(BPy_BMEdge *self)
|
||||
|
@ -3564,9 +3526,8 @@ static PyObject *bpy_bmedge_repr(BPy_BMEdge *self)
|
|||
e->v2,
|
||||
BM_elem_index_get(e->v2));
|
||||
}
|
||||
else {
|
||||
|
||||
return PyUnicode_FromFormat("<BMEdge dead at %p>", self);
|
||||
}
|
||||
}
|
||||
|
||||
static PyObject *bpy_bmface_repr(BPy_BMFace *self)
|
||||
|
@ -3578,9 +3539,8 @@ static PyObject *bpy_bmface_repr(BPy_BMFace *self)
|
|||
return PyUnicode_FromFormat(
|
||||
"<BMFace(%p), index=%d, totverts=%d>", f, BM_elem_index_get(f), f->len);
|
||||
}
|
||||
else {
|
||||
|
||||
return PyUnicode_FromFormat("<BMFace dead at %p>", self);
|
||||
}
|
||||
}
|
||||
|
||||
static PyObject *bpy_bmloop_repr(BPy_BMLoop *self)
|
||||
|
@ -3599,9 +3559,8 @@ static PyObject *bpy_bmloop_repr(BPy_BMLoop *self)
|
|||
l->f,
|
||||
BM_elem_index_get(l->f));
|
||||
}
|
||||
else {
|
||||
|
||||
return PyUnicode_FromFormat("<BMLoop dead at %p>", self);
|
||||
}
|
||||
}
|
||||
|
||||
/* Types
|
||||
|
@ -4054,12 +4013,10 @@ int bpy_bm_generic_valid_check(BPy_BMGeneric *self)
|
|||
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
PyErr_Format(PyExc_ReferenceError,
|
||||
"BMesh data of type %.200s has been removed",
|
||||
Py_TYPE(self)->tp_name);
|
||||
|
||||
PyErr_Format(
|
||||
PyExc_ReferenceError, "BMesh data of type %.200s has been removed", Py_TYPE(self)->tp_name);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int bpy_bm_generic_valid_check_source(BMesh *bm_source,
|
||||
|
@ -4079,7 +4036,7 @@ int bpy_bm_generic_valid_check_source(BMesh *bm_source,
|
|||
if (UNLIKELY(ret == -1)) {
|
||||
break;
|
||||
}
|
||||
else {
|
||||
|
||||
if (UNLIKELY(py_bm_elem->bm != bm_source)) {
|
||||
/* could give more info here */
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
|
@ -4091,7 +4048,6 @@ int bpy_bm_generic_valid_check_source(BMesh *bm_source,
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -67,10 +67,9 @@ static CustomDataLayer *bpy_bmlayeritem_get(BPy_BMLayerItem *self)
|
|||
if (index_absolute != -1) {
|
||||
return &data->layers[index_absolute];
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_SetString(PyExc_RuntimeError, "layer has become invalid");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* py-type definitions
|
||||
|
@ -142,9 +141,8 @@ static PyObject *bpy_bmlayercollection_active_get(BPy_BMLayerItem *self, void *U
|
|||
if (index != -1) {
|
||||
return BPy_BMLayerItem_CreatePyObject(self->bm, self->htype, self->type, index);
|
||||
}
|
||||
else {
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(
|
||||
|
@ -169,9 +167,8 @@ static PyObject *bpy_bmlayeritem_name_get(BPy_BMLayerItem *self, void *UNUSED(fl
|
|||
if (layer) {
|
||||
return PyUnicode_FromString(layer->name);
|
||||
}
|
||||
else {
|
||||
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static PyGetSetDef bpy_bmlayeraccess_vert_getseters[] = {
|
||||
|
@ -617,7 +614,7 @@ static PyObject *bpy_bmlayercollection_get(BPy_BMLayerCollection *self, PyObject
|
|||
if (!PyArg_ParseTuple(args, "s|O:get", &key, &def)) {
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
||||
CustomData *data;
|
||||
int index;
|
||||
|
||||
|
@ -627,7 +624,6 @@ static PyObject *bpy_bmlayercollection_get(BPy_BMLayerCollection *self, PyObject
|
|||
if (index != -1) {
|
||||
return BPy_BMLayerItem_CreatePyObject(self->bm, self->htype, self->type, index);
|
||||
}
|
||||
}
|
||||
|
||||
return Py_INCREF_RET(def);
|
||||
}
|
||||
|
@ -689,10 +685,9 @@ static PyObject *bpy_bmlayercollection_subscript_str(BPy_BMLayerCollection *self
|
|||
if (index != -1) {
|
||||
return BPy_BMLayerItem_CreatePyObject(self->bm, self->htype, self->type, index);
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_Format(PyExc_KeyError, "BMLayerCollection[key]: key \"%.200s\" not found", keyname);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static PyObject *bpy_bmlayercollection_subscript_int(BPy_BMLayerCollection *self, int keynum)
|
||||
|
@ -750,28 +745,28 @@ static PyObject *bpy_bmlayercollection_subscript(BPy_BMLayerCollection *self, Py
|
|||
if (PyUnicode_Check(key)) {
|
||||
return bpy_bmlayercollection_subscript_str(self, _PyUnicode_AsString(key));
|
||||
}
|
||||
else if (PyIndex_Check(key)) {
|
||||
if (PyIndex_Check(key)) {
|
||||
Py_ssize_t i = PyNumber_AsSsize_t(key, PyExc_IndexError);
|
||||
if (i == -1 && PyErr_Occurred()) {
|
||||
return NULL;
|
||||
}
|
||||
return bpy_bmlayercollection_subscript_int(self, i);
|
||||
}
|
||||
else if (PySlice_Check(key)) {
|
||||
if (PySlice_Check(key)) {
|
||||
PySliceObject *key_slice = (PySliceObject *)key;
|
||||
Py_ssize_t step = 1;
|
||||
|
||||
if (key_slice->step != Py_None && !_PyEval_SliceIndex(key, &step)) {
|
||||
return NULL;
|
||||
}
|
||||
else if (step != 1) {
|
||||
if (step != 1) {
|
||||
PyErr_SetString(PyExc_TypeError, "BMLayerCollection[slice]: slice steps not supported");
|
||||
return NULL;
|
||||
}
|
||||
else if (key_slice->start == Py_None && key_slice->stop == Py_None) {
|
||||
if (key_slice->start == Py_None && key_slice->stop == Py_None) {
|
||||
return bpy_bmlayercollection_subscript_slice(self, 0, PY_SSIZE_T_MAX);
|
||||
}
|
||||
else {
|
||||
|
||||
Py_ssize_t start = 0, stop = PY_SSIZE_T_MAX;
|
||||
|
||||
/* avoid PySlice_GetIndicesEx because it needs to know the length ahead of time. */
|
||||
|
@ -796,16 +791,12 @@ static PyObject *bpy_bmlayercollection_subscript(BPy_BMLayerCollection *self, Py
|
|||
if (stop - start <= 0) {
|
||||
return PyTuple_New(0);
|
||||
}
|
||||
else {
|
||||
|
||||
return bpy_bmlayercollection_subscript_slice(self, start, stop);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
PyErr_SetString(PyExc_AttributeError,
|
||||
"BMLayerCollection[key]: invalid key, key must be an int");
|
||||
|
||||
PyErr_SetString(PyExc_AttributeError, "BMLayerCollection[key]: invalid key, key must be an int");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static int bpy_bmlayercollection_contains(BPy_BMLayerCollection *self, PyObject *value)
|
||||
|
@ -1024,11 +1015,11 @@ static void *bpy_bmlayeritem_ptr_get(BPy_BMElem *py_ele, BPy_BMLayerItem *py_lay
|
|||
PyErr_SetString(PyExc_AttributeError, "BMElem[key]: invalid key, must be a BMLayerItem");
|
||||
return NULL;
|
||||
}
|
||||
else if (UNLIKELY(py_ele->bm != py_layer->bm)) {
|
||||
if (UNLIKELY(py_ele->bm != py_layer->bm)) {
|
||||
PyErr_SetString(PyExc_ValueError, "BMElem[layer]: layer is from another mesh");
|
||||
return NULL;
|
||||
}
|
||||
else if (UNLIKELY(ele->head.htype != py_layer->htype)) {
|
||||
if (UNLIKELY(ele->head.htype != py_layer->htype)) {
|
||||
char namestr_1[32], namestr_2[32];
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"Layer/Element type mismatch, expected %.200s got layer type %.200s",
|
||||
|
@ -1046,9 +1037,8 @@ static void *bpy_bmlayeritem_ptr_get(BPy_BMElem *py_ele, BPy_BMLayerItem *py_lay
|
|||
PyErr_SetString(PyExc_KeyError, "BMElem[key]: layer not found");
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -65,9 +65,8 @@ static int bpy_bmloopuv_uv_set(BPy_BMLoopUV *self, PyObject *value, void *UNUSED
|
|||
copy_v2_v2(self->data->uv, tvec);
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_bmloopuv_flag__pin_uv_doc, "UV pin state.\n\n:type: boolean");
|
||||
|
@ -136,10 +135,9 @@ int BPy_BMLoopUV_AssignPyObject(struct MLoopUV *mloopuv, PyObject *value)
|
|||
PyErr_Format(PyExc_TypeError, "expected BMLoopUV, not a %.200s", Py_TYPE(value)->tp_name);
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
|
||||
*((MLoopUV *)mloopuv) = *(((BPy_BMLoopUV *)value)->data);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
PyObject *BPy_BMLoopUV_CreatePyObject(struct MLoopUV *mloopuv)
|
||||
|
@ -174,9 +172,8 @@ static int bpy_bmvertskin_radius_set(BPy_BMVertSkin *self, PyObject *value, void
|
|||
copy_v2_v2(self->data->radius, tvec);
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_bmvertskin_flag__use_root_doc,
|
||||
|
@ -251,10 +248,9 @@ int BPy_BMVertSkin_AssignPyObject(struct MVertSkin *mvertskin, PyObject *value)
|
|||
PyErr_Format(PyExc_TypeError, "expected BMVertSkin, not a %.200s", Py_TYPE(value)->tp_name);
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
|
||||
*((MVertSkin *)mvertskin) = *(((BPy_BMVertSkin *)value)->data);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
PyObject *BPy_BMVertSkin_CreatePyObject(struct MVertSkin *mvertskin)
|
||||
|
@ -351,9 +347,8 @@ int BPy_BMLoopColor_AssignPyObject(struct MLoopCol *mloopcol, PyObject *value)
|
|||
mloopcol_from_float(mloopcol, tvec);
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
PyObject *BPy_BMLoopColor_CreatePyObject(struct MLoopCol *data)
|
||||
|
@ -416,7 +411,7 @@ static PyObject *bpy_bmdeformvert_subscript(BPy_BMDeformVert *self, PyObject *ke
|
|||
if (i == -1 && PyErr_Occurred()) {
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
||||
MDeformWeight *dw = BKE_defvert_find_index(self->data, i);
|
||||
|
||||
if (dw == NULL) {
|
||||
|
@ -425,16 +420,13 @@ static PyObject *bpy_bmdeformvert_subscript(BPy_BMDeformVert *self, PyObject *ke
|
|||
"key not found");
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
||||
return PyFloat_FromDouble(dw->weight);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_Format(
|
||||
PyExc_TypeError, "BMDeformVert keys must be integers, not %.200s", Py_TYPE(key)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static int bpy_bmdeformvert_ass_subscript(BPy_BMDeformVert *self, PyObject *key, PyObject *value)
|
||||
|
@ -455,7 +447,7 @@ static int bpy_bmdeformvert_ass_subscript(BPy_BMDeformVert *self, PyObject *key,
|
|||
"weight keys can't be negative");
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
|
||||
MDeformWeight *dw = BKE_defvert_ensure_index(self->data, i);
|
||||
const float f = PyFloat_AsDouble(value);
|
||||
if (f == -1 && PyErr_Occurred()) { // parsed key not a number
|
||||
|
@ -467,7 +459,6 @@ static int bpy_bmdeformvert_ass_subscript(BPy_BMDeformVert *self, PyObject *key,
|
|||
|
||||
dw->weight = clamp_f(f, 0.0f, 1.0f);
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* del dvert[group_index] */
|
||||
MDeformWeight *dw = BKE_defvert_find_index(self->data, i);
|
||||
|
@ -482,11 +473,10 @@ static int bpy_bmdeformvert_ass_subscript(BPy_BMDeformVert *self, PyObject *key,
|
|||
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_Format(
|
||||
PyExc_TypeError, "BMDeformVert keys must be integers, not %.200s", Py_TYPE(key)->tp_name);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
static int bpy_bmdeformvert_contains(BPy_BMDeformVert *self, PyObject *value)
|
||||
|
@ -616,16 +606,14 @@ static PyObject *bpy_bmdeformvert_get(BPy_BMDeformVert *self, PyObject *args)
|
|||
if (!PyArg_ParseTuple(args, "i|O:get", &key, &def)) {
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
||||
MDeformWeight *dw = BKE_defvert_find_index(self->data, key);
|
||||
|
||||
if (dw) {
|
||||
return PyFloat_FromDouble(dw->weight);
|
||||
}
|
||||
else {
|
||||
|
||||
return Py_INCREF_RET(def);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_bmdeformvert_clear_doc,
|
||||
|
@ -675,13 +663,12 @@ int BPy_BMDeformVert_AssignPyObject(struct MDeformVert *dvert, PyObject *value)
|
|||
PyErr_Format(PyExc_TypeError, "expected BMDeformVert, not a %.200s", Py_TYPE(value)->tp_name);
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
|
||||
MDeformVert *dvert_src = ((BPy_BMDeformVert *)value)->data;
|
||||
if (LIKELY(dvert != dvert_src)) {
|
||||
BKE_defvert_copy(dvert, dvert_src);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
PyObject *BPy_BMDeformVert_CreatePyObject(struct MDeformVert *dvert)
|
||||
|
|
|
@ -51,9 +51,8 @@ static PyObject *bpy_bmeditselseq_active_get(BPy_BMEditSelSeq *self, void *UNUSE
|
|||
if ((ese = self->bm->selected.last)) {
|
||||
return BPy_BMElem_CreatePyObject(self->bm, &ese->ele->head);
|
||||
}
|
||||
else {
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
static PyGetSetDef bpy_bmeditselseq_getseters[] = {
|
||||
|
@ -196,10 +195,9 @@ static PyObject *bpy_bmeditselseq_subscript_int(BPy_BMEditSelSeq *self, int keyn
|
|||
if (ese) {
|
||||
return BPy_BMElem_CreatePyObject(self->bm, &ese->ele->head);
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_Format(PyExc_IndexError, "BMElemSeq[index]: index %d out of range", keynum);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static PyObject *bpy_bmeditselseq_subscript_slice(BPy_BMEditSelSeq *self,
|
||||
|
@ -254,21 +252,21 @@ static PyObject *bpy_bmeditselseq_subscript(BPy_BMEditSelSeq *self, PyObject *ke
|
|||
}
|
||||
return bpy_bmeditselseq_subscript_int(self, i);
|
||||
}
|
||||
else if (PySlice_Check(key)) {
|
||||
if (PySlice_Check(key)) {
|
||||
PySliceObject *key_slice = (PySliceObject *)key;
|
||||
Py_ssize_t step = 1;
|
||||
|
||||
if (key_slice->step != Py_None && !_PyEval_SliceIndex(key, &step)) {
|
||||
return NULL;
|
||||
}
|
||||
else if (step != 1) {
|
||||
if (step != 1) {
|
||||
PyErr_SetString(PyExc_TypeError, "BMElemSeq[slice]: slice steps not supported");
|
||||
return NULL;
|
||||
}
|
||||
else if (key_slice->start == Py_None && key_slice->stop == Py_None) {
|
||||
if (key_slice->start == Py_None && key_slice->stop == Py_None) {
|
||||
return bpy_bmeditselseq_subscript_slice(self, 0, PY_SSIZE_T_MAX);
|
||||
}
|
||||
else {
|
||||
|
||||
Py_ssize_t start = 0, stop = PY_SSIZE_T_MAX;
|
||||
|
||||
/* avoid PySlice_GetIndicesEx because it needs to know the length ahead of time. */
|
||||
|
@ -293,15 +291,12 @@ static PyObject *bpy_bmeditselseq_subscript(BPy_BMEditSelSeq *self, PyObject *ke
|
|||
if (stop - start <= 0) {
|
||||
return PyList_New(0);
|
||||
}
|
||||
else {
|
||||
|
||||
return bpy_bmeditselseq_subscript_slice(self, start, stop);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_SetString(PyExc_AttributeError, "BMElemSeq[key]: invalid key, key must be an int");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static int bpy_bmeditselseq_contains(BPy_BMEditSelSeq *self, PyObject *value)
|
||||
|
@ -358,10 +353,9 @@ static PyObject *bpy_bmeditseliter_next(BPy_BMEditSelIter *self)
|
|||
PyErr_SetNone(PyExc_StopIteration);
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
||||
self->ese = ese->next;
|
||||
return (PyObject *)BPy_BMElem_CreatePyObject(self->bm, &ese->ele->head);
|
||||
}
|
||||
}
|
||||
|
||||
PyTypeObject BPy_BMEditSelSeq_Type;
|
||||
|
|
|
@ -91,11 +91,10 @@ static PyObject *bpy_bm_utils_vert_collapse_edge(PyObject *UNUSED(self), PyObjec
|
|||
if (e_new) {
|
||||
return BPy_BMEdge_CreatePyObject(bm, e_new);
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"vert_collapse_edge(vert, edge): no new edge created, internal error");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_bm_utils_vert_collapse_faces_doc,
|
||||
|
@ -158,11 +157,10 @@ static PyObject *bpy_bm_utils_vert_collapse_faces(PyObject *UNUSED(self), PyObje
|
|||
if (e_new) {
|
||||
return BPy_BMEdge_CreatePyObject(bm, e_new);
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"vert_collapse_faces(vert, edge): no new edge created, internal error");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_bm_utils_vert_dissolve_doc,
|
||||
|
@ -360,11 +358,10 @@ static PyObject *bpy_bm_utils_edge_split(PyObject *UNUSED(self), PyObject *args)
|
|||
ret, BPy_BMEdge_CreatePyObject(bm, e_new), BPy_BMVert_CreatePyObject(bm, v_new));
|
||||
return ret;
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"edge_split(edge, vert): couldn't split the edge, internal error");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_bm_utils_edge_rotate_doc,
|
||||
|
@ -401,9 +398,8 @@ static PyObject *bpy_bm_utils_edge_rotate(PyObject *UNUSED(self), PyObject *args
|
|||
if (e_new) {
|
||||
return BPy_BMEdge_CreatePyObject(bm, e_new);
|
||||
}
|
||||
else {
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(
|
||||
|
@ -534,10 +530,9 @@ static PyObject *bpy_bm_utils_face_split(PyObject *UNUSED(self), PyObject *args,
|
|||
ret, BPy_BMFace_CreatePyObject(bm, f_new), BPy_BMLoop_CreatePyObject(bm, l_new));
|
||||
return ret;
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_SetString(PyExc_ValueError, "face_split(...): couldn't split the face, internal error");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_bm_utils_face_split_edgenet_doc,
|
||||
|
@ -617,11 +612,10 @@ static PyObject *bpy_bm_utils_face_split_edgenet(PyObject *UNUSED(self),
|
|||
}
|
||||
return ret;
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"face_split_edgenet(...): couldn't split the face, internal error");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_bm_utils_face_join_doc,
|
||||
|
@ -664,9 +658,8 @@ static PyObject *bpy_bm_utils_face_join(PyObject *UNUSED(self), PyObject *args)
|
|||
if (f_new) {
|
||||
return BPy_BMFace_CreatePyObject(bm, f_new);
|
||||
}
|
||||
else {
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(
|
||||
|
@ -721,9 +714,8 @@ static PyObject *bpy_bm_utils_face_vert_separate(PyObject *UNUSED(self), PyObjec
|
|||
if (v_new != v_old) {
|
||||
return BPy_BMVert_CreatePyObject(bm, v_new);
|
||||
}
|
||||
else {
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_bm_utils_face_flip_doc,
|
||||
|
@ -782,9 +774,8 @@ static PyObject *bpy_bm_utils_loop_separate(PyObject *UNUSED(self), BPy_BMLoop *
|
|||
if (v_new != v_old) {
|
||||
return BPy_BMVert_CreatePyObject(bm, v_new);
|
||||
}
|
||||
else {
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
static struct PyMethodDef BPy_BM_utils_methods[] = {
|
||||
|
|
|
@ -415,10 +415,9 @@ typedef struct BufferOrOffset {
|
|||
if (ret_str) { \
|
||||
return PyUnicode_FromString((const char *)ret_str); \
|
||||
} \
|
||||
else { \
|
||||
\
|
||||
PyErr_SetString(PyExc_AttributeError, "could not get opengl string"); \
|
||||
return NULL; \
|
||||
}
|
||||
return NULL;
|
||||
|
||||
/** \} */
|
||||
|
||||
|
@ -705,7 +704,7 @@ static int BGL_BufferOrOffsetConverter(PyObject *object, BufferOrOffset *buffer)
|
|||
buffer->offset = NULL;
|
||||
return 1;
|
||||
}
|
||||
else if (PyNumber_Check(object)) {
|
||||
if (PyNumber_Check(object)) {
|
||||
Py_ssize_t offset = PyNumber_AsSsize_t(object, PyExc_IndexError);
|
||||
if (offset == -1 && PyErr_Occurred()) {
|
||||
return 0;
|
||||
|
@ -715,15 +714,14 @@ static int BGL_BufferOrOffsetConverter(PyObject *object, BufferOrOffset *buffer)
|
|||
buffer->offset = (void *)offset;
|
||||
return 1;
|
||||
}
|
||||
else if (PyObject_TypeCheck(object, &BGL_bufferType)) {
|
||||
if (PyObject_TypeCheck(object, &BGL_bufferType)) {
|
||||
buffer->buffer = (Buffer *)object;
|
||||
buffer->offset = NULL;
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_SetString(PyExc_TypeError, "expected a bgl.Buffer or None");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#define MAX_DIMENSIONS 256
|
||||
|
@ -766,7 +764,7 @@ static PyObject *Buffer_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject
|
|||
"too many dimensions, max is " STRINGIFY(MAX_DIMENSIONS));
|
||||
return NULL;
|
||||
}
|
||||
else if (ndimensions < 1) {
|
||||
if (ndimensions < 1) {
|
||||
PyErr_SetString(PyExc_AttributeError, "sequence must have at least one dimension");
|
||||
return NULL;
|
||||
}
|
||||
|
@ -913,10 +911,9 @@ static int Buffer_ass_item(Buffer *self, int i, PyObject *v)
|
|||
Py_DECREF(row);
|
||||
return ret;
|
||||
}
|
||||
else {
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
switch (self->type) {
|
||||
case GL_BYTE:
|
||||
|
@ -996,7 +993,7 @@ static PyObject *Buffer_subscript(Buffer *self, PyObject *item)
|
|||
}
|
||||
return Buffer_item(self, i);
|
||||
}
|
||||
else if (PySlice_Check(item)) {
|
||||
if (PySlice_Check(item)) {
|
||||
Py_ssize_t start, stop, step, slicelength;
|
||||
|
||||
if (PySlice_GetIndicesEx(item, self->dimensions[0], &start, &stop, &step, &slicelength) < 0) {
|
||||
|
@ -1006,19 +1003,17 @@ static PyObject *Buffer_subscript(Buffer *self, PyObject *item)
|
|||
if (slicelength <= 0) {
|
||||
return PyTuple_New(0);
|
||||
}
|
||||
else if (step == 1) {
|
||||
if (step == 1) {
|
||||
return Buffer_slice(self, start, stop);
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_SetString(PyExc_IndexError, "slice steps not supported with vectors");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_Format(
|
||||
PyExc_TypeError, "buffer indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static int Buffer_ass_subscript(Buffer *self, PyObject *item, PyObject *value)
|
||||
|
@ -1033,7 +1028,7 @@ static int Buffer_ass_subscript(Buffer *self, PyObject *item, PyObject *value)
|
|||
}
|
||||
return Buffer_ass_item(self, i, value);
|
||||
}
|
||||
else if (PySlice_Check(item)) {
|
||||
if (PySlice_Check(item)) {
|
||||
Py_ssize_t start, stop, step, slicelength;
|
||||
|
||||
if (PySlice_GetIndicesEx(item, self->dimensions[0], &start, &stop, &step, &slicelength) < 0) {
|
||||
|
@ -1043,16 +1038,14 @@ static int Buffer_ass_subscript(Buffer *self, PyObject *item, PyObject *value)
|
|||
if (step == 1) {
|
||||
return Buffer_ass_slice(self, start, stop, value);
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_SetString(PyExc_IndexError, "slice steps not supported with vectors");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_Format(
|
||||
PyExc_TypeError, "buffer indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
static void Buffer_dealloc(Buffer *self)
|
||||
|
|
|
@ -51,13 +51,12 @@ static PyObject *idprop_py_from_idp_string(const IDProperty *prop)
|
|||
if (prop->subtype == IDP_STRING_SUB_BYTE) {
|
||||
return PyBytes_FromStringAndSize(IDP_String(prop), prop->len);
|
||||
}
|
||||
else {
|
||||
|
||||
#ifdef USE_STRING_COERCE
|
||||
return PyC_UnicodeFromByteAndSize(IDP_Array(prop), prop->len - 1);
|
||||
#else
|
||||
return PyUnicode_FromStringAndSize(IDP_String(prop), prop->len - 1);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
static PyObject *idprop_py_from_idp_int(const IDProperty *prop)
|
||||
|
@ -479,10 +478,10 @@ static IDProperty *idp_from_PySequence_Buffer(const char *name, Py_buffer *buffe
|
|||
/* should never happen as the type has been checked before */
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
||||
val.array.type = id_type;
|
||||
val.array.len = buffer->len / buffer->itemsize;
|
||||
}
|
||||
|
||||
prop = IDP_New(IDP_ARRAY, &val, name);
|
||||
memcpy(IDP_Array(prop), buffer->buf, buffer->len);
|
||||
return prop;
|
||||
|
@ -576,17 +575,15 @@ static IDProperty *idp_from_PySequence(const char *name, PyObject *ob)
|
|||
PyBuffer_Release(&buffer);
|
||||
return prop;
|
||||
}
|
||||
else {
|
||||
|
||||
PyObject *ob_seq_fast = PySequence_Fast(ob, "py -> idprop");
|
||||
if (ob_seq_fast != NULL) {
|
||||
IDProperty *prop = idp_from_PySequence_Fast(name, ob_seq_fast);
|
||||
Py_DECREF(ob_seq_fast);
|
||||
return prop;
|
||||
}
|
||||
else {
|
||||
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static IDProperty *idp_from_PyMapping(const char *name, PyObject *ob)
|
||||
|
@ -641,29 +638,28 @@ static IDProperty *idp_from_PyObject(PyObject *name_obj, PyObject *ob)
|
|||
if (PyFloat_Check(ob)) {
|
||||
return idp_from_PyFloat(name, ob);
|
||||
}
|
||||
else if (PyLong_Check(ob)) {
|
||||
if (PyLong_Check(ob)) {
|
||||
return idp_from_PyLong(name, ob);
|
||||
}
|
||||
else if (PyUnicode_Check(ob)) {
|
||||
if (PyUnicode_Check(ob)) {
|
||||
return idp_from_PyUnicode(name, ob);
|
||||
}
|
||||
else if (PyBytes_Check(ob)) {
|
||||
if (PyBytes_Check(ob)) {
|
||||
return idp_from_PyBytes(name, ob);
|
||||
}
|
||||
else if (PySequence_Check(ob)) {
|
||||
if (PySequence_Check(ob)) {
|
||||
return idp_from_PySequence(name, ob);
|
||||
}
|
||||
else if (ob == Py_None || pyrna_id_CheckPyObject(ob)) {
|
||||
if (ob == Py_None || pyrna_id_CheckPyObject(ob)) {
|
||||
return idp_from_DatablockPointer(name, ob);
|
||||
}
|
||||
else if (PyMapping_Check(ob)) {
|
||||
if (PyMapping_Check(ob)) {
|
||||
return idp_from_PyMapping(name, ob);
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_Format(
|
||||
PyExc_TypeError, "invalid id-property type %.200s not supported", Py_TYPE(ob)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
@ -736,12 +732,11 @@ int BPy_Wrap_SetMapItem(IDProperty *prop, PyObject *key, PyObject *val)
|
|||
IDP_FreeFromGroup(prop, pkey);
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_SetString(PyExc_KeyError, "property not found in group");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
bool ok;
|
||||
|
||||
ok = BPy_IDProperty_Map_ValidateAndCreate(key, prop, val);
|
||||
|
@ -750,7 +745,6 @@ int BPy_Wrap_SetMapItem(IDProperty *prop, PyObject *key, PyObject *val)
|
|||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int BPy_IDGroup_Map_SetItem(BPy_IDProperty *self, PyObject *key, PyObject *val)
|
||||
|
@ -1485,7 +1479,7 @@ static PyObject *BPy_IDArray_subscript(BPy_IDArray *self, PyObject *item)
|
|||
}
|
||||
return BPy_IDArray_GetItem(self, i);
|
||||
}
|
||||
else if (PySlice_Check(item)) {
|
||||
if (PySlice_Check(item)) {
|
||||
Py_ssize_t start, stop, step, slicelength;
|
||||
|
||||
if (PySlice_GetIndicesEx(item, self->prop->len, &start, &stop, &step, &slicelength) < 0) {
|
||||
|
@ -1495,21 +1489,19 @@ static PyObject *BPy_IDArray_subscript(BPy_IDArray *self, PyObject *item)
|
|||
if (slicelength <= 0) {
|
||||
return PyTuple_New(0);
|
||||
}
|
||||
else if (step == 1) {
|
||||
if (step == 1) {
|
||||
return BPy_IDArray_slice(self, start, stop);
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_SetString(PyExc_TypeError, "slice steps not supported with vectors");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"vector indices must be integers, not %.200s",
|
||||
__func__,
|
||||
Py_TYPE(item)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static int BPy_IDArray_ass_subscript(BPy_IDArray *self, PyObject *item, PyObject *value)
|
||||
|
@ -1524,7 +1516,7 @@ static int BPy_IDArray_ass_subscript(BPy_IDArray *self, PyObject *item, PyObject
|
|||
}
|
||||
return BPy_IDArray_SetItem(self, i, value);
|
||||
}
|
||||
else if (PySlice_Check(item)) {
|
||||
if (PySlice_Check(item)) {
|
||||
Py_ssize_t start, stop, step, slicelength;
|
||||
|
||||
if (PySlice_GetIndicesEx(item, self->prop->len, &start, &stop, &step, &slicelength) < 0) {
|
||||
|
@ -1534,16 +1526,14 @@ static int BPy_IDArray_ass_subscript(BPy_IDArray *self, PyObject *item, PyObject
|
|||
if (step == 1) {
|
||||
return BPy_IDArray_ass_slice(self, start, stop, value);
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_SetString(PyExc_TypeError, "slice steps not supported with vectors");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_Format(
|
||||
PyExc_TypeError, "vector indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
static PyMappingMethods BPy_IDArray_AsMapping = {
|
||||
|
@ -1709,14 +1699,12 @@ static PyObject *BPy_Group_Iter_Next(BPy_IDGroup_Iter *self)
|
|||
BPy_IDGroup_WrapData(self->group->id, cur, self->group->prop));
|
||||
return ret;
|
||||
}
|
||||
else {
|
||||
|
||||
return PyUnicode_FromString(cur->name);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_SetNone(PyExc_StopIteration);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
PyTypeObject BPy_IDGroup_Iter_Type = {
|
||||
|
|
|
@ -57,11 +57,10 @@ static int py_imbuf_valid_check(Py_ImBuf *self)
|
|||
if (LIKELY(self->ibuf)) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_Format(
|
||||
PyExc_ReferenceError, "ImBuf data of type %.200s has been freed", Py_TYPE(self)->tp_name);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
#define PY_IMBUF_CHECK_OBJ(obj) \
|
||||
|
@ -324,9 +323,8 @@ static PyObject *py_imbuf_repr(Py_ImBuf *self)
|
|||
return PyUnicode_FromFormat(
|
||||
"<imbuf: address=%p, filepath='%s', size=(%d, %d)>", ibuf, ibuf->name, ibuf->x, ibuf->y);
|
||||
}
|
||||
else {
|
||||
|
||||
return PyUnicode_FromString("<imbuf: address=0x0>");
|
||||
}
|
||||
}
|
||||
|
||||
static Py_hash_t py_imbuf_hash(Py_ImBuf *self)
|
||||
|
|
|
@ -375,12 +375,11 @@ void PyC_StackSpit(void)
|
|||
fprintf(stderr, "python line lookup failed, interpreter inactive\n");
|
||||
return;
|
||||
}
|
||||
else {
|
||||
|
||||
/* lame but handy */
|
||||
PyGILState_STATE gilstate = PyGILState_Ensure();
|
||||
PyRun_SimpleString("__import__('traceback').print_stack()");
|
||||
PyGILState_Release(gilstate);
|
||||
}
|
||||
}
|
||||
|
||||
void PyC_StackPrint(/* FILE */ void *fp)
|
||||
|
@ -760,22 +759,20 @@ const char *PyC_UnicodeAsByteAndSize(PyObject *py_str, Py_ssize_t *size, PyObjec
|
|||
* chars since blender doesn't limit this */
|
||||
return result;
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_Clear();
|
||||
|
||||
if (PyBytes_Check(py_str)) {
|
||||
*size = PyBytes_GET_SIZE(py_str);
|
||||
return PyBytes_AS_STRING(py_str);
|
||||
}
|
||||
else if ((*coerce = PyUnicode_EncodeFSDefault(py_str))) {
|
||||
if ((*coerce = PyUnicode_EncodeFSDefault(py_str))) {
|
||||
*size = PyBytes_GET_SIZE(*coerce);
|
||||
return PyBytes_AS_STRING(*coerce);
|
||||
}
|
||||
else {
|
||||
|
||||
/* leave error raised from EncodeFS */
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const char *PyC_UnicodeAsByte(PyObject *py_str, PyObject **coerce)
|
||||
|
@ -789,20 +786,18 @@ const char *PyC_UnicodeAsByte(PyObject *py_str, PyObject **coerce)
|
|||
* chars since blender doesn't limit this. */
|
||||
return result;
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_Clear();
|
||||
|
||||
if (PyBytes_Check(py_str)) {
|
||||
return PyBytes_AS_STRING(py_str);
|
||||
}
|
||||
else if ((*coerce = PyUnicode_EncodeFSDefault(py_str))) {
|
||||
if ((*coerce = PyUnicode_EncodeFSDefault(py_str))) {
|
||||
return PyBytes_AS_STRING(*coerce);
|
||||
}
|
||||
else {
|
||||
|
||||
/* leave error raised from EncodeFS */
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PyObject *PyC_UnicodeFromByteAndSize(const char *str, Py_ssize_t size)
|
||||
|
@ -813,12 +808,11 @@ PyObject *PyC_UnicodeFromByteAndSize(const char *str, Py_ssize_t size)
|
|||
* chars since blender doesn't limit this */
|
||||
return result;
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_Clear();
|
||||
/* this means paths will always be accessible once converted, on all OS's */
|
||||
result = PyUnicode_DecodeFSDefaultAndSize(str, size);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
PyObject *PyC_UnicodeFromByte(const char *str)
|
||||
|
@ -1136,13 +1130,12 @@ void *PyC_RNA_AsPointer(PyObject *value, const char *type_name)
|
|||
|
||||
return result;
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"expected '%.200s' type found '%.200s' instead",
|
||||
type_name,
|
||||
Py_TYPE(value)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
|
|
@ -222,7 +222,7 @@ static PyObject *bpygpu_Batch_draw(BPyGPUBatch *self, PyObject *args)
|
|||
if (!PyArg_ParseTuple(args, "|O!:GPUBatch.draw", &BPyGPUShader_Type, &py_program)) {
|
||||
return NULL;
|
||||
}
|
||||
else if (py_program == NULL) {
|
||||
if (py_program == NULL) {
|
||||
if (!bpygpu_batch_is_program_or_error(self)) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -118,22 +118,20 @@ static PyObject *bpy_app_handlers_persistent_new(PyTypeObject *UNUSED(type),
|
|||
"get the dictionary from the function passed");
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
||||
/* set id */
|
||||
if (*dict_ptr == NULL) {
|
||||
*dict_ptr = PyDict_New();
|
||||
}
|
||||
|
||||
PyDict_SetItemString(*dict_ptr, PERMINENT_CB_ID, Py_None);
|
||||
}
|
||||
|
||||
Py_INCREF(value);
|
||||
return value;
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_SetString(PyExc_ValueError, "bpy.app.handlers.persistent expected a function");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* dummy type because decorators can't be PyCFunctions */
|
||||
|
|
|
@ -83,9 +83,8 @@ int bpy_pydriver_create_dict(void)
|
|||
if (d == NULL) {
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
|
||||
bpy_pydriver_Dict = d;
|
||||
}
|
||||
|
||||
/* import some modules: builtins, bpy, math, (Blender.noise)*/
|
||||
PyDict_SetItemString(d, "__builtins__", PyEval_GetBuiltins());
|
||||
|
@ -680,11 +679,8 @@ float BPY_driver_exec(struct PathResolvedRNA *anim_rna,
|
|||
if (isfinite(result)) {
|
||||
return (float)result;
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,
|
||||
"\tBPY_driver_eval() - driver '%s' evaluates to '%f'\n",
|
||||
driver->expression,
|
||||
result);
|
||||
|
||||
fprintf(
|
||||
stderr, "\tBPY_driver_eval() - driver '%s' evaluates to '%f'\n", driver->expression, result);
|
||||
return 0.0f;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -244,7 +244,7 @@ static PyObject *bpy_lib_enter(BPy_Library *self)
|
|||
}
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
||||
int i = 0, code;
|
||||
while ((code = BKE_idtype_idcode_iter_step(&i))) {
|
||||
if (BKE_idtype_idcode_is_linkable(code)) {
|
||||
|
@ -260,7 +260,6 @@ static PyObject *bpy_lib_enter(BPy_Library *self)
|
|||
Py_DECREF(str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* create a dummy */
|
||||
self_from = PyObject_New(BPy_Library, &bpy_lib_Type);
|
||||
|
@ -393,7 +392,7 @@ static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *UNUSED(args))
|
|||
BKE_main_id_tag_all(bmain, LIB_TAG_PRE_EXISTING, false);
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
||||
Library *lib = mainl->curlib; /* newly added lib, assign before append end */
|
||||
BLO_library_link_end(mainl, &(self->blo_handle), self->flag, NULL, NULL, NULL, NULL);
|
||||
BLO_blendhandle_close(self->blo_handle);
|
||||
|
@ -451,7 +450,6 @@ static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *UNUSED(args))
|
|||
|
||||
BLI_ghash_free(old_to_new_ids, NULL, NULL);
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
static PyObject *bpy_lib_dir(BPy_Library *self)
|
||||
|
|
|
@ -1408,9 +1408,8 @@ static bool py_long_as_int(PyObject *py_long, int *r_int)
|
|||
*r_int = (int)PyLong_AS_LONG(py_long);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
@ -1716,7 +1715,7 @@ static int bpy_prop_callback_check(PyObject *py_func, const char *keyword, int a
|
|||
Py_TYPE(py_func)->tp_name);
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
|
||||
PyCodeObject *f_code = (PyCodeObject *)PyFunction_GET_CODE(py_func);
|
||||
if (f_code->co_argcount != argcount) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
|
@ -1727,7 +1726,6 @@ static int bpy_prop_callback_check(PyObject *py_func, const char *keyword, int a
|
|||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1981,7 +1979,7 @@ static void bpy_prop_callback_assign_enum(struct PropertyRNA *prop,
|
|||
Py_DECREF(args); \
|
||||
return ret; \
|
||||
} \
|
||||
else if (PyTuple_GET_SIZE(args) > 1) { \
|
||||
if (PyTuple_GET_SIZE(args) > 1) { \
|
||||
PyErr_SetString(PyExc_ValueError, "all args must be keywords"); \
|
||||
return NULL; \
|
||||
} \
|
||||
|
@ -3537,7 +3535,7 @@ static PyObject *BPy_RemoveProperty(PyObject *self, PyObject *args, PyObject *kw
|
|||
Py_DECREF(args);
|
||||
return ret;
|
||||
}
|
||||
else if (PyTuple_GET_SIZE(args) > 1) {
|
||||
if (PyTuple_GET_SIZE(args) > 1) {
|
||||
PyErr_SetString(PyExc_ValueError, "expected one positional arg, one keyword arg");
|
||||
return NULL;
|
||||
}
|
||||
|
@ -3546,11 +3544,11 @@ static PyObject *BPy_RemoveProperty(PyObject *self, PyObject *args, PyObject *kw
|
|||
if (srna == NULL && PyErr_Occurred()) {
|
||||
return NULL; /* self's type was compatible but error getting the srna */
|
||||
}
|
||||
else if (srna == NULL) {
|
||||
if (srna == NULL) {
|
||||
PyErr_SetString(PyExc_TypeError, "RemoveProperty(): struct rna not available for this type");
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
||||
const char *id = NULL;
|
||||
|
||||
static const char *_keywords[] = {
|
||||
|
@ -3566,7 +3564,7 @@ static PyObject *BPy_RemoveProperty(PyObject *self, PyObject *args, PyObject *kw
|
|||
PyErr_Format(PyExc_TypeError, "RemoveProperty(): '%s' not a defined dynamic property", id);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
|
|
|
@ -987,7 +987,7 @@ static PyObject *pyrna_prop_str(BPy_PropertyRNA *self)
|
|||
PyErr_SetString(PyExc_RuntimeError, "could not use property type, internal error");
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
||||
/* This should never fail. */
|
||||
int len = -1;
|
||||
char *c = type_fmt;
|
||||
|
@ -1005,7 +1005,6 @@ static PyObject *pyrna_prop_str(BPy_PropertyRNA *self)
|
|||
if (len != -1) {
|
||||
sprintf(--c, "[%d]", len);
|
||||
}
|
||||
}
|
||||
|
||||
/* If a pointer, try to print name of pointer target too. */
|
||||
if (type == PROP_POINTER) {
|
||||
|
@ -1246,7 +1245,7 @@ static int pyrna_string_to_enum(
|
|||
Py_TYPE(item)->tp_name);
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
|
||||
if (!RNA_property_enum_value(BPy_GetContext(), ptr, prop, param, r_value)) {
|
||||
const char *enum_str = pyrna_enum_as_string(ptr, prop);
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
|
@ -1257,7 +1256,6 @@ static int pyrna_string_to_enum(
|
|||
MEM_freeN((void *)enum_str);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1715,14 +1713,14 @@ static int pyrna_py_to_prop(
|
|||
Py_TYPE(value)->tp_name);
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
|
||||
if (data) {
|
||||
*((bool *)data) = param;
|
||||
}
|
||||
else {
|
||||
RNA_property_boolean_set(ptr, prop, param);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case PROP_INT: {
|
||||
|
@ -1737,7 +1735,7 @@ static int pyrna_py_to_prop(
|
|||
RNA_property_identifier(prop));
|
||||
return -1;
|
||||
}
|
||||
else if (param == -1 && PyErr_Occurred()) {
|
||||
if (param == -1 && PyErr_Occurred()) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"%.200s %.200s.%.200s expected an int type, not %.200s",
|
||||
error_prefix,
|
||||
|
@ -1746,7 +1744,7 @@ static int pyrna_py_to_prop(
|
|||
Py_TYPE(value)->tp_name);
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
|
||||
int param_i = (int)param;
|
||||
if (data) {
|
||||
RNA_property_int_clamp(ptr, prop, ¶m_i);
|
||||
|
@ -1755,7 +1753,7 @@ static int pyrna_py_to_prop(
|
|||
else {
|
||||
RNA_property_int_set(ptr, prop, param_i);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case PROP_FLOAT: {
|
||||
|
@ -1769,7 +1767,7 @@ static int pyrna_py_to_prop(
|
|||
Py_TYPE(value)->tp_name);
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
|
||||
if (data) {
|
||||
RNA_property_float_clamp(ptr, prop, (float *)¶m);
|
||||
*((float *)data) = param;
|
||||
|
@ -1777,7 +1775,7 @@ static int pyrna_py_to_prop(
|
|||
else {
|
||||
RNA_property_float_set(ptr, prop, param);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case PROP_STRING: {
|
||||
|
@ -1835,7 +1833,7 @@ static int pyrna_py_to_prop(
|
|||
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
|
||||
if (data) {
|
||||
if (RNA_property_flag(prop) & PROP_THICK_WRAP) {
|
||||
BLI_strncpy((char *)data, (char *)param, RNA_property_string_maxlength(prop));
|
||||
|
@ -1848,7 +1846,6 @@ static int pyrna_py_to_prop(
|
|||
RNA_property_string_set_bytes(ptr, prop, param, PyBytes_Size(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* Unicode String. */
|
||||
#ifdef USE_STRING_COERCE
|
||||
|
@ -1886,7 +1883,7 @@ static int pyrna_py_to_prop(
|
|||
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
|
||||
/* Same as bytes. */
|
||||
/* XXX, this is suspect, but needed for function calls,
|
||||
* need to see if there's a better way. */
|
||||
|
@ -1901,7 +1898,7 @@ static int pyrna_py_to_prop(
|
|||
else {
|
||||
RNA_property_string_set(ptr, prop, param);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef USE_STRING_COERCE
|
||||
Py_XDECREF(value_coerce);
|
||||
#endif /* USE_STRING_COERCE */
|
||||
|
@ -1971,7 +1968,7 @@ static int pyrna_py_to_prop(
|
|||
PointerRNA opptr = RNA_property_pointer_get(ptr, prop);
|
||||
return pyrna_pydict_to_props(&opptr, value, false, error_prefix);
|
||||
}
|
||||
else if (base_type == &RNA_GizmoProperties) {
|
||||
if (base_type == &RNA_GizmoProperties) {
|
||||
PointerRNA opptr = RNA_property_pointer_get(ptr, prop);
|
||||
return pyrna_pydict_to_props(&opptr, value, false, error_prefix);
|
||||
}
|
||||
|
@ -2008,7 +2005,7 @@ static int pyrna_py_to_prop(
|
|||
Py_XDECREF(value_new);
|
||||
return -1;
|
||||
}
|
||||
else if ((flag & PROP_NEVER_NULL) && value == Py_None) {
|
||||
if ((flag & PROP_NEVER_NULL) && value == Py_None) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"%.200s %.200s.%.200s does not support a 'None' assignment %.200s type",
|
||||
error_prefix,
|
||||
|
@ -2018,7 +2015,7 @@ static int pyrna_py_to_prop(
|
|||
Py_XDECREF(value_new);
|
||||
return -1;
|
||||
}
|
||||
else if ((value != Py_None) && ((flag & PROP_ID_SELF_CHECK) &&
|
||||
if ((value != Py_None) && ((flag & PROP_ID_SELF_CHECK) &&
|
||||
ptr->owner_id == ((BPy_StructRNA *)value)->ptr.owner_id)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"%.200s %.200s.%.200s ID type does not support assignment to itself",
|
||||
|
@ -2028,7 +2025,7 @@ static int pyrna_py_to_prop(
|
|||
Py_XDECREF(value_new);
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
|
||||
BPy_StructRNA *param = (BPy_StructRNA *)value;
|
||||
bool raise_error = false;
|
||||
if (data) {
|
||||
|
@ -2107,7 +2104,6 @@ static int pyrna_py_to_prop(
|
|||
Py_XDECREF(value_new);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
Py_XDECREF(value_new);
|
||||
|
||||
|
@ -2295,9 +2291,8 @@ static Py_ssize_t pyrna_prop_array_length(BPy_PropertyArrayRNA *self)
|
|||
if (RNA_property_array_dimension(&self->ptr, self->prop, NULL) > 1) {
|
||||
return RNA_property_multi_array_length(&self->ptr, self->prop, self->arraydim);
|
||||
}
|
||||
else {
|
||||
|
||||
return RNA_property_array_length(&self->ptr, self->prop);
|
||||
}
|
||||
}
|
||||
|
||||
static Py_ssize_t pyrna_prop_collection_length(BPy_PropertyRNA *self)
|
||||
|
@ -2356,7 +2351,7 @@ static PyObject *pyrna_prop_collection_subscript_int(BPy_PropertyRNA *self, Py_s
|
|||
if (RNA_property_collection_lookup_int(&self->ptr, self->prop, keynum_abs, &newptr)) {
|
||||
return pyrna_struct_CreatePyObject(&newptr);
|
||||
}
|
||||
else {
|
||||
|
||||
const int len = RNA_property_collection_length(&self->ptr, self->prop);
|
||||
if (keynum_abs >= len) {
|
||||
PyErr_Format(PyExc_IndexError,
|
||||
|
@ -2374,7 +2369,6 @@ static PyObject *pyrna_prop_collection_subscript_int(BPy_PropertyRNA *self, Py_s
|
|||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Values type must have been already checked. */
|
||||
|
@ -2473,21 +2467,21 @@ static int pyrna_prop_collection_subscript_str_lib_pair_ptr(BPy_PropertyRNA *sel
|
|||
PyTuple_GET_SIZE(key));
|
||||
return -1;
|
||||
}
|
||||
else if (self->ptr.type != &RNA_BlendData) {
|
||||
if (self->ptr.type != &RNA_BlendData) {
|
||||
PyErr_Format(PyExc_KeyError,
|
||||
"%s: is only valid for bpy.data collections, not %.200s",
|
||||
err_prefix,
|
||||
RNA_struct_identifier(self->ptr.type));
|
||||
return -1;
|
||||
}
|
||||
else if ((keyname = _PyUnicode_AsString(PyTuple_GET_ITEM(key, 0))) == NULL) {
|
||||
if ((keyname = _PyUnicode_AsString(PyTuple_GET_ITEM(key, 0))) == NULL) {
|
||||
PyErr_Format(PyExc_KeyError,
|
||||
"%s: id must be a string, not %.200s",
|
||||
err_prefix,
|
||||
Py_TYPE(PyTuple_GET_ITEM(key, 0))->tp_name);
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
|
||||
PyObject *keylib = PyTuple_GET_ITEM(key, 1);
|
||||
Library *lib;
|
||||
bool found = false;
|
||||
|
@ -2508,11 +2502,10 @@ static int pyrna_prop_collection_subscript_str_lib_pair_ptr(BPy_PropertyRNA *sel
|
|||
keylib_str);
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
PyErr_Format(PyExc_KeyError,
|
||||
"%s: lib must be a string or None, not %.200s",
|
||||
|
@ -2542,10 +2535,8 @@ static int pyrna_prop_collection_subscript_str_lib_pair_ptr(BPy_PropertyRNA *sel
|
|||
PyErr_SetString(PyExc_KeyError, "bpy_prop_collection[key, lib]: not found");
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
|
||||
return found; /* 1 / 0, no exception. */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static PyObject *pyrna_prop_collection_subscript_str_lib_pair(BPy_PropertyRNA *self,
|
||||
|
@ -2560,9 +2551,8 @@ static PyObject *pyrna_prop_collection_subscript_str_lib_pair(BPy_PropertyRNA *s
|
|||
if (contains == 1) {
|
||||
return pyrna_struct_CreatePyObject(&ptr);
|
||||
}
|
||||
else {
|
||||
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static PyObject *pyrna_prop_collection_subscript_slice(BPy_PropertyRNA *self,
|
||||
|
@ -2707,7 +2697,7 @@ static PyObject *pyrna_prop_collection_subscript(BPy_PropertyRNA *self, PyObject
|
|||
if (PyUnicode_Check(key)) {
|
||||
return pyrna_prop_collection_subscript_str(self, _PyUnicode_AsString(key));
|
||||
}
|
||||
else if (PyIndex_Check(key)) {
|
||||
if (PyIndex_Check(key)) {
|
||||
Py_ssize_t i = PyNumber_AsSsize_t(key, PyExc_IndexError);
|
||||
if (i == -1 && PyErr_Occurred()) {
|
||||
return NULL;
|
||||
|
@ -2715,21 +2705,21 @@ static PyObject *pyrna_prop_collection_subscript(BPy_PropertyRNA *self, PyObject
|
|||
|
||||
return pyrna_prop_collection_subscript_int(self, i);
|
||||
}
|
||||
else if (PySlice_Check(key)) {
|
||||
if (PySlice_Check(key)) {
|
||||
PySliceObject *key_slice = (PySliceObject *)key;
|
||||
Py_ssize_t step = 1;
|
||||
|
||||
if (key_slice->step != Py_None && !_PyEval_SliceIndex(key, &step)) {
|
||||
return NULL;
|
||||
}
|
||||
else if (step != 1) {
|
||||
if (step != 1) {
|
||||
PyErr_SetString(PyExc_TypeError, "bpy_prop_collection[slice]: slice steps not supported");
|
||||
return NULL;
|
||||
}
|
||||
else if (key_slice->start == Py_None && key_slice->stop == Py_None) {
|
||||
if (key_slice->start == Py_None && key_slice->stop == Py_None) {
|
||||
return pyrna_prop_collection_subscript_slice(self, 0, PY_SSIZE_T_MAX);
|
||||
}
|
||||
else {
|
||||
|
||||
Py_ssize_t start = 0, stop = PY_SSIZE_T_MAX;
|
||||
|
||||
/* Avoid PySlice_GetIndicesEx because it needs to know the length ahead of time. */
|
||||
|
@ -2754,23 +2744,20 @@ static PyObject *pyrna_prop_collection_subscript(BPy_PropertyRNA *self, PyObject
|
|||
if (stop - start <= 0) {
|
||||
return PyList_New(0);
|
||||
}
|
||||
else {
|
||||
|
||||
return pyrna_prop_collection_subscript_slice(self, start, stop);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (PyTuple_Check(key)) {
|
||||
if (PyTuple_Check(key)) {
|
||||
/* Special case, for ID datablocks we. */
|
||||
return pyrna_prop_collection_subscript_str_lib_pair(
|
||||
self, key, "bpy_prop_collection[id, lib]", true);
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"bpy_prop_collection[key]: invalid key, "
|
||||
"must be a string or an int, not %.200s",
|
||||
Py_TYPE(key)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* generic check to see if a PyObject is compatible with a collection
|
||||
|
@ -2786,18 +2773,17 @@ static int pyrna_prop_collection_type_check(BPy_PropertyRNA *self, PyObject *val
|
|||
"this collection doesn't support None assignment");
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
|
||||
return 0; /* None is OK. */
|
||||
}
|
||||
}
|
||||
else if (BPy_StructRNA_Check(value) == 0) {
|
||||
if (BPy_StructRNA_Check(value) == 0) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"bpy_prop_collection[key] = value: invalid, "
|
||||
"expected a StructRNA type or None, not a %.200s",
|
||||
Py_TYPE(value)->tp_name);
|
||||
return -1;
|
||||
}
|
||||
else if ((prop_srna = RNA_property_pointer_type(&self->ptr, self->prop))) {
|
||||
if ((prop_srna = RNA_property_pointer_type(&self->ptr, self->prop))) {
|
||||
StructRNA *value_srna = ((BPy_StructRNA *)value)->ptr.type;
|
||||
if (RNA_struct_is_a(value_srna, prop_srna) == 0) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
|
@ -2807,10 +2793,9 @@ static int pyrna_prop_collection_type_check(BPy_PropertyRNA *self, PyObject *val
|
|||
RNA_struct_identifier(value_srna));
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
|
||||
return 0; /* OK, this is the correct type! */
|
||||
}
|
||||
}
|
||||
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"bpy_prop_collection[key] = value: internal error, "
|
||||
|
@ -2831,7 +2816,7 @@ static int pyrna_prop_collection_ass_subscript(BPy_PropertyRNA *self,
|
|||
PyErr_SetString(PyExc_TypeError, "del bpy_prop_collection[key]: not supported");
|
||||
return -1;
|
||||
}
|
||||
else if (pyrna_prop_collection_type_check(self, value) == -1) {
|
||||
if (pyrna_prop_collection_type_check(self, value) == -1) {
|
||||
return -1; /* Exception is set. */
|
||||
}
|
||||
|
||||
|
@ -2895,13 +2880,12 @@ static int pyrna_prop_collection_ass_subscript(BPy_PropertyRNA *self,
|
|||
}
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"bpy_prop_collection[key]: invalid key, "
|
||||
"must be a string or an int, not %.200s",
|
||||
Py_TYPE(key)->tp_name);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
static PyObject *pyrna_prop_array_subscript(BPy_PropertyArrayRNA *self, PyObject *key)
|
||||
|
@ -2921,24 +2905,24 @@ static PyObject *pyrna_prop_array_subscript(BPy_PropertyArrayRNA *self, PyObject
|
|||
}
|
||||
return pyrna_prop_array_subscript_int(self, i);
|
||||
}
|
||||
else if (PySlice_Check(key)) {
|
||||
if (PySlice_Check(key)) {
|
||||
Py_ssize_t step = 1;
|
||||
PySliceObject *key_slice = (PySliceObject *)key;
|
||||
|
||||
if (key_slice->step != Py_None && !_PyEval_SliceIndex(key, &step)) {
|
||||
return NULL;
|
||||
}
|
||||
else if (step != 1) {
|
||||
if (step != 1) {
|
||||
PyErr_SetString(PyExc_TypeError, "bpy_prop_array[slice]: slice steps not supported");
|
||||
return NULL;
|
||||
}
|
||||
else if (key_slice->start == Py_None && key_slice->stop == Py_None) {
|
||||
if (key_slice->start == Py_None && key_slice->stop == Py_None) {
|
||||
/* Note: no significant advantage with optimizing [:] slice as with collections,
|
||||
* but include here for consistency with collection slice func */
|
||||
Py_ssize_t len = (Py_ssize_t)pyrna_prop_array_length(self);
|
||||
return pyrna_prop_array_subscript_slice(self, &self->ptr, self->prop, 0, len, len);
|
||||
}
|
||||
else {
|
||||
|
||||
int len = pyrna_prop_array_length(self);
|
||||
Py_ssize_t start, stop, slicelength;
|
||||
|
||||
|
@ -2949,15 +2933,12 @@ static PyObject *pyrna_prop_array_subscript(BPy_PropertyArrayRNA *self, PyObject
|
|||
if (slicelength <= 0) {
|
||||
return PyTuple_New(0);
|
||||
}
|
||||
else {
|
||||
|
||||
return pyrna_prop_array_subscript_slice(self, &self->ptr, self->prop, start, stop, len);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_SetString(PyExc_AttributeError, "bpy_prop_array[key]: invalid key, key must be an int");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2972,7 +2953,7 @@ static PyObject *prop_subscript_ass_array_slice__as_seq_fast(PyObject *value, in
|
|||
"element in assignment is not a sequence type"))) {
|
||||
return NULL;
|
||||
}
|
||||
else if (PySequence_Fast_GET_SIZE(value_fast) != length) {
|
||||
if (PySequence_Fast_GET_SIZE(value_fast) != length) {
|
||||
Py_DECREF(value_fast);
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"bpy_prop_array[slice] = value: "
|
||||
|
@ -2980,9 +2961,8 @@ static PyObject *prop_subscript_ass_array_slice__as_seq_fast(PyObject *value, in
|
|||
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
||||
return value_fast;
|
||||
}
|
||||
}
|
||||
|
||||
static int prop_subscript_ass_array_slice__float_recursive(
|
||||
|
@ -3005,7 +2985,7 @@ static int prop_subscript_ass_array_slice__float_recursive(
|
|||
}
|
||||
return index;
|
||||
}
|
||||
else {
|
||||
|
||||
BLI_assert(totdim == 1);
|
||||
const float min = range[0], max = range[1];
|
||||
int i;
|
||||
|
@ -3015,7 +2995,6 @@ static int prop_subscript_ass_array_slice__float_recursive(
|
|||
value[i] = v;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
static int prop_subscript_ass_array_slice__int_recursive(
|
||||
|
@ -3038,7 +3017,7 @@ static int prop_subscript_ass_array_slice__int_recursive(
|
|||
}
|
||||
return index;
|
||||
}
|
||||
else {
|
||||
|
||||
BLI_assert(totdim == 1);
|
||||
const int min = range[0], max = range[1];
|
||||
int i;
|
||||
|
@ -3048,7 +3027,6 @@ static int prop_subscript_ass_array_slice__int_recursive(
|
|||
value[i] = v;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
static int prop_subscript_ass_array_slice__bool_recursive(PyObject **value_items,
|
||||
|
@ -3073,7 +3051,7 @@ static int prop_subscript_ass_array_slice__bool_recursive(PyObject **value_items
|
|||
}
|
||||
return index;
|
||||
}
|
||||
else {
|
||||
|
||||
BLI_assert(totdim == 1);
|
||||
int i;
|
||||
for (i = 0; i != length; i++) {
|
||||
|
@ -3081,7 +3059,6 @@ static int prop_subscript_ass_array_slice__bool_recursive(PyObject **value_items
|
|||
value[i] = v;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
/* Could call `pyrna_py_to_prop_array_index(self, i, value)` in a loop, but it is slow. */
|
||||
|
@ -3364,7 +3341,6 @@ static int pyrna_prop_collection_contains(BPy_PropertyRNA *self, PyObject *key)
|
|||
return pyrna_prop_collection_subscript_str_lib_pair_ptr(
|
||||
self, key, "(id, lib) in bpy_prop_collection", false, NULL);
|
||||
}
|
||||
else {
|
||||
|
||||
/* Key in dict style check. */
|
||||
const char *keyname = _PyUnicode_AsString(key);
|
||||
|
@ -3380,7 +3356,6 @@ static int pyrna_prop_collection_contains(BPy_PropertyRNA *self, PyObject *key)
|
|||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int pyrna_struct_contains(BPy_StructRNA *self, PyObject *value)
|
||||
|
@ -3821,30 +3796,25 @@ static PyObject *pyrna_struct_path_resolve(BPy_StructRNA *self, PyObject *args)
|
|||
path);
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
||||
return pyrna_array_index(&r_ptr, r_prop, index);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
if (coerce == Py_False) {
|
||||
return pyrna_prop_CreatePyObject(&r_ptr, r_prop);
|
||||
}
|
||||
else {
|
||||
|
||||
return pyrna_prop_to_py(&r_ptr, r_prop);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
return pyrna_struct_CreatePyObject(&r_ptr);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"%.200s.path_resolve(\"%.200s\") could not be resolved",
|
||||
RNA_struct_identifier(self->ptr.type),
|
||||
path);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(pyrna_struct_path_from_id_doc,
|
||||
|
@ -3954,7 +3924,7 @@ static PyObject *pyrna_prop_as_bytes(BPy_PropertyRNA *self)
|
|||
RNA_property_identifier(self->prop));
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
||||
PyObject *ret;
|
||||
char buf_fixed[256], *buf;
|
||||
int buf_len;
|
||||
|
@ -3969,7 +3939,6 @@ static PyObject *pyrna_prop_as_bytes(BPy_PropertyRNA *self)
|
|||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(pyrna_prop_update_doc,
|
||||
|
@ -4478,7 +4447,7 @@ static int pyrna_struct_setattro(BPy_StructRNA *self, PyObject *pyname, PyObject
|
|||
PyErr_SetString(PyExc_AttributeError, "bpy_struct: __setattr__ must be a string");
|
||||
return -1;
|
||||
}
|
||||
else if (name[0] != '_' && (prop = RNA_struct_find_property(&self->ptr, name))) {
|
||||
if (name[0] != '_' && (prop = RNA_struct_find_property(&self->ptr, name))) {
|
||||
if (!RNA_property_editable_flag(&self->ptr, prop)) {
|
||||
PyErr_Format(PyExc_AttributeError,
|
||||
"bpy_struct: attribute \"%.200s\" from \"%.200s\" is read-only",
|
||||
|
@ -4497,7 +4466,7 @@ static int pyrna_struct_setattro(BPy_StructRNA *self, PyObject *pyname, PyObject
|
|||
name);
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
|
||||
PointerRNA newptr;
|
||||
ListBase newlb;
|
||||
short newtype;
|
||||
|
@ -4513,7 +4482,6 @@ static int pyrna_struct_setattro(BPy_StructRNA *self, PyObject *pyname, PyObject
|
|||
|
||||
BLI_freelistN(&newlb);
|
||||
}
|
||||
}
|
||||
|
||||
/* pyrna_py_to_prop sets its own exceptions */
|
||||
if (prop) {
|
||||
|
@ -4523,9 +4491,8 @@ static int pyrna_struct_setattro(BPy_StructRNA *self, PyObject *pyname, PyObject
|
|||
}
|
||||
return pyrna_py_to_prop(&self->ptr, prop, NULL, value, "bpy_struct: item.attr = val:");
|
||||
}
|
||||
else {
|
||||
|
||||
return PyObject_GenericSetAttr((PyObject *)self, pyname, value);
|
||||
}
|
||||
}
|
||||
|
||||
static PyObject *pyrna_prop_dir(BPy_PropertyRNA *self)
|
||||
|
@ -4563,7 +4530,7 @@ static PyObject *pyrna_prop_collection_getattro(BPy_PropertyRNA *self, PyObject
|
|||
PyErr_SetString(PyExc_AttributeError, "bpy_prop_collection: __getattr__ must be a string");
|
||||
return NULL;
|
||||
}
|
||||
else if (name[0] != '_') {
|
||||
if (name[0] != '_') {
|
||||
PyObject *ret;
|
||||
PropertyRNA *prop;
|
||||
FunctionRNA *func;
|
||||
|
@ -4575,7 +4542,7 @@ static PyObject *pyrna_prop_collection_getattro(BPy_PropertyRNA *self, PyObject
|
|||
|
||||
return ret;
|
||||
}
|
||||
else if ((func = RNA_struct_find_function(r_ptr.type, name))) {
|
||||
if ((func = RNA_struct_find_function(r_ptr.type, name))) {
|
||||
PyObject *self_collection = pyrna_struct_CreatePyObject(&r_ptr);
|
||||
ret = pyrna_func_to_py(&((BPy_DummyPointerRNA *)self_collection)->ptr, func);
|
||||
Py_DECREF(self_collection);
|
||||
|
@ -4639,11 +4606,11 @@ static int pyrna_prop_collection_setattro(BPy_PropertyRNA *self, PyObject *pynam
|
|||
PyErr_SetString(PyExc_AttributeError, "bpy_prop: __setattr__ must be a string");
|
||||
return -1;
|
||||
}
|
||||
else if (value == NULL) {
|
||||
if (value == NULL) {
|
||||
PyErr_SetString(PyExc_AttributeError, "bpy_prop: del not supported");
|
||||
return -1;
|
||||
}
|
||||
else if (RNA_property_collection_type_get(&self->ptr, self->prop, &r_ptr)) {
|
||||
if (RNA_property_collection_type_get(&self->ptr, self->prop, &r_ptr)) {
|
||||
if ((prop = RNA_struct_find_property(&r_ptr, name))) {
|
||||
/* pyrna_py_to_prop sets its own exceptions. */
|
||||
return pyrna_py_to_prop(&r_ptr, prop, NULL, value, "BPy_PropertyRNA - Attribute (setattr):");
|
||||
|
@ -4673,9 +4640,8 @@ static PyObject *pyrna_prop_collection_idprop_add(BPy_PropertyRNA *self)
|
|||
"bpy_prop_collection.add(): not supported for this collection");
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
||||
return pyrna_struct_CreatePyObject(&r_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
static PyObject *pyrna_prop_collection_idprop_remove(BPy_PropertyRNA *self, PyObject *value)
|
||||
|
@ -5798,7 +5764,7 @@ static PyObject *pyrna_struct_new(PyTypeObject *type, PyObject *args, PyObject *
|
|||
Py_INCREF(base);
|
||||
return (PyObject *)base;
|
||||
}
|
||||
else if (PyType_IsSubtype(Py_TYPE(base), &pyrna_struct_Type)) {
|
||||
if (PyType_IsSubtype(Py_TYPE(base), &pyrna_struct_Type)) {
|
||||
/* this almost never runs, only when using user defined subclasses of built-in object.
|
||||
* this isn't common since it's NOT related to registerable subclasses. eg:
|
||||
*
|
||||
|
@ -5826,10 +5792,9 @@ static PyObject *pyrna_struct_new(PyTypeObject *type, PyObject *args, PyObject *
|
|||
type->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_Format(PyExc_TypeError, "bpy_struct.__new__(type): expected a single argument");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* only needed for subtyping, so a new class gets a valid BPy_StructRNA
|
||||
|
@ -5845,18 +5810,17 @@ static PyObject *pyrna_prop_new(PyTypeObject *type, PyObject *args, PyObject *UN
|
|||
if (type == Py_TYPE(base)) {
|
||||
return Py_INCREF_RET((PyObject *)base);
|
||||
}
|
||||
else if (PyType_IsSubtype(type, &pyrna_prop_Type)) {
|
||||
if (PyType_IsSubtype(type, &pyrna_prop_Type)) {
|
||||
BPy_PropertyRNA *ret = (BPy_PropertyRNA *)type->tp_alloc(type, 0);
|
||||
ret->ptr = base->ptr;
|
||||
ret->prop = base->prop;
|
||||
return (PyObject *)ret;
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"bpy_prop.__new__(type): type '%.200s' is not a subtype of bpy_prop",
|
||||
type->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *data)
|
||||
|
@ -6192,10 +6156,9 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject
|
|||
err = -1;
|
||||
break;
|
||||
}
|
||||
else { /* PyDict_GetItemString wont raise an error. */
|
||||
/* PyDict_GetItemString wont raise an error. */
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG_STRING_FREE
|
||||
if (item) {
|
||||
|
@ -7131,7 +7094,7 @@ static PyObject *pyrna_prop_collection_iter_next(BPy_PropertyCollectionIterRNA *
|
|||
PyErr_SetNone(PyExc_StopIteration);
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
||||
BPy_StructRNA *pyrna = (BPy_StructRNA *)pyrna_struct_CreatePyObject(&self->iter.ptr);
|
||||
|
||||
# ifdef USE_PYRNA_STRUCT_REFERENCE
|
||||
|
@ -7149,7 +7112,6 @@ static PyObject *pyrna_prop_collection_iter_next(BPy_PropertyCollectionIterRNA *
|
|||
RNA_property_collection_next(&self->iter);
|
||||
|
||||
return (PyObject *)pyrna;
|
||||
}
|
||||
}
|
||||
|
||||
static void pyrna_prop_collection_iter_dealloc(BPy_PropertyCollectionIterRNA *self)
|
||||
|
@ -7413,9 +7375,8 @@ static StructRNA *srna_from_ptr(PointerRNA *ptr)
|
|||
if (ptr->type == &RNA_Struct) {
|
||||
return ptr->data;
|
||||
}
|
||||
else {
|
||||
|
||||
return ptr->type;
|
||||
}
|
||||
}
|
||||
|
||||
/* Always returns a new ref, be sure to decref when done. */
|
||||
|
@ -7445,7 +7406,7 @@ PyObject *pyrna_struct_CreatePyObject(PointerRNA *ptr)
|
|||
Py_INCREF(pyrna);
|
||||
return (PyObject *)pyrna;
|
||||
}
|
||||
else {
|
||||
|
||||
/* Existing users will need to use 'type_recast' method. */
|
||||
Py_DECREF(pyrna);
|
||||
*instance = NULL;
|
||||
|
@ -7454,7 +7415,6 @@ PyObject *pyrna_struct_CreatePyObject(PointerRNA *ptr)
|
|||
pyrna = NULL;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
PyTypeObject *tp = (PyTypeObject *)pyrna_struct_Subtype(ptr);
|
||||
|
@ -7560,9 +7520,8 @@ PyObject *pyrna_id_CreatePyObject(ID *id)
|
|||
RNA_id_pointer_create(id, &ptr);
|
||||
return pyrna_struct_CreatePyObject(&ptr);
|
||||
}
|
||||
else {
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
bool pyrna_id_FromPyObject(PyObject *obj, ID **id)
|
||||
|
@ -7571,10 +7530,9 @@ bool pyrna_id_FromPyObject(PyObject *obj, ID **id)
|
|||
*id = ((BPy_StructRNA *)obj)->ptr.owner_id;
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
|
||||
*id = NULL;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool pyrna_id_CheckPyObject(PyObject *obj)
|
||||
|
@ -7869,13 +7827,13 @@ StructRNA *srna_from_self(PyObject *self, const char *error_prefix)
|
|||
if (self == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
else if (PyCapsule_CheckExact(self)) {
|
||||
if (PyCapsule_CheckExact(self)) {
|
||||
return PyCapsule_GetPointer(self, NULL);
|
||||
}
|
||||
else if (PyType_Check(self) == 0) {
|
||||
if (PyType_Check(self) == 0) {
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
||||
/* These cases above not errors, they just mean the type was not compatible
|
||||
* After this any errors will be raised in the script */
|
||||
|
||||
|
@ -7892,7 +7850,6 @@ StructRNA *srna_from_self(PyObject *self, const char *error_prefix)
|
|||
}
|
||||
|
||||
return srna;
|
||||
}
|
||||
}
|
||||
|
||||
static int deferred_register_prop(StructRNA *srna, PyObject *key, PyObject *item)
|
||||
|
|
|
@ -181,7 +181,7 @@ static int pyrna_struct_anim_args_parse_no_resolve(PointerRNA *ptr,
|
|||
*r_path_full = path;
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
|
||||
char *path_prefix = RNA_path_from_ID_to_struct(ptr);
|
||||
if (path_prefix == NULL) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
|
@ -198,7 +198,7 @@ static int pyrna_struct_anim_args_parse_no_resolve(PointerRNA *ptr,
|
|||
*r_path_full = BLI_string_join_by_sep_charN('.', path_prefix, path);
|
||||
}
|
||||
MEM_freeN(path_prefix);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -383,7 +383,7 @@ PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args, PyOb
|
|||
|
||||
return PyBool_FromLong(result);
|
||||
}
|
||||
else {
|
||||
|
||||
ID *id = self->ptr.owner_id;
|
||||
ReportList reports;
|
||||
bool result;
|
||||
|
@ -409,7 +409,6 @@ PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args, PyOb
|
|||
}
|
||||
|
||||
return PyBool_FromLong(result);
|
||||
}
|
||||
}
|
||||
|
||||
char pyrna_struct_keyframe_delete_doc[] =
|
||||
|
@ -453,7 +452,7 @@ PyObject *pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *args, PyOb
|
|||
NULL) == -1) {
|
||||
return NULL;
|
||||
}
|
||||
else if (self->ptr.type == &RNA_NlaStrip) {
|
||||
if (self->ptr.type == &RNA_NlaStrip) {
|
||||
/* Handle special properties for NLA Strips, whose F-Curves are stored on the
|
||||
* strips themselves. These are stored separately or else the properties will
|
||||
* not have any effect.
|
||||
|
@ -518,14 +517,14 @@ PyObject *pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *args, PyOb
|
|||
|
||||
return PyBool_FromLong(result);
|
||||
}
|
||||
else {
|
||||
|
||||
bool result;
|
||||
ReportList reports;
|
||||
|
||||
BKE_reports_init(&reports, RPT_STORE);
|
||||
|
||||
result = (delete_keyframe(
|
||||
G.main, &reports, self->ptr.owner_id, NULL, path_full, index, cfra) != 0);
|
||||
result = (delete_keyframe(G.main, &reports, self->ptr.owner_id, NULL, path_full, index, cfra) !=
|
||||
0);
|
||||
MEM_freeN((void *)path_full);
|
||||
|
||||
if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1) {
|
||||
|
@ -533,7 +532,6 @@ PyObject *pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *args, PyOb
|
|||
}
|
||||
|
||||
return PyBool_FromLong(result);
|
||||
}
|
||||
}
|
||||
|
||||
char pyrna_struct_driver_add_doc[] =
|
||||
|
@ -563,7 +561,7 @@ PyObject *pyrna_struct_driver_add(BPy_StructRNA *self, PyObject *args)
|
|||
&self->ptr, "bpy_struct.driver_add():", path, &path_full, &index) == -1) {
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
||||
PyObject *ret = NULL;
|
||||
ReportList reports;
|
||||
int result;
|
||||
|
@ -616,7 +614,6 @@ PyObject *pyrna_struct_driver_add(BPy_StructRNA *self, PyObject *args)
|
|||
MEM_freeN((void *)path_full);
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
char pyrna_struct_driver_remove_doc[] =
|
||||
|
@ -646,7 +643,7 @@ PyObject *pyrna_struct_driver_remove(BPy_StructRNA *self, PyObject *args)
|
|||
&self->ptr, "bpy_struct.driver_remove():", path, &path_full, &index) == -1) {
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
||||
short result;
|
||||
ReportList reports;
|
||||
|
||||
|
@ -667,5 +664,4 @@ PyObject *pyrna_struct_driver_remove(BPy_StructRNA *self, PyObject *args)
|
|||
DEG_relations_tag_update(CTX_data_main(context));
|
||||
|
||||
return PyBool_FromLong(result);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -180,7 +180,7 @@ static int validate_array_type(PyObject *seq,
|
|||
Py_TYPE(seq)->tp_name);
|
||||
return -1;
|
||||
}
|
||||
else if ((seq_size != dimsize[dim]) && (is_dynamic == false)) {
|
||||
if ((seq_size != dimsize[dim]) && (is_dynamic == false)) {
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"%s sequences of dimension %d should contain %d items, not %d",
|
||||
error_prefix,
|
||||
|
@ -201,7 +201,7 @@ static int validate_array_type(PyObject *seq,
|
|||
i);
|
||||
return -1;
|
||||
}
|
||||
else if (!check_item_type(item)) {
|
||||
if (!check_item_type(item)) {
|
||||
Py_DECREF(item);
|
||||
|
||||
#if 0
|
||||
|
@ -279,7 +279,7 @@ static int validate_array_length(PyObject *rvalue,
|
|||
RNA_property_identifier(prop));
|
||||
return -1;
|
||||
}
|
||||
else if ((RNA_property_flag(prop) & PROP_DYNAMIC) && lvalue_dim == 0) {
|
||||
if ((RNA_property_flag(prop) & PROP_DYNAMIC) && lvalue_dim == 0) {
|
||||
if (RNA_property_array_length(ptr, prop) != tot) {
|
||||
#if 0
|
||||
/* length is flexible */
|
||||
|
@ -382,7 +382,7 @@ static int validate_array(PyObject *rvalue,
|
|||
RNA_property_identifier(prop));
|
||||
return -1;
|
||||
}
|
||||
else if (totdim != 2) {
|
||||
if (totdim != 2) {
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"%s %.200s.%.200s, matrix assign array with %d dimensions",
|
||||
error_prefix,
|
||||
|
@ -391,7 +391,7 @@ static int validate_array(PyObject *rvalue,
|
|||
totdim);
|
||||
return -1;
|
||||
}
|
||||
else if (pymat->num_col != dimsize[0] || pymat->num_row != dimsize[1]) {
|
||||
if (pymat->num_col != dimsize[0] || pymat->num_row != dimsize[1]) {
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"%s %.200s.%.200s, matrix assign dimension size mismatch, "
|
||||
"is %dx%d, expected be %dx%d",
|
||||
|
@ -404,12 +404,11 @@ static int validate_array(PyObject *rvalue,
|
|||
dimsize[1]);
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
|
||||
*r_totitem = dimsize[0] * dimsize[1];
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* USE_MATHUTILS */
|
||||
|
||||
{
|
||||
|
@ -1017,7 +1016,7 @@ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value)
|
|||
PyErr_Clear();
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
|
||||
float tmp[32];
|
||||
float *tmp_arr;
|
||||
|
||||
|
@ -1041,7 +1040,7 @@ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value)
|
|||
}
|
||||
|
||||
return i < len ? 1 : 0;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case PROP_INT: {
|
||||
|
@ -1050,7 +1049,7 @@ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value)
|
|||
PyErr_Clear();
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
|
||||
int tmp[32];
|
||||
int *tmp_arr;
|
||||
|
||||
|
@ -1074,7 +1073,7 @@ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value)
|
|||
}
|
||||
|
||||
return i < len ? 1 : 0;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case PROP_BOOLEAN: {
|
||||
|
@ -1083,7 +1082,7 @@ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value)
|
|||
PyErr_Clear();
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
|
||||
bool tmp[32];
|
||||
bool *tmp_arr;
|
||||
|
||||
|
@ -1107,7 +1106,7 @@ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value)
|
|||
}
|
||||
|
||||
return i < len ? 1 : 0;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -317,7 +317,7 @@ PyObject *pyrna_callback_classmethod_add(PyObject *UNUSED(self), PyObject *args)
|
|||
error_prefix) == -1) {
|
||||
return NULL;
|
||||
}
|
||||
else if (params.region_type_str && pyrna_enum_value_from_id(rna_enum_region_type_items,
|
||||
if (params.region_type_str && pyrna_enum_value_from_id(rna_enum_region_type_items,
|
||||
params.region_type_str,
|
||||
¶ms.region_type,
|
||||
error_prefix) == -1) {
|
||||
|
@ -352,30 +352,27 @@ PyObject *pyrna_callback_classmethod_add(PyObject *UNUSED(self), PyObject *args)
|
|||
region_draw_mode_items, params.event_str, ¶ms.event, error_prefix) == -1) {
|
||||
return NULL;
|
||||
}
|
||||
else if (pyrna_enum_value_from_id(rna_enum_region_type_items,
|
||||
if (pyrna_enum_value_from_id(rna_enum_region_type_items,
|
||||
params.region_type_str,
|
||||
¶ms.region_type,
|
||||
error_prefix) == -1) {
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
||||
const eSpace_Type spaceid = rna_Space_refine_reverse(srna);
|
||||
if (spaceid == SPACE_EMPTY) {
|
||||
PyErr_Format(PyExc_TypeError, "unknown space type '%.200s'", RNA_struct_identifier(srna));
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
||||
SpaceType *st = BKE_spacetype_from_id(spaceid);
|
||||
ARegionType *art = BKE_regiontype_from_id(st, params.region_type);
|
||||
if (art == NULL) {
|
||||
PyErr_Format(
|
||||
PyExc_TypeError, "region type '%.200s' not in space", params.region_type_str);
|
||||
PyErr_Format(PyExc_TypeError, "region type '%.200s' not in space", params.region_type_str);
|
||||
return NULL;
|
||||
}
|
||||
handle = ED_region_draw_cb_activate(art, cb_region_draw, (void *)args, params.event);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
PyErr_SetString(PyExc_TypeError, "callback_add(): type does not support callbacks");
|
||||
return NULL;
|
||||
|
@ -448,25 +445,22 @@ PyObject *pyrna_callback_classmethod_remove(PyObject *UNUSED(self), PyObject *ar
|
|||
error_prefix) == -1) {
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
||||
const eSpace_Type spaceid = rna_Space_refine_reverse(srna);
|
||||
if (spaceid == SPACE_EMPTY) {
|
||||
PyErr_Format(PyExc_TypeError, "unknown space type '%.200s'", RNA_struct_identifier(srna));
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
||||
SpaceType *st = BKE_spacetype_from_id(spaceid);
|
||||
ARegionType *art = BKE_regiontype_from_id(st, params.region_type);
|
||||
if (art == NULL) {
|
||||
PyErr_Format(
|
||||
PyExc_TypeError, "region type '%.200s' not in space", params.region_type_str);
|
||||
PyErr_Format(PyExc_TypeError, "region type '%.200s' not in space", params.region_type_str);
|
||||
return NULL;
|
||||
}
|
||||
ED_region_draw_cb_exit(art, handle);
|
||||
capsule_clear = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
PyErr_SetString(PyExc_TypeError, "callback_remove(): type does not support callbacks");
|
||||
return NULL;
|
||||
|
|
|
@ -367,10 +367,10 @@ static PyObject *bpy_gizmo_target_get_value(PyObject *UNUSED(self), PyObject *ar
|
|||
WM_gizmo_target_property_float_get_array(gz, gz_prop, value);
|
||||
return PyC_Tuple_PackArray_F32(value, array_len);
|
||||
}
|
||||
else {
|
||||
|
||||
float value = WM_gizmo_target_property_float_get(gz, gz_prop);
|
||||
return PyFloat_FromDouble(value);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
|
|
|
@ -249,9 +249,9 @@ int mathutils_array_parse_alloc(float **array,
|
|||
memcpy(*array, ((BaseMathObject *)value)->data, size * sizeof(float));
|
||||
return size;
|
||||
}
|
||||
else
|
||||
|
||||
#endif
|
||||
{
|
||||
|
||||
PyObject *value_fast = NULL;
|
||||
// *array = NULL;
|
||||
int ret;
|
||||
|
@ -284,7 +284,6 @@ int mathutils_array_parse_alloc(float **array,
|
|||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
/* parse an array of vectors */
|
||||
|
@ -482,45 +481,41 @@ int mathutils_any_to_rotmat(float rmat[3][3], PyObject *value, const char *error
|
|||
if (BaseMath_ReadCallback((BaseMathObject *)value) == -1) {
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
|
||||
eulO_to_mat3(rmat, ((EulerObject *)value)->eul, ((EulerObject *)value)->order);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else if (QuaternionObject_Check(value)) {
|
||||
if (QuaternionObject_Check(value)) {
|
||||
if (BaseMath_ReadCallback((BaseMathObject *)value) == -1) {
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
|
||||
float tquat[4];
|
||||
normalize_qt_qt(tquat, ((QuaternionObject *)value)->quat);
|
||||
quat_to_mat3(rmat, tquat);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else if (MatrixObject_Check(value)) {
|
||||
if (MatrixObject_Check(value)) {
|
||||
if (BaseMath_ReadCallback((BaseMathObject *)value) == -1) {
|
||||
return -1;
|
||||
}
|
||||
else if (((MatrixObject *)value)->num_row < 3 || ((MatrixObject *)value)->num_col < 3) {
|
||||
if (((MatrixObject *)value)->num_row < 3 || ((MatrixObject *)value)->num_col < 3) {
|
||||
PyErr_Format(
|
||||
PyExc_ValueError, "%.200s: matrix must have minimum 3x3 dimensions", error_prefix);
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
|
||||
matrix_as_3x3(rmat, (MatrixObject *)value);
|
||||
normalize_m3(rmat);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"%.200s: expected a Euler, Quaternion or Matrix type, "
|
||||
"found %.200s",
|
||||
error_prefix,
|
||||
Py_TYPE(value)->tp_name);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------MATRIX FUNCTIONS-------------------- */
|
||||
|
|
|
@ -347,7 +347,7 @@ static PyObject *Color_subscript(ColorObject *self, PyObject *item)
|
|||
}
|
||||
return Color_item(self, i);
|
||||
}
|
||||
else if (PySlice_Check(item)) {
|
||||
if (PySlice_Check(item)) {
|
||||
Py_ssize_t start, stop, step, slicelength;
|
||||
|
||||
if (PySlice_GetIndicesEx(item, COLOR_SIZE, &start, &stop, &step, &slicelength) < 0) {
|
||||
|
@ -357,19 +357,17 @@ static PyObject *Color_subscript(ColorObject *self, PyObject *item)
|
|||
if (slicelength <= 0) {
|
||||
return PyTuple_New(0);
|
||||
}
|
||||
else if (step == 1) {
|
||||
if (step == 1) {
|
||||
return Color_slice(self, start, stop);
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_SetString(PyExc_IndexError, "slice steps not supported with color");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_Format(
|
||||
PyExc_TypeError, "color indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static int Color_ass_subscript(ColorObject *self, PyObject *item, PyObject *value)
|
||||
|
@ -384,7 +382,7 @@ static int Color_ass_subscript(ColorObject *self, PyObject *item, PyObject *valu
|
|||
}
|
||||
return Color_ass_item(self, i, value);
|
||||
}
|
||||
else if (PySlice_Check(item)) {
|
||||
if (PySlice_Check(item)) {
|
||||
Py_ssize_t start, stop, step, slicelength;
|
||||
|
||||
if (PySlice_GetIndicesEx(item, COLOR_SIZE, &start, &stop, &step, &slicelength) < 0) {
|
||||
|
@ -394,16 +392,14 @@ static int Color_ass_subscript(ColorObject *self, PyObject *item, PyObject *valu
|
|||
if (step == 1) {
|
||||
return Color_ass_slice(self, start, stop, value);
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_SetString(PyExc_IndexError, "slice steps not supported with color");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_Format(
|
||||
PyExc_TypeError, "color indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* -----------------PROTCOL DECLARATIONS-------------------------- */
|
||||
|
|
|
@ -558,7 +558,7 @@ static PyObject *Euler_subscript(EulerObject *self, PyObject *item)
|
|||
}
|
||||
return Euler_item(self, i);
|
||||
}
|
||||
else if (PySlice_Check(item)) {
|
||||
if (PySlice_Check(item)) {
|
||||
Py_ssize_t start, stop, step, slicelength;
|
||||
|
||||
if (PySlice_GetIndicesEx(item, EULER_SIZE, &start, &stop, &step, &slicelength) < 0) {
|
||||
|
@ -568,19 +568,17 @@ static PyObject *Euler_subscript(EulerObject *self, PyObject *item)
|
|||
if (slicelength <= 0) {
|
||||
return PyTuple_New(0);
|
||||
}
|
||||
else if (step == 1) {
|
||||
if (step == 1) {
|
||||
return Euler_slice(self, start, stop);
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_SetString(PyExc_IndexError, "slice steps not supported with eulers");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_Format(
|
||||
PyExc_TypeError, "euler indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static int Euler_ass_subscript(EulerObject *self, PyObject *item, PyObject *value)
|
||||
|
@ -595,7 +593,7 @@ static int Euler_ass_subscript(EulerObject *self, PyObject *item, PyObject *valu
|
|||
}
|
||||
return Euler_ass_item(self, i, value);
|
||||
}
|
||||
else if (PySlice_Check(item)) {
|
||||
if (PySlice_Check(item)) {
|
||||
Py_ssize_t start, stop, step, slicelength;
|
||||
|
||||
if (PySlice_GetIndicesEx(item, EULER_SIZE, &start, &stop, &step, &slicelength) < 0) {
|
||||
|
@ -605,16 +603,14 @@ static int Euler_ass_subscript(EulerObject *self, PyObject *item, PyObject *valu
|
|||
if (step == 1) {
|
||||
return Euler_ass_slice(self, start, stop, value);
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_SetString(PyExc_IndexError, "slice steps not supported with euler");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_Format(
|
||||
PyExc_TypeError, "euler indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* -----------------PROTCOL DECLARATIONS-------------------------- */
|
||||
|
|
|
@ -54,9 +54,8 @@ static int matrix_row_vector_check(MatrixObject *mat, VectorObject *vec, int row
|
|||
"owner matrix has been resized since this row vector was created");
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
static int matrix_col_vector_check(MatrixObject *mat, VectorObject *vec, int col)
|
||||
|
@ -67,9 +66,8 @@ static int matrix_col_vector_check(MatrixObject *mat, VectorObject *vec, int col
|
|||
"owner matrix has been resized since this column vector was created");
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
|
@ -380,11 +378,10 @@ static PyObject *Matrix_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
|||
if (Matrix_ass_slice((MatrixObject *)matrix, 0, INT_MAX, arg) == 0) {
|
||||
return matrix;
|
||||
}
|
||||
else { /* matrix ok, slice assignment not */
|
||||
/* matrix ok, slice assignment not */
|
||||
Py_DECREF(matrix);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -406,15 +403,13 @@ static PyObject *matrix__apply_to_copy(PyObject *(*matrix_func)(MatrixObject *),
|
|||
Py_DECREF(ret_dummy);
|
||||
return ret;
|
||||
}
|
||||
else { /* error */
|
||||
/* error */
|
||||
Py_DECREF(ret);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
/* copy may fail if the read callback errors out */
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* when a matrix is 4x4 size but initialized as a 3x3, re-assign values for 4x4 */
|
||||
|
@ -512,11 +507,10 @@ static PyObject *C_Matrix_Rotation(PyObject *cls, PyObject *args)
|
|||
"or a string in 'X', 'Y', 'Z'");
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
||||
/* use the string */
|
||||
vec = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
angle = angle_wrap_rad(angle);
|
||||
|
||||
|
@ -1023,7 +1017,7 @@ static float matrix_determinant_internal(const MatrixObject *self)
|
|||
MATRIX_ITEM(self, 1, 0),
|
||||
MATRIX_ITEM(self, 1, 1));
|
||||
}
|
||||
else if (self->num_col == 3) {
|
||||
if (self->num_col == 3) {
|
||||
return determinant_m3(MATRIX_ITEM(self, 0, 0),
|
||||
MATRIX_ITEM(self, 0, 1),
|
||||
MATRIX_ITEM(self, 0, 2),
|
||||
|
@ -1034,9 +1028,8 @@ static float matrix_determinant_internal(const MatrixObject *self)
|
|||
MATRIX_ITEM(self, 2, 1),
|
||||
MATRIX_ITEM(self, 2, 2));
|
||||
}
|
||||
else {
|
||||
|
||||
return determinant_m4((float(*)[4])self->matrix);
|
||||
}
|
||||
}
|
||||
|
||||
static void adjoint_matrix_n(float *mat_dst, const float *mat_src, const ushort dim)
|
||||
|
@ -1094,9 +1087,8 @@ static bool matrix_invert_internal(const MatrixObject *self, float *r_mat)
|
|||
matrix_invert_with_det_n_internal(r_mat, self->matrix, det, self->num_col);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1475,9 +1467,8 @@ static bool matrix_invert_is_compat(const MatrixObject *self)
|
|||
"only square matrices are supported");
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
static bool matrix_invert_args_check(const MatrixObject *self, PyObject *args, bool check_type)
|
||||
|
@ -1605,11 +1596,10 @@ static PyObject *Matrix_inverted(MatrixObject *self, PyObject *args)
|
|||
Py_INCREF(fallback);
|
||||
return fallback;
|
||||
}
|
||||
else {
|
||||
|
||||
matrix_invert_raise_degenerate();
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return Matrix_copy_notest(self, mat);
|
||||
}
|
||||
|
@ -2386,7 +2376,7 @@ static int Matrix_ass_slice(MatrixObject *self, int begin, int end, PyObject *va
|
|||
/* PySequence_Fast sets the error */
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
|
||||
PyObject **value_fast_items = PySequence_Fast_ITEMS(value_fast);
|
||||
const int size = end - begin;
|
||||
int row, col;
|
||||
|
@ -2427,7 +2417,6 @@ static int Matrix_ass_slice(MatrixObject *self, int begin, int end, PyObject *va
|
|||
|
||||
(void)BaseMath_WriteCallback(self);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/*------------------------NUMERIC PROTOCOLS----------------------
|
||||
*------------------------obj + obj------------------------------*/
|
||||
|
@ -2540,7 +2529,7 @@ static PyObject *Matrix_mul(PyObject *m1, PyObject *m2)
|
|||
|
||||
return Matrix_CreatePyObject(mat, mat2->num_col, mat1->num_row, Py_TYPE(mat1));
|
||||
}
|
||||
else if (mat2) {
|
||||
if (mat2) {
|
||||
/*FLOAT/INT * MATRIX */
|
||||
if (((scalar = PyFloat_AsDouble(m1)) == -1.0f && PyErr_Occurred()) == 0) {
|
||||
return matrix_mul_float(mat2, scalar);
|
||||
|
@ -2655,7 +2644,7 @@ static PyObject *Matrix_matmul(PyObject *m1, PyObject *m2)
|
|||
|
||||
return Matrix_CreatePyObject(mat, mat2->num_col, mat1->num_row, Py_TYPE(mat1));
|
||||
}
|
||||
else if (mat1) {
|
||||
if (mat1) {
|
||||
/* MATRIX @ VECTOR */
|
||||
if (VectorObject_Check(m2)) {
|
||||
VectorObject *vec2 = (VectorObject *)m2;
|
||||
|
@ -2772,7 +2761,7 @@ static PyObject *Matrix_subscript(MatrixObject *self, PyObject *item)
|
|||
}
|
||||
return Matrix_item_row(self, i);
|
||||
}
|
||||
else if (PySlice_Check(item)) {
|
||||
if (PySlice_Check(item)) {
|
||||
Py_ssize_t start, stop, step, slicelength;
|
||||
|
||||
if (PySlice_GetIndicesEx(item, self->num_row, &start, &stop, &step, &slicelength) < 0) {
|
||||
|
@ -2782,19 +2771,17 @@ static PyObject *Matrix_subscript(MatrixObject *self, PyObject *item)
|
|||
if (slicelength <= 0) {
|
||||
return PyTuple_New(0);
|
||||
}
|
||||
else if (step == 1) {
|
||||
if (step == 1) {
|
||||
return Matrix_slice(self, start, stop);
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_SetString(PyExc_IndexError, "slice steps not supported with matrices");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_Format(
|
||||
PyExc_TypeError, "matrix indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static int Matrix_ass_subscript(MatrixObject *self, PyObject *item, PyObject *value)
|
||||
|
@ -2809,7 +2796,7 @@ static int Matrix_ass_subscript(MatrixObject *self, PyObject *item, PyObject *va
|
|||
}
|
||||
return Matrix_ass_item_row(self, i, value);
|
||||
}
|
||||
else if (PySlice_Check(item)) {
|
||||
if (PySlice_Check(item)) {
|
||||
Py_ssize_t start, stop, step, slicelength;
|
||||
|
||||
if (PySlice_GetIndicesEx(item, self->num_row, &start, &stop, &step, &slicelength) < 0) {
|
||||
|
@ -2819,16 +2806,14 @@ static int Matrix_ass_subscript(MatrixObject *self, PyObject *item, PyObject *va
|
|||
if (step == 1) {
|
||||
return Matrix_ass_slice(self, start, stop, value);
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_SetString(PyExc_IndexError, "slice steps not supported with matrices");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_Format(
|
||||
PyExc_TypeError, "matrix indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
static PyMappingMethods Matrix_AsMapping = {
|
||||
|
@ -2977,15 +2962,14 @@ static PyObject *Matrix_is_negative_get(MatrixObject *self, void *UNUSED(closure
|
|||
if (self->num_row == 4 && self->num_col == 4) {
|
||||
return PyBool_FromLong(is_negative_m4((float(*)[4])self->matrix));
|
||||
}
|
||||
else if (self->num_row == 3 && self->num_col == 3) {
|
||||
if (self->num_row == 3 && self->num_col == 3) {
|
||||
return PyBool_FromLong(is_negative_m3((float(*)[3])self->matrix));
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_SetString(PyExc_AttributeError,
|
||||
"Matrix.is_negative: "
|
||||
"inappropriate matrix size - expects 3x3 or 4x4 matrix");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(Matrix_is_orthogonal_doc,
|
||||
|
@ -3000,15 +2984,14 @@ static PyObject *Matrix_is_orthogonal_get(MatrixObject *self, void *UNUSED(closu
|
|||
if (self->num_row == 4 && self->num_col == 4) {
|
||||
return PyBool_FromLong(is_orthonormal_m4((float(*)[4])self->matrix));
|
||||
}
|
||||
else if (self->num_row == 3 && self->num_col == 3) {
|
||||
if (self->num_row == 3 && self->num_col == 3) {
|
||||
return PyBool_FromLong(is_orthonormal_m3((float(*)[3])self->matrix));
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_SetString(PyExc_AttributeError,
|
||||
"Matrix.is_orthogonal: "
|
||||
"inappropriate matrix size - expects 3x3 or 4x4 matrix");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(Matrix_is_orthogonal_axis_vectors_doc,
|
||||
|
@ -3024,15 +3007,14 @@ static PyObject *Matrix_is_orthogonal_axis_vectors_get(MatrixObject *self, void
|
|||
if (self->num_row == 4 && self->num_col == 4) {
|
||||
return PyBool_FromLong(is_orthogonal_m4((float(*)[4])self->matrix));
|
||||
}
|
||||
else if (self->num_row == 3 && self->num_col == 3) {
|
||||
if (self->num_row == 3 && self->num_col == 3) {
|
||||
return PyBool_FromLong(is_orthogonal_m3((float(*)[3])self->matrix));
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_SetString(PyExc_AttributeError,
|
||||
"Matrix.is_orthogonal_axis_vectors: "
|
||||
"inappropriate matrix size - expects 3x3 or 4x4 matrix");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -3478,14 +3460,13 @@ static PyObject *MatrixAccess_subscript(MatrixAccessObject *self, PyObject *item
|
|||
}
|
||||
return Matrix_item_row(matrix_user, i);
|
||||
}
|
||||
else { /* MAT_ACCESS_ROW */
|
||||
/* MAT_ACCESS_ROW */
|
||||
if (i < 0) {
|
||||
i += matrix_user->num_col;
|
||||
}
|
||||
return Matrix_item_col(matrix_user, i);
|
||||
}
|
||||
}
|
||||
else if (PySlice_Check(item)) {
|
||||
if (PySlice_Check(item)) {
|
||||
Py_ssize_t start, stop, step, slicelength;
|
||||
|
||||
if (PySlice_GetIndicesEx(item, MatrixAccess_len(self), &start, &stop, &step, &slicelength) <
|
||||
|
@ -3496,19 +3477,17 @@ static PyObject *MatrixAccess_subscript(MatrixAccessObject *self, PyObject *item
|
|||
if (slicelength <= 0) {
|
||||
return PyTuple_New(0);
|
||||
}
|
||||
else if (step == 1) {
|
||||
if (step == 1) {
|
||||
return MatrixAccess_slice(self, start, stop);
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_SetString(PyExc_IndexError, "slice steps not supported with matrix accessors");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_Format(
|
||||
PyExc_TypeError, "matrix indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static int MatrixAccess_ass_subscript(MatrixAccessObject *self, PyObject *item, PyObject *value)
|
||||
|
@ -3527,19 +3506,17 @@ static int MatrixAccess_ass_subscript(MatrixAccessObject *self, PyObject *item,
|
|||
}
|
||||
return Matrix_ass_item_row(matrix_user, i, value);
|
||||
}
|
||||
else { /* MAT_ACCESS_ROW */
|
||||
/* MAT_ACCESS_ROW */
|
||||
if (i < 0) {
|
||||
i += matrix_user->num_col;
|
||||
}
|
||||
return Matrix_ass_item_col(matrix_user, i, value);
|
||||
}
|
||||
}
|
||||
/* TODO, slice */
|
||||
else {
|
||||
|
||||
PyErr_Format(
|
||||
PyExc_TypeError, "matrix indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
static PyObject *MatrixAccess_iter(MatrixAccessObject *self)
|
||||
|
|
|
@ -815,7 +815,7 @@ static PyObject *Quaternion_subscript(QuaternionObject *self, PyObject *item)
|
|||
}
|
||||
return Quaternion_item(self, i);
|
||||
}
|
||||
else if (PySlice_Check(item)) {
|
||||
if (PySlice_Check(item)) {
|
||||
Py_ssize_t start, stop, step, slicelength;
|
||||
|
||||
if (PySlice_GetIndicesEx(item, QUAT_SIZE, &start, &stop, &step, &slicelength) < 0) {
|
||||
|
@ -825,20 +825,17 @@ static PyObject *Quaternion_subscript(QuaternionObject *self, PyObject *item)
|
|||
if (slicelength <= 0) {
|
||||
return PyTuple_New(0);
|
||||
}
|
||||
else if (step == 1) {
|
||||
if (step == 1) {
|
||||
return Quaternion_slice(self, start, stop);
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_SetString(PyExc_IndexError, "slice steps not supported with quaternions");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"quaternion indices must be integers, not %.200s",
|
||||
Py_TYPE(item)->tp_name);
|
||||
|
||||
PyErr_Format(
|
||||
PyExc_TypeError, "quaternion indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static int Quaternion_ass_subscript(QuaternionObject *self, PyObject *item, PyObject *value)
|
||||
|
@ -853,7 +850,7 @@ static int Quaternion_ass_subscript(QuaternionObject *self, PyObject *item, PyOb
|
|||
}
|
||||
return Quaternion_ass_item(self, i, value);
|
||||
}
|
||||
else if (PySlice_Check(item)) {
|
||||
if (PySlice_Check(item)) {
|
||||
Py_ssize_t start, stop, step, slicelength;
|
||||
|
||||
if (PySlice_GetIndicesEx(item, QUAT_SIZE, &start, &stop, &step, &slicelength) < 0) {
|
||||
|
@ -863,17 +860,14 @@ static int Quaternion_ass_subscript(QuaternionObject *self, PyObject *item, PyOb
|
|||
if (step == 1) {
|
||||
return Quaternion_ass_slice(self, start, stop, value);
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_SetString(PyExc_IndexError, "slice steps not supported with quaternion");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"quaternion indices must be integers, not %.200s",
|
||||
Py_TYPE(item)->tp_name);
|
||||
|
||||
PyErr_Format(
|
||||
PyExc_TypeError, "quaternion indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------NUMERIC PROTOCOLS---------------------- */
|
||||
|
@ -967,7 +961,7 @@ static PyObject *Quaternion_mul(PyObject *q1, PyObject *q2)
|
|||
return Quaternion_CreatePyObject(quat, Py_TYPE(q1));
|
||||
}
|
||||
/* the only case this can happen (for a supported type is "FLOAT * QUAT") */
|
||||
else if (quat2) { /* FLOAT * QUAT */
|
||||
if (quat2) { /* FLOAT * QUAT */
|
||||
if (((scalar = PyFloat_AsDouble(q1)) == -1.0f && PyErr_Occurred()) == 0) {
|
||||
return quat_mul_float(quat2, scalar);
|
||||
}
|
||||
|
@ -1049,7 +1043,7 @@ static PyObject *Quaternion_matmul(PyObject *q1, PyObject *q2)
|
|||
mul_qt_qtqt(quat, quat1->quat, quat2->quat);
|
||||
return Quaternion_CreatePyObject(quat, Py_TYPE(q1));
|
||||
}
|
||||
else if (quat1) {
|
||||
if (quat1) {
|
||||
/* QUAT @ VEC */
|
||||
if (VectorObject_Check(q2)) {
|
||||
VectorObject *vec2 = (VectorObject *)q2;
|
||||
|
@ -1384,10 +1378,9 @@ static PyObject *quat__apply_to_copy(PyObject *(*quat_func)(QuaternionObject *),
|
|||
Py_DECREF(ret_dummy);
|
||||
return ret;
|
||||
}
|
||||
else { /* error */
|
||||
/* error */
|
||||
Py_DECREF(ret);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* axis vector suffers from precision errors, use this function to ensure */
|
||||
|
|
|
@ -104,10 +104,9 @@ static PyObject *vec__apply_to_copy(PyObject *(*vec_func)(VectorObject *), Vecto
|
|||
Py_DECREF(ret_dummy);
|
||||
return (PyObject *)ret;
|
||||
}
|
||||
else { /* error */
|
||||
/* error */
|
||||
Py_DECREF(ret);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------CLASS-METHODS----------------------------*/
|
||||
|
@ -1004,13 +1003,12 @@ static PyObject *Vector_angle(VectorObject *self, PyObject *args)
|
|||
Py_INCREF(fallback);
|
||||
return fallback;
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"Vector.angle(other): "
|
||||
"zero length vectors have no valid angle");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return PyFloat_FromDouble(saacos(dot / (sqrt(dot_self) * sqrt(dot_other))));
|
||||
}
|
||||
|
@ -1059,13 +1057,12 @@ static PyObject *Vector_angle_signed(VectorObject *self, PyObject *args)
|
|||
Py_INCREF(fallback);
|
||||
return fallback;
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"Vector.angle_signed(other): "
|
||||
"zero length vectors have no valid angle");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return PyFloat_FromDouble(angle_signed_v2v2(self->vec, tvec));
|
||||
}
|
||||
|
@ -1238,13 +1235,12 @@ static PyObject *Vector_slerp(VectorObject *self, PyObject *args)
|
|||
Py_INCREF(fallback);
|
||||
return fallback;
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"Vector.slerp(): "
|
||||
"zero length vectors unsupported");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* We have sane state, execute slerp */
|
||||
cosom = (float)dot_vn_vn(self_vec, other_vec, size);
|
||||
|
@ -1256,13 +1252,12 @@ static PyObject *Vector_slerp(VectorObject *self, PyObject *args)
|
|||
Py_INCREF(fallback);
|
||||
return fallback;
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"Vector.slerp(): "
|
||||
"opposite vectors unsupported");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
interp_dot_slerp(fac, cosom, w);
|
||||
|
||||
|
@ -1785,7 +1780,7 @@ static PyObject *Vector_mul(PyObject *v1, PyObject *v2)
|
|||
/* element-wise product */
|
||||
return vector_mul_vec(vec1, vec2);
|
||||
}
|
||||
else if (vec1) {
|
||||
if (vec1) {
|
||||
if (((scalar = PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred()) == 0) { /* VEC * FLOAT */
|
||||
return vector_mul_float(vec1, scalar);
|
||||
}
|
||||
|
@ -1890,7 +1885,7 @@ static PyObject *Vector_matmul(PyObject *v1, PyObject *v2)
|
|||
/*dot product*/
|
||||
return PyFloat_FromDouble(dot_vn_vn(vec1->vec, vec2->vec, vec1->size));
|
||||
}
|
||||
else if (vec1) {
|
||||
if (vec1) {
|
||||
if (MatrixObject_Check(v2)) {
|
||||
/* VEC @ MATRIX */
|
||||
float tvec[MAX_DIMENSIONS];
|
||||
|
@ -2039,10 +2034,9 @@ static PyObject *Vector_richcmpr(PyObject *objectA, PyObject *objectB, int compa
|
|||
if (comparison_type == Py_NE) {
|
||||
Py_RETURN_TRUE;
|
||||
}
|
||||
else {
|
||||
|
||||
Py_RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
vecA = (VectorObject *)objectA;
|
||||
vecB = (VectorObject *)objectB;
|
||||
|
||||
|
@ -2054,10 +2048,9 @@ static PyObject *Vector_richcmpr(PyObject *objectA, PyObject *objectB, int compa
|
|||
if (comparison_type == Py_NE) {
|
||||
Py_RETURN_TRUE;
|
||||
}
|
||||
else {
|
||||
|
||||
Py_RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
switch (comparison_type) {
|
||||
case Py_LT:
|
||||
|
@ -2107,9 +2100,8 @@ static PyObject *Vector_richcmpr(PyObject *objectA, PyObject *objectB, int compa
|
|||
if (result == 1) {
|
||||
Py_RETURN_TRUE;
|
||||
}
|
||||
else {
|
||||
|
||||
Py_RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static Py_hash_t Vector_hash(VectorObject *self)
|
||||
|
@ -2152,7 +2144,7 @@ static PyObject *Vector_subscript(VectorObject *self, PyObject *item)
|
|||
}
|
||||
return Vector_item(self, i);
|
||||
}
|
||||
else if (PySlice_Check(item)) {
|
||||
if (PySlice_Check(item)) {
|
||||
Py_ssize_t start, stop, step, slicelength;
|
||||
|
||||
if (PySlice_GetIndicesEx(item, self->size, &start, &stop, &step, &slicelength) < 0) {
|
||||
|
@ -2162,19 +2154,17 @@ static PyObject *Vector_subscript(VectorObject *self, PyObject *item)
|
|||
if (slicelength <= 0) {
|
||||
return PyTuple_New(0);
|
||||
}
|
||||
else if (step == 1) {
|
||||
if (step == 1) {
|
||||
return Vector_slice(self, start, stop);
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_SetString(PyExc_IndexError, "slice steps not supported with vectors");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_Format(
|
||||
PyExc_TypeError, "vector indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static int Vector_ass_subscript(VectorObject *self, PyObject *item, PyObject *value)
|
||||
|
@ -2189,7 +2179,7 @@ static int Vector_ass_subscript(VectorObject *self, PyObject *item, PyObject *va
|
|||
}
|
||||
return Vector_ass_item(self, i, value);
|
||||
}
|
||||
else if (PySlice_Check(item)) {
|
||||
if (PySlice_Check(item)) {
|
||||
Py_ssize_t start, stop, step, slicelength;
|
||||
|
||||
if (PySlice_GetIndicesEx(item, self->size, &start, &stop, &step, &slicelength) < 0) {
|
||||
|
@ -2199,16 +2189,14 @@ static int Vector_ass_subscript(VectorObject *self, PyObject *item, PyObject *va
|
|||
if (step == 1) {
|
||||
return Vector_ass_slice(self, start, stop, value);
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_SetString(PyExc_IndexError, "slice steps not supported with vectors");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_Format(
|
||||
PyExc_TypeError, "vector indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
static PyMappingMethods Vector_AsMapping = {
|
||||
|
@ -2523,9 +2511,8 @@ static int Vector_swizzle_set(VectorObject *self, PyObject *value, void *closure
|
|||
if (BaseMath_WriteCallback(self) == -1) {
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#define _SWIZZLE1(a) ((a) | SWIZZLE_VALID_AXIS)
|
||||
|
|
|
@ -914,7 +914,7 @@ static PyObject *C_BVHTree_FromPolygons(PyObject *UNUSED(cls), PyObject *args, P
|
|||
return bvhtree_CreatePyObject(
|
||||
tree, epsilon, coords, coords_len, tris, tris_len, orig_index, orig_normal);
|
||||
}
|
||||
else {
|
||||
|
||||
if (coords) {
|
||||
MEM_freeN(coords);
|
||||
}
|
||||
|
@ -923,7 +923,6 @@ static PyObject *C_BVHTree_FromPolygons(PyObject *UNUSED(cls), PyObject *args, P
|
|||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef MATH_STANDALONE
|
||||
|
@ -1053,27 +1052,24 @@ static Mesh *bvh_get_mesh(const char *funcname,
|
|||
funcname);
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
||||
*r_free_mesh = true;
|
||||
return mesh_create_eval_final_render(depsgraph, scene, ob, &data_masks);
|
||||
}
|
||||
}
|
||||
else if (ob_eval != NULL) {
|
||||
if (ob_eval != NULL) {
|
||||
if (use_cage) {
|
||||
return mesh_get_eval_deform(depsgraph, scene, ob_eval, &data_masks);
|
||||
}
|
||||
else {
|
||||
|
||||
return mesh_get_eval_final(depsgraph, scene, ob_eval, &data_masks);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"%s(...): Cannot get evaluated data from given dependency graph / object pair",
|
||||
funcname);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
/* !use_deform */
|
||||
if (use_render) {
|
||||
if (use_cage) {
|
||||
|
@ -1083,12 +1079,11 @@ static Mesh *bvh_get_mesh(const char *funcname,
|
|||
funcname);
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
||||
*r_free_mesh = true;
|
||||
return mesh_create_eval_no_deform_render(depsgraph, scene, ob, &data_masks);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
if (use_cage) {
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"%s(...): cage arg is unsupported when deform=False and dependency graph "
|
||||
|
@ -1096,12 +1091,9 @@ static Mesh *bvh_get_mesh(const char *funcname,
|
|||
funcname);
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
||||
*r_free_mesh = true;
|
||||
return mesh_create_eval_no_deform(depsgraph, scene, ob, &data_masks);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(C_BVHTree_FromObject_doc,
|
||||
|
|
|
@ -204,12 +204,11 @@ static PyObject *M_Geometry_intersect_line_line(PyObject *UNUSED(self), PyObject
|
|||
/* collinear */
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
else {
|
||||
|
||||
tuple = PyTuple_New(2);
|
||||
PyTuple_SET_ITEMS(
|
||||
tuple, Vector_CreatePyObject(i1, len, NULL), Vector_CreatePyObject(i2, len, NULL));
|
||||
return tuple;
|
||||
}
|
||||
}
|
||||
|
||||
/* Line-Line intersection using algorithm from mathworld.wolfram.com */
|
||||
|
@ -466,9 +465,8 @@ static PyObject *M_Geometry_intersect_line_line_2d(PyObject *UNUSED(self), PyObj
|
|||
if (isect_seg_seg_v2_point(UNPACK4(lines), vi) == 1) {
|
||||
return Vector_CreatePyObject(vi, 2, NULL);
|
||||
}
|
||||
else {
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(
|
||||
|
@ -519,9 +517,8 @@ static PyObject *M_Geometry_intersect_line_plane(PyObject *UNUSED(self), PyObjec
|
|||
if (isect_line_plane_v3(isect, line_a, line_b, plane_co, plane_no) == 1) {
|
||||
return Vector_CreatePyObject(isect, 3, NULL);
|
||||
}
|
||||
else {
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(
|
||||
|
@ -637,7 +634,7 @@ static PyObject *M_Geometry_intersect_line_sphere(PyObject *UNUSED(self), PyObje
|
|||
-1)) == 0) {
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
||||
bool use_a = true;
|
||||
bool use_b = true;
|
||||
float lambda;
|
||||
|
@ -673,7 +670,6 @@ static PyObject *M_Geometry_intersect_line_sphere(PyObject *UNUSED(self), PyObje
|
|||
use_b ? Vector_CreatePyObject(isect_b, 3, NULL) : Py_INCREF_RET(Py_None));
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
/* keep in sync with M_Geometry_intersect_line_sphere */
|
||||
|
@ -723,7 +719,7 @@ static PyObject *M_Geometry_intersect_line_sphere_2d(PyObject *UNUSED(self), PyO
|
|||
-1)) == 0) {
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
||||
bool use_a = true;
|
||||
bool use_b = true;
|
||||
float lambda;
|
||||
|
@ -759,7 +755,6 @@ static PyObject *M_Geometry_intersect_line_sphere_2d(PyObject *UNUSED(self), PyO
|
|||
use_b ? Vector_CreatePyObject(isect_b, 2, NULL) : Py_INCREF_RET(Py_None));
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(
|
||||
|
@ -849,9 +844,8 @@ static PyObject *M_Geometry_intersect_point_tri(PyObject *UNUSED(self), PyObject
|
|||
if (isect_point_tri_v3(pt, UNPACK3(tri), vi)) {
|
||||
return Vector_CreatePyObject(vi, 3, NULL);
|
||||
}
|
||||
else {
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(M_Geometry_closest_point_on_tri_doc,
|
||||
|
@ -1094,7 +1088,7 @@ static PyObject *M_Geometry_points_in_planes(PyObject *UNUSED(self), PyObject *a
|
|||
(float **)&planes, 4, py_planes, "points_in_planes")) == -1) {
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
||||
/* note, this could be refactored into plain C easy - py bits are noted */
|
||||
const float eps = 0.0001f;
|
||||
const uint len = (uint)planes_len;
|
||||
|
@ -1132,14 +1126,11 @@ static PyObject *M_Geometry_points_in_planes(PyObject *UNUSED(self), PyObject *a
|
|||
* </pre>
|
||||
*/
|
||||
const float quotient_ninv = -1.0f / quotient;
|
||||
potentialVertex[0] = ((n2n3[0] * N1[3]) + (n3n1[0] * N2[3]) +
|
||||
(n1n2[0] * N3[3])) *
|
||||
potentialVertex[0] = ((n2n3[0] * N1[3]) + (n3n1[0] * N2[3]) + (n1n2[0] * N3[3])) *
|
||||
quotient_ninv;
|
||||
potentialVertex[1] = ((n2n3[1] * N1[3]) + (n3n1[1] * N2[3]) +
|
||||
(n1n2[1] * N3[3])) *
|
||||
potentialVertex[1] = ((n2n3[1] * N1[3]) + (n3n1[1] * N2[3]) + (n1n2[1] * N3[3])) *
|
||||
quotient_ninv;
|
||||
potentialVertex[2] = ((n2n3[2] * N1[3]) + (n3n1[2] * N2[3]) +
|
||||
(n1n2[2] * N3[3])) *
|
||||
potentialVertex[2] = ((n2n3[2] * N1[3]) + (n3n1[2] * N2[3]) + (n1n2[2] * N3[3])) *
|
||||
quotient_ninv;
|
||||
for (l = 0; l < len; l++) {
|
||||
const float *NP = planes[l];
|
||||
|
@ -1176,7 +1167,6 @@ static PyObject *M_Geometry_points_in_planes(PyObject *UNUSED(self), PyObject *a
|
|||
PyTuple_SET_ITEMS(ret, py_verts, py_plane_index);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef MATH_STANDALONE
|
||||
|
@ -1321,7 +1311,7 @@ static PyObject *M_Geometry_tessellate_polygon(PyObject *UNUSED(self), PyObject
|
|||
BKE_displist_free(&dispbase); /* possible some dl was allocated */
|
||||
return NULL;
|
||||
}
|
||||
else if (totpoints) {
|
||||
if (totpoints) {
|
||||
/* now make the list to return */
|
||||
BKE_displist_fill(&dispbase, &dispbase, is_2d ? ((const float[3]){0, 0, -1}) : NULL, false);
|
||||
|
||||
|
|
Loading…
Reference in New Issue