mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-29 07:22:07 +00:00
Merge branch 'floatcvt' of https://github.com/rheit/zdoom into floatcvt
This commit is contained in:
commit
e4d68e17fd
14 changed files with 155 additions and 106 deletions
|
@ -140,10 +140,10 @@ struct EDSector
|
|||
bool colorSet;
|
||||
|
||||
// colormaptop//bottom cannot be used because ZDoom has no corresponding properties.
|
||||
|
||||
FTransform planexform[2];
|
||||
double xoffs[2], yoffs[2];
|
||||
DAngle angle[2];
|
||||
DWORD portalflags[2];
|
||||
fixed_t overlayalpha[2];
|
||||
double Overlayalpha[2];
|
||||
};
|
||||
|
||||
static FString EDMap;
|
||||
|
@ -275,7 +275,7 @@ static void parseSector(FScanner &sc)
|
|||
EDSector 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;
|
||||
|
||||
sc.MustGetStringName("{");
|
||||
|
@ -398,19 +398,19 @@ static void parseSector(FScanner &sc)
|
|||
{
|
||||
sc.CheckString("=");
|
||||
sc.MustGetFloat();
|
||||
sec.planexform[sector_t::floor].angle = FLOAT2ANGLE(sc.Float);
|
||||
sec.angle[sector_t::floor] = sc.Float;
|
||||
}
|
||||
else if (sc.Compare("flooroffsetx"))
|
||||
{
|
||||
sc.CheckString("=");
|
||||
sc.MustGetFloat();
|
||||
sec.planexform[sector_t::floor].xoffs = FLOAT2FIXED(sc.Float);
|
||||
sec.xoffs[sector_t::floor] = sc.Float;
|
||||
}
|
||||
else if (sc.Compare("flooroffsety"))
|
||||
{
|
||||
sc.CheckString("=");
|
||||
sc.MustGetFloat();
|
||||
sec.planexform[sector_t::floor].yoffs = FLOAT2FIXED(sc.Float);
|
||||
sec.yoffs[sector_t::floor] = sc.Float;
|
||||
}
|
||||
else if (sc.Compare("ceilingterrain"))
|
||||
{
|
||||
|
@ -422,19 +422,19 @@ static void parseSector(FScanner &sc)
|
|||
{
|
||||
sc.CheckString("=");
|
||||
sc.MustGetFloat();
|
||||
sec.planexform[sector_t::ceiling].angle = FLOAT2ANGLE(sc.Float);
|
||||
sec.angle[sector_t::ceiling] = sc.Float;
|
||||
}
|
||||
else if (sc.Compare("ceilingoffsetx"))
|
||||
{
|
||||
sc.CheckString("=");
|
||||
sc.MustGetFloat();
|
||||
sec.planexform[sector_t::ceiling].xoffs = FLOAT2FIXED(sc.Float);
|
||||
sec.xoffs[sector_t::ceiling] = sc.Float;
|
||||
}
|
||||
else if (sc.Compare("ceilingoffsety"))
|
||||
{
|
||||
sc.CheckString("=");
|
||||
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"))
|
||||
{
|
||||
|
@ -464,14 +464,14 @@ static void parseSector(FScanner &sc)
|
|||
sc.MustGetNumber();
|
||||
if (sc.CheckString("%")) sc.Float = sc.Number / 100.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"))
|
||||
{
|
||||
sc.MustGetFloat();
|
||||
if (sc.CheckString("%")) sc.Float = sc.Number / 100.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"))
|
||||
|
@ -742,10 +742,10 @@ void ProcessEDSector(sector_t *sec, int recordnum)
|
|||
const DWORD pflagmask = PLANEF_DISABLED | PLANEF_NORENDER | PLANEF_NOPASS | PLANEF_BLOCKSOUND | PLANEF_ADDITIVE;
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
sec->planes[i].xform.xoffs = esec->planexform[i].xoffs;
|
||||
sec->planes[i].xform.yoffs = esec->planexform[i].yoffs;
|
||||
sec->planes[i].xform.angle = esec->planexform[i].angle;
|
||||
sec->planes[i].alpha = esec->overlayalpha[i];
|
||||
sec->SetXOffset(i, esec->xoffs[i]);
|
||||
sec->SetYOffset(i, esec->yoffs[i]);
|
||||
sec->SetAngle(i, esec->angle[i]);
|
||||
sec->SetAlpha(i, esec->Overlayalpha[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 p2;
|
||||
|
||||
if (ld->dx == 0)
|
||||
if (ld->Delta().X == 0)
|
||||
{ // ST_VERTICAL
|
||||
p1 = m_Box[BOXRIGHT] < ld->v1->fixX();
|
||||
p2 = m_Box[BOXLEFT] < ld->v1->fixX();
|
||||
if (ld->dy < 0)
|
||||
if (ld->Delta().Y < 0)
|
||||
{
|
||||
p1 ^= 1;
|
||||
p2 ^= 1;
|
||||
}
|
||||
}
|
||||
else if (ld->dy == 0)
|
||||
else if (ld->Delta().Y == 0)
|
||||
{ // ST_HORIZONTAL:
|
||||
p1 = m_Box[BOXTOP] > ld->v1->fixY();
|
||||
p2 = m_Box[BOXBOTTOM] > ld->v1->fixY();
|
||||
if (ld->dx < 0)
|
||||
if (ld->Delta().X < 0)
|
||||
{
|
||||
p1 ^= 1;
|
||||
p2 ^= 1;
|
||||
}
|
||||
}
|
||||
else if ((ld->dy ^ ld->dx) >= 0)
|
||||
else if ((ld->Delta().X * ld->Delta().Y) >= 0)
|
||||
{ // ST_POSITIVE:
|
||||
p1 = P_PointOnLineSide (m_Box[BOXLEFT], m_Box[BOXTOP], ld);
|
||||
p2 = P_PointOnLineSide (m_Box[BOXRIGHT], m_Box[BOXBOTTOM], ld);
|
||||
|
|
|
@ -135,14 +135,12 @@ static void P_Add3DFloor(sector_t* sec, sector_t* sec2, line_t* master, int flag
|
|||
{
|
||||
ffloor->bottom.plane = &sec2->floorplane;
|
||||
ffloor->bottom.texture = &sec2->planes[sector_t::floor].Texture;
|
||||
ffloor->bottom.texheight = &sec2->planes[sector_t::floor].TexZ;
|
||||
ffloor->bottom.isceiling = sector_t::floor;
|
||||
}
|
||||
else
|
||||
{
|
||||
ffloor->bottom.plane = &sec2->ceilingplane;
|
||||
ffloor->bottom.texture = &sec2->planes[sector_t::ceiling].Texture;
|
||||
ffloor->bottom.texheight = &sec2->planes[sector_t::ceiling].TexZ;
|
||||
ffloor->bottom.isceiling = sector_t::ceiling;
|
||||
}
|
||||
|
||||
|
@ -150,7 +148,6 @@ static void P_Add3DFloor(sector_t* sec, sector_t* sec2, line_t* master, int flag
|
|||
{
|
||||
ffloor->top.plane = &sec2->ceilingplane;
|
||||
ffloor->top.texture = &sec2->planes[sector_t::ceiling].Texture;
|
||||
ffloor->top.texheight = &sec2->planes[sector_t::ceiling].TexZ;
|
||||
ffloor->toplightlevel = &sec2->lightlevel;
|
||||
ffloor->top.isceiling = sector_t::ceiling;
|
||||
}
|
||||
|
@ -158,7 +155,6 @@ static void P_Add3DFloor(sector_t* sec, sector_t* sec2, line_t* master, int flag
|
|||
{
|
||||
ffloor->top.plane = &sec->floorplane;
|
||||
ffloor->top.texture = &sec2->planes[sector_t::floor].Texture;
|
||||
ffloor->top.texheight = &sec2->planes[sector_t::floor].TexZ;
|
||||
ffloor->toplightlevel = &sec->lightlevel;
|
||||
ffloor->top.isceiling = sector_t::floor;
|
||||
ffloor->top.model = sec;
|
||||
|
|
|
@ -68,7 +68,6 @@ struct F3DFloor
|
|||
{
|
||||
secplane_t * plane;
|
||||
const FTextureID * texture;
|
||||
const fixed_t * texheight;
|
||||
sector_t * model;
|
||||
int isceiling;
|
||||
int vindex;
|
||||
|
|
|
@ -129,10 +129,10 @@ struct gl5_mapnode_t
|
|||
|
||||
static int CheckForMissingSegs()
|
||||
{
|
||||
float *added_seglen = new float[numsides];
|
||||
double *added_seglen = new double[numsides];
|
||||
int missing = 0;
|
||||
|
||||
memset(added_seglen, 0, sizeof(float)*numsides);
|
||||
memset(added_seglen, 0, sizeof(double)*numsides);
|
||||
for(int i=0;i<numsegs;i++)
|
||||
{
|
||||
seg_t * seg = &segs[i];
|
||||
|
@ -140,20 +140,15 @@ static int CheckForMissingSegs()
|
|||
if (seg->sidedef!=NULL)
|
||||
{
|
||||
// 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());
|
||||
added_seglen[seg->sidedef - sides] += float(vec1.Length());
|
||||
DVector2 vec1(seg->v2->fX() - seg->v1->fX(), seg->v2->fY() - seg->v1->fY());
|
||||
added_seglen[seg->sidedef - sides] += vec1.Length();
|
||||
}
|
||||
}
|
||||
|
||||
for(int i=0;i<numsides;i++)
|
||||
{
|
||||
side_t * side =&sides[i];
|
||||
line_t * line = side->linedef;
|
||||
|
||||
DVector2 lvec(line->dx, line->dy);
|
||||
float linelen = float(lvec.Length());
|
||||
|
||||
missing += (added_seglen[i] < linelen - FRACUNIT);
|
||||
double linelen = sides[i].linedef->Delta().Length();
|
||||
missing += (added_seglen[i] < linelen - 1.);
|
||||
}
|
||||
|
||||
delete [] added_seglen;
|
||||
|
|
|
@ -410,38 +410,37 @@ bool AActor::FixMapthingPos()
|
|||
continue;
|
||||
|
||||
// Get the exact distance to the line
|
||||
fdivline_t dll, dlv;
|
||||
fixed_t linelen = (fixed_t)g_sqrt((double)ldef->dx*ldef->dx + (double)ldef->dy*ldef->dy);
|
||||
divline_t dll, dlv;
|
||||
double linelen = ldef->Delta().Length();
|
||||
|
||||
P_MakeDivline(ldef, &dll);
|
||||
|
||||
dlv.x = _f_X();
|
||||
dlv.y = _f_Y();
|
||||
dlv.dx = FixedDiv(dll.dy, linelen);
|
||||
dlv.dy = -FixedDiv(dll.dx, linelen);
|
||||
dlv.x = X();
|
||||
dlv.y = Y();
|
||||
dlv.dx = dll.dy / 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",
|
||||
this->GetClass()->TypeName.GetChars(), _f_X() >> FRACBITS, _f_Y() >> FRACBITS,
|
||||
ldef->dx == 0 ? "vertical" : ldef->dy == 0 ? "horizontal" : "diagonal",
|
||||
DPrintf("%s at (%f,%f) lies on %s line %td, distance = %f\n",
|
||||
this->GetClass()->TypeName.GetChars(), X(), Y(),
|
||||
ldef->Delta().X == 0 ? "vertical" : ldef->Delta().Y == 0 ? "horizontal" : "diagonal",
|
||||
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)
|
||||
{
|
||||
finean += ANGLE_90;
|
||||
ang += 90.;
|
||||
}
|
||||
else
|
||||
{
|
||||
finean -= ANGLE_90;
|
||||
ang -= 90.;
|
||||
}
|
||||
finean >>= ANGLETOFINESHIFT;
|
||||
|
||||
// Get the distance we have to move the object away from the wall
|
||||
distance = _f_radius() - distance;
|
||||
SetXY(_f_X() + FixedMul(distance, finecosine[finean]), _f_Y() + FixedMul(distance, finesine[finean]));
|
||||
distance = radius - distance;
|
||||
SetXY(Pos().XY() + ang.ToVector(distance));
|
||||
ClearInterpolation();
|
||||
success = true;
|
||||
}
|
||||
|
@ -1936,27 +1935,32 @@ int P_VanillaPointOnLineSide(fixed_t x, fixed_t y, const line_t* line)
|
|||
fixed_t dy;
|
||||
fixed_t left;
|
||||
fixed_t right;
|
||||
DVector2 delta = line->Delta();
|
||||
|
||||
if (!line->dx)
|
||||
if (delta.X == 0)
|
||||
{
|
||||
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())
|
||||
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());
|
||||
dy = (y - line->v1->fixY());
|
||||
|
||||
left = FixedMul ( line->dy>>FRACBITS , dx );
|
||||
right = FixedMul ( dy , line->dx>>FRACBITS );
|
||||
left = FixedMul ( int(delta.Y * 256) , dx );
|
||||
right = FixedMul ( dy , int(delta.X * 256) );
|
||||
|
||||
if (right < left)
|
||||
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
|
||||
? 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)
|
||||
{
|
||||
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)
|
||||
|
@ -125,8 +125,8 @@ inline void P_MakeDivline (const line_t *li, fdivline_t *dl)
|
|||
{
|
||||
dl->x = li->v1->fixX();
|
||||
dl->y = li->v1->fixY();
|
||||
dl->dx = li->dx;
|
||||
dl->dy = li->dy;
|
||||
dl->dx = li->fixDx();
|
||||
dl->dy = li->fixDy();
|
||||
}
|
||||
|
||||
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];
|
||||
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 ?
|
||||
planeh > portal->specialf1 : planeh < portal->specialf1);
|
||||
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)
|
||||
{
|
||||
DVector2 delta = linedef->Delta();
|
||||
int rel;
|
||||
if (((level.flags2 & LEVEL2_SMOOTHLIGHTING) || (Flags & WALLF_SMOOTHLIGHTING) || r_fakecontrast == 2) &&
|
||||
linedef->dx != 0)
|
||||
delta.X != 0)
|
||||
{
|
||||
rel = xs_RoundToInt // OMG LEE KILLOUGH LIVES! :/
|
||||
(
|
||||
level.WallHorizLight
|
||||
+ fabs(atan(double(linedef->dy) / linedef->dx) / 1.57079)
|
||||
+ fabs(atan(delta.Y / delta.X) / 1.57079)
|
||||
* (level.WallVertLight - level.WallHorizLight)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
rel = linedef->dx == 0 ? level.WallVertLight :
|
||||
linedef->dy == 0 ? level.WallHorizLight : 0;
|
||||
rel = delta.X == 0 ? level.WallVertLight :
|
||||
delta.Y == 0 ? level.WallHorizLight : 0;
|
||||
}
|
||||
if (pfakecontrast != NULL)
|
||||
{
|
||||
|
|
|
@ -1903,8 +1903,7 @@ void P_AdjustLine (line_t *ld)
|
|||
v1 = ld->v1;
|
||||
v2 = ld->v2;
|
||||
|
||||
ld->dx = v2->fixX() - v1->fixX();
|
||||
ld->dy = v2->fixY() - v1->fixY();
|
||||
ld->setDelta(v2->fX() - v1->fX(), v2->fY() - v1->fY());
|
||||
|
||||
if (v1->fixX() < v2->fixX())
|
||||
{
|
||||
|
@ -2423,15 +2422,15 @@ static void P_LoopSidedefs (bool firstloop)
|
|||
if (sidetemp[right].b.next != NO_SIDE)
|
||||
{
|
||||
int bestright = right; // Shut up, GCC
|
||||
angle_t bestang = ANGLE_MAX;
|
||||
DAngle bestang = 360.;
|
||||
line_t *leftline, *rightline;
|
||||
angle_t ang1, ang2, ang;
|
||||
DAngle ang1, ang2, ang;
|
||||
|
||||
leftline = sides[i].linedef;
|
||||
ang1 = R_PointToAngle2 (0, 0, leftline->dx, leftline->dy);
|
||||
ang1 = leftline->Delta().Angle();
|
||||
if (!sidetemp[i].b.lineside)
|
||||
{
|
||||
ang1 += ANGLE_180;
|
||||
ang1 += 180;
|
||||
}
|
||||
|
||||
while (right != NO_SIDE)
|
||||
|
@ -2441,13 +2440,13 @@ static void P_LoopSidedefs (bool firstloop)
|
|||
rightline = sides[right].linedef;
|
||||
if (rightline->frontsector != rightline->backsector)
|
||||
{
|
||||
ang2 = R_PointToAngle2 (0, 0, rightline->dx, rightline->dy);
|
||||
ang2 = rightline->Delta().Angle();
|
||||
if (sidetemp[right].b.lineside)
|
||||
{
|
||||
ang2 += ANGLE_180;
|
||||
ang2 += 180;
|
||||
}
|
||||
|
||||
ang = ang2 - ang1;
|
||||
ang = (ang2 - ang1).Normalized360();
|
||||
|
||||
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;
|
||||
|
||||
p[0] = FIXED2DBL (line->v1->fixX());
|
||||
p[1] = FIXED2DBL (line->v1->fixY());
|
||||
p[2] = FIXED2DBL (plane->ZatPoint (line->v1->fixX(), line->v1->fixY()));
|
||||
v1[0] = FIXED2DBL (line->dx);
|
||||
v1[1] = FIXED2DBL (line->dy);
|
||||
v1[2] = FIXED2DBL (plane->ZatPoint (line->v2->fixX(), line->v2->fixY())) - p[2];
|
||||
v2[0] = FIXED2DBL (x - line->v1->fixX());
|
||||
v2[1] = FIXED2DBL (y - line->v1->fixY());
|
||||
p[0] = line->v1->fX();
|
||||
p[1] = line->v1->fY();
|
||||
p[2] = plane->ZatPointF (line->v1);
|
||||
v1[0] = line->Delta().X;
|
||||
v1[1] = line->Delta().Y;
|
||||
v1[2] = plane->ZatPointF (line->v2) - p[2];
|
||||
v2[0] = FIXED2DBL (x) - p[0];
|
||||
v2[1] = FIXED2DBL (y) - p[1];
|
||||
v2[2] = FIXED2DBL (z) - p[2];
|
||||
|
||||
cross = v1 ^ v2;
|
||||
|
@ -487,8 +487,8 @@ static void P_AlignPlane (sector_t *sec, line_t *line, int which)
|
|||
vert = (*probe++)->v2;
|
||||
else
|
||||
vert = (*probe)->v1;
|
||||
dist = fabs((double(line->v1->fixY()) - vert->fixY()) * line->dx -
|
||||
(double(line->v1->fixX()) - vert->fixX()) * line->dy);
|
||||
dist = fabs((double(line->v1->fixY()) - vert->fixY()) * line->fixDx() -
|
||||
(double(line->v1->fixX()) - vert->fixX()) * line->fixDy());
|
||||
|
||||
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);
|
||||
destheight = (which == 0) ? refsec->GetPlaneTexZ(sector_t::floor) : refsec->GetPlaneTexZ(sector_t::ceiling);
|
||||
|
||||
p[0] = FIXED2DBL (line->v1->fixX());
|
||||
p[1] = FIXED2DBL(line->v1->fixY());
|
||||
p[0] = line->v1->fX();
|
||||
p[1] = line->v1->fY();
|
||||
p[2] = FIXED2DBL(destheight);
|
||||
v1[0] = FIXED2DBL(line->dx);
|
||||
v1[1] = FIXED2DBL(line->dy);
|
||||
v1[0] = line->Delta().X;
|
||||
v1[1] = line->Delta().Y;
|
||||
v1[2] = 0;
|
||||
v2[0] = FIXED2DBL(refvert->fixX() - line->v1->fixX());
|
||||
v2[1] = FIXED2DBL(refvert->fixY() - line->v1->fixY());
|
||||
v2[0] = refvert->fX() - line->v1->fX();
|
||||
v2[1] = refvert->fY() - line->v1->fY();
|
||||
v2[2] = FIXED2DBL(srcheight - destheight);
|
||||
|
||||
cross = (v1 ^ v2).Unit();
|
||||
|
|
|
@ -943,8 +943,9 @@ void FPolyObj::UpdateBBox ()
|
|||
}
|
||||
|
||||
// Update the line's slopetype
|
||||
line->dx = line->v2->fixX() - line->v1->fixX();
|
||||
line->dy = line->v2->fixY() - line->v1->fixY();
|
||||
line->setDelta(
|
||||
line->v2->fixX() - line->v1->fixX(),
|
||||
line->v2->fixY() - line->v1->fixY());
|
||||
}
|
||||
CalcCenter();
|
||||
}
|
||||
|
|
|
@ -251,10 +251,10 @@ static void SetRotation(FLinePortal *port)
|
|||
{
|
||||
line_t *dst = port->mDestination;
|
||||
line_t *line = port->mOrigin;
|
||||
double angle = g_atan2(dst->dy, dst->dx) - g_atan2(line->dy, line->dx) + M_PI;
|
||||
port->mSinRot = FLOAT2FIXED(g_sin(angle));
|
||||
port->mCosRot = FLOAT2FIXED(g_cos(angle));
|
||||
port->mAngleDiff = ToDegrees(angle);
|
||||
DAngle angle = dst->Delta().Angle() - line->Delta().Angle() + 180.;
|
||||
port->mSinRot = FLOAT2FIXED(angle.Sin());
|
||||
port->mCosRot = FLOAT2FIXED(angle.Cos());
|
||||
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)
|
||||
{
|
||||
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)
|
||||
|
@ -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)
|
||||
{
|
||||
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;
|
||||
|
||||
fixed_t dx = line->v1->fixX() - x;
|
||||
|
|
54
src/r_defs.h
54
src/r_defs.h
|
@ -449,6 +449,11 @@ public:
|
|||
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
|
||||
{
|
||||
return FixedMul (ic, -d - DMulScale16 (a, ac->_f_X(), b, ac->_f_Y()));
|
||||
|
@ -772,6 +777,11 @@ struct sector_t
|
|||
planes[pos].xform.xoffs = o;
|
||||
}
|
||||
|
||||
void SetXOffset(int pos, double o)
|
||||
{
|
||||
planes[pos].xform.xoffs = FLOAT2FIXED(o);
|
||||
}
|
||||
|
||||
void AddXOffset(int pos, fixed_t o)
|
||||
{
|
||||
planes[pos].xform.xoffs += o;
|
||||
|
@ -797,6 +807,11 @@ struct sector_t
|
|||
planes[pos].xform.yoffs = o;
|
||||
}
|
||||
|
||||
void SetYOffset(int pos, double o)
|
||||
{
|
||||
planes[pos].xform.yoffs = FLOAT2FIXED(o);
|
||||
}
|
||||
|
||||
void AddYOffset(int pos, fixed_t o)
|
||||
{
|
||||
planes[pos].xform.yoffs += o;
|
||||
|
@ -866,6 +881,11 @@ struct sector_t
|
|||
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
|
||||
{
|
||||
if (!addbase)
|
||||
|
@ -976,12 +996,22 @@ struct sector_t
|
|||
if (dirtify) SetAllVerticesDirty();
|
||||
}
|
||||
|
||||
void SetPlaneTexZ(int pos, double val)
|
||||
{
|
||||
planes[pos].TexZ = FLOAT2FIXED(val);
|
||||
}
|
||||
|
||||
void ChangePlaneTexZ(int pos, fixed_t val)
|
||||
{
|
||||
planes[pos].TexZ += val;
|
||||
SetAllVerticesDirty();
|
||||
}
|
||||
|
||||
void ChangePlaneTexZ(int pos, double val)
|
||||
{
|
||||
planes[pos].TexZ += FLOAT2FIXED(val);
|
||||
}
|
||||
|
||||
static inline short ClampLight(int level)
|
||||
{
|
||||
return (short)clamp(level, SHRT_MIN, SHRT_MAX);
|
||||
|
@ -1423,7 +1453,9 @@ FArchive &operator<< (FArchive &arc, side_t::part &p);
|
|||
struct line_t
|
||||
{
|
||||
vertex_t *v1, *v2; // vertices, from v1 to v2
|
||||
private:
|
||||
fixed_t dx, dy; // precalculated v2 - v1 for side checking
|
||||
public:
|
||||
DWORD flags;
|
||||
DWORD activation; // activation type
|
||||
int special;
|
||||
|
@ -1452,6 +1484,28 @@ struct line_t
|
|||
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
|
||||
{
|
||||
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;
|
||||
|
||||
// Reflect the current view behind the mirror.
|
||||
if (pds->src->dx == 0)
|
||||
if (pds->src->Delta().X == 0)
|
||||
{ // vertical mirror
|
||||
viewx = v1->fixX() - startx + v1->fixX();
|
||||
}
|
||||
else if (pds->src->dy == 0)
|
||||
else if (pds->src->Delta().Y == 0)
|
||||
{ // horizontal mirror
|
||||
viewy = v1->fixY() - starty + v1->fixY();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue