attempt optimizing P_PointOn stuff again
this time non inversed and wrong lel
This commit is contained in:
1 parent
51631dcb40
commit
2d5cf03ceb
1 file changed
+8
-15
+8
-15
@@ -136,7 +136,7 @@ void P_ClosestPointOnLine3D(fixed_t x, fixed_t y, fixed_t z, line_t *line, verte
|
||||
//
|
||||
INT32 P_PointOnLineSide(fixed_t x, fixed_t y, const line_t *line)
|
||||
{
|
||||
fixed_t dx, dy, left, right;
|
||||
fixed_t dx, dy;
|
||||
|
||||
if (!line->dx)
|
||||
return x <= line->v1->x ? line->dy > 0 : line->dy < 0;
|
||||
@@ -147,10 +147,7 @@ INT32 P_PointOnLineSide(fixed_t x, fixed_t y, const line_t *line)
|
||||
dx = (x - line->v1->x);
|
||||
dy = (y - line->v1->y);
|
||||
|
||||
left = FixedMul(line->dy>>FRACBITS, dx);
|
||||
right = FixedMul(dy, line->dx>>FRACBITS);
|
||||
|
||||
return right < left ? 0 : 1;
|
||||
return FixedMul(dy, line->dx>>FRACBITS) >= FixedMul(line->dy>>FRACBITS, dx) ? 1 : 0;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -210,7 +207,7 @@ INT32 P_BoxOnLineSide(fixed_t *tmbox, const line_t *ld)
|
||||
//
|
||||
static INT32 P_PointOnDivlineSide(fixed_t x, fixed_t y, divline_t *line)
|
||||
{
|
||||
fixed_t dx, dy, left, right;
|
||||
fixed_t dx, dy;
|
||||
|
||||
if (!line->dx)
|
||||
return x <= line->x ? line->dy > 0 : line->dy < 0;
|
||||
@@ -221,17 +218,13 @@ static INT32 P_PointOnDivlineSide(fixed_t x, fixed_t y, divline_t *line)
|
||||
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)
|
||||
return ((line->dy ^ dx) & 0x80000000) ? 1 : 0;
|
||||
|
||||
left = FixedMul(line->dy>>8, dx>>8);
|
||||
right = FixedMul(dy>>8, line->dx>>8);
|
||||
|
||||
return right < left ? 0 : 1;
|
||||
// Try to quickly decide by looking at sign bits.
|
||||
// also use a mask to avoid branch prediction
|
||||
INT32 mask = ((line->dy ^ line->dx ^ dx ^ dy) & 0x80000000);
|
||||
return ((mask & ((line->dy ^ dx) & 0x80000000)) | // (left is negative)
|
||||
(~mask & (FixedMul(dy>>8, line->dx>>8) >= FixedMul(line->dy>>8, dx>>8)))) ? 1 : 0;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// P_MakeDivline
|
||||
//
|
||||
|
||||
Reference in new issue
Block a user