From cdd38d487a311e6c71b76382d428f5dc26caf067 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Wed, 3 Oct 2007 10:08:45 -0400 Subject: Unify handling of userplanes and regular planes to simplify the clipping code. (really done by Keith) --- src/mesa/pipe/draw/draw_clip.c | 52 +++++------------------------------------- 1 file changed, 6 insertions(+), 46 deletions(-) (limited to 'src/mesa/pipe/draw/draw_clip.c') diff --git a/src/mesa/pipe/draw/draw_clip.c b/src/mesa/pipe/draw/draw_clip.c index a505146047..4e1483f025 100644 --- a/src/mesa/pipe/draw/draw_clip.c +++ b/src/mesa/pipe/draw/draw_clip.c @@ -50,13 +50,6 @@ #endif -/** bitmask for the first view-frustum clip planes */ -#define VIEWPLANE_MASK ((1 << 6) - 1) - -/** bitmask for the user-defined clip planes */ -#define USERPLANE_MASK (((1 << PIPE_MAX_CLIP_PLANES) - 1) << 6) - - struct clipper { struct draw_stage stage; /**< base class */ @@ -335,10 +328,6 @@ do_clip_line( struct draw_stage *stage, const float dp0 = dot4( pos0, plane ); const float dp1 = dot4( pos1, plane ); - /* need this to handle user-clip planes properly */ - if (dp0 < 0.0F && dp1 < 0.0F) - return; - if (dp1 < 0.0F) { float t = dp1 / (dp1 - dp0); t1 = MAX2(t1, t); @@ -392,21 +381,8 @@ static void clip_point( struct draw_stage *stage, struct prim_header *header ) { - if (header->v[0]->clipmask == 0) { + if (header->v[0]->clipmask == 0) stage->next->point( stage->next, header ); - } - else if (header->v[0]->clipmask & USERPLANE_MASK) { - /* test against user clip planes now */ - const struct clipper *clipper = clipper_stage( stage ); - uint i; - for (i = 6; i < stage->draw->nr_planes; i++) { - float dot = dot4(clipper->plane[i], header->v[0]->clip); - if (dot < 0.0F) - return; /* clipped! */ - } - /* not clipped */ - stage->next->point( stage->next, header ); - } } @@ -421,22 +397,8 @@ clip_line( struct draw_stage *stage, /* no clipping needed */ stage->next->line( stage->next, header ); } - else if (((header->v[0]->clipmask & - header->v[1]->clipmask & - VIEWPLANE_MASK) == 0) || - (clipmask & USERPLANE_MASK)) { - /* About the above predicate: the clipmask bits for the view volume - * exactly indicate whether the coordinate is inside or outside each - * frustum plane. However, the bits for user-defined planes are set - * if the plane is enabled, and does not really indicate if the - * coordinate is inside or outside the user-defined plane. - * - * To change this (so that the user-plane bits really indicate - * inside/outside) we'd have to compute the dot products earlier - * in the draw_prim.c code (see compute_clipmask()). - * We will probably do that when we have support for user clip coord - * in vertex shaders... - */ + else if ((header->v[0]->clipmask & + header->v[1]->clipmask) == 0) { do_clip_line(stage, header, clipmask); } /* else, totally clipped */ @@ -455,11 +417,9 @@ clip_tri( struct draw_stage *stage, /* no clipping needed */ stage->next->tri( stage->next, header ); } - else if (((header->v[0]->clipmask & - header->v[1]->clipmask & - header->v[2]->clipmask & - VIEWPLANE_MASK) == 0) || - (clipmask & USERPLANE_MASK)) { + else if ((header->v[0]->clipmask & + header->v[1]->clipmask & + header->v[2]->clipmask) == 0) { do_clip_tri(stage, header, clipmask); } } -- cgit v1.2.3