mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-10 23:01:50 +00:00
- floatified the remaining parts of p_sector.cpp.
This commit is contained in:
parent
66929cbaff
commit
27bad66f61
2 changed files with 43 additions and 55 deletions
|
@ -892,14 +892,14 @@ void sector_t::CheckPortalPlane(int plane)
|
||||||
double sector_t::HighestCeilingAt(const DVector2 &p, sector_t **resultsec)
|
double sector_t::HighestCeilingAt(const DVector2 &p, sector_t **resultsec)
|
||||||
{
|
{
|
||||||
sector_t *check = this;
|
sector_t *check = this;
|
||||||
fixed_t planeheight = FIXED_MIN;
|
double planeheight = -FLT_MAX;
|
||||||
DVector2 pos = p;
|
DVector2 pos = p;
|
||||||
|
|
||||||
// Continue until we find a blocking portal or a portal below where we actually are.
|
// Continue until we find a blocking portal or a portal below where we actually are.
|
||||||
while (!check->PortalBlocksMovement(ceiling) && planeheight < FLOAT2FIXED(check->SkyBoxes[ceiling]->specialf1))
|
while (!check->PortalBlocksMovement(ceiling) && planeheight < check->SkyBoxes[ceiling]->specialf1)
|
||||||
{
|
{
|
||||||
pos += check->CeilingDisplacement();
|
pos += check->CeilingDisplacement();
|
||||||
planeheight = FLOAT2FIXED(check->SkyBoxes[ceiling]->specialf1);
|
planeheight = check->SkyBoxes[ceiling]->specialf1;
|
||||||
check = P_PointInSector(pos);
|
check = P_PointInSector(pos);
|
||||||
}
|
}
|
||||||
if (resultsec) *resultsec = check;
|
if (resultsec) *resultsec = check;
|
||||||
|
@ -915,14 +915,14 @@ double sector_t::HighestCeilingAt(const DVector2 &p, sector_t **resultsec)
|
||||||
double sector_t::LowestFloorAt(const DVector2 &p, sector_t **resultsec)
|
double sector_t::LowestFloorAt(const DVector2 &p, sector_t **resultsec)
|
||||||
{
|
{
|
||||||
sector_t *check = this;
|
sector_t *check = this;
|
||||||
fixed_t planeheight = FIXED_MAX;
|
double planeheight = FLT_MAX;
|
||||||
DVector2 pos = p;
|
DVector2 pos = p;
|
||||||
|
|
||||||
// Continue until we find a blocking portal or a portal above where we actually are.
|
// Continue until we find a blocking portal or a portal above where we actually are.
|
||||||
while (!check->PortalBlocksMovement(floor) && planeheight > FLOAT2FIXED(check->SkyBoxes[floor]->specialf1))
|
while (!check->PortalBlocksMovement(floor) && planeheight > check->SkyBoxes[floor]->specialf1)
|
||||||
{
|
{
|
||||||
pos += check->FloorDisplacement();
|
pos += check->FloorDisplacement();
|
||||||
planeheight = FLOAT2FIXED(check->SkyBoxes[floor]->specialf1);
|
planeheight = check->SkyBoxes[floor]->specialf1;
|
||||||
check = P_PointInSector(pos);
|
check = P_PointInSector(pos);
|
||||||
}
|
}
|
||||||
if (resultsec) *resultsec = check;
|
if (resultsec) *resultsec = check;
|
||||||
|
@ -930,34 +930,34 @@ double sector_t::LowestFloorAt(const DVector2 &p, sector_t **resultsec)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fixed_t sector_t::NextHighestCeilingAt(fixed_t x, fixed_t y, fixed_t bottomz, fixed_t topz, int flags, sector_t **resultsec, F3DFloor **resultffloor)
|
double sector_t::NextHighestCeilingAt(double x, double y, double bottomz, double topz, int flags, sector_t **resultsec, F3DFloor **resultffloor)
|
||||||
{
|
{
|
||||||
sector_t *sec = this;
|
sector_t *sec = this;
|
||||||
fixed_t planeheight = FIXED_MIN;
|
double planeheight = -FLT_MAX;
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
// Looking through planes from bottom to top
|
// Looking through planes from bottom to top
|
||||||
fixed_t realceil = sec->ceilingplane.ZatPoint(x, y);
|
double realceil = sec->ceilingplane.ZatPoint(x, y);
|
||||||
for (int i = sec->e->XFloor.ffloors.Size() - 1; i >= 0; --i)
|
for (int i = sec->e->XFloor.ffloors.Size() - 1; i >= 0; --i)
|
||||||
{
|
{
|
||||||
F3DFloor *rover = sec->e->XFloor.ffloors[i];
|
F3DFloor *rover = sec->e->XFloor.ffloors[i];
|
||||||
if (!(rover->flags & FF_SOLID) || !(rover->flags & FF_EXISTS)) continue;
|
if (!(rover->flags & FF_SOLID) || !(rover->flags & FF_EXISTS)) continue;
|
||||||
|
|
||||||
fixed_t ff_bottom = rover->bottom.plane->ZatPoint(x, y);
|
double ff_bottom = rover->bottom.plane->ZatPoint(x, y);
|
||||||
fixed_t ff_top = rover->top.plane->ZatPoint(x, y);
|
double ff_top = rover->top.plane->ZatPoint(x, y);
|
||||||
|
|
||||||
fixed_t delta1 = bottomz - (ff_bottom + ((ff_top - ff_bottom) / 2));
|
double delta1 = bottomz - (ff_bottom + ((ff_top - ff_bottom) / 2));
|
||||||
fixed_t delta2 = topz - (ff_bottom + ((ff_top - ff_bottom) / 2));
|
double delta2 = topz - (ff_bottom + ((ff_top - ff_bottom) / 2));
|
||||||
|
|
||||||
if (ff_bottom < realceil && abs(delta1) > abs(delta2))
|
if (ff_bottom < realceil && fabs(delta1) > fabs(delta2))
|
||||||
{
|
{
|
||||||
if (resultsec) *resultsec = sec;
|
if (resultsec) *resultsec = sec;
|
||||||
if (resultffloor) *resultffloor = rover;
|
if (resultffloor) *resultffloor = rover;
|
||||||
return ff_bottom;
|
return ff_bottom;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((flags & FFCF_NOPORTALS) || sec->PortalBlocksMovement(ceiling) || planeheight >= FLOAT2FIXED(sec->SkyBoxes[ceiling]->specialf1))
|
if ((flags & FFCF_NOPORTALS) || sec->PortalBlocksMovement(ceiling) || planeheight >= sec->SkyBoxes[ceiling]->specialf1)
|
||||||
{ // Use sector's floor
|
{ // Use sector's floor
|
||||||
if (resultffloor) *resultffloor = NULL;
|
if (resultffloor) *resultffloor = NULL;
|
||||||
if (resultsec) *resultsec = sec;
|
if (resultsec) *resultsec = sec;
|
||||||
|
@ -966,23 +966,23 @@ fixed_t sector_t::NextHighestCeilingAt(fixed_t x, fixed_t y, fixed_t bottomz, fi
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DVector2 pos = sec->CeilingDisplacement();
|
DVector2 pos = sec->CeilingDisplacement();
|
||||||
x += FLOAT2FIXED(pos.X);
|
x += pos.X;
|
||||||
y += FLOAT2FIXED(pos.Y);
|
y += pos.Y;
|
||||||
planeheight = FLOAT2FIXED(sec->SkyBoxes[ceiling]->specialf1);
|
planeheight = sec->SkyBoxes[ceiling]->specialf1;
|
||||||
sec = P_PointInSector(x, y);
|
sec = P_PointInSector(x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fixed_t sector_t::NextLowestFloorAt(fixed_t x, fixed_t y, fixed_t z, int flags, fixed_t steph, sector_t **resultsec, F3DFloor **resultffloor)
|
double sector_t::NextLowestFloorAt(double x, double y, double z, int flags, double steph, sector_t **resultsec, F3DFloor **resultffloor)
|
||||||
{
|
{
|
||||||
sector_t *sec = this;
|
sector_t *sec = this;
|
||||||
fixed_t planeheight = FIXED_MAX;
|
double planeheight = FLT_MAX;
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
// Looking through planes from top to bottom
|
// Looking through planes from top to bottom
|
||||||
unsigned numff = sec->e->XFloor.ffloors.Size();
|
unsigned numff = sec->e->XFloor.ffloors.Size();
|
||||||
fixed_t realfloor = sec->floorplane.ZatPoint(x, y);
|
double realfloor = sec->floorplane.ZatPoint(x, y);
|
||||||
for (unsigned i = 0; i < numff; ++i)
|
for (unsigned i = 0; i < numff; ++i)
|
||||||
{
|
{
|
||||||
F3DFloor *ff = sec->e->XFloor.ffloors[i];
|
F3DFloor *ff = sec->e->XFloor.ffloors[i];
|
||||||
|
@ -991,8 +991,8 @@ fixed_t sector_t::NextLowestFloorAt(fixed_t x, fixed_t y, fixed_t z, int flags,
|
||||||
// either with feet above the 3D floor or feet with less than 'stepheight' map units inside
|
// either with feet above the 3D floor or feet with less than 'stepheight' map units inside
|
||||||
if ((ff->flags & (FF_EXISTS | FF_SOLID)) == (FF_EXISTS | FF_SOLID))
|
if ((ff->flags & (FF_EXISTS | FF_SOLID)) == (FF_EXISTS | FF_SOLID))
|
||||||
{
|
{
|
||||||
fixed_t ffz = ff->top.plane->ZatPoint(x, y);
|
double ffz = ff->top.plane->ZatPoint(x, y);
|
||||||
fixed_t ffb = ff->bottom.plane->ZatPoint(x, y);
|
double ffb = ff->bottom.plane->ZatPoint(x, y);
|
||||||
|
|
||||||
if (ffz > realfloor && (z >= ffz || (!(flags & FFCF_3DRESTRICT) && (ffb < z && ffz < z + steph))))
|
if (ffz > realfloor && (z >= ffz || (!(flags & FFCF_3DRESTRICT) && (ffb < z && ffz < z + steph))))
|
||||||
{ // This floor is beneath our feet.
|
{ // This floor is beneath our feet.
|
||||||
|
@ -1002,7 +1002,7 @@ fixed_t sector_t::NextLowestFloorAt(fixed_t x, fixed_t y, fixed_t z, int flags,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((flags & FFCF_NOPORTALS) || sec->PortalBlocksMovement(sector_t::floor) || planeheight <= FLOAT2FIXED(sec->SkyBoxes[floor]->specialf1))
|
if ((flags & FFCF_NOPORTALS) || sec->PortalBlocksMovement(sector_t::floor) || planeheight <= sec->SkyBoxes[floor]->specialf1)
|
||||||
{ // Use sector's floor
|
{ // Use sector's floor
|
||||||
if (resultffloor) *resultffloor = NULL;
|
if (resultffloor) *resultffloor = NULL;
|
||||||
if (resultsec) *resultsec = sec;
|
if (resultsec) *resultsec = sec;
|
||||||
|
@ -1011,9 +1011,9 @@ fixed_t sector_t::NextLowestFloorAt(fixed_t x, fixed_t y, fixed_t z, int flags,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DVector2 pos = sec->FloorDisplacement();
|
DVector2 pos = sec->FloorDisplacement();
|
||||||
x += FLOAT2FIXED(pos.X);
|
x += pos.X;
|
||||||
y += FLOAT2FIXED(pos.Y);
|
y += pos.Y;
|
||||||
planeheight = FLOAT2FIXED(sec->SkyBoxes[floor]->specialf1);
|
planeheight = sec->SkyBoxes[floor]->specialf1;
|
||||||
sec = P_PointInSector(x, y);
|
sec = P_PointInSector(x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1087,18 +1087,18 @@ bool secplane_t::CopyPlaneIfValid (secplane_t *dest, const secplane_t *opp) cons
|
||||||
|
|
||||||
// If the planes do not have matching slopes, then always copy them
|
// If the planes do not have matching slopes, then always copy them
|
||||||
// because clipping would require creating new sectors.
|
// because clipping would require creating new sectors.
|
||||||
if (a != dest->a || b != dest->b || c != dest->c)
|
if (fA() != dest->fA() || fB() != dest->fB() || fC() != dest->fC())
|
||||||
{
|
{
|
||||||
copy = true;
|
copy = true;
|
||||||
}
|
}
|
||||||
else if (opp->a != -dest->a || opp->b != -dest->b || opp->c != -dest->c)
|
else if (opp->fA() != -dest->fA() || opp->fB() != -dest->fB() || opp->fC() != -dest->fC())
|
||||||
{
|
{
|
||||||
if (d < dest->d)
|
if (fD() < dest->fD())
|
||||||
{
|
{
|
||||||
copy = true;
|
copy = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (d < dest->d && d > -opp->d)
|
else if (fD() < dest->fD() && fD() > -opp->fD())
|
||||||
{
|
{
|
||||||
copy = true;
|
copy = true;
|
||||||
}
|
}
|
||||||
|
@ -1136,21 +1136,19 @@ bool P_AlignFlat (int linenum, int side, int fc)
|
||||||
if (!sec)
|
if (!sec)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
fixed_t x = line->v1->fixX();
|
DVector2 pos = line->v1->fPos();
|
||||||
fixed_t y = line->v1->fixY();
|
DVector2 pos2 = line->v2->fPos();
|
||||||
|
DAngle angle = (pos2 - pos).Angle();
|
||||||
angle_t angle = R_PointToAngle2 (x, y, line->v2->fixX(), line->v2->fixY());
|
DAngle norm = angle - 90;
|
||||||
angle_t norm = (angle-ANGLE_90) >> ANGLETOFINESHIFT;
|
double dist = norm.Cos() * pos.X + norm.Sin() * pos.Y;
|
||||||
|
|
||||||
fixed_t dist = -DMulScale16 (finecosine[norm], x, finesine[norm], y);
|
|
||||||
|
|
||||||
if (side)
|
if (side)
|
||||||
{
|
{
|
||||||
angle = angle + ANGLE_180;
|
angle += 180.;
|
||||||
dist = -dist;
|
dist = -dist;
|
||||||
}
|
}
|
||||||
|
|
||||||
sec->SetBase(fc, dist & ((1<<(FRACBITS+8))-1), 0-angle);
|
sec->SetBase(fc, dist, -angle);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
20
src/r_defs.h
20
src/r_defs.h
|
@ -879,10 +879,10 @@ struct sector_t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetBase(int pos, fixed_t y, angle_t o)
|
void SetBase(int pos, double y, DAngle o)
|
||||||
{
|
{
|
||||||
planes[pos].xform.base_yoffs = y;
|
planes[pos].xform.base_yoffs = FLOAT2FIXED(y);
|
||||||
planes[pos].xform.base_angle = o;
|
planes[pos].xform.base_angle = o.BAMs();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetAlpha(int pos, fixed_t o)
|
void SetAlpha(int pos, fixed_t o)
|
||||||
|
@ -1082,18 +1082,8 @@ struct sector_t
|
||||||
return LowestFloorAt(a->Pos(), resultsec);
|
return LowestFloorAt(a->Pos(), resultsec);
|
||||||
}
|
}
|
||||||
|
|
||||||
fixed_t NextHighestCeilingAt(fixed_t x, fixed_t y, fixed_t bottomz, fixed_t topz, int flags = 0, sector_t **resultsec = NULL, F3DFloor **resultffloor = NULL);
|
double NextHighestCeilingAt(double x, double y, double bottomz, double topz, int flags = 0, sector_t **resultsec = NULL, F3DFloor **resultffloor = NULL);
|
||||||
fixed_t NextLowestFloorAt(fixed_t x, fixed_t y, fixed_t z, int flags = 0, fixed_t steph = 0, sector_t **resultsec = NULL, F3DFloor **resultffloor = NULL);
|
double NextLowestFloorAt(double x, double y, double z, int flags = 0, double steph = 0, sector_t **resultsec = NULL, F3DFloor **resultffloor = NULL);
|
||||||
|
|
||||||
inline double NextHighestCeilingAt(double x, double y, double bottomz, double topz, int flags = 0, sector_t **resultsec = NULL, F3DFloor **resultffloor = NULL)
|
|
||||||
{
|
|
||||||
return FIXED2DBL(NextHighestCeilingAt(FLOAT2FIXED(x), FLOAT2FIXED(y), FLOAT2FIXED(bottomz), FLOAT2FIXED(topz), flags, resultsec, resultffloor));
|
|
||||||
}
|
|
||||||
|
|
||||||
double NextLowestFloorAt(double x, double y, double z, int flags = 0, double steph = 0, sector_t **resultsec = NULL, F3DFloor **resultffloor = NULL)
|
|
||||||
{
|
|
||||||
return FIXED2DBL(NextLowestFloorAt(FLOAT2FIXED(x), FLOAT2FIXED(y), FLOAT2FIXED(z), flags, FLOAT2FIXED(steph), resultsec, resultffloor));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Member variables
|
// Member variables
|
||||||
double CenterFloor() const { return floorplane.ZatPoint(centerspot); }
|
double CenterFloor() const { return floorplane.ZatPoint(centerspot); }
|
||||||
|
|
Loading…
Reference in a new issue