mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-10 23:01:50 +00:00
- made the linedef deltas private and only accessible through access functions.
Now everything should be in place to remove the fixed point math from the rest of the play code.
This commit is contained in:
parent
84d547adfb
commit
ff0b371582
14 changed files with 155 additions and 106 deletions
|
@ -140,10 +140,10 @@ struct EDSector
|
||||||
bool colorSet;
|
bool colorSet;
|
||||||
|
|
||||||
// colormaptop//bottom cannot be used because ZDoom has no corresponding properties.
|
// colormaptop//bottom cannot be used because ZDoom has no corresponding properties.
|
||||||
|
double xoffs[2], yoffs[2];
|
||||||
FTransform planexform[2];
|
DAngle angle[2];
|
||||||
DWORD portalflags[2];
|
DWORD portalflags[2];
|
||||||
fixed_t overlayalpha[2];
|
double Overlayalpha[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
static FString EDMap;
|
static FString EDMap;
|
||||||
|
@ -275,7 +275,7 @@ static void parseSector(FScanner &sc)
|
||||||
EDSector sec;
|
EDSector sec;
|
||||||
|
|
||||||
memset(&sec, 0, sizeof(sec));
|
memset(&sec, 0, sizeof(sec));
|
||||||
sec.overlayalpha[sector_t::floor] = sec.overlayalpha[sector_t::ceiling] = OPAQUE;
|
sec.Overlayalpha[sector_t::floor] = sec.Overlayalpha[sector_t::ceiling] = 1.;
|
||||||
sec.floorterrain = sec.ceilingterrain = -1;
|
sec.floorterrain = sec.ceilingterrain = -1;
|
||||||
|
|
||||||
sc.MustGetStringName("{");
|
sc.MustGetStringName("{");
|
||||||
|
@ -398,19 +398,19 @@ static void parseSector(FScanner &sc)
|
||||||
{
|
{
|
||||||
sc.CheckString("=");
|
sc.CheckString("=");
|
||||||
sc.MustGetFloat();
|
sc.MustGetFloat();
|
||||||
sec.planexform[sector_t::floor].angle = FLOAT2ANGLE(sc.Float);
|
sec.angle[sector_t::floor] = sc.Float;
|
||||||
}
|
}
|
||||||
else if (sc.Compare("flooroffsetx"))
|
else if (sc.Compare("flooroffsetx"))
|
||||||
{
|
{
|
||||||
sc.CheckString("=");
|
sc.CheckString("=");
|
||||||
sc.MustGetFloat();
|
sc.MustGetFloat();
|
||||||
sec.planexform[sector_t::floor].xoffs = FLOAT2FIXED(sc.Float);
|
sec.xoffs[sector_t::floor] = sc.Float;
|
||||||
}
|
}
|
||||||
else if (sc.Compare("flooroffsety"))
|
else if (sc.Compare("flooroffsety"))
|
||||||
{
|
{
|
||||||
sc.CheckString("=");
|
sc.CheckString("=");
|
||||||
sc.MustGetFloat();
|
sc.MustGetFloat();
|
||||||
sec.planexform[sector_t::floor].yoffs = FLOAT2FIXED(sc.Float);
|
sec.yoffs[sector_t::floor] = sc.Float;
|
||||||
}
|
}
|
||||||
else if (sc.Compare("ceilingterrain"))
|
else if (sc.Compare("ceilingterrain"))
|
||||||
{
|
{
|
||||||
|
@ -422,19 +422,19 @@ static void parseSector(FScanner &sc)
|
||||||
{
|
{
|
||||||
sc.CheckString("=");
|
sc.CheckString("=");
|
||||||
sc.MustGetFloat();
|
sc.MustGetFloat();
|
||||||
sec.planexform[sector_t::ceiling].angle = FLOAT2ANGLE(sc.Float);
|
sec.angle[sector_t::ceiling] = sc.Float;
|
||||||
}
|
}
|
||||||
else if (sc.Compare("ceilingoffsetx"))
|
else if (sc.Compare("ceilingoffsetx"))
|
||||||
{
|
{
|
||||||
sc.CheckString("=");
|
sc.CheckString("=");
|
||||||
sc.MustGetFloat();
|
sc.MustGetFloat();
|
||||||
sec.planexform[sector_t::ceiling].xoffs = FLOAT2FIXED(sc.Float);
|
sec.xoffs[sector_t::ceiling] = sc.Float;
|
||||||
}
|
}
|
||||||
else if (sc.Compare("ceilingoffsety"))
|
else if (sc.Compare("ceilingoffsety"))
|
||||||
{
|
{
|
||||||
sc.CheckString("=");
|
sc.CheckString("=");
|
||||||
sc.MustGetFloat();
|
sc.MustGetFloat();
|
||||||
sec.planexform[sector_t::ceiling].yoffs = FLOAT2FIXED(sc.Float);
|
sec.yoffs[sector_t::ceiling] = sc.Float;
|
||||||
}
|
}
|
||||||
else if (sc.Compare("colormaptop") || sc.Compare("colormapbottom"))
|
else if (sc.Compare("colormaptop") || sc.Compare("colormapbottom"))
|
||||||
{
|
{
|
||||||
|
@ -464,14 +464,14 @@ static void parseSector(FScanner &sc)
|
||||||
sc.MustGetNumber();
|
sc.MustGetNumber();
|
||||||
if (sc.CheckString("%")) sc.Float = sc.Number / 100.f;
|
if (sc.CheckString("%")) sc.Float = sc.Number / 100.f;
|
||||||
else sc.Float = sc.Number / 255.f;
|
else sc.Float = sc.Number / 255.f;
|
||||||
sec.overlayalpha[sector_t::floor] = FLOAT2FIXED(sc.Float);
|
sec.Overlayalpha[sector_t::floor] = sc.Float;
|
||||||
}
|
}
|
||||||
else if (sc.Compare("ceiling"))
|
else if (sc.Compare("ceiling"))
|
||||||
{
|
{
|
||||||
sc.MustGetFloat();
|
sc.MustGetFloat();
|
||||||
if (sc.CheckString("%")) sc.Float = sc.Number / 100.f;
|
if (sc.CheckString("%")) sc.Float = sc.Number / 100.f;
|
||||||
else sc.Float = sc.Number / 255.f;
|
else sc.Float = sc.Number / 255.f;
|
||||||
sec.overlayalpha[sector_t::floor] = FLOAT2FIXED(sc.Float);
|
sec.Overlayalpha[sector_t::floor] = sc.Float;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (sc.Compare("portalflags"))
|
else if (sc.Compare("portalflags"))
|
||||||
|
@ -742,10 +742,10 @@ void ProcessEDSector(sector_t *sec, int recordnum)
|
||||||
const DWORD pflagmask = PLANEF_DISABLED | PLANEF_NORENDER | PLANEF_NOPASS | PLANEF_BLOCKSOUND | PLANEF_ADDITIVE;
|
const DWORD pflagmask = PLANEF_DISABLED | PLANEF_NORENDER | PLANEF_NOPASS | PLANEF_BLOCKSOUND | PLANEF_ADDITIVE;
|
||||||
for (int i = 0; i < 2; i++)
|
for (int i = 0; i < 2; i++)
|
||||||
{
|
{
|
||||||
sec->planes[i].xform.xoffs = esec->planexform[i].xoffs;
|
sec->SetXOffset(i, esec->xoffs[i]);
|
||||||
sec->planes[i].xform.yoffs = esec->planexform[i].yoffs;
|
sec->SetYOffset(i, esec->yoffs[i]);
|
||||||
sec->planes[i].xform.angle = esec->planexform[i].angle;
|
sec->SetAngle(i, esec->angle[i]);
|
||||||
sec->planes[i].alpha = esec->overlayalpha[i];
|
sec->SetAlpha(i, esec->Overlayalpha[i]);
|
||||||
sec->planes[i].Flags = (sec->planes[i].Flags & ~pflagmask) | esec->portalflags[i];
|
sec->planes[i].Flags = (sec->planes[i].Flags & ~pflagmask) | esec->portalflags[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,27 +76,27 @@ int FBoundingBox::BoxOnLineSide (const line_t *ld) const
|
||||||
int p1;
|
int p1;
|
||||||
int p2;
|
int p2;
|
||||||
|
|
||||||
if (ld->dx == 0)
|
if (ld->Delta().X == 0)
|
||||||
{ // ST_VERTICAL
|
{ // ST_VERTICAL
|
||||||
p1 = m_Box[BOXRIGHT] < ld->v1->fixX();
|
p1 = m_Box[BOXRIGHT] < ld->v1->fixX();
|
||||||
p2 = m_Box[BOXLEFT] < ld->v1->fixX();
|
p2 = m_Box[BOXLEFT] < ld->v1->fixX();
|
||||||
if (ld->dy < 0)
|
if (ld->Delta().Y < 0)
|
||||||
{
|
{
|
||||||
p1 ^= 1;
|
p1 ^= 1;
|
||||||
p2 ^= 1;
|
p2 ^= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (ld->dy == 0)
|
else if (ld->Delta().Y == 0)
|
||||||
{ // ST_HORIZONTAL:
|
{ // ST_HORIZONTAL:
|
||||||
p1 = m_Box[BOXTOP] > ld->v1->fixY();
|
p1 = m_Box[BOXTOP] > ld->v1->fixY();
|
||||||
p2 = m_Box[BOXBOTTOM] > ld->v1->fixY();
|
p2 = m_Box[BOXBOTTOM] > ld->v1->fixY();
|
||||||
if (ld->dx < 0)
|
if (ld->Delta().X < 0)
|
||||||
{
|
{
|
||||||
p1 ^= 1;
|
p1 ^= 1;
|
||||||
p2 ^= 1;
|
p2 ^= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((ld->dy ^ ld->dx) >= 0)
|
else if ((ld->Delta().X * ld->Delta().Y) >= 0)
|
||||||
{ // ST_POSITIVE:
|
{ // ST_POSITIVE:
|
||||||
p1 = P_PointOnLineSide (m_Box[BOXLEFT], m_Box[BOXTOP], ld);
|
p1 = P_PointOnLineSide (m_Box[BOXLEFT], m_Box[BOXTOP], ld);
|
||||||
p2 = P_PointOnLineSide (m_Box[BOXRIGHT], m_Box[BOXBOTTOM], ld);
|
p2 = P_PointOnLineSide (m_Box[BOXRIGHT], m_Box[BOXBOTTOM], ld);
|
||||||
|
|
|
@ -133,14 +133,12 @@ static void P_Add3DFloor(sector_t* sec, sector_t* sec2, line_t* master, int flag
|
||||||
{
|
{
|
||||||
ffloor->bottom.plane = &sec2->floorplane;
|
ffloor->bottom.plane = &sec2->floorplane;
|
||||||
ffloor->bottom.texture = &sec2->planes[sector_t::floor].Texture;
|
ffloor->bottom.texture = &sec2->planes[sector_t::floor].Texture;
|
||||||
ffloor->bottom.texheight = &sec2->planes[sector_t::floor].TexZ;
|
|
||||||
ffloor->bottom.isceiling = sector_t::floor;
|
ffloor->bottom.isceiling = sector_t::floor;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ffloor->bottom.plane = &sec2->ceilingplane;
|
ffloor->bottom.plane = &sec2->ceilingplane;
|
||||||
ffloor->bottom.texture = &sec2->planes[sector_t::ceiling].Texture;
|
ffloor->bottom.texture = &sec2->planes[sector_t::ceiling].Texture;
|
||||||
ffloor->bottom.texheight = &sec2->planes[sector_t::ceiling].TexZ;
|
|
||||||
ffloor->bottom.isceiling = sector_t::ceiling;
|
ffloor->bottom.isceiling = sector_t::ceiling;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,7 +146,6 @@ static void P_Add3DFloor(sector_t* sec, sector_t* sec2, line_t* master, int flag
|
||||||
{
|
{
|
||||||
ffloor->top.plane = &sec2->ceilingplane;
|
ffloor->top.plane = &sec2->ceilingplane;
|
||||||
ffloor->top.texture = &sec2->planes[sector_t::ceiling].Texture;
|
ffloor->top.texture = &sec2->planes[sector_t::ceiling].Texture;
|
||||||
ffloor->top.texheight = &sec2->planes[sector_t::ceiling].TexZ;
|
|
||||||
ffloor->toplightlevel = &sec2->lightlevel;
|
ffloor->toplightlevel = &sec2->lightlevel;
|
||||||
ffloor->top.isceiling = sector_t::ceiling;
|
ffloor->top.isceiling = sector_t::ceiling;
|
||||||
}
|
}
|
||||||
|
@ -156,7 +153,6 @@ static void P_Add3DFloor(sector_t* sec, sector_t* sec2, line_t* master, int flag
|
||||||
{
|
{
|
||||||
ffloor->top.plane = &sec->floorplane;
|
ffloor->top.plane = &sec->floorplane;
|
||||||
ffloor->top.texture = &sec2->planes[sector_t::floor].Texture;
|
ffloor->top.texture = &sec2->planes[sector_t::floor].Texture;
|
||||||
ffloor->top.texheight = &sec2->planes[sector_t::floor].TexZ;
|
|
||||||
ffloor->toplightlevel = &sec->lightlevel;
|
ffloor->toplightlevel = &sec->lightlevel;
|
||||||
ffloor->top.isceiling = sector_t::floor;
|
ffloor->top.isceiling = sector_t::floor;
|
||||||
ffloor->top.model = sec;
|
ffloor->top.model = sec;
|
||||||
|
|
|
@ -68,7 +68,6 @@ struct F3DFloor
|
||||||
{
|
{
|
||||||
secplane_t * plane;
|
secplane_t * plane;
|
||||||
const FTextureID * texture;
|
const FTextureID * texture;
|
||||||
const fixed_t * texheight;
|
|
||||||
sector_t * model;
|
sector_t * model;
|
||||||
int isceiling;
|
int isceiling;
|
||||||
int vindex;
|
int vindex;
|
||||||
|
|
|
@ -129,10 +129,10 @@ struct gl5_mapnode_t
|
||||||
|
|
||||||
static int CheckForMissingSegs()
|
static int CheckForMissingSegs()
|
||||||
{
|
{
|
||||||
float *added_seglen = new float[numsides];
|
double *added_seglen = new double[numsides];
|
||||||
int missing = 0;
|
int missing = 0;
|
||||||
|
|
||||||
memset(added_seglen, 0, sizeof(float)*numsides);
|
memset(added_seglen, 0, sizeof(double)*numsides);
|
||||||
for(int i=0;i<numsegs;i++)
|
for(int i=0;i<numsegs;i++)
|
||||||
{
|
{
|
||||||
seg_t * seg = &segs[i];
|
seg_t * seg = &segs[i];
|
||||||
|
@ -140,20 +140,15 @@ static int CheckForMissingSegs()
|
||||||
if (seg->sidedef!=NULL)
|
if (seg->sidedef!=NULL)
|
||||||
{
|
{
|
||||||
// check all the segs and calculate the length they occupy on their sidedef
|
// check all the segs and calculate the length they occupy on their sidedef
|
||||||
DVector2 vec1(seg->v2->fixX() - seg->v1->fixX(), seg->v2->fixY() - seg->v1->fixY());
|
DVector2 vec1(seg->v2->fX() - seg->v1->fX(), seg->v2->fY() - seg->v1->fY());
|
||||||
added_seglen[seg->sidedef - sides] += float(vec1.Length());
|
added_seglen[seg->sidedef - sides] += vec1.Length();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i=0;i<numsides;i++)
|
for(int i=0;i<numsides;i++)
|
||||||
{
|
{
|
||||||
side_t * side =&sides[i];
|
double linelen = sides[i].linedef->Delta().Length();
|
||||||
line_t * line = side->linedef;
|
missing += (added_seglen[i] < linelen - 1.);
|
||||||
|
|
||||||
DVector2 lvec(line->dx, line->dy);
|
|
||||||
float linelen = float(lvec.Length());
|
|
||||||
|
|
||||||
missing += (added_seglen[i] < linelen - FRACUNIT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delete [] added_seglen;
|
delete [] added_seglen;
|
||||||
|
|
|
@ -410,38 +410,37 @@ bool AActor::FixMapthingPos()
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Get the exact distance to the line
|
// Get the exact distance to the line
|
||||||
fdivline_t dll, dlv;
|
divline_t dll, dlv;
|
||||||
fixed_t linelen = (fixed_t)g_sqrt((double)ldef->dx*ldef->dx + (double)ldef->dy*ldef->dy);
|
double linelen = ldef->Delta().Length();
|
||||||
|
|
||||||
P_MakeDivline(ldef, &dll);
|
P_MakeDivline(ldef, &dll);
|
||||||
|
|
||||||
dlv.x = _f_X();
|
dlv.x = X();
|
||||||
dlv.y = _f_Y();
|
dlv.y = Y();
|
||||||
dlv.dx = FixedDiv(dll.dy, linelen);
|
dlv.dx = dll.dy / linelen;
|
||||||
dlv.dy = -FixedDiv(dll.dx, linelen);
|
dlv.dy = -dll.dx / linelen;
|
||||||
|
|
||||||
fixed_t distance = abs(P_InterceptVector(&dlv, &dll));
|
double distance = fabs(P_InterceptVector(&dlv, &dll));
|
||||||
|
|
||||||
if (distance < _f_radius())
|
if (distance < radius)
|
||||||
{
|
{
|
||||||
DPrintf("%s at (%d,%d) lies on %s line %td, distance = %f\n",
|
DPrintf("%s at (%f,%f) lies on %s line %td, distance = %f\n",
|
||||||
this->GetClass()->TypeName.GetChars(), _f_X() >> FRACBITS, _f_Y() >> FRACBITS,
|
this->GetClass()->TypeName.GetChars(), X(), Y(),
|
||||||
ldef->dx == 0 ? "vertical" : ldef->dy == 0 ? "horizontal" : "diagonal",
|
ldef->Delta().X == 0 ? "vertical" : ldef->Delta().Y == 0 ? "horizontal" : "diagonal",
|
||||||
ldef - lines, FIXED2DBL(distance));
|
ldef - lines, FIXED2DBL(distance));
|
||||||
angle_t finean = R_PointToAngle2(0, 0, ldef->dx, ldef->dy);
|
DAngle ang = ldef->Delta().Angle();
|
||||||
if (ldef->backsector != NULL && ldef->backsector == secstart)
|
if (ldef->backsector != NULL && ldef->backsector == secstart)
|
||||||
{
|
{
|
||||||
finean += ANGLE_90;
|
ang += 90.;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
finean -= ANGLE_90;
|
ang -= 90.;
|
||||||
}
|
}
|
||||||
finean >>= ANGLETOFINESHIFT;
|
|
||||||
|
|
||||||
// Get the distance we have to move the object away from the wall
|
// Get the distance we have to move the object away from the wall
|
||||||
distance = _f_radius() - distance;
|
distance = radius - distance;
|
||||||
SetXY(_f_X() + FixedMul(distance, finecosine[finean]), _f_Y() + FixedMul(distance, finesine[finean]));
|
SetXY(Pos().XY() + ang.ToVector(distance));
|
||||||
ClearInterpolation();
|
ClearInterpolation();
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
|
@ -1936,27 +1935,32 @@ int P_VanillaPointOnLineSide(fixed_t x, fixed_t y, const line_t* line)
|
||||||
fixed_t dy;
|
fixed_t dy;
|
||||||
fixed_t left;
|
fixed_t left;
|
||||||
fixed_t right;
|
fixed_t right;
|
||||||
|
DVector2 delta = line->Delta();
|
||||||
|
|
||||||
if (!line->dx)
|
if (delta.X == 0)
|
||||||
{
|
{
|
||||||
if (x <= line->v1->fixX())
|
if (x <= line->v1->fixX())
|
||||||
return line->dy > 0;
|
return delta.Y > 0;
|
||||||
|
|
||||||
return line->dy < 0;
|
return delta.Y < 0;
|
||||||
}
|
}
|
||||||
if (!line->dy)
|
if (delta.Y == 0)
|
||||||
{
|
{
|
||||||
if (y <= line->v1->fixY())
|
if (y <= line->v1->fixY())
|
||||||
return line->dx < 0;
|
return delta.X < 0;
|
||||||
|
|
||||||
return line->dx > 0;
|
return delta.X > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Note: This cannot really be converted to floating point
|
||||||
|
// without breaking the intended use of this function
|
||||||
|
// (i.e. to emulate the horrible imprecision of the entire methpd)
|
||||||
|
|
||||||
dx = (x - line->v1->fixX());
|
dx = (x - line->v1->fixX());
|
||||||
dy = (y - line->v1->fixY());
|
dy = (y - line->v1->fixY());
|
||||||
|
|
||||||
left = FixedMul ( line->dy>>FRACBITS , dx );
|
left = FixedMul ( int(delta.Y * 256) , dx );
|
||||||
right = FixedMul ( dy , line->dx>>FRACBITS );
|
right = FixedMul ( dy , int(delta.X * 256) );
|
||||||
|
|
||||||
if (right < left)
|
if (right < left)
|
||||||
return 0; // front side
|
return 0; // front side
|
||||||
|
|
|
@ -53,12 +53,12 @@ inline int P_PointOnLineSide (fixed_t x, fixed_t y, const line_t *line)
|
||||||
|
|
||||||
return i_compatflags2 & COMPATF2_POINTONLINE
|
return i_compatflags2 & COMPATF2_POINTONLINE
|
||||||
? P_VanillaPointOnLineSide(x, y, line)
|
? P_VanillaPointOnLineSide(x, y, line)
|
||||||
: DMulScale32 (y-line->v1->fixY(), line->dx, line->v1->fixX()-x, line->dy) > 0;
|
: DMulScale32 (y-line->v1->fixY(), line->fixDx(), line->v1->fixX()-x, line->fixDy()) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int P_PointOnLineSidePrecise (fixed_t x, fixed_t y, const line_t *line)
|
inline int P_PointOnLineSidePrecise (fixed_t x, fixed_t y, const line_t *line)
|
||||||
{
|
{
|
||||||
return DMulScale32 (y-line->v1->fixY(), line->dx, line->v1->fixX()-x, line->dy) > 0;
|
return DMulScale32 (y-line->v1->fixY(), line->fixDx(), line->v1->fixX()-x, line->fixDy()) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int P_PointOnLineSide(double x, double y, const line_t *line)
|
inline int P_PointOnLineSide(double x, double y, const line_t *line)
|
||||||
|
@ -125,8 +125,8 @@ inline void P_MakeDivline (const line_t *li, fdivline_t *dl)
|
||||||
{
|
{
|
||||||
dl->x = li->v1->fixX();
|
dl->x = li->v1->fixX();
|
||||||
dl->y = li->v1->fixY();
|
dl->y = li->v1->fixY();
|
||||||
dl->dx = li->dx;
|
dl->dx = li->fixDx();
|
||||||
dl->dy = li->dy;
|
dl->dy = li->fixDy();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void P_MakeDivline(const line_t *li, divline_t *dl)
|
inline void P_MakeDivline(const line_t *li, divline_t *dl)
|
||||||
|
|
|
@ -877,7 +877,7 @@ void sector_t::CheckPortalPlane(int plane)
|
||||||
AActor *portal = SkyBoxes[plane];
|
AActor *portal = SkyBoxes[plane];
|
||||||
if (!portal || portal->special1 != SKYBOX_LINKEDPORTAL) return;
|
if (!portal || portal->special1 != SKYBOX_LINKEDPORTAL) return;
|
||||||
|
|
||||||
double planeh = FIXED2DBL(planes[plane].TexZ);
|
double planeh = GetPlaneTexZF(plane);
|
||||||
int obstructed = PLANEF_OBSTRUCTED * (plane == sector_t::floor ?
|
int obstructed = PLANEF_OBSTRUCTED * (plane == sector_t::floor ?
|
||||||
planeh > portal->specialf1 : planeh < portal->specialf1);
|
planeh > portal->specialf1 : planeh < portal->specialf1);
|
||||||
planes[plane].Flags = (planes[plane].Flags & ~PLANEF_OBSTRUCTED) | obstructed;
|
planes[plane].Flags = (planes[plane].Flags & ~PLANEF_OBSTRUCTED) | obstructed;
|
||||||
|
@ -1225,21 +1225,22 @@ int side_t::GetLightLevel (bool foggy, int baselight, bool is3dlight, int *pfake
|
||||||
{
|
{
|
||||||
if (!(Flags & WALLF_NOFAKECONTRAST) && r_fakecontrast != 0)
|
if (!(Flags & WALLF_NOFAKECONTRAST) && r_fakecontrast != 0)
|
||||||
{
|
{
|
||||||
|
DVector2 delta = linedef->Delta();
|
||||||
int rel;
|
int rel;
|
||||||
if (((level.flags2 & LEVEL2_SMOOTHLIGHTING) || (Flags & WALLF_SMOOTHLIGHTING) || r_fakecontrast == 2) &&
|
if (((level.flags2 & LEVEL2_SMOOTHLIGHTING) || (Flags & WALLF_SMOOTHLIGHTING) || r_fakecontrast == 2) &&
|
||||||
linedef->dx != 0)
|
delta.X != 0)
|
||||||
{
|
{
|
||||||
rel = xs_RoundToInt // OMG LEE KILLOUGH LIVES! :/
|
rel = xs_RoundToInt // OMG LEE KILLOUGH LIVES! :/
|
||||||
(
|
(
|
||||||
level.WallHorizLight
|
level.WallHorizLight
|
||||||
+ fabs(atan(double(linedef->dy) / linedef->dx) / 1.57079)
|
+ fabs(atan(delta.Y / delta.X) / 1.57079)
|
||||||
* (level.WallVertLight - level.WallHorizLight)
|
* (level.WallVertLight - level.WallHorizLight)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rel = linedef->dx == 0 ? level.WallVertLight :
|
rel = delta.X == 0 ? level.WallVertLight :
|
||||||
linedef->dy == 0 ? level.WallHorizLight : 0;
|
delta.Y == 0 ? level.WallHorizLight : 0;
|
||||||
}
|
}
|
||||||
if (pfakecontrast != NULL)
|
if (pfakecontrast != NULL)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1903,8 +1903,7 @@ void P_AdjustLine (line_t *ld)
|
||||||
v1 = ld->v1;
|
v1 = ld->v1;
|
||||||
v2 = ld->v2;
|
v2 = ld->v2;
|
||||||
|
|
||||||
ld->dx = v2->fixX() - v1->fixX();
|
ld->setDelta(v2->fX() - v1->fX(), v2->fY() - v1->fY());
|
||||||
ld->dy = v2->fixY() - v1->fixY();
|
|
||||||
|
|
||||||
if (v1->fixX() < v2->fixX())
|
if (v1->fixX() < v2->fixX())
|
||||||
{
|
{
|
||||||
|
@ -2423,15 +2422,15 @@ static void P_LoopSidedefs (bool firstloop)
|
||||||
if (sidetemp[right].b.next != NO_SIDE)
|
if (sidetemp[right].b.next != NO_SIDE)
|
||||||
{
|
{
|
||||||
int bestright = right; // Shut up, GCC
|
int bestright = right; // Shut up, GCC
|
||||||
angle_t bestang = ANGLE_MAX;
|
DAngle bestang = 360.;
|
||||||
line_t *leftline, *rightline;
|
line_t *leftline, *rightline;
|
||||||
angle_t ang1, ang2, ang;
|
DAngle ang1, ang2, ang;
|
||||||
|
|
||||||
leftline = sides[i].linedef;
|
leftline = sides[i].linedef;
|
||||||
ang1 = R_PointToAngle2 (0, 0, leftline->dx, leftline->dy);
|
ang1 = leftline->Delta().Angle();
|
||||||
if (!sidetemp[i].b.lineside)
|
if (!sidetemp[i].b.lineside)
|
||||||
{
|
{
|
||||||
ang1 += ANGLE_180;
|
ang1 += 180;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (right != NO_SIDE)
|
while (right != NO_SIDE)
|
||||||
|
@ -2441,13 +2440,13 @@ static void P_LoopSidedefs (bool firstloop)
|
||||||
rightline = sides[right].linedef;
|
rightline = sides[right].linedef;
|
||||||
if (rightline->frontsector != rightline->backsector)
|
if (rightline->frontsector != rightline->backsector)
|
||||||
{
|
{
|
||||||
ang2 = R_PointToAngle2 (0, 0, rightline->dx, rightline->dy);
|
ang2 = rightline->Delta().Angle();
|
||||||
if (sidetemp[right].b.lineside)
|
if (sidetemp[right].b.lineside)
|
||||||
{
|
{
|
||||||
ang2 += ANGLE_180;
|
ang2 += 180;
|
||||||
}
|
}
|
||||||
|
|
||||||
ang = ang2 - ang1;
|
ang = (ang2 - ang1).Normalized360();
|
||||||
|
|
||||||
if (ang != 0 && ang <= bestang)
|
if (ang != 0 && ang <= bestang)
|
||||||
{
|
{
|
||||||
|
|
|
@ -79,14 +79,14 @@ static void P_SlopeLineToPoint (int lineid, fixed_t x, fixed_t y, fixed_t z, boo
|
||||||
|
|
||||||
DVector3 p, v1, v2, cross;
|
DVector3 p, v1, v2, cross;
|
||||||
|
|
||||||
p[0] = FIXED2DBL (line->v1->fixX());
|
p[0] = line->v1->fX();
|
||||||
p[1] = FIXED2DBL (line->v1->fixY());
|
p[1] = line->v1->fY();
|
||||||
p[2] = FIXED2DBL (plane->ZatPoint (line->v1->fixX(), line->v1->fixY()));
|
p[2] = plane->ZatPointF (line->v1);
|
||||||
v1[0] = FIXED2DBL (line->dx);
|
v1[0] = line->Delta().X;
|
||||||
v1[1] = FIXED2DBL (line->dy);
|
v1[1] = line->Delta().Y;
|
||||||
v1[2] = FIXED2DBL (plane->ZatPoint (line->v2->fixX(), line->v2->fixY())) - p[2];
|
v1[2] = plane->ZatPointF (line->v2) - p[2];
|
||||||
v2[0] = FIXED2DBL (x - line->v1->fixX());
|
v2[0] = FIXED2DBL (x) - p[0];
|
||||||
v2[1] = FIXED2DBL (y - line->v1->fixY());
|
v2[1] = FIXED2DBL (y) - p[1];
|
||||||
v2[2] = FIXED2DBL (z) - p[2];
|
v2[2] = FIXED2DBL (z) - p[2];
|
||||||
|
|
||||||
cross = v1 ^ v2;
|
cross = v1 ^ v2;
|
||||||
|
@ -487,8 +487,8 @@ static void P_AlignPlane (sector_t *sec, line_t *line, int which)
|
||||||
vert = (*probe++)->v2;
|
vert = (*probe++)->v2;
|
||||||
else
|
else
|
||||||
vert = (*probe)->v1;
|
vert = (*probe)->v1;
|
||||||
dist = fabs((double(line->v1->fixY()) - vert->fixY()) * line->dx -
|
dist = fabs((double(line->v1->fixY()) - vert->fixY()) * line->fixDx() -
|
||||||
(double(line->v1->fixX()) - vert->fixX()) * line->dy);
|
(double(line->v1->fixX()) - vert->fixX()) * line->fixDy());
|
||||||
|
|
||||||
if (dist > bestdist)
|
if (dist > bestdist)
|
||||||
{
|
{
|
||||||
|
@ -508,14 +508,14 @@ static void P_AlignPlane (sector_t *sec, line_t *line, int which)
|
||||||
srcheight = (which == 0) ? sec->GetPlaneTexZ(sector_t::floor) : sec->GetPlaneTexZ(sector_t::ceiling);
|
srcheight = (which == 0) ? sec->GetPlaneTexZ(sector_t::floor) : sec->GetPlaneTexZ(sector_t::ceiling);
|
||||||
destheight = (which == 0) ? refsec->GetPlaneTexZ(sector_t::floor) : refsec->GetPlaneTexZ(sector_t::ceiling);
|
destheight = (which == 0) ? refsec->GetPlaneTexZ(sector_t::floor) : refsec->GetPlaneTexZ(sector_t::ceiling);
|
||||||
|
|
||||||
p[0] = FIXED2DBL (line->v1->fixX());
|
p[0] = line->v1->fX();
|
||||||
p[1] = FIXED2DBL(line->v1->fixY());
|
p[1] = line->v1->fY();
|
||||||
p[2] = FIXED2DBL(destheight);
|
p[2] = FIXED2DBL(destheight);
|
||||||
v1[0] = FIXED2DBL(line->dx);
|
v1[0] = line->Delta().X;
|
||||||
v1[1] = FIXED2DBL(line->dy);
|
v1[1] = line->Delta().Y;
|
||||||
v1[2] = 0;
|
v1[2] = 0;
|
||||||
v2[0] = FIXED2DBL(refvert->fixX() - line->v1->fixX());
|
v2[0] = refvert->fX() - line->v1->fX();
|
||||||
v2[1] = FIXED2DBL(refvert->fixY() - line->v1->fixY());
|
v2[1] = refvert->fY() - line->v1->fY();
|
||||||
v2[2] = FIXED2DBL(srcheight - destheight);
|
v2[2] = FIXED2DBL(srcheight - destheight);
|
||||||
|
|
||||||
cross = (v1 ^ v2).Unit();
|
cross = (v1 ^ v2).Unit();
|
||||||
|
|
|
@ -943,8 +943,9 @@ void FPolyObj::UpdateBBox ()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the line's slopetype
|
// Update the line's slopetype
|
||||||
line->dx = line->v2->fixX() - line->v1->fixX();
|
line->setDelta(
|
||||||
line->dy = line->v2->fixY() - line->v1->fixY();
|
line->v2->fixX() - line->v1->fixX(),
|
||||||
|
line->v2->fixY() - line->v1->fixY());
|
||||||
}
|
}
|
||||||
CalcCenter();
|
CalcCenter();
|
||||||
}
|
}
|
||||||
|
|
|
@ -251,10 +251,10 @@ static void SetRotation(FLinePortal *port)
|
||||||
{
|
{
|
||||||
line_t *dst = port->mDestination;
|
line_t *dst = port->mDestination;
|
||||||
line_t *line = port->mOrigin;
|
line_t *line = port->mOrigin;
|
||||||
double angle = g_atan2(dst->dy, dst->dx) - g_atan2(line->dy, line->dx) + M_PI;
|
DAngle angle = dst->Delta().Angle() - line->Delta().Angle() + 180.;
|
||||||
port->mSinRot = FLOAT2FIXED(g_sin(angle));
|
port->mSinRot = FLOAT2FIXED(angle.Sin());
|
||||||
port->mCosRot = FLOAT2FIXED(g_cos(angle));
|
port->mCosRot = FLOAT2FIXED(angle.Cos());
|
||||||
port->mAngleDiff = ToDegrees(angle);
|
port->mAngleDiff = angle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -513,7 +513,7 @@ inline int P_PointOnLineSideExplicit (fixed_t x, fixed_t y, fixed_t x1, fixed_t
|
||||||
|
|
||||||
inline int P_GetLineSide(fixed_t x, fixed_t y, const line_t *line)
|
inline int P_GetLineSide(fixed_t x, fixed_t y, const line_t *line)
|
||||||
{
|
{
|
||||||
return DMulScale32(y - line->v1->fixY(), line->dx, line->v1->fixX() - x, line->dy);
|
return DMulScale32(y - line->v1->fixY(), line->fixDx(), line->v1->fixX() - x, line->fixDy());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool P_ClipLineToPortal(line_t* line, line_t* portal, fixed_t viewx, fixed_t viewy, bool partial, bool samebehind)
|
bool P_ClipLineToPortal(line_t* line, line_t* portal, fixed_t viewx, fixed_t viewy, bool partial, bool samebehind)
|
||||||
|
@ -652,7 +652,7 @@ void P_TranslatePortalZ(line_t* src, fixed_t& z)
|
||||||
|
|
||||||
fixed_t P_PointLineDistance(line_t* line, fixed_t x, fixed_t y)
|
fixed_t P_PointLineDistance(line_t* line, fixed_t x, fixed_t y)
|
||||||
{
|
{
|
||||||
angle_t angle = R_PointToAngle2(0, 0, line->dx, line->dy);
|
angle_t angle = R_PointToAngle2(0, 0, line->fixDx(), line->fixDy());
|
||||||
angle += ANGLE_180;
|
angle += ANGLE_180;
|
||||||
|
|
||||||
fixed_t dx = line->v1->fixX() - x;
|
fixed_t dx = line->v1->fixX() - x;
|
||||||
|
|
54
src/r_defs.h
54
src/r_defs.h
|
@ -418,6 +418,11 @@ public:
|
||||||
return FixedMul (ic, -d - DMulScale16 (a, v->fixX(), b, v->fixY()));
|
return FixedMul (ic, -d - DMulScale16 (a, v->fixX(), b, v->fixY()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double ZatPointF(const vertex_t *v) const
|
||||||
|
{
|
||||||
|
return FIXED2DBL(FixedMul(ic, -d - DMulScale16(a, v->fixX(), b, v->fixY())));
|
||||||
|
}
|
||||||
|
|
||||||
fixed_t ZatPoint (const AActor *ac) const
|
fixed_t ZatPoint (const AActor *ac) const
|
||||||
{
|
{
|
||||||
return FixedMul (ic, -d - DMulScale16 (a, ac->_f_X(), b, ac->_f_Y()));
|
return FixedMul (ic, -d - DMulScale16 (a, ac->_f_X(), b, ac->_f_Y()));
|
||||||
|
@ -733,6 +738,11 @@ struct sector_t
|
||||||
planes[pos].xform.xoffs = o;
|
planes[pos].xform.xoffs = o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetXOffset(int pos, double o)
|
||||||
|
{
|
||||||
|
planes[pos].xform.xoffs = FLOAT2FIXED(o);
|
||||||
|
}
|
||||||
|
|
||||||
void AddXOffset(int pos, fixed_t o)
|
void AddXOffset(int pos, fixed_t o)
|
||||||
{
|
{
|
||||||
planes[pos].xform.xoffs += o;
|
planes[pos].xform.xoffs += o;
|
||||||
|
@ -758,6 +768,11 @@ struct sector_t
|
||||||
planes[pos].xform.yoffs = o;
|
planes[pos].xform.yoffs = o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetYOffset(int pos, double o)
|
||||||
|
{
|
||||||
|
planes[pos].xform.yoffs = FLOAT2FIXED(o);
|
||||||
|
}
|
||||||
|
|
||||||
void AddYOffset(int pos, fixed_t o)
|
void AddYOffset(int pos, fixed_t o)
|
||||||
{
|
{
|
||||||
planes[pos].xform.yoffs += o;
|
planes[pos].xform.yoffs += o;
|
||||||
|
@ -827,6 +842,11 @@ struct sector_t
|
||||||
planes[pos].xform.angle = o;
|
planes[pos].xform.angle = o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetAngle(int pos, DAngle o)
|
||||||
|
{
|
||||||
|
planes[pos].xform.angle = o.BAMs();
|
||||||
|
}
|
||||||
|
|
||||||
angle_t GetAngle(int pos, bool addbase = true) const
|
angle_t GetAngle(int pos, bool addbase = true) const
|
||||||
{
|
{
|
||||||
if (!addbase)
|
if (!addbase)
|
||||||
|
@ -925,11 +945,21 @@ struct sector_t
|
||||||
planes[pos].TexZ = val;
|
planes[pos].TexZ = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetPlaneTexZ(int pos, double val)
|
||||||
|
{
|
||||||
|
planes[pos].TexZ = FLOAT2FIXED(val);
|
||||||
|
}
|
||||||
|
|
||||||
void ChangePlaneTexZ(int pos, fixed_t val)
|
void ChangePlaneTexZ(int pos, fixed_t val)
|
||||||
{
|
{
|
||||||
planes[pos].TexZ += val;
|
planes[pos].TexZ += val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ChangePlaneTexZ(int pos, double val)
|
||||||
|
{
|
||||||
|
planes[pos].TexZ += FLOAT2FIXED(val);
|
||||||
|
}
|
||||||
|
|
||||||
static inline short ClampLight(int level)
|
static inline short ClampLight(int level)
|
||||||
{
|
{
|
||||||
return (short)clamp(level, SHRT_MIN, SHRT_MAX);
|
return (short)clamp(level, SHRT_MIN, SHRT_MAX);
|
||||||
|
@ -1334,7 +1364,9 @@ FArchive &operator<< (FArchive &arc, side_t::part &p);
|
||||||
struct line_t
|
struct line_t
|
||||||
{
|
{
|
||||||
vertex_t *v1, *v2; // vertices, from v1 to v2
|
vertex_t *v1, *v2; // vertices, from v1 to v2
|
||||||
|
private:
|
||||||
fixed_t dx, dy; // precalculated v2 - v1 for side checking
|
fixed_t dx, dy; // precalculated v2 - v1 for side checking
|
||||||
|
public:
|
||||||
DWORD flags;
|
DWORD flags;
|
||||||
DWORD activation; // activation type
|
DWORD activation; // activation type
|
||||||
int special;
|
int special;
|
||||||
|
@ -1362,6 +1394,28 @@ struct line_t
|
||||||
return{ FIXED2DBL(dx), FIXED2DBL(dy) };
|
return{ FIXED2DBL(dx), FIXED2DBL(dy) };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fixed_t fixDx() const
|
||||||
|
{
|
||||||
|
return dx;
|
||||||
|
}
|
||||||
|
|
||||||
|
fixed_t fixDy() const
|
||||||
|
{
|
||||||
|
return dy;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setDelta(fixed_t x, fixed_t y)
|
||||||
|
{
|
||||||
|
dx = x;
|
||||||
|
dy = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setDelta(double x, double y)
|
||||||
|
{
|
||||||
|
dx = FLOAT2FIXED(x);
|
||||||
|
dy = FLOAT2FIXED(y);
|
||||||
|
}
|
||||||
|
|
||||||
FLinePortal *getPortal() const
|
FLinePortal *getPortal() const
|
||||||
{
|
{
|
||||||
return portalindex >= linePortals.Size() ? (FLinePortal*)NULL : &linePortals[portalindex];
|
return portalindex >= linePortals.Size() ? (FLinePortal*)NULL : &linePortals[portalindex];
|
||||||
|
|
|
@ -702,11 +702,11 @@ void R_EnterPortal (PortalDrawseg* pds, int depth)
|
||||||
vertex_t *v1 = pds->src->v1;
|
vertex_t *v1 = pds->src->v1;
|
||||||
|
|
||||||
// Reflect the current view behind the mirror.
|
// Reflect the current view behind the mirror.
|
||||||
if (pds->src->dx == 0)
|
if (pds->src->Delta().X == 0)
|
||||||
{ // vertical mirror
|
{ // vertical mirror
|
||||||
viewx = v1->fixX() - startx + v1->fixX();
|
viewx = v1->fixX() - startx + v1->fixX();
|
||||||
}
|
}
|
||||||
else if (pds->src->dy == 0)
|
else if (pds->src->Delta().Y == 0)
|
||||||
{ // horizontal mirror
|
{ // horizontal mirror
|
||||||
viewy = v1->fixY() - starty + v1->fixY();
|
viewy = v1->fixY() - starty + v1->fixY();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue