Merge branch 'floatcvt' of https://github.com/rheit/zdoom into floatcvt

# Conflicts:
#	src/r_defs.h
This commit is contained in:
Christoph Oelckers 2016-04-02 22:17:33 +02:00
commit f7553fcd51
34 changed files with 388 additions and 605 deletions

View File

@ -1193,15 +1193,6 @@ public:
bool HasSpecialDeathStates () const;
fixed_t _f_X() const
{
return FLOAT2FIXED(__Pos.X);
}
fixed_t _f_Y() const
{
return FLOAT2FIXED(__Pos.Y);
}
double X() const
{
return __Pos.X;
@ -1274,23 +1265,11 @@ public:
if (!moving) Prev.Z = Z();
}
// These are not for general use as they do not link the actor into the world!
void SetXY(fixed_t xx, fixed_t yy)
{
__Pos.X = FIXED2DBL(xx);
__Pos.Y = FIXED2DBL(yy);
}
void SetXY(const DVector2 &npos)
{
__Pos.X = npos.X;
__Pos.Y = npos.Y;
}
void SetXYZ(fixed_t xx, fixed_t yy, fixed_t zz)
{
__Pos.X = FIXED2DBL(xx);
__Pos.Y = FIXED2DBL(yy);
__Pos.Z = FIXED2DBL(zz);
}
void SetXYZ(double xx, double yy, double zz)
{
__Pos = { xx,yy,zz };

View File

@ -1931,7 +1931,7 @@ void AM_drawSubsectors()
sector_t *sec = Renderer->FakeFlat(subsectors[i].render_sector, &tempsec, &floorlight, &ceilinglight, false);
// Find texture origin.
originpt.x = -sec->GetXOffsetF(sector_t::floor);
originpt.y = sec->GetYOffset(sector_t::floor);
originpt.y = sec->GetYOffsetF(sector_t::floor);
rotation = -sec->GetAngleF(sector_t::floor);
// Coloring for the polygon
colormap = sec->ColorMap;
@ -1953,13 +1953,13 @@ void AM_drawSubsectors()
double secx;
double secy;
double seczb, seczt;
double cmpz = FIXED2DBL(viewz);
double cmpz = ViewPos.Z;
if (players[consoleplayer].camera && sec == players[consoleplayer].camera->Sector)
{
// For the actual camera sector use the current viewpoint as reference.
secx = FIXED2DBL(viewx);
secy = FIXED2DBL(viewy);
secx = ViewPos.X;
secy = ViewPos.Y;
}
else
{
@ -3011,7 +3011,7 @@ void AM_drawAuthorMarkers ()
marked->subsector->flags & SSECF_DRAWN :
marked->Sector->MoreFlags & SECF_DRAWN)))
{
DrawMarker (tex, marked->X(), marked->Y(), 0, flip, mark->Scale.X, mark->Scale.Y, mark->Translation,
DrawMarker (tex, marked->X(), marked->Y(), 0, flip, mark->Scale.X*16, mark->Scale.Y*16, mark->Translation,
mark->Alpha, mark->fillcolor, mark->RenderStyle);
}
marked = mark->args[0] != 0 ? it.Next() : NULL;

View File

@ -1782,7 +1782,7 @@ public:
m_Type = DCeiling::ceilLowerByValue; // doesn't really matter as long as it's no special value
m_Tag=tag;
m_TopHeight=m_BottomHeight=sec->ceilingplane.PointToDist(sec->centerspot,destheight);
m_Direction=destheight>sec->GetPlaneTexZ(sector_t::ceiling)? 1:-1;
m_Direction=destheight>sec->GetPlaneTexZF(sector_t::ceiling)? 1:-1;
// Do not interpolate instant movement ceilings.
double movedist = fabs(sec->ceilingplane.fD() - m_BottomHeight);

View File

@ -156,6 +156,11 @@ inline double AngleToFloat(unsigned f)
return f * (90. / 0x40000000);
}
inline double AngleToFloat(int f)
{
return f * (90. / 0x40000000);
}
#define FLOAT2FIXED(f) FloatToFixed(f)
#define FIXED2FLOAT(f) float(FixedToFloat(f))
#define FIXED2DBL(f) FixedToFloat(f)

View File

@ -205,7 +205,7 @@ void DCeiling::Tick ()
case ceilCrushAndRaise:
case ceilLowerAndCrush:
if (m_CrushMode == ECrushMode::crushSlowdown)
m_Speed = FRACUNIT / 8;
m_Speed = 1. / 8;
break;
default:

View File

@ -254,7 +254,7 @@ void DDoor::DoorSound(bool raise, DSeqNode *curseq) const
if (m_Sector->Flags & SECF_SILENTMOVE) return;
if (m_Speed >= FRACUNIT*8)
if (m_Speed >= 8)
{
choice += 2;
}

View File

@ -149,15 +149,16 @@ CUSTOM_CVAR( Int, r_maxparticles, 4000, CVAR_ARCHIVE )
void P_InitParticles ()
{
const char *i;
int num;
if ((i = Args->CheckValue ("-numparticles")))
NumParticles = atoi (i);
num = atoi (i);
// [BC] Use r_maxparticles now.
else
NumParticles = r_maxparticles;
num = r_maxparticles;
// This should be good, but eh...
NumParticles = clamp<WORD>(NumParticles, 100, 65535);
NumParticles = (WORD)clamp<int>(num, 100, 65535);
P_DeinitParticles();
Particles = new particle_t[NumParticles];
@ -206,7 +207,7 @@ void P_FindParticleSubsectors ()
for (WORD i = ActiveParticles; i != NO_PARTICLE; i = Particles[i].tnext)
{
// Try to reuse the subsector from the last portal check, if still valid.
if (Particles[i].subsector == NULL) Particles[i].subsector = R_PointInSubsector(Particles[i].x, Particles[i].y);
if (Particles[i].subsector == NULL) Particles[i].subsector = R_PointInSubsector(Particles[i].Pos);
int ssnum = int(Particles[i].subsector - subsectors);
Particles[i].snext = ParticlesInSubsec[ssnum];
ParticlesInSubsec[ssnum] = i;
@ -279,33 +280,29 @@ void P_ThinkParticles ()
continue;
}
DVector2 newxy = P_GetOffsetPosition(FIXED2DBL(particle->x), FIXED2DBL(particle->y), FIXED2DBL(particle->vel.x), FIXED2DBL(particle->vel.y));
particle->x = FLOAT2FIXED(newxy.X);
particle->y = FLOAT2FIXED(newxy.Y);
//particle->x += particle->vel.x;
//particle->y += particle->vel.y;
particle->z += particle->vel.z;
particle->vel.x += particle->accx;
particle->vel.y += particle->accy;
particle->vel.z += particle->accz;
particle->subsector = R_PointInSubsector(particle->x, particle->y);
// Handle crossing a line portal
DVector2 newxy = P_GetOffsetPosition(particle->Pos.X, particle->Pos.Y, particle->Vel.X, particle->Vel.Y);
particle->Pos.X = newxy.X;
particle->Pos.Y = newxy.Y;
particle->Pos.Z += particle->Vel.Z;
particle->Vel += particle->Acc;
particle->subsector = R_PointInSubsector(particle->Pos);
// Handle crossing a sector portal.
if (!particle->subsector->sector->PortalBlocksMovement(sector_t::ceiling))
{
AActor *skybox = particle->subsector->sector->SkyBoxes[sector_t::ceiling];
if (particle->z > FLOAT2FIXED(skybox->specialf1))
if (particle->Pos.Z > skybox->specialf1)
{
particle->x += FLOAT2FIXED(skybox->Scale.X);
particle->y += FLOAT2FIXED(skybox->Scale.Y);
particle->Pos += skybox->Scale;
particle->subsector = NULL;
}
}
else if (!particle->subsector->sector->PortalBlocksMovement(sector_t::floor))
{
AActor *skybox = particle->subsector->sector->SkyBoxes[sector_t::floor];
if (particle->z < FLOAT2FIXED(skybox->specialf1))
if (particle->Pos.Z < skybox->specialf1)
{
particle->x += FLOAT2FIXED(skybox->Scale.X);
particle->y += FLOAT2FIXED(skybox->Scale.Y);
particle->Pos += skybox->Scale;
particle->subsector = NULL;
}
}
@ -320,20 +317,14 @@ void P_SpawnParticle(const DVector3 &pos, const DVector3 &vel, const DVector3 &a
if (particle)
{
particle->x = FLOAT2FIXED(pos.X);
particle->y = FLOAT2FIXED(pos.Y);
particle->z = FLOAT2FIXED(pos.Z);
particle->vel.x = FLOAT2FIXED(vel.X);
particle->vel.y = FLOAT2FIXED(vel.Y);
particle->vel.z = FLOAT2FIXED(vel.Z);
particle->Pos = pos;
particle->Vel = vel;
particle->Acc = accel;
particle->color = ParticleColor(color);
particle->trans = BYTE(startalpha*255);
if (fadestep < 0) particle->fade = FADEFROMTTL(lifetime);
else particle->fade = int(fadestep * 255);
particle->ttl = lifetime;
particle->accx = FLOAT2FIXED(accel.X);
particle->accy = FLOAT2FIXED(accel.Y);
particle->accz = FLOAT2FIXED(accel.Z);
particle->bright = fullbright;
particle->size = (WORD)size;
}
@ -380,15 +371,14 @@ particle_t *JitterParticle (int ttl, double drift)
particle_t *particle = NewParticle ();
if (particle) {
fixed_t *val = &particle->vel.x;
int i;
// Set initial velocities
for (i = 3; i; i--, val++)
*val = (int)((FRACUNIT/4096) * (M_Random () - 128) * drift);
for (i = 3; i; i--)
particle->Vel[i] = ((1./4096) * (M_Random () - 128) * drift);
// Set initial accelerations
for (i = 3; i; i--, val++)
*val = (int)((FRACUNIT/16384) * (M_Random () - 128) * drift);
for (i = 3; i; i--)
particle->Acc[i] = ((1./16384) * (M_Random () - 128) * drift);
particle->trans = 255; // fully opaque
particle->ttl = ttl;
@ -411,15 +401,12 @@ static void MakeFountain (AActor *actor, int color1, int color2)
DAngle an = M_Random() * (360. / 256);
double out = actor->radius * M_Random() / 256.;
DVector3 pos = actor->Vec3Angle(out, an, actor->Height + 1);
particle->x = FLOAT2FIXED(pos.X);
particle->y = FLOAT2FIXED(pos.Y);
particle->z = FLOAT2FIXED(pos.Z);
particle->Pos = actor->Vec3Angle(out, an, actor->Height + 1);
if (out < actor->radius/8)
particle->vel.z += FRACUNIT*10/3;
particle->Vel.Z += 10./3;
else
particle->vel.z += FRACUNIT*3;
particle->accz -= FRACUNIT/11;
particle->Vel.Z += 3;
particle->Acc.Z -= 1./11;
if (M_Random() < 30) {
particle->size = 4;
particle->color = color2;
@ -445,7 +432,7 @@ void P_RunEffect (AActor *actor, int effects)
double backz = actor->Height * ((2. / 3) - actor->Vel.Z / 8);
DAngle an = moveangle + 90.;
int speed;
double speed;
particle = JitterParticle (3 + (M_Random() & 31));
if (particle) {
@ -454,14 +441,12 @@ void P_RunEffect (AActor *actor, int effects)
backx - actor->Vel.X * pathdist,
backy - actor->Vel.Y * pathdist,
backz - actor->Vel.Z * pathdist);
particle->x = FLOAT2FIXED(pos.X);
particle->y = FLOAT2FIXED(pos.Y);
particle->z = FLOAT2FIXED(pos.Z);
speed = (M_Random () - 128) * (FRACUNIT/200);
particle->vel.x += fixed_t(speed * an.Cos());
particle->vel.y += fixed_t(speed * an.Sin());
particle->vel.z -= FRACUNIT/36;
particle->accz -= FRACUNIT/20;
particle->Pos = pos;
speed = (M_Random () - 128) * (1./200);
particle->Vel.X += speed * an.Cos();
particle->Vel.Y += speed * an.Sin();
particle->Vel.Z -= 1./36;
particle->Acc.Z -= 1./20;
particle->color = yellow;
particle->size = 2;
}
@ -473,15 +458,13 @@ void P_RunEffect (AActor *actor, int effects)
backx - actor->Vel.X * pathdist,
backy - actor->Vel.Y * pathdist,
backz - actor->Vel.Z * pathdist + (M_Random() / 64.));
particle->x = FLOAT2FIXED(pos.X);
particle->y = FLOAT2FIXED(pos.Y);
particle->z = FLOAT2FIXED(pos.Z);
particle->Pos = pos;
speed = (M_Random () - 128) * (FRACUNIT/200);
particle->vel.x += fixed_t(speed * an.Cos());
particle->vel.y += fixed_t(speed * an.Sin());
particle->vel.z += FRACUNIT/80;
particle->accz += FRACUNIT/40;
speed = (M_Random () - 128) * (1./200);
particle->Vel.X += speed * an.Cos();
particle->Vel.Y += speed * an.Sin();
particle->Vel.Z -= 1. / 80;
particle->Acc.Z -= 1. / 40;
if (M_Random () & 7)
particle->color = grey2;
else
@ -529,18 +512,16 @@ void P_RunEffect (AActor *actor, int effects)
{
DAngle ang = M_Random() * (360 / 256.);
DVector3 pos = actor->Vec3Angle(actor->radius, ang, 0);
particle->x = FLOAT2FIXED(pos.X);
particle->y = FLOAT2FIXED(pos.Y);
particle->z = FLOAT2FIXED(pos.Z);
particle->Pos = pos;
particle->color = *protectColors[M_Random() & 1];
particle->vel.z = FRACUNIT;
particle->accz = M_Random () << 7;
particle->Vel.Z = 1;
particle->Acc.Z = M_Random () / 512.;
particle->size = 1;
if (M_Random () < 128)
{ // make particle fall from top of actor
particle->z += FLOAT2FIXED(actor->Height);
particle->vel.z = -particle->vel.z;
particle->accz = -particle->accz;
particle->Pos.Z += actor->Height;
particle->Vel.Z = -particle->Vel.Z;
particle->Acc.Z = -particle->Acc.Z;
}
}
}
@ -570,20 +551,21 @@ void P_DrawSplash (int count, const DVector3 &pos, DAngle angle, int kind)
p->size = 2;
p->color = M_Random() & 0x80 ? color1 : color2;
p->vel.z -= M_Random () * 512;
p->accz -= FRACUNIT/8;
p->accx += (M_Random () - 128) * 8;
p->accy += (M_Random () - 128) * 8;
p->z = FLOAT2FIXED(pos.Z) - M_Random () * 1024;
p->Vel.Z -= M_Random () / 128.;
p->Acc.Z -= 1./8;
p->Acc.X += (M_Random () - 128) / 8192.;
p->Acc.Y += (M_Random () - 128) / 8192.;
p->Pos.Z = pos.Z - M_Random () / 64.;
angle += M_Random() * (45./256);
p->x = FLOAT2FIXED(pos.X + (M_Random() & 15)*angle.Cos());
p->y = FLOAT2FIXED(pos.Y + (M_Random() & 15)*angle.Sin());
p->Pos.X = pos.X + (M_Random() & 15)*angle.Cos();
p->Pos.Y = pos.Y + (M_Random() & 15)*angle.Sin();
}
}
void P_DrawSplash2 (int count, const DVector3 &pos, DAngle angle, int updown, int kind)
{
int color1, color2, zvel, zspread, zadd;
int color1, color2, zadd;
double zvel, zspread;
switch (kind)
{
@ -605,14 +587,14 @@ void P_DrawSplash2 (int count, const DVector3 &pos, DAngle angle, int updown, in
break;
}
zvel = -128;
zspread = updown ? -6000 : 6000;
zadd = (updown == 2) ? -128 : 0;
zvel = -0.5;
zspread = updown ? -6000 / 65536. : 6000 / 65536.;
zadd = (updown == 2) ? 128 : 0;
for (; count; count--)
{
particle_t *p = NewParticle ();
angle_t an;
DAngle an;
if (!p)
break;
@ -622,19 +604,20 @@ void P_DrawSplash2 (int count, const DVector3 &pos, DAngle angle, int updown, in
p->trans = 255;
p->size = 4;
p->color = M_Random() & 0x80 ? color1 : color2;
p->vel.z = M_Random () * zvel;
p->accz = -FRACUNIT/22;
if (kind) {
an = (angle.BAMs() + ((M_Random() - 128) << 23)) >> ANGLETOFINESHIFT;
p->vel.x = (M_Random () * finecosine[an]) >> 11;
p->vel.y = (M_Random () * finesine[an]) >> 11;
p->accx = p->vel.x >> 4;
p->accy = p->vel.y >> 4;
p->Vel.Z = M_Random() * zvel;
p->Acc.Z = -1 / 22.;
if (kind)
{
an = angle + ((M_Random() - 128) * (180 / 256.));
p->Vel.X = M_Random() * an.Cos() / 2048.;
p->Vel.Y = M_Random() * an.Sin() / 2048.;
p->Acc.X = p->Vel.X / 16.;
p->Acc.Y = p->Vel.Y / 16.;
}
p->z = FLOAT2FIXED(pos.Z) + (M_Random () + zadd - 128) * zspread;
an = (angle.BAMs() + ((M_Random() - 128) << 22)) >> ANGLETOFINESHIFT;
p->x = FLOAT2FIXED(pos.X) + ((M_Random () & 31)-15)*finecosine[an];
p->y = FLOAT2FIXED(pos.X) + ((M_Random () & 31)-15)*finesine[an];
an = angle + ((M_Random() - 128) * (90 / 256.));
p->Pos.X = pos.X + ((M_Random() & 31) - 15) * an.Cos();
p->Pos.Y = pos.Y + ((M_Random() & 31) - 15) * an.Sin();
p->Pos.Z = pos.Z + (M_Random() + zadd - 128) * zspread;
}
}
@ -692,7 +675,7 @@ void P_DrawRailTrail(AActor *source, const DVector3 &start, const DVector3 &end,
point = start + r * dir;
dir.Z = dirz;
S_Sound (DVector3(point.X, point.Y, viewz), CHAN_WEAPON, sound, 1, ATTN_NORM);
S_Sound (DVector3(point.X, point.Y, ViewPos.Z), CHAN_WEAPON, sound, 1, ATTN_NORM);
}
}
}
@ -749,13 +732,8 @@ void P_DrawRailTrail(AActor *source, const DVector3 &start, const DVector3 &end,
p->bright = fullbright;
tempvec = DMatrix3x3(dir, deg) * extend;
p->vel.x = FLOAT2FIXED(tempvec.X * drift)>>4;
p->vel.y = FLOAT2FIXED(tempvec.Y * drift)>>4;
p->vel.z = FLOAT2FIXED(tempvec.Z * drift)>>4;
tempvec += pos;
p->x = FLOAT2FIXED(tempvec.X);
p->y = FLOAT2FIXED(tempvec.Y);
p->z = FLOAT2FIXED(tempvec.Z);
p->Vel = tempvec * drift / 16.;
p->Pos = tempvec + pos;
pos += spiral_step;
deg += double(r_rail_spiralsparsity * 14);
@ -812,11 +790,9 @@ void P_DrawRailTrail(AActor *source, const DVector3 &start, const DVector3 &end,
DVector3 postmp = pos + diff;
p->size = 2;
p->x = FLOAT2FIXED(postmp.X);
p->y = FLOAT2FIXED(postmp.Y);
p->z = FLOAT2FIXED(postmp.Z);
p->Pos = postmp;
if (color1 != -1)
p->accz -= FRACUNIT/4096;
p->Acc.Z -= 1./4096;
pos += trail_step;
p->bright = fullbright;
@ -888,10 +864,8 @@ void P_DisconnectEffect (AActor *actor)
double zo = M_Random()*actor->Height / 256;
DVector3 pos = actor->Vec3Offset(xo, yo, zo);
p->x = FLOAT2FIXED(pos.X);
p->y = FLOAT2FIXED(pos.Y);
p->z = FLOAT2FIXED(pos.Z);
p->accz -= FRACUNIT/4096;
p->Pos = pos;
p->Acc.Z -= 1./4096;
p->color = M_Random() < 128 ? maroon1 : maroon2;
p->size = 4;
}

View File

@ -52,21 +52,16 @@
struct subsector_t;
// [RH] Particle details
struct fixedvec3
{
fixed_t x, y, z;
};
struct particle_t
{
fixed_t x,y,z;
fixedvec3 vel;
fixed_t accx,accy,accz;
DVector3 Pos;
DVector3 Vel;
DVector3 Acc;
BYTE ttl;
BYTE trans;
WORD size;
BYTE bright:1;
BYTE bright;
BYTE fade;
int color;
WORD tnext;

View File

@ -615,7 +615,7 @@ bool EV_BuildStairs (int tag, DFloor::EStair type, line_t *line,
floor->m_PauseTime = 0;
floor->m_StepTime = floor->m_PerStepTime = persteptime;
floor->m_Crush = (!(usespecials & DFloor::stairUseSpecials) && speed == 4*FRACUNIT) ? 10 : -1; //jff 2/27/98 fix uninitialized crush field
floor->m_Crush = (!(usespecials & DFloor::stairUseSpecials) && speed == 4) ? 10 : -1; //jff 2/27/98 fix uninitialized crush field
floor->m_Hexencrush = false;
floor->m_Speed = speed;

View File

@ -102,7 +102,7 @@ static bool MoveCeiling(sector_t *sector, int crush, double move)
// Don't let the ceiling go below the floor
if (!sector->ceilingplane.isSlope() && !sector->floorplane.isSlope() &&
sector->GetPlaneTexZ(sector_t::floor) > sector->GetPlaneTexZ(sector_t::ceiling)) return false;
sector->GetPlaneTexZF(sector_t::floor) > sector->GetPlaneTexZF(sector_t::ceiling)) return false;
return true;
}
@ -116,7 +116,7 @@ static bool MoveFloor(sector_t *sector, int crush, double move)
// Don't let the floor go above the ceiling
if (!sector->ceilingplane.isSlope() && !sector->floorplane.isSlope() &&
sector->GetPlaneTexZ(sector_t::floor) > sector->GetPlaneTexZ(sector_t::ceiling)) return false;
sector->GetPlaneTexZF(sector_t::floor) > sector->GetPlaneTexZF(sector_t::ceiling)) return false;
return true;
}

View File

@ -2186,7 +2186,7 @@ FUNC(LS_Sector_SetTranslucent)
FSectorTagIterator itr(arg0);
while ((secnum = itr.Next()) >= 0)
{
sectors[secnum].SetAlpha(arg1, Scale(arg2, OPAQUE, 255));
sectors[secnum].SetAlpha(arg1, clamp(arg2, 0, 255) / 255.);
sectors[secnum].ChangeFlags(arg1, ~PLANEF_ADDITIVE, arg3? PLANEF_ADDITIVE:0);
}
return true;
@ -2465,9 +2465,9 @@ FUNC(LS_Sector_SetFloorScale2)
while ((secnum = itr.Next()) >= 0)
{
if (arg1)
sectors[secnum].SetXScale(sector_t::floor, arg1);
sectors[secnum].SetXScale(sector_t::floor, xscale);
if (arg2)
sectors[secnum].SetYScale(sector_t::floor, arg2);
sectors[secnum].SetYScale(sector_t::floor, yscale);
}
return true;
}
@ -2487,9 +2487,9 @@ FUNC(LS_Sector_SetCeilingScale2)
while ((secnum = itr.Next()) >= 0)
{
if (arg1)
sectors[secnum].SetXScale(sector_t::ceiling, arg1);
sectors[secnum].SetXScale(sector_t::ceiling, xscale);
if (arg2)
sectors[secnum].SetYScale(sector_t::ceiling, arg2);
sectors[secnum].SetYScale(sector_t::ceiling, yscale);
}
return true;
}

View File

@ -51,7 +51,6 @@ struct FTranslatedLineTarget;
// mapblocks are used to check movement
// against lines and things
#define MAPBLOCKUNITS 128
#define MAPBLOCKSIZE (MAPBLOCKUNITS*FRACUNIT)
// Inspired by Maes
extern int bmapnegx;

View File

@ -2220,7 +2220,7 @@ bool P_TryMove(AActor *thing, const DVector2 &pos,
// so that the renderer can properly calculate an interpolated position along the movement path.
if (thing == players[consoleplayer].camera)
{
divline_t dl1 = { besthit.Oldrefpos.X,besthit.Oldrefpos.Y, besthit.Refpos.X - besthit.Oldrefpos.Y, besthit.Refpos.Y - besthit.Oldrefpos.Y };
divline_t dl1 = { besthit.Oldrefpos.X,besthit.Oldrefpos.Y, besthit.Refpos.X - besthit.Oldrefpos.X, besthit.Refpos.Y - besthit.Oldrefpos.Y };
DVector3a hit = { {dl1.x + dl1.dx * bestfrac, dl1.y + dl1.dy * bestfrac, 0.},0. };
R_AddInterpolationPoint(hit);

View File

@ -1456,7 +1456,7 @@ void FPathTraverse::init(double x1, double y1, double x2, double y2, int flags,
if (flags & PT_DELTA)
{
x2 += x1;
y2 += y2;
y2 += y1;
}
x1 -= bmaporgx;
@ -1469,10 +1469,10 @@ void FPathTraverse::init(double x1, double y1, double x2, double y2, int flags,
xt2 = x2 / MAPBLOCKUNITS;
yt2 = y2 / MAPBLOCKUNITS;
mapx = int(xt1);
mapy = int(yt1);
int mapex = int(xt2);
int mapey = int(yt2);
mapx = xs_FloorToInt(xt1);
mapy = xs_FloorToInt(yt1);
int mapex = xs_FloorToInt(xt2);
int mapey = xs_FloorToInt(yt2);
if (mapex > mapx)
@ -1563,7 +1563,7 @@ void FPathTraverse::init(double x1, double y1, double x2, double y2, int flags,
}
// [RH] Handle corner cases properly instead of pretending they don't exist.
switch (((int(yintercept) == mapy) << 1) | (int(xintercept) == mapx))
switch (((xs_FloorToInt(yintercept) == mapy) << 1) | (xs_FloorToInt(xintercept) == mapx))
{
case 0: // neither xintercept nor yintercept match!
count = 100; // Stop traversing, because somebody screwed up.

View File

@ -38,12 +38,12 @@ struct intercept_t
inline int P_PointOnLineSidePrecise(double x, double y, const line_t *line)
{
return (y - line->v1->fY()) * line->Delta().X + (line->v1->fX() - x) * line->Delta().Y > -EQUAL_EPSILON;
return (y - line->v1->fY()) * line->Delta().X + (line->v1->fX() - x) * line->Delta().Y > EQUAL_EPSILON;
}
inline int P_PointOnLineSidePrecise(const DVector2 &pt, const line_t *line)
{
return (pt.Y - line->v1->fY()) * line->Delta().X + (line->v1->fX() - pt.X) * line->Delta().Y > -EQUAL_EPSILON;
return (pt.Y - line->v1->fY()) * line->Delta().X + (line->v1->fX() - pt.X) * line->Delta().Y > EQUAL_EPSILON;
}
inline int P_PointOnLineSide (double x, double y, const line_t *line)
@ -73,12 +73,12 @@ inline int P_PointOnLineSide(const DVector2 & p, const line_t *line)
inline int P_PointOnDivlineSide(double x, double y, const divline_t *line)
{
return (y - line->y) * line->dx + (line->x - x) * line->dy > -EQUAL_EPSILON;
return (y - line->y) * line->dx + (line->x - x) * line->dy > EQUAL_EPSILON;
}
inline int P_PointOnDivlineSide(const DVector2 &pos, const divline_t *line)
{
return (pos.Y - line->y) * line->dx + (line->x - pos.X) * line->dy > -EQUAL_EPSILON;
return (pos.Y - line->y) * line->dx + (line->x - pos.X) * line->dy > EQUAL_EPSILON;
}
//==========================================================================

View File

@ -1220,10 +1220,8 @@ void P_LoadSegs (MapData * map)
BYTE *vertchanged = new BYTE[numvertexes]; // phares 10/4/98
DWORD segangle;
line_t* line; // phares 10/4/98
int ptp_angle; // phares 10/4/98
int delta_angle; // phares 10/4/98
int dis; // phares 10/4/98
int dx,dy; // phares 10/4/98
//int ptp_angle; // phares 10/4/98
//int delta_angle; // phares 10/4/98
int vnum1,vnum2; // phares 10/4/98
int lumplen = map->Size(ML_SEGS);
@ -1315,30 +1313,26 @@ void P_LoadSegs (MapData * map)
// off, then move one vertex. This may seem insignificant, but one degree
// errors _can_ cause firelines.
ptp_angle = R_PointToAngle2 (li->v1->fixX(), li->v1->fixY(), li->v2->fixX(), li->v2->fixY());
dis = 0;
delta_angle = (absangle(ptp_angle-(segangle<<16))>>ANGLETOFINESHIFT)*360/FINEANGLES;
DAngle ptp_angle = (li->v2->fPos() - li->v1->fPos()).Angle();
DAngle seg_angle = AngleToFloat(segangle);
DAngle delta_angle = absangle(ptp_angle, seg_angle);
if (delta_angle != 0)
if (delta_angle >= 1.)
{
segangle >>= (ANGLETOFINESHIFT-16);
dx = (li->v1->fixX() - li->v2->fixX())>>FRACBITS;
dy = (li->v1->fixY() - li->v2->fixY())>>FRACBITS;
dis = ((int) g_sqrt((double)(dx*dx + dy*dy)))<<FRACBITS;
dx = finecosine[segangle];
dy = finesine[segangle];
double dis = (li->v2->fPos() - li->v1->fPos()).Length();
DVector2 delta = seg_angle.ToVector();
if ((vnum2 > vnum1) && (vertchanged[vnum2] == 0))
{
li->v2->set(
li->v1->fixX() + FixedMul(dis,dx),
li->v1->fixY() + FixedMul(dis,dy));
li->v1->fX() + dis * delta.X,
li->v1->fY() + dis * delta.Y);
vertchanged[vnum2] = 1; // this was changed
}
else if (vertchanged[vnum1] == 0)
{
li->v1->set(
li->v2->fixX() - FixedMul(dis,dx),
li->v2->fixY() - FixedMul(dis,dy));
li->v2->fX() - dis * delta.X,
li->v2->fY() - dis * delta.Y);
vertchanged[vnum1] = 1; // this was changed
}
}
@ -1506,10 +1500,10 @@ void P_LoadSectors (MapData *map, FMissingTextureTracker &missingtex)
{
ss->e = &sectors[0].e[i];
if (!map->HasBehavior) ss->Flags |= SECF_FLOORDROP;
ss->SetPlaneTexZ(sector_t::floor, LittleShort(ms->floorheight)<<FRACBITS);
ss->floorplane.set(0, 0, FRACUNIT, -ss->GetPlaneTexZ(sector_t::floor));
ss->SetPlaneTexZ(sector_t::ceiling, LittleShort(ms->ceilingheight)<<FRACBITS);
ss->ceilingplane.set(0, 0, -FRACUNIT, ss->GetPlaneTexZ(sector_t::ceiling));
ss->SetPlaneTexZ(sector_t::floor, (double)LittleShort(ms->floorheight));
ss->floorplane.set(0, 0, 1., -ss->GetPlaneTexZF(sector_t::floor));
ss->SetPlaneTexZ(sector_t::ceiling, (double)LittleShort(ms->ceilingheight));
ss->ceilingplane.set(0, 0, -1., ss->GetPlaneTexZF(sector_t::ceiling));
SetTexture(ss, i, sector_t::floor, ms->floorpic, missingtex, true);
SetTexture(ss, i, sector_t::ceiling, ms->ceilingpic, missingtex, true);
ss->lightlevel = LittleShort(ms->lightlevel);
@ -1525,12 +1519,12 @@ void P_LoadSectors (MapData *map, FMissingTextureTracker &missingtex)
ss->nextsec = -1; //jff 2/26/98 add fields to support locking out
ss->prevsec = -1; // stair retriggering until build completes
ss->SetAlpha(sector_t::floor, OPAQUE);
ss->SetAlpha(sector_t::ceiling, OPAQUE);
ss->SetXScale(sector_t::floor, FRACUNIT); // [RH] floor and ceiling scaling
ss->SetYScale(sector_t::floor, FRACUNIT);
ss->SetXScale(sector_t::ceiling, FRACUNIT);
ss->SetYScale(sector_t::ceiling, FRACUNIT);
ss->SetAlpha(sector_t::floor, 1.);
ss->SetAlpha(sector_t::ceiling, 1.);
ss->SetXScale(sector_t::floor, 1.); // [RH] floor and ceiling scaling
ss->SetYScale(sector_t::floor, 1.);
ss->SetXScale(sector_t::ceiling, 1.);
ss->SetYScale(sector_t::ceiling, 1.);
ss->heightsec = NULL; // sector used to get floor and ceiling height
// killough 3/7/98: end changes
@ -2011,8 +2005,8 @@ void P_FinishLoadingLineDef(line_t *ld, int alpha)
ld->frontsector = ld->sidedef[0] != NULL ? ld->sidedef[0]->sector : NULL;
ld->backsector = ld->sidedef[1] != NULL ? ld->sidedef[1]->sector : NULL;
double dx = FIXED2DBL(ld->v2->fixX() - ld->v1->fixX());
double dy = FIXED2DBL(ld->v2->fixY() - ld->v1->fixY());
double dx = (ld->v2->fX() - ld->v1->fX());
double dy = (ld->v2->fY() - ld->v1->fY());
int linenum = int(ld-lines);
if (ld->frontsector == NULL)
@ -2137,8 +2131,8 @@ void P_LoadLineDefs (MapData * map)
I_Error ("Line %d has invalid vertices: %d and/or %d.\nThe map only contains %d vertices.", i+skipped, v1, v2, numvertexes);
}
else if (v1 == v2 ||
(vertexes[LittleShort(mld->v1)].fixX() == vertexes[LittleShort(mld->v2)].fixX() &&
vertexes[LittleShort(mld->v1)].fixY() == vertexes[LittleShort(mld->v2)].fixY()))
(vertexes[LittleShort(mld->v1)].fX() == vertexes[LittleShort(mld->v2)].fX() &&
vertexes[LittleShort(mld->v1)].fY() == vertexes[LittleShort(mld->v2)].fY()))
{
Printf ("Removing 0-length line %d\n", i+skipped);
memmove (mld, mld+1, sizeof(*mld)*(numlines-i-1));
@ -2226,8 +2220,8 @@ void P_LoadLineDefs2 (MapData * map)
mld = ((maplinedef2_t*)mldf) + i;
if (mld->v1 == mld->v2 ||
(vertexes[LittleShort(mld->v1)].fixX() == vertexes[LittleShort(mld->v2)].fixX() &&
vertexes[LittleShort(mld->v1)].fixY() == vertexes[LittleShort(mld->v2)].fixY()))
(vertexes[LittleShort(mld->v1)].fX() == vertexes[LittleShort(mld->v2)].fX() &&
vertexes[LittleShort(mld->v1)].fY() == vertexes[LittleShort(mld->v2)].fY()))
{
Printf ("Removing 0-length line %d\n", i+skipped);
memmove (mld, mld+1, sizeof(*mld)*(numlines-i-1));
@ -2782,6 +2776,7 @@ static void P_CreateBlockMap ()
TArray<int> *BlockLists, *block, *endblock;
int adder;
int bmapwidth, bmapheight;
double dminx, dmaxx, dminy, dmaxy;
int minx, maxx, miny, maxy;
int i;
int line;
@ -2790,21 +2785,21 @@ static void P_CreateBlockMap ()
return;
// Find map extents for the blockmap
minx = maxx = vertexes[0].fixX();
miny = maxy = vertexes[0].fixY();
dminx = dmaxx = vertexes[0].fX();
dminy = dmaxy = vertexes[0].fY();
for (i = 1; i < numvertexes; ++i)
{
if (vertexes[i].fixX() < minx) minx = vertexes[i].fixX();
else if (vertexes[i].fixX() > maxx) maxx = vertexes[i].fixX();
if (vertexes[i].fixY() < miny) miny = vertexes[i].fixY();
else if (vertexes[i].fixY() > maxy) maxy = vertexes[i].fixY();
if (vertexes[i].fX() < dminx) dminx = vertexes[i].fX();
else if (vertexes[i].fX() > dmaxx) dmaxx = vertexes[i].fX();
if (vertexes[i].fY() < dminy) dminy = vertexes[i].fY();
else if (vertexes[i].fY() > dmaxy) dmaxy = vertexes[i].fY();
}
maxx >>= FRACBITS;
minx >>= FRACBITS;
maxy >>= FRACBITS;
miny >>= FRACBITS;
minx = int(dminx);
miny = int(dminy);
maxx = int(dmaxx);
maxy = int(dmaxy);
bmapwidth = ((maxx - minx) >> BLOCKBITS) + 1;
bmapheight = ((maxy - miny) >> BLOCKBITS) + 1;
@ -2820,10 +2815,10 @@ static void P_CreateBlockMap ()
for (line = 0; line < numlines; ++line)
{
int x1 = lines[line].v1->fixX() >> FRACBITS;
int y1 = lines[line].v1->fixY() >> FRACBITS;
int x2 = lines[line].v2->fixX() >> FRACBITS;
int y2 = lines[line].v2->fixY() >> FRACBITS;
int x1 = int(lines[line].v1->fX());
int y1 = int(lines[line].v1->fY());
int x2 = int(lines[line].v2->fX());
int y2 = int(lines[line].v2->fY());
int dx = x2 - x1;
int dy = y2 - y1;
int bx = (x1 - minx) >> BLOCKBITS;
@ -3225,8 +3220,8 @@ static void P_GroupLines (bool buildmap)
Triangle[1] = sector->lines[0]->v2;
if (sector->linecount > 1)
{
fixed_t dx = Triangle[1]->fixX() - Triangle[0]->fixX();
fixed_t dy = Triangle[1]->fixY() - Triangle[0]->fixY();
double dx = Triangle[1]->fX() - Triangle[0]->fX();
double dy = Triangle[1]->fY() - Triangle[0]->fY();
// Find another point in the sector that does not lie
// on the same line as the first two points.
for (j = 0; j < 2; ++j)
@ -3234,11 +3229,10 @@ static void P_GroupLines (bool buildmap)
vertex_t *v;
v = (j == 1) ? sector->lines[1]->v1 : sector->lines[1]->v2;
if (DMulScale32 (v->fixY() - Triangle[0]->fixY(), dx,
Triangle[0]->fixX() - v->fixX(), dy) != 0)
if ( (v->fY() - Triangle[0]->fY()) * dx + (Triangle[0]->fX() - v->fX() * dy) != 0)
{
sector->centerspot.X = FIXED2DBL(Triangle[0]->fixX() / 3 + Triangle[1]->fixX() / 3 + v->fixX() / 3);
sector->centerspot.Y = FIXED2DBL(Triangle[0]->fixY() / 3 + Triangle[1]->fixY() / 3 + v->fixY() / 3);
sector->centerspot.X = (Triangle[0]->fX() / 3 + Triangle[1]->fX() / 3 + v->fX() / 3);
sector->centerspot.Y = (Triangle[0]->fY() / 3 + Triangle[1]->fY() / 3 + v->fY() / 3);
break;
}
}
@ -4193,9 +4187,9 @@ CCMD (lineloc)
{
Printf ("No such line\n");
}
Printf ("(%d,%d) -> (%d,%d)\n", lines[linenum].v1->fixX() >> FRACBITS,
lines[linenum].v1->fixY() >> FRACBITS,
lines[linenum].v2->fixX() >> FRACBITS,
lines[linenum].v2->fixY() >> FRACBITS);
Printf ("(%f,%f) -> (%f,%f)\n", lines[linenum].v1->fX(),
lines[linenum].v1->fY(),
lines[linenum].v2->fX(),
lines[linenum].v2->fY());
}
#endif

View File

@ -642,10 +642,11 @@ bool SightCheck::P_SightPathTraverse ()
xt2 = x2 / MAPBLOCKUNITS;
yt2 = y2 / MAPBLOCKUNITS;
mapx = int(xt1);
mapy = int(yt1);
int mapex = int(xt2);
int mapey = int(yt2);
mapx = xs_FloorToInt(xt1);
mapy = xs_FloorToInt(yt1);
int mapex = xs_FloorToInt(xt2);
int mapey = xs_FloorToInt(yt2);
if (mapex > mapx)
{
@ -731,7 +732,7 @@ bool SightCheck::P_SightPathTraverse ()
if (res == -1 || (mapxstep | mapystep) == 0)
break;
switch (((int(yintercept) == mapy) << 1) | (int(xintercept) == mapx))
switch (((xs_FloorToInt(yintercept) == mapy) << 1) | (xs_FloorToInt(xintercept) == mapx))
{
case 0: // neither xintercept nor yintercept match!
sightcounts[5]++;
@ -872,7 +873,7 @@ sightcounts[0]++;
double lookheight = t1->Center();
t1->GetPortalTransition(lookheight, &sec);
double bottomslope = t2->Z() - (t1->Z() + lookheight);
double bottomslope = t2->Z() - lookheight;
double topslope = bottomslope + t2->Height;
SightTask task = { 0, topslope, bottomslope, -1, sec->PortalGroup };

View File

@ -860,8 +860,8 @@ static void SetupFloorPortal (AStackPoint *point)
if (skyv != NULL && skyv->bAlways)
{
skyv->Mate = point;
if (Sector->GetAlpha(sector_t::floor) == OPAQUE)
Sector->SetAlpha(sector_t::floor, Scale (point->args[0], OPAQUE, 255));
if (Sector->GetAlphaF(sector_t::floor) == 1.)
Sector->SetAlpha(sector_t::floor, clamp(point->args[0], 0, 255) / 255.);
}
}
@ -874,8 +874,8 @@ static void SetupCeilingPortal (AStackPoint *point)
if (skyv != NULL && skyv->bAlways)
{
skyv->Mate = point;
if (Sector->GetAlpha(sector_t::ceiling) == OPAQUE)
Sector->SetAlpha(sector_t::ceiling, Scale(point->args[0], OPAQUE, 255));
if (Sector->GetAlphaF(sector_t::ceiling) == 1.)
Sector->SetAlpha(sector_t::ceiling, clamp(point->args[0], 0, 255) / 255.);
}
}
@ -1148,7 +1148,7 @@ void P_InitSectorSpecial(sector_t *sector, int special, bool nothinkers)
break;
case dSector_DoorCloseIn30:
new DDoor(sector, DDoor::doorWaitClose, FRACUNIT * 2, 0, 0, 30 * TICRATE);
new DDoor(sector, DDoor::doorWaitClose, 2, 0, 0, 30 * TICRATE);
break;
case dDamage_End:
@ -1164,7 +1164,7 @@ void P_InitSectorSpecial(sector_t *sector, int special, bool nothinkers)
break;
case dSector_DoorRaiseIn5Mins:
new DDoor (sector, DDoor::doorWaitRaise, 2*FRACUNIT, TICRATE*30/7, 0, 5*60*TICRATE);
new DDoor (sector, DDoor::doorWaitRaise, 2, TICRATE*30/7, 0, 5*60*TICRATE);
break;
case dFriction_Low:

View File

@ -177,79 +177,17 @@ static int WriteVERTEXES (FILE *file)
static int WriteSEGS (FILE *file)
{
#if 0
mapseg_t ms;
ms.offset = 0; // unused by ZDoom, so just leave it 0
for (int i = 0; i < numsegs; ++i)
{
if (segs[i].linedef!=NULL)
{
ms.v1 = LittleShort(short(segs[i].v1 - vertexes));
ms.v2 = LittleShort(short(segs[i].v2 - vertexes));
ms.linedef = LittleShort(short(segs[i].linedef - lines));
ms.side = segs[i].sidedef == segs[i].linedef->sidedef[0] ? 0 : LittleShort((short)1);
ms.angle = LittleShort(short(R_PointToAngle2 (segs[i].v1->fixX(), segs[i].v1->fixY(), segs[i].v2->fixX(), segs[i].v2->fixY())>>16));
fwrite (&ms, sizeof(ms), 1, file);
}
}
return numsegs * sizeof(ms);
#else
return 0;
#endif
}
static int WriteSSECTORS (FILE *file)
{
#if 0
mapsubsector_t mss;
for (int i = 0; i < numsubsectors; ++i)
{
mss.firstseg = LittleShort((WORD)subsectors[i].firstline);
mss.numsegs = LittleShort((WORD)subsectors[i].numlines);
fwrite (&mss, sizeof(mss), 1, file);
}
return numsubsectors * sizeof(mss);
#else
return 0;
#endif
}
static int WriteNODES (FILE *file)
{
#if 0
mapnode_t mn;
for (int i = 0; i < numnodes; ++i)
{
mn.x = LittleShort(short(nodes[i].x >> FRACBITS));
mn.y = LittleShort(short(nodes[i].y >> FRACBITS));
mn.dx = LittleShort(short(nodes[i].dx >> FRACBITS));
mn.dy = LittleShort(short(nodes[i].dy >> FRACBITS));
for (int j = 0; j < 2; ++j)
{
for (int k = 0; k < 4; ++k)
{
mn.bbox[j][k] = LittleShort(short(nodes[i].bbox[j][k] >> FRACBITS));
}
WORD child;
if ((size_t)nodes[i].children[j] & 1)
{
child = mapnode_t::NF_SUBSECTOR | WORD((subsector_t *)((BYTE *)nodes[i].children[j] - 1) - subsectors);
}
else
{
child = WORD((node_t *)nodes[i].children[j] - nodes);
}
mn.children[j] = LittleShort(child);
}
fwrite (&mn, sizeof(mn), 1, file);
}
return numnodes * sizeof(mn);
#else
return 0;
#endif
}
static int WriteSECTORS (FILE *file)
@ -258,8 +196,8 @@ static int WriteSECTORS (FILE *file)
for (int i = 0; i < numsectors; ++i)
{
ms.floorheight = LittleShort(short(sectors[i].GetPlaneTexZ(sector_t::floor) >> FRACBITS));
ms.ceilingheight = LittleShort(short(sectors[i].GetPlaneTexZ(sector_t::ceiling) >> FRACBITS));
ms.floorheight = LittleShort(short(sectors[i].GetPlaneTexZF(sector_t::floor)));
ms.ceilingheight = LittleShort(short(sectors[i].GetPlaneTexZF(sector_t::ceiling)));
uppercopy (ms.floorpic, GetTextureName (sectors[i].GetTexture(sector_t::floor)));
uppercopy (ms.ceilingpic, GetTextureName (sectors[i].GetTexture(sector_t::ceiling)));
ms.lightlevel = LittleShort((short)sectors[i].lightlevel);

View File

@ -180,10 +180,10 @@ static int DoomSpecificInfo (char *buffer, char *end)
}
else
{
p += snprintf (buffer+p, size-p, "\n\nviewx = %d", (int)viewx);
p += snprintf (buffer+p, size-p, "\nviewy = %d", (int)viewy);
p += snprintf (buffer+p, size-p, "\nviewz = %d", (int)viewz);
p += snprintf (buffer+p, size-p, "\nviewangle = %x", (unsigned int)viewangle);
p += snprintf (buffer+p, size-p, "\n\nviewx = %f", ViewPos.X);
p += snprintf (buffer+p, size-p, "\nviewy = %f", ViewPos.Y);
p += snprintf (buffer+p, size-p, "\nviewz = %f", ViewPos.Z);
p += snprintf (buffer+p, size-p, "\nviewangle = %f", ViewAngle.Degrees);
}
}
buffer[p++] = '\n';

View File

@ -184,7 +184,7 @@ double I_GetTimeFrac (uint32 *ms)
if (ms) *ms = TicStart + (1000 / TICRATE);
if (TicStart == 0)
{
return FRACUNIT;
return 1;
}
else
{

View File

@ -52,12 +52,12 @@ void R_3D_AddHeight(secplane_t *add, sector_t *sec)
{
HeightLevel *near;
HeightLevel *curr;
fixed_t height;
height = add->ZatPoint(viewx, viewy);
if(height >= FLOAT2FIXED(sec->CenterCeiling())) return;
if(height <= FLOAT2FIXED(sec->CenterFloor())) return;
double fheight = add->ZatPoint(ViewPos);
if(fheight >= sec->CenterCeiling()) return;
if(fheight <= sec->CenterFloor()) return;
fixed_t height = FLOAT2FIXED(fheight);
fakeActive = 1;
if(height_max >= 0) {

View File

@ -49,7 +49,6 @@ enum
extern int fake3D;
extern F3DFloor *fakeFloor;
extern fixed_t fakeHeight;
extern fixed_t fakeAlpha;
extern int fakeActive;
extern fixed_t sclipBottom;

View File

@ -38,6 +38,7 @@
#include "p_lnspec.h"
#include "p_setup.h"
#include "r_local.h"
#include "r_main.h"
#include "r_plane.h"
#include "r_draw.h"
@ -394,8 +395,8 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec,
}
}
fixed_t refceilz = s->ceilingplane.ZatPoint (viewx, viewy);
fixed_t orgceilz = sec->ceilingplane.ZatPoint (viewx, viewy);
fixed_t refceilz = s->ceilingplane.ZatPointFixed (viewx, viewy);
fixed_t orgceilz = sec->ceilingplane.ZatPointFixed(viewx, viewy);
#if 1
// [RH] Allow viewing underwater areas through doors/windows that
@ -404,8 +405,8 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec,
// sectors at the same time.
if (back && !r_fakingunderwater && curline->frontsector->heightsec == NULL)
{
if (rw_frontcz1 <= s->floorplane.ZatPoint (curline->v1->fixX(), curline->v1->fixY()) &&
rw_frontcz2 <= s->floorplane.ZatPoint (curline->v2->fixX(), curline->v2->fixY()))
if (rw_frontcz1 <= s->floorplane.ZatPointFixed (curline->v1) &&
rw_frontcz2 <= s->floorplane.ZatPointFixed(curline->v2))
{
// Check that the window is actually visible
for (int z = WallC.sx1; z < WallC.sx2; ++z)
@ -555,7 +556,7 @@ void R_AddLine (seg_t *line)
// reject lines that aren't seen from the portal (if any)
// [ZZ] 10.01.2016: lines inside a skybox shouldn't be clipped, although this imposes some limitations on portals in skyboxes.
if (!CurrentPortalInSkybox && CurrentPortal && P_ClipLineToPortal(line->linedef, CurrentPortal->dst, DVector2(FIXED2DBL(viewx), FIXED2DBL(viewy))))
if (!CurrentPortalInSkybox && CurrentPortal && P_ClipLineToPortal(line->linedef, CurrentPortal->dst, ViewPos))
return;
vertex_t *v1, *v2;
@ -580,10 +581,10 @@ void R_AddLine (seg_t *line)
{
backsector = line->backsector;
}
rw_frontcz1 = frontsector->ceilingplane.ZatPoint (line->v1->fixX(), line->v1->fixY());
rw_frontfz1 = frontsector->floorplane.ZatPoint (line->v1->fixX(), line->v1->fixY());
rw_frontcz2 = frontsector->ceilingplane.ZatPoint (line->v2->fixX(), line->v2->fixY());
rw_frontfz2 = frontsector->floorplane.ZatPoint (line->v2->fixX(), line->v2->fixY());
rw_frontcz1 = frontsector->ceilingplane.ZatPointFixed(line->v1);
rw_frontfz1 = frontsector->floorplane.ZatPointFixed(line->v1);
rw_frontcz2 = frontsector->ceilingplane.ZatPointFixed(line->v2);
rw_frontfz2 = frontsector->floorplane.ZatPointFixed(line->v2);
rw_mustmarkfloor = rw_mustmarkceiling = false;
rw_havehigh = rw_havelow = false;
@ -602,10 +603,10 @@ void R_AddLine (seg_t *line)
}
doorclosed = 0; // killough 4/16/98
rw_backcz1 = backsector->ceilingplane.ZatPoint (line->v1->fixX(), line->v1->fixY());
rw_backfz1 = backsector->floorplane.ZatPoint (line->v1->fixX(), line->v1->fixY());
rw_backcz2 = backsector->ceilingplane.ZatPoint (line->v2->fixX(), line->v2->fixY());
rw_backfz2 = backsector->floorplane.ZatPoint (line->v2->fixX(), line->v2->fixY());
rw_backcz1 = backsector->ceilingplane.ZatPointFixed (line->v1);
rw_backfz1 = backsector->floorplane.ZatPointFixed(line->v1);
rw_backcz2 = backsector->ceilingplane.ZatPointFixed(line->v2);
rw_backfz2 = backsector->floorplane.ZatPointFixed(line->v2);
// Cannot make these walls solid, because it can result in
// sprite clipping problems for sprites near the wall
@ -1183,9 +1184,9 @@ void R_Subsector (subsector_t *sub)
fakeFloor->validcount = validcount;
R_3D_NewClip();
}
fakeHeight = FLOAT2FIXED(fakeFloor->top.plane->ZatPoint(frontsector->centerspot));
if (fakeHeight < viewz &&
fakeHeight > FLOAT2FIXED(frontsector->floorplane.ZatPoint(frontsector->centerspot)))
double fakeHeight = fakeFloor->top.plane->ZatPoint(frontsector->centerspot);
if (fakeHeight < ViewPos.Z &&
fakeHeight > frontsector->floorplane.ZatPoint(frontsector->centerspot))
{
fake3D = FAKE3D_FAKEFLOOR;
tempsec = *fakeFloor->model;
@ -1245,9 +1246,9 @@ void R_Subsector (subsector_t *sub)
fakeFloor->validcount = validcount;
R_3D_NewClip();
}
fakeHeight = FLOAT2FIXED(fakeFloor->bottom.plane->ZatPoint(frontsector->centerspot));
if (fakeHeight > viewz &&
fakeHeight < FLOAT2FIXED(frontsector->ceilingplane.ZatPoint(frontsector->centerspot)))
double fakeHeight = fakeFloor->bottom.plane->ZatPoint(frontsector->centerspot);
if (fakeHeight > ViewPos.Z &&
fakeHeight < frontsector->ceilingplane.ZatPoint(frontsector->centerspot))
{
fake3D = FAKE3D_FAKECEILING;
tempsec = *fakeFloor->model;

View File

@ -313,15 +313,6 @@ private:
fixed_t a, b, c, d, ic;
public:
void set(fixed_t aa, fixed_t bb, fixed_t cc, fixed_t dd)
{
a = aa;
b = bb;
c = cc;
d = dd;
ic = FixedDiv(FRACUNIT, c);
}
void set(double aa, double bb, double cc, double dd)
{
a = FLOAT2FIXED(aa);
@ -383,6 +374,12 @@ public:
return TMulScale16(a,x, b,y, c,z) + d;
}
int PointOnSide(const DVector3 &pos) const
{
double v = a * pos.X + b * pos.Y + c * pos.Z + d;
return v < -EQUAL_EPSILON ? -1 : v > EQUAL_EPSILON ? 1 : 0;
}
// Returns the value of z at (0,0) This is used by the 3D floor code which does not handle slopes
fixed_t Zat0 () const
{
@ -390,11 +387,25 @@ public:
}
// Returns the value of z at (x,y)
fixed_t ZatPoint (fixed_t x, fixed_t y) const
fixed_t ZatPoint(fixed_t x, fixed_t y) const = delete; // it is not allowed to call this.
fixed_t ZatPointFixed(fixed_t x, fixed_t y) const
{
return FixedMul (ic, -d - DMulScale16 (a, x, b, y));
}
// This is for the software renderer
fixed_t ZatPointFixed(const DVector2 &pos) const
{
return xs_CRoundToInt((d + a*pos.X + b*pos.Y) * ic / (-65536.0));
}
fixed_t ZatPointFixed(const vertex_t *v) const
{
return FixedMul(ic, -d - DMulScale16(a, v->fixX(), b, v->fixY()));
}
// Returns the value of z at (x,y) as a double
double ZatPoint (double x, double y) const
{
@ -406,6 +417,7 @@ public:
return (d + a*pos.X + b*pos.Y) * ic / (-65536.0 * 65536.0);
}
double ZatPoint(const vertex_t *v) const
{
return FIXED2DBL(FixedMul(ic, -d - DMulScale16(a, v->fixX(), b, v->fixY())));
@ -456,12 +468,6 @@ public:
return fD() - hdiff * fC();
}
// Returns how much this plane's height would change if d were set to oldd
fixed_t HeightDiff (fixed_t oldd) const
{
return FixedMul (oldd - d, ic);
}
// Returns how much this plane's height would change if d were set to oldd
double HeightDiff(double oldd) const
{
@ -474,16 +480,6 @@ public:
return (oldd - newd) * fiC();
}
fixed_t PointToDist (fixed_t x, fixed_t y, fixed_t z) const
{
return -TMulScale16 (a, x, y, b, z, c);
}
fixed_t PointToDist (const vertex_t *v, fixed_t z) const
{
return -TMulScale16 (a, v->fixX(), b, v->fixY(), z, c);
}
double PointToDist(const DVector2 &xy, double z) const
{
return -(a * xy.X + b * xy.Y + c * z) / 65536.;
@ -729,21 +725,11 @@ struct sector_t
splane planes[2];
void SetXOffset(int pos, fixed_t 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)
{
planes[pos].xform.xoffs += o;
}
void AddXOffset(int pos, double o)
{
planes[pos].xform.xoffs += FLOAT2FIXED(o);
@ -759,21 +745,11 @@ struct sector_t
return FIXED2DBL(planes[pos].xform.xoffs);
}
void SetYOffset(int pos, fixed_t 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)
{
planes[pos].xform.yoffs += o;
}
void AddYOffset(int pos, double o)
{
planes[pos].xform.yoffs += FLOAT2FIXED(o);
@ -803,11 +779,6 @@ struct sector_t
}
}
void SetXScale(int pos, fixed_t o)
{
planes[pos].xform.xscale = o;
}
void SetXScale(int pos, double o)
{
planes[pos].xform.xscale = FLOAT2FIXED(o);
@ -823,11 +794,6 @@ struct sector_t
return FIXED2DBL(planes[pos].xform.xscale);
}
void SetYScale(int pos, fixed_t o)
{
planes[pos].xform.yscale = o;
}
void SetYScale(int pos, double o)
{
planes[pos].xform.yscale = FLOAT2FIXED(o);
@ -843,11 +809,6 @@ struct sector_t
return FIXED2DBL(planes[pos].xform.yscale);
}
void SetAngle(int pos, angle_t o)
{
planes[pos].xform.angle = o;
}
void SetAngle(int pos, DAngle o)
{
planes[pos].xform.angle = o.BAMs();
@ -883,11 +844,6 @@ struct sector_t
planes[pos].xform.base_angle = o.BAMs();
}
void SetAlpha(int pos, fixed_t o)
{
planes[pos].alpha = o;
}
void SetAlpha(int pos, double o)
{
planes[pos].alpha = FLOAT2FIXED(o);
@ -946,34 +902,13 @@ struct sector_t
return FIXED2DBL(planes[pos].TexZ);
}
void SetVerticesDirty() {
for (unsigned i = 0; i < e->vertices.Size(); i++) e->vertices[i]->dirty = true;
}
void SetAllVerticesDirty()
{
SetVerticesDirty();
for (unsigned i = 0; i < e->FakeFloor.Sectors.Size(); i++) e->FakeFloor.Sectors[i]->SetVerticesDirty();
for (unsigned i = 0; i < e->XFloor.attached.Size(); i++) e->XFloor.attached[i]->SetVerticesDirty();
}
void SetPlaneTexZ(int pos, fixed_t val)
{
planes[pos].TexZ = val;
}
void SetPlaneTexZ(int pos, double val)
void SetPlaneTexZ(int pos, double val, bool dirtify = false) // This mainly gets used by init code. The only place where it must set the vertex to dirty is the interpolation code.
{
planes[pos].TexZ = FLOAT2FIXED(val);
if (dirtify) SetAllVerticesDirty();
}
void ChangePlaneTexZ(int pos, fixed_t val)
{
planes[pos].TexZ += val;
SetAllVerticesDirty();
}
void ChangePlaneTexZ(int pos, double val)
{
planes[pos].TexZ += FLOAT2FIXED(val);
@ -1071,6 +1006,18 @@ struct sector_t
return Displacements.getOffset(PortalGroup, SkyBoxes[sector_t::ceiling]->Sector->PortalGroup);
}
void SetVerticesDirty()
{
for (unsigned i = 0; i < e->vertices.Size(); i++) e->vertices[i]->dirty = true;
}
void SetAllVerticesDirty()
{
SetVerticesDirty();
for (unsigned i = 0; i < e->FakeFloor.Sectors.Size(); i++) e->FakeFloor.Sectors[i]->SetVerticesDirty();
for (unsigned i = 0; i < e->XFloor.attached.Size(); i++) e->XFloor.attached[i]->SetVerticesDirty();
}
int GetTerrain(int pos) const;
void TransferSpecial(sector_t *model);

View File

@ -68,6 +68,7 @@
#define TEST_ANGLE 2468347904
#endif
// TYPES -------------------------------------------------------------------
// EXTERNAL FUNCTION PROTOTYPES --------------------------------------------
@ -727,9 +728,8 @@ void R_EnterPortal (PortalDrawseg* pds, int depth)
viewx = FLOAT2FIXED((x1 + r * dx)*2 - x);
viewy = FLOAT2FIXED((y1 + r * dy)*2 - y);
}
viewangle = 2*R_PointToAngle2 (pds->src->v1->fixX(), pds->src->v1->fixY(),
pds->src->v2->fixX(), pds->src->v2->fixY()) - startang;
viewangle = pds->src->Delta().Angle().BAMs() - startang;
ViewAngle = AngleToFloat(viewangle);
}
else
{
@ -743,6 +743,7 @@ void R_EnterPortal (PortalDrawseg* pds, int depth)
viewz = FLOAT2FIXED(view.Z);
viewangle = va.BAMs();
}
ViewAngle = AngleToFloat(viewangle);
viewsin = finesine[viewangle>>ANGLETOFINESHIFT];
viewcos = finecosine[viewangle>>ANGLETOFINESHIFT];
@ -821,6 +822,7 @@ void R_EnterPortal (PortalDrawseg* pds, int depth)
viewx = startx;
viewy = starty;
viewz = startz;
ViewAngle = AngleToFloat(viewangle);
}
//==========================================================================

View File

@ -1082,6 +1082,7 @@ void R_DrawHeightPlanes(fixed_t height)
viewy = pl->viewy;
viewz = pl->viewz;
viewangle = pl->viewangle;
ViewAngle = AngleToFloat(viewangle);
MirrorFlags = pl->MirrorFlags;
R_DrawSinglePlane (pl, pl->sky & 0x7FFFFFFF, pl->Additive, true);
}
@ -1092,6 +1093,7 @@ void R_DrawHeightPlanes(fixed_t height)
viewy = oViewY;
viewz = oViewZ;
viewangle = oViewAngle;
ViewAngle = AngleToFloat(viewangle);
}
@ -1240,7 +1242,7 @@ void R_DrawSkyBoxes ()
viewx = FLOAT2FIXED(viewpos.X);
viewy = FLOAT2FIXED(viewpos.Y);
viewz = FLOAT2FIXED(viewpos.Z);
viewangle = savedangle + (sky->PrevAngles.Yaw + (sky->Angles.Yaw * r_TicFracF) - sky->PrevAngles.Yaw).BAMs();
viewangle = savedangle + (sky->PrevAngles.Yaw + deltaangle(sky->PrevAngles.Yaw, sky->Angles.Yaw) * r_TicFracF).BAMs();
R_CopyStackedViewParameters();
}
@ -1248,11 +1250,12 @@ void R_DrawSkyBoxes ()
{
extralight = pl->extralight;
R_SetVisibility (pl->visibility);
viewx = pl->viewx - FLOAT2FIXED(sky->Mate->X() + sky->X());
viewy = pl->viewy - FLOAT2FIXED(sky->Mate->Y() + sky->Y());
viewx = pl->viewx + FLOAT2FIXED(-sky->Mate->X() + sky->X());
viewy = pl->viewy + FLOAT2FIXED(-sky->Mate->Y() + sky->Y());
viewz = pl->viewz;
viewangle = pl->viewangle;
}
ViewAngle = AngleToFloat(viewangle);
sky->bInSkybox = true;
if (mate != NULL) mate->bInSkybox = true;
@ -1367,6 +1370,7 @@ void R_DrawSkyBoxes ()
R_SetVisibility (savedvisibility);
extralight = savedextralight;
viewangle = savedangle;
ViewAngle = AngleToFloat(viewangle);
R_SetViewAngle ();
CurrentPortalInSkybox = false;

View File

@ -274,7 +274,7 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2)
{
if (!(fake3D & FAKE3D_CLIPTOP))
{
sclipTop = sec->ceilingplane.ZatPoint(viewx, viewy);
sclipTop = sec->ceilingplane.ZatPointFixed(viewx, viewy);
}
for (i = frontsector->e->XFloor.lightlist.Size() - 1; i >= 0; i--)
{
@ -1385,10 +1385,10 @@ static void wallscan_np2_ds(drawseg_t *ds, int x1, int x2, short *uwal, short *d
{
if (rw_pic->GetHeight() != 1 << rw_pic->HeightBits)
{
fixed_t frontcz1 = ds->curline->frontsector->ceilingplane.ZatPoint(ds->curline->v1->fixX(), ds->curline->v1->fixY());
fixed_t frontfz1 = ds->curline->frontsector->floorplane.ZatPoint(ds->curline->v1->fixX(), ds->curline->v1->fixY());
fixed_t frontcz2 = ds->curline->frontsector->ceilingplane.ZatPoint(ds->curline->v2->fixX(), ds->curline->v2->fixY());
fixed_t frontfz2 = ds->curline->frontsector->floorplane.ZatPoint(ds->curline->v2->fixX(), ds->curline->v2->fixY());
fixed_t frontcz1 = ds->curline->frontsector->ceilingplane.ZatPointFixed(ds->curline->v1);
fixed_t frontfz1 = ds->curline->frontsector->floorplane.ZatPointFixed(ds->curline->v1);
fixed_t frontcz2 = ds->curline->frontsector->ceilingplane.ZatPointFixed(ds->curline->v2);
fixed_t frontfz2 = ds->curline->frontsector->floorplane.ZatPointFixed(ds->curline->v2);
fixed_t top = MAX(frontcz1, frontcz2);
fixed_t bot = MIN(frontfz1, frontfz2);
if (fake3D & FAKE3D_CLIPTOP)
@ -2783,7 +2783,7 @@ int WallMost (short *mostbuf, const secplane_t &plane, const FWallCoords *wallc)
x -= MulScale30 (frac, x - curline->v1->fixX());
y -= MulScale30 (frac, y - curline->v1->fixY());
}
z1 = viewz - plane.ZatPoint (x, y);
z1 = viewz - plane.ZatPointFixed(x, y);
if (wallc->sx2 > wallc->sx1 + 1)
{
@ -2795,7 +2795,7 @@ int WallMost (short *mostbuf, const secplane_t &plane, const FWallCoords *wallc)
x += MulScale30 (frac, curline->v2->fixX() - x);
y += MulScale30 (frac, curline->v2->fixY() - y);
}
z2 = viewz - plane.ZatPoint (x, y);
z2 = viewz - plane.ZatPointFixed(x, y);
}
else
{
@ -2812,7 +2812,7 @@ int WallMost (short *mostbuf, const secplane_t &plane, const FWallCoords *wallc)
x += MulScale30 (frac, curline->v2->fixX() - x);
y += MulScale30 (frac, curline->v2->fixY() - y);
}
z1 = viewz - plane.ZatPoint (x, y);
z1 = viewz - plane.ZatPointFixed(x, y);
if (wallc->sx2 > wallc->sx1 + 1)
{
@ -2824,7 +2824,7 @@ int WallMost (short *mostbuf, const secplane_t &plane, const FWallCoords *wallc)
x -= MulScale30 (frac, x - curline->v1->fixX());
y -= MulScale30 (frac, y - curline->v1->fixY());
}
z2 = viewz - plane.ZatPoint (x, y);
z2 = viewz - plane.ZatPointFixed(x, y);
}
else
{

View File

@ -78,9 +78,6 @@ extern int numgamesubsectors;
//
// POV data.
//
extern fixed_t viewz;
extern angle_t viewangle;
extern AActor* camera; // [RH] camera instead of viewplayer
extern sector_t* viewsector; // [RH] keep track of sector viewing from

View File

@ -802,7 +802,7 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor
{
// choose a different rotation based on player view
spriteframe_t *sprframe = &SpriteFrames[tex->Rotations];
angle_t ang = R_PointToAngle (fx, fy);
angle_t ang = R_PointToAngle2 (viewx, viewy, fx, fy);
angle_t rot;
if (sprframe->Texture[0] == sprframe->Texture[1])
{
@ -841,7 +841,7 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor
//picnum = SpriteFrames[sprdef->spriteframes + thing->frame].Texture[0];
// choose a different rotation based on player view
spriteframe_t *sprframe = &SpriteFrames[sprdef->spriteframes + thing->frame];
angle_t ang = R_PointToAngle (fx, fy);
angle_t ang = R_PointToAngle2 (viewx, viewy, fx, fy);
angle_t rot;
if (sprframe->Texture[0] == sprframe->Texture[1])
{
@ -937,19 +937,19 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor
{
if (fakeside == FAKED_AboveCeiling)
{
if (gzt < heightsec->ceilingplane.ZatPoint (fx, fy))
if (gzt < heightsec->ceilingplane.ZatPointFixed(fx, fy))
return;
}
else if (fakeside == FAKED_BelowFloor)
{
if (gzb >= heightsec->floorplane.ZatPoint (fx, fy))
if (gzb >= heightsec->floorplane.ZatPointFixed(fx, fy))
return;
}
else
{
if (gzt < heightsec->floorplane.ZatPoint (fx, fy))
if (gzt < heightsec->floorplane.ZatPointFixed(fx, fy))
return;
if (!(heightsec->MoreFlags & SECF_FAKEFLOORONLY) && gzb >= heightsec->ceilingplane.ZatPoint (fx, fy))
if (!(heightsec->MoreFlags & SECF_FAKEFLOORONLY) && gzb >= heightsec->ceilingplane.ZatPointFixed(fx, fy))
return;
}
}
@ -1931,7 +1931,7 @@ void R_DrawSprite (vissprite_t *spr)
{
if (!(fake3D & FAKE3D_CLIPTOP))
{
sclipTop = spr->sector->ceilingplane.ZatPoint(viewx, viewy);
sclipTop = spr->sector->ceilingplane.ZatPointFixed(viewx, viewy);
}
sector_t *sec = NULL;
for (i = spr->sector->e->XFloor.lightlist.Size() - 1; i >= 0; i--)
@ -2031,7 +2031,7 @@ void R_DrawSprite (vissprite_t *spr)
{ // only things in specially marked sectors
if (spr->FakeFlatStat != FAKED_AboveCeiling)
{
fixed_t hz = spr->heightsec->floorplane.ZatPoint (spr->gx, spr->gy);
fixed_t hz = spr->heightsec->floorplane.ZatPointFixed(spr->gx, spr->gy);
fixed_t h = (centeryfrac - FixedMul (hz-viewz, scale)) >> FRACBITS;
if (spr->FakeFlatStat == FAKED_BelowFloor)
@ -2053,7 +2053,7 @@ void R_DrawSprite (vissprite_t *spr)
}
if (spr->FakeFlatStat != FAKED_BelowFloor && !(spr->heightsec->MoreFlags & SECF_FAKEFLOORONLY))
{
fixed_t hz = spr->heightsec->ceilingplane.ZatPoint (spr->gx, spr->gy);
fixed_t hz = spr->heightsec->ceilingplane.ZatPointFixed(spr->gx, spr->gy);
fixed_t h = (centeryfrac - FixedMul (hz-viewz, scale)) >> FRACBITS;
if (spr->FakeFlatStat == FAKED_AboveCeiling)
@ -2423,12 +2423,12 @@ void R_ProjectParticle (particle_t *particle, const sector_t *sector, int shade,
BYTE* map;
// [ZZ] Particle not visible through the portal plane
if (CurrentPortal && !!P_PointOnLineSide(particle->x, particle->y, CurrentPortal->dst))
if (CurrentPortal && !!P_PointOnLineSide(particle->Pos, CurrentPortal->dst))
return;
// transform the origin point
tr_x = particle->x - viewx;
tr_y = particle->y - viewy;
tr_x = FLOAT2FIXED(particle->Pos.X - ViewPos.X);
tr_y = FLOAT2FIXED(particle->Pos.Y - ViewPos.Y);
tz = DMulScale20 (tr_x, viewtancos, tr_y, viewtansin);
@ -2460,8 +2460,8 @@ void R_ProjectParticle (particle_t *particle, const sector_t *sector, int shade,
if (x1 >= x2)
return;
yscale = MulScale16 (yaspectmul, xscale);
ty = particle->z - viewz;
yscale = MulScale16(yaspectmul, xscale);
ty = FLOAT2FIXED(particle->Pos.Z - ViewPos.Z);
psize <<= 4;
y1 = (centeryfrac - FixedMul (ty+psize, yscale)) >> FRACBITS;
y2 = (centeryfrac - FixedMul (ty-psize, yscale)) >> FRACBITS;
@ -2522,9 +2522,9 @@ void R_ProjectParticle (particle_t *particle, const sector_t *sector, int shade,
map = sector->ColorMap->Maps;
}
if (botpic != skyflatnum && particle->z < botplane->ZatPoint (particle->x, particle->y))
if (botpic != skyflatnum && particle->Pos.Z < botplane->ZatPoint (particle->Pos))
return;
if (toppic != skyflatnum && particle->z >= topplane->ZatPoint (particle->x, particle->y))
if (toppic != skyflatnum && particle->Pos.Z >= topplane->ZatPoint (particle->Pos))
return;
// store information in a vissprite
@ -2536,9 +2536,9 @@ void R_ProjectParticle (particle_t *particle, const sector_t *sector, int shade,
vis->yscale = xscale;
vis->depth = tz;
vis->idepth = (DWORD)DivScale32 (1, tz) >> 1;
vis->gx = particle->x;
vis->gy = particle->y;
vis->gz = particle->z; // kg3D
vis->gx = FLOAT2FIXED(particle->Pos.X);
vis->gy = FLOAT2FIXED(particle->Pos.Y);
vis->gz = FLOAT2FIXED(particle->Pos.Z);
vis->gzb = y1;
vis->gzt = y2;
vis->x1 = x1;

View File

@ -70,12 +70,15 @@ EXTERN_CVAR (Bool, cl_capfps)
struct InterpolationViewer
{
struct instance
{
DVector3 Pos;
DRotator Angles;
};
AActor *ViewActor;
int otic;
fixed_t oviewx, oviewy, oviewz;
fixed_t nviewx, nviewy, nviewz;
int oviewpitch, nviewpitch;
angle_t oviewangle, nviewangle;
instance Old, New;
};
// PRIVATE DATA DECLARATIONS -----------------------------------------------
@ -102,11 +105,9 @@ DCanvas *RenderTarget; // [RH] canvas to render to
int viewwindowx;
int viewwindowy;
fixed_t viewx;
fixed_t viewy;
fixed_t viewz;
int viewpitch;
angle_t viewangle;
DVector3 ViewPos;
DAngle ViewAngle;
DAngle ViewPitch;
extern "C"
{
@ -148,6 +149,10 @@ int FieldOfView = 2048; // Fineangles in the SCREENWIDTH wide window
FCanvasTextureInfo *FCanvasTextureInfo::List;
fixed_t viewx, viewy, viewz;
angle_t viewangle;
int viewpitch;
// CODE --------------------------------------------------------------------
static void R_Shutdown ();
@ -574,27 +579,20 @@ EXTERN_CVAR (Bool, cl_noprediction)
void R_InterpolateView (player_t *player, double Frac, InterpolationViewer *iview)
{
fixed_t frac = FLOAT2FIXED(Frac);
if (NoInterpolateView)
{
InterpolationPath.Clear();
NoInterpolateView = false;
iview->oviewx = iview->nviewx;
iview->oviewy = iview->nviewy;
iview->oviewz = iview->nviewz;
iview->oviewpitch = iview->nviewpitch;
iview->oviewangle = iview->nviewangle;
iview->Old = iview->New;
}
int oldgroup = R_PointInSubsector(iview->oviewx, iview->oviewy)->sector->PortalGroup;
int newgroup = R_PointInSubsector(iview->nviewx, iview->nviewy)->sector->PortalGroup;
int oldgroup = R_PointInSubsector(iview->Old.Pos)->sector->PortalGroup;
int newgroup = R_PointInSubsector(iview->New.Pos)->sector->PortalGroup;
fixed_t oviewangle = iview->oviewangle;
fixed_t nviewangle = iview->nviewangle;
if ((iview->oviewx != iview->nviewx || iview->oviewy != iview->nviewy) && InterpolationPath.Size() > 0)
DAngle oviewangle = iview->Old.Angles.Yaw;
DAngle nviewangle = iview->New.Angles.Yaw;
if ((iview->Old.Pos.X != iview->New.Pos.X || iview->Old.Pos.Y != iview->New.Pos.Y) && InterpolationPath.Size() > 0)
{
viewx = iview->nviewx;
viewy = iview->nviewy;
viewz = iview->nviewz;
DVector3 view = iview->New.Pos;
// Interpolating through line portals is a messy affair.
// What needs be done is to store the portal transitions of the camera actor as waypoints
@ -602,49 +600,47 @@ void R_InterpolateView (player_t *player, double Frac, InterpolationViewer *ivie
// Needless to say, this doesn't work for chasecam mode.
if (!r_showviewer)
{
fixed_t pathlen = 0;
fixed_t zdiff = 0;
fixed_t totalzdiff = 0;
angle_t adiff = 0;
angle_t totaladiff = 0;
fixed_t oviewz = iview->oviewz;
fixed_t nviewz = iview->nviewz;
DVector3a oldpos = { {FIXED2DBL(iview->oviewx), FIXED2DBL(iview->oviewy), 0.}, 0. };
DVector3a newpos = { {FIXED2DBL(iview->nviewx), FIXED2DBL(iview->nviewy), 0. }, 0. };
double pathlen = 0;
double zdiff = 0;
double totalzdiff = 0;
DAngle adiff = 0.;
DAngle totaladiff = 0.;
double oviewz = iview->Old.Pos.Z;
double nviewz = iview->New.Pos.Z;
DVector3a oldpos = { { iview->Old.Pos.X, iview->Old.Pos.Y, 0 }, 0. };
DVector3a newpos = { { iview->New.Pos.X, iview->New.Pos.Y, 0 }, 0. };
InterpolationPath.Push(newpos); // add this to the array to simplify the loops below
for (unsigned i = 0; i < InterpolationPath.Size(); i += 2)
{
DVector3a &start = i == 0 ? oldpos : InterpolationPath[i - 1];
DVector3a &end = InterpolationPath[i];
pathlen += FLOAT2FIXED((end.pos-start.pos).Length());
totalzdiff += FLOAT2FIXED(start.pos.Z);
totaladiff += start.angle.BAMs();
pathlen += (end.pos-start.pos).Length();
totalzdiff += start.pos.Z;
totaladiff += start.angle;
}
fixed_t interpolatedlen = FixedMul(frac, pathlen);
double interpolatedlen = Frac * pathlen;
for (unsigned i = 0; i < InterpolationPath.Size(); i += 2)
{
DVector3a &start = i == 0 ? oldpos : InterpolationPath[i - 1];
DVector3a &end = InterpolationPath[i];
fixed_t fraglen = FLOAT2FIXED((end.pos - start.pos).Length());
zdiff += FLOAT2FIXED(start.pos.Z);
adiff += start.angle.BAMs();
double fraglen = (end.pos - start.pos).Length();
zdiff += start.pos.Z;
adiff += start.angle;
if (fraglen <= interpolatedlen)
{
interpolatedlen -= fraglen;
}
else
{
double fragfrac = FIXED2DBL(FixedDiv(interpolatedlen, fraglen));
double fragfrac = interpolatedlen / fraglen;
oviewz += zdiff;
nviewz -= totalzdiff - zdiff;
oviewangle += adiff;
nviewangle -= totaladiff - adiff;
DVector2 viewpos = start.pos + (fragfrac * (end.pos - start.pos));
viewx = FLOAT2FIXED(viewpos.X);
viewy = FLOAT2FIXED(viewpos.Y);
viewz = oviewz + FixedMul(frac, nviewz - oviewz);
ViewPos = { viewpos, oviewz + Frac * (nviewz - oviewz) };
break;
}
}
@ -654,17 +650,15 @@ void R_InterpolateView (player_t *player, double Frac, InterpolationViewer *ivie
else
{
DVector2 disp = Displacements.getOffset(oldgroup, newgroup);
viewx = iview->oviewx + FixedMul(frac, iview->nviewx - iview->oviewx - FLOAT2FIXED(disp.X));
viewy = iview->oviewy + FixedMul(frac, iview->nviewy - iview->oviewy - FLOAT2FIXED(disp.Y));
viewz = iview->oviewz + FixedMul(frac, iview->nviewz - iview->oviewz);
ViewPos = iview->Old.Pos + (iview->New.Pos - iview->Old.Pos - disp) * Frac;
}
if (player != NULL &&
!(player->cheats & CF_INTERPVIEW) &&
player - players == consoleplayer &&
camera == player->mo &&
!demoplayback &&
iview->nviewx == camera->_f_X() &&
iview->nviewy == camera->_f_Y() &&
iview->New.Pos.X == camera->X() &&
iview->New.Pos.Y == camera->Y() &&
!(player->cheats & (CF_TOTALLYFROZEN|CF_FROZEN)) &&
player->playerstate == PST_LIVE &&
player->mo->reactiontime == 0 &&
@ -673,53 +667,26 @@ void R_InterpolateView (player_t *player, double Frac, InterpolationViewer *ivie
(!netgame || !cl_noprediction) &&
!LocalKeyboardTurner)
{
viewangle = nviewangle + (LocalViewAngle & 0xFFFF0000);
fixed_t delta = player->centering ? 0 : -(signed)(LocalViewPitch & 0xFFFF0000);
viewpitch = iview->nviewpitch;
if (delta > 0)
{
// Avoid overflowing viewpitch (can happen when a netgame is stalled)
if (viewpitch > INT_MAX - delta)
{
viewpitch = player->MaxPitch.BAMs();
}
else
{
viewpitch = MIN<int>(viewpitch + delta, player->MaxPitch.BAMs());
}
}
else if (delta < 0)
{
// Avoid overflowing viewpitch (can happen when a netgame is stalled)
if (viewpitch < INT_MIN - delta)
{
viewpitch = player->MinPitch.BAMs();
}
else
{
viewpitch = MAX<int>(viewpitch + delta, player->MinPitch.BAMs());
}
}
ViewAngle = (nviewangle + AngleToFloat(LocalViewAngle & 0xFFFF0000)).Normalized180();
DAngle delta = player->centering ? DAngle(0.) : AngleToFloat(int(LocalViewPitch & 0xFFFF0000));
ViewPitch = clamp<DAngle>((iview->New.Angles.Pitch - delta).Normalized180(), player->MinPitch, player->MaxPitch);
}
else
{
viewpitch = iview->oviewpitch + FixedMul (frac, iview->nviewpitch - iview->oviewpitch);
viewangle = oviewangle + FixedMul (frac, nviewangle - oviewangle);
ViewPitch = (iview->Old.Angles.Pitch + deltaangle(iview->Old.Angles.Pitch, iview->New.Angles.Pitch) * Frac).Normalized180();
ViewAngle = (oviewangle + deltaangle(oviewangle, nviewangle) * Frac).Normalized180();
}
// Due to interpolation this is not necessarily the same as the sector the camera is in.
viewsector = R_PointInSubsector(viewx, viewy)->sector;
viewsector = R_PointInSubsector(ViewPos)->sector;
bool moved = false;
while (!viewsector->PortalBlocksMovement(sector_t::ceiling))
{
AActor *point = viewsector->SkyBoxes[sector_t::ceiling];
if (viewz > FLOAT2FIXED(point->specialf1))
if (ViewPos.Z > point->specialf1)
{
viewx += FLOAT2FIXED(point->Scale.X);
viewy += FLOAT2FIXED(point->Scale.Y);
viewsector = R_PointInSubsector(viewx, viewy)->sector;
ViewPos += point->Scale;
viewsector = R_PointInSubsector(ViewPos)->sector;
moved = true;
}
else break;
@ -729,11 +696,10 @@ void R_InterpolateView (player_t *player, double Frac, InterpolationViewer *ivie
while (!viewsector->PortalBlocksMovement(sector_t::floor))
{
AActor *point = viewsector->SkyBoxes[sector_t::floor];
if (viewz < FLOAT2FIXED(point->specialf1))
if (ViewPos.Z < point->specialf1)
{
viewx += FLOAT2FIXED(point->Scale.X);
viewy += FLOAT2FIXED(point->Scale.Y);
viewsector = R_PointInSubsector(viewx, viewy)->sector;
ViewPos += point->Scale;
viewsector = R_PointInSubsector(ViewPos)->sector;
moved = true;
}
else break;
@ -761,10 +727,8 @@ void R_ResetViewInterpolation ()
void R_SetViewAngle ()
{
angle_t ang = viewangle >> ANGLETOFINESHIFT;
viewsin = finesine[ang];
viewcos = finecosine[ang];
viewsin = FLOAT2FIXED(ViewAngle.Sin());
viewcos = FLOAT2FIXED(ViewAngle.Cos());
viewtansin = FixedMul (FocalTangent, viewsin);
viewtancos = FixedMul (FocalTangent, viewcos);
@ -787,7 +751,8 @@ static InterpolationViewer *FindPastViewer (AActor *actor)
}
// Not found, so make a new one
InterpolationViewer iview = { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
InterpolationViewer iview;
memset(&iview, 0, sizeof(iview));
iview.ViewActor = actor;
iview.otic = -1;
InterpolationPath.Clear();
@ -851,11 +816,7 @@ void R_RebuildViewInterpolation(player_t *player)
InterpolationViewer *iview = FindPastViewer(player->camera);
iview->oviewx = iview->nviewx;
iview->oviewy = iview->nviewy;
iview->oviewz = iview->nviewz;
iview->oviewpitch = iview->nviewpitch;
iview->oviewangle = iview->nviewangle;
iview->Old = iview->New;
InterpolationPath.Clear();
}
@ -955,52 +916,39 @@ void R_SetupFrame (AActor *actor)
if (iview->otic != -1 && nowtic > iview->otic)
{
iview->otic = nowtic;
iview->oviewx = iview->nviewx;
iview->oviewy = iview->nviewy;
iview->oviewz = iview->nviewz;
iview->oviewpitch = iview->nviewpitch;
iview->oviewangle = iview->nviewangle;
iview->Old = iview->New;
}
if (player != NULL && gamestate != GS_TITLELEVEL &&
((player->cheats & CF_CHASECAM) || (r_deathcamera && camera->health <= 0)))
{
sector_t *oldsector = R_PointInSubsector(iview->oviewx, iview->oviewy)->sector;
sector_t *oldsector = R_PointInSubsector(iview->Old.Pos)->sector;
// [RH] Use chasecam view
DVector3 campos;
P_AimCamera (camera, campos, viewsector, unlinked);
iview->nviewx = FLOAT2FIXED(campos.X);
iview->nviewy = FLOAT2FIXED(campos.Y);
iview->nviewz = FLOAT2FIXED(campos.Z);
P_AimCamera (camera, campos, viewsector, unlinked); // fixme: This needs to translate the angle, too.
iview->New.Pos = campos;
r_showviewer = true;
// Interpolating this is a very complicated thing because nothing keeps track of the aim camera's movement, so whenever we detect a portal transition
// it's probably best to just reset the interpolation for this move.
// Note that this can still cause problems with unusually linked portals
if (viewsector->PortalGroup != oldsector->PortalGroup || (unlinked && P_AproxDistance(iview->oviewx - iview->nviewx, iview->oviewy - iview->nviewy) > 256 * FRACUNIT))
if (viewsector->PortalGroup != oldsector->PortalGroup || (unlinked && ((iview->New.Pos.XY() - iview->Old.Pos.XY()).LengthSquared()) > 256*256))
{
iview->otic = nowtic;
iview->oviewx = iview->nviewx;
iview->oviewy = iview->nviewy;
iview->oviewz = iview->nviewz;
iview->oviewpitch = iview->nviewpitch;
iview->oviewangle = iview->nviewangle;
iview->Old = iview->New;
}
}
else
{
iview->nviewx = camera->_f_X();
iview->nviewy = camera->_f_Y();
iview->nviewz = FLOAT2FIXED(camera->player ? camera->player->viewz : camera->Z() + camera->GetCameraHeight());
iview->New.Pos = { camera->Pos().XY(), camera->player ? camera->player->viewz : camera->Z() + camera->GetCameraHeight() };
viewsector = camera->Sector;
r_showviewer = false;
}
iview->nviewpitch = camera->Angles.Pitch.BAMs();
iview->New.Angles = camera->Angles;
if (camera->player != 0)
{
player = camera->player;
}
iview->nviewangle = camera->Angles.Yaw.BAMs();
if (iview->otic == -1 || r_NoInterpolate)
{
R_ResetViewInterpolation ();
@ -1014,13 +962,6 @@ void R_SetupFrame (AActor *actor)
}
R_InterpolateView (player, r_TicFracF, iview);
#ifdef TEST_X
viewx = TEST_X;
viewy = TEST_Y;
viewz = TEST_Z;
viewangle = TEST_ANGLE;
#endif
R_SetViewAngle ();
interpolator.DoInterpolations (r_TicFracF);
@ -1028,19 +969,19 @@ void R_SetupFrame (AActor *actor)
// Keep the view within the sector's floor and ceiling
if (viewsector->PortalBlocksMovement(sector_t::ceiling))
{
fixed_t theZ = viewsector->ceilingplane.ZatPoint(viewx, viewy) - 4 * FRACUNIT;
if (viewz > theZ)
double theZ = viewsector->ceilingplane.ZatPoint(ViewPos) - 4;
if (ViewPos.Z > theZ)
{
viewz = theZ;
ViewPos.Z = theZ;
}
}
if (viewsector->PortalBlocksMovement(sector_t::floor))
{
fixed_t theZ = viewsector->floorplane.ZatPoint(viewx, viewy) + 4 * FRACUNIT;
if (viewz < theZ)
double theZ = viewsector->floorplane.ZatPoint(ViewPos) + 4;
if (ViewPos.Z < theZ)
{
viewz = theZ;
ViewPos.Z = theZ;
}
}
@ -1058,32 +999,30 @@ void R_SetupFrame (AActor *actor)
{
an = camera->Angles.Yaw;
double power = QuakePower(quakefactor, jiggers.RelIntensity.X, jiggers.RelOffset.X, jiggers.Falloff, jiggers.WFalloff);
viewx += FLOAT2FIXED(an.Cos() * power);
viewy += FLOAT2FIXED(an.Sin() * power);
ViewPos += an.ToVector(power);
}
if (jiggers.RelIntensity.Y != 0 || jiggers.RelOffset.Y != 0)
{
an = camera->Angles.Yaw + 90;
double power = QuakePower(quakefactor, jiggers.RelIntensity.Y, jiggers.RelOffset.Y, jiggers.Falloff, jiggers.WFalloff);
viewx += FLOAT2FIXED(an.Cos() * power);
viewy += FLOAT2FIXED(an.Sin() * power);
ViewPos += an.ToVector(power);
}
// FIXME: Relative Z is not relative
if (jiggers.RelIntensity.Z != 0 || jiggers.RelOffset.Z != 0)
{
viewz += FLOAT2FIXED(QuakePower(quakefactor, jiggers.RelIntensity.Z, jiggers.RelOffset.Z, jiggers.Falloff, jiggers.WFalloff));
ViewPos.Z += QuakePower(quakefactor, jiggers.RelIntensity.Z, jiggers.RelOffset.Z, jiggers.Falloff, jiggers.WFalloff);
}
if (jiggers.Intensity.X != 0 || jiggers.Offset.X != 0)
{
viewx += FLOAT2FIXED(QuakePower(quakefactor, jiggers.Intensity.X, jiggers.Offset.X, jiggers.Falloff, jiggers.WFalloff));
ViewPos.X += QuakePower(quakefactor, jiggers.Intensity.X, jiggers.Offset.X, jiggers.Falloff, jiggers.WFalloff);
}
if (jiggers.Intensity.Y != 0 || jiggers.Offset.Y != 0)
{
viewy += FLOAT2FIXED(QuakePower(quakefactor, jiggers.Intensity.Y, jiggers.Offset.Y, jiggers.Falloff, jiggers.WFalloff));
ViewPos.Y += QuakePower(quakefactor, jiggers.Intensity.Y, jiggers.Offset.Y, jiggers.Falloff, jiggers.WFalloff);
}
if (jiggers.Intensity.Z != 0 || jiggers.Offset.Z != 0)
{
viewz += FLOAT2FIXED(QuakePower(quakefactor, jiggers.Intensity.Z, jiggers.Offset.Z, jiggers.Falloff, jiggers.WFalloff));
ViewPos.Z += QuakePower(quakefactor, jiggers.Intensity.Z, jiggers.Offset.Z, jiggers.Falloff, jiggers.WFalloff);
}
}
}
@ -1102,7 +1041,7 @@ void R_SetupFrame (AActor *actor)
secplane_t *plane;
int viewside;
plane = (i < lightlist.Size()-1) ? &lightlist[i+1].plane : &viewsector->floorplane;
viewside = plane->PointOnSide(viewx, viewy, viewz);
viewside = plane->PointOnSide(ViewPos);
// Reverse the direction of the test if the plane was downward facing.
// We want to know if the view is above it, whatever its orientation may be.
if (plane->fC() < 0)
@ -1124,9 +1063,9 @@ void R_SetupFrame (AActor *actor)
const sector_t *s = viewsector->GetHeightSec();
if (s != NULL)
{
newblend = s->floorplane.PointOnSide(viewx, viewy, viewz) < 0
newblend = s->floorplane.PointOnSide(ViewPos) < 0
? s->bottommap
: s->ceilingplane.PointOnSide(viewx, viewy, viewz) < 0
: s->ceilingplane.PointOnSide(ViewPos) < 0
? s->topmap
: s->midmap;
if (APART(newblend) == 0 && newblend >= numfakecmaps)
@ -1156,6 +1095,12 @@ void R_SetupFrame (AActor *actor)
}
}
viewx = FLOAT2FIXED(ViewPos.X);
viewy = FLOAT2FIXED(ViewPos.Y);
viewz = FLOAT2FIXED(ViewPos.Z);
viewangle = ViewAngle.BAMs();
viewpitch = ViewPitch.BAMs();
Renderer->CopyStackedViewParameters();
Renderer->SetupFrame(player);

View File

@ -2,6 +2,7 @@
#define __R_UTIL_H
#include "r_state.h"
#include "vectors.h"
//
// Stuff from r_main.h that's needed outside the rendering code.
@ -11,10 +12,13 @@
extern DCanvas *RenderTarget;
extern fixed_t viewx;
extern fixed_t viewy;
extern fixed_t viewz;
extern int viewpitch;
extern DVector3 ViewPos;
extern DAngle ViewAngle;
extern DAngle ViewPitch;
extern fixed_t viewx, viewy, viewz;
extern angle_t viewangle;
extern int viewpitch;
extern "C" int centerx, centerxwide;
extern "C" int centery;
@ -65,7 +69,6 @@ inline int R_PointOnSide(const DVector2 &pos, const node_t *node)
}
angle_t R_PointToAngle2 (fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2);
inline angle_t R_PointToAngle (fixed_t x, fixed_t y) { return R_PointToAngle2 (viewx, viewy, x, y); }
inline angle_t R_PointToAnglePrecise (fixed_t viewx, fixed_t viewy, fixed_t x, fixed_t y)
{
return xs_RoundToUInt(g_atan2(double(y-viewy), double(x-viewx)) * (ANGLE_180/M_PI));

View File

@ -722,7 +722,7 @@ static int WI_DrawCharPatch (FFont *font, int charcode, int x, int y, EColorRang
int width;
screen->DrawTexture(font->GetChar(charcode, &width), x, y,
nomove ? DTA_CleanNoMove : DTA_Clean, true,
DTA_ShadowAlpha, (gameinfo.gametype & GAME_DoomChex) ? 0 : FRACUNIT/2,
DTA_ShadowAlpha, (gameinfo.gametype & GAME_DoomChex) ? 0 : OPAQUE/2,
DTA_Translation, font->GetColorTranslation(translation),
TAG_DONE);
return x - width;

View File

@ -1080,10 +1080,10 @@ void DoomSpecificInfo (char *buffer, size_t bufflen)
}
else
{
buffer += mysnprintf (buffer, buffend - buffer, "\r\n\r\nviewx = %d", viewx);
buffer += mysnprintf (buffer, buffend - buffer, "\r\nviewy = %d", viewy);
buffer += mysnprintf (buffer, buffend - buffer, "\r\nviewz = %d", viewz);
buffer += mysnprintf (buffer, buffend - buffer, "\r\nviewangle = %x", viewangle);
buffer += mysnprintf (buffer, buffend - buffer, "\r\n\r\nviewx = %f", ViewPos.X);
buffer += mysnprintf (buffer, buffend - buffer, "\r\nviewy = %f", ViewPos.Y);
buffer += mysnprintf (buffer, buffend - buffer, "\r\nviewz = %f", ViewPos.Z);
buffer += mysnprintf (buffer, buffend - buffer, "\r\nviewangle = %f", ViewAngle);
}
}
*buffer++ = '\r';