diff options
author | Willian Padovani Germano <wpgermano@gmail.com> | 2005-12-14 21:01:42 +0300 |
---|---|---|
committer | Willian Padovani Germano <wpgermano@gmail.com> | 2005-12-14 21:01:42 +0300 |
commit | 8304b73a08bc174e190c94ec05245a36e3ad66c2 (patch) | |
tree | 7a811eccf4a42fa307f96024f4096b5233edcfe3 /source/blender/python/api2_2x | |
parent | 564ca3cede5f62a3595661d3c3e5c11cc924a2f3 (diff) |
BPython:
- malformed nmeshes could crash Blender with a sigsegv. Related to old
behavior that accepted "faces" with one or two verts.
- removing unused var (store_edges) + doc update.
Diffstat (limited to 'source/blender/python/api2_2x')
-rw-r--r-- | source/blender/python/api2_2x/NMesh.c | 24 | ||||
-rw-r--r-- | source/blender/python/api2_2x/NMesh.h | 2 | ||||
-rw-r--r-- | source/blender/python/api2_2x/doc/NMesh.py | 4 |
3 files changed, 19 insertions, 11 deletions
diff --git a/source/blender/python/api2_2x/NMesh.c b/source/blender/python/api2_2x/NMesh.c index a614dbaa3d4..a22307c7574 100644 --- a/source/blender/python/api2_2x/NMesh.c +++ b/source/blender/python/api2_2x/NMesh.c @@ -90,7 +90,7 @@ extern void countall(void); static PyObject *g_nmeshmodule = NULL; static int unlink_existingMeshData( Mesh * mesh ); -static int convert_NMeshToMesh( Mesh *mesh, BPy_NMesh *nmesh, int store_edges ); +static int convert_NMeshToMesh( Mesh *mesh, BPy_NMesh *nmesh ); static void check_dverts(Mesh *me, int old_totverts); static PyObject *NMesh_printDebug( PyObject * self ); static PyObject *NMesh_addEdge( PyObject * self, PyObject * args ); @@ -1330,11 +1330,11 @@ static PyObject *NMesh_update( PyObject *self, PyObject *a, PyObject *kwd ) if( mesh ) { old_totvert = mesh->totvert; unlink_existingMeshData( mesh ); - if( !convert_NMeshToMesh( mesh, nmesh, store_edges ) ) + if( !convert_NMeshToMesh( mesh, nmesh ) ) return NULL; if (mesh->dvert) check_dverts(mesh, old_totvert); } else { - mesh = Mesh_fromNMesh( nmesh, store_edges ); + mesh = Mesh_fromNMesh( nmesh ); /* if mesh is NULL, there was an error */ if( !mesh ) return NULL; @@ -1461,7 +1461,7 @@ static PyObject *NMesh_getVertexInfluences( PyObject * self, PyObject * args ) return influence_list; } -Mesh *Mesh_fromNMesh( BPy_NMesh * nmesh , int store_edges ) +Mesh *Mesh_fromNMesh( BPy_NMesh * nmesh ) { Mesh *mesh = NULL; @@ -1476,7 +1476,7 @@ Mesh *Mesh_fromNMesh( BPy_NMesh * nmesh , int store_edges ) mesh->id.us = 0; /* no user yet */ G.totmesh++; - if( !convert_NMeshToMesh( mesh, nmesh, store_edges ) ) + if( !convert_NMeshToMesh( mesh, nmesh ) ) return NULL; return mesh; @@ -2890,6 +2890,14 @@ static void fill_medge_from_nmesh(Mesh * mesh, BPy_NMesh * nmesh) } } + /* tot_valid_faces_edges < 0 causes a sigsegv crash, so we + * clamp to prevent it + * (this is related to faces (correctly) requiring at least 3 verts now, + * which can break old scripts -- maybe we should also warn about the + * 'broken' mesh the user created, but for now, until we investigate + * better, this should do) */ + if (tot_valid_faces_edges < 0) tot_valid_faces_edges = 0; + /* Now we have the total count of valid edges */ mesh->totedge=tot_valid_nmedges+tot_valid_faces_edges; mesh->medge=MEM_callocN(mesh->totedge*sizeof(MEdge), "make mesh edges"); @@ -2955,7 +2963,7 @@ static void check_dverts(Mesh *me, int old_totvert) return; } -static int convert_NMeshToMesh( Mesh * mesh, BPy_NMesh * nmesh, int store_edges) +static int convert_NMeshToMesh( Mesh * mesh, BPy_NMesh * nmesh) { MFace *newmf; TFace *newtf; @@ -3183,7 +3191,7 @@ static PyObject *M_NMesh_PutRaw( PyObject * self, PyObject * args ) old_totvert = mesh->totvert; unlink_existingMeshData( mesh ); - if( !convert_NMeshToMesh( mesh, nmesh, store_edges ) ) + if( !convert_NMeshToMesh( mesh, nmesh ) ) return NULL; nmesh->mesh = mesh; @@ -3414,7 +3422,7 @@ Mesh *NMesh_FromPyObject( PyObject * pyobj, Object * ob ) if( nmesh->mesh ) { mesh = nmesh->mesh; } else { - mesh = Mesh_fromNMesh( nmesh, 1 ); + mesh = Mesh_fromNMesh( nmesh ); if( !mesh ) /* NULL means an PyError */ return NULL; diff --git a/source/blender/python/api2_2x/NMesh.h b/source/blender/python/api2_2x/NMesh.h index 57d029b5d26..f1639d7d401 100644 --- a/source/blender/python/api2_2x/NMesh.h +++ b/source/blender/python/api2_2x/NMesh.h @@ -145,7 +145,7 @@ int NMesh_CheckPyObject( PyObject * pyobj ); void mesh_update( Mesh * mesh , Object * ob ); PyObject *new_NMesh( Mesh * oldmesh ); -Mesh *Mesh_fromNMesh( BPy_NMesh * nmesh , int store_edges ); +Mesh *Mesh_fromNMesh( BPy_NMesh * nmesh ); PyObject *NMesh_assignMaterials_toObject( BPy_NMesh * nmesh, Object * ob ); Material **nmesh_updateMaterials( BPy_NMesh * nmesh ); Material **newMaterialList_fromPyList( PyObject * list ); diff --git a/source/blender/python/api2_2x/doc/NMesh.py b/source/blender/python/api2_2x/doc/NMesh.py index 9b22a80bab1..763ffdd20f7 100644 --- a/source/blender/python/api2_2x/doc/NMesh.py +++ b/source/blender/python/api2_2x/doc/NMesh.py @@ -188,7 +188,7 @@ def PutRaw(nmesh, name = None, recalc_normals = 1, store_edges = 0): this nmesh data. It can be an existing mesh data object or a new one. @param recalc_normals: If non-zero, the vertex normals for the mesh will be recalculated. - @param store_edges: if non-zero, the edges data are stored + @param store_edges: deprecated, edges are always stored now. @rtype: None or Object @return: It depends on the 'name' parameter: - I{name} refers to an existing mesh data obj already linked to an @@ -587,7 +587,7 @@ class NMesh: @type recalc_normals: int (bool) @param recalc_normals: if nonzero the vertex normals are recalculated. @type store_edges: int (bool) - @param store_edges: if nonzero, then edge data is stored. + @param store_edges: deprecated, edges are always stored now. @type vertex_shade: int (bool) @param vertex_shade: if nonzero vertices are colored based on the current lighting setup, like when there are no vertex colors and no |