Fix #32082: face textures lost when linking scene from another file
authorSergey Sharybin <sergey.vfx@gmail.com>
Thu, 12 Jul 2012 07:30:50 +0000 (07:30 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Thu, 12 Jul 2012 07:30:50 +0000 (07:30 +0000)
Issue was caused by missing expand for MTexPoly-s tpages.

source/blender/blenloader/intern/readfile.c

index 14860509d81002285b39e870d0a6c7b758171754..4a5eabc761578a4214338256d93552053d6096e1 100644 (file)
@@ -8519,7 +8519,6 @@ static void expand_curve(FileData *fd, Main *mainvar, Curve *cu)
 static void expand_mesh(FileData *fd, Main *mainvar, Mesh *me)
 {
        CustomDataLayer *layer;
-       MTFace *mtf;
        TFace *tf;
        int a, i;
        
@@ -8541,14 +8540,34 @@ static void expand_mesh(FileData *fd, Main *mainvar, Mesh *me)
                }
        }
 
-       for (a = 0; a < me->fdata.totlayer; a++) {
-               layer = &me->fdata.layers[a];
-               
-               if (layer->type == CD_MTFACE) {
-                       mtf = (MTFace*)layer->data;
-                       for (i = 0; i < me->totface; i++, mtf++) {
-                               if (mtf->tpage)
-                                       expand_doit(fd, mainvar, mtf->tpage);
+       if (me->mface && !me->mpoly) {
+               MTFace *mtf;
+
+               for (a = 0; a < me->fdata.totlayer; a++) {
+                       layer = &me->fdata.layers[a];
+
+                       if (layer->type == CD_MTFACE) {
+                               mtf = (MTFace *) layer->data;
+                               for (i = 0; i < me->totface; i++, mtf++) {
+                                       if (mtf->tpage)
+                                               expand_doit(fd, mainvar, mtf->tpage);
+                               }
+                       }
+               }
+       }
+       else {
+               MTexPoly *mtp;
+
+               for (a = 0; a < me->pdata.totlayer; a++) {
+                       layer = &me->pdata.layers[a];
+
+                       if (layer->type == CD_MTEXPOLY) {
+                               mtp = (MTexPoly *) layer->data;
+
+                               for (i = 0; i < me->totpoly; i++, mtp++) {
+                                       if (mtp->tpage)
+                                               expand_doit(fd, mainvar, mtp->tpage);
+                               }
                        }
                }
        }