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,6 +2389,7 @@ 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() 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" @@ -3594,6 +3595,11 @@ 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) { @@ -3670,6 +3676,11 @@ } } + if (G.bfcEnabled) + glEnable(GL_CULL_FACE); + else + glDisable(GL_CULL_FACE); + return retval; } @@ -6438,6 +6449,11 @@ 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 +7218,7 @@ } free_old_images(); + glDisable(GL_CULL_FACE); } /* ***************** BACKBUF SEL (BBS) ********* */ 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 */ 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) @@ -1247,6 +1247,16 @@ 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 */ 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) @@ -1567,6 +1567,11 @@ 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); + 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");