Orange: tuesday sync with bf-blender
[blender.git] / source / blender / renderconverter / intern / convertBlenderScene.c
index 14726c6ca849753ce6a0f238de8581a1da38e6cd..a4dbad1000a7c3bd1240486ae3875ed8d1e31776 100644 (file)
@@ -1382,13 +1382,13 @@ static void init_render_mesh(Object *ob)
        Material *ma;
        MSticky *ms = NULL;
        PartEff *paf;
+       DispListMesh *dlm = NULL;
+       DerivedMesh *dm;
        unsigned int *vertcol;
        float xn, yn, zn,  imat[3][3], mat[4][4];  //nor[3],
        float *orco=0;
        int a, a1, ok, need_orco=0, totvlako, totverto, vertofs;
-       int end, do_autosmooth=0, totvert = 0;
-       DispListMesh *dlm = NULL;
-       DerivedMesh *dm;
+       int end, do_autosmooth=0, totvert = 0, dm_needsfree;
        
        me= ob->data;
 
@@ -1424,7 +1424,18 @@ static void init_render_mesh(Object *ob)
        
        if(need_orco) orco = get_object_orco(ob);
        
-       dm = mesh_create_derived_render(ob);
+       /* duplicators don't call modifier stack */
+       if(ob->flag&OB_FROMDUPLI) {
+               dm= ob->derivedFinal;
+               dm_needsfree= 0;
+       }
+       else {
+               dm = mesh_create_derived_render(ob);
+               dm_needsfree= 1;
+       }
+       
+       if(dm==NULL) return;    /* in case duplicated object fails? */
+       
        dlm = dm->convertToDispListMesh(dm, 1);
 
        mvert= dlm->mvert;
@@ -1624,7 +1635,7 @@ static void init_render_mesh(Object *ob)
        calc_vertexnormals(totverto, totvlako);
 
        if(dlm) displistmesh_free(dlm);
-       dm->release(dm);
+       if(dm_needsfree) dm->release(dm);
 }
 
 /* ------------------------------------------------------------------------- */