- floatified line_t::bbox.

This commit is contained in:
Christoph Oelckers 2016-03-31 01:22:49 +02:00
parent 7a2c8fdc1c
commit f41afde545
6 changed files with 38 additions and 85 deletions

View File

@ -885,11 +885,8 @@ void P_NewChaseDir(AActor * actor)
double deltay = 0;
while ((line = it.Next()))
{
if (line->backsector && // Ignore one-sided linedefs
box.Right() > line->bbox[BOXLEFT] &&
box.Left() < line->bbox[BOXRIGHT] &&
box.Top() > line->bbox[BOXBOTTOM] && // Linedef must be contacted
box.Bottom() < line->bbox[BOXTOP] &&
if (line->backsector && // Ignore one-sided linedefs
box.inRange(line) &&
box.BoxOnLineSide(line) == -1)
{
double front = line->frontsector->floorplane.ZatPoint(actor->PosRelative(line));

View File

@ -403,10 +403,10 @@ bool AActor::FixMapthingPos()
}
// Not inside the line's bounding box
if (_f_X() + _f_radius() <= ldef->bbox[BOXLEFT]
|| _f_X() - _f_radius() >= ldef->bbox[BOXRIGHT]
|| _f_Y() + _f_radius() <= ldef->bbox[BOXBOTTOM]
|| _f_Y() - _f_radius() >= ldef->bbox[BOXTOP])
if (X() + radius <= ldef->bbox[BOXLEFT]
|| X() - radius >= ldef->bbox[BOXRIGHT]
|| Y() + radius <= ldef->bbox[BOXBOTTOM]
|| Y() - radius >= ldef->bbox[BOXTOP])
continue;
// Get the exact distance to the line

View File

@ -1905,26 +1905,26 @@ void P_AdjustLine (line_t *ld)
ld->setDelta(v2->fX() - v1->fX(), v2->fY() - v1->fY());
if (v1->fixX() < v2->fixX())
if (v1->fX() < v2->fX())
{
ld->bbox[BOXLEFT] = v1->fixX();
ld->bbox[BOXRIGHT] = v2->fixX();
ld->bbox[BOXLEFT] = v1->fX();
ld->bbox[BOXRIGHT] = v2->fX();
}
else
{
ld->bbox[BOXLEFT] = v2->fixX();
ld->bbox[BOXRIGHT] = v1->fixX();
ld->bbox[BOXLEFT] = v2->fX();
ld->bbox[BOXRIGHT] = v1->fX();
}
if (v1->fixY() < v2->fixY())
if (v1->fY() < v2->fY())
{
ld->bbox[BOXBOTTOM] = v1->fixY();
ld->bbox[BOXTOP] = v2->fixY();
ld->bbox[BOXBOTTOM] = v1->fY();
ld->bbox[BOXTOP] = v2->fY();
}
else
{
ld->bbox[BOXBOTTOM] = v2->fixY();
ld->bbox[BOXTOP] = v1->fixY();
ld->bbox[BOXBOTTOM] = v2->fY();
ld->bbox[BOXTOP] = v1->fY();
}
}

View File

@ -168,6 +168,7 @@ public:
// EXTERNAL FUNCTION PROTOTYPES --------------------------------------------
void PO_Init (void);
void P_AdjustLine(line_t *ld);
// PRIVATE FUNCTION PROTOTYPES ---------------------------------------------
@ -893,33 +894,7 @@ void FPolyObj::UpdateBBox ()
{
for(unsigned i=0;i<Linedefs.Size(); i++)
{
line_t *line = Linedefs[i];
if (line->v1->fixX() < line->v2->fixX())
{
line->bbox[BOXLEFT] = line->v1->fixX();
line->bbox[BOXRIGHT] = line->v2->fixX();
}
else
{
line->bbox[BOXLEFT] = line->v2->fixX();
line->bbox[BOXRIGHT] = line->v1->fixX();
}
if (line->v1->fixY() < line->v2->fixY())
{
line->bbox[BOXBOTTOM] = line->v1->fixY();
line->bbox[BOXTOP] = line->v2->fixY();
}
else
{
line->bbox[BOXBOTTOM] = line->v2->fixY();
line->bbox[BOXTOP] = line->v1->fixY();
}
// Update the line's slopetype
line->setDelta(
line->v2->fixX() - line->v1->fixX(),
line->v2->fixY() - line->v1->fixY());
P_AdjustLine(Linedefs[i]);
}
CalcCenter();
}
@ -987,10 +962,10 @@ void FPolyObj::DoMovePolyobj (const DVector2 &pos)
}
for (unsigned i = 0; i < Linedefs.Size(); i++)
{
Linedefs[i]->bbox[BOXTOP] += FLOAT2FIXED(pos.Y);
Linedefs[i]->bbox[BOXBOTTOM] += FLOAT2FIXED(pos.Y);
Linedefs[i]->bbox[BOXLEFT] += FLOAT2FIXED(pos.X);
Linedefs[i]->bbox[BOXRIGHT] += FLOAT2FIXED(pos.X);
Linedefs[i]->bbox[BOXTOP] += pos.Y;
Linedefs[i]->bbox[BOXBOTTOM] += pos.Y;
Linedefs[i]->bbox[BOXLEFT] += pos.X;
Linedefs[i]->bbox[BOXRIGHT] += pos.X;
}
}
@ -1120,10 +1095,10 @@ bool FPolyObj::CheckMobjBlocking (side_t *sd)
ld = sd->linedef;
top = GetSafeBlockY(ld->bbox[BOXTOP]-bmaporgy);
bottom = GetSafeBlockY(ld->bbox[BOXBOTTOM]-bmaporgy);
left = GetSafeBlockX(ld->bbox[BOXLEFT]-bmaporgx);
right = GetSafeBlockX(ld->bbox[BOXRIGHT]-bmaporgx);
top = int((ld->bbox[BOXTOP] - FIXED2DBL(bmaporgy)) / 128.);
bottom = int((ld->bbox[BOXBOTTOM] - FIXED2DBL(bmaporgy)) / 128.);
left = int((ld->bbox[BOXLEFT] - FIXED2DBL(bmaporgx)) / 128.);
right = int((ld->bbox[BOXRIGHT] - FIXED2DBL(bmaporgx)) / 128.);
blocked = false;
checker.Clear();
@ -1183,14 +1158,7 @@ bool FPolyObj::CheckMobjBlocking (side_t *sd)
FBoundingBox box(mobj->X(), mobj->Y(), mobj->radius);
if (box.Right() <= ld->bbox[BOXLEFT]
|| box.Left() >= ld->bbox[BOXRIGHT]
|| box.Top() <= ld->bbox[BOXBOTTOM]
|| box.Bottom() >= ld->bbox[BOXTOP])
{
continue;
}
if (box.BoxOnLineSide(ld) != -1)
if (!box.inRange(ld) || box.BoxOnLineSide(ld) != -1)
{
continue;
}
@ -1648,10 +1616,10 @@ static void TranslateToStartSpot (int tag, const DVector2 &origin)
}
for (unsigned i = 0; i < po->Linedefs.Size(); i++)
{
po->Linedefs[i]->bbox[BOXTOP] -= FLOAT2FIXED(delta.Y);
po->Linedefs[i]->bbox[BOXBOTTOM] -= FLOAT2FIXED(delta.Y);
po->Linedefs[i]->bbox[BOXLEFT] -= FLOAT2FIXED(delta.X);
po->Linedefs[i]->bbox[BOXRIGHT] -= FLOAT2FIXED(delta.X);
po->Linedefs[i]->bbox[BOXTOP] -= delta.Y;
po->Linedefs[i]->bbox[BOXBOTTOM] -= delta.Y;
po->Linedefs[i]->bbox[BOXLEFT] -= delta.X;
po->Linedefs[i]->bbox[BOXRIGHT] -= delta.X;
}
for (unsigned i = 0; i < po->Vertices.Size(); i++)
{

View File

@ -1174,13 +1174,7 @@ bool P_CollectConnectedGroups(int startgroup, const fixedvec3 &position, fixed_t
FBoundingBox box(position.x + disp.pos.x, position.y + disp.pos.y, checkradius);
if (box.Right() <= ld->bbox[BOXLEFT]
|| box.Left() >= ld->bbox[BOXRIGHT]
|| box.Top() <= ld->bbox[BOXBOTTOM]
|| box.Bottom() >= ld->bbox[BOXTOP])
continue; // not touched
if (box.BoxOnLineSide(linkedPortals[i]->mOrigin) != -1) continue; // not touched
if (!box.inRange(ld) || box.BoxOnLineSide(linkedPortals[i]->mOrigin) != -1) continue; // not touched
foundPortals.Push(linkedPortals[i]);
}
bool foundone = true;
@ -1241,13 +1235,7 @@ bool P_CollectConnectedGroups(int startgroup, const fixedvec3 &position, fixed_t
line_t *ld;
while ((ld = it.Next()))
{
if (box.Right() <= ld->bbox[BOXLEFT]
|| box.Left() >= ld->bbox[BOXRIGHT]
|| box.Top() <= ld->bbox[BOXBOTTOM]
|| box.Bottom() >= ld->bbox[BOXTOP])
continue;
if (box.BoxOnLineSide(ld) != -1)
if (!box.inRange(ld) || box.BoxOnLineSide(ld) != -1)
continue;
if (!(thisgroup & FPortalGroupArray::LOWER))

View File

@ -1407,7 +1407,7 @@ public:
fixed_t Alpha; // <--- translucency (0=invisibile, FRACUNIT=opaque)
int args[5]; // <--- hexen-style arguments (expanded to ZDoom's full width)
side_t *sidedef[2];
fixed_t bbox[4]; // bounding box, for the extent of the LineDef.
double bbox[4]; // bounding box, for the extent of the LineDef.
sector_t *frontsector, *backsector;
int validcount; // if == validcount, already checked
int locknumber; // [Dusk] lock number for special
@ -1672,10 +1672,10 @@ inline void AActor::ClearInterpolation()
inline bool FBoundingBox::inRange(const line_t *ld) const
{
return Left() < ld->bbox[BOXRIGHT] &&
Right() > ld->bbox[BOXLEFT] &&
Top() > ld->bbox[BOXBOTTOM] &&
Bottom() < ld->bbox[BOXTOP];
return FIXED2DBL(Left()) < ld->bbox[BOXRIGHT] &&
FIXED2DBL(Right()) > ld->bbox[BOXLEFT] &&
FIXED2DBL(Top()) > ld->bbox[BOXBOTTOM] &&
FIXED2DBL(Bottom()) < ld->bbox[BOXTOP];
}