diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2007-03-12 03:30:46 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2007-03-12 03:30:46 +0300 |
commit | ffd91ac7260d2d147a45be5f505b205bcb602e2c (patch) | |
tree | 7c1644c0915a5b2bc5d6a3cc61a971b836140416 /source/blender/python/api2_2x/Mesh.c | |
parent | 508a24269b2faf6a5ebaab7c80ae20c77a010d96 (diff) |
Fix for bug #6127:
Import scripts could create meshes with old style edgecodes.
Diffstat (limited to 'source/blender/python/api2_2x/Mesh.c')
-rw-r--r-- | source/blender/python/api2_2x/Mesh.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/source/blender/python/api2_2x/Mesh.c b/source/blender/python/api2_2x/Mesh.c index 60f297d3591..ff0fff439d1 100644 --- a/source/blender/python/api2_2x/Mesh.c +++ b/source/blender/python/api2_2x/Mesh.c @@ -442,6 +442,31 @@ static void delete_edges( Mesh *mesh, unsigned int *vert_table, int to_delete ) } } +/* +* Since all faces must have 3 or 4 verts, we can't have v3 or v4 be zero. +* If that happens during the deletion, we have to shuffle the vertices +* around; otherwise it can cause an Eeekadoodle or worse. If there are +* texture faces as well, they have to be shuffled as well. +* +* (code borrowed from test_index_face() in mesh.c, but since we know the +* faces already have correct number of vertices, this is a little faster) +*/ + +static void eeek_fix( MFace *mface, int len4 ) +{ + /* if 4 verts, then neither v3 nor v4 can be zero */ + if( len4 ) { + if( !mface->v3 || !mface->v4 ) { + SWAP( int, mface->v1, mface->v3 ); + SWAP( int, mface->v2, mface->v4 ); + } + } else if( !mface->v3 ) { + /* if 2 verts, then just v3 cannot be zero (v4 MUST be zero) */ + SWAP( int, mface->v1, mface->v2 ); + SWAP( int, mface->v2, mface->v3 ); + } +} + static void delete_faces( Mesh *mesh, unsigned int *vert_table, int to_delete ) { int i; @@ -4801,7 +4826,7 @@ static PyObject *MFaceSeq_extend( BPy_MEdgeSeq * self, PyObject *args, * go through some contortions to guarantee the third and fourth * vertices are not index 0 */ - test_index_face( &tmpface, NULL, 0, nverts ); + eeek_fix( &tmpface, nverts == 4 ); vert[0] = tmpface.v1; vert[1] = tmpface.v2; vert[2] = tmpface.v3; |