diff options
author | Nicholas Bishop <nicholasbishop@gmail.com> | 2010-11-20 21:54:58 +0300 |
---|---|---|
committer | Nicholas Bishop <nicholasbishop@gmail.com> | 2010-11-20 21:54:58 +0300 |
commit | bf14b214813c48beea1c9ca50e58b6002ec869a6 (patch) | |
tree | 7fd72cc557fe9383f519a6c6cd2c752fec3e48dd /source/blender/blenkernel/intern | |
parent | 6eaf0ac8be90442083af73cc53bdbee75db4a179 (diff) |
== Multires ==
Fixed bug #20620, "VertColors and Flat/Soft imported from 2.49 are wrong
(MultiRes)" reported by Manuel R.
* Added function to load level-0 vertex colors
* Added function to load level-0 face flags
* Warning: the 2.5 multires modifier doesn't support multires vertex colors
or multires face flags; that data will be lost if you import it into 2.5.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/multires.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 5e3c147a99f..7f7433f8965 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -1325,6 +1325,52 @@ static void multires_load_old_dm(DerivedMesh *dm, Mesh *me, int totlvl) multires_mvert_to_ss(dm, vdst); } +/* Copy the first-level vcol data to the mesh, if it exists */ +/* Warning: higher-level vcol data will be lost */ +static void multires_load_old_vcols(Mesh *me) +{ + MultiresLevel *lvl; + MultiresColFace *colface; + MCol *mcol; + int i, j; + + if(!(lvl = me->mr->levels.first)) + return; + + if(!(colface = lvl->colfaces)) + return; + + /* older multires format never supported multiple vcol layers, + so we can assume the active vcol layer is the correct one */ + if(!(mcol = CustomData_get_layer(&me->fdata, CD_MCOL))) + return; + + for(i = 0; i < me->totface; ++i) { + for(j = 0; j < 4; ++j) { + mcol[i*4 + j].a = colface[i].col[j].a; + mcol[i*4 + j].r = colface[i].col[j].r; + mcol[i*4 + j].g = colface[i].col[j].g; + mcol[i*4 + j].b = colface[i].col[j].b; + } + } +} + +/* Copy the first-level face-flag data to the mesh */ +static void multires_load_old_face_flags(Mesh *me) +{ + MultiresLevel *lvl; + MultiresFace *faces; + int i; + + if(!(lvl = me->mr->levels.first)) + return; + + if(!(faces = lvl->faces)) + return; + + for(i = 0; i < me->totface; ++i) + me->mface[i].flag = faces[i].flag; +} void multires_load_old(Object *ob, Mesh *me) { @@ -1386,6 +1432,9 @@ void multires_load_old(Object *ob, Mesh *me) memset(&me->mr->vdata, 0, sizeof(CustomData)); memset(&me->mr->fdata, 0, sizeof(CustomData)); + multires_load_old_vcols(me); + multires_load_old_face_flags(me); + /* Remove the old multires */ multires_free(me->mr); me->mr= NULL; |