Index: release/scripts/startup/bl_ui/space_view3d.py =================================================================== --- release/scripts/startup/bl_ui/space_view3d.py (revision 46911) +++ release/scripts/startup/bl_ui/space_view3d.py (working copy) @@ -2389,8 +2389,10 @@ col = layout.column() col.label(text="Shading:") col.prop(gs, "material_mode", text="") + col.prop(view, "use_back_face_culling") col.prop(view, "show_textured_solid") + layout.separator() region = view.region_quadview Index: source/blender/gpu/intern/gpu_draw.c =================================================================== --- source/blender/gpu/intern/gpu_draw.c (revision 46911) +++ source/blender/gpu/intern/gpu_draw.c (working copy) @@ -31,7 +31,6 @@ #include - #include "GL/glew.h" #include "BLI_math.h" @@ -1174,7 +1173,7 @@ GPUVertexAttribs *gattribs = attribs; GPUMaterial *gpumat; GPUBlendMode alphablend; - + /* no GPU_begin_object_materials, use default material */ if (!GMS.matbuf) { float diff[4], spec[4]; @@ -1190,7 +1189,6 @@ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diff); glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, spec); glMateriali(GL_FRONT_AND_BACK, GL_SHININESS, 35); /* blender default */ - return 0; } @@ -1247,6 +1245,18 @@ alphablend= mat->game.alpha_blend; if (GMS.is_alpha_pass) glDepthMask(1); + + if (G.bfcEnabled){ + if(mat->game.flag){ + glEnable(GL_CULL_FACE); + }else{ + glDisable(GL_CULL_FACE); + } + }else{ + glDisable(GL_CULL_FACE); + } + + } else { /* or do fixed function opengl material */ @@ -1258,7 +1268,7 @@ /* set (alpha) blending mode */ GPU_set_material_alpha_blend(alphablend); } - + return GMS.lastretval; } @@ -1310,6 +1320,7 @@ glLoadIdentity(); glMatrixMode(GL_MODELVIEW); } + } /* Lights */ Index: source/blender/makesrna/intern/rna_space.c =================================================================== --- source/blender/makesrna/intern/rna_space.c (revision 46911) +++ source/blender/makesrna/intern/rna_space.c (working copy) @@ -382,6 +382,7 @@ } } + static PointerRNA rna_SpaceView3D_region_3d_get(PointerRNA *ptr) { View3D *v3d = (View3D *)(ptr->data); @@ -1567,6 +1568,12 @@ RNA_def_property_ui_text(prop, "Textured Solid", "Display face-assigned textures in solid view"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + //BFC Property + prop = RNA_def_property(srna, "use_back_face_culling", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag2", V3D_USE_BFC); + RNA_def_property_ui_text(prop, "BackFace Culling", "Viewport Back Face Culling"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + prop = RNA_def_property(srna, "lock_camera", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag2", V3D_LOCK_CAMERA); RNA_def_property_ui_text(prop, "Lock Camera to View", "Enable view navigation within the camera view"); Index: source/blender/editors/space_view3d/drawobject.c =================================================================== --- source/blender/editors/space_view3d/drawobject.c (revision 46911) +++ source/blender/editors/space_view3d/drawobject.c (working copy) @@ -48,6 +48,7 @@ #include "DNA_world_types.h" #include "DNA_armature_types.h" #include "DNA_object_types.h" +#include "DNA_userdef_types.h" #include "BLI_utildefines.h" #include "BLI_blenlib.h" @@ -3108,6 +3109,7 @@ if (efa && !BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { GPU_enable_material(efa->mat_nr + 1, NULL); + return DM_DRAW_OPTION_NORMAL; } else @@ -3588,12 +3590,20 @@ /* returns 1 if nothing was drawn, for detecting to draw an object center */ static int draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d, Base *base, int dt, int flag) { + Object *ob = base->object; Object *obedit = scene->obedit; Mesh *me = ob->data; BMEditMesh *em = me->edit_btmesh; int do_alpha_after = FALSE, drawlinked = 0, retval = 0, glsl, check_alpha, i; + if (G.bfcEnabled){ + glEnable(GL_CULL_FACE); + }else{ + glDisable(GL_CULL_FACE); + } + + /* 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) { @@ -3669,7 +3679,13 @@ } } } - + + if (G.bfcEnabled){ + glEnable(GL_CULL_FACE); + }else{ + glDisable(GL_CULL_FACE); + } + return retval; } @@ -6438,6 +6454,10 @@ short dt, dtx, zbufoff = 0; const short is_obact = (ob == OBACT); + if(v3d->flag2 &V3D_USE_BFC){ + G.bfcEnabled = 1; + }else{G.bfcEnabled=0;} + /* only once set now, will be removed too, should become a global standard */ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -7202,6 +7222,8 @@ } free_old_images(); + glDisable(GL_CULL_FACE); + } /* ***************** BACKBUF SEL (BBS) ********* */ @@ -7371,6 +7393,7 @@ dm->drawMappedFaces(dm, bbs_mesh_solid__setDrawOpts, GPU_enable_material, NULL, me, 0); dm->release(dm); + } void draw_object_backbufsel(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob) Index: source/blender/blenkernel/BKE_global.h =================================================================== --- source/blender/blenkernel/BKE_global.h (revision 46911) +++ source/blender/blenkernel/BKE_global.h (working copy) @@ -77,6 +77,8 @@ /* Frank's variables */ int save_over; + int bfcEnabled; + /* Rob's variables (keep here for WM recode) */ int have_quicktime; int ui_international; Index: source/blender/makesdna/DNA_view3d_types.h =================================================================== --- source/blender/makesdna/DNA_view3d_types.h (revision 46911) +++ source/blender/makesdna/DNA_view3d_types.h (working copy) @@ -260,6 +260,7 @@ /* View3d->flag2 (short) */ #define V3D_RENDER_OVERRIDE 4 #define V3D_SOLID_TEX 8 +#define V3D_USE_BFC 1 #define V3D_DISPGP 16 #define V3D_LOCK_CAMERA 32 #define V3D_RENDER_SHADOW 64 /* This is a runtime only flag that's used to tell draw_mesh_object() that we're doing a shadow pass instead of a regular draw */