diff options
author | Nicholas Bishop <nicholasbishop@gmail.com> | 2008-06-22 23:43:52 +0400 |
---|---|---|
committer | Nicholas Bishop <nicholasbishop@gmail.com> | 2008-06-22 23:43:52 +0400 |
commit | b8c383cc6ea14a9b77cc154d84aa6b2a8976b483 (patch) | |
tree | 032c82c260258a282f2e506b1dd143c496082e9d /source/blender/blenloader | |
parent | f41da7e7dcbc2e2c8de6da4d07b8b7f34a0c0048 (diff) |
Fixed saving/loading of MDisps. This took longer than it should have because of a bug in SDNA, noted in the MDisps struct.
Undo/Redo should work correctly as well.
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 15 | ||||
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 18 |
2 files changed, 32 insertions, 1 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 7d0dd9e41c1..131fb03c292 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -2702,6 +2702,19 @@ static void direct_link_dverts(FileData *fd, int count, MDeformVert *mdverts) } } +static void direct_link_mdisps(FileData *fd, int count, MDisps *mdisps) +{ + if(mdisps) { + int i; + + for(i = 0; i < count; ++i) { + mdisps[i].disps = newdataadr(fd, mdisps[i].disps); + if(!mdisps[i].disps) + mdisps[i].totdisp = 0; + } + } +} + static void direct_link_customdata(FileData *fd, CustomData *data, int count) { int i = 0; @@ -2713,6 +2726,8 @@ static void direct_link_customdata(FileData *fd, CustomData *data, int count) if (CustomData_verify_versions(data, i)) { layer->data = newdataadr(fd, layer->data); + if(layer->type == CD_MDISPS) + direct_link_mdisps(fd, count, layer->data); i++; } } diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index b4a9f225470..e12a4d25ce2 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -1105,7 +1105,7 @@ static void write_curves(WriteData *wd, ListBase *idbase) static void write_dverts(WriteData *wd, int count, MDeformVert *dvlist) { if (dvlist) { - int i; + int i; /* Write the dvert list */ writestruct(wd, DATA, "MDeformVert", count, dvlist); @@ -1118,6 +1118,19 @@ static void write_dverts(WriteData *wd, int count, MDeformVert *dvlist) } } +static void write_mdisps(WriteData *wd, int count, MDisps *mdlist) +{ + if(mdlist) { + int i; + + writestruct(wd, DATA, "MDisps", count, mdlist); + for(i = 0; i < count; ++i) { + if(mdlist[i].disps) + writedata(wd, DATA, sizeof(float)*3*mdlist[i].totdisp, mdlist[i].disps); + } + } +} + static void write_customdata(WriteData *wd, int count, CustomData *data, int partial_type, int partial_count) { int i; @@ -1133,6 +1146,9 @@ static void write_customdata(WriteData *wd, int count, CustomData *data, int par /* layer types that allocate own memory need special handling */ write_dverts(wd, count, layer->data); } + else if (layer->type == CD_MDISPS) { + write_mdisps(wd, count, layer->data); + } else { CustomData_file_write_info(layer->type, &structname, &structnum); if (structnum) { |