forked from bartvdbraak/blender
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.
This commit is contained in:
parent
564ca3cede
commit
8304b73a08
@ -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;
|
||||
|
||||
|
@ -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 );
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user