svn merge ^/trunk/blender -r40720:40872
[blender.git] / source / blender / render / intern / source / convertblender.c
index 195b037727e0b9bb677646628fabb05480ed9ecd..c241603f64a4eb29112fb3ea4570e30f98e52970 100644 (file)
@@ -1524,7 +1524,7 @@ static void get_particle_uvco_mcol(short from, DerivedMesh *dm, float *fuv, int
        if(sd->uvco && ELEM(from,PART_FROM_FACE,PART_FROM_VOLUME)) {
                for(i=0; i<sd->totuv; i++) {
                        if(num != DMCACHE_NOTFOUND) {
        if(sd->uvco && ELEM(from,PART_FROM_FACE,PART_FROM_VOLUME)) {
                for(i=0; i<sd->totuv; i++) {
                        if(num != DMCACHE_NOTFOUND) {
-                               MFace *mface = dm->getFaceData(dm, num, CD_MFACE);
+                               MFace *mface = dm->getTessFaceData(dm, num, CD_MFACE);
                                MTFace *mtface = (MTFace*)CustomData_get_layer_n(&dm->faceData, CD_MTFACE, i);
                                mtface += num;
                                
                                MTFace *mtface = (MTFace*)CustomData_get_layer_n(&dm->faceData, CD_MTFACE, i);
                                mtface += num;
                                
@@ -1541,7 +1541,7 @@ static void get_particle_uvco_mcol(short from, DerivedMesh *dm, float *fuv, int
        if(sd->mcol && ELEM(from,PART_FROM_FACE,PART_FROM_VOLUME)) {
                for(i=0; i<sd->totcol; i++) {
                        if(num != DMCACHE_NOTFOUND) {
        if(sd->mcol && ELEM(from,PART_FROM_FACE,PART_FROM_VOLUME)) {
                for(i=0; i<sd->totcol; i++) {
                        if(num != DMCACHE_NOTFOUND) {
-                               MFace *mface = dm->getFaceData(dm, num, CD_MFACE);
+                               MFace *mface = dm->getTessFaceData(dm, num, CD_MFACE);
                                MCol *mc = (MCol*)CustomData_get_layer_n(&dm->faceData, CD_MCOL, i);
                                mc += num * 4;
 
                                MCol *mc = (MCol*)CustomData_get_layer_n(&dm->faceData, CD_MCOL, i);
                                mc += num * 4;
 
@@ -1752,8 +1752,8 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
                                if(ma->amb != 0.0f)
                                        dosurfacecache= 1;
 
                                if(ma->amb != 0.0f)
                                        dosurfacecache= 1;
 
-                       totface= psmd->dm->getNumFaces(psmd->dm);
-                       origindex= psmd->dm->getFaceDataArray(psmd->dm, CD_ORIGINDEX);
+                       totface= psmd->dm->getNumTessFaces(psmd->dm);
+                       origindex= psmd->dm->getTessFaceDataArray(psmd->dm, CD_ORIGINDEX);
                        for(a=0; a<totface; a++)
                                strandbuf->totbound= MAX2(strandbuf->totbound, (origindex)? origindex[a]: a);
 
                        for(a=0; a<totface; a++)
                                strandbuf->totbound= MAX2(strandbuf->totbound, (origindex)? origindex[a]: a);
 
@@ -1797,7 +1797,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
                        num= pa->num_dmcache;
 
                        if(num == DMCACHE_NOTFOUND)
                        num= pa->num_dmcache;
 
                        if(num == DMCACHE_NOTFOUND)
-                               if(pa->num < psmd->dm->getNumFaces(psmd->dm))
+                               if(pa->num < psmd->dm->getNumTessFaces(psmd->dm))
                                        num= pa->num;
 
                        get_particle_uvco_mcol(part->from, psmd->dm, pa->fuv, num, &sd);
                                        num= pa->num;
 
                        get_particle_uvco_mcol(part->from, psmd->dm, pa->fuv, num, &sd);
@@ -1856,7 +1856,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
                                num = parent->num_dmcache;
 
                                if(num == DMCACHE_NOTFOUND)
                                num = parent->num_dmcache;
 
                                if(num == DMCACHE_NOTFOUND)
-                                       if(parent->num < psmd->dm->getNumFaces(psmd->dm))
+                                       if(parent->num < psmd->dm->getNumTessFaces(psmd->dm))
                                                num = parent->num;
 
                                get_particle_uvco_mcol(part->from, psmd->dm, parent->fuv, num, &sd);
                                                num = parent->num;
 
                                get_particle_uvco_mcol(part->from, psmd->dm, parent->fuv, num, &sd);
@@ -2722,8 +2722,8 @@ static void init_render_dm(DerivedMesh *dm, Render *re, ObjectRen *obr,
                for(mat_iter= 0; (mat_iter < ob->totcol || (mat_iter==0 && ob->totcol==0)); mat_iter++) {
 
                        ma= give_render_material(re, ob, mat_iter+1);
                for(mat_iter= 0; (mat_iter < ob->totcol || (mat_iter==0 && ob->totcol==0)); mat_iter++) {
 
                        ma= give_render_material(re, ob, mat_iter+1);
-                       end= dm->getNumFaces(dm);
-                       mface= dm->getFaceArray(dm);
+                       end= dm->getNumTessFaces(dm);
+                       mface= dm->getTessFaceArray(dm);
 
                        for(a=0; a<end; a++, mface++) {
                                int v1, v2, v3, v4, flag;
 
                        for(a=0; a<end; a++, mface++) {
                                int v1, v2, v3, v4, flag;
@@ -3102,10 +3102,10 @@ static struct edgesort *make_mesh_edge_lookup(DerivedMesh *dm, int *totedgesort)
        unsigned int *mcol=NULL;
        int a, totedge=0, totface;
 
        unsigned int *mcol=NULL;
        int a, totedge=0, totface;
 
-       mface= dm->getFaceArray(dm);
-       totface= dm->getNumFaces(dm);
-       tface= dm->getFaceDataArray(dm, CD_MTFACE);
-       mcol= dm->getFaceDataArray(dm, CD_MCOL);
+       mface= dm->getTessFaceArray(dm);
+       totface= dm->getNumTessFaces(dm);
+       tface= dm->getTessFaceDataArray(dm, CD_MTFACE);
+       mcol= dm->getTessFaceDataArray(dm, CD_MCOL);
 
        if(mcol==NULL && tface==NULL) return NULL;
 
 
        if(mcol==NULL && tface==NULL) return NULL;
 
@@ -3326,7 +3326,7 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset)
        totvert= dm->getNumVerts(dm);
 
        /* attempt to autsmooth on original mesh, only without subsurf */
        totvert= dm->getNumVerts(dm);
 
        /* attempt to autsmooth on original mesh, only without subsurf */
-       if(do_autosmooth && me->totvert==totvert && me->totface==dm->getNumFaces(dm))
+       if(do_autosmooth && me->totvert==totvert && me->totface==dm->getNumTessFaces(dm))
                use_original_normals= 1;
        
        ms = (totvert==me->totvert)?me->msticky:NULL;
                use_original_normals= 1;
        
        ms = (totvert==me->totvert)?me->msticky:NULL;
@@ -3399,8 +3399,8 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset)
                                }
 
                                if(ok) {
                                }
 
                                if(ok) {
-                                       end= dm->getNumFaces(dm);
-                                       mface= dm->getFaceArray(dm);
+                                       end= dm->getNumTessFaces(dm);
+                                       mface= dm->getTessFaceArray(dm);
                                        
                                        for(a=0; a<end; a++, mface++) {
                                                int v1, v2, v3, v4, flag;
                                        
                                        for(a=0; a<end; a++, mface++) {
                                                int v1, v2, v3, v4, flag;
@@ -4359,9 +4359,9 @@ static void finalize_render_object(Render *re, ObjectRen *obr, int timeoffset)
 /* Database                                                                                                                                     */
 /* ------------------------------------------------------------------------- */
 
 /* Database                                                                                                                                     */
 /* ------------------------------------------------------------------------- */
 
-static int render_object_type(int type) 
+static int render_object_type(short type)
 {
 {
-       return ELEM5(type, OB_FONT, OB_CURVE, OB_SURF, OB_MESH, OB_MBALL);
+       return OB_TYPE_SUPPORT_MATERIAL(type);
 }
 
 static void find_dupli_instances(Render *re, ObjectRen *obr)
 }
 
 static void find_dupli_instances(Render *re, ObjectRen *obr)
@@ -4852,8 +4852,13 @@ static void database_init_objects(Render *re, unsigned int renderlay, int nolamp
         * NULL is just for init */
        set_dupli_tex_mat(NULL, NULL, NULL);
 
         * NULL is just for init */
        set_dupli_tex_mat(NULL, NULL, NULL);
 
-       for(SETLOOPER(re->scene, sce_iter, base)) {
-               ob= base->object;
+       /* loop over all objects rather then using SETLOOPER because we may
+        * reference an mtex-mapped object which isnt rendered or is an
+        * empty in a dupli group. We could scan all render material/lamp/world
+        * mtex's for mapto objects but its easier just to set the
+        * 'imat' / 'imat_ren' on all and unlikely to be a performance hit
+       * See bug: [#28744] - campbell */
+       for(ob= re->main->object.first; ob; ob= ob->id.next) {
                /* imat objects has to be done here, since displace can have texture using Object map-input */
                mul_m4_m4m4(mat, ob->obmat, re->viewmat);
                invert_m4_m4(ob->imat_ren, mat);
                /* imat objects has to be done here, since displace can have texture using Object map-input */
                mul_m4_m4m4(mat, ob->obmat, re->viewmat);
                invert_m4_m4(ob->imat_ren, mat);
@@ -5021,7 +5026,7 @@ void RE_Database_FromScene(Render *re, Main *bmain, Scene *scene, unsigned int l
        /* per second, per object, stats print this */
        re->i.infostr= "Preparing Scene data";
        re->i.cfra= scene->r.cfra;
        /* per second, per object, stats print this */
        re->i.infostr= "Preparing Scene data";
        re->i.cfra= scene->r.cfra;
-       strncpy(re->i.scenename, scene->id.name+2, 20);
+       BLI_strncpy(re->i.scenename, scene->id.name+2, sizeof(re->i.scenename));
        
        /* XXX add test if dbase was filled already? */
        
        
        /* XXX add test if dbase was filled already? */