mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-24 21:21:04 +00:00
Improved point-on-line compatibility feature
P_PointOnLineSide() and P_PointOnDivlineSide() functions from the initial Doom source code release are used in compatibility mode
This commit is contained in:
parent
ee7eb3253a
commit
39b18a3447
2 changed files with 98 additions and 7 deletions
|
@ -240,10 +240,11 @@ fixed_t P_AproxDistance (fixed_t dx, fixed_t dy);
|
|||
|
||||
inline int P_PointOnLineSide (fixed_t x, fixed_t y, const line_t *line)
|
||||
{
|
||||
const SDWORD result = DMulScale32 (y-line->v1->y, line->dx, line->v1->x-x, line->dy);
|
||||
return (compatflags2 & COMPATF2_POINTONLINE)
|
||||
? result >= 0
|
||||
: result > 0;
|
||||
extern int P_VanillaPointOnLineSide(fixed_t x, fixed_t y, const line_t* line);
|
||||
|
||||
return compatflags2 & COMPATF2_POINTONLINE
|
||||
? P_VanillaPointOnLineSide(x, y, line)
|
||||
: DMulScale32 (y-line->v1->y, line->dx, line->v1->x-x, line->dy) > 0;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -257,10 +258,11 @@ inline int P_PointOnLineSide (fixed_t x, fixed_t y, const line_t *line)
|
|||
|
||||
inline int P_PointOnDivlineSide (fixed_t x, fixed_t y, const divline_t *line)
|
||||
{
|
||||
const SDWORD result = DMulScale32 (y-line->y, line->dx, line->x-x, line->dy);
|
||||
extern int P_VanillaPointOnDivlineSide(fixed_t x, fixed_t y, const divline_t* line);
|
||||
|
||||
return (compatflags2 & COMPATF2_POINTONLINE)
|
||||
? result >= 0
|
||||
: result > 0;
|
||||
? P_VanillaPointOnDivlineSide(x, y, line)
|
||||
: (DMulScale32 (y-line->y, line->dx, line->x-x, line->dy) > 0);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
|
@ -1523,3 +1523,92 @@ static AActor *RoughBlockCheck (AActor *mo, int index, void *param)
|
|||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// P_VanillaPointOnLineSide
|
||||
// P_PointOnLineSide() from the initial Doom source code release
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
int P_VanillaPointOnLineSide(fixed_t x, fixed_t y, const line_t* line)
|
||||
{
|
||||
fixed_t dx;
|
||||
fixed_t dy;
|
||||
fixed_t left;
|
||||
fixed_t right;
|
||||
|
||||
if (!line->dx)
|
||||
{
|
||||
if (x <= line->v1->x)
|
||||
return line->dy > 0;
|
||||
|
||||
return line->dy < 0;
|
||||
}
|
||||
if (!line->dy)
|
||||
{
|
||||
if (y <= line->v1->y)
|
||||
return line->dx < 0;
|
||||
|
||||
return line->dx > 0;
|
||||
}
|
||||
|
||||
dx = (x - line->v1->x);
|
||||
dy = (y - line->v1->y);
|
||||
|
||||
left = FixedMul ( line->dy>>FRACBITS , dx );
|
||||
right = FixedMul ( dy , line->dx>>FRACBITS );
|
||||
|
||||
if (right < left)
|
||||
return 0; // front side
|
||||
return 1; // back side
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// P_VanillaPointOnDivlineSide
|
||||
// P_PointOnDivlineSide() from the initial Doom source code release
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
int P_VanillaPointOnDivlineSide(fixed_t x, fixed_t y, const divline_t* line)
|
||||
{
|
||||
fixed_t dx;
|
||||
fixed_t dy;
|
||||
fixed_t left;
|
||||
fixed_t right;
|
||||
|
||||
if (!line->dx)
|
||||
{
|
||||
if (x <= line->x)
|
||||
return line->dy > 0;
|
||||
|
||||
return line->dy < 0;
|
||||
}
|
||||
if (!line->dy)
|
||||
{
|
||||
if (y <= line->y)
|
||||
return line->dx < 0;
|
||||
|
||||
return line->dx > 0;
|
||||
}
|
||||
|
||||
dx = (x - line->x);
|
||||
dy = (y - line->y);
|
||||
|
||||
// try to quickly decide by looking at sign bits
|
||||
if ( (line->dy ^ line->dx ^ dx ^ dy)&0x80000000 )
|
||||
{
|
||||
if ( (line->dy ^ dx) & 0x80000000 )
|
||||
return 1; // (left is negative)
|
||||
return 0;
|
||||
}
|
||||
|
||||
left = FixedMul ( line->dy>>8, dx>>8 );
|
||||
right = FixedMul ( dy>>8 , line->dx>>8 );
|
||||
|
||||
if (right < left)
|
||||
return 0; // front side
|
||||
return 1; // back side
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue