Committing patch #25675 "Make "Cast Buffer Shadows" option work in viewport and BGE...
[blender.git] / source / blender / editors / space_view3d / drawobject.c
index ddc10d78cac0faabaa7667cdbc6a7a9bc6355fd1..3133ad131bbf0daf0409e6ec188709890a7323a4 100644 (file)
@@ -2843,8 +2843,20 @@ static int draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
        Object *ob= base->object;
        Object *obedit= scene->obedit;
        Mesh *me= ob->data;
+       Material *ma=NULL;
        EditMesh *em= me->edit_mesh;
-       int do_alpha_pass= 0, drawlinked= 0, retval= 0, glsl, check_alpha;
+       int do_alpha_pass= 0, drawlinked= 0, retval= 0, glsl, check_alpha, i;
+
+       /* If we are drawing shadows and any of the materials don't cast a shadow, then don't draw the object */
+       if (v3d->flag2 & V3D_RENDER_SHADOW)
+       {
+               for(i=0; i<ob->totcol; ++i)
+               {
+                       ma = give_current_material(ob, i);
+                       if (ma && !(ma->mode & MA_SHADBUF))
+                               return 1;
+               }
+       }
        
        if(obedit && ob!=obedit && ob->data==obedit->data) {
                if(ob_get_key(ob) || ob_get_key(obedit));