Tuesday merger of bf-blender into orange branch.
[blender-staging.git] / source / blender / blenkernel / intern / displist.c
index e3ce24fe19082dfb25c18c56157dee6e37d8d7bb..668e8d6e71c299b04507b9ae885f5c4c4e0ee1ac 100644 (file)
@@ -542,6 +542,7 @@ static void fastshade(float *co, float *nor, float *orco, Material *ma, char *co
                        if(ma->diff_shader==MA_DIFF_ORENNAYAR) is= OrenNayar_Diff(nor, lv, shi.view, ma->roughness);
                        else if(ma->diff_shader==MA_DIFF_TOON) is= Toon_Diff(nor, lv, shi.view, ma->param[0], ma->param[1]);
                        else if(ma->diff_shader==MA_DIFF_MINNAERT) is= Minnaert_Diff(is, nor, shi.view, ma->darkness);
+                       else if(ma->diff_shader==MA_DIFF_FRESNEL) is= Fresnel_Diff(nor, lv, shi.view, ma->param[0], ma->param[1]);
                }
                
                back= 0;
@@ -731,15 +732,6 @@ static void init_fastshade_for_ob(Object *ob, int *need_orco_r, float mat[4][4],
                }
        }
 }
-static void end_fastshade_for_ob(Object *ob)
-{
-       int a;
-
-       for(a=0; a<ob->totcol; a++) {
-               Material *ma= give_current_material(ob, a+1);
-               if(ma) end_render_material(ma);
-       }
-}
 
 void mesh_create_shadedColors(Object *ob, int onlyForMesh, unsigned int **col1_r, unsigned int **col2_r)
 {
@@ -851,11 +843,12 @@ void mesh_create_shadedColors(Object *ob, int onlyForMesh, unsigned int **col1_r
 
        if (dmNeedsFree) dm->release(dm);
 
-       end_fastshade_for_ob(ob);
 }
 
-void shadeDispList(Object *ob)
+/* has base pointer, to check for layer */
+void shadeDispList(Base *base)
 {
+       Object *ob= base->object;
        DispList *dl, *dlob;
        Material *ma = NULL;
        Curve *cu;
@@ -864,8 +857,6 @@ void shadeDispList(Object *ob)
        unsigned int *col1;
        int a;
 
-       if(ob->flag & OB_FROMDUPLI) return;
-
        dl = find_displist(&ob->disp, DL_VERTCOL);
        if (dl) {
                BLI_remlink(&ob->disp, dl);
@@ -991,8 +982,6 @@ void shadeDispList(Object *ob)
                        dl= dl->next;
                }
        }
-       
-       end_fastshade_for_ob(ob);
 }
 
 void reshadeall_displist(void)
@@ -1002,16 +991,13 @@ void reshadeall_displist(void)
        
        freefastshade();
        
-       base= G.scene->base.first;
-       while(base) {
+       for(base= G.scene->base.first; base; base= base->next) {
+               ob= base->object;
+               freedisplist(&ob->disp);
                if(base->lay & G.scene->lay) {
-                       ob= base->object;
-                       
                        /* Metaballs have standard displist at the Object */
-                       if(ob->type==OB_MBALL) shadeDispList(ob);
-                       else freedisplist(&ob->disp);
+                       if(ob->type==OB_MBALL) shadeDispList(base);
                }
-               base= base->next;
        }
 }
 
@@ -1244,7 +1230,7 @@ void filldisplist(ListBase *dispbase, ListBase *to)
                                        f1+= 3;
        
                                        /* index number */
-                                       eve->vn= (EditVert *)totvert;
+                                       eve->tmp.l = totvert;
                                        totvert++;
                                        
                                        eve= eve->next;
@@ -1254,9 +1240,9 @@ void filldisplist(ListBase *dispbase, ListBase *to)
                                efa= fillfacebase.first;
                                index= dlnew->index;
                                while(efa) {
-                                       index[0]= (long)efa->v1->vn;
-                                       index[1]= (long)efa->v2->vn;
-                                       index[2]= (long)efa->v3->vn;
+                                       index[0]= (long)efa->v1->tmp.l;
+                                       index[1]= (long)efa->v2->tmp.l;
+                                       index[2]= (long)efa->v3->tmp.l;
                                        
                                        index+= 3;
                                        efa= efa->next;
@@ -1404,7 +1390,7 @@ static float calc_taper(Object *taperobj, int cur, int tot)
 
 void makeDispListMBall(Object *ob)
 {
-       if(!ob || (ob->flag&OB_FROMDUPLI) || ob->type!=OB_MBALL) return;
+       if(!ob || ob->type!=OB_MBALL) return;
 
        freedisplist(&(ob->disp));
        
@@ -1591,9 +1577,9 @@ void makeDispListCurveTypes(Object *ob, int forOrco)
 {
        Curve *cu = ob->data;
        ListBase *dispbase;
-
-       if((ob->flag&OB_FROMDUPLI) || !ELEM3(ob->type, OB_SURF, OB_CURVE, OB_FONT)) return;
-       if(ob->flag & OB_FROMDUPLI) return;
+       
+       /* we do allow duplis... this is only displist on curve level */
+       if(!ELEM3(ob->type, OB_SURF, OB_CURVE, OB_FONT)) return;
 
        freedisplist(&(ob->disp));
        dispbase= &(cu->disp);
@@ -2004,8 +1990,6 @@ void imagestodisplist(void)
                base= base->next;
        }
        
-       end_render_textures();
-       
        allqueue(REDRAWVIEW3D, 0);
 }