p_move.c
//
// Check if the thing intersects a linedef
//
Check if the thing intersects a linedef
Check if the thing intersects a linedef
static boolean PM_BoxCrossLine(line_t *ld)
{
   fixed_t x1, x2, y1, y2;
   fixed_t lx, ly, ldx, ldy;
   fixed_t dx1, dx2, dy1, dy2;
   boolean side1, side2;
   fixed_t *ldbbox = P_LineBBox(ld);
   if(tmbbox[BOXRIGHT ] <= ldbbox[BOXLEFT  ] ||
      tmbbox[BOXLEFT  ] >= ldbbox[BOXRIGHT ] ||
      tmbbox[BOXTOP   ] <= ldbbox[BOXBOTTOM] ||
      tmbbox[BOXBOTTOM] >= ldbbox[BOXTOP   ])
   {
      return false; 
   }
   y1 = tmbbox[BOXTOP   ];
   y2 = tmbbox[BOXBOTTOM];
   if(ld->slopetype == ST_POSITIVE)
   {
      x1 = tmbbox[BOXLEFT ];
      x2 = tmbbox[BOXRIGHT];
   }
   else
   {
      x1 = tmbbox[BOXRIGHT];
      x2 = tmbbox[BOXLEFT ];
   }
   lx  = ld->v1->x;
   ly  = ld->v1->y;
   ldx = (ld->v2->x - lx) >> FRACBITS;
   ldy = (ld->v2->y - ly) >> FRACBITS;
   dx1 = (x1 - lx) >> FRACBITS;
   dy1 = (y1 - ly) >> FRACBITS;
   dx2 = (x2 - lx) >> FRACBITS;
   dy2 = (y2 - ly) >> FRACBITS;
   side1 = (ldy * dx1 < dy1 * ldx);
   side2 = (ldy * dx2 < dy2 * ldx);
   return (side1 != side2);
}
static boolean PM_BoxCrossLine ( line_t * ld ) { fixed_t x1 , x2 , y1 , y2 ; fixed_t lx , ly , ldx , ldy ; fixed_t dx1 , dx2 , dy1 , dy2 ; boolean side1 , side2 ; fixed_t * ldbbox = P_LineBBox ( ld ) ; if ( tmbbox [ BOXRIGHT ] <= ldbbox [ BOXLEFT ] || tmbbox [ BOXLEFT ] >= ldbbox [ BOXRIGHT ] || tmbbox [ BOXTOP ] <= ldbbox [ BOXBOTTOM ] || tmbbox [ BOXBOTTOM ] >= ldbbox [ BOXTOP ] ) { return false ; } y1 = tmbbox [ BOXTOP ] ; y2 = tmbbox [ BOXBOTTOM ] ; if ( ld -> slopetype == ST_POSITIVE ) { x1 = tmbbox [ BOXLEFT ] ; x2 = tmbbox [ BOXRIGHT ] ; } else { x1 = tmbbox [ BOXRIGHT ] ; x2 = tmbbox [ BOXLEFT ] ; } lx = ld -> v1 -> x ; ly = ld -> v1 -> y ; ldx = ( ld -> v2 -> x - lx ) >> FRACBITS ; ldy = ( ld -> v2 -> y - ly ) >> FRACBITS ; dx1 = ( x1 - lx ) >> FRACBITS ; dy1 = ( y1 - ly ) >> FRACBITS ; dx2 = ( x2 - lx ) >> FRACBITS ; dy2 = ( y2 - ly ) >> FRACBITS ; side1 = ( ldy * dx1 < dy1 * ldx ) ; side2 = ( ldy * dx2 < dy2 * ldx ) ; return ( side1 != side2 ) ; }
Check if the thing intersects a linedef
Check if the thing intersects a linedef
// bounding boxes don't intersect