Mesa (master): swrast: fix incorrect tri culling in selection/feedback mode .

Brian Paul brianp at kemper.freedesktop.org
Thu Aug 27 22:55:13 UTC 2009


Module: Mesa
Branch: master
Commit: 8f4d66c5f893b49eb3973aa3b31a856314c045c7
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=8f4d66c5f893b49eb3973aa3b31a856314c045c7

Author: Brian Paul <brianp at vmware.com>
Date:   Thu Aug 27 16:50:03 2009 -0600

swrast: fix incorrect tri culling in selection/feedback mode.

See bug 16866.

---

 src/mesa/swrast/s_feedback.c |    4 ++--
 src/mesa/swrast/s_triangle.c |   12 +++++++-----
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/src/mesa/swrast/s_feedback.c b/src/mesa/swrast/s_feedback.c
index 7bb914b..47ed25e 100644
--- a/src/mesa/swrast/s_feedback.c
+++ b/src/mesa/swrast/s_feedback.c
@@ -58,7 +58,7 @@ void
 _swrast_feedback_triangle(GLcontext *ctx, const SWvertex *v0,
                           const SWvertex *v1, const SWvertex *v2)
 {
-   if (_swrast_culltriangle(ctx, v0, v1, v2)) {
+   if (!_swrast_culltriangle(ctx, v0, v1, v2)) {
       _mesa_feedback_token(ctx, (GLfloat) (GLint) GL_POLYGON_TOKEN);
       _mesa_feedback_token(ctx, (GLfloat) 3); /* three vertices */
 
@@ -113,7 +113,7 @@ void
 _swrast_select_triangle(GLcontext *ctx, const SWvertex *v0,
                         const SWvertex *v1, const SWvertex *v2)
 {
-   if (_swrast_culltriangle(ctx, v0, v1, v2)) {
+   if (!_swrast_culltriangle(ctx, v0, v1, v2)) {
       const GLfloat zs = 1.0F / ctx->DrawBuffer->_DepthMaxF;
 
       _mesa_update_hitflag( ctx, v0->attrib[FRAG_ATTRIB_WPOS][2] * zs );
diff --git a/src/mesa/swrast/s_triangle.c b/src/mesa/swrast/s_triangle.c
index 9260e35..1d2fed7 100644
--- a/src/mesa/swrast/s_triangle.c
+++ b/src/mesa/swrast/s_triangle.c
@@ -44,8 +44,9 @@
 #include "s_triangle.h"
 
 
-/*
- * Just used for feedback mode.
+/**
+ * Test if a triangle should be culled.  Used for feedback and selection mode.
+ * \return GL_TRUE if the triangle is to be culled, GL_FALSE otherwise.
  */
 GLboolean
 _swrast_culltriangle( GLcontext *ctx,
@@ -53,16 +54,17 @@ _swrast_culltriangle( GLcontext *ctx,
                       const SWvertex *v1,
                       const SWvertex *v2 )
 {
+   SWcontext *swrast = SWRAST_CONTEXT(ctx);
    GLfloat ex = v1->attrib[FRAG_ATTRIB_WPOS][0] - v0->attrib[FRAG_ATTRIB_WPOS][0];
    GLfloat ey = v1->attrib[FRAG_ATTRIB_WPOS][1] - v0->attrib[FRAG_ATTRIB_WPOS][1];
    GLfloat fx = v2->attrib[FRAG_ATTRIB_WPOS][0] - v0->attrib[FRAG_ATTRIB_WPOS][0];
    GLfloat fy = v2->attrib[FRAG_ATTRIB_WPOS][1] - v0->attrib[FRAG_ATTRIB_WPOS][1];
    GLfloat c = ex*fy-ey*fx;
 
-   if (c * SWRAST_CONTEXT(ctx)->_BackfaceCullSign > 0)
-      return 0;
+   if (c * swrast->_BackfaceSign * swrast->_BackfaceCullSign < 0.0F)
+      return GL_FALSE;
 
-   return 1;
+   return GL_TRUE;
 }
 
 




More information about the mesa-commit mailing list