diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2006-11-23 21:36:13 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2006-11-23 21:36:13 +0300 |
commit | b1f787715a7c919c203e1cfbf8ce4529b7eeb69c (patch) | |
tree | 35485a563bde2c3591e4d589fdab1c86f42ac84d /source/blender | |
parent | 3b9556996c6a23ccddab58697164c72ede592aaf (diff) |
Fix for bug #5296: Mesh.update destroys vertex groups. Code wasn't
updated for customdata layers yet.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/python/api2_2x/NMesh.c | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/source/blender/python/api2_2x/NMesh.c b/source/blender/python/api2_2x/NMesh.c index 6f8bf1eb95a..f991ee9380a 100644 --- a/source/blender/python/api2_2x/NMesh.c +++ b/source/blender/python/api2_2x/NMesh.c @@ -2760,13 +2760,25 @@ static void EXPP_unlink_mesh( Mesh * me ) static int unlink_existingMeshData( Mesh * mesh ) { + MDeformVert *dvert= NULL; + EXPP_unlink_mesh( mesh ); + if(mesh->dvert) { + /* we don't want to remove dvert here, check_dverts still needs it */ + dvert= mesh->dvert; + CustomData_set_layer( &mesh->vdata, CD_MDEFORMVERT, NULL ); + } + CustomData_free( &mesh->vdata, mesh->totvert ); CustomData_free( &mesh->edata, mesh->totedge ); CustomData_free( &mesh->fdata, mesh->totface ); mesh_update_customdata_pointers( mesh ); + if(dvert) + mesh->dvert= CustomData_add_layer( &mesh->vdata, CD_MDEFORMVERT, 0, + dvert, mesh->totvert ); + mesh->totedge = 0; if( mesh->mat ) { @@ -2967,25 +2979,17 @@ static void check_dverts(Mesh *me, int old_totvert) /* if vert count didn't change or there are no dverts, all is fine */ if ((totvert == old_totvert) || (!me->dvert)) return; /* if all verts have been deleted, free old dverts */ - else if (totvert == 0) free_dverts(me->dvert, old_totvert); - /* if verts have been added, expand me->dvert */ - else if (totvert > old_totvert) { - MDeformVert *mdv = me->dvert; - me->dvert = NULL; - create_dverts( &me->id ); - copy_dverts(me->dvert, mdv, old_totvert); - free_dverts(mdv, old_totvert); + else if (totvert == 0) { + CustomData_free_layer( &me->vdata, CD_MDEFORMVERT, old_totvert ); + me->dvert= NULL; } - /* if verts have been deleted, shrink me->dvert */ else { - MDeformVert *mdv = me->dvert; - me->dvert = NULL; - create_dverts( &me->id ); - copy_dverts(me->dvert, mdv, totvert); - free_dverts(mdv, old_totvert); + /* verts added or removed, make new me->dvert */ + MDeformVert *mdv = MEM_callocN( sizeof(MDeformVert)*totvert, "mdv" ); + copy_dverts( mdv, me->dvert, MIN2( old_totvert, totvert ) ); + free_dverts( me->dvert, old_totvert ); + me->dvert= CustomData_set_layer( &me->vdata, CD_MDEFORMVERT, mdv ); } - - return; } static int convert_NMeshToMesh( Mesh * mesh, BPy_NMesh * nmesh) |