From 08775e8f145a863938c982d18191d1d55a517f98 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 23 Apr 2010 11:19:06 +0000 Subject: Mesh Deform Modifier: compress static binding weights better, threshold is still set very low so in many cases it could be even smaller, but being a bit conservative here to try to avoid breaking rigs. This is not forward-compatible, i.e. loading new files in older blender versions will loose the binding. --- source/blender/blenloader/intern/readfile.c | 66 ++++++++++++++++++++++------- 1 file changed, 51 insertions(+), 15 deletions(-) (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 32a07db1768..8b0861252fe 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -3852,24 +3852,35 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb) else if (md->type==eModifierType_MeshDeform) { MeshDeformModifierData *mmd = (MeshDeformModifierData*) md; - mmd->bindweights= newdataadr(fd, mmd->bindweights); - mmd->bindcos= newdataadr(fd, mmd->bindcos); + mmd->bindinfluences= newdataadr(fd, mmd->bindinfluences); + mmd->bindoffsets= newdataadr(fd, mmd->bindoffsets); + mmd->bindcagecos= newdataadr(fd, mmd->bindcagecos); mmd->dyngrid= newdataadr(fd, mmd->dyngrid); mmd->dyninfluences= newdataadr(fd, mmd->dyninfluences); mmd->dynverts= newdataadr(fd, mmd->dynverts); + mmd->bindweights= newdataadr(fd, mmd->bindweights); + mmd->bindcos= newdataadr(fd, mmd->bindcos); + if(fd->flags & FD_FLAGS_SWITCH_ENDIAN) { int a; + if(mmd->bindoffsets) + for(a=0; atotvert+1; a++) + SWITCH_INT(mmd->bindoffsets[a]) + if(mmd->bindcagecos) + for(a=0; atotcagevert*3; a++) + SWITCH_INT(mmd->bindcagecos[a]) + if(mmd->dynverts) + for(a=0; atotvert; a++) + SWITCH_INT(mmd->dynverts[a]) + if(mmd->bindweights) for(a=0; atotcagevert*mmd->totvert; a++) SWITCH_INT(mmd->bindweights[a]) if(mmd->bindcos) for(a=0; atotcagevert*3; a++) SWITCH_INT(mmd->bindcos[a]) - if(mmd->dynverts) - for(a=0; atotvert; a++) - SWITCH_INT(mmd->dynverts[a]) } } } @@ -5169,7 +5180,7 @@ static void direct_link_screen(FileData *fd, bScreen *sc) /*comma expressions, (e.g. expr1, expr2, expr3) evalutate each expression, from left to right. the right-most expression sets the result of the comma expression as a whole*/ - for(cl= sconsole->history.first; cl && (clnext=cl->next), cl; cl= clnext) { + for(cl= sconsole->history.first; cl && (clnext=cl->next); cl= clnext) { cl->line= newdataadr(fd, cl->line); if (!cl->line) { BLI_remlink(&sconsole->history, cl); @@ -6451,6 +6462,30 @@ static void do_version_mtex_factor_2_50(MTex **mtex_array, short idtype) } } +static void do_version_mdef_250(FileData *fd, Library *lib, Main *main) +{ + Object *ob; + ModifierData *md; + MeshDeformModifierData *mmd; + + for(ob= main->object.first; ob; ob=ob->id.next) { + for(md=ob->modifiers.first; md; md=md->next) { + if(md->type == eModifierType_MeshDeform) { + mmd= (MeshDeformModifierData*)md; + + if(mmd->bindcos) { + /* make bindcos NULL in order to trick older versions + into thinking that the mesh was not bound yet */ + mmd->bindcagecos= mmd->bindcos; + mmd->bindcos= NULL; + + modifier_mdef_compact_influences(md); + } + } + } + } +} + static void do_version_constraints_radians_degrees_250(ListBase *lb) { bConstraint *con; @@ -10780,7 +10815,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) /* put 2.50 compatibility code here until next subversion bump */ { - + do_version_mdef_250(fd, lib, main); } /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ @@ -12219,16 +12254,17 @@ static void read_libraries(FileData *basefd, ListBase *mainlist) printf(" absolute lib: %s\n", mainptr->curlib->filename); printf(" relative lib: %s\n", mainptr->curlib->name); printf(" enter a new path:\n"); - scanf("%s", newlib_path); - strcpy(mainptr->curlib->name, newlib_path); - strcpy(mainptr->curlib->filename, newlib_path); - cleanup_path(G.sce, mainptr->curlib->filename); - - fd= blo_openblenderfile(mainptr->curlib->filename, basefd->reports); + if(scanf("%s", newlib_path) > 0) { + strcpy(mainptr->curlib->name, newlib_path); + strcpy(mainptr->curlib->filename, newlib_path); + cleanup_path(G.sce, mainptr->curlib->filename); + + fd= blo_openblenderfile(mainptr->curlib->filename, basefd->reports); - if(fd) { - printf("found: '%s', party on macuno!\n", mainptr->curlib->filename); + if(fd) { + printf("found: '%s', party on macuno!\n", mainptr->curlib->filename); + } } } } -- cgit v1.2.3