Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2012-05-25 13:26:47 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2012-05-25 13:26:47 +0400
commit19dd66cf3b0108c0a74d7626b31c1b8cb9dd57fe (patch)
treeef7c42022e4adddf82a0bc5929f30d61aa976354 /source/blender/editors
parent29e89dc996c0addbc36b4d0051760842b4923bb6 (diff)
3D View: add Backface Culling option, to hide faces when seen from the back side,
found in the Display panel. Patch by Simon Kirk and Irie Shinsuke, refactored to also work for non-mesh objects and avoid globals.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/space_view3d/drawobject.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 780f4a2d86a..a5f3df4257a 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -3610,7 +3610,13 @@ static int draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
else if (ob->modifiers.first || obedit->modifiers.first) {}
else drawlinked = 1;
}
-
+
+ /* backface culling */
+ if (v3d->flag2 & V3D_BACKFACE_CULLING) {
+ glEnable(GL_CULL_FACE);
+ glCullFace(GL_BACK);
+ }
+
if (ob == obedit || drawlinked) {
DerivedMesh *finalDM, *cageDM;
@@ -3669,6 +3675,9 @@ static int draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
}
}
}
+
+ if (v3d->flag2 & V3D_BACKFACE_CULLING)
+ glDisable(GL_CULL_FACE);
return retval;
}
@@ -3939,7 +3948,17 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas
const short solid = (dt > OB_WIRE);
int retval = 0;
+ /* backface culling */
+ if(v3d->flag2 & V3D_BACKFACE_CULLING) {
+ /* not all displists use same in/out normal direction convention */
+ glEnable(GL_CULL_FACE);
+ glCullFace((ob->type == OB_MBALL) ? GL_BACK : GL_FRONT);
+ }
+
if (drawCurveDerivedMesh(scene, v3d, rv3d, base, dt) == 0) {
+ if (v3d->flag2 & V3D_BACKFACE_CULLING)
+ glDisable(GL_CULL_FACE);
+
return 0;
}
@@ -4045,6 +4064,9 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas
break;
}
+ if (v3d->flag2 & V3D_BACKFACE_CULLING)
+ glDisable(GL_CULL_FACE);
+
return retval;
}