summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2006-10-18 18:02:05 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2006-10-18 18:02:05 +0000
commita1a0a29a5ad93be00989881055931e78941304a5 (patch)
tree7fc187bf8d65f8c8f29c7754c9e30c111c64f497 /src
parentff893a83f1a764ad4b093582bf28ff5e42860049 (diff)
Fix broken line clipping.
When both ends of the line were clipped, we were using the new v0 instead of the original v0 when computing the location of the second vertex. Thus, the second vertex's position was incorrect. Thanks to Heath Feather for finding a test case.
Diffstat (limited to 'src')
-rw-r--r--src/mesa/tnl/t_vb_cliptmp.h11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/mesa/tnl/t_vb_cliptmp.h b/src/mesa/tnl/t_vb_cliptmp.h
index e5e379e151..788fe329ed 100644
--- a/src/mesa/tnl/t_vb_cliptmp.h
+++ b/src/mesa/tnl/t_vb_cliptmp.h
@@ -1,6 +1,6 @@
/*
* Mesa 3-D graphics library
- * Version: 6.5.1
+ * Version: 6.5.2
*
* Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
*
@@ -125,6 +125,7 @@ TAG(clip_line)( GLcontext *ctx, GLuint v0, GLuint v1, GLubyte mask )
GLfloat t0 = 0;
GLfloat t1 = 0;
GLuint p;
+ const GLuint v0_orig = v0;
if (mask & 0x3f) {
LINE_CLIP( CLIP_RIGHT_BIT, -1, 0, 0, 1 );
@@ -157,9 +158,13 @@ TAG(clip_line)( GLcontext *ctx, GLuint v0, GLuint v1, GLubyte mask )
ASSERT(t0 == 0.0);
}
+ /* Note: we need to use vertex v0_orig when computing the new
+ * interpolated/clipped vertex position, not the current v0 which
+ * may have got set when we clipped the other end of the line!
+ */
if (VB->ClipMask[v1]) {
- INTERP_4F( t1, coord[newvert], coord[v1], coord[v0] );
- interp( ctx, t1, newvert, v1, v0, GL_FALSE );
+ INTERP_4F( t1, coord[newvert], coord[v1], coord[v0_orig] );
+ interp( ctx, t1, newvert, v1, v0_orig, GL_FALSE );
if (ctx->Light.ShadeModel == GL_FLAT)
tnl->Driver.Render.CopyPV( ctx, newvert, v1 );