diff options
author | Willian Padovani Germano <wpgermano@gmail.com> | 2003-08-05 07:45:31 +0400 |
---|---|---|
committer | Willian Padovani Germano <wpgermano@gmail.com> | 2003-08-05 07:45:31 +0400 |
commit | 683c322b0ebf7f407bb79f775f592e8ebfeef078 (patch) | |
tree | c54d9f5d441c688feb8d1975b4475fa87e257b19 | |
parent | 7db4249ae4ad5b32993c18a3cd66bd339449d5c8 (diff) |
Exppython:
- Fixed bug #399:
Old bug on NMesh: segfault on NMesh.Face(vertexlist).
- Fixed bug #433:
"Typo" on Armature: bone's setQuat method was changing bone->head, not
bone->quat.
-rw-r--r-- | source/blender/python/api2_2x/Bone.c | 8 | ||||
-rw-r--r-- | source/blender/python/api2_2x/NMesh.c | 38 |
2 files changed, 35 insertions, 11 deletions
diff --git a/source/blender/python/api2_2x/Bone.c b/source/blender/python/api2_2x/Bone.c index d94623f5e3f..226ce3b2898 100644 --- a/source/blender/python/api2_2x/Bone.c +++ b/source/blender/python/api2_2x/Bone.c @@ -543,10 +543,10 @@ static PyObject *Bone_setQuat(BPy_Bone *self, PyObject *args) return (EXPP_ReturnPyObjError (PyExc_AttributeError, "expected 4 float arguments")); - self->bone->head[0] = f1; - self->bone->head[1] = f2; - self->bone->head[2] = f3; - self->bone->head[3] = f4; + self->bone->quat[0] = f1; + self->bone->quat[1] = f2; + self->bone->quat[2] = f3; + self->bone->quat[3] = f4; Py_INCREF(Py_None); return Py_None; diff --git a/source/blender/python/api2_2x/NMesh.c b/source/blender/python/api2_2x/NMesh.c index a1b8ba89aaa..7db50bd8fa2 100644 --- a/source/blender/python/api2_2x/NMesh.c +++ b/source/blender/python/api2_2x/NMesh.c @@ -147,11 +147,35 @@ static void NMFace_dealloc (PyObject *self) PyObject_DEL(self); } -static BPy_NMFace *new_NMFace(PyObject *vertexlist) +static PyObject *new_NMFace(PyObject *vertexlist) { BPy_NMFace *mf = PyObject_NEW (BPy_NMFace, &NMFace_Type); + PyObject *vlcopy; - mf->v = vertexlist; + if (vertexlist) { /* create a copy of the given vertex list */ + PyObject *item; + int i, len = PyList_Size(vertexlist); + + vlcopy = PyList_New(len); + + if (!vlcopy) + return EXPP_ReturnPyObjError(PyExc_MemoryError, + "couldn't create PyList"); + + for (i = 0; i < len; i++) { + item = PySequence_GetItem(vertexlist, i); /* PySequence increfs */ + + if (item) + PyList_SET_ITEM(vlcopy, i, item); + else + return EXPP_ReturnPyObjError(PyExc_RuntimeError, + "couldn't get vertex from a PyList"); + } + } + else /* create an empty vertex list */ + vlcopy = PyList_New(0); + + mf->v = vlcopy; mf->uv = PyList_New(0); mf->image = NULL; mf->mode = TF_DYNAMIC + TF_TEX; @@ -159,10 +183,10 @@ static BPy_NMFace *new_NMFace(PyObject *vertexlist) mf->transp = TF_SOLID; mf->col = PyList_New(0); - mf->smooth= 0; - mf->mat_nr= 0; + mf->smooth = 0; + mf->mat_nr = 0; - return mf; + return (PyObject *)mf; } static PyObject *M_NMesh_Face(PyObject *self, PyObject *args) @@ -173,9 +197,9 @@ static PyObject *M_NMesh_Face(PyObject *self, PyObject *args) return EXPP_ReturnPyObjError (PyExc_TypeError, "expected a list of vertices or nothing as argument"); - if (!vertlist) vertlist = PyList_New(0); +/* if (!vertlist) vertlist = PyList_New(0); */ - return (PyObject *)new_NMFace(vertlist); + return new_NMFace(vertlist); } static PyObject *NMFace_append(PyObject *self, PyObject *args) |