Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWillian Padovani Germano <wpgermano@gmail.com>2003-08-02 07:37:16 +0400
committerWillian Padovani Germano <wpgermano@gmail.com>2003-08-02 07:37:16 +0400
commit1a0fc24542d0787acdba69184e5ac2d19aeec1c0 (patch)
tree81d532e1450b08e787bd35afc231fa977cc72db6
parent08c1fe681830c660df9a21e7824b83d21c4164da (diff)
Exppython:
Expanding NMesh_update() to accept a parameter to tell it to recalculate normals, I introduced an error: new meshes would segfault Blender. Fixed.
-rw-r--r--source/blender/python/api2_2x/NMesh.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/source/blender/python/api2_2x/NMesh.c b/source/blender/python/api2_2x/NMesh.c
index aa7eeea0f6f..a1b8ba89aaa 100644
--- a/source/blender/python/api2_2x/NMesh.c
+++ b/source/blender/python/api2_2x/NMesh.c
@@ -171,7 +171,7 @@ static PyObject *M_NMesh_Face(PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "|O!", &PyList_Type, &vertlist))
return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected a list of vertices or nothing as argument");
+ "expected a list of vertices or nothing as argument");
if (!vertlist) vertlist = PyList_New(0);
@@ -760,15 +760,19 @@ static PyObject *NMesh_update(PyObject *self, PyObject *args)
return EXPP_ReturnPyObjError (PyExc_AttributeError,
"expected nothing or an int (0 or 1) as argument");
+ if (recalc_normals && recalc_normals != 1)
+ return EXPP_ReturnPyObjError (PyExc_ValueError,
+ "expected 0 or 1 as argument");
+
if (mesh) {
unlink_existingMeshData(mesh);
convert_NMeshToMesh(mesh, nmesh);
} else {
nmesh->mesh = Mesh_fromNMesh(nmesh);
- }
+ mesh = nmesh->mesh;
+ }
- if(recalc_normals == 1)
- vertexnormals_mesh(mesh, 0);
+ if (recalc_normals) vertexnormals_mesh(mesh, 0);
mesh_update(mesh);
@@ -1350,17 +1354,17 @@ static void mface_from_data(MFace *mf, TFace *tf, MCol *col, BPy_NMFace *from)
BPy_NMVert *nmv;
int i = PyList_Size(from->v);
- if(i >= 1) {
+ if (i >= 1) {
nmv = (BPy_NMVert *)PyList_GetItem(from->v, 0);
if (BPy_NMVert_Check(nmv) && nmv->index != -1) mf->v1 = nmv->index;
else mf->v1 = 0;
}
- if(i >= 2) {
+ if (i >= 2) {
nmv = (BPy_NMVert *)PyList_GetItem(from->v, 1);
if (BPy_NMVert_Check(nmv) && nmv->index != -1) mf->v2 = nmv->index;
else mf->v2 = 0;
}
- if(i >= 3) {
+ if (i >= 3) {
nmv = (BPy_NMVert *)PyList_GetItem(from->v, 2);
if (BPy_NMVert_Check(nmv) && nmv->index != -1) mf->v3 = nmv->index;
else mf->v3= 0;
@@ -1448,8 +1452,10 @@ void EXPP_unlink_mesh(Mesh *me)
if(me->mat[a]) me->mat[a]->id.us--;
me->mat[a]= 0;
}
-/* ... here we want to preserve mesh keys
- if(me->key) me->key->id.us--;
+/* ... here we want to preserve mesh keys */
+/* if users want to get rid of them, they can use mesh.removeAllKeys() */
+/*
+ if(me->key) me->key->id.us--;
me->key= 0;
*/
if(me->texcomesh) me->texcomesh= 0;
@@ -1712,8 +1718,7 @@ static PyObject *M_NMesh_PutRaw(PyObject *self, PyObject *args)
convert_NMeshToMesh(mesh, nmesh);
nmesh->mesh = mesh;
- if(recalc_normals)
- vertexnormals_mesh(mesh, 0);
+ if (recalc_normals) vertexnormals_mesh(mesh, 0);
mesh_update(mesh);