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

# Conflicts:
#	src/r_data/r_interpolate.cpp
This commit is contained in:
Christoph Oelckers 2016-03-30 18:24:22 +02:00
commit 251172c7f0
71 changed files with 1213 additions and 1298 deletions

View file

@ -850,11 +850,7 @@ public:
return VecToAngle(otherpos - Pos().XY());
}
DAngle AngleTo(AActor *other, fixed_t oxofs, fixed_t oyofs, bool absolute = false) const
{
fixedvec3 otherpos = absolute ? other->_f_Pos() : other->_f_PosRelative(this);
return VecToAngle(otherpos.x + oxofs - _f_X(), otherpos.y + oyofs - _f_Y());
}
DAngle AngleTo(AActor *other, fixed_t oxofs, fixed_t oyofs, bool absolute = false) const = delete;
DAngle AngleTo(AActor *other, double oxofs, double oyofs, bool absolute = false) const
{
@ -1008,12 +1004,6 @@ public:
double Speed;
double FloatSpeed;
// intentionally stange names so that searching for them is easier.
angle_t _f_angle() { return FLOAT2ANGLE(Angles.Yaw.Degrees); }
int _f_pitch() { return FLOAT2ANGLE(Angles.Pitch.Degrees); }
fixed_t _f_speed() { return FLOAT2FIXED(Speed); }
WORD sprite; // used to find patch_t and flip value
BYTE frame; // sprite frame to draw
DVector2 Scale; // Scaling values; 1 is normal size
@ -1305,16 +1295,11 @@ public:
{
return Z() < checkz - Z_Epsilon;
}
bool isAtZ(double checkz)
bool isAtZ(double checkz) const
{
return fabs(Z() - checkz) < Z_Epsilon;
}
fixedvec3 _f_PosRelative(int grp) const;
fixedvec3 _f_PosRelative(const AActor *other) const;
fixedvec3 _f_PosRelative(sector_t *sec) const;
fixedvec3 _f_PosRelative(line_t *line) const;
DVector3 PosRelative(int grp) const;
DVector3 PosRelative(const AActor *other) const;
DVector3 PosRelative(sector_t *sec) const;

View file

@ -2533,8 +2533,8 @@ void AM_rotate(double *xp, double *yp, DAngle a)
if (angle_saved != a)
{
angle_saved = a;
sinrot = sin(ToRadians(a));
cosrot = cos(ToRadians(a));
sinrot = sin(a.Radians());
cosrot = cos(a.Radians());
}
double x = *xp;

View file

@ -34,13 +34,13 @@ bool DBot::Reachable (AActor *rtarget)
if (player->mo == rtarget)
return false;
if ((rtarget->Sector->ceilingplane.ZatPointF (rtarget) -
rtarget->Sector->floorplane.ZatPointF (rtarget))
if ((rtarget->Sector->ceilingplane.ZatPoint (rtarget) -
rtarget->Sector->floorplane.ZatPoint (rtarget))
< player->mo->Height) //Where rtarget is, player->mo can't be.
return false;
sector_t *last_s = player->mo->Sector;
double last_z = last_s->floorplane.ZatPointF (player->mo);
double last_z = last_s->floorplane.ZatPoint (player->mo);
double estimated_dist = player->mo->Distance2D(rtarget);
bool reachable = true;
@ -100,7 +100,7 @@ bool DBot::Reachable (AActor *rtarget)
thing = in->d.thing;
if (thing == player->mo) //Can't reach self in this case.
continue;
if (thing == rtarget && (rtarget->Sector->floorplane.ZatPointF (rtarget) <= (last_z+MAXMOVEHEIGHT)))
if (thing == rtarget && (rtarget->Sector->floorplane.ZatPoint (rtarget) <= (last_z+MAXMOVEHEIGHT)))
{
return true;
}

View file

@ -350,7 +350,7 @@ void DBot::Pitch (AActor *target)
diff = target->Z() - player->mo->Z();
aim = g_atan(diff / player->mo->Distance2D(target));
player->mo->Angles.Pitch = ToDegrees(aim);
player->mo->Angles.Pitch = DAngle::ToDegrees(aim);
}
//Checks if a sector is dangerous.

View file

@ -1244,9 +1244,9 @@ CCMD(angleconvtest)
Printf("Testing degrees to angle conversion:\n");
for (double ang = -5 * 180.; ang < 5 * 180.; ang += 45.)
{
angle_t ang1 = FLOAT2ANGLE(ang);
angle_t ang2 = (angle_t)(ang * (ANGLE_90 / 90.));
angle_t ang3 = (angle_t)(int)(ang * (ANGLE_90 / 90.));
unsigned ang1 = DAngle(ang).BAMs();
unsigned ang2 = (unsigned)(ang * (0x40000000 / 90.));
unsigned ang3 = (unsigned)(int)(ang * (0x40000000 / 90.));
Printf("Angle = %.5f: xs_RoundToInt = %08x, unsigned cast = %08x, signed cast = %08x\n",
ang, ang1, ang2, ang3);
}

View file

@ -290,7 +290,7 @@ void ParseCompatibility()
sc.MustGetNumber();
CompatParams.Push(sc.Number);
sc.MustGetFloat();
CompatParams.Push(FLOAT2FIXED(sc.Float));
CompatParams.Push(int(sc.Float*65536.));
}
else if (sc.Compare("setwallyscale"))
{
@ -303,7 +303,7 @@ void ParseCompatibility()
sc.MustGetString();
CompatParams.Push(sc.MustMatchString(WallTiers));
sc.MustGetFloat();
CompatParams.Push(FLOAT2FIXED(sc.Float));
CompatParams.Push(int(sc.Float*65536.));
}
else if (sc.Compare("setthingz"))
{
@ -522,7 +522,7 @@ void SetCompatibilityParams()
{
sector_t *sec = &sectors[CompatParams[i+1]];
sec->floorplane.ChangeHeight(CompatParams[i+2]);
sec->ChangePlaneTexZ(sector_t::floor, CompatParams[i+2]);
sec->ChangePlaneTexZ(sector_t::floor, CompatParams[i+2] / 65536.);
}
i += 3;
break;
@ -534,7 +534,7 @@ void SetCompatibilityParams()
side_t *side = lines[CompatParams[i+1]].sidedef[CompatParams[i+2]];
if (side != NULL)
{
side->SetTextureYScale(CompatParams[i+3], CompatParams[i+4]);
side->SetTextureYScale(CompatParams[i+3], CompatParams[i+4] / 65536.);
}
}
i += 5;

View file

@ -878,33 +878,6 @@ void D_ReadUserInfoStrings (int pnum, BYTE **stream, bool update)
*stream += strlen (*((char **)stream)) + 1;
}
void ReadCompatibleUserInfo(FArchive &arc, userinfo_t &info)
{
char netname[MAXPLAYERNAME + 1];
BYTE team;
int aimdist, color, colorset, skin, gender;
bool neverswitch;
//fxed_t movebob, stillbob; These were never serialized!
//int playerclass; "
info.Reset();
arc.Read(&netname, sizeof(netname));
arc << team << aimdist << color << skin << gender << neverswitch << colorset;
*static_cast<FStringCVar *>(info[NAME_Name]) = netname;
*static_cast<FIntCVar *>(info[NAME_Team]) = team;
*static_cast<FFloatCVar *>(info[NAME_Autoaim]) = ANGLE2FLOAT(aimdist);
*static_cast<FIntCVar *>(info[NAME_Skin]) = skin;
*static_cast<FIntCVar *>(info[NAME_Gender]) = gender;
*static_cast<FBoolCVar *>(info[NAME_NeverSwitchOnPickup]) = neverswitch;
*static_cast<FIntCVar *>(info[NAME_ColorSet]) = colorset;
UCVarValue val;
val.Int = color;
static_cast<FColorCVar *>(info[NAME_Color])->SetGenericRep(val, CVAR_Int);
}
void WriteUserInfo(FArchive &arc, userinfo_t &info)
{
TMapIterator<FName, FBaseCVar *> it(info);
@ -945,12 +918,6 @@ void ReadUserInfo(FArchive &arc, userinfo_t &info, FString &skin)
char *str = NULL;
UCVarValue val;
if (SaveVersion < 4253)
{
ReadCompatibleUserInfo(arc, info);
return;
}
info.Reset();
skin = NULL;
for (arc << name; name != NAME_None; arc << name)

View file

@ -390,7 +390,12 @@ bool PType::VisitedNodeSet::Check(const PType *node)
void PType::SetValue(void *addr, int val)
{
assert(0 && "Cannot set value for this type");
assert(0 && "Cannot set int value for this type");
}
void PType::SetValue(void *addr, double val)
{
assert(0 && "Cannot set float value for this type");
}
//==========================================================================
@ -405,6 +410,12 @@ int PType::GetValueInt(void *addr) const
return 0;
}
double PType::GetValueFloat(void *addr) const
{
assert(0 && "Cannot get value for this type");
return 0;
}
//==========================================================================
//
// PType :: GetStoreOp
@ -674,6 +685,11 @@ void PInt::SetValue(void *addr, int val)
}
}
void PInt::SetValue(void *addr, double val)
{
SetValue(addr, (int)val);
}
//==========================================================================
//
// PInt :: GetValueInt
@ -706,6 +722,17 @@ int PInt::GetValueInt(void *addr) const
}
}
//==========================================================================
//
// PInt :: GetValueFloat
//
//==========================================================================
double PInt::GetValueFloat(void *addr) const
{
return GetValueInt(addr);
}
//==========================================================================
//
// PInt :: GetStoreOp
@ -919,6 +946,11 @@ void PFloat::SetSymbols(const PFloat::SymbolInitI *sym, size_t count)
//==========================================================================
void PFloat::SetValue(void *addr, int val)
{
return SetValue(addr, (double)val);
}
void PFloat::SetValue(void *addr, double val)
{
assert(((intptr_t)addr & (Align - 1)) == 0 && "unaligned address");
if (Size == 4)
@ -939,16 +971,27 @@ void PFloat::SetValue(void *addr, int val)
//==========================================================================
int PFloat::GetValueInt(void *addr) const
{
return xs_ToInt(GetValueFloat(addr));
}
//==========================================================================
//
// PFloat :: GetValueFloat
//
//==========================================================================
double PFloat::GetValueFloat(void *addr) const
{
assert(((intptr_t)addr & (Align - 1)) == 0 && "unaligned address");
if (Size == 4)
{
return xs_ToInt(*(float *)addr);
return *(float *)addr;
}
else
{
assert(Size == 8);
return xs_ToInt(*(double *)addr);
return *(double *)addr;
}
}
@ -2273,22 +2316,23 @@ PClass *PClass::CreateDerivedClass(FName name, unsigned int size)
//==========================================================================
//
// PClass:: Extend
// PClass :: Extend
//
// Add <extension> bytes to the end of this class. Returns the previous
// size of the class.
// Add <extension> bytes to the end of this class and possibly more to meet
// alignment restrictions. Returns the start of the extended block.
//
//==========================================================================
unsigned int PClass::Extend(unsigned int extension)
unsigned int PClass::Extend(unsigned int extension, unsigned int alignment)
{
assert(this->bRuntimeClass);
unsigned int oldsize = Size;
Size += extension;
unsigned int padto = (oldsize + alignment - 1) & ~(alignment - 1);
Size = padto + extension;
Defaults = (BYTE *)M_Realloc(Defaults, Size);
memset(Defaults + oldsize, 0, extension);
return oldsize;
memset(Defaults + oldsize, 0, Size - oldsize);
return padto;
}
//==========================================================================

View file

@ -188,9 +188,11 @@ public:
// Sets the value of a variable of this type at (addr)
virtual void SetValue(void *addr, int val);
virtual void SetValue(void *addr, double val);
// Gets the value of a variable of this type at (addr)
virtual int GetValueInt(void *addr) const;
virtual double GetValueFloat(void *addr) const;
// Gets the opcode to store from a register to memory
virtual int GetStoreOp() const;
@ -320,7 +322,9 @@ public:
PInt(unsigned int size, bool unsign);
virtual void SetValue(void *addr, int val);
virtual void SetValue(void *addr, double val);
virtual int GetValueInt(void *addr) const;
virtual double GetValueFloat(void *addr) const;
virtual int GetStoreOp() const;
virtual int GetLoadOp() const;
virtual int GetRegType() const;
@ -344,7 +348,9 @@ public:
PFloat(unsigned int size);
virtual void SetValue(void *addr, int val);
virtual void SetValue(void *addr, double val);
virtual int GetValueInt(void *addr) const;
virtual double GetValueFloat(void *addr) const;
virtual int GetStoreOp() const;
virtual int GetLoadOp() const;
virtual int GetRegType() const;
@ -633,7 +639,8 @@ public:
void InsertIntoHash();
DObject *CreateNew() const;
PClass *CreateDerivedClass(FName name, unsigned int size);
unsigned int Extend(unsigned int extension);
unsigned int Extend(unsigned int extension, unsigned int alignment);
unsigned int Extend(const PType *type) { return Extend(type->Size, type->Align); }
void InitializeActorInfo();
void BuildFlatPointers();
const PClass *NativeClass() const;

View file

@ -435,10 +435,6 @@ struct FPlayerStart
angle(mthing->angle),
type(pnum)
{ }
fixed_t _f_X() { return FLOAT2FIXED(pos.X); }
fixed_t _f_Y() { return FLOAT2FIXED(pos.Y); }
fixed_t _f_Z() { return FLOAT2FIXED(pos.Z); }
};
// Player spawn spots for deathmatch.
extern TArray<FPlayerStart> deathmatchstarts;

View file

@ -133,7 +133,7 @@ DMovingCeiling::DMovingCeiling (sector_t *sector)
interpolation = sector->SetInterpolation(sector_t::CeilingMove, true);
}
bool DMover::MoveAttached(int crush, fixed_t move, int floorOrCeiling, bool resetfailed)
bool DMover::MoveAttached(int crush, double move, int floorOrCeiling, bool resetfailed)
{
if (!P_Scroll3dMidtex(m_Sector, crush, move, !!floorOrCeiling) && resetfailed)
{
@ -155,20 +155,20 @@ bool DMover::MoveAttached(int crush, fixed_t move, int floorOrCeiling, bool rese
// (Use -1 to prevent it from trying to crush)
// dest is the desired d value for the plane
//
DMover::EResult DMover::MovePlane (fixed_t speed, fixed_t dest, int crush,
DMover::EResult DMover::MovePlane (double speed, double dest, int crush,
int floorOrCeiling, int direction, bool hexencrush)
{
bool flag;
fixed_t lastpos;
fixed_t movedest;
fixed_t move;
//fixed_t destheight; //jff 02/04/98 used to keep floors/ceilings
double lastpos;
double movedest;
double move;
//double destheight; //jff 02/04/98 used to keep floors/ceilings
// from moving thru each other
switch (floorOrCeiling)
{
case 0:
// FLOOR
lastpos = m_Sector->floorplane.fixD();
lastpos = m_Sector->floorplane.fD();
switch (direction)
{
case -1:
@ -223,9 +223,9 @@ DMover::EResult DMover::MovePlane (fixed_t speed, fixed_t dest, int crush,
// [RH] not so easy with arbitrary planes
//destheight = (dest < m_Sector->ceilingheight) ? dest : m_Sector->ceilingheight;
if (!m_Sector->ceilingplane.isSlope() && !m_Sector->floorplane.isSlope() &&
(!(i_compatflags2 & COMPATF2_FLOORMOVE) && -dest > m_Sector->ceilingplane.fixD()))
(!(i_compatflags2 & COMPATF2_FLOORMOVE) && -dest > m_Sector->ceilingplane.fD()))
{
dest = -m_Sector->ceilingplane.fixD();
dest = -m_Sector->ceilingplane.fD();
}
movedest = m_Sector->floorplane.GetChangedHeight (speed);
@ -282,7 +282,7 @@ DMover::EResult DMover::MovePlane (fixed_t speed, fixed_t dest, int crush,
case 1:
// CEILING
lastpos = m_Sector->ceilingplane.fixD();
lastpos = m_Sector->ceilingplane.fD();
switch (direction)
{
case -1:
@ -291,9 +291,9 @@ DMover::EResult DMover::MovePlane (fixed_t speed, fixed_t dest, int crush,
// [RH] not so easy with arbitrary planes
//destheight = (dest > m_Sector->floorheight) ? dest : m_Sector->floorheight;
if (!m_Sector->ceilingplane.isSlope() && !m_Sector->floorplane.isSlope() &&
(!(i_compatflags2 & COMPATF2_FLOORMOVE) && dest < -m_Sector->floorplane.fixD()))
(!(i_compatflags2 & COMPATF2_FLOORMOVE) && dest < -m_Sector->floorplane.fD()))
{
dest = -m_Sector->floorplane.fixD();
dest = -m_Sector->floorplane.fD();
}
movedest = m_Sector->ceilingplane.GetChangedHeight (-speed);
if (movedest <= dest)

View file

@ -30,26 +30,26 @@ protected:
enum EResult { ok, crushed, pastdest };
TObjPtr<DInterpolation> interpolation;
private:
bool MoveAttached(int crush, fixed_t move, int floorOrCeiling, bool resetfailed);
EResult MovePlane (fixed_t speed, fixed_t dest, int crush, int floorOrCeiling, int direction, bool hexencrush);
bool MoveAttached(int crush, double move, int floorOrCeiling, bool resetfailed);
EResult MovePlane (double speed, double dest, int crush, int floorOrCeiling, int direction, bool hexencrush);
protected:
DMover ();
void Serialize (FArchive &arc);
void Destroy();
void StopInterpolation(bool force = false);
inline EResult MoveFloor (fixed_t speed, fixed_t dest, int crush, int direction, bool hexencrush)
inline EResult MoveFloor (double speed, double dest, int crush, int direction, bool hexencrush)
{
return MovePlane (speed, dest, crush, 0, direction, hexencrush);
}
inline EResult MoveFloor (fixed_t speed, fixed_t dest, int direction)
inline EResult MoveFloor (double speed, double dest, int direction)
{
return MovePlane (speed, dest, -1, 0, direction, false);
}
inline EResult MoveCeiling (fixed_t speed, fixed_t dest, int crush, int direction, bool hexencrush)
inline EResult MoveCeiling (double speed, double dest, int crush, int direction, bool hexencrush)
{
return MovePlane (speed, dest, crush, 1, direction, hexencrush);
}
inline EResult MoveCeiling (fixed_t speed, fixed_t dest, int direction)
inline EResult MoveCeiling (double speed, double dest, int direction)
{
return MovePlane (speed, dest, -1, 1, direction, false);
}

View file

@ -105,7 +105,7 @@ struct EDLinedef
int tag;
int id;
int args[5];
fixed_t alpha;
double alpha;
DWORD flags;
DWORD activation;
};
@ -158,7 +158,7 @@ static void parseLinedef(FScanner &sc)
bool argsset = false;
memset(&ld, 0, sizeof(ld));
ld.alpha = FRACUNIT;
ld.alpha = 1.;
sc.MustGetStringName("{");
while (!sc.CheckString("}"))
@ -216,7 +216,7 @@ static void parseLinedef(FScanner &sc)
{
sc.CheckString("=");
sc.MustGetFloat();
ld.alpha = FLOAT2FIXED(sc.Float);
ld.alpha = sc.Float;
}
else if (sc.Compare("extflags"))
{
@ -703,7 +703,7 @@ void ProcessEDLinedef(line_t *ld, int recordnum)
ld->special = eld->special;
ld->activation = eld->activation;
ld->flags = (ld->flags&~fmask) | eld->flags;
ld->Alpha = eld->alpha;
ld->setAlpha(eld->alpha);
memcpy(ld->args, eld->args, sizeof(ld->args));
tagManager.AddLineID(int(ld - lines), eld->tag);
}

View file

@ -269,12 +269,13 @@ bool wipe_doBurn (int ticks)
}
// Draw the screen
fixed_t xstep, ystep, firex, firey;
int xstep, ystep, firex, firey;
int x, y;
BYTE *to, *fromold, *fromnew;
const int SHIFT = 16;
xstep = (FIREWIDTH * FRACUNIT) / SCREENWIDTH;
ystep = (FIREHEIGHT * FRACUNIT) / SCREENHEIGHT;
xstep = (FIREWIDTH << SHIFT) / SCREENWIDTH;
ystep = (FIREHEIGHT << SHIFT) / SCREENHEIGHT;
to = screen->GetBuffer();
fromold = (BYTE *)wipe_scr_start;
fromnew = (BYTE *)wipe_scr_end;
@ -285,7 +286,7 @@ bool wipe_doBurn (int ticks)
{
int fglevel;
fglevel = burnarray[(firex>>FRACBITS)+(firey>>FRACBITS)*FIREWIDTH] / 2;
fglevel = burnarray[(firex>>SHIFT)+(firey>>SHIFT)*FIREWIDTH] / 2;
if (fglevel >= 63)
{
to[x] = fromnew[x];
@ -340,7 +341,7 @@ bool wipe_doFade (int ticks)
else
{
int x, y;
fixed_t bglevel = 64 - fade;
int bglevel = 64 - fade;
DWORD *fg2rgb = Col2RGB8[fade];
DWORD *bg2rgb = Col2RGB8[bglevel];
BYTE *fromnew = (BYTE *)wipe_scr_end;

View file

@ -1537,16 +1537,13 @@ void FParser::SF_StartSectorSound(void)
/************* Sector functions ***************/
//DMover::EResult P_MoveFloor (sector_t * m_Sector, fixed_t speed, fixed_t dest, int crush, int direction, int flags=0);
//DMover::EResult P_MoveCeiling (sector_t * m_Sector, fixed_t speed, fixed_t dest, int crush, int direction, int flags=0);
class DFloorChanger : public DFloor
{
public:
DFloorChanger(sector_t * sec)
: DFloor(sec) {}
bool Move(fixed_t speed, fixed_t dest, int crush, int direction)
bool Move(double speed, double dest, int crush, int direction)
{
bool res = DMover::crushed != MoveFloor(speed, dest, crush, direction, false);
Destroy();
@ -1569,8 +1566,8 @@ void FParser::SF_FloorHeight(void)
{
int tagnum;
int secnum;
fixed_t dest;
int returnval = 1; // haleyjd: SoM's fixes
double dest;
double returnval = 1; // haleyjd: SoM's fixes
if (CheckArgs(1))
{
@ -1582,7 +1579,7 @@ void FParser::SF_FloorHeight(void)
int crush = (t_argc >= 3) ? intvalue(t_argv[2]) : false;
i = -1;
dest = fixedvalue(t_argv[1]);
dest = floatvalue(t_argv[1]);
// set all sectors with tag
@ -1593,8 +1590,8 @@ void FParser::SF_FloorHeight(void)
DFloorChanger * f = new DFloorChanger(&sectors[i]);
if (!f->Move(
abs(dest - sectors[i].CenterFloor()),
sectors[i].floorplane.PointToDist (sectors[i]._f_centerspot(), dest),
fabs(dest - sectors[i].CenterFloor()),
sectors[i].floorplane.PointToDist (sectors[i].centerspot, dest),
crush? 10:-1,
(dest > sectors[i].CenterFloor()) ? 1 : -1))
{
@ -1610,13 +1607,11 @@ void FParser::SF_FloorHeight(void)
script_error("sector not found with tagnum %i\n", tagnum);
return;
}
returnval = sectors[secnum].CenterFloor() >> FRACBITS;
returnval = sectors[secnum].CenterFloor();
}
// return floor height
t_return.type = svt_int;
t_return.value.i = returnval;
t_return.setDouble(returnval);
}
}
@ -1628,7 +1623,7 @@ void FParser::SF_FloorHeight(void)
class DMoveFloor : public DFloor
{
public:
DMoveFloor(sector_t * sec,int moveheight,int _m_Direction,int crush,int movespeed)
DMoveFloor(sector_t * sec,double moveheight,int _m_Direction,int crush,double movespeed)
: DFloor(sec)
{
m_Type = floorRaiseByValue;
@ -1638,7 +1633,7 @@ public:
m_FloorDestDist = moveheight;
// Do not interpolate instant movement floors.
fixed_t movedist = abs(-sec->floorplane.fixD() - moveheight);
double movedist = fabs(-sec->floorplane.fD() - moveheight);
if (m_Speed >= movedist)
{
StopInterpolation(true);
@ -1660,13 +1655,14 @@ void FParser::SF_MoveFloor(void)
{
int secnum = -1;
sector_t *sec;
int tagnum, platspeed = 1, destheight, crush;
int tagnum, crush;
double platspeed = 1, destheight;
if (CheckArgs(2))
{
tagnum = intvalue(t_argv[0]);
destheight = intvalue(t_argv[1]) * FRACUNIT;
platspeed = t_argc > 2 ? fixedvalue(t_argv[2]) : FRACUNIT;
destheight = intvalue(t_argv[1]);
platspeed = t_argc > 2 ? floatvalue(t_argv[2]) : 1.;
crush = (t_argc > 3 ? intvalue(t_argv[3]) : -1);
// move all sectors with tag
@ -1678,8 +1674,8 @@ void FParser::SF_MoveFloor(void)
// Don't start a second thinker on the same floor
if (sec->floordata) continue;
new DMoveFloor(sec,sec->floorplane.PointToDist(sec->_f_centerspot(),destheight),
destheight < sec->CenterFloor() ? -1:1,crush,platspeed);
new DMoveFloor(sec, sec->floorplane.PointToDist(sec->centerspot, destheight),
destheight < sec->CenterFloor() ? -1 : 1, crush, platspeed);
}
}
}
@ -1696,7 +1692,7 @@ public:
DCeilingChanger(sector_t * sec)
: DCeiling(sec) {}
bool Move(fixed_t speed, fixed_t dest, int crush, int direction)
bool Move(double speed, double dest, int crush, int direction)
{
bool res = DMover::crushed != MoveCeiling(speed, dest, crush, direction, false);
Destroy();
@ -1716,10 +1712,10 @@ public:
// ceiling height of sector
void FParser::SF_CeilingHeight(void)
{
fixed_t dest;
double dest;
int secnum;
int tagnum;
int returnval = 1;
double returnval = 1;
if (CheckArgs(1))
{
@ -1731,7 +1727,7 @@ void FParser::SF_CeilingHeight(void)
int crush = (t_argc >= 3) ? intvalue(t_argv[2]) : false;
i = -1;
dest = fixedvalue(t_argv[1]);
dest = floatvalue(t_argv[1]);
// set all sectors with tag
FSSectorTagIterator itr(tagnum);
@ -1741,8 +1737,8 @@ void FParser::SF_CeilingHeight(void)
DCeilingChanger * c = new DCeilingChanger(&sectors[i]);
if (!c->Move(
abs(dest - sectors[i].CenterCeiling()),
sectors[i].ceilingplane.PointToDist (sectors[i]._f_centerspot(), dest),
fabs(dest - sectors[i].CenterCeiling()),
sectors[i].ceilingplane.PointToDist (sectors[i].centerspot, dest),
crush? 10:-1,
(dest > sectors[i].CenterCeiling()) ? 1 : -1))
{
@ -1758,12 +1754,11 @@ void FParser::SF_CeilingHeight(void)
script_error("sector not found with tagnum %i\n", tagnum);
return;
}
returnval = sectors[secnum].CenterCeiling() >> FRACBITS;
returnval = sectors[secnum].CenterCeiling();
}
// return ceiling height
t_return.type = svt_int;
t_return.value.i = returnval;
t_return.setDouble(returnval);
}
}
@ -1778,7 +1773,7 @@ class DMoveCeiling : public DCeiling
{
public:
DMoveCeiling(sector_t * sec,int tag,fixed_t destheight,fixed_t speed,int silent,int crush)
DMoveCeiling(sector_t * sec,int tag,double destheight,double speed,int silent,int crush)
: DCeiling(sec)
{
m_Crush = crush;
@ -1786,11 +1781,11 @@ public:
m_Silent = silent;
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->_f_centerspot(),destheight);
m_TopHeight=m_BottomHeight=sec->ceilingplane.PointToDist(sec->centerspot,destheight);
m_Direction=destheight>sec->GetPlaneTexZ(sector_t::ceiling)? 1:-1;
// Do not interpolate instant movement ceilings.
fixed_t movedist = abs(sec->ceilingplane.fixD() - m_BottomHeight);
double movedist = fabs(sec->ceilingplane.fD() - m_BottomHeight);
if (m_Speed >= movedist)
{
StopInterpolation (true);
@ -1811,15 +1806,16 @@ void FParser::SF_MoveCeiling(void)
{
int secnum = -1;
sector_t *sec;
int tagnum, platspeed = 1, destheight;
int tagnum;
double platspeed = 1, destheight;
int crush;
int silent;
if (CheckArgs(2))
{
tagnum = intvalue(t_argv[0]);
destheight = intvalue(t_argv[1]) * FRACUNIT;
platspeed = /*FLOORSPEED **/ (t_argc > 2 ? fixedvalue(t_argv[2]) : FRACUNIT);
destheight = intvalue(t_argv[1]);
platspeed = /*FLOORSPEED **/ (t_argc > 2 ? floatvalue(t_argv[2]) : 1);
crush=t_argc>3 ? intvalue(t_argv[3]):-1;
silent=t_argc>4 ? intvalue(t_argv[4]):1;

View file

@ -1065,9 +1065,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_SkullRodStorm)
return 0;
}
if (self->bouncecount >= 0 && (unsigned)self->bouncecount < self->Sector->e->XFloor.ffloors.Size())
pos.Z = self->Sector->e->XFloor.ffloors[self->bouncecount]->bottom.plane->ZatPointF(mo);
pos.Z = self->Sector->e->XFloor.ffloors[self->bouncecount]->bottom.plane->ZatPoint(mo);
else
pos.Z = self->Sector->ceilingplane.ZatPointF(mo);
pos.Z = self->Sector->ceilingplane.ZatPoint(mo);
int moceiling = P_Find3DFloor(NULL, pos, false, false, pos.Z);
if (moceiling >= 0) mo->SetZ(pos.Z - mo->Height);
mo->Translation = multiplayer ? TRANSLATION(TRANSLATION_RainPillar,self->special2) : 0;
@ -1120,7 +1120,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_HideInCeiling)
F3DFloor * rover = self->Sector->e->XFloor.ffloors[i];
if (!(rover->flags & FF_SOLID) || !(rover->flags & FF_EXISTS)) continue;
if ((foo = rover->bottom.plane->ZatPointF(self)) >= self->Top())
if ((foo = rover->bottom.plane->ZatPoint(self)) >= self->Top())
{
self->SetZ(foo + 4, false);
self->bouncecount = i;

View file

@ -306,7 +306,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CheckTerrain)
sector_t *sec = self->Sector;
if (self->Z() == sec->floorplane.ZatPointF(self) && sec->PortalBlocksMovement(sector_t::floor))
if (self->Z() == sec->floorplane.ZatPoint(self) && sec->PortalBlocksMovement(sector_t::floor))
{
if (sec->special == Damage_InstantDeath)
{

View file

@ -95,14 +95,14 @@ DEFINE_ACTION_FUNCTION(AActor, A_LightGoesOut)
AActor *foo;
sector_t *sec = self->Sector;
vertex_t *spot;
fixed_t newheight;
double newheight;
sec->SetLightLevel(0);
fixed_t oldtheight = sec->floorplane.Zat0();
double oldtheight = sec->floorplane.fD();
newheight = sec->FindLowestFloorSurrounding(&spot);
sec->floorplane.setD(sec->floorplane.PointToDist (spot, newheight));
fixed_t newtheight = sec->floorplane.Zat0();
double newtheight = sec->floorplane.fD();
sec->ChangePlaneTexZ(sector_t::floor, newtheight - oldtheight);
sec->CheckPortalPlane(sector_t::floor);

View file

@ -136,17 +136,30 @@ inline SDWORD ModDiv (SDWORD num, SDWORD den, SDWORD *dmval)
return num % den;
}
inline fixed_t FloatToFixed(double f)
{
return xs_Fix<16>::ToFix(f);
}
#define FLOAT2FIXED(f) ((fixed_t)xs_Fix<16>::ToFix(f))
#define FIXED2FLOAT(f) ((f) / float(65536))
#define FIXED2DBL(f) ((f) / double(65536))
inline double FixedToFloat(fixed_t f)
{
return f / 65536.;
}
#define ANGLE2DBL(f) ((f) * (90./ANGLE_90))
#define ANGLE2FLOAT(f) (float((f) * (90./ANGLE_90)))
#define FLOAT2ANGLE(f) ((angle_t)xs_CRoundToInt((f) * (ANGLE_90/90.)))
inline unsigned FloatToAngle(double f)
{
return xs_CRoundToInt((f)* (0x40000000 / 90.));
}
#define ANGLE2RAD(f) ((f) * (M_PI/ANGLE_180))
#define ANGLE2RADF(f) ((f) * float(M_PI/ANGLE_180))
#define RAD2ANGLE(f) ((angle_t)xs_CRoundToInt((f) * (ANGLE_180/M_PI)))
inline double AngleToFloat(unsigned f)
{
return f * (90. / 0x40000000);
}
#define FLOAT2FIXED(f) FloatToFixed(f)
#define FIXED2FLOAT(f) float(FixedToFloat(f))
#define FIXED2DBL(f) FixedToFloat(f)
#define ANGLE2DBL(f) AngleToFloat(f)
#endif

View file

@ -331,13 +331,13 @@ void P_PlayerOnSpecial3DFloor(player_t* player)
if(rover->flags & FF_SOLID)
{
// Player must be on top of the floor to be affected...
if(player->mo->Z() != rover->top.plane->ZatPointF(player->mo)) continue;
if(player->mo->Z() != rover->top.plane->ZatPoint(player->mo)) continue;
}
else
{
//Water and DEATH FOG!!! heh
if (player->mo->Z() > rover->top.plane->ZatPointF(player->mo) ||
player->mo->Top() < rover->bottom.plane->ZatPointF(player->mo))
if (player->mo->Z() > rover->top.plane->ZatPoint(player->mo) ||
player->mo->Top() < rover->bottom.plane->ZatPoint(player->mo))
continue;
}
@ -368,7 +368,7 @@ bool P_CheckFor3DFloorHit(AActor * mo)
if(rover->flags & FF_SOLID && rover->model->SecActTarget)
{
if(mo->Z() == rover->top.plane->ZatPointF(mo))
if(mo->Z() == rover->top.plane->ZatPoint(mo))
{
rover->model->SecActTarget->TriggerAction (mo, SECSPAC_HitFloor);
return true;
@ -394,7 +394,7 @@ bool P_CheckFor3DCeilingHit(AActor * mo)
if(rover->flags & FF_SOLID && rover->model->SecActTarget)
{
if(mo->Top() == rover->bottom.plane->ZatPointF(mo))
if(mo->Top() == rover->bottom.plane->ZatPoint(mo))
{
rover->model->SecActTarget->TriggerAction (mo, SECSPAC_HitCeiling);
return true;

View file

@ -51,7 +51,7 @@
//
//============================================================================
bool P_Scroll3dMidtex(sector_t *sector, int crush, fixed_t move, bool ceiling)
bool P_Scroll3dMidtex(sector_t *sector, int crush, double move, bool ceiling)
{
extsector_t::midtex::plane &scrollplane = ceiling? sector->e->Midtex.Ceiling : sector->e->Midtex.Floor;

View file

@ -9,14 +9,14 @@ struct sector_t;
struct line_t;
class AActor;
bool P_Scroll3dMidtex(sector_t *sector, int crush, fixed_t move, bool ceiling);
bool P_Scroll3dMidtex(sector_t *sector, int crush, double move, bool ceiling);
void P_Start3dMidtexInterpolations(TArray<DInterpolation *> &list, sector_t *sec, bool ceiling);
void P_Attach3dMidtexLinesToSector(sector_t *dest, int lineid, int tag, bool ceiling);
bool P_GetMidTexturePosition(const line_t *line, int sideno, double *ptextop, double *ptexbot);
bool P_Check3dMidSwitch(AActor *actor, line_t *line, int side);
bool P_LineOpening_3dMidtex(AActor *thing, const line_t *linedef, struct FLineOpening &open, bool restrict=false);
bool P_MoveLinkedSectors(sector_t *sector, int crush, fixed_t move, bool ceiling);
bool P_MoveLinkedSectors(sector_t *sector, int crush, double move, bool ceiling);
void P_StartLinkedSectorInterpolations(TArray<DInterpolation *> &list, sector_t *sector, bool ceiling);
bool P_AddSectorLinks(sector_t *control, int tag, INTBOOL ceiling, int movetype);
void P_AddSectorLinksByID(sector_t *control, int id, INTBOOL ceiling);

View file

@ -1390,7 +1390,7 @@ public:
void Serialize (FArchive &arc);
private:
sector_t *Sector;
fixed_t WatchD, LastD;
double WatchD, LastD;
int Special, Arg0, Arg1, Arg2, Arg3, Arg4;
TObjPtr<AActor> Activator;
line_t *Line;
@ -1426,9 +1426,9 @@ DPlaneWatcher::DPlaneWatcher (AActor *it, line_t *line, int lineSide, bool ceili
{
plane = Sector->floorplane;
}
LastD = plane.fixD();
plane.ChangeHeight (height << FRACBITS);
WatchD = plane.fixD();
LastD = plane.fD();
plane.ChangeHeight (height);
WatchD = plane.fD();
}
else
{
@ -1454,15 +1454,15 @@ void DPlaneWatcher::Tick ()
return;
}
fixed_t newd;
double newd;
if (bCeiling)
{
newd = Sector->ceilingplane.fixD();
newd = Sector->ceilingplane.fD();
}
else
{
newd = Sector->floorplane.fixD();
newd = Sector->floorplane.fD();
}
if ((LastD < WatchD && newd >= WatchD) ||
@ -4565,12 +4565,12 @@ int DLevelScript::LineFromID(int id)
}
}
bool GetVarAddrType(AActor *self, FName varname, int index, void *&addr, PType *&type)
bool GetVarAddrType(AActor *self, FName varname, int index, void *&addr, PType *&type, bool readonly)
{
PField *var = dyn_cast<PField>(self->GetClass()->Symbols.FindSymbol(varname, true));
PArray *arraytype;
if (var == NULL || (var->Flags & VARF_Native))
if (var == NULL || (!readonly && (var->Flags & VARF_Native)))
{
return false;
}
@ -4593,6 +4593,17 @@ bool GetVarAddrType(AActor *self, FName varname, int index, void *&addr, PType *
return false;
}
addr = baddr;
// We don't want Int subclasses like Name or Color to be accessible,
// but we do want to support Float subclasses like Fixed.
if (!type->IsA(RUNTIME_CLASS(PInt)) || !type->IsKindOf(RUNTIME_CLASS(PFloat)))
{
// For reading, we also support Name and String types.
if (readonly && (type->IsA(RUNTIME_CLASS(PName)) || type->IsA(RUNTIME_CLASS(PString))))
{
return true;
}
return false;
}
return true;
}
@ -4601,9 +4612,16 @@ static void SetUserVariable(AActor *self, FName varname, int index, int value)
void *addr;
PType *type;
if (GetVarAddrType(self, varname, index, addr, type))
if (GetVarAddrType(self, varname, index, addr, type, false))
{
type->SetValue(addr, value);
if (!type->IsKindOf(RUNTIME_CLASS(PFloat)))
{
type->SetValue(addr, value);
}
else
{
type->SetValue(addr, ACSToDouble(value));
}
}
}
@ -4612,9 +4630,24 @@ static int GetUserVariable(AActor *self, FName varname, int index)
void *addr;
PType *type;
if (GetVarAddrType(self, varname, index, addr, type))
if (GetVarAddrType(self, varname, index, addr, type, true))
{
return type->GetValueInt(addr);
if (type->IsKindOf(RUNTIME_CLASS(PFloat)))
{
return DoubleToACS(type->GetValueFloat(addr));
}
else if (type->IsA(RUNTIME_CLASS(PName)))
{
return GlobalACSStrings.AddString(FName(ENamedName(type->GetValueInt(addr))).GetChars());
}
else if (type->IsA(RUNTIME_CLASS(PString)))
{
return GlobalACSStrings.AddString(*(FString *)addr);
}
else
{
return type->GetValueInt(addr);
}
}
return 0;
}
@ -4916,7 +4949,7 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, SDWORD *args)
return GetUDMFInt(UDMF_Line, LineFromID(args[0]), FBehavior::StaticLookupString(args[1]));
case ACSF_GetLineUDMFFixed:
return GetUDMFFixed(UDMF_Line, LineFromID(args[0]), FBehavior::StaticLookupString(args[1]));
return DoubleToACS(GetUDMFFloat(UDMF_Line, LineFromID(args[0]), FBehavior::StaticLookupString(args[1])));
case ACSF_GetThingUDMFInt:
case ACSF_GetThingUDMFFixed:
@ -4926,13 +4959,13 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, SDWORD *args)
return GetUDMFInt(UDMF_Sector, P_FindFirstSectorFromTag(args[0]), FBehavior::StaticLookupString(args[1]));
case ACSF_GetSectorUDMFFixed:
return GetUDMFFixed(UDMF_Sector, P_FindFirstSectorFromTag(args[0]), FBehavior::StaticLookupString(args[1]));
return DoubleToACS(GetUDMFFloat(UDMF_Sector, P_FindFirstSectorFromTag(args[0]), FBehavior::StaticLookupString(args[1])));
case ACSF_GetSideUDMFInt:
return GetUDMFInt(UDMF_Side, SideFromID(args[0], args[1]), FBehavior::StaticLookupString(args[2]));
case ACSF_GetSideUDMFFixed:
return GetUDMFFixed(UDMF_Side, SideFromID(args[0], args[1]), FBehavior::StaticLookupString(args[2]));
return DoubleToACS(GetUDMFFloat(UDMF_Side, SideFromID(args[0], args[1]), FBehavior::StaticLookupString(args[2])));
case ACSF_GetActorVelX:
actor = SingleActorFromTID(args[0], activator);

View file

@ -402,19 +402,21 @@ static void LoadSectors (sectortype *bsec)
bsec->floorstat = WORD(bsec->floorstat);
sec->e = &sectors[0].e[i];
sec->SetPlaneTexZ(sector_t::floor, -(LittleLong(bsec->floorZ) << 8));
sec->floorplane.set(0, 0, -FRACUNIT, -sec->GetPlaneTexZ(sector_t::floor));
double floorheight = -LittleLong(bsec->floorZ) / 256.;
sec->SetPlaneTexZ(sector_t::floor, floorheight);
sec->floorplane.SetAtHeight(floorheight, sector_t::floor);
mysnprintf (tnam, countof(tnam), "BTIL%04d", LittleShort(bsec->floorpicnum));
sec->SetTexture(sector_t::floor, TexMan.GetTexture (tnam, FTexture::TEX_Build));
sec->SetXScale(sector_t::floor, (bsec->floorstat & 8) ? FRACUNIT*2 : FRACUNIT);
sec->SetYScale(sector_t::floor, (bsec->floorstat & 8) ? FRACUNIT*2 : FRACUNIT);
sec->SetXOffset(sector_t::floor, (bsec->floorxpanning << FRACBITS) + (32 << FRACBITS));
sec->SetYOffset(sector_t::floor, bsec->floorypanning << FRACBITS);
sec->SetXScale(sector_t::floor, (bsec->floorstat & 8) ? 2. : 1.);
sec->SetYScale(sector_t::floor, (bsec->floorstat & 8) ? 2. : 1.);
sec->SetXOffset(sector_t::floor, bsec->floorxpanning + 32.);
sec->SetYOffset(sector_t::floor, bsec->floorypanning + 0.);
sec->SetPlaneLight(sector_t::floor, SHADE2LIGHT (bsec->floorshade));
sec->ChangeFlags(sector_t::floor, 0, PLANEF_ABSLIGHTING);
sec->SetPlaneTexZ(sector_t::ceiling, -(LittleLong(bsec->ceilingZ) << 8));
sec->ceilingplane.set(0, 0, -FRACUNIT, sec->GetPlaneTexZ(sector_t::ceiling));
double ceilingheight = -LittleLong(bsec->ceilingZ) / 256.;
sec->SetPlaneTexZ(sector_t::ceiling, ceilingheight);
sec->ceilingplane.SetAtHeight(ceilingheight, sector_t::ceiling);
mysnprintf (tnam, countof(tnam), "BTIL%04d", LittleShort(bsec->ceilingpicnum));
sec->SetTexture(sector_t::ceiling, TexMan.GetTexture (tnam, FTexture::TEX_Build));
if (bsec->ceilingstat & 1)
@ -422,10 +424,10 @@ static void LoadSectors (sectortype *bsec)
sky1texture = sky2texture = sec->GetTexture(sector_t::ceiling);
sec->SetTexture(sector_t::ceiling, skyflatnum);
}
sec->SetXScale(sector_t::ceiling, (bsec->ceilingstat & 8) ? FRACUNIT*2 : FRACUNIT);
sec->SetYScale(sector_t::ceiling, (bsec->ceilingstat & 8) ? FRACUNIT*2 : FRACUNIT);
sec->SetXOffset(sector_t::ceiling, (bsec->ceilingxpanning << FRACBITS) + (32 << FRACBITS));
sec->SetYOffset(sector_t::ceiling, bsec->ceilingypanning << FRACBITS);
sec->SetXScale(sector_t::ceiling, (bsec->ceilingstat & 8) ? 2. : 1.);
sec->SetYScale(sector_t::ceiling, (bsec->ceilingstat & 8) ? 2. : 1.);
sec->SetXOffset(sector_t::ceiling, bsec->ceilingxpanning + 32.);
sec->SetYOffset(sector_t::ceiling, bsec->ceilingypanning + 0.);
sec->SetPlaneLight(sector_t::ceiling, SHADE2LIGHT (bsec->ceilingshade));
sec->ChangeFlags(sector_t::ceiling, 0, PLANEF_ABSLIGHTING);
@ -444,30 +446,30 @@ static void LoadSectors (sectortype *bsec)
if (bsec->floorstat & 4)
{
sec->SetAngle(sector_t::floor, ANGLE_90);
sec->SetXScale(sector_t::floor, -sec->GetXScale(sector_t::floor));
sec->SetAngle(sector_t::floor, DAngle(90.));
sec->SetXScale(sector_t::floor, -sec->GetXScaleF(sector_t::floor));
}
if (bsec->floorstat & 16)
{
sec->SetXScale(sector_t::floor, -sec->GetXScale(sector_t::floor));
sec->SetXScale(sector_t::floor, -sec->GetXScaleF(sector_t::floor));
}
if (bsec->floorstat & 32)
{
sec->SetYScale(sector_t::floor, -sec->GetYScale(sector_t::floor));
sec->SetYScale(sector_t::floor, -sec->GetYScaleF(sector_t::floor));
}
if (bsec->ceilingstat & 4)
{
sec->SetAngle(sector_t::ceiling, ANGLE_90);
sec->SetYScale(sector_t::ceiling, -sec->GetYScale(sector_t::ceiling));
sec->SetAngle(sector_t::ceiling, DAngle(90.));
sec->SetYScale(sector_t::ceiling, -sec->GetYScaleF(sector_t::ceiling));
}
if (bsec->ceilingstat & 16)
{
sec->SetXScale(sector_t::ceiling, -sec->GetXScale(sector_t::ceiling));
sec->SetXScale(sector_t::ceiling, -sec->GetXScaleF(sector_t::ceiling));
}
if (bsec->ceilingstat & 32)
{
sec->SetYScale(sector_t::ceiling, -sec->GetYScale(sector_t::ceiling));
sec->SetYScale(sector_t::ceiling, -sec->GetYScaleF(sector_t::ceiling));
}
}
}
@ -523,8 +525,8 @@ static void LoadWalls (walltype *walls, int numwalls, sectortype *bsec)
walls[i].nextwall = LittleShort(walls[i].nextwall);
walls[i].nextsector = LittleShort(walls[i].nextsector);
sides[i].SetTextureXOffset(walls[i].xpanning << FRACBITS);
sides[i].SetTextureYOffset(walls[i].ypanning << FRACBITS);
sides[i].SetTextureXOffset((double)walls[i].xpanning);
sides[i].SetTextureYOffset((double)walls[i].ypanning);
sides[i].SetTexture(side_t::top, pic);
sides[i].SetTexture(side_t::bottom, pic);
@ -542,8 +544,8 @@ static void LoadWalls (walltype *walls, int numwalls, sectortype *bsec)
}
sides[i].TexelLength = walls[i].xrepeat * 8;
sides[i].SetTextureYScale(walls[i].yrepeat << (FRACBITS - 3));
sides[i].SetTextureXScale(FRACUNIT);
sides[i].SetTextureYScale(walls[i].yrepeat / 8.);
sides[i].SetTextureXScale(1.);
sides[i].SetLight(SHADE2LIGHT(walls[i].shade));
sides[i].Flags = WALLF_ABSLIGHTING;
sides[i].RightSide = walls[i].point2;
@ -751,16 +753,16 @@ static int LoadSprites (spritetype *sprites, Xsprite *xsprites, int numsprites,
//
//==========================================================================
vertex_t *FindVertex (SDWORD x, SDWORD y)
vertex_t *FindVertex (SDWORD xx, SDWORD yy)
{
int i;
x <<= 12;
y = -(y << 12);
double x = xx / 64.;
double y = -yy / 64.;
for (i = 0; i < numvertexes; ++i)
{
if (vertexes[i].fixX() == x && vertexes[i].fixY() == y)
if (vertexes[i].fX() == x && vertexes[i].fY() == y)
{
return &vertexes[i];
}
@ -814,8 +816,7 @@ static void CalcPlane (SlopeWork &slope, secplane_t &plane)
slope.x[2] = slope.x[0];
slope.y[2] = slope.y[0] + 64;
}
j = DMulScale3 (slope.dx, slope.y[2]-slope.wal->y,
-slope.dy, slope.x[2]-slope.wal->x);
j = DMulScale3 (slope.dx, slope.y[2]-slope.wal->y, -slope.dy, slope.x[2]-slope.wal->x);
slope.z[2] += Scale (slope.heinum, j, slope.i);
pt[0] = DVector3(slope.dx, -slope.dy, 0);
@ -827,9 +828,8 @@ static void CalcPlane (SlopeWork &slope, secplane_t &plane)
pt[2] = -pt[2];
}
plane.set(pt[2][0], pt[2][1], pt[2][2], 0.);
plane.setD(-TMulScale8
(plane.fixA(), slope.x[0]<<4, plane.fixB(), (-slope.y[0])<<4, plane.fixC(), slope.z[0]));
double dist = -pt[2][0] * slope.x[0] * 16 + pt[2][1] * slope.y[0] * 16 - pt[2][2] * slope.z[0];
plane.set(pt[2][0], pt[2][1], pt[2][2], dist);
}
//==========================================================================

View file

@ -228,7 +228,7 @@ DCeiling::DCeiling (sector_t *sec)
{
}
DCeiling::DCeiling (sector_t *sec, fixed_t speed1, fixed_t speed2, int silent)
DCeiling::DCeiling (sector_t *sec, double speed1, double speed2, int silent)
: DMovingCeiling (sec)
{
m_Crush = -1;
@ -245,10 +245,10 @@ DCeiling::DCeiling (sector_t *sec, fixed_t speed1, fixed_t speed2, int silent)
//============================================================================
DCeiling *DCeiling::Create(sector_t *sec, DCeiling::ECeiling type, line_t *line, int tag,
fixed_t speed, fixed_t speed2, fixed_t height,
double speed, double speed2, double height,
int crush, int silent, int change, ECrushMode hexencrush)
{
fixed_t targheight = 0; // Silence, GCC
double targheight = 0; // Silence, GCC
// if ceiling already moving, don't start a second function on it
if (sec->PlaneMoving(sector_t::ceiling))
@ -264,7 +264,7 @@ DCeiling *DCeiling::Create(sector_t *sec, DCeiling::ECeiling type, line_t *line,
{
case ceilCrushAndRaise:
case ceilCrushRaiseAndStay:
ceiling->m_TopHeight = sec->ceilingplane.fixD();
ceiling->m_TopHeight = sec->ceilingplane.fD();
case ceilLowerAndCrush:
targheight = sec->FindHighestFloorPoint (&spot);
targheight += height;
@ -292,7 +292,7 @@ DCeiling *DCeiling::Create(sector_t *sec, DCeiling::ECeiling type, line_t *line,
case ceilMoveToValue:
{
int diff = height - sec->ceilingplane.ZatPoint (spot);
double diff = height - sec->ceilingplane.ZatPoint (spot);
targheight = height;
if (diff < 0)
@ -400,15 +400,15 @@ DCeiling *DCeiling::Create(sector_t *sec, DCeiling::ECeiling type, line_t *line,
// Do not interpolate instant movement ceilings.
// Note for ZDoomGL: Check to make sure that you update the sector
// after the ceiling moves, because it hasn't actually moved yet.
fixed_t movedist;
double movedist;
if (ceiling->m_Direction < 0)
{
movedist = sec->ceilingplane.fixD() - ceiling->m_BottomHeight;
movedist = sec->ceilingplane.fD() - ceiling->m_BottomHeight;
}
else
{
movedist = ceiling->m_TopHeight - sec->ceilingplane.fixD();
movedist = ceiling->m_TopHeight - sec->ceilingplane.fD();
}
if (ceiling->m_Speed >= movedist)
{
@ -483,7 +483,7 @@ DCeiling *DCeiling::Create(sector_t *sec, DCeiling::ECeiling type, line_t *line,
//============================================================================
bool EV_DoCeiling (DCeiling::ECeiling type, line_t *line,
int tag, fixed_t speed, fixed_t speed2, fixed_t height,
int tag, double speed, double speed2, double height,
int crush, int silent, int change, DCeiling::ECrushMode hexencrush)
{
int secnum;

View file

@ -82,14 +82,14 @@ void DDoor::Tick ()
{
EResult res;
if (m_Sector->floorplane.fixD() != m_OldFloorDist)
// Adjust bottom height - but only if there isn't an active lift attached to the floor.
if (m_Sector->floorplane.fD() != m_OldFloorDist)
{
if (!m_Sector->floordata || !m_Sector->floordata->IsKindOf(RUNTIME_CLASS(DPlat)) ||
!(barrier_cast<DPlat*>(m_Sector->floordata))->IsLift())
{
m_OldFloorDist = m_Sector->floorplane.fixD();
m_BotDist = m_Sector->ceilingplane.PointToDist (m_BotSpot,
m_Sector->floorplane.ZatPoint (m_BotSpot));
m_OldFloorDist = m_Sector->floorplane.fD();
m_BotDist = m_Sector->ceilingplane.PointToDist (m_BotSpot, m_Sector->floorplane.ZatPoint (m_BotSpot));
}
}
@ -140,10 +140,10 @@ void DDoor::Tick ()
res = MoveCeiling (m_Speed, m_BotDist, -1, m_Direction, false);
// killough 10/98: implement gradual lighting effects
if (m_LightTag != 0 && m_TopDist != -m_Sector->floorplane.fixD())
if (m_LightTag != 0 && m_TopDist != -m_Sector->floorplane.fD())
{
EV_LightTurnOnPartway (m_LightTag,
FIXED2DBL(FixedDiv (m_Sector->ceilingplane.fixD() + m_Sector->floorplane.fixD(), m_TopDist + m_Sector->floorplane.fixD())));
(m_Sector->ceilingplane.fD() + m_Sector->floorplane.fD()) / (m_TopDist + m_Sector->floorplane.fD()));
}
if (res == pastdest)
@ -186,10 +186,10 @@ void DDoor::Tick ()
res = MoveCeiling (m_Speed, m_TopDist, -1, m_Direction, false);
// killough 10/98: implement gradual lighting effects
if (m_LightTag != 0 && m_TopDist != -m_Sector->floorplane.fixD())
if (m_LightTag != 0 && m_TopDist != -m_Sector->floorplane.fD())
{
EV_LightTurnOnPartway (m_LightTag,
FIXED2DBL(FixedDiv (m_Sector->ceilingplane.fixD() + m_Sector->floorplane.fixD(), m_TopDist + m_Sector->floorplane.fixD())));
(m_Sector->ceilingplane.fD() + m_Sector->floorplane.fD()) / (m_TopDist + m_Sector->floorplane.fD()));
}
if (res == pastdest)
@ -350,12 +350,12 @@ DDoor::DDoor (sector_t *sector)
//
//============================================================================
DDoor::DDoor (sector_t *sec, EVlDoor type, fixed_t speed, int delay, int lightTag, int topcountdown)
DDoor::DDoor (sector_t *sec, EVlDoor type, double speed, int delay, int lightTag, int topcountdown)
: DMovingCeiling (sec),
m_Type (type), m_Speed (speed), m_TopWait (delay), m_TopCountdown(topcountdown), m_LightTag (lightTag)
{
vertex_t *spot;
fixed_t height;
double height;
if (i_compatflags & COMPATF_NODOORLIGHT)
{
@ -367,7 +367,7 @@ DDoor::DDoor (sector_t *sec, EVlDoor type, fixed_t speed, int delay, int lightTa
case doorClose:
m_Direction = -1;
height = sec->FindLowestCeilingSurrounding (&spot);
m_TopDist = sec->ceilingplane.PointToDist (spot, height - 4*FRACUNIT);
m_TopDist = sec->ceilingplane.PointToDist (spot, height - 4);
DoorSound (false);
break;
@ -375,13 +375,13 @@ DDoor::DDoor (sector_t *sec, EVlDoor type, fixed_t speed, int delay, int lightTa
case doorRaise:
m_Direction = 1;
height = sec->FindLowestCeilingSurrounding (&spot);
m_TopDist = sec->ceilingplane.PointToDist (spot, height - 4*FRACUNIT);
if (m_TopDist != sec->ceilingplane.fixD())
m_TopDist = sec->ceilingplane.PointToDist (spot, height - 4);
if (m_TopDist != sec->ceilingplane.fD())
DoorSound (true);
break;
case doorCloseWaitOpen:
m_TopDist = sec->ceilingplane.fixD();
m_TopDist = sec->ceilingplane.fD();
m_Direction = -1;
DoorSound (false);
break;
@ -389,7 +389,7 @@ DDoor::DDoor (sector_t *sec, EVlDoor type, fixed_t speed, int delay, int lightTa
case doorWaitRaise:
m_Direction = 2;
height = sec->FindLowestCeilingSurrounding (&spot);
m_TopDist = sec->ceilingplane.PointToDist (spot, height - 4*FRACUNIT);
m_TopDist = sec->ceilingplane.PointToDist (spot, height - 4);
break;
case doorWaitClose:
@ -397,8 +397,8 @@ DDoor::DDoor (sector_t *sec, EVlDoor type, fixed_t speed, int delay, int lightTa
m_Type = DDoor::doorRaise;
height = sec->FindHighestFloorPoint (&m_BotSpot);
m_BotDist = sec->ceilingplane.PointToDist (m_BotSpot, height);
m_OldFloorDist = sec->floorplane.fixD();
m_TopDist = sec->ceilingplane.fixD();
m_OldFloorDist = sec->floorplane.fD();
m_TopDist = sec->ceilingplane.fD();
break;
}
@ -414,7 +414,7 @@ DDoor::DDoor (sector_t *sec, EVlDoor type, fixed_t speed, int delay, int lightTa
height = sec->FindLowestCeilingPoint(&m_BotSpot);
m_BotDist = sec->ceilingplane.PointToDist (m_BotSpot, height);
}
m_OldFloorDist = sec->floorplane.fixD();
m_OldFloorDist = sec->floorplane.fD();
}
//============================================================================
@ -425,7 +425,7 @@ DDoor::DDoor (sector_t *sec, EVlDoor type, fixed_t speed, int delay, int lightTa
//============================================================================
bool EV_DoDoor (DDoor::EVlDoor type, line_t *line, AActor *thing,
int tag, int speed, int delay, int lock, int lightTag, bool boomgen, int topcountdown)
int tag, double speed, int delay, int lock, int lightTag, bool boomgen, int topcountdown)
{
bool rtn = false;
int secnum;
@ -559,13 +559,13 @@ bool DAnimatedDoor::StartClosing ()
return false;
}
fixed_t topdist = m_Sector->ceilingplane.fixD();
if (MoveCeiling (2048*FRACUNIT, m_BotDist, 0, -1, false) == crushed)
double topdist = m_Sector->ceilingplane.fD();
if (MoveCeiling (2048., m_BotDist, 0, -1, false) == crushed)
{
return false;
}
MoveCeiling (2048*FRACUNIT, topdist, 1);
MoveCeiling (2048., topdist, 1);
m_Line1->flags |= ML_BLOCKING;
m_Line2->flags |= ML_BLOCKING;
@ -650,7 +650,7 @@ void DAnimatedDoor::Tick ()
if (--m_Frame < 0)
{
// IF DOOR IS DONE CLOSING...
MoveCeiling (2048*FRACUNIT, m_BotDist, -1);
MoveCeiling (2048., m_BotDist, -1);
m_Sector->ceilingdata = NULL;
Destroy ();
// Unset blocking flags on lines that didn't start with them. Since the
@ -690,7 +690,7 @@ void DAnimatedDoor::Tick ()
DAnimatedDoor::DAnimatedDoor (sector_t *sec, line_t *line, int speed, int delay, FDoorAnimation *anim)
: DMovingCeiling (sec)
{
fixed_t topdist;
double topdist;
FTextureID picnum;
// The DMovingCeiling constructor automatically sets up an interpolation for us.
@ -722,7 +722,7 @@ DAnimatedDoor::DAnimatedDoor (sector_t *sec, line_t *line, int speed, int delay,
FTexture *tex = TexMan[picnum];
topdist = tex ? tex->GetScaledHeight() : 64;
topdist = m_Sector->ceilingplane.fixD() - topdist * m_Sector->ceilingplane.fixC();
topdist = m_Sector->ceilingplane.fD() - topdist * m_Sector->ceilingplane.fC();
m_Status = Opening;
m_Speed = speed;
@ -733,8 +733,8 @@ DAnimatedDoor::DAnimatedDoor (sector_t *sec, line_t *line, int speed, int delay,
m_SetBlocking2 = !!(m_Line2->flags & ML_BLOCKING);
m_Line1->flags |= ML_BLOCKING;
m_Line2->flags |= ML_BLOCKING;
m_BotDist = m_Sector->ceilingplane.fixD();
MoveCeiling (2048*FRACUNIT, topdist, 1);
m_BotDist = m_Sector->ceilingplane.fD();
MoveCeiling (2048., topdist, 1);
if (m_DoorAnim->OpenSound != NAME_None)
{
SN_StartSequence (m_Sector, CHAN_INTERIOR, m_DoorAnim->OpenSound, 1);

View file

@ -883,9 +883,9 @@ void P_DisconnectEffect (AActor *actor)
break;
fixed_t xo = ((M_Random() - 128) << 9) * (actor->_f_radius() >> FRACBITS);
fixed_t yo = ((M_Random() - 128) << 9) * (actor->_f_radius() >> FRACBITS);
fixed_t zo = (M_Random() << 8) * (actor->_f_height() >> FRACBITS);
fixed_t xo = ((M_Random() - 128) << 9) * int(actor->radius);
fixed_t yo = ((M_Random() - 128) << 9) * int(actor->radius);
fixed_t zo = (M_Random() << 8) * int(actor->Height);
fixedvec3 pos = actor->Vec3Offset(xo, yo, zo);
p->x = pos.x;
p->y = pos.y;

View file

@ -2874,7 +2874,7 @@ void A_Face(AActor *self, AActor *other, DAngle max_turn, DAngle max_pitch, DAng
double dist_z = target_z - source_z;
double ddist = g_sqrt(dist.X*dist.X + dist.Y*dist.Y + dist_z*dist_z);
DAngle other_pitch = DAngle(ToDegrees(g_asin(dist_z / ddist))).Normalized180();
DAngle other_pitch = DAngle::ToDegrees(g_asin(dist_z / ddist)).Normalized180();
if (max_pitch != 0)
{

View file

@ -280,14 +280,14 @@ DFloor::DFloor (sector_t *sec)
//==========================================================================
bool EV_DoFloor (DFloor::EFloor floortype, line_t *line, int tag,
fixed_t speed, fixed_t height, int crush, int change, bool hexencrush, bool hereticlower)
double speed, double height, int crush, int change, bool hexencrush, bool hereticlower)
{
int secnum;
bool rtn;
sector_t* sec;
DFloor* floor;
fixed_t ceilingheight;
fixed_t newheight;
double ceilingheight;
double newheight;
vertex_t *spot, *spot2;
rtn = false;
@ -312,7 +312,7 @@ bool EV_DoFloor (DFloor::EFloor floortype, line_t *line, int tag,
floor->m_Hexencrush = hexencrush;
floor->m_Speed = speed;
floor->m_ResetCount = 0; // [RH]
floor->m_OrgDist = sec->floorplane.fixD(); // [RH]
floor->m_OrgDist = sec->floorplane.fD(); // [RH]
switch (floortype)
{
@ -322,7 +322,7 @@ bool EV_DoFloor (DFloor::EFloor floortype, line_t *line, int tag,
floor->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight);
// [RH] DOOM's turboLower type did this. I've just extended it
// to be applicable to all LowerToHighest types.
if (hereticlower || floor->m_FloorDestDist != sec->floorplane.fixD())
if (hereticlower || floor->m_FloorDestDist != sec->floorplane.fD())
floor->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight+height);
break;
@ -344,7 +344,7 @@ bool EV_DoFloor (DFloor::EFloor floortype, line_t *line, int tag,
case DFloor::floorLowerByValue:
floor->m_Direction = -1;
newheight = sec->CenterFloor() - height;
floor->m_FloorDestDist = sec->floorplane.PointToDist (sec->_f_centerspot(), newheight);
floor->m_FloorDestDist = sec->floorplane.PointToDist (sec->centerspot, newheight);
break;
case DFloor::floorRaiseInstant:
@ -352,13 +352,13 @@ bool EV_DoFloor (DFloor::EFloor floortype, line_t *line, int tag,
case DFloor::floorRaiseByValue:
floor->m_Direction = 1;
newheight = sec->CenterFloor() + height;
floor->m_FloorDestDist = sec->floorplane.PointToDist (sec->_f_centerspot(), newheight);
floor->m_FloorDestDist = sec->floorplane.PointToDist (sec->centerspot, newheight);
break;
case DFloor::floorMoveToValue:
sec->FindHighestFloorPoint (&spot);
floor->m_FloorDestDist = sec->floorplane.PointToDist (spot, height);
floor->m_Direction = (floor->m_FloorDestDist > sec->floorplane.fixD()) ? -1 : 1;
floor->m_Direction = (floor->m_FloorDestDist > sec->floorplane.fD()) ? -1 : 1;
break;
case DFloor::floorRaiseAndCrushDoom:
@ -366,12 +366,12 @@ bool EV_DoFloor (DFloor::EFloor floortype, line_t *line, int tag,
floor->m_Direction = 1;
newheight = sec->FindLowestCeilingSurrounding (&spot);
if (floortype == DFloor::floorRaiseAndCrushDoom)
newheight -= 8 * FRACUNIT;
newheight -= 8;
ceilingheight = sec->FindLowestCeilingPoint (&spot2);
floor->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight);
if (sec->floorplane.ZatPointDist (spot2, floor->m_FloorDestDist) > ceilingheight)
floor->m_FloorDestDist = sec->floorplane.PointToDist (spot2,
floortype == DFloor::floorRaiseAndCrushDoom ? ceilingheight - 8*FRACUNIT : ceilingheight);
floortype == DFloor::floorRaiseAndCrushDoom ? ceilingheight - 8 : ceilingheight);
break;
case DFloor::floorRaiseToHighest:
@ -394,7 +394,7 @@ bool EV_DoFloor (DFloor::EFloor floortype, line_t *line, int tag,
case DFloor::floorRaiseAndCrush:
floor->m_Direction = 1;
newheight = sec->FindLowestCeilingPoint (&spot) - 8*FRACUNIT;
newheight = sec->FindLowestCeilingPoint (&spot) - 8;
floor->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight);
break;
@ -413,7 +413,7 @@ bool EV_DoFloor (DFloor::EFloor floortype, line_t *line, int tag,
case DFloor::floorLowerByTexture:
floor->m_Direction = -1;
newheight = sec->CenterFloor() - sec->FindShortestTextureAround ();
floor->m_FloorDestDist = sec->floorplane.PointToDist (sec->_f_centerspot(), newheight);
floor->m_FloorDestDist = sec->floorplane.PointToDist (sec->centerspot, newheight);
break;
case DFloor::floorLowerToCeiling:
@ -430,13 +430,13 @@ bool EV_DoFloor (DFloor::EFloor floortype, line_t *line, int tag,
// enough, BOOM preserved the code here even though it
// also had this function.)
newheight = sec->CenterFloor() + sec->FindShortestTextureAround ();
floor->m_FloorDestDist = sec->floorplane.PointToDist (sec->_f_centerspot(), newheight);
floor->m_FloorDestDist = sec->floorplane.PointToDist (sec->centerspot, newheight);
break;
case DFloor::floorRaiseAndChange:
floor->m_Direction = 1;
newheight = sec->CenterFloor() + height;
floor->m_FloorDestDist = sec->floorplane.PointToDist (sec->_f_centerspot(), newheight);
floor->m_FloorDestDist = sec->floorplane.PointToDist (sec->centerspot, newheight);
if (line != NULL)
{
FTextureID oldpic = sec->GetTexture(sector_t::floor);
@ -475,9 +475,9 @@ bool EV_DoFloor (DFloor::EFloor floortype, line_t *line, int tag,
// Do not interpolate instant movement floors.
bool silent = false;
if ((floor->m_Direction>0 && floor->m_FloorDestDist>sec->floorplane.fixD()) || // moving up but going down
(floor->m_Direction<0 && floor->m_FloorDestDist<sec->floorplane.fixD()) || // moving down but going up
(floor->m_Speed >= abs(sec->floorplane.fixD() - floor->m_FloorDestDist))) // moving in one step
if ((floor->m_Direction>0 && floor->m_FloorDestDist>sec->floorplane.fD()) || // moving up but going down
(floor->m_Direction<0 && floor->m_FloorDestDist<sec->floorplane.fD()) || // moving down but going up
(floor->m_Speed >= fabs(sec->floorplane.fD() - floor->m_FloorDestDist))) // moving in one step
{
floor->StopInterpolation(true);
@ -560,13 +560,13 @@ bool EV_FloorCrushStop (int tag)
//==========================================================================
bool EV_BuildStairs (int tag, DFloor::EStair type, line_t *line,
fixed_t stairsize, fixed_t speed, int delay, int reset, int igntxt,
double stairsize, double speed, int delay, int reset, int igntxt,
int usespecials)
{
int secnum = -1;
int osecnum; //jff 3/4/98 save old loop index
int height;
fixed_t stairstep;
double height;
double stairstep;
int i;
int newsecnum = -1;
FTextureID texture;
@ -583,7 +583,7 @@ bool EV_BuildStairs (int tag, DFloor::EStair type, line_t *line,
if (speed == 0)
return false;
persteptime = FixedDiv (stairsize, speed) >> FRACBITS;
persteptime = int(stairsize / speed);
// check if a manual trigger, if so do just the sector on the backside
FSectorTagIterator itr(tag, line);
@ -609,7 +609,7 @@ bool EV_BuildStairs (int tag, DFloor::EStair type, line_t *line,
stairstep = stairsize * floor->m_Direction;
floor->m_Type = DFloor::buildStair; //jff 3/31/98 do not leave uninited
floor->m_ResetCount = reset; // [RH] Tics until reset (0 if never)
floor->m_OrgDist = sec->floorplane.fixD(); // [RH] Height to reset to
floor->m_OrgDist = sec->floorplane.fD(); // [RH] Height to reset to
// [RH] Set up delay values
floor->m_Delay = delay;
floor->m_PauseTime = 0;
@ -620,7 +620,7 @@ bool EV_BuildStairs (int tag, DFloor::EStair type, line_t *line,
floor->m_Speed = speed;
height = sec->CenterFloor() + stairstep;
floor->m_FloorDestDist = sec->floorplane.PointToDist (sec->_f_centerspot(), height);
floor->m_FloorDestDist = sec->floorplane.PointToDist (sec->centerspot, height);
texture = sec->GetTexture(sector_t::floor);
osecnum = secnum; //jff 3/4/98 preserve loop index
@ -710,7 +710,7 @@ bool EV_BuildStairs (int tag, DFloor::EStair type, line_t *line,
floor = new DFloor (sec);
floor->StartFloorSound ();
floor->m_Direction = (type == DFloor::buildUp) ? 1 : -1;
floor->m_FloorDestDist = sec->floorplane.PointToDist (0, 0, height);
floor->m_FloorDestDist = sec->floorplane.PointToDist (DVector2(0, 0), height);
// [RH] Set up delay values
floor->m_Delay = delay;
floor->m_PauseTime = 0;
@ -719,8 +719,8 @@ bool EV_BuildStairs (int tag, DFloor::EStair type, line_t *line,
if (usespecials & DFloor::stairSync)
{
// [RH]
fixed_t rise = height - sec->CenterFloor();
floor->m_Speed = Scale (speed, rise, stairstep);
double rise = height - sec->CenterFloor();
floor->m_Speed = speed * rise / stairstep;
}
else
{
@ -728,10 +728,10 @@ bool EV_BuildStairs (int tag, DFloor::EStair type, line_t *line,
}
floor->m_Type = DFloor::buildStair; //jff 3/31/98 do not leave uninited
//jff 2/27/98 fix uninitialized crush field
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_ResetCount = reset; // [RH] Tics until reset (0 if never)
floor->m_OrgDist = sec->floorplane.fixD(); // [RH] Height to reset to
floor->m_OrgDist = sec->floorplane.fD(); // [RH] Height to reset to
}
} while (ok);
// [RH] make sure the first sector doesn't point to a previous one, otherwise
@ -747,7 +747,7 @@ bool EV_BuildStairs (int tag, DFloor::EStair type, line_t *line,
//
//==========================================================================
bool EV_DoDonut (int tag, line_t *line, fixed_t pillarspeed, fixed_t slimespeed)
bool EV_DoDonut (int tag, line_t *line, double pillarspeed, double slimespeed)
{
sector_t* s1;
sector_t* s2;
@ -757,7 +757,7 @@ bool EV_DoDonut (int tag, line_t *line, fixed_t pillarspeed, fixed_t slimespeed)
int i;
DFloor* floor;
vertex_t* spot;
fixed_t height;
double height;
rtn = false;
@ -900,10 +900,10 @@ void DElevator::Tick ()
{
EResult res;
fixed_t oldfloor, oldceiling;
double oldfloor, oldceiling;
oldfloor = m_Sector->floorplane.fixD();
oldceiling = m_Sector->ceilingplane.fixD();
oldfloor = m_Sector->floorplane.fD();
oldceiling = m_Sector->ceilingplane.fD();
if (m_Direction < 0) // moving down
{
@ -966,14 +966,14 @@ void DElevator::StartFloorSound ()
//==========================================================================
bool EV_DoElevator (line_t *line, DElevator::EElevator elevtype,
fixed_t speed, fixed_t height, int tag)
double speed, double height, int tag)
{
int secnum;
bool rtn;
sector_t* sec;
DElevator* elevator;
fixed_t floorheight, ceilingheight;
fixed_t newheight;
double floorheight, ceilingheight;
double newheight;
vertex_t* spot;
if (!line && (elevtype == DElevator::elevateCurrent))
@ -1010,7 +1010,7 @@ bool EV_DoElevator (line_t *line, DElevator::EElevator elevtype,
elevator->m_Direction = -1;
newheight = sec->FindNextLowestFloor (&spot);
elevator->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight);
newheight += sec->ceilingplane.ZatPoint (spot) - sec->floorplane.ZatPoint (spot);
newheight += sec->ceilingplane.ZatPoint(spot) - sec->floorplane.ZatPoint(spot);
elevator->m_CeilingDestDist = sec->ceilingplane.PointToDist (spot, newheight);
break;
@ -1019,7 +1019,7 @@ bool EV_DoElevator (line_t *line, DElevator::EElevator elevtype,
elevator->m_Direction = 1;
newheight = sec->FindNextHighestFloor (&spot);
elevator->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight);
newheight += sec->ceilingplane.ZatPoint (spot) - sec->floorplane.ZatPoint (spot);
newheight += sec->ceilingplane.ZatPoint(spot) - sec->floorplane.ZatPoint(spot);
elevator->m_CeilingDestDist = sec->ceilingplane.PointToDist (spot, newheight);
break;
@ -1027,25 +1027,25 @@ bool EV_DoElevator (line_t *line, DElevator::EElevator elevtype,
case DElevator::elevateCurrent:
newheight = line->frontsector->floorplane.ZatPoint (line->v1);
elevator->m_FloorDestDist = sec->floorplane.PointToDist (line->v1, newheight);
newheight += sec->ceilingplane.ZatPoint (line->v1) - sec->floorplane.ZatPoint (line->v1);
newheight += sec->ceilingplane.ZatPoint(line->v1) - sec->floorplane.ZatPoint(line->v1);
elevator->m_CeilingDestDist = sec->ceilingplane.PointToDist (line->v1, newheight);
elevator->m_Direction =
elevator->m_FloorDestDist > sec->floorplane.fixD() ? -1 : 1;
elevator->m_FloorDestDist > sec->floorplane.fD() ? -1 : 1;
break;
// [RH] elevate up by a specific amount
case DElevator::elevateRaise:
elevator->m_Direction = 1;
elevator->m_FloorDestDist = sec->floorplane.PointToDist (sec->_f_centerspot(), floorheight + height);
elevator->m_CeilingDestDist = sec->ceilingplane.PointToDist (sec->_f_centerspot(), ceilingheight + height);
elevator->m_FloorDestDist = sec->floorplane.PointToDist (sec->centerspot, floorheight + height);
elevator->m_CeilingDestDist = sec->ceilingplane.PointToDist (sec->centerspot, ceilingheight + height);
break;
// [RH] elevate down by a specific amount
case DElevator::elevateLower:
elevator->m_Direction = -1;
elevator->m_FloorDestDist = sec->floorplane.PointToDist (sec->_f_centerspot(), floorheight - height);
elevator->m_CeilingDestDist = sec->ceilingplane.PointToDist (sec->_f_centerspot(), ceilingheight - height);
elevator->m_FloorDestDist = sec->floorplane.PointToDist (sec->centerspot, floorheight - height);
elevator->m_CeilingDestDist = sec->ceilingplane.PointToDist (sec->centerspot, ceilingheight - height);
break;
}
}
@ -1178,7 +1178,7 @@ void DWaggleBase::DoWaggle (bool ceiling)
{
secplane_t *plane;
int pos;
fixed_t dist;
double dist;
if (ceiling)
{
@ -1204,7 +1204,7 @@ void DWaggleBase::DoWaggle (bool ceiling)
case WGLSTATE_REDUCE:
if ((m_Scale -= m_ScaleDelta) <= 0)
{ // Remove
dist = FixedDiv (m_OriginalDist - plane->fixD(), plane->fixC());
dist = (m_OriginalDist - plane->fD()) / plane->fC();
m_Sector->ChangePlaneTexZ(pos, -plane->HeightDiff (m_OriginalDist));
plane->setD(m_OriginalDist);
P_ChangeSector (m_Sector, true, dist, ceiling, false);
@ -1233,11 +1233,8 @@ void DWaggleBase::DoWaggle (bool ceiling)
}
m_Accumulator += m_AccDelta;
fixed_t mag = finesine[(m_Accumulator>>9)&8191]*8;
dist = plane->fixD();
plane->setD(m_OriginalDist + plane->PointToDist (0, 0, FixedMul (mag, m_Scale)));
dist = plane->fD();
plane->setD(m_OriginalDist + plane->PointToDist (DVector2(0, 0), BobSin(m_Accumulator) *m_Scale));
m_Sector->ChangePlaneTexZ(pos, plane->HeightDiff (dist));
dist = plane->HeightDiff (dist);
@ -1322,19 +1319,18 @@ bool EV_StartWaggle (int tag, line_t *line, int height, int speed, int offset,
if (ceiling)
{
waggle = new DCeilingWaggle (sector);
waggle->m_OriginalDist = sector->ceilingplane.fixD();
waggle->m_OriginalDist = sector->ceilingplane.fD();
}
else
{
waggle = new DFloorWaggle (sector);
waggle->m_OriginalDist = sector->floorplane.fixD();
waggle->m_OriginalDist = sector->floorplane.fD();
}
waggle->m_Accumulator = offset*FRACUNIT;
waggle->m_AccDelta = speed << (FRACBITS-6);
waggle->m_Accumulator = offset;
waggle->m_AccDelta = speed / 64.;
waggle->m_Scale = 0;
waggle->m_TargetScale = height << (FRACBITS-6);
waggle->m_ScaleDelta = waggle->m_TargetScale
/(TICRATE+((3*TICRATE)*height)/255);
waggle->m_TargetScale = height / 64.;
waggle->m_ScaleDelta = waggle->m_TargetScale / (TICRATE + ((3 * TICRATE)*height) / 255);
waggle->m_Ticker = timer ? timer*TICRATE : -1;
waggle->m_State = WGLSTATE_EXPAND;
}

View file

@ -93,7 +93,7 @@ bool sector_t::IsLinked(sector_t *other, bool ceiling) const
//
//============================================================================
static bool MoveCeiling(sector_t *sector, int crush, fixed_t move)
static bool MoveCeiling(sector_t *sector, int crush, double move)
{
sector->ceilingplane.ChangeHeight (move);
sector->ChangePlaneTexZ(sector_t::ceiling, move);
@ -107,7 +107,7 @@ static bool MoveCeiling(sector_t *sector, int crush, fixed_t move)
return true;
}
static bool MoveFloor(sector_t *sector, int crush, fixed_t move)
static bool MoveFloor(sector_t *sector, int crush, double move)
{
sector->floorplane.ChangeHeight (move);
sector->ChangePlaneTexZ(sector_t::floor, move);
@ -131,7 +131,7 @@ static bool MoveFloor(sector_t *sector, int crush, fixed_t move)
//
//============================================================================
bool P_MoveLinkedSectors(sector_t *sector, int crush, fixed_t move, bool ceiling)
bool P_MoveLinkedSectors(sector_t *sector, int crush, double move, bool ceiling)
{
extsector_t::linked::plane &scrollplane = ceiling? sector->e->Linked.Ceiling : sector->e->Linked.Floor;
bool ok = true;

View file

@ -514,7 +514,7 @@ FUNC(LS_Floor_TransferNumeric)
FUNC(LS_Floor_Donut)
// Floor_Donut (pillartag, pillarspeed, slimespeed)
{
return EV_DoDonut (arg0, ln, _f_SPEED(arg1), _f_SPEED(arg2));
return EV_DoDonut (arg0, ln, SPEED(arg1), SPEED(arg2));
}
FUNC(LS_Generic_Floor)
@ -558,56 +558,56 @@ FUNC(LS_Stairs_BuildDown)
// Stair_BuildDown (tag, speed, height, delay, reset)
{
return EV_BuildStairs (arg0, DFloor::buildDown, ln,
arg2 * FRACUNIT, _f_SPEED(arg1), TICS(arg3), arg4, 0, DFloor::stairUseSpecials);
arg2, SPEED(arg1), TICS(arg3), arg4, 0, DFloor::stairUseSpecials);
}
FUNC(LS_Stairs_BuildUp)
// Stairs_BuildUp (tag, speed, height, delay, reset)
{
return EV_BuildStairs (arg0, DFloor::buildUp, ln,
arg2 * FRACUNIT, _f_SPEED(arg1), TICS(arg3), arg4, 0, DFloor::stairUseSpecials);
arg2, SPEED(arg1), TICS(arg3), arg4, 0, DFloor::stairUseSpecials);
}
FUNC(LS_Stairs_BuildDownSync)
// Stairs_BuildDownSync (tag, speed, height, reset)
{
return EV_BuildStairs (arg0, DFloor::buildDown, ln,
arg2 * FRACUNIT, _f_SPEED(arg1), 0, arg3, 0, DFloor::stairUseSpecials|DFloor::stairSync);
arg2, SPEED(arg1), 0, arg3, 0, DFloor::stairUseSpecials|DFloor::stairSync);
}
FUNC(LS_Stairs_BuildUpSync)
// Stairs_BuildUpSync (tag, speed, height, reset)
{
return EV_BuildStairs (arg0, DFloor::buildUp, ln,
arg2 * FRACUNIT, _f_SPEED(arg1), 0, arg3, 0, DFloor::stairUseSpecials|DFloor::stairSync);
arg2, SPEED(arg1), 0, arg3, 0, DFloor::stairUseSpecials|DFloor::stairSync);
}
FUNC(LS_Stairs_BuildUpDoom)
// Stairs_BuildUpDoom (tag, speed, height, delay, reset)
{
return EV_BuildStairs (arg0, DFloor::buildUp, ln,
arg2 * FRACUNIT, _f_SPEED(arg1), TICS(arg3), arg4, 0, 0);
arg2, SPEED(arg1), TICS(arg3), arg4, 0, 0);
}
FUNC(LS_Stairs_BuildDownDoom)
// Stair_BuildDownDoom (tag, speed, height, delay, reset)
{
return EV_BuildStairs (arg0, DFloor::buildDown, ln,
arg2 * FRACUNIT, _f_SPEED(arg1), TICS(arg3), arg4, 0, 0);
arg2, SPEED(arg1), TICS(arg3), arg4, 0, 0);
}
FUNC(LS_Stairs_BuildDownDoomSync)
// Stairs_BuildDownDoomSync (tag, speed, height, reset)
{
return EV_BuildStairs (arg0, DFloor::buildDown, ln,
arg2 * FRACUNIT, _f_SPEED(arg1), 0, arg3, 0, DFloor::stairSync);
arg2, SPEED(arg1), 0, arg3, 0, DFloor::stairSync);
}
FUNC(LS_Stairs_BuildUpDoomSync)
// Stairs_BuildUpDoomSync (tag, speed, height, reset)
{
return EV_BuildStairs (arg0, DFloor::buildUp, ln,
arg2 * FRACUNIT, _f_SPEED(arg1), 0, arg3, 0, DFloor::stairSync);
arg2, SPEED(arg1), 0, arg3, 0, DFloor::stairSync);
}
@ -616,7 +616,7 @@ FUNC(LS_Generic_Stairs)
{
DFloor::EStair type = (arg3 & 1) ? DFloor::buildUp : DFloor::buildDown;
bool res = EV_BuildStairs (arg0, type, ln,
arg2 * FRACUNIT, _f_SPEED(arg1), 0, arg4, arg3 & 2, 0);
arg2, SPEED(arg1), 0, arg4, arg3 & 2, 0);
if (res && ln && (ln->flags & ML_REPEAT_SPECIAL) && ln->special == Generic_Stairs)
// Toggle direction of next activation of repeatable stairs
@ -628,61 +628,61 @@ FUNC(LS_Generic_Stairs)
FUNC(LS_Pillar_Build)
// Pillar_Build (tag, speed, height)
{
return EV_DoPillar (DPillar::pillarBuild, ln, arg0, _f_SPEED(arg1), arg2*FRACUNIT, 0, -1, false);
return EV_DoPillar (DPillar::pillarBuild, ln, arg0, SPEED(arg1), arg2, 0, -1, false);
}
FUNC(LS_Pillar_BuildAndCrush)
// Pillar_BuildAndCrush (tag, speed, height, crush, crushtype)
{
return EV_DoPillar (DPillar::pillarBuild, ln, arg0, _f_SPEED(arg1), arg2*FRACUNIT, 0, arg3, CRUSHTYPE(arg4));
return EV_DoPillar (DPillar::pillarBuild, ln, arg0, SPEED(arg1), arg2, 0, arg3, CRUSHTYPE(arg4));
}
FUNC(LS_Pillar_Open)
// Pillar_Open (tag, speed, f_height, c_height)
{
return EV_DoPillar (DPillar::pillarOpen, ln, arg0, _f_SPEED(arg1), arg2*FRACUNIT, arg3*FRACUNIT, -1, false);
return EV_DoPillar (DPillar::pillarOpen, ln, arg0, SPEED(arg1), arg2, arg3, -1, false);
}
FUNC(LS_Ceiling_LowerByValue)
// Ceiling_LowerByValue (tag, speed, height, change, crush)
{
return EV_DoCeiling (DCeiling::ceilLowerByValue, ln, arg0, SPEED(arg1), 0, arg2*FRACUNIT, CRUSH(arg4), 0, CHANGE(arg3));
return EV_DoCeiling (DCeiling::ceilLowerByValue, ln, arg0, SPEED(arg1), 0, arg2, CRUSH(arg4), 0, CHANGE(arg3));
}
FUNC(LS_Ceiling_RaiseByValue)
// Ceiling_RaiseByValue (tag, speed, height, change)
{
return EV_DoCeiling (DCeiling::ceilRaiseByValue, ln, arg0, SPEED(arg1), 0, arg2*FRACUNIT, CRUSH(arg4), 0, CHANGE(arg3));
return EV_DoCeiling (DCeiling::ceilRaiseByValue, ln, arg0, SPEED(arg1), 0, arg2, CRUSH(arg4), 0, CHANGE(arg3));
}
FUNC(LS_Ceiling_LowerByValueTimes8)
// Ceiling_LowerByValueTimes8 (tag, speed, height, change, crush)
{
return EV_DoCeiling (DCeiling::ceilLowerByValue, ln, arg0, SPEED(arg1), 0, arg2*FRACUNIT*8, -1, 0, CHANGE(arg3));
return EV_DoCeiling (DCeiling::ceilLowerByValue, ln, arg0, SPEED(arg1), 0, arg2*8, -1, 0, CHANGE(arg3));
}
FUNC(LS_Ceiling_RaiseByValueTimes8)
// Ceiling_RaiseByValueTimes8 (tag, speed, height, change)
{
return EV_DoCeiling (DCeiling::ceilRaiseByValue, ln, arg0, SPEED(arg1), 0, arg2*FRACUNIT*8, -1, 0, CHANGE(arg3));
return EV_DoCeiling (DCeiling::ceilRaiseByValue, ln, arg0, SPEED(arg1), 0, arg2*8, -1, 0, CHANGE(arg3));
}
FUNC(LS_Ceiling_CrushAndRaise)
// Ceiling_CrushAndRaise (tag, speed, crush, crushtype)
{
return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, SPEED(arg1), SPEED(arg1)/2, 8*FRACUNIT, arg2, 0, 0, CRUSHTYPE(arg3, false));
return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, SPEED(arg1), SPEED(arg1)/2, 8, arg2, 0, 0, CRUSHTYPE(arg3, false));
}
FUNC(LS_Ceiling_LowerAndCrush)
// Ceiling_LowerAndCrush (tag, speed, crush, crushtype)
{
return EV_DoCeiling (DCeiling::ceilLowerAndCrush, ln, arg0, SPEED(arg1), SPEED(arg1), 8*FRACUNIT, arg2, 0, 0, CRUSHTYPE(arg3, arg1 == 8));
return EV_DoCeiling (DCeiling::ceilLowerAndCrush, ln, arg0, SPEED(arg1), SPEED(arg1), 8, arg2, 0, 0, CRUSHTYPE(arg3, arg1 == 8));
}
FUNC(LS_Ceiling_LowerAndCrushDist)
// Ceiling_LowerAndCrush (tag, speed, crush, dist, crushtype)
{
return EV_DoCeiling (DCeiling::ceilLowerAndCrush, ln, arg0, SPEED(arg1), SPEED(arg1), arg3*FRACUNIT, arg2, 0, 0, CRUSHTYPE(arg4, arg1 == 8));
return EV_DoCeiling (DCeiling::ceilLowerAndCrush, ln, arg0, SPEED(arg1), SPEED(arg1), arg3, arg2, 0, 0, CRUSHTYPE(arg4, arg1 == 8));
}
FUNC(LS_Ceiling_CrushStop)
@ -694,21 +694,21 @@ FUNC(LS_Ceiling_CrushStop)
FUNC(LS_Ceiling_CrushRaiseAndStay)
// Ceiling_CrushRaiseAndStay (tag, speed, crush, crushtype)
{
return EV_DoCeiling (DCeiling::ceilCrushRaiseAndStay, ln, arg0, SPEED(arg1), SPEED(arg1)/2, 8*FRACUNIT, arg2, 0, 0, CRUSHTYPE(arg3, false));
return EV_DoCeiling (DCeiling::ceilCrushRaiseAndStay, ln, arg0, SPEED(arg1), SPEED(arg1)/2, 8, arg2, 0, 0, CRUSHTYPE(arg3, false));
}
FUNC(LS_Ceiling_MoveToValueTimes8)
// Ceiling_MoveToValueTimes8 (tag, speed, height, negative, change)
{
return EV_DoCeiling (DCeiling::ceilMoveToValue, ln, arg0, SPEED(arg1), 0,
arg2*FRACUNIT*8*((arg3) ? -1 : 1), -1, 0, CHANGE(arg4));
arg2*8*((arg3) ? -1 : 1), -1, 0, CHANGE(arg4));
}
FUNC(LS_Ceiling_MoveToValue)
// Ceiling_MoveToValue (tag, speed, height, negative, change)
{
return EV_DoCeiling (DCeiling::ceilMoveToValue, ln, arg0, SPEED(arg1), 0,
arg2*FRACUNIT*((arg3) ? -1 : 1), -1, 0, CHANGE(arg4));
arg2*((arg3) ? -1 : 1), -1, 0, CHANGE(arg4));
}
FUNC(LS_Ceiling_LowerToHighestFloor)
@ -720,13 +720,13 @@ FUNC(LS_Ceiling_LowerToHighestFloor)
FUNC(LS_Ceiling_LowerInstant)
// Ceiling_LowerInstant (tag, unused, height, change, crush)
{
return EV_DoCeiling (DCeiling::ceilLowerInstant, ln, arg0, 0, 0, arg2*FRACUNIT*8, CRUSH(arg4), 0, CHANGE(arg3));
return EV_DoCeiling (DCeiling::ceilLowerInstant, ln, arg0, 0, 0, arg2*8, CRUSH(arg4), 0, CHANGE(arg3));
}
FUNC(LS_Ceiling_RaiseInstant)
// Ceiling_RaiseInstant (tag, unused, height, change)
{
return EV_DoCeiling (DCeiling::ceilRaiseInstant, ln, arg0, 0, 0, arg2*FRACUNIT*8, -1, 0, CHANGE(arg3));
return EV_DoCeiling (DCeiling::ceilRaiseInstant, ln, arg0, 0, 0, arg2*8, -1, 0, CHANGE(arg3));
}
FUNC(LS_Ceiling_CrushRaiseAndStayA)
@ -750,7 +750,7 @@ FUNC(LS_Ceiling_CrushAndRaiseA)
FUNC(LS_Ceiling_CrushAndRaiseDist)
// Ceiling_CrushAndRaiseDist (tag, dist, speed, damage, crushtype)
{
return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, SPEED(arg2), SPEED(arg2), arg1*FRACUNIT, arg3, 0, 0, CRUSHTYPE(arg4, arg2 == 8));
return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, SPEED(arg2), SPEED(arg2), arg1, arg3, 0, 0, CRUSHTYPE(arg4, arg2 == 8));
}
FUNC(LS_Ceiling_CrushAndRaiseSilentA)
@ -762,7 +762,7 @@ FUNC(LS_Ceiling_CrushAndRaiseSilentA)
FUNC(LS_Ceiling_CrushAndRaiseSilentDist)
// Ceiling_CrushAndRaiseSilentDist (tag, dist, upspeed, damage, crushtype)
{
return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, SPEED(arg2), SPEED(arg2), arg1*FRACUNIT, arg3, 1, 0, CRUSHTYPE(arg4, arg2 == 8));
return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, SPEED(arg2), SPEED(arg2), arg1, arg3, 1, 0, CRUSHTYPE(arg4, arg2 == 8));
}
FUNC(LS_Ceiling_RaiseToNearest)
@ -858,7 +858,7 @@ FUNC(LS_Generic_Ceiling)
}
}
return EV_DoCeiling (type, ln, arg0, SPEED(arg1), SPEED(arg1), arg2*FRACUNIT,
return EV_DoCeiling (type, ln, arg0, SPEED(arg1), SPEED(arg1), arg2,
(arg4 & 16) ? 20 : -1, 0, arg4 & 7);
}
@ -880,13 +880,13 @@ FUNC(LS_Generic_Crusher2)
FUNC(LS_Plat_PerpetualRaise)
// Plat_PerpetualRaise (tag, speed, delay)
{
return EV_DoPlat (arg0, ln, DPlat::platPerpetualRaise, 0, _f_SPEED(arg1), TICS(arg2), 8, 0);
return EV_DoPlat (arg0, ln, DPlat::platPerpetualRaise, 0, SPEED(arg1), TICS(arg2), 8, 0);
}
FUNC(LS_Plat_PerpetualRaiseLip)
// Plat_PerpetualRaiseLip (tag, speed, delay, lip)
{
return EV_DoPlat (arg0, ln, DPlat::platPerpetualRaise, 0, _f_SPEED(arg1), TICS(arg2), arg3, 0);
return EV_DoPlat (arg0, ln, DPlat::platPerpetualRaise, 0, SPEED(arg1), TICS(arg2), arg3, 0);
}
FUNC(LS_Plat_Stop)
@ -899,7 +899,7 @@ FUNC(LS_Plat_Stop)
FUNC(LS_Plat_DownWaitUpStay)
// Plat_DownWaitUpStay (tag, speed, delay)
{
return EV_DoPlat (arg0, ln, DPlat::platDownWaitUpStay, 0, _f_SPEED(arg1), TICS(arg2), 8, 0);
return EV_DoPlat (arg0, ln, DPlat::platDownWaitUpStay, 0, SPEED(arg1), TICS(arg2), 8, 0);
}
FUNC(LS_Plat_DownWaitUpStayLip)
@ -907,31 +907,31 @@ FUNC(LS_Plat_DownWaitUpStayLip)
{
return EV_DoPlat (arg0, ln,
arg4 ? DPlat::platDownWaitUpStayStone : DPlat::platDownWaitUpStay,
0, _f_SPEED(arg1), TICS(arg2), arg3, 0);
0, SPEED(arg1), TICS(arg2), arg3, 0);
}
FUNC(LS_Plat_DownByValue)
// Plat_DownByValue (tag, speed, delay, height)
{
return EV_DoPlat (arg0, ln, DPlat::platDownByValue, FRACUNIT*arg3*8, _f_SPEED(arg1), TICS(arg2), 0, 0);
return EV_DoPlat (arg0, ln, DPlat::platDownByValue, arg3*8, SPEED(arg1), TICS(arg2), 0, 0);
}
FUNC(LS_Plat_UpByValue)
// Plat_UpByValue (tag, speed, delay, height)
{
return EV_DoPlat (arg0, ln, DPlat::platUpByValue, FRACUNIT*arg3*8, _f_SPEED(arg1), TICS(arg2), 0, 0);
return EV_DoPlat (arg0, ln, DPlat::platUpByValue, arg3*8, SPEED(arg1), TICS(arg2), 0, 0);
}
FUNC(LS_Plat_UpWaitDownStay)
// Plat_UpWaitDownStay (tag, speed, delay)
{
return EV_DoPlat (arg0, ln, DPlat::platUpWaitDownStay, 0, _f_SPEED(arg1), TICS(arg2), 0, 0);
return EV_DoPlat (arg0, ln, DPlat::platUpWaitDownStay, 0, SPEED(arg1), TICS(arg2), 0, 0);
}
FUNC(LS_Plat_UpNearestWaitDownStay)
// Plat_UpNearestWaitDownStay (tag, speed, delay)
{
return EV_DoPlat (arg0, ln, DPlat::platUpNearestWaitDownStay, 0, _f_SPEED(arg1), TICS(arg2), 0, 0);
return EV_DoPlat (arg0, ln, DPlat::platUpNearestWaitDownStay, 0, SPEED(arg1), TICS(arg2), 0, 0);
}
FUNC(LS_Plat_RaiseAndStayTx0)
@ -953,13 +953,13 @@ FUNC(LS_Plat_RaiseAndStayTx0)
}
return EV_DoPlat (arg0, ln, type, 0, _f_SPEED(arg1), 0, 0, 1);
return EV_DoPlat (arg0, ln, type, 0, SPEED(arg1), 0, 0, 1);
}
FUNC(LS_Plat_UpByValueStayTx)
// Plat_UpByValueStayTx (tag, speed, height)
{
return EV_DoPlat (arg0, ln, DPlat::platUpByValueStay, FRACUNIT*arg2*8, _f_SPEED(arg1), 0, 0, 2);
return EV_DoPlat (arg0, ln, DPlat::platUpByValueStay, arg2*8, SPEED(arg1), 0, 0, 2);
}
FUNC(LS_Plat_ToggleCeiling)
@ -992,7 +992,7 @@ FUNC(LS_Generic_Lift)
break;
}
return EV_DoPlat (arg0, ln, type, arg4*8*FRACUNIT, _f_SPEED(arg1), OCTICS(arg2), 0, 0);
return EV_DoPlat (arg0, ln, type, arg4*8, SPEED(arg1), OCTICS(arg2), 0, 0);
}
FUNC(LS_Exit_Normal)
@ -1947,13 +1947,13 @@ FUNC(LS_FS_Execute)
FUNC(LS_FloorAndCeiling_LowerByValue)
// FloorAndCeiling_LowerByValue (tag, speed, height)
{
return EV_DoElevator (ln, DElevator::elevateLower, _f_SPEED(arg1), arg2*FRACUNIT, arg0);
return EV_DoElevator (ln, DElevator::elevateLower, SPEED(arg1), arg2, arg0);
}
FUNC(LS_FloorAndCeiling_RaiseByValue)
// FloorAndCeiling_RaiseByValue (tag, speed, height)
{
return EV_DoElevator (ln, DElevator::elevateRaise, _f_SPEED(arg1), arg2*FRACUNIT, arg0);
return EV_DoElevator (ln, DElevator::elevateRaise, SPEED(arg1), arg2, arg0);
}
FUNC(LS_FloorAndCeiling_LowerRaise)
@ -1966,7 +1966,7 @@ FUNC(LS_FloorAndCeiling_LowerRaise)
// more or less unintuitive value for the fourth arg to trigger Boom's broken behavior
if (arg3 != 1998 || !res) // (1998 for the year in which Boom was released... :P)
{
res |= EV_DoFloor (DFloor::floorLowerToLowest, ln, arg0, _f_SPEED(arg1), 0, -1, 0, false);
res |= EV_DoFloor (DFloor::floorLowerToLowest, ln, arg0, SPEED(arg1), 0, -1, 0, false);
}
return res;
}
@ -1974,19 +1974,19 @@ FUNC(LS_FloorAndCeiling_LowerRaise)
FUNC(LS_Elevator_MoveToFloor)
// Elevator_MoveToFloor (tag, speed)
{
return EV_DoElevator (ln, DElevator::elevateCurrent, _f_SPEED(arg1), 0, arg0);
return EV_DoElevator (ln, DElevator::elevateCurrent, SPEED(arg1), 0, arg0);
}
FUNC(LS_Elevator_RaiseToNearest)
// Elevator_RaiseToNearest (tag, speed)
{
return EV_DoElevator (ln, DElevator::elevateUp, _f_SPEED(arg1), 0, arg0);
return EV_DoElevator (ln, DElevator::elevateUp, SPEED(arg1), 0, arg0);
}
FUNC(LS_Elevator_LowerToNearest)
// Elevator_LowerToNearest (tag, speed)
{
return EV_DoElevator (ln, DElevator::elevateDown, _f_SPEED(arg1), 0, arg0);
return EV_DoElevator (ln, DElevator::elevateDown, SPEED(arg1), 0, arg0);
}
FUNC(LS_Light_ForceLightning)
@ -2764,7 +2764,7 @@ enum
PROP_FLIGHT,
PROP_UNUSED1,
PROP_UNUSED2,
PROP__f_SPEED,
PROP_SPEED,
PROP_BUDDHA,
};
@ -2779,7 +2779,7 @@ FUNC(LS_SetPlayerProperty)
return false;
// Add or remove a power
if (arg2 >= PROP_INVULNERABILITY && arg2 <= PROP__f_SPEED)
if (arg2 >= PROP_INVULNERABILITY && arg2 <= PROP_SPEED)
{
static PClass * const *powers[11] =
{

View file

@ -45,7 +45,7 @@ struct FTranslatedLineTarget;
#include <stdlib.h>
#define STEEPSLOPE 46342 // [RH] Minimum floorplane.fixC() value for walking
#define STEEPSLOPE (46342/65536.) // [RH] Minimum floorplane.c value for walking
#define BONUSADD 6
@ -293,10 +293,7 @@ enum
void P_FindFloorCeiling (AActor *actor, int flags=0);
bool P_ChangeSector (sector_t* sector, int crunch, double amt, int floorOrCeil, bool isreset);
inline bool P_ChangeSector(sector_t* sector, int crunch, int amt, int floorOrCeil, bool isreset)
{
return P_ChangeSector(sector, crunch, FIXED2DBL(amt), floorOrCeil, isreset);
}
inline bool P_ChangeSector(sector_t* sector, int crunch, int amt, int floorOrCeil, bool isreset) = delete;
DAngle P_AimLineAttack(AActor *t1, DAngle angle, double distance, FTranslatedLineTarget *pLineTarget = NULL, DAngle vrange = 0., int flags = 0, AActor *target = NULL, AActor *friender = NULL);
@ -328,11 +325,7 @@ void P_TraceBleed(int damage, FTranslatedLineTarget *t, AActor *puff); // hitsc
void P_TraceBleed (int damage, AActor *target); // random direction version
bool P_HitFloor (AActor *thing);
bool P_HitWater (AActor *thing, sector_t *sec, const DVector3 &pos, bool checkabove = false, bool alert = true, bool force = false);
inline bool P_HitWater(AActor *thing, sector_t *sec, const fixedvec3 &pos, bool checkabove = false, bool alert = true, bool force = false)
{
DVector3 fpos(FIXED2DBL(pos.x), FIXED2DBL(pos.y), FIXED2DBL(pos.z));
return P_HitWater(thing, sec, fpos, checkabove, alert, force);
}
inline bool P_HitWater(AActor *thing, sector_t *sec, const fixedvec3 &pos, bool checkabove = false, bool alert = true, bool force = false) = delete;
void P_CheckSplash(AActor *self, double distance);
struct FRailParams
@ -396,14 +389,7 @@ bool Check_Sides(AActor *, int, int); // phares
// [RH]
const secplane_t * P_CheckSlopeWalk(AActor *actor, DVector2 &move);
inline const secplane_t * P_CheckSlopeWalk(AActor *actor, fixed_t &xmove, fixed_t &ymove)
{
DVector2 move = { FIXED2DBL(xmove), FIXED2DBL(ymove) };
const secplane_t *ret = P_CheckSlopeWalk(actor, move);
xmove = FLOAT2FIXED(move.X);
ymove = FLOAT2FIXED(move.Y);
return ret;
}
inline const secplane_t * P_CheckSlopeWalk(AActor *actor, fixed_t &xmove, fixed_t &ymove) = delete;
//
// P_SETUP

View file

@ -526,8 +526,8 @@ double P_GetFriction(const AActor *mo, double *frictionfactor)
if (!(rover->flags & FF_EXISTS)) continue;
if (!(rover->flags & FF_SWIMMABLE)) continue;
if (mo->Z() > rover->top.plane->ZatPointF(mo) ||
mo->Z() < rover->bottom.plane->ZatPointF(mo))
if (mo->Z() > rover->top.plane->ZatPoint(mo) ||
mo->Z() < rover->bottom.plane->ZatPoint(mo))
continue;
newfriction = rover->model->GetFriction(rover->top.isceiling, &newmf);
@ -557,7 +557,7 @@ double P_GetFriction(const AActor *mo, double *frictionfactor)
if (rover->flags & FF_SOLID)
{
// Must be standing on a solid floor
if (mo->Z() != rover->top.plane->ZatPoint(pos)) continue;
if (!mo->isAtZ(rover->top.plane->ZatPoint(pos))) continue;
}
else if (rover->flags & FF_SWIMMABLE)
{
@ -573,7 +573,7 @@ double P_GetFriction(const AActor *mo, double *frictionfactor)
if (newfriction < friction || friction == ORIG_FRICTION)
{
friction = newfriction;
movefactor = newmf * 0.5;
movefactor = newmf;
}
}
@ -808,7 +808,7 @@ bool PIT_CheckLine(FMultiBlockLinesIterator &mit, FMultiBlockLinesIterator::Chec
if (!(tm.thing->flags & MF_DROPOFF) &&
!(tm.thing->flags & (MF_NOGRAVITY | MF_NOCLIP)))
{
if ((open.frontfloorplane.fixC() < STEEPSLOPE) != (open.backfloorplane.fixC() < STEEPSLOPE))
if ((open.frontfloorplane.fC() < STEEPSLOPE) != (open.backfloorplane.fC() < STEEPSLOPE))
{
// on the boundary of a steep slope
return false;
@ -2122,12 +2122,12 @@ bool P_TryMove(AActor *thing, const DVector2 &pos,
// it slopes or the player's eyes are bobbing in and out.
bool oldAboveFakeFloor, oldAboveFakeCeiling;
double _viewheight = thing->player ? thing->player->viewheight : thing->Height / 2;
double viewheight = thing->player ? thing->player->viewheight : thing->Height / 2;
oldAboveFakeFloor = oldAboveFakeCeiling = false; // pacify GCC
if (oldsec->heightsec)
{
double eyez = oldz + FIXED2DBL(viewheight);
double eyez = oldz + viewheight;
oldAboveFakeFloor = eyez > oldsec->heightsec->floorplane.ZatPoint(thing);
oldAboveFakeCeiling = eyez > oldsec->heightsec->ceilingplane.ZatPoint(thing);
@ -2333,7 +2333,7 @@ bool P_TryMove(AActor *thing, const DVector2 &pos,
if (newsec->heightsec && oldsec->heightsec && newsec->SecActTarget)
{
const sector_t *hs = newsec->heightsec;
double eyez = thing->Z() + FIXED2DBL(viewheight);
double eyez = thing->Z() + viewheight;
double fakez = hs->floorplane.ZatPoint(pos);
if (!oldAboveFakeFloor && eyez > fakez)
@ -2913,7 +2913,7 @@ const secplane_t * P_CheckSlopeWalk(AActor *actor, DVector2 &move)
{
if (!(rover->flags & FF_SOLID) || !(rover->flags & FF_EXISTS)) continue;
double thisplanez = rover->top.plane->ZatPointF(actor);
double thisplanez = rover->top.plane->ZatPoint(actor);
if (thisplanez > planezhere && thisplanez <= actor->Z() + actor->MaxStepHeight)
{
@ -2958,12 +2958,12 @@ const secplane_t * P_CheckSlopeWalk(AActor *actor, DVector2 &move)
const msecnode_t *node;
bool dopush = true;
if (plane->fixC() > STEEPSLOPE * 2 / 3)
if (plane->fC() > STEEPSLOPE * 2 / 3)
{
for (node = actor->touching_sectorlist; node; node = node->m_tnext)
{
sector_t *sec = node->m_sector;
if (sec->floorplane.fixC() >= STEEPSLOPE)
if (sec->floorplane.fC() >= STEEPSLOPE)
{
DVector3 pos = actor->PosRelative(sec) +move;
@ -3741,7 +3741,7 @@ struct aim_t
{
if (lastceilingplane)
{
double ff_top = lastceilingplane->ZatPointF(th);
double ff_top = lastceilingplane->ZatPoint(th);
DAngle pitch = -VecToAngle(dist, ff_top - shootz);
// upper slope intersects with this 3d-floor
if (pitch > toppitch)
@ -3751,7 +3751,7 @@ struct aim_t
}
if (lastfloorplane)
{
double ff_bottom = lastfloorplane->ZatPointF(th);
double ff_bottom = lastfloorplane->ZatPoint(th);
DAngle pitch = -VecToAngle(dist, ff_bottom - shootz);
// lower slope intersects with this 3d-floor
if (pitch < bottompitch)
@ -4411,7 +4411,7 @@ void P_TraceBleed(int damage, AActor *target, AActor *missile)
double aim;
aim = g_atan(missile->Vel.Z / target->Distance2D(missile));
pitch = -ToDegrees(aim);
pitch = -DAngle::ToDegrees(aim);
}
else
{

View file

@ -427,7 +427,7 @@ bool AActor::FixMapthingPos()
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));
ldef - lines, distance);
DAngle ang = ldef->Delta().Angle();
if (ldef->backsector != NULL && ldef->backsector == secstart)
{
@ -519,7 +519,8 @@ void AActor::LinkToWorld(bool spawningmapthing, sector_t *sector)
for (int i = -1; i < (int)check.Size(); i++)
{
fixedvec3 pos = i==-1? _f_Pos() : _f_PosRelative(check[i]);
DVector3 _pos = i==-1? Pos() : PosRelative(check[i]);
fixedvec3 pos = { FLOAT2FIXED(_pos.X), FLOAT2FIXED(_pos.Y),FLOAT2FIXED(_pos.Z) };
int x1 = GetSafeBlockX(pos.x - _f_radius() - bmaporgx);
int x2 = GetSafeBlockX(pos.x + _f_radius() - bmaporgx);

View file

@ -2175,7 +2175,7 @@ explode:
{ // Don't stop sliding if halfway off a step with some velocity
if (fabs(mo->Vel.X) > 0.25 || fabs(mo->Vel.Y) > 0.25)
{
if (mo->floorz > mo->Sector->floorplane.ZatPointF(mo))
if (mo->floorz > mo->Sector->floorplane.ZatPoint(mo))
{
if (mo->dropoffz != mo->floorz) // 3DMidtex or other special cases that must be excluded
{
@ -2186,7 +2186,7 @@ explode:
// if the floor comes from one in the current sector stop sliding the corpse!
F3DFloor * rover=mo->Sector->e->XFloor.ffloors[i];
if (!(rover->flags&FF_EXISTS)) continue;
if (rover->flags&FF_SOLID && rover->top.plane->ZatPointF(mo) == mo->floorz) break;
if (rover->flags&FF_SOLID && rover->top.plane->ZatPoint(mo) == mo->floorz) break;
}
if (i==mo->Sector->e->XFloor.ffloors.Size())
return Oldfloorz;
@ -2427,8 +2427,8 @@ void P_ZMovement (AActor *mo, double oldfloorz)
if (!(rover->flags & FF_EXISTS)) continue;
if (!(rover->flags & FF_SWIMMABLE)) continue;
if (mo->Z() >= rover->top.plane->ZatPointF(mo) ||
mo->Center() < rover->bottom.plane->ZatPointF(mo))
if (mo->Z() >= rover->top.plane->ZatPoint(mo) ||
mo->Center() < rover->bottom.plane->ZatPoint(mo))
continue;
friction = rover->model->GetFriction(rover->top.isceiling);
@ -2447,7 +2447,7 @@ void P_ZMovement (AActor *mo, double oldfloorz)
{ // Hit the floor
if ((!mo->player || !(mo->player->cheats & CF_PREDICTING)) &&
mo->Sector->SecActTarget != NULL &&
mo->Sector->floorplane.ZatPointF(mo) == mo->floorz)
mo->Sector->floorplane.ZatPoint(mo) == mo->floorz)
{ // [RH] Let the sector do something to the actor
mo->Sector->SecActTarget->TriggerAction (mo, SECSPAC_HitFloor);
}
@ -2547,7 +2547,7 @@ void P_ZMovement (AActor *mo, double oldfloorz)
{ // hit the ceiling
if ((!mo->player || !(mo->player->cheats & CF_PREDICTING)) &&
mo->Sector->SecActTarget != NULL &&
mo->Sector->ceilingplane.ZatPointF(mo) == mo->ceilingz)
mo->Sector->ceilingplane.ZatPoint(mo) == mo->ceilingz)
{ // [RH] Let the sector do something to the actor
mo->Sector->SecActTarget->TriggerAction (mo, SECSPAC_HitCeiling);
}
@ -2602,7 +2602,7 @@ void P_CheckFakeFloorTriggers (AActor *mo, double oldz, bool oldz_has_viewheight
if (sec->heightsec != NULL && sec->SecActTarget != NULL)
{
sector_t *hs = sec->heightsec;
double waterz = hs->floorplane.ZatPointF(mo);
double waterz = hs->floorplane.ZatPoint(mo);
double newz;
double viewheight;
@ -2637,7 +2637,7 @@ void P_CheckFakeFloorTriggers (AActor *mo, double oldz, bool oldz_has_viewheight
if (!(hs->MoreFlags & SECF_FAKEFLOORONLY))
{
waterz = hs->ceilingplane.ZatPointF(mo);
waterz = hs->ceilingplane.ZatPoint(mo);
if (oldz <= waterz && newz > waterz)
{ // View went above fake ceiling
sec->SecActTarget->TriggerAction (mo, SECSPAC_EyesAboveC);
@ -3644,18 +3644,18 @@ void AActor::Tick ()
// Check 3D floors as well
floorplane = P_FindFloorPlane(floorsector, PosAtZ(floorz));
if (floorplane.fixC() < STEEPSLOPE &&
if (floorplane.fC() < STEEPSLOPE &&
floorplane.ZatPoint (PosRelative(floorsector)) <= floorz)
{
const msecnode_t *node;
bool dopush = true;
if (floorplane.fixC() > STEEPSLOPE*2/3)
if (floorplane.fC() > STEEPSLOPE*2/3)
{
for (node = touching_sectorlist; node; node = node->m_tnext)
{
const sector_t *sec = node->m_sector;
if (sec->floorplane.fixC() >= STEEPSLOPE)
if (sec->floorplane.fC() >= STEEPSLOPE)
{
if (floorplane.ZatPoint(PosRelative(node->m_sector)) >= Z() - MaxStepHeight)
{
@ -3897,15 +3897,15 @@ void AActor::CheckSectorTransition(sector_t *oldsec)
if (Sector->SecActTarget != NULL)
{
int act = SECSPAC_Enter;
if (Z() <= Sector->floorplane.ZatPointF(this))
if (Z() <= Sector->floorplane.ZatPoint(this))
{
act |= SECSPAC_HitFloor;
}
if (Top() >= Sector->ceilingplane.ZatPointF(this))
if (Top() >= Sector->ceilingplane.ZatPoint(this))
{
act |= SECSPAC_HitCeiling;
}
if (Sector->heightsec != NULL && Z() == Sector->heightsec->floorplane.ZatPointF(this))
if (Sector->heightsec != NULL && Z() == Sector->heightsec->floorplane.ZatPoint(this))
{
act |= SECSPAC_HitFakeFloor;
}
@ -3952,7 +3952,7 @@ bool AActor::UpdateWaterLevel (bool dosplash)
const sector_t *hsec = Sector->GetHeightSec();
if (hsec != NULL)
{
fh = hsec->floorplane.ZatPointF (this);
fh = hsec->floorplane.ZatPoint (this);
//if (hsec->MoreFlags & SECF_UNDERWATERMASK) // also check Boom-style non-swimmable sectors
{
if (Z() < fh)
@ -3968,7 +3968,7 @@ bool AActor::UpdateWaterLevel (bool dosplash)
}
}
}
else if (!(hsec->MoreFlags & SECF_FAKEFLOORONLY) && (Top() > hsec->ceilingplane.ZatPointF (this)))
else if (!(hsec->MoreFlags & SECF_FAKEFLOORONLY) && (Top() > hsec->ceilingplane.ZatPoint (this)))
{
waterlevel = 3;
}
@ -3992,8 +3992,8 @@ bool AActor::UpdateWaterLevel (bool dosplash)
if (!(rover->flags & FF_EXISTS)) continue;
if(!(rover->flags & FF_SWIMMABLE) || rover->flags & FF_SOLID) continue;
double ff_bottom=rover->bottom.plane->ZatPointF(this);
double ff_top=rover->top.plane->ZatPointF(this);
double ff_bottom=rover->bottom.plane->ZatPoint(this);
double ff_top=rover->top.plane->ZatPoint(this);
if(ff_top <= Z() || ff_bottom > (Center())) continue;
@ -4174,7 +4174,7 @@ AActor *AActor::StaticSpawn (PClassActor *type, const DVector3 &pos, replace_t a
}
else
{
actor->SpawnPoint.Z = (actor->Z() - actor->Sector->floorplane.ZatPointF(actor));
actor->SpawnPoint.Z = (actor->Z() - actor->Sector->floorplane.ZatPoint(actor));
}
if (actor->FloatBobPhase == (BYTE)-1) actor->FloatBobPhase = rng(); // Don't make everything bob in sync (unless deliberately told to do)
@ -4420,7 +4420,7 @@ void AActor::AdjustFloorClip ()
const msecnode_t *m;
// possibly standing on a 3D-floor
if (Sector->e->XFloor.ffloors.Size() && Z() > Sector->floorplane.ZatPointF(this)) Floorclip = 0;
if (Sector->e->XFloor.ffloors.Size() && Z() > Sector->floorplane.ZatPoint(this)) Floorclip = 0;
// [RH] clip based on shallowest floor player is standing on
// If the sector has a deep water effect, then let that effect
@ -5522,7 +5522,7 @@ foundone:
if (smallsplash && splash->SmallSplash)
{
mo = Spawn (splash->SmallSplash, pos, ALLOW_REPLACE);
if (mo) mo->Floorclip += FIXED2DBL(splash->SmallSplashClip);
if (mo) mo->Floorclip += splash->SmallSplashClip;
}
else
{

View file

@ -89,10 +89,10 @@ void DPillar::Serialize (FArchive &arc)
void DPillar::Tick ()
{
int r, s;
fixed_t oldfloor, oldceiling;
double oldfloor, oldceiling;
oldfloor = m_Sector->floorplane.fixD();
oldceiling = m_Sector->ceilingplane.fixD();
oldfloor = m_Sector->floorplane.fD();
oldceiling = m_Sector->ceilingplane.fD();
if (m_Type == pillarBuild)
{
@ -123,11 +123,11 @@ void DPillar::Tick ()
}
}
DPillar::DPillar (sector_t *sector, EPillar type, fixed_t speed,
fixed_t floordist, fixed_t ceilingdist, int crush, bool hexencrush)
DPillar::DPillar (sector_t *sector, EPillar type, double speed,
double floordist, double ceilingdist, int crush, bool hexencrush)
: DMover (sector)
{
fixed_t newheight;
double newheight;
vertex_t *spot;
sector->floordata = sector->ceilingdata = this;
@ -144,15 +144,15 @@ DPillar::DPillar (sector_t *sector, EPillar type, fixed_t speed,
if (floordist == 0)
{
newheight = (sector->CenterFloor () + sector->CenterCeiling ()) / 2;
m_FloorTarget = sector->floorplane.PointToDist (sector->_f_centerspot(), newheight);
m_CeilingTarget = sector->ceilingplane.PointToDist (sector->_f_centerspot(), newheight);
m_FloorTarget = sector->floorplane.PointToDist (sector->centerspot, newheight);
m_CeilingTarget = sector->ceilingplane.PointToDist (sector->centerspot, newheight);
floordist = newheight - sector->CenterFloor ();
}
else
{
newheight = sector->CenterFloor () + floordist;
m_FloorTarget = sector->floorplane.PointToDist (sector->_f_centerspot(), newheight);
m_CeilingTarget = sector->ceilingplane.PointToDist (sector->_f_centerspot(), newheight);
m_FloorTarget = sector->floorplane.PointToDist (sector->centerspot, newheight);
m_CeilingTarget = sector->ceilingplane.PointToDist (sector->centerspot, newheight);
}
ceilingdist = sector->CenterCeiling () - newheight;
}
@ -169,7 +169,7 @@ DPillar::DPillar (sector_t *sector, EPillar type, fixed_t speed,
else
{
newheight = sector->CenterFloor() - floordist;
m_FloorTarget = sector->floorplane.PointToDist (sector->_f_centerspot(), newheight);
m_FloorTarget = sector->floorplane.PointToDist (sector->centerspot, newheight);
}
if (ceilingdist == 0)
{
@ -180,7 +180,7 @@ DPillar::DPillar (sector_t *sector, EPillar type, fixed_t speed,
else
{
newheight = sector->CenterCeiling() + ceilingdist;
m_CeilingTarget = sector->ceilingplane.PointToDist (sector->_f_centerspot(), newheight);
m_CeilingTarget = sector->ceilingplane.PointToDist (sector->centerspot, newheight);
}
}
@ -190,12 +190,12 @@ DPillar::DPillar (sector_t *sector, EPillar type, fixed_t speed,
if (floordist > ceilingdist)
{
m_FloorSpeed = speed;
m_CeilingSpeed = Scale (speed, ceilingdist, floordist);
m_CeilingSpeed = speed * ceilingdist / floordist;
}
else
{
m_CeilingSpeed = speed;
m_FloorSpeed = Scale (speed, floordist, ceilingdist);
m_FloorSpeed = speed * floordist / ceilingdist;
}
if (!(m_Sector->Flags & SECF_SILENTMOVE))
@ -216,7 +216,7 @@ DPillar::DPillar (sector_t *sector, EPillar type, fixed_t speed,
}
bool EV_DoPillar (DPillar::EPillar type, line_t *line, int tag,
fixed_t speed, fixed_t height, fixed_t height2, int crush, bool hexencrush)
double speed, double height, double height2, int crush, bool hexencrush)
{
int secnum;
sector_t *sec;
@ -231,7 +231,7 @@ bool EV_DoPillar (DPillar::EPillar type, line_t *line, int tag,
if (sec->PlaneMoving(sector_t::floor) || sec->PlaneMoving(sector_t::ceiling))
continue;
fixed_t flor, ceil;
double flor, ceil;
flor = sec->CenterFloor ();
ceil = sec->CenterCeiling ();

View file

@ -198,7 +198,7 @@ void DPlat::Tick ()
case waiting:
if (m_Count > 0 && !--m_Count)
{
if (m_Sector->floorplane.fixD() == m_Low)
if (m_Sector->floorplane.fD() == m_Low)
m_Status = up;
else
m_Status = down;
@ -225,15 +225,15 @@ DPlat::DPlat (sector_t *sector)
// [RH] Changed amount to height and added delay,
// lip, change, tag, and speed parameters.
//
bool EV_DoPlat (int tag, line_t *line, DPlat::EPlatType type, int height,
int speed, int delay, int lip, int change)
bool EV_DoPlat (int tag, line_t *line, DPlat::EPlatType type, double height,
double speed, int delay, int lip, int change)
{
DPlat *plat;
int secnum;
sector_t *sec;
bool rtn = false;
bool manual = false;
fixed_t newheight = 0;
double newheight = 0;
vertex_t *spot;
if (tag != 0)
@ -277,7 +277,7 @@ bool EV_DoPlat (int tag, line_t *line, DPlat::EPlatType type, int height,
//jff 1/26/98 Avoid raise plat bouncing a head off a ceiling and then
//going down forever -- default lower to plat height when triggered
plat->m_Low = sec->floorplane.fixD();
plat->m_Low = sec->floorplane.fD();
if (change)
{
@ -292,7 +292,7 @@ bool EV_DoPlat (int tag, line_t *line, DPlat::EPlatType type, int height,
case DPlat::platRaiseAndStayLockout:
newheight = sec->FindNextHighestFloor (&spot);
plat->m_High = sec->floorplane.PointToDist (spot, newheight);
plat->m_Low = sec->floorplane.fixD();
plat->m_Low = sec->floorplane.fD();
plat->m_Status = DPlat::up;
plat->PlayPlatSound ("Floor");
sec->ClearSpecial();
@ -300,30 +300,30 @@ bool EV_DoPlat (int tag, line_t *line, DPlat::EPlatType type, int height,
case DPlat::platUpByValue:
case DPlat::platUpByValueStay:
newheight = sec->floorplane.ZatPoint (0, 0) + height;
plat->m_High = sec->floorplane.PointToDist (0, 0, newheight);
plat->m_Low = sec->floorplane.fixD();
newheight = sec->floorplane.ZatPoint (sec->centerspot) + height;
plat->m_High = sec->floorplane.PointToDist (sec->centerspot, newheight);
plat->m_Low = sec->floorplane.fD();
plat->m_Status = DPlat::up;
plat->PlayPlatSound ("Floor");
break;
case DPlat::platDownByValue:
newheight = sec->floorplane.ZatPoint (0, 0) - height;
plat->m_Low = sec->floorplane.PointToDist (0, 0, newheight);
plat->m_High = sec->floorplane.fixD();
newheight = sec->floorplane.ZatPoint (sec->centerspot) - height;
plat->m_Low = sec->floorplane.PointToDist (sec->centerspot, newheight);
plat->m_High = sec->floorplane.fD();
plat->m_Status = DPlat::down;
plat->PlayPlatSound ("Floor");
break;
case DPlat::platDownWaitUpStay:
case DPlat::platDownWaitUpStayStone:
newheight = sec->FindLowestFloorSurrounding (&spot) + lip*FRACUNIT;
newheight = sec->FindLowestFloorSurrounding (&spot) + lip;
plat->m_Low = sec->floorplane.PointToDist (spot, newheight);
if (plat->m_Low < sec->floorplane.fixD())
plat->m_Low = sec->floorplane.fixD();
if (plat->m_Low < sec->floorplane.fD())
plat->m_Low = sec->floorplane.fD();
plat->m_High = sec->floorplane.fixD();
plat->m_High = sec->floorplane.fD();
plat->m_Status = DPlat::down;
plat->PlayPlatSound (type == DPlat::platDownWaitUpStay ? "Platform" : "Floor");
break;
@ -338,27 +338,27 @@ bool EV_DoPlat (int tag, line_t *line, DPlat::EPlatType type, int height,
newheight = sec->FindHighestFloorSurrounding (&spot);
}
plat->m_High = sec->floorplane.PointToDist (spot, newheight);
plat->m_Low = sec->floorplane.fixD();
plat->m_Low = sec->floorplane.fD();
if (plat->m_High > sec->floorplane.fixD())
plat->m_High = sec->floorplane.fixD();
if (plat->m_High > sec->floorplane.fD())
plat->m_High = sec->floorplane.fD();
plat->m_Status = DPlat::up;
plat->PlayPlatSound ("Platform");
break;
case DPlat::platPerpetualRaise:
newheight = sec->FindLowestFloorSurrounding (&spot) + lip*FRACUNIT;
newheight = sec->FindLowestFloorSurrounding (&spot) + lip;
plat->m_Low = sec->floorplane.PointToDist (spot, newheight);
if (plat->m_Low < sec->floorplane.fixD())
plat->m_Low = sec->floorplane.fixD();
if (plat->m_Low < sec->floorplane.fD())
plat->m_Low = sec->floorplane.fD();
newheight = sec->FindHighestFloorSurrounding (&spot);
plat->m_High = sec->floorplane.PointToDist (spot, newheight);
if (plat->m_High > sec->floorplane.fixD())
plat->m_High = sec->floorplane.fixD();
if (plat->m_High > sec->floorplane.fD())
plat->m_High = sec->floorplane.fD();
plat->m_Status = pr_doplat() & 1 ? DPlat::up : DPlat::down;
@ -371,26 +371,26 @@ bool EV_DoPlat (int tag, line_t *line, DPlat::EPlatType type, int height,
// set up toggling between ceiling, floor inclusive
newheight = sec->FindLowestCeilingPoint (&spot);
plat->m_Low = sec->floorplane.PointToDist (spot, newheight);
plat->m_High = sec->floorplane.fixD();
plat->m_High = sec->floorplane.fD();
plat->m_Status = DPlat::down;
SN_StartSequence (sec, CHAN_FLOOR, "Silence", 0);
break;
case DPlat::platDownToNearestFloor:
newheight = sec->FindNextLowestFloor (&spot) + lip*FRACUNIT;
newheight = sec->FindNextLowestFloor (&spot) + lip;
plat->m_Low = sec->floorplane.PointToDist (spot, newheight);
plat->m_Status = DPlat::down;
plat->m_High = sec->floorplane.fixD();
plat->m_High = sec->floorplane.fD();
plat->PlayPlatSound ("Platform");
break;
case DPlat::platDownToLowestCeiling:
newheight = sec->FindLowestCeilingSurrounding (&spot);
plat->m_Low = sec->floorplane.PointToDist (spot, newheight);
plat->m_High = sec->floorplane.fixD();
plat->m_High = sec->floorplane.fD();
if (plat->m_Low < sec->floorplane.fixD())
plat->m_Low = sec->floorplane.fixD();
if (plat->m_Low < sec->floorplane.fD())
plat->m_Low = sec->floorplane.fD();
plat->m_Status = DPlat::down;
plat->PlayPlatSound ("Platform");

View file

@ -183,8 +183,8 @@ void DScroller::Tick ()
if (m_Control != -1)
{ // compute scroll amounts based on a sector's height changes
double height = sectors[m_Control].CenterFloorF () +
sectors[m_Control].CenterCeilingF ();
double height = sectors[m_Control].CenterFloor () +
sectors[m_Control].CenterCeiling ();
double delta = height - m_LastHeight;
m_LastHeight = height;
dx *= delta;
@ -277,7 +277,7 @@ DScroller::DScroller (EScroll type, double dx, double dy,
m_vdx = m_vdy = 0;
if ((m_Control = control) != -1)
m_LastHeight =
sectors[control].CenterFloorF () + sectors[control].CenterCeilingF ();
sectors[control].CenterFloor () + sectors[control].CenterCeiling ();
m_Affectee = affectee;
m_Interpolations[0] = m_Interpolations[1] = m_Interpolations[2] = NULL;

View file

@ -63,19 +63,19 @@ sector_t *sector_t::NextSpecialSector (int type, sector_t *nogood) const
// P_FindLowestFloorSurrounding()
// FIND LOWEST FLOOR HEIGHT IN SURROUNDING SECTORS
//
fixed_t sector_t::FindLowestFloorSurrounding (vertex_t **v) const
double sector_t::FindLowestFloorSurrounding (vertex_t **v) const
{
int i;
sector_t *other;
line_t *check;
fixed_t floor;
fixed_t ofloor;
double floor;
double ofloor;
vertex_t *spot;
if (linecount == 0) return GetPlaneTexZ(sector_t::floor);
if (linecount == 0) return GetPlaneTexZF(sector_t::floor);
spot = lines[0]->v1;
floor = floorplane.ZatPoint (spot);
floor = floorplane.ZatPoint(spot);
for (i = 0; i < linecount; i++)
{
@ -107,19 +107,19 @@ fixed_t sector_t::FindLowestFloorSurrounding (vertex_t **v) const
// P_FindHighestFloorSurrounding()
// FIND HIGHEST FLOOR HEIGHT IN SURROUNDING SECTORS
//
fixed_t sector_t::FindHighestFloorSurrounding (vertex_t **v) const
double sector_t::FindHighestFloorSurrounding (vertex_t **v) const
{
int i;
line_t *check;
sector_t *other;
fixed_t floor;
fixed_t ofloor;
double floor;
double ofloor;
vertex_t *spot;
if (linecount == 0) return GetPlaneTexZ(sector_t::floor);
if (linecount == 0) return GetPlaneTexZF(sector_t::floor);
spot = lines[0]->v1;
floor = FIXED_MIN;
floor = -FLT_MAX;
for (i = 0; i < linecount; i++)
{
@ -157,21 +157,21 @@ fixed_t sector_t::FindHighestFloorSurrounding (vertex_t **v) const
//
// Rewritten by Lee Killough to avoid fixed array and to be faster
//
fixed_t sector_t::FindNextHighestFloor (vertex_t **v) const
double sector_t::FindNextHighestFloor (vertex_t **v) const
{
fixed_t height;
fixed_t heightdiff;
fixed_t ofloor, floor;
double height;
double heightdiff;
double ofloor, floor;
sector_t *other;
vertex_t *spot;
line_t *check;
int i;
if (linecount == 0) return GetPlaneTexZ(sector_t::floor);
if (linecount == 0) return GetPlaneTexZF(sector_t::floor);
spot = lines[0]->v1;
height = floorplane.ZatPoint (spot);
heightdiff = FIXED_MAX;
height = floorplane.ZatPoint(spot);
heightdiff = FLT_MAX;
for (i = 0; i < linecount; i++)
{
@ -212,21 +212,21 @@ fixed_t sector_t::FindNextHighestFloor (vertex_t **v) const
//
// jff 02/03/98 Twiddled Lee's P_FindNextHighestFloor to make this
//
fixed_t sector_t::FindNextLowestFloor (vertex_t **v) const
double sector_t::FindNextLowestFloor (vertex_t **v) const
{
fixed_t height;
fixed_t heightdiff;
fixed_t ofloor, floor;
double height;
double heightdiff;
double ofloor, floor;
sector_t *other;
vertex_t *spot;
line_t *check;
int i;
if (linecount == 0) return GetPlaneTexZ(sector_t::floor);
if (linecount == 0) return GetPlaneTexZF(sector_t::floor);
spot = lines[0]->v1;
height = floorplane.ZatPoint (spot);
heightdiff = FIXED_MAX;
heightdiff = FLT_MAX;
for (i = 0; i < linecount; i++)
{
@ -242,7 +242,7 @@ fixed_t sector_t::FindNextLowestFloor (vertex_t **v) const
spot = check->v1;
}
ofloor = other->floorplane.ZatPoint (check->v2);
floor = floorplane.ZatPoint (check->v2);
floor = floorplane.ZatPoint(check->v2);
if (ofloor < floor && floor - ofloor < heightdiff && !IsLinked(other, false))
{
heightdiff = floor - ofloor;
@ -266,38 +266,38 @@ fixed_t sector_t::FindNextLowestFloor (vertex_t **v) const
//
// jff 02/03/98 Twiddled Lee's P_FindNextHighestFloor to make this
//
fixed_t sector_t::FindNextLowestCeiling (vertex_t **v) const
double sector_t::FindNextLowestCeiling (vertex_t **v) const
{
fixed_t height;
fixed_t heightdiff;
fixed_t oceil, ceil;
double height;
double heightdiff;
double oceil, ceil;
sector_t *other;
vertex_t *spot;
line_t *check;
int i;
if (linecount == 0) return GetPlaneTexZ(sector_t::ceiling);
if (linecount == 0) return GetPlaneTexZF(sector_t::ceiling);
spot = lines[0]->v1;
height = ceilingplane.ZatPoint (spot);
heightdiff = FIXED_MAX;
height = ceilingplane.ZatPoint(spot);
heightdiff = FLT_MAX;
for (i = 0; i < linecount; i++)
{
check = lines[i];
if (NULL != (other = getNextSector (check, this)))
{
oceil = other->ceilingplane.ZatPoint (check->v1);
ceil = ceilingplane.ZatPoint (check->v1);
oceil = other->ceilingplane.ZatPoint(check->v1);
ceil = ceilingplane.ZatPoint(check->v1);
if (oceil < ceil && ceil - oceil < heightdiff && !IsLinked(other, true))
{
heightdiff = ceil - oceil;
height = oceil;
spot = check->v1;
}
oceil = other->ceilingplane.ZatPoint (check->v2);
ceil = ceilingplane.ZatPoint (check->v2);
oceil = other->ceilingplane.ZatPoint(check->v2);
ceil = ceilingplane.ZatPoint(check->v2);
if (oceil < ceil && ceil - oceil < heightdiff && !IsLinked(other, true))
{
heightdiff = ceil - oceil;
@ -321,37 +321,37 @@ fixed_t sector_t::FindNextLowestCeiling (vertex_t **v) const
//
// jff 02/03/98 Twiddled Lee's P_FindNextHighestFloor to make this
//
fixed_t sector_t::FindNextHighestCeiling (vertex_t **v) const
double sector_t::FindNextHighestCeiling (vertex_t **v) const
{
fixed_t height;
fixed_t heightdiff;
fixed_t oceil, ceil;
double height;
double heightdiff;
double oceil, ceil;
sector_t *other;
vertex_t *spot;
line_t *check;
int i;
if (linecount == 0) return GetPlaneTexZ(sector_t::ceiling);
if (linecount == 0) return GetPlaneTexZF(sector_t::ceiling);
spot = lines[0]->v1;
height = ceilingplane.ZatPoint (spot);
heightdiff = FIXED_MAX;
height = ceilingplane.ZatPoint(spot);
heightdiff = FLT_MAX;
for (i = 0; i < linecount; i++)
{
check = lines[i];
if (NULL != (other = getNextSector (check, this)))
{
oceil = other->ceilingplane.ZatPoint (check->v1);
ceil = ceilingplane.ZatPoint (check->v1);
oceil = other->ceilingplane.ZatPoint(check->v1);
ceil = ceilingplane.ZatPoint(check->v1);
if (oceil > ceil && oceil - ceil < heightdiff && !IsLinked(other, true))
{
heightdiff = oceil - ceil;
height = oceil;
spot = check->v1;
}
oceil = other->ceilingplane.ZatPoint (check->v2);
ceil = ceilingplane.ZatPoint (check->v2);
oceil = other->ceilingplane.ZatPoint(check->v2);
ceil = ceilingplane.ZatPoint(check->v2);
if (oceil > ceil && oceil - ceil < heightdiff && !IsLinked(other, true))
{
heightdiff = oceil - ceil;
@ -368,32 +368,32 @@ fixed_t sector_t::FindNextHighestCeiling (vertex_t **v) const
//
// FIND LOWEST CEILING IN THE SURROUNDING SECTORS
//
fixed_t sector_t::FindLowestCeilingSurrounding (vertex_t **v) const
double sector_t::FindLowestCeilingSurrounding (vertex_t **v) const
{
fixed_t height;
fixed_t oceil;
double height;
double oceil;
sector_t *other;
vertex_t *spot;
line_t *check;
int i;
if (linecount == 0) return GetPlaneTexZ(sector_t::ceiling);
if (linecount == 0) return GetPlaneTexZF(sector_t::ceiling);
spot = lines[0]->v1;
height = FIXED_MAX;
height = FLT_MAX;
for (i = 0; i < linecount; i++)
{
check = lines[i];
if (NULL != (other = getNextSector (check, this)))
{
oceil = other->ceilingplane.ZatPoint (check->v1);
oceil = other->ceilingplane.ZatPoint(check->v1);
if (oceil < height)
{
height = oceil;
spot = check->v1;
}
oceil = other->ceilingplane.ZatPoint (check->v2);
oceil = other->ceilingplane.ZatPoint(check->v2);
if (oceil < height)
{
height = oceil;
@ -410,32 +410,32 @@ fixed_t sector_t::FindLowestCeilingSurrounding (vertex_t **v) const
//
// FIND HIGHEST CEILING IN THE SURROUNDING SECTORS
//
fixed_t sector_t::FindHighestCeilingSurrounding (vertex_t **v) const
double sector_t::FindHighestCeilingSurrounding (vertex_t **v) const
{
fixed_t height;
fixed_t oceil;
double height;
double oceil;
sector_t *other;
vertex_t *spot;
line_t *check;
int i;
if (linecount == 0) return GetPlaneTexZ(sector_t::ceiling);
if (linecount == 0) return GetPlaneTexZF(sector_t::ceiling);
spot = lines[0]->v1;
height = FIXED_MIN;
height = -FLT_MAX;
for (i = 0; i < linecount; i++)
{
check = lines[i];
if (NULL != (other = getNextSector (check, this)))
{
oceil = other->ceilingplane.ZatPoint (check->v1);
oceil = other->ceilingplane.ZatPoint(check->v1);
if (oceil > height)
{
height = oceil;
spot = check->v1;
}
oceil = other->ceilingplane.ZatPoint (check->v2);
oceil = other->ceilingplane.ZatPoint(check->v2);
if (oceil > height)
{
height = oceil;
@ -457,14 +457,14 @@ fixed_t sector_t::FindHighestCeilingSurrounding (vertex_t **v) const
// jff 02/03/98 Add routine to find shortest lower texture
//
static inline void CheckShortestTex (FTextureID texnum, fixed_t &minsize)
static inline void CheckShortestTex (FTextureID texnum, double &minsize)
{
if (texnum.isValid() || (texnum.isNull() && (i_compatflags & COMPATF_SHORTTEX)))
{
FTexture *tex = TexMan[texnum];
if (tex != NULL)
{
fixed_t h = tex->GetScaledHeight()<<FRACBITS;
double h = tex->GetScaledHeight();
if (h < minsize)
{
minsize = h;
@ -473,9 +473,9 @@ static inline void CheckShortestTex (FTextureID texnum, fixed_t &minsize)
}
}
fixed_t sector_t::FindShortestTextureAround () const
double sector_t::FindShortestTextureAround () const
{
fixed_t minsize = FIXED_MAX;
double minsize = FLT_MAX;
for (int i = 0; i < linecount; i++)
{
@ -485,7 +485,7 @@ fixed_t sector_t::FindShortestTextureAround () const
CheckShortestTex (lines[i]->sidedef[1]->GetTexture(side_t::bottom), minsize);
}
}
return minsize < FIXED_MAX ? minsize : TexMan[0]->GetHeight() * FRACUNIT;
return minsize < FLT_MAX ? minsize : TexMan[0]->GetHeight();
}
@ -499,9 +499,9 @@ fixed_t sector_t::FindShortestTextureAround () const
//
// jff 03/20/98 Add routine to find shortest upper texture
//
fixed_t sector_t::FindShortestUpperAround () const
double sector_t::FindShortestUpperAround () const
{
fixed_t minsize = FIXED_MAX;
double minsize = FLT_MAX;
for (int i = 0; i < linecount; i++)
{
@ -511,7 +511,7 @@ fixed_t sector_t::FindShortestUpperAround () const
CheckShortestTex (lines[i]->sidedef[1]->GetTexture(side_t::top), minsize);
}
}
return minsize < FIXED_MAX ? minsize : TexMan[0]->GetHeight() * FRACUNIT;
return minsize < FLT_MAX ? minsize : TexMan[0]->GetHeight();
}
@ -529,7 +529,7 @@ fixed_t sector_t::FindShortestUpperAround () const
// jff 3/14/98 change first parameter to plain height to allow call
// from routine not using floormove_t
//
sector_t *sector_t::FindModelFloorSector (fixed_t floordestheight) const
sector_t *sector_t::FindModelFloorSector (double floordestheight) const
{
int i;
sector_t *sec;
@ -540,8 +540,8 @@ sector_t *sector_t::FindModelFloorSector (fixed_t floordestheight) const
{
sec = getNextSector (lines[i], this);
if (sec != NULL &&
(sec->floorplane.ZatPoint (lines[i]->v1) == floordestheight ||
sec->floorplane.ZatPoint (lines[i]->v2) == floordestheight))
(sec->floorplane.ZatPoint(lines[i]->v1) == floordestheight ||
sec->floorplane.ZatPoint(lines[i]->v2) == floordestheight))
{
return sec;
}
@ -565,7 +565,7 @@ sector_t *sector_t::FindModelFloorSector (fixed_t floordestheight) const
// jff 3/14/98 change first parameter to plain height to allow call
// from routine not using ceiling_t
//
sector_t *sector_t::FindModelCeilingSector (fixed_t floordestheight) const
sector_t *sector_t::FindModelCeilingSector (double floordestheight) const
{
int i;
sector_t *sec;
@ -576,8 +576,8 @@ sector_t *sector_t::FindModelCeilingSector (fixed_t floordestheight) const
{
sec = getNextSector (lines[i], this);
if (sec != NULL &&
(sec->ceilingplane.ZatPoint (lines[i]->v1) == floordestheight ||
sec->ceilingplane.ZatPoint (lines[i]->v2) == floordestheight))
(sec->ceilingplane.ZatPoint(lines[i]->v1) == floordestheight ||
sec->ceilingplane.ZatPoint(lines[i]->v2) == floordestheight))
{
return sec;
}
@ -609,12 +609,12 @@ int sector_t::FindMinSurroundingLight (int min) const
//
// Find the highest point on the floor of the sector
//
fixed_t sector_t::FindHighestFloorPoint (vertex_t **v) const
double sector_t::FindHighestFloorPoint (vertex_t **v) const
{
int i;
line_t *line;
fixed_t height = FIXED_MIN;
fixed_t probeheight;
double height = -FLT_MAX;
double probeheight;
vertex_t *spot = NULL;
if (!floorplane.isSlope())
@ -624,19 +624,19 @@ fixed_t sector_t::FindHighestFloorPoint (vertex_t **v) const
if (linecount == 0) *v = &vertexes[0];
else *v = lines[0]->v1;
}
return floorplane.Zat0();
return floorplane.fD();
}
for (i = 0; i < linecount; i++)
{
line = lines[i];
probeheight = floorplane.ZatPoint (line->v1);
probeheight = floorplane.ZatPoint(line->v1);
if (probeheight > height)
{
height = probeheight;
spot = line->v1;
}
probeheight = floorplane.ZatPoint (line->v2);
probeheight = floorplane.ZatPoint(line->v2);
if (probeheight > height)
{
height = probeheight;
@ -651,12 +651,12 @@ fixed_t sector_t::FindHighestFloorPoint (vertex_t **v) const
//
// Find the lowest point on the ceiling of the sector
//
fixed_t sector_t::FindLowestCeilingPoint (vertex_t **v) const
double sector_t::FindLowestCeilingPoint (vertex_t **v) const
{
int i;
line_t *line;
fixed_t height = FIXED_MAX;
fixed_t probeheight;
double height = FLT_MAX;
double probeheight;
vertex_t *spot = NULL;
if (!ceilingplane.isSlope())
@ -666,19 +666,19 @@ fixed_t sector_t::FindLowestCeilingPoint (vertex_t **v) const
if (linecount == 0) *v = &vertexes[0];
else *v = lines[0]->v1;
}
return ceilingplane.fixD();
return ceilingplane.fD();
}
for (i = 0; i < linecount; i++)
{
line = lines[i];
probeheight = ceilingplane.ZatPoint (line->v1);
probeheight = ceilingplane.ZatPoint(line->v1);
if (probeheight < height)
{
height = probeheight;
spot = line->v1;
}
probeheight = ceilingplane.ZatPoint (line->v2);
probeheight = ceilingplane.ZatPoint(line->v2);
if (probeheight < height)
{
height = probeheight;
@ -892,14 +892,14 @@ void sector_t::CheckPortalPlane(int plane)
double sector_t::HighestCeilingAt(const DVector2 &p, sector_t **resultsec)
{
sector_t *check = this;
fixed_t planeheight = FIXED_MIN;
double planeheight = -FLT_MAX;
DVector2 pos = p;
// Continue until we find a blocking portal or a portal below where we actually are.
while (!check->PortalBlocksMovement(ceiling) && planeheight < FLOAT2FIXED(check->SkyBoxes[ceiling]->specialf1))
while (!check->PortalBlocksMovement(ceiling) && planeheight < check->SkyBoxes[ceiling]->specialf1)
{
pos += check->CeilingDisplacement();
planeheight = FLOAT2FIXED(check->SkyBoxes[ceiling]->specialf1);
planeheight = check->SkyBoxes[ceiling]->specialf1;
check = P_PointInSector(pos);
}
if (resultsec) *resultsec = check;
@ -915,14 +915,14 @@ double sector_t::HighestCeilingAt(const DVector2 &p, sector_t **resultsec)
double sector_t::LowestFloorAt(const DVector2 &p, sector_t **resultsec)
{
sector_t *check = this;
fixed_t planeheight = FIXED_MAX;
double planeheight = FLT_MAX;
DVector2 pos = p;
// Continue until we find a blocking portal or a portal above where we actually are.
while (!check->PortalBlocksMovement(floor) && planeheight > FLOAT2FIXED(check->SkyBoxes[floor]->specialf1))
while (!check->PortalBlocksMovement(floor) && planeheight > check->SkyBoxes[floor]->specialf1)
{
pos += check->FloorDisplacement();
planeheight = FLOAT2FIXED(check->SkyBoxes[floor]->specialf1);
planeheight = check->SkyBoxes[floor]->specialf1;
check = P_PointInSector(pos);
}
if (resultsec) *resultsec = check;
@ -930,34 +930,34 @@ double sector_t::LowestFloorAt(const DVector2 &p, sector_t **resultsec)
}
fixed_t sector_t::NextHighestCeilingAt(fixed_t x, fixed_t y, fixed_t bottomz, fixed_t topz, int flags, sector_t **resultsec, F3DFloor **resultffloor)
double sector_t::NextHighestCeilingAt(double x, double y, double bottomz, double topz, int flags, sector_t **resultsec, F3DFloor **resultffloor)
{
sector_t *sec = this;
fixed_t planeheight = FIXED_MIN;
double planeheight = -FLT_MAX;
while (true)
{
// Looking through planes from bottom to top
fixed_t realceil = sec->ceilingplane.ZatPoint(x, y);
double realceil = sec->ceilingplane.ZatPoint(x, y);
for (int i = sec->e->XFloor.ffloors.Size() - 1; i >= 0; --i)
{
F3DFloor *rover = sec->e->XFloor.ffloors[i];
if (!(rover->flags & FF_SOLID) || !(rover->flags & FF_EXISTS)) continue;
fixed_t ff_bottom = rover->bottom.plane->ZatPoint(x, y);
fixed_t ff_top = rover->top.plane->ZatPoint(x, y);
double ff_bottom = rover->bottom.plane->ZatPoint(x, y);
double ff_top = rover->top.plane->ZatPoint(x, y);
fixed_t delta1 = bottomz - (ff_bottom + ((ff_top - ff_bottom) / 2));
fixed_t delta2 = topz - (ff_bottom + ((ff_top - ff_bottom) / 2));
double delta1 = bottomz - (ff_bottom + ((ff_top - ff_bottom) / 2));
double delta2 = topz - (ff_bottom + ((ff_top - ff_bottom) / 2));
if (ff_bottom < realceil && abs(delta1) > abs(delta2))
if (ff_bottom < realceil && fabs(delta1) > fabs(delta2))
{
if (resultsec) *resultsec = sec;
if (resultffloor) *resultffloor = rover;
return ff_bottom;
}
}
if ((flags & FFCF_NOPORTALS) || sec->PortalBlocksMovement(ceiling) || planeheight >= FLOAT2FIXED(sec->SkyBoxes[ceiling]->specialf1))
if ((flags & FFCF_NOPORTALS) || sec->PortalBlocksMovement(ceiling) || planeheight >= sec->SkyBoxes[ceiling]->specialf1)
{ // Use sector's floor
if (resultffloor) *resultffloor = NULL;
if (resultsec) *resultsec = sec;
@ -966,23 +966,23 @@ fixed_t sector_t::NextHighestCeilingAt(fixed_t x, fixed_t y, fixed_t bottomz, fi
else
{
DVector2 pos = sec->CeilingDisplacement();
x += FLOAT2FIXED(pos.X);
y += FLOAT2FIXED(pos.Y);
planeheight = FLOAT2FIXED(sec->SkyBoxes[ceiling]->specialf1);
x += pos.X;
y += pos.Y;
planeheight = sec->SkyBoxes[ceiling]->specialf1;
sec = P_PointInSector(x, y);
}
}
}
fixed_t sector_t::NextLowestFloorAt(fixed_t x, fixed_t y, fixed_t z, int flags, fixed_t steph, sector_t **resultsec, F3DFloor **resultffloor)
double sector_t::NextLowestFloorAt(double x, double y, double z, int flags, double steph, sector_t **resultsec, F3DFloor **resultffloor)
{
sector_t *sec = this;
fixed_t planeheight = FIXED_MAX;
double planeheight = FLT_MAX;
while (true)
{
// Looking through planes from top to bottom
unsigned numff = sec->e->XFloor.ffloors.Size();
fixed_t realfloor = sec->floorplane.ZatPoint(x, y);
double realfloor = sec->floorplane.ZatPoint(x, y);
for (unsigned i = 0; i < numff; ++i)
{
F3DFloor *ff = sec->e->XFloor.ffloors[i];
@ -991,8 +991,8 @@ fixed_t sector_t::NextLowestFloorAt(fixed_t x, fixed_t y, fixed_t z, int flags,
// either with feet above the 3D floor or feet with less than 'stepheight' map units inside
if ((ff->flags & (FF_EXISTS | FF_SOLID)) == (FF_EXISTS | FF_SOLID))
{
fixed_t ffz = ff->top.plane->ZatPoint(x, y);
fixed_t ffb = ff->bottom.plane->ZatPoint(x, y);
double ffz = ff->top.plane->ZatPoint(x, y);
double ffb = ff->bottom.plane->ZatPoint(x, y);
if (ffz > realfloor && (z >= ffz || (!(flags & FFCF_3DRESTRICT) && (ffb < z && ffz < z + steph))))
{ // This floor is beneath our feet.
@ -1002,7 +1002,7 @@ fixed_t sector_t::NextLowestFloorAt(fixed_t x, fixed_t y, fixed_t z, int flags,
}
}
}
if ((flags & FFCF_NOPORTALS) || sec->PortalBlocksMovement(sector_t::floor) || planeheight <= FLOAT2FIXED(sec->SkyBoxes[floor]->specialf1))
if ((flags & FFCF_NOPORTALS) || sec->PortalBlocksMovement(sector_t::floor) || planeheight <= sec->SkyBoxes[floor]->specialf1)
{ // Use sector's floor
if (resultffloor) *resultffloor = NULL;
if (resultsec) *resultsec = sec;
@ -1011,9 +1011,9 @@ fixed_t sector_t::NextLowestFloorAt(fixed_t x, fixed_t y, fixed_t z, int flags,
else
{
DVector2 pos = sec->FloorDisplacement();
x += FLOAT2FIXED(pos.X);
y += FLOAT2FIXED(pos.Y);
planeheight = FLOAT2FIXED(sec->SkyBoxes[floor]->specialf1);
x += pos.X;
y += pos.Y;
planeheight = sec->SkyBoxes[floor]->specialf1;
sec = P_PointInSector(x, y);
}
}
@ -1087,18 +1087,18 @@ bool secplane_t::CopyPlaneIfValid (secplane_t *dest, const secplane_t *opp) cons
// If the planes do not have matching slopes, then always copy them
// because clipping would require creating new sectors.
if (a != dest->a || b != dest->b || c != dest->c)
if (fA() != dest->fA() || fB() != dest->fB() || fC() != dest->fC())
{
copy = true;
}
else if (opp->a != -dest->a || opp->b != -dest->b || opp->c != -dest->c)
else if (opp->fA() != -dest->fA() || opp->fB() != -dest->fB() || opp->fC() != -dest->fC())
{
if (d < dest->d)
if (fD() < dest->fD())
{
copy = true;
}
}
else if (d < dest->d && d > -opp->d)
else if (fD() < dest->fD() && fD() > -opp->fD())
{
copy = true;
}
@ -1136,21 +1136,19 @@ bool P_AlignFlat (int linenum, int side, int fc)
if (!sec)
return false;
fixed_t x = line->v1->fixX();
fixed_t y = line->v1->fixY();
angle_t angle = R_PointToAngle2 (x, y, line->v2->fixX(), line->v2->fixY());
angle_t norm = (angle-ANGLE_90) >> ANGLETOFINESHIFT;
fixed_t dist = -DMulScale16 (finecosine[norm], x, finesine[norm], y);
DVector2 pos = line->v1->fPos();
DVector2 pos2 = line->v2->fPos();
DAngle angle = (pos2 - pos).Angle();
DAngle norm = angle - 90;
double dist = norm.Cos() * pos.X + norm.Sin() * pos.Y;
if (side)
{
angle = angle + ANGLE_180;
angle += 180.;
dist = -dist;
}
sec->SetBase(fc, dist & ((1<<(FRACBITS+8))-1), 0-angle);
sec->SetBase(fc, dist, -angle);
return true;
}

View file

@ -119,7 +119,7 @@ void P_TranslateLineDef (line_t *ld, maplinedef_t *mld, int lineindexforid = -1)
int P_TranslateSectorSpecial (int);
int GetUDMFInt(int type, int index, const char *key);
fixed_t GetUDMFFixed(int type, int index, const char *key);
double GetUDMFFloat(int type, int index, const char *key);
bool P_LoadGLNodes(MapData * map);
bool P_CheckNodes(MapData * map, bool rebuilt, int buildtime);

View file

@ -561,8 +561,8 @@ bool SightCheck::P_SightTraverseIntercepts ()
if ((rover->flags & FF_SOLID) == myseethrough || !(rover->flags & FF_EXISTS)) continue;
if ((Flags & SF_IGNOREWATERBOUNDARY) && (rover->flags & FF_SOLID) == 0) continue;
double ff_bottom = rover->bottom.plane->ZatPointF(seeingthing);
double ff_top = rover->top.plane->ZatPointF(seeingthing);
double ff_bottom = rover->bottom.plane->ZatPoint(seeingthing);
double ff_top = rover->top.plane->ZatPoint(seeingthing);
if (Lastztop <= ff_bottom && topz > ff_bottom && Lastzbottom <= ff_bottom && bottomz > ff_bottom) return false;
if (Lastzbottom >= ff_top && bottomz < ff_top && Lastztop >= ff_top && topz < ff_top) return false;
@ -849,16 +849,16 @@ sightcounts[0]++;
if (!(flags & SF_IGNOREWATERBOUNDARY))
{
if ((s1->GetHeightSec() &&
((t1->Top() <= s1->heightsec->floorplane.ZatPointF(t1) &&
t2->Z() >= s1->heightsec->floorplane.ZatPointF(t2)) ||
(t1->Z() >= s1->heightsec->ceilingplane.ZatPointF(t1) &&
t2->Top() <= s1->heightsec->ceilingplane.ZatPointF(t2))))
((t1->Top() <= s1->heightsec->floorplane.ZatPoint(t1) &&
t2->Z() >= s1->heightsec->floorplane.ZatPoint(t2)) ||
(t1->Z() >= s1->heightsec->ceilingplane.ZatPoint(t1) &&
t2->Top() <= s1->heightsec->ceilingplane.ZatPoint(t2))))
||
(s2->GetHeightSec() &&
((t2->Top() <= s2->heightsec->floorplane.ZatPointF(t2) &&
t1->Z() >= s2->heightsec->floorplane.ZatPointF(t1)) ||
(t2->Z() >= s2->heightsec->ceilingplane.ZatPointF(t2) &&
t1->Top() <= s2->heightsec->ceilingplane.ZatPointF(t1)))))
((t2->Top() <= s2->heightsec->floorplane.ZatPoint(t2) &&
t1->Z() >= s2->heightsec->floorplane.ZatPoint(t1)) ||
(t2->Z() >= s2->heightsec->ceilingplane.ZatPoint(t2) &&
t1->Top() <= s2->heightsec->ceilingplane.ZatPoint(t1)))))
{
res = false;
goto done;

View file

@ -45,7 +45,7 @@
//
//===========================================================================
static void P_SlopeLineToPoint (int lineid, fixed_t x, fixed_t y, fixed_t z, bool slopeCeil)
static void P_SlopeLineToPoint (int lineid, const DVector3 &pos, bool slopeCeil)
{
int linenum;
@ -56,7 +56,7 @@ static void P_SlopeLineToPoint (int lineid, fixed_t x, fixed_t y, fixed_t z, boo
sector_t *sec;
secplane_t *plane;
if (P_PointOnLineSidePrecise (x, y, line) == 0)
if (P_PointOnLineSidePrecise (pos, line) == 0)
{
sec = line->frontsector;
}
@ -81,19 +81,19 @@ static void P_SlopeLineToPoint (int lineid, fixed_t x, fixed_t y, fixed_t z, boo
p[0] = line->v1->fX();
p[1] = line->v1->fY();
p[2] = plane->ZatPointF (line->v1);
p[2] = plane->ZatPoint (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];
v1[2] = plane->ZatPoint (line->v2) - p[2];
v2[0] = pos.X - p[0];
v2[1] = pos.Y - p[1];
v2[2] = pos.Z - p[2];
cross = v1 ^ v2;
double len = cross.Length();
if (len == 0)
{
Printf ("Slope thing at (%d,%d) lies directly on its target line.\n", int(x>>16), int(y>>16));
Printf ("Slope thing at (%f,%f) lies directly on its target line.\n", pos.X, pos.Y);
return;
}
cross /= len;
@ -103,10 +103,8 @@ static void P_SlopeLineToPoint (int lineid, fixed_t x, fixed_t y, fixed_t z, boo
cross = -cross;
}
plane->set(cross[0], cross[1], cross[2], 0.);
plane->setD(-TMulScale16 (plane->fixA(), x,
plane->fixB(), y,
plane->fixC(), z));
double dist = -cross[0] * pos.X - cross[1] * pos.Y - cross[2] * pos.Z;
plane->set(cross[0], cross[1], cross[2], dist);
}
}
@ -120,7 +118,6 @@ static void P_CopyPlane (int tag, sector_t *dest, bool copyCeil)
{
sector_t *source;
int secnum;
size_t planeofs;
secnum = P_FindFirstSectorFromTag (tag);
if (secnum == -1)
@ -132,18 +129,17 @@ static void P_CopyPlane (int tag, sector_t *dest, bool copyCeil)
if (copyCeil)
{
planeofs = myoffsetof(sector_t, ceilingplane);
dest->ceilingplane = source->ceilingplane;
}
else
{
planeofs = myoffsetof(sector_t, floorplane);
dest->floorplane = source->floorplane;
}
*(secplane_t *)((BYTE *)dest + planeofs) = *(secplane_t *)((BYTE *)source + planeofs);
}
static void P_CopyPlane (int tag, fixed_t x, fixed_t y, bool copyCeil)
static void P_CopyPlane (int tag, const DVector2 &pos, bool copyCeil)
{
sector_t *dest = P_PointInSector (x, y);
sector_t *dest = P_PointInSector (pos);
P_CopyPlane(tag, dest, copyCeil);
}
@ -153,54 +149,47 @@ static void P_CopyPlane (int tag, fixed_t x, fixed_t y, bool copyCeil)
//
//===========================================================================
void P_SetSlope (secplane_t *plane, bool setCeil, int xyangi, int zangi,
fixed_t x, fixed_t y, fixed_t z)
void P_SetSlope (secplane_t *plane, bool setCeil, int xyangi, int zangi, const DVector3 &pos)
{
angle_t xyang;
angle_t zang;
DAngle xyang;
DAngle zang;
if (zangi >= 180)
{
zang = ANGLE_180-ANGLE_1;
zang = 179.;
}
else if (zangi <= 0)
{
zang = ANGLE_1;
zang = 1.;
}
else
{
zang = Scale (zangi, ANGLE_90, 90);
zang = (double)zangi;
}
if (setCeil)
{
zang += ANGLE_180;
zang += 180.;
}
zang >>= ANGLETOFINESHIFT;
// Sanitize xyangi to [0,360) range
xyangi = xyangi % 360;
if (xyangi < 0)
{
xyangi = 360 + xyangi;
}
xyang = (angle_t)Scale (xyangi, ANGLE_90, 90 << ANGLETOFINESHIFT);
xyang = (double)xyangi;
DVector3 norm;
if (ib_compatflags & BCOMPATF_SETSLOPEOVERFLOW)
{
norm[0] = double(finecosine[zang] * finecosine[xyang]);
norm[1] = double(finecosine[zang] * finesine[xyang]);
// We have to consider an integer multiplication overflow here.
norm[0] = FixedToFloat(FloatToFixed(zang.Cos()) * FloatToFixed(xyang.Cos()));
norm[1] = FixedToFloat(FloatToFixed(zang.Cos()) * FloatToFixed(xyang.Sin()));
}
else
{
norm[0] = double(finecosine[zang]) * double(finecosine[xyang]);
norm[1] = double(finecosine[zang]) * double(finesine[xyang]);
norm[0] = zang.Cos() * xyang.Cos();
norm[1] = zang.Cos() * xyang.Sin();
}
norm[2] = double(finesine[zang]) * 65536.f;
norm[2] = zang.Sin();
norm.MakeUnit();
plane->set(norm[0], norm[1], norm[2], 0.);
plane->setD(-TMulScale16(plane->fixA(), x, plane->fixB(), y, plane->fixC(), z));
double dist = -norm[0] * pos.X - norm[1] * pos.Y - norm[2] * pos.Z;
plane->set(norm[0], norm[1], norm[2], dist);
}
@ -210,7 +199,7 @@ void P_SetSlope (secplane_t *plane, bool setCeil, int xyangi, int zangi,
//
//===========================================================================
void P_VavoomSlope(sector_t * sec, int id, fixed_t x, fixed_t y, fixed_t z, int which)
void P_VavoomSlope(sector_t * sec, int id, const DVector3 &pos, int which)
{
for (int i=0;i<sec->linecount;i++)
{
@ -220,21 +209,21 @@ void P_VavoomSlope(sector_t * sec, int id, fixed_t x, fixed_t y, fixed_t z, int
{
DVector3 v1, v2, cross;
secplane_t *srcplane = (which == 0) ? &sec->floorplane : &sec->ceilingplane;
fixed_t srcheight = (which == 0) ? sec->GetPlaneTexZ(sector_t::floor) : sec->GetPlaneTexZ(sector_t::ceiling);
double srcheight = (which == 0) ? sec->GetPlaneTexZF(sector_t::floor) : sec->GetPlaneTexZF(sector_t::ceiling);
v1[0] = FIXED2DBL (x - l->v2->fixX());
v1[1] = FIXED2DBL (y - l->v2->fixY());
v1[2] = FIXED2DBL (z - srcheight);
v1[0] = pos.X - l->v2->fX();
v1[1] = pos.Y - l->v2->fY();
v1[2] = pos.Z - srcheight;
v2[0] = FIXED2DBL (x - l->v1->fixX());
v2[1] = FIXED2DBL (y - l->v1->fixY());
v2[2] = FIXED2DBL (z - srcheight);
v2[0] = pos.X - l->v1->fX();
v2[1] = pos.Y - l->v1->fY();
v2[2] = pos.Z - srcheight;
cross = v1 ^ v2;
double len = cross.Length();
if (len == 0)
{
Printf ("Slope thing at (%d,%d) lies directly on its target line.\n", int(x>>16), int(y>>16));
Printf ("Slope thing at (%f,%f) lies directly on its target line.\n", pos.X, pos.Y);
return;
}
cross /= len;
@ -245,8 +234,8 @@ void P_VavoomSlope(sector_t * sec, int id, fixed_t x, fixed_t y, fixed_t z, int
cross = -cross;
}
srcplane->set(cross[0], cross[1], cross[2], 0.);
srcplane->setD(-TMulScale16(srcplane->fixA(), x, srcplane->fixB(), y, srcplane->fixC(), z));
double dist = -cross[0] * pos.X - cross[1] * pos.Y - cross[2] * pos.Z;
srcplane->set(cross[0], cross[1], cross[2], dist);
return;
}
}
@ -337,13 +326,13 @@ static void P_SetSlopesFromVertexHeights(FMapThing *firstmt, FMapThing *lastmt,
double *h1 = vt_heights[j].CheckKey(vi1);
double *h2 = vt_heights[j].CheckKey(vi2);
double *h3 = vt_heights[j].CheckKey(vi3);
if (h1==NULL && h2==NULL && h3==NULL) continue;
if (h1 == NULL && h2 == NULL && h3 == NULL) continue;
vt1.Z = h1? *h1 : j==0? sec->GetPlaneTexZF(sector_t::floor) : sec->GetPlaneTexZF(sector_t::ceiling);
vt2.Z = h2? *h2 : j==0? sec->GetPlaneTexZF(sector_t::floor) : sec->GetPlaneTexZF(sector_t::ceiling);
vt3.Z = h3? *h3 : j==0? sec->GetPlaneTexZF(sector_t::floor) : sec->GetPlaneTexZF(sector_t::ceiling);
if (P_PointOnLineSidePrecise(vertexes[vi3].fixX(), vertexes[vi3].fixY(), sec->lines[0]) == 0)
if (P_PointOnLineSidePrecise(vertexes[vi3].fX(), vertexes[vi3].fY(), sec->lines[0]) == 0)
{
vec1 = vt2 - vt3;
vec2 = vt1 - vt3;
@ -373,10 +362,8 @@ static void P_SetSlopesFromVertexHeights(FMapThing *firstmt, FMapThing *lastmt,
secplane_t *plane = j==0? &sec->floorplane : &sec->ceilingplane;
plane->set(cross[0], cross[1], cross[2], 0.);
plane->setD(-TMulScale16 (plane->fixA(), vertexes[vi3].fixX(),
plane->fixB(), vertexes[vi3].fixY(),
plane->fixC(), FLOAT2FIXED(vt3.Z)));
double dist = -cross[0] * vertexes[vi3].fX() - cross[1] * vertexes[vi3].fY() - cross[2] * vt3.Z;
plane->set(cross[0], cross[1], cross[2], dist);
}
}
}
@ -415,21 +402,17 @@ void P_SpawnSlopeMakers (FMapThing *firstmt, FMapThing *lastmt, const int *oldve
}
pos.Z = refplane->ZatPoint (mt->pos) + mt->pos.Z;
fixed_t x = FLOAT2FIXED(pos.X);
fixed_t y = FLOAT2FIXED(pos.Y);
fixed_t z = FLOAT2FIXED(pos.Z);
if (mt->info->Special <= SMT_SlopeCeilingPointLine)
{ // SlopeFloorPointLine and SlopCeilingPointLine
P_SlopeLineToPoint (mt->args[0], x, y, z, ceiling);
P_SlopeLineToPoint (mt->args[0], pos, ceiling);
}
else if (mt->info->Special <= SMT_SetCeilingSlope)
{ // SetFloorSlope and SetCeilingSlope
P_SetSlope (refplane, ceiling, mt->angle, mt->args[0], x, y, z);
P_SetSlope (refplane, ceiling, mt->angle, mt->args[0], pos);
}
else
{ // VavoomFloor and VavoomCeiling
P_VavoomSlope(sec, mt->thingid, x, y, FLOAT2FIXED(mt->pos.Z), ceiling);
{ // VavoomFloor and VavoomCeiling (these do not perform any sector height adjustment - z is absolute)
P_VavoomSlope(sec, mt->thingid, mt->pos, ceiling);
}
mt->EdNum = 0;
}
@ -440,7 +423,7 @@ void P_SpawnSlopeMakers (FMapThing *firstmt, FMapThing *lastmt, const int *oldve
if (mt->info != NULL && mt->info->Type == NULL &&
(mt->info->Special == SMT_CopyFloorPlane || mt->info->Special == SMT_CopyCeilingPlane))
{
P_CopyPlane (mt->args[0], FLOAT2FIXED(mt->pos.X), FLOAT2FIXED(mt->pos.Y), mt->info->Special == SMT_CopyCeilingPlane);
P_CopyPlane (mt->args[0], mt->pos, mt->info->Special == SMT_CopyCeilingPlane);
mt->EdNum = 0;
}
}
@ -464,7 +447,7 @@ void P_SpawnSlopeMakers (FMapThing *firstmt, FMapThing *lastmt, const int *oldve
//
//===========================================================================
static void P_AlignPlane (sector_t *sec, line_t *line, int which)
static void P_AlignPlane(sector_t *sec, line_t *line, int which)
{
sector_t *refsec;
double bestdist;
@ -478,7 +461,7 @@ static void P_AlignPlane (sector_t *sec, line_t *line, int which)
// Find furthest vertex from the reference line. It, along with the two ends
// of the line, will define the plane.
bestdist = 0;
for (i = sec->linecount*2, probe = sec->lines; i > 0; i--)
for (i = sec->linecount * 2, probe = sec->lines; i > 0; i--)
{
double dist;
vertex_t *vert;
@ -487,8 +470,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->fixDx() -
(double(line->v1->fixX()) - vert->fixX()) * line->fixDy());
dist = fabs((line->v1->fY() - vert->fY()) * line->Delta().X -
(line->v1->fX() - vert->fX()) * line->Delta().Y);
if (dist > bestdist)
{
@ -502,21 +485,21 @@ static void P_AlignPlane (sector_t *sec, line_t *line, int which)
DVector3 p, v1, v2, cross;
secplane_t *srcplane;
fixed_t srcheight, destheight;
double srcheight, destheight;
srcplane = (which == 0) ? &sec->floorplane : &sec->ceilingplane;
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);
srcheight = (which == 0) ? sec->GetPlaneTexZF(sector_t::floor) : sec->GetPlaneTexZF(sector_t::ceiling);
destheight = (which == 0) ? refsec->GetPlaneTexZF(sector_t::floor) : refsec->GetPlaneTexZF(sector_t::ceiling);
p[0] = line->v1->fX();
p[1] = line->v1->fY();
p[2] = FIXED2DBL(destheight);
p[2] = destheight;
v1[0] = line->Delta().X;
v1[1] = line->Delta().Y;
v1[2] = 0;
v2[0] = refvert->fX() - line->v1->fX();
v2[1] = refvert->fY() - line->v1->fY();
v2[2] = FIXED2DBL(srcheight - destheight);
v2[2] = srcheight - destheight;
cross = (v1 ^ v2).Unit();
@ -526,10 +509,8 @@ static void P_AlignPlane (sector_t *sec, line_t *line, int which)
cross = -cross;
}
srcplane->set(cross[0], cross[1], cross[2], 0.);
srcplane->setD(-TMulScale16 (srcplane->fixA(), line->v1->fixX(),
srcplane->fixB(), line->v1->fixY(),
srcplane->fixC(), destheight));
double dist = -cross[0] * line->v1->fX() - cross[1] * line->v1->fY() - cross[2] * destheight;
srcplane->set(cross[0], cross[1], cross[2], dist);
}
//===========================================================================
@ -618,4 +599,3 @@ void P_CopySlopes()
}
}
}

View file

@ -453,7 +453,7 @@ static void DoSectorDamage(AActor *actor, sector_t *sec, int amount, FName type,
if (!(flags & DAMAGE_PLAYERS) && actor->player != NULL)
return;
if (!(flags & DAMAGE_IN_AIR) && !actor->isAtZ(sec->floorplane.ZatPointF(actor)) && !actor->waterlevel)
if (!(flags & DAMAGE_IN_AIR) && !actor->isAtZ(sec->floorplane.ZatPoint(actor)) && !actor->waterlevel)
return;
if (protectClass != NULL)
@ -490,8 +490,8 @@ void P_SectorDamage(int tag, int amount, FName type, PClassActor *protectClass,
{
next = actor->snext;
// Only affect actors touching the 3D floor
double z1 = sec->floorplane.ZatPointF(actor);
double z2 = sec->ceilingplane.ZatPointF(actor);
double z1 = sec->floorplane.ZatPoint(actor);
double z2 = sec->ceilingplane.ZatPoint(actor);
if (z2 < z1)
{
// Account for Vavoom-style 3D floors

View file

@ -357,9 +357,9 @@ public:
protected:
DPlat (sector_t *sector);
fixed_t m_Speed;
fixed_t m_Low;
fixed_t m_High;
double m_Speed;
double m_Low;
double m_High;
int m_Wait;
int m_Count;
EPlatState m_Status;
@ -376,13 +376,13 @@ private:
DPlat ();
friend bool EV_DoPlat (int tag, line_t *line, EPlatType type,
int height, int speed, int delay, int lip, int change);
double height, double speed, int delay, int lip, int change);
friend void EV_StopPlat (int tag);
friend void P_ActivateInStasis (int tag);
};
bool EV_DoPlat (int tag, line_t *line, DPlat::EPlatType type,
int height, int speed, int delay, int lip, int change);
double height, double speed, int delay, int lip, int change);
void EV_StopPlat (int tag);
void P_ActivateInStasis (int tag);
@ -403,8 +403,8 @@ public:
};
DPillar (sector_t *sector, EPillar type, fixed_t speed, fixed_t height,
fixed_t height2, int crush, bool hexencrush);
DPillar (sector_t *sector, EPillar type, double speed, double height,
double height2, int crush, bool hexencrush);
void Serialize (FArchive &arc);
void Tick ();
@ -412,10 +412,10 @@ public:
protected:
EPillar m_Type;
fixed_t m_FloorSpeed;
fixed_t m_CeilingSpeed;
fixed_t m_FloorTarget;
fixed_t m_CeilingTarget;
double m_FloorSpeed;
double m_CeilingSpeed;
double m_FloorTarget;
double m_CeilingTarget;
int m_Crush;
bool m_Hexencrush;
TObjPtr<DInterpolation> m_Interp_Ceiling;
@ -426,7 +426,7 @@ private:
};
bool EV_DoPillar (DPillar::EPillar type, line_t *line, int tag,
fixed_t speed, fixed_t height, fixed_t height2, int crush, bool hexencrush);
double speed, double height, double height2, int crush, bool hexencrush);
//
// P_DOORS
@ -446,16 +446,16 @@ public:
};
DDoor (sector_t *sector);
DDoor (sector_t *sec, EVlDoor type, fixed_t speed, int delay, int lightTag, int topcountdown);
DDoor (sector_t *sec, EVlDoor type, double speed, int delay, int lightTag, int topcountdown);
void Serialize (FArchive &arc);
void Tick ();
protected:
EVlDoor m_Type;
fixed_t m_TopDist;
fixed_t m_BotDist, m_OldFloorDist;
double m_TopDist;
double m_BotDist, m_OldFloorDist;
vertex_t *m_BotSpot;
fixed_t m_Speed;
double m_Speed;
// 1 = up, 0 = waiting at top, -1 = down
int m_Direction;
@ -471,7 +471,7 @@ protected:
void DoorSound (bool raise, class DSeqNode *curseq=NULL) const;
friend bool EV_DoDoor (DDoor::EVlDoor type, line_t *line, AActor *thing,
int tag, int speed, int delay, int lock,
int tag, double speed, int delay, int lock,
int lightTag, bool boomgen, int topcountdown);
private:
DDoor ();
@ -479,16 +479,9 @@ private:
};
bool EV_DoDoor (DDoor::EVlDoor type, line_t *line, AActor *thing,
int tag, int speed, int delay, int lock,
int tag, double speed, int delay, int lock,
int lightTag, bool boomgen = false, int topcountdown = 0);
inline bool EV_DoDoor(DDoor::EVlDoor type, line_t *line, AActor *thing,
int tag, double speed, int delay, int lock,
int lightTag, bool boomgen = false, int topcountdown = 0)
{
return EV_DoDoor(type, line, thing, tag, FLOAT2FIXED(speed), delay, lock, lightTag, boomgen, topcountdown);
}
class DAnimatedDoor : public DMovingCeiling
{
@ -506,7 +499,7 @@ protected:
int m_Frame;
FDoorAnimation *m_DoorAnim;
int m_Timer;
fixed_t m_BotDist;
double m_BotDist;
int m_Status;
enum
{
@ -575,22 +568,22 @@ public:
DCeiling (sector_t *sec);
DCeiling (sector_t *sec, fixed_t speed1, fixed_t speed2, int silent);
DCeiling (sector_t *sec, double speed1, double speed2, int silent);
void Serialize (FArchive &arc);
void Tick ();
static DCeiling *Create(sector_t *sec, DCeiling::ECeiling type, line_t *line, int tag,
fixed_t speed, fixed_t speed2, fixed_t height,
double speed, double speed2, double height,
int crush, int silent, int change, ECrushMode hexencrush);
protected:
ECeiling m_Type;
fixed_t m_BottomHeight;
fixed_t m_TopHeight;
fixed_t m_Speed;
fixed_t m_Speed1; // [RH] dnspeed of crushers
fixed_t m_Speed2; // [RH] upspeed of crushers
double m_BottomHeight;
double m_TopHeight;
double m_Speed;
double m_Speed1; // [RH] dnspeed of crushers
double m_Speed2; // [RH] upspeed of crushers
int m_Crush;
ECrushMode m_CrushMode;
int m_Silent;
@ -614,23 +607,9 @@ private:
};
bool EV_DoCeiling (DCeiling::ECeiling type, line_t *line,
int tag, fixed_t speed, fixed_t speed2, fixed_t height,
int tag, double speed, double speed2, double height,
int crush, int silent, int change, DCeiling::ECrushMode hexencrush = DCeiling::ECrushMode::crushDoom);
inline bool EV_DoCeiling(DCeiling::ECeiling type, line_t *line,
int tag, double speed, double speed2, fixed_t height,
int crush, int silent, int change, DCeiling::ECrushMode hexencrush = DCeiling::ECrushMode::crushDoom)
{
return EV_DoCeiling(type, line, tag, FLOAT2FIXED(speed), FLOAT2FIXED(speed2), height, crush, silent, change, hexencrush);
}
inline bool EV_DoCeiling(DCeiling::ECeiling type, line_t *line,
int tag, double speed, int speed2, fixed_t height,
int crush, int silent, int change, DCeiling::ECrushMode hexencrush = DCeiling::ECrushMode::crushDoom)
{
return EV_DoCeiling(type, line, tag, FLOAT2FIXED(speed), speed2, height, crush, silent, change, hexencrush);
}
bool EV_CeilingCrushStop (int tag);
void P_ActivateInStasisCeiling (int tag);
@ -701,19 +680,19 @@ public:
void Serialize (FArchive &arc);
void Tick ();
protected:
//protected:
EFloor m_Type;
int m_Crush;
bool m_Hexencrush;
int m_Direction;
secspecial_t m_NewSpecial;
FTextureID m_Texture;
fixed_t m_FloorDestDist;
fixed_t m_Speed;
double m_FloorDestDist;
double m_Speed;
// [RH] New parameters used to reset and delay stairs
double m_OrgDist;
int m_ResetCount;
int m_OrgDist;
int m_Delay;
int m_PauseTime;
int m_StepTime;
@ -723,33 +702,24 @@ protected:
void SetFloorChangeType (sector_t *sec, int change);
friend bool EV_BuildStairs (int tag, DFloor::EStair type, line_t *line,
fixed_t stairsize, fixed_t speed, int delay, int reset, int igntxt,
double stairsize, double speed, int delay, int reset, int igntxt,
int usespecials);
friend bool EV_DoFloor (DFloor::EFloor floortype, line_t *line, int tag,
fixed_t speed, fixed_t height, int crush, int change, bool hexencrush, bool hereticlower);
double speed, double height, int crush, int change, bool hexencrush, bool hereticlower);
friend bool EV_FloorCrushStop (int tag);
friend bool EV_DoDonut (int tag, line_t *line, fixed_t pillarspeed, fixed_t slimespeed);
friend bool EV_DoDonut (int tag, line_t *line, double pillarspeed, double slimespeed);
private:
DFloor ();
};
bool EV_BuildStairs (int tag, DFloor::EStair type, line_t *line,
fixed_t stairsize, fixed_t speed, int delay, int reset, int igntxt,
double stairsize, double speed, int delay, int reset, int igntxt,
int usespecials);
bool EV_DoFloor (DFloor::EFloor floortype, line_t *line, int tag,
fixed_t speed, fixed_t height, int crush, int change, bool hexencrush, bool hereticlower=false);
inline bool EV_DoFloor(DFloor::EFloor floortype, line_t *line, int tag,
double speed, double height, int crush, int change, bool hexencrush, bool hereticlower = false)
{
return EV_DoFloor(floortype, line, tag, FLOAT2FIXED(speed), FLOAT2FIXED(height), crush, change, hexencrush, hereticlower);
}
inline bool EV_DoFloor(DFloor::EFloor floortype, line_t *line, int tag,
double speed, int height, int crush, int change, bool hexencrush, bool hereticlower = false)
{
return EV_DoFloor(floortype, line, tag, FLOAT2FIXED(speed), height<<FRACBITS, crush, change, hexencrush, hereticlower);
}
bool EV_DoFloor(DFloor::EFloor floortype, line_t *line, int tag,
double speed, double height, int crush, int change, bool hexencrush, bool hereticlower = false);
bool EV_FloorCrushStop (int tag);
bool EV_DoDonut (int tag, line_t *line, fixed_t pillarspeed, fixed_t slimespeed);
bool EV_DoDonut (int tag, line_t *line, double pillarspeed, double slimespeed);
class DElevator : public DMover
{
@ -775,22 +745,20 @@ public:
protected:
EElevator m_Type;
int m_Direction;
fixed_t m_FloorDestDist;
fixed_t m_CeilingDestDist;
fixed_t m_Speed;
double m_FloorDestDist;
double m_CeilingDestDist;
double m_Speed;
TObjPtr<DInterpolation> m_Interp_Ceiling;
TObjPtr<DInterpolation> m_Interp_Floor;
void StartFloorSound ();
friend bool EV_DoElevator (line_t *line, DElevator::EElevator type, fixed_t speed,
fixed_t height, int tag);
friend bool EV_DoElevator (line_t *line, DElevator::EElevator type, double speed, double height, int tag);
private:
DElevator ();
};
bool EV_DoElevator (line_t *line, DElevator::EElevator type, fixed_t speed,
fixed_t height, int tag);
bool EV_DoElevator (line_t *line, DElevator::EElevator type, double speed, double height, int tag);
class DWaggleBase : public DMover
{
@ -802,12 +770,12 @@ public:
void Serialize (FArchive &arc);
protected:
fixed_t m_OriginalDist;
fixed_t m_Accumulator;
fixed_t m_AccDelta;
fixed_t m_TargetScale;
fixed_t m_Scale;
fixed_t m_ScaleDelta;
double m_OriginalDist;
double m_Accumulator;
double m_AccDelta;
double m_TargetScale;
double m_Scale;
double m_ScaleDelta;
int m_Ticker;
int m_State;
TObjPtr<DInterpolation> m_Interpolation;

View file

@ -49,23 +49,23 @@
struct FTraceInfo
{
fixed_t StartX, StartY, StartZ;
fixed_t Vx, Vy, Vz;
DVector3 Start;
DVector3 Vec;
ActorFlags ActorMask;
DWORD WallMask;
AActor *IgnoreThis;
FTraceResults *Results;
FTraceResults *TempResults;
sector_t *CurSector;
fixed_t MaxDist;
fixed_t EnterDist;
double MaxDist;
double EnterDist;
ETraceStatus (*TraceCallback)(FTraceResults &res, void *data);
void *TraceCallbackData;
DWORD TraceFlags;
int inshootthrough;
fixed_t startfrac;
double startfrac;
int aimdir;
fixed_t limitz;
double limitz;
// These are required for 3D-floor checking
// to create a fake sector with a floor
@ -78,8 +78,8 @@ struct FTraceInfo
bool ThingCheck(intercept_t *in);
bool TraceTraverse (int ptflags);
bool CheckPlane(const secplane_t &plane);
int EnterLinePortal(line_t *li, fixed_t frac);
void EnterSectorPortal(int position, fixed_t frac, sector_t *entersec);
int EnterLinePortal(line_t *li, double frac);
void EnterSectorPortal(int position, double frac, sector_t *entersec);
bool CheckSectorPlane(const sector_t *sector, bool checkFloor)
@ -94,8 +94,8 @@ struct FTraceInfo
void SetSourcePosition()
{
Results->SrcFromTarget = { FIXED2DBL(StartX), FIXED2DBL(StartY), FIXED2DBL(StartZ) };
Results->HitVector = { FIXED2DBL(Vx), FIXED2DBL(Vy), FIXED2DBL(Vz) };
Results->SrcFromTarget = Start;
Results->HitVector = Vec;
Results->SrcAngleFromTarget = Results->HitVector.Angle();
}
@ -111,11 +111,9 @@ static bool EditTraceResult (DWORD flags, FTraceResults &res);
//
//==========================================================================
bool Trace (fixed_t x, fixed_t y, fixed_t z, sector_t *sector,
fixed_t vx, fixed_t vy, fixed_t vz, fixed_t maxDist,
ActorFlags actorMask, DWORD wallMask, AActor *ignore,
FTraceResults &res,
DWORD flags, ETraceStatus (*callback)(FTraceResults &res, void *), void *callbackdata)
bool Trace(const DVector3 &start, sector_t *sector, const DVector3 &direction, double maxDist,
ActorFlags actorMask, DWORD wallMask, AActor *ignore, FTraceResults &res, DWORD flags,
ETraceStatus(*callback)(FTraceResults &res, void *), void *callbackdata)
{
int ptflags;
FTraceInfo inf;
@ -126,12 +124,8 @@ bool Trace (fixed_t x, fixed_t y, fixed_t z, sector_t *sector,
ptflags = actorMask ? PT_ADDLINES|PT_ADDTHINGS|PT_COMPATIBLE : PT_ADDLINES;
inf.StartX = x;
inf.StartY = y;
inf.StartZ = z;
inf.Vx = vx;
inf.Vy = vy;
inf.Vz = vz;
inf.Start = start;
inf.Vec = direction;
inf.ActorMask = actorMask;
inf.WallMask = wallMask;
inf.IgnoreThis = ignore;
@ -149,30 +143,6 @@ bool Trace (fixed_t x, fixed_t y, fixed_t z, sector_t *sector,
inf.startfrac = 0;
memset(&res, 0, sizeof(res));
// check for overflows and clip if necessary
SQWORD xd = (SQWORD)x + ((SQWORD(vx) * SQWORD(maxDist)) >> 16);
if (xd>SQWORD(32767)*FRACUNIT)
{
inf.MaxDist = FixedDiv(FIXED_MAX - x, vx);
}
else if (xd<-SQWORD(32767)*FRACUNIT)
{
inf.MaxDist = FixedDiv(FIXED_MIN - x, vx);
}
SQWORD yd = (SQWORD)y + ((SQWORD(vy) * SQWORD(maxDist)) >> 16);
if (yd>SQWORD(32767)*FRACUNIT)
{
inf.MaxDist = FixedDiv(FIXED_MAX - y, vy);
}
else if (yd<-SQWORD(32767)*FRACUNIT)
{
inf.MaxDist = FixedDiv(FIXED_MIN - y, vy);
}
if (inf.TraceTraverse (ptflags))
{
return flags ? EditTraceResult(flags, res) : true;
@ -190,7 +160,7 @@ bool Trace (fixed_t x, fixed_t y, fixed_t z, sector_t *sector,
//
//============================================================================
void FTraceInfo::EnterSectorPortal(int position, fixed_t frac, sector_t *entersec)
void FTraceInfo::EnterSectorPortal(int position, double frac, sector_t *entersec)
{
if (aimdir != -1 && aimdir != position) return;
AActor *portal = entersec->SkyBoxes[position];
@ -203,24 +173,19 @@ void FTraceInfo::EnterSectorPortal(int position, fixed_t frac, sector_t *enterse
memset(&results, 0, sizeof(results));
newtrace.StartX = StartX + FLOAT2FIXED(portal->Scale.X);
newtrace.StartY = StartY + FLOAT2FIXED(portal->Scale.Y);
newtrace.StartZ = StartZ;
newtrace.Start += portal->Scale;
frac += FixedDiv(FRACUNIT, MaxDist);
fixed_t enterdist = FixedMul(MaxDist, frac);
fixed_t enterX = newtrace.StartX + FixedMul(enterdist, Vx);
fixed_t enterY = newtrace.StartY + FixedMul(enterdist, Vy);
frac += 1 / MaxDist;
double enterdist = MaxDist * frac;
DVector2 enter = newtrace.Start.XY() + enterdist * Vec.XY();
newtrace.Vx = Vx;
newtrace.Vy = Vy;
newtrace.Vz = Vz;
newtrace.Vec = Vec;
newtrace.ActorMask = ActorMask;
newtrace.WallMask = WallMask;
newtrace.IgnoreThis = IgnoreThis;
newtrace.Results = &results;
newtrace.TempResults = TempResults;
newtrace.CurSector = P_PointInSector(enterX ,enterY);
newtrace.CurSector = P_PointInSector(enter);
newtrace.MaxDist = MaxDist;
newtrace.EnterDist = EnterDist;
newtrace.TraceCallback = TraceCallback;
@ -229,7 +194,7 @@ void FTraceInfo::EnterSectorPortal(int position, fixed_t frac, sector_t *enterse
newtrace.inshootthrough = true;
newtrace.startfrac = frac;
newtrace.aimdir = position;
newtrace.limitz = FLOAT2FIXED(portal->specialf1);
newtrace.limitz = portal->specialf1;
newtrace.sectorsel = 0;
if (newtrace.TraceTraverse(ActorMask ? PT_ADDLINES | PT_ADDTHINGS | PT_COMPATIBLE : PT_ADDLINES))
@ -244,7 +209,7 @@ void FTraceInfo::EnterSectorPortal(int position, fixed_t frac, sector_t *enterse
//
//============================================================================
int FTraceInfo::EnterLinePortal(line_t *li, fixed_t frac)
int FTraceInfo::EnterLinePortal(line_t *li, double frac)
{
FLinePortal *port = li->getPortal();
@ -253,28 +218,23 @@ int FTraceInfo::EnterLinePortal(line_t *li, fixed_t frac)
FTraceInfo newtrace;
newtrace.StartX = StartX;
newtrace.StartY = StartY;
newtrace.StartZ = StartZ;
newtrace.Vx = Vx;
newtrace.Vy = Vy;
newtrace.Vz = Vz;
newtrace.Start = Start;
newtrace.Vec = Vec;
P_TranslatePortalXY(li, newtrace.StartX, newtrace.StartY);
P_TranslatePortalZ(li, newtrace.StartZ);
P_TranslatePortalVXVY(li, newtrace.Vx, newtrace.Vy);
P_TranslatePortalXY(li, newtrace.Start.X, newtrace.Start.Y);
P_TranslatePortalZ(li, newtrace.Start.Z);
P_TranslatePortalVXVY(li, newtrace.Vec.X, newtrace.Vec.Y);
frac += FixedDiv(FRACUNIT, MaxDist);
fixed_t enterdist = FixedMul(MaxDist, frac);
fixed_t enterX = newtrace.StartX + FixedMul(enterdist, Vx);
fixed_t enterY = newtrace.StartY + FixedMul(enterdist, Vy);
frac += 1 / MaxDist;
double enterdist = MaxDist / frac;
DVector2 enter = newtrace.Start.XY() + enterdist * Vec.XY();
newtrace.ActorMask = ActorMask;
newtrace.WallMask = WallMask;
newtrace.IgnoreThis = IgnoreThis;
newtrace.Results = Results;
newtrace.TempResults = TempResults;
newtrace.CurSector = P_PointInSector(enterX, enterY);
newtrace.CurSector = P_PointInSector(enter);
newtrace.MaxDist = MaxDist;
newtrace.EnterDist = EnterDist;
newtrace.TraceCallback = TraceCallback;
@ -306,14 +266,12 @@ void FTraceInfo::Setup3DFloors()
CurSector = &DummySector[0];
sectorsel = 1;
fixed_t sdist = FixedMul(MaxDist, startfrac);
fixed_t x = StartX + FixedMul(Vx, sdist);
fixed_t y = StartY + FixedMul(Vy, sdist);
fixed_t z = StartZ + FixedMul(Vz, sdist);
double sdist = MaxDist * startfrac;
DVector3 pos = Start + Vec * sdist;
fixed_t bf = CurSector->floorplane.ZatPoint(x, y);
fixed_t bc = CurSector->ceilingplane.ZatPoint(x, y);
double bf = CurSector->floorplane.ZatPoint(pos);
double bc = CurSector->ceilingplane.ZatPoint(pos);
for (auto rover : ff)
{
@ -331,10 +289,10 @@ void FTraceInfo::Setup3DFloors()
if (!(rover->flags&FF_SHOOTTHROUGH))
{
fixed_t ff_bottom = rover->bottom.plane->ZatPoint(x, y);
fixed_t ff_top = rover->top.plane->ZatPoint(x, y);
double ff_bottom = rover->bottom.plane->ZatPoint(pos);
double ff_top = rover->top.plane->ZatPoint(pos);
// clip to the part of the sector we are in
if (z > ff_top)
if (pos.Z > ff_top)
{
// above
if (bf < ff_top)
@ -345,7 +303,7 @@ void FTraceInfo::Setup3DFloors()
bf = ff_top;
}
}
else if (z < ff_bottom)
else if (pos.Z < ff_bottom)
{
//below
if (bc > ff_bottom)
@ -401,12 +359,10 @@ bool FTraceInfo::LineCheck(intercept_t *in)
int lineside;
sector_t *entersector;
fixed_t dist = FixedMul(MaxDist, in->frac);
fixed_t hitx = StartX + FixedMul(Vx, dist);
fixed_t hity = StartY + FixedMul(Vy, dist);
fixed_t hitz = StartZ + FixedMul(Vz, dist);
double dist = MaxDist * in->Frac;
DVector3 hit = Start + Vec * dist;
fixed_t ff, fc, bf = 0, bc = 0;
double ff, fc, bf = 0, bc = 0;
if (in->d.line->frontsector->sectornum == CurSector->sectornum)
{
@ -425,7 +381,7 @@ bool FTraceInfo::LineCheck(intercept_t *in)
}
else
{
lineside = P_PointOnLineSide(StartX, StartY, in->d.line);
lineside = P_PointOnLineSide(Start, in->d.line);
CurSector = lineside ? in->d.line->backsector : in->d.line->frontsector;
}
}
@ -455,20 +411,20 @@ bool FTraceInfo::LineCheck(intercept_t *in)
}
}
ff = CurSector->floorplane.ZatPoint(hitx, hity);
fc = CurSector->ceilingplane.ZatPoint(hitx, hity);
ff = CurSector->floorplane.ZatPoint(hit);
fc = CurSector->ceilingplane.ZatPoint(hit);
if (entersector != NULL)
{
bf = entersector->floorplane.ZatPoint(hitx, hity);
bc = entersector->ceilingplane.ZatPoint(hitx, hity);
bf = entersector->floorplane.ZatPoint(hit);
bc = entersector->ceilingplane.ZatPoint(hit);
}
sector_t *hsec = CurSector->GetHeightSec();
if (Results->CrossedWater == NULL &&
hsec != NULL &&
//CurSector->heightsec->waterzone &&
hitz <= hsec->floorplane.ZatPoint(hitx, hity))
hit.Z <= hsec->floorplane.ZatPoint(hit))
{
// hit crossed a water plane
if (CheckSectorPlane(hsec, true))
@ -478,7 +434,7 @@ bool FTraceInfo::LineCheck(intercept_t *in)
}
}
if (hitz <= ff)
if (hit.Z <= ff)
{
if (CurSector->PortalBlocksMovement(sector_t::floor))
{
@ -493,7 +449,7 @@ bool FTraceInfo::LineCheck(intercept_t *in)
return false;
}
}
else if (hitz >= fc)
else if (hit.Z >= fc)
{
if (CurSector->PortalBlocksMovement(sector_t::ceiling))
{
@ -510,9 +466,9 @@ bool FTraceInfo::LineCheck(intercept_t *in)
}
else if (in->d.line->isLinePortal())
{
if (entersector == NULL || (hitz >= bf && hitz <= bc))
if (entersector == NULL || (hit.Z >= bf && hit.Z <= bc))
{
int res = EnterLinePortal(in->d.line, in->frac);
int res = EnterLinePortal(in->d.line, in->Frac);
if (res != -1)
{
aimdir = INT_MAX; // flag for ending the traverse
@ -522,7 +478,7 @@ bool FTraceInfo::LineCheck(intercept_t *in)
goto normalline; // hit upper or lower tier.
}
else if (entersector == NULL ||
hitz < bf || hitz > bc ||
hit.Z < bf || hit.Z > bc ||
in->d.line->flags & WallMask)
{
normalline:
@ -530,8 +486,8 @@ normalline:
Results->HitType = TRACE_HitWall;
Results->Tier =
entersector == NULL ? TIER_Middle :
hitz <= bf ? TIER_Lower :
hitz >= bc ? TIER_Upper : TIER_Middle;
hit.Z <= bf ? TIER_Lower :
hit.Z >= bc ? TIER_Upper : TIER_Middle;
if (TraceFlags & TRACE_Impact)
{
P_ActivateLine(in->d.line, IgnoreThis, lineside, SPAC_Impact);
@ -552,11 +508,11 @@ normalline:
if (entershootthrough != inshootthrough && rover->flags&FF_EXISTS)
{
fixed_t ff_bottom = rover->bottom.plane->ZatPoint(hitx, hity);
fixed_t ff_top = rover->top.plane->ZatPoint(hitx, hity);
double ff_bottom = rover->bottom.plane->ZatPoint(hit);
double ff_top = rover->top.plane->ZatPoint(hit);
// clip to the part of the sector we are in
if (hitz > ff_top)
if (hit.Z > ff_top)
{
// above
if (bf < ff_top)
@ -567,7 +523,7 @@ normalline:
bf = ff_top;
}
}
else if (hitz < ff_bottom)
else if (hit.Z < ff_bottom)
{
//below
if (bc > ff_bottom)
@ -631,12 +587,12 @@ cont:
}
else
{
if (hitz <= bf || hitz >= bc)
if (hit.Z <= bf || hit.Z >= bc)
{
Results->HitType = TRACE_HitWall;
Results->Tier =
hitz <= bf ? TIER_Lower :
hitz >= bc ? TIER_Upper : TIER_Middle;
hit.Z <= bf ? TIER_Lower :
hit.Z >= bc ? TIER_Upper : TIER_Middle;
}
else
{
@ -651,10 +607,10 @@ cont:
if (Results->HitType == TRACE_HitWall)
{
Results->HitPos = { FIXED2DBL(hitx), FIXED2DBL(hity), FIXED2DBL(hitz) };
Results->HitPos = hit;
SetSourcePosition();
Results->Distance = FIXED2DBL(dist);
Results->Fraction = FIXED2DBL(in->frac);
Results->Distance = dist;
Results->Fraction = in->Frac;
Results->Line = in->d.line;
Results->Side = lineside;
}
@ -692,60 +648,54 @@ cont:
bool FTraceInfo::ThingCheck(intercept_t *in)
{
fixed_t dist = FixedMul(MaxDist, in->frac);
fixed_t hitx = StartX + FixedMul(Vx, dist);
fixed_t hity = StartY + FixedMul(Vy, dist);
fixed_t hitz = StartZ + FixedMul(Vz, dist);
double dist = MaxDist * in->Frac;
DVector3 hit = Start + Vec * dist;
if (hitz > in->d.thing->_f_Top())
if (hit.Z > in->d.thing->Top())
{
// trace enters above actor
if (Vz >= 0) return true; // Going up: can't hit
if (Vec.Z >= 0) return true; // Going up: can't hit
// Does it hit the top of the actor?
dist = FixedDiv(in->d.thing->_f_Top() - StartZ, Vz);
dist = (in->d.thing->Top() - Start.Z) / Vec.Z;
if (dist > MaxDist) return true;
in->frac = FixedDiv(dist, MaxDist);
in->Frac = dist / MaxDist;
hitx = StartX + FixedMul(Vx, dist);
hity = StartY + FixedMul(Vy, dist);
hitz = StartZ + FixedMul(Vz, dist);
hit = Start + Vec * dist;
// calculated coordinate is outside the actor's bounding box
if (abs(hitx - in->d.thing->_f_X()) > in->d.thing->_f_radius() ||
abs(hity - in->d.thing->_f_Y()) > in->d.thing->_f_radius()) return true;
if (fabs(hit.X - in->d.thing->X()) > in->d.thing->radius ||
fabs(hit.Y - in->d.thing->Y()) > in->d.thing->radius) return true;
}
else if (hitz < in->d.thing->_f_Z())
else if (hit.Z < in->d.thing->Z())
{ // trace enters below actor
if (Vz <= 0) return true; // Going down: can't hit
if (Vec.Z <= 0) return true; // Going down: can't hit
// Does it hit the bottom of the actor?
dist = FixedDiv(in->d.thing->_f_Z() - StartZ, Vz);
dist = (in->d.thing->Z() - Start.Z) / Vec.Z;
if (dist > MaxDist) return true;
in->frac = FixedDiv(dist, MaxDist);
in->Frac = dist / MaxDist;
hitx = StartX + FixedMul(Vx, dist);
hity = StartY + FixedMul(Vy, dist);
hitz = StartZ + FixedMul(Vz, dist);
hit = Start + Vec * dist;
// calculated coordinate is outside the actor's bounding box
if (abs(hitx - in->d.thing->_f_X()) > in->d.thing->_f_radius() ||
abs(hity - in->d.thing->_f_Y()) > in->d.thing->_f_radius()) return true;
if (fabs(hit.X - in->d.thing->X()) > in->d.thing->radius ||
fabs(hit.Y - in->d.thing->Y()) > in->d.thing->radius) return true;
}
if (CurSector->e->XFloor.ffloors.Size())
{
// check for 3D floor hits first.
fixed_t ff_floor = CurSector->floorplane.ZatPoint(hitx, hity);
fixed_t ff_ceiling = CurSector->ceilingplane.ZatPoint(hitx, hity);
double ff_floor = CurSector->floorplane.ZatPoint(hit);
double ff_ceiling = CurSector->ceilingplane.ZatPoint(hit);
if (hitz > ff_ceiling && CurSector->PortalBlocksMovement(sector_t::ceiling)) // actor is hit above the current ceiling
if (hit.Z > ff_ceiling && CurSector->PortalBlocksMovement(sector_t::ceiling)) // actor is hit above the current ceiling
{
Results->HitType = TRACE_HitCeiling;
Results->HitTexture = CurSector->GetTexture(sector_t::ceiling);
}
else if (hitz < ff_floor && CurSector->PortalBlocksMovement(sector_t::floor)) // actor is hit below the current floor
else if (hit.Z < ff_floor && CurSector->PortalBlocksMovement(sector_t::floor)) // actor is hit below the current floor
{
Results->HitType = TRACE_HitFloor;
Results->HitTexture = CurSector->GetTexture(sector_t::floor);
@ -778,10 +728,10 @@ cont1:
Results->HitType = TRACE_HitActor;
Results->HitPos = { FIXED2DBL(hitx), FIXED2DBL(hity), FIXED2DBL(hitz) };
Results->HitPos = hit;
SetSourcePosition();
Results->Distance = FIXED2DBL(dist);
Results->Fraction = FIXED2DBL(in->frac);
Results->Distance = dist;
Results->Fraction = in->Frac;
Results->Actor = in->d.thing;
if (TraceCallback != NULL)
@ -811,7 +761,7 @@ bool FTraceInfo::TraceTraverse (int ptflags)
// Do a 3D floor check in the starting sector
Setup3DFloors();
FPathTraverse it(StartX, StartY, FixedMul (Vx, MaxDist), FixedMul (Vy, MaxDist), ptflags | PT_DELTA, startfrac);
FPathTraverse it(Start.X, Start.Y, Vec.X * MaxDist, Vec.Y * MaxDist, ptflags | PT_DELTA, startfrac);
intercept_t *in;
int lastsplashsector = -1;
@ -911,12 +861,9 @@ bool FTraceInfo::TraceTraverse (int ptflags)
}
if (Results->HitType == TRACE_HitNone && Results->Distance == 0)
{
Results->HitPos = {
FIXED2DBL(StartX + FixedMul(Vx, MaxDist)),
FIXED2DBL(StartY + FixedMul(Vy, MaxDist)),
FIXED2DBL(StartZ + FixedMul(Vz, MaxDist)) };
Results->HitPos = Start + Vec * MaxDist;
SetSourcePosition();
Results->Distance = FIXED2DBL(MaxDist);
Results->Distance = MaxDist;
Results->Fraction = 1.;
}
return Results->HitType != TRACE_HitNone;
@ -930,25 +877,20 @@ bool FTraceInfo::TraceTraverse (int ptflags)
bool FTraceInfo::CheckPlane (const secplane_t &plane)
{
fixed_t den = TMulScale16 (plane.fixA(), Vx, plane.fixB(), Vy, plane.fixC(), Vz);
double den = plane.fA() * Vec.X + plane.fB() * Vec.Y + plane.fC() * Vec.Z;
if (den != 0)
{
fixed_t num = TMulScale16 (plane.fixA(), StartX,
plane.fixB(), StartY,
plane.fixC(), StartZ) + plane.fixD();
double num = plane.fA() * Start.X + plane.fB() * Start.Y + plane.fC() * Start.Z + plane.fD();
fixed_t hitdist = FixedDiv (-num, den);
double hitdist = -num / den;
if (hitdist > EnterDist && hitdist < MaxDist)
{
Results->HitPos = {
FIXED2DBL(StartX + FixedMul(Vx, hitdist)),
FIXED2DBL(StartY + FixedMul(Vy, hitdist)),
FIXED2DBL(StartZ + FixedMul(Vz, hitdist)) };
Results->HitPos = Start + Vec * hitdist;
SetSourcePosition();
Results->Distance = FIXED2DBL(hitdist);
Results->Fraction = FIXED2DBL(FixedDiv (hitdist, MaxDist));
Results->Distance = hitdist;
Results->Fraction = hitdist / MaxDist;
return true;
}
}

View file

@ -124,20 +124,8 @@ enum ETraceStatus
TRACE_Abort, // stop the trace, returning no hits
};
bool Trace (fixed_t x, fixed_t y, fixed_t z, sector_t *sector,
fixed_t vx, fixed_t vy, fixed_t vz, fixed_t maxDist,
ActorFlags ActorMask, DWORD WallMask, AActor *ignore,
FTraceResults &res,
DWORD traceFlags=0,
ETraceStatus (*callback)(FTraceResults &res, void *)=NULL, void *callbackdata=NULL);
inline bool Trace(const DVector3 &start, sector_t *sector, const DVector3 &direction, double maxDist,
bool Trace(const DVector3 &start, sector_t *sector, const DVector3 &direction, double maxDist,
ActorFlags ActorMask, DWORD WallMask, AActor *ignore, FTraceResults &res, DWORD traceFlags = 0,
ETraceStatus(*callback)(FTraceResults &res, void *) = NULL, void *callbackdata = NULL)
{
return Trace(FLOAT2FIXED(start.X), FLOAT2FIXED(start.Y), FLOAT2FIXED(start.Z), sector,
FLOAT2FIXED(direction.X), FLOAT2FIXED(direction.Y), FLOAT2FIXED(direction.Z), FLOAT2FIXED(maxDist),
ActorMask, WallMask, ignore, res, traceFlags, callback, callbackdata);
}
ETraceStatus(*callback)(FTraceResults &res, void *) = NULL, void *callbackdata = NULL);
#endif //__P_TRACE_H__

View file

@ -252,14 +252,9 @@ double UDMFParserBase::CheckFloat(const char *key)
return sc.Float;
}
fixed_t UDMFParserBase::CheckFixed(const char *key)
DAngle UDMFParserBase::CheckAngle(const char *key)
{
return FLOAT2FIXED(CheckFloat(key));
}
angle_t UDMFParserBase::CheckAngle(const char *key)
{
return FLOAT2ANGLE(CheckFloat(key));
return DAngle(CheckFloat(key)).Normalized360();
}
bool UDMFParserBase::CheckBool(const char *key)
@ -358,7 +353,7 @@ int GetUDMFInt(int type, int index, const char *key)
return 0;
}
fixed_t GetUDMFFixed(int type, int index, const char *key)
double GetUDMFFloat(int type, int index, const char *key)
{
assert(type >=0 && type <=3);
@ -369,7 +364,7 @@ fixed_t GetUDMFFixed(int type, int index, const char *key)
FUDMFKey *pKey = pKeys->Find(key);
if (pKey != NULL)
{
return FLOAT2FIXED(pKey->FloatVal);
return pKey->FloatVal;
}
}
return 0;
@ -970,7 +965,7 @@ public:
if (namespace_bits & (Zd|Zdt|Va)) switch(key)
{
case NAME_Alpha:
ld->Alpha = CheckFixed(key);
ld->setAlpha(CheckFloat(key));
continue;
case NAME_Renderstyle:
@ -1096,7 +1091,7 @@ public:
{
ld->Alpha = TRANSLUC75;
}
if (strifetrans2 && ld->Alpha == FRACUNIT)
if (strifetrans2 && ld->Alpha == OPAQUE)
{
ld->Alpha = TRANSLUC25;
}
@ -1127,14 +1122,14 @@ public:
void ParseSidedef(side_t *sd, intmapsidedef_t *sdt, int index)
{
fixed_t texofs[2]={0,0};
double texOfs[2]={0,0};
memset(sd, 0, sizeof(*sd));
sdt->bottomtexture = "-";
sdt->toptexture = "-";
sdt->midtexture = "-";
sd->SetTextureXScale(FRACUNIT);
sd->SetTextureYScale(FRACUNIT);
sd->SetTextureXScale(1.);
sd->SetTextureYScale(1.);
sd->Index = index;
sc.MustGetToken('{');
@ -1144,11 +1139,11 @@ public:
switch(key)
{
case NAME_Offsetx:
texofs[0] = CheckInt(key) << FRACBITS;
texOfs[0] = CheckInt(key);
continue;
case NAME_Offsety:
texofs[1] = CheckInt(key) << FRACBITS;
texOfs[1] = CheckInt(key);
continue;
case NAME_Texturetop:
@ -1174,51 +1169,51 @@ public:
if (namespace_bits & (Zd|Zdt|Va)) switch(key)
{
case NAME_offsetx_top:
sd->SetTextureXOffset(side_t::top, CheckFixed(key));
sd->SetTextureXOffset(side_t::top, CheckFloat(key));
continue;
case NAME_offsety_top:
sd->SetTextureYOffset(side_t::top, CheckFixed(key));
sd->SetTextureYOffset(side_t::top, CheckFloat(key));
continue;
case NAME_offsetx_mid:
sd->SetTextureXOffset(side_t::mid, CheckFixed(key));
sd->SetTextureXOffset(side_t::mid, CheckFloat(key));
continue;
case NAME_offsety_mid:
sd->SetTextureYOffset(side_t::mid, CheckFixed(key));
sd->SetTextureYOffset(side_t::mid, CheckFloat(key));
continue;
case NAME_offsetx_bottom:
sd->SetTextureXOffset(side_t::bottom, CheckFixed(key));
sd->SetTextureXOffset(side_t::bottom, CheckFloat(key));
continue;
case NAME_offsety_bottom:
sd->SetTextureYOffset(side_t::bottom, CheckFixed(key));
sd->SetTextureYOffset(side_t::bottom, CheckFloat(key));
continue;
case NAME_scalex_top:
sd->SetTextureXScale(side_t::top, CheckFixed(key));
sd->SetTextureXScale(side_t::top, CheckFloat(key));
continue;
case NAME_scaley_top:
sd->SetTextureYScale(side_t::top, CheckFixed(key));
sd->SetTextureYScale(side_t::top, CheckFloat(key));
continue;
case NAME_scalex_mid:
sd->SetTextureXScale(side_t::mid, CheckFixed(key));
sd->SetTextureXScale(side_t::mid, CheckFloat(key));
continue;
case NAME_scaley_mid:
sd->SetTextureYScale(side_t::mid, CheckFixed(key));
sd->SetTextureYScale(side_t::mid, CheckFloat(key));
continue;
case NAME_scalex_bottom:
sd->SetTextureXScale(side_t::bottom, CheckFixed(key));
sd->SetTextureXScale(side_t::bottom, CheckFloat(key));
continue;
case NAME_scaley_bottom:
sd->SetTextureYScale(side_t::bottom, CheckFixed(key));
sd->SetTextureYScale(side_t::bottom, CheckFloat(key));
continue;
case NAME_light:
@ -1263,12 +1258,12 @@ public:
}
}
// initialization of these is delayed to allow separate offsets and add them with the global ones.
sd->AddTextureXOffset(side_t::top, texofs[0]);
sd->AddTextureXOffset(side_t::mid, texofs[0]);
sd->AddTextureXOffset(side_t::bottom, texofs[0]);
sd->AddTextureYOffset(side_t::top, texofs[1]);
sd->AddTextureYOffset(side_t::mid, texofs[1]);
sd->AddTextureYOffset(side_t::bottom, texofs[1]);
sd->AddTextureXOffset(side_t::top, texOfs[0]);
sd->AddTextureXOffset(side_t::mid, texOfs[0]);
sd->AddTextureXOffset(side_t::bottom, texOfs[0]);
sd->AddTextureYOffset(side_t::top, texOfs[1]);
sd->AddTextureYOffset(side_t::mid, texOfs[1]);
sd->AddTextureYOffset(side_t::bottom, texOfs[1]);
}
//===========================================================================
@ -1288,12 +1283,12 @@ public:
memset(sec, 0, sizeof(*sec));
sec->lightlevel = 160;
sec->SetXScale(sector_t::floor, FRACUNIT); // [RH] floor and ceiling scaling
sec->SetYScale(sector_t::floor, FRACUNIT);
sec->SetXScale(sector_t::ceiling, FRACUNIT);
sec->SetYScale(sector_t::ceiling, FRACUNIT);
sec->SetAlpha(sector_t::floor, OPAQUE);
sec->SetAlpha(sector_t::ceiling, OPAQUE);
sec->SetXScale(sector_t::floor, 1.); // [RH] floor and ceiling scaling
sec->SetYScale(sector_t::floor, 1.);
sec->SetXScale(sector_t::ceiling, 1.);
sec->SetYScale(sector_t::ceiling, 1.);
sec->SetAlpha(sector_t::floor, 1.);
sec->SetAlpha(sector_t::ceiling, 1.);
sec->thinglist = NULL;
sec->touching_thinglist = NULL; // phares 3/14/98
sec->seqType = (level.flags & LEVEL_SNDSEQTOTALCTRL) ? 0 : -1;
@ -1320,11 +1315,11 @@ public:
switch(key)
{
case NAME_Heightfloor:
sec->SetPlaneTexZ(sector_t::floor, CheckInt(key) << FRACBITS);
sec->SetPlaneTexZ(sector_t::floor, CheckFloat(key));
continue;
case NAME_Heightceiling:
sec->SetPlaneTexZ(sector_t::ceiling, CheckInt(key) << FRACBITS);
sec->SetPlaneTexZ(sector_t::ceiling, CheckFloat(key));
continue;
case NAME_Texturefloor:
@ -1360,35 +1355,35 @@ public:
if (namespace_bits & (Zd|Zdt|Va)) switch(key)
{
case NAME_Xpanningfloor:
sec->SetXOffset(sector_t::floor, CheckFixed(key));
sec->SetXOffset(sector_t::floor, CheckFloat(key));
continue;
case NAME_Ypanningfloor:
sec->SetYOffset(sector_t::floor, CheckFixed(key));
sec->SetYOffset(sector_t::floor, CheckFloat(key));
continue;
case NAME_Xpanningceiling:
sec->SetXOffset(sector_t::ceiling, CheckFixed(key));
sec->SetXOffset(sector_t::ceiling, CheckFloat(key));
continue;
case NAME_Ypanningceiling:
sec->SetYOffset(sector_t::ceiling, CheckFixed(key));
sec->SetYOffset(sector_t::ceiling, CheckFloat(key));
continue;
case NAME_Xscalefloor:
sec->SetXScale(sector_t::floor, CheckFixed(key));
sec->SetXScale(sector_t::floor, CheckFloat(key));
continue;
case NAME_Yscalefloor:
sec->SetYScale(sector_t::floor, CheckFixed(key));
sec->SetYScale(sector_t::floor, CheckFloat(key));
continue;
case NAME_Xscaleceiling:
sec->SetXScale(sector_t::ceiling, CheckFixed(key));
sec->SetXScale(sector_t::ceiling, CheckFloat(key));
continue;
case NAME_Yscaleceiling:
sec->SetYScale(sector_t::ceiling, CheckFixed(key));
sec->SetYScale(sector_t::ceiling, CheckFloat(key));
continue;
case NAME_Rotationfloor:
@ -1408,11 +1403,11 @@ public:
continue;
case NAME_Alphafloor:
sec->SetAlpha(sector_t::floor, CheckFixed(key));
sec->SetAlpha(sector_t::floor, CheckFloat(key));
continue;
case NAME_Alphaceiling:
sec->SetAlpha(sector_t::ceiling, CheckFixed(key));
sec->SetAlpha(sector_t::ceiling, CheckFloat(key));
continue;
case NAME_Renderstylefloor:
@ -1600,7 +1595,7 @@ public:
// Reset the planes to their defaults if not all of the plane equation's parameters were found.
if (fplaneflags != 15)
{
sec->floorplane.set(0, 0, FRACUNIT, -sec->GetPlaneTexZ(sector_t::floor));
sec->floorplane.SetAtHeight(sec->GetPlaneTexZF(sector_t::floor), sector_t::floor);
}
else
{
@ -1610,7 +1605,7 @@ public:
}
if (cplaneflags != 15)
{
sec->ceilingplane.set(0, 0, -FRACUNIT, sec->GetPlaneTexZ(sector_t::ceiling));
sec->ceilingplane.SetAtHeight(sec->GetPlaneTexZF(sector_t::ceiling), sector_t::ceiling);
}
else
{
@ -1663,18 +1658,18 @@ public:
vd->zCeiling = vd->zFloor = vd->flags = 0;
sc.MustGetToken('{');
fixed_t x, y;
double x, y;
while (!sc.CheckToken('}'))
{
FName key = ParseKey();
switch (key)
{
case NAME_X:
x = CheckFixed(key);
x = CheckFloat(key);
break;
case NAME_Y:
y = CheckFixed(key);
y = CheckFloat(key);
break;
case NAME_ZCeiling:
@ -1714,7 +1709,7 @@ public:
I_Error ("Line %d has invalid vertices: %zd and/or %zd.\nThe map only contains %d vertices.", i+skipped, v1i, v2i, numvertexes);
}
else if (v1i == v2i ||
(vertexes[v1i].fixX() == vertexes[v2i].fixX() && vertexes[v1i].fixY() == vertexes[v2i].fixY()))
(vertexes[v1i].fX() == vertexes[v2i].fX() && vertexes[v1i].fY() == vertexes[v2i].fY()))
{
Printf ("Removing 0-length line %d\n", i+skipped);
ParsedLines.Delete(i);

View file

@ -17,8 +17,7 @@ protected:
FName ParseKey(bool checkblock = false, bool *isblock = NULL);
int CheckInt(const char *key);
double CheckFloat(const char *key);
fixed_t CheckFixed(const char *key);
angle_t CheckAngle(const char *key);
DAngle CheckAngle(const char *key);
bool CheckBool(const char *key);
const char *CheckString(const char *key);

View file

@ -2500,7 +2500,6 @@ void P_PlayerThink (player_t *player)
}
if (player->centering)
{
player->mo->Angles.Pitch.Normalize180(); // make sure we are in the proper range here for the following code.
if (fabs(player->mo->Angles.Pitch) > 2.)
{
player->mo->Angles.Pitch *= (2. / 3.);
@ -2609,7 +2608,7 @@ void P_PlayerThink (player_t *player)
P_PlayerOnSpecial3DFloor (player);
P_PlayerInSpecialSector (player);
if (!player->mo->isAbove(player->mo->Sector->floorplane.ZatPointF(player->mo)) ||
if (!player->mo->isAbove(player->mo->Sector->floorplane.ZatPoint(player->mo)) ||
player->mo->waterlevel)
{
// Player must be touching the floor

View file

@ -867,7 +867,7 @@ void FPolyObj::ThrustMobj (AActor *actor, side_t *side)
}
vertex_t *v1 = side->V1();
vertex_t *v2 = side->V2();
thrustAngle = VecToAngle(v2->fixX() - v1->fixX(), v2->fixY() - v1->fixY()) - 90.;
thrustAngle = (v2->fPos() - v1->fPos()).Angle() - 90.;
pe = static_cast<DPolyAction *>(specialdata);
if (pe)
@ -1239,8 +1239,8 @@ bool FPolyObj::CheckMobjBlocking (side_t *sd)
}
// [BL] See if we hit below the floor/ceiling of the poly.
else if(!performBlockingThrust && (
mobj->_f_Z() < ld->sidedef[!side]->sector->GetSecPlane(sector_t::floor).ZatPoint(mobj) ||
mobj->_f_Top() > ld->sidedef[!side]->sector->GetSecPlane(sector_t::ceiling).ZatPoint(mobj)
mobj->Z() < ld->sidedef[!side]->sector->GetSecPlane(sector_t::floor).ZatPoint(mobj) ||
mobj->Top() > ld->sidedef[!side]->sector->GetSecPlane(sector_t::ceiling).ZatPoint(mobj)
))
{
performBlockingThrust = true;

View file

@ -1096,8 +1096,8 @@ void P_CreateLinkedPortals()
{
// This is a fatal condition. We have to remove one of the two portals. Choose the one that doesn't match the current plane
Printf("Error in sector %d: Ceiling portal at z=%d is below floor portal at z=%d\n", i, cz, fz);
fixed_t cp = sectors[i].ceilingplane.Zat0();
fixed_t fp = sectors[i].ceilingplane.Zat0();
fixed_t cp = -sectors[i].ceilingplane.fixD();
fixed_t fp = -sectors[i].ceilingplane.fixD();
if (cp < fp || fz == fp)
{
sectors[i].SkyBoxes[sector_t::ceiling] = NULL;

View file

@ -55,8 +55,8 @@ void R_3D_AddHeight(secplane_t *add, sector_t *sec)
fixed_t height;
height = add->ZatPoint(viewx, viewy);
if(height >= sec->CenterCeiling()) return;
if(height <= sec->CenterFloor()) return;
if(height >= FLOAT2FIXED(sec->CenterCeiling())) return;
if(height <= FLOAT2FIXED(sec->CenterFloor())) return;
fakeActive = 1;

View file

@ -426,7 +426,7 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec,
tempsec->floorplane = sec->floorplane;
tempsec->ceilingplane = s->floorplane;
tempsec->ceilingplane.FlipVert ();
tempsec->ceilingplane.ChangeHeight (-1);
tempsec->ceilingplane.ChangeHeight(-1 / 65536.);
tempsec->ColorMap = s->ColorMap;
}
@ -438,12 +438,12 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec,
tempsec->ceilingplane = s->floorplane;
tempsec->ceilingplane.FlipVert ();
tempsec->ceilingplane.ChangeHeight (-1);
tempsec->ceilingplane.ChangeHeight (-1 / 65536.);
if (s->GetTexture(sector_t::ceiling) == skyflatnum)
{
tempsec->floorplane = tempsec->ceilingplane;
tempsec->floorplane.FlipVert ();
tempsec->floorplane.ChangeHeight (+1);
tempsec->floorplane.ChangeHeight (+1 / 65536.);
tempsec->SetTexture(sector_t::ceiling, tempsec->GetTexture(sector_t::floor), false);
tempsec->planes[sector_t::ceiling].xform = tempsec->planes[sector_t::floor].xform;
}
@ -475,7 +475,7 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec,
tempsec->ceilingplane = s->ceilingplane;
tempsec->floorplane = s->ceilingplane;
tempsec->floorplane.FlipVert ();
tempsec->floorplane.ChangeHeight (+1);
tempsec->floorplane.ChangeHeight (+1 / 65536.);
tempsec->ColorMap = s->ColorMap;
tempsec->ColorMap = s->ColorMap;
@ -1261,14 +1261,14 @@ void R_Subsector (subsector_t *sub)
} else position = sector_t::ceiling;
frontsector = &tempsec;
tempsec.ceilingplane.ChangeHeight(-1);
tempsec.ceilingplane.ChangeHeight(-1 / 65536.);
if (fixedlightlev < 0 && sub->sector->e->XFloor.lightlist.Size())
{
light = P_GetPlaneLight(sub->sector, &frontsector->ceilingplane, false);
basecolormap = light->extra_colormap;
ceilinglightlevel = *light->p_lightlevel;
}
tempsec.ceilingplane.ChangeHeight(1);
tempsec.ceilingplane.ChangeHeight(1 / 65536.);
floorplane = NULL;
ceilingplane = R_FindPlane(frontsector->ceilingplane, // killough 3/8/98

View file

@ -52,8 +52,8 @@ class DSectorPlaneInterpolation : public DInterpolation
DECLARE_CLASS(DSectorPlaneInterpolation, DInterpolation)
sector_t *sector;
fixed_t oldheight, oldtexz;
fixed_t bakheight, baktexz;
double oldheight, oldtexz;
double bakheight, baktexz;
bool ceiling;
TArray<DInterpolation *> attached;
@ -65,7 +65,7 @@ public:
void Destroy();
void UpdateInterpolation();
void Restore();
void Interpolate(fixed_t smoothratio);
void Interpolate(double smoothratio);
void Serialize(FArchive &arc);
size_t PointerSubstitution (DObject *old, DObject *notOld);
size_t PropagateMark();
@ -82,8 +82,8 @@ class DSectorScrollInterpolation : public DInterpolation
DECLARE_CLASS(DSectorScrollInterpolation, DInterpolation)
sector_t *sector;
fixed_t oldx, oldy;
fixed_t bakx, baky;
double oldx, oldy;
double bakx, baky;
bool ceiling;
public:
@ -93,7 +93,7 @@ public:
void Destroy();
void UpdateInterpolation();
void Restore();
void Interpolate(fixed_t smoothratio);
void Interpolate(double smoothratio);
void Serialize(FArchive &arc);
};
@ -110,8 +110,8 @@ class DWallScrollInterpolation : public DInterpolation
side_t *side;
int part;
fixed_t oldx, oldy;
fixed_t bakx, baky;
double oldx, oldy;
double bakx, baky;
public:
@ -120,7 +120,7 @@ public:
void Destroy();
void UpdateInterpolation();
void Restore();
void Interpolate(fixed_t smoothratio);
void Interpolate(double smoothratio);
void Serialize(FArchive &arc);
};
@ -135,9 +135,9 @@ class DPolyobjInterpolation : public DInterpolation
DECLARE_CLASS(DPolyobjInterpolation, DInterpolation)
FPolyObj *poly;
TArray<fixed_t> oldverts, bakverts;
fixed_t oldcx, oldcy;
fixed_t bakcx, bakcy;
TArray<double> oldverts, bakverts;
double oldcx, oldcy;
double bakcx, bakcy;
public:
@ -146,7 +146,7 @@ public:
void Destroy();
void UpdateInterpolation();
void Restore();
void Interpolate(fixed_t smoothratio);
void Interpolate(double smoothratio);
void Serialize(FArchive &arc);
};
@ -251,9 +251,9 @@ void FInterpolator::RemoveInterpolation(DInterpolation *interp)
//
//==========================================================================
void FInterpolator::DoInterpolations(fixed_t smoothratio)
void FInterpolator::DoInterpolations(double smoothratio)
{
if (smoothratio == FRACUNIT)
if (smoothratio >= 1.)
{
didInterp = false;
return;
@ -440,13 +440,13 @@ void DSectorPlaneInterpolation::UpdateInterpolation()
{
if (!ceiling)
{
oldheight = sector->floorplane.fixD();
oldtexz = sector->GetPlaneTexZ(sector_t::floor);
oldheight = sector->floorplane.fD();
oldtexz = sector->GetPlaneTexZF(sector_t::floor);
}
else
{
oldheight = sector->ceilingplane.fixD();
oldtexz = sector->GetPlaneTexZ(sector_t::ceiling);
oldheight = sector->ceilingplane.fD();
oldtexz = sector->GetPlaneTexZF(sector_t::ceiling);
}
}
@ -478,7 +478,7 @@ void DSectorPlaneInterpolation::Restore()
//
//==========================================================================
void DSectorPlaneInterpolation::Interpolate(fixed_t smoothratio)
void DSectorPlaneInterpolation::Interpolate(double smoothratio)
{
secplane_t *pplane;
int pos;
@ -503,8 +503,8 @@ void DSectorPlaneInterpolation::Interpolate(fixed_t smoothratio)
}
else
{
pplane->setD(oldheight + FixedMul(bakheight - oldheight, smoothratio));
sector->SetPlaneTexZ(pos, oldtexz + FixedMul(baktexz - oldtexz, smoothratio), true);
pplane->setD(oldheight + (bakheight - oldheight) * smoothratio);
sector->SetPlaneTexZ(pos, oldtexz + (baktexz - oldtexz) * smoothratio, true);
P_RecalculateAttached3DFloors(sector);
sector->CheckPortalPlane(pos);
}
@ -604,8 +604,8 @@ void DSectorScrollInterpolation::Destroy()
void DSectorScrollInterpolation::UpdateInterpolation()
{
oldx = sector->GetXOffset(ceiling);
oldy = sector->GetYOffset(ceiling, false);
oldx = sector->GetXOffsetF(ceiling);
oldy = sector->GetYOffsetF(ceiling, false);
}
//==========================================================================
@ -626,7 +626,7 @@ void DSectorScrollInterpolation::Restore()
//
//==========================================================================
void DSectorScrollInterpolation::Interpolate(fixed_t smoothratio)
void DSectorScrollInterpolation::Interpolate(double smoothratio)
{
bakx = sector->GetXOffset(ceiling);
baky = sector->GetYOffset(ceiling, false);
@ -637,8 +637,8 @@ void DSectorScrollInterpolation::Interpolate(fixed_t smoothratio)
}
else
{
sector->SetXOffset(ceiling, oldx + FixedMul(bakx - oldx, smoothratio));
sector->SetYOffset(ceiling, oldy + FixedMul(baky - oldy, smoothratio));
sector->SetXOffset(ceiling, oldx + (bakx - oldx) * smoothratio);
sector->SetYOffset(ceiling, oldy + (baky - oldy) * smoothratio);
}
}
@ -695,8 +695,8 @@ void DWallScrollInterpolation::Destroy()
void DWallScrollInterpolation::UpdateInterpolation()
{
oldx = side->GetTextureXOffset(part);
oldy = side->GetTextureYOffset(part);
oldx = side->GetTextureXOffsetF(part);
oldy = side->GetTextureYOffsetF(part);
}
//==========================================================================
@ -717,7 +717,7 @@ void DWallScrollInterpolation::Restore()
//
//==========================================================================
void DWallScrollInterpolation::Interpolate(fixed_t smoothratio)
void DWallScrollInterpolation::Interpolate(double smoothratio)
{
bakx = side->GetTextureXOffset(part);
baky = side->GetTextureYOffset(part);
@ -728,8 +728,8 @@ void DWallScrollInterpolation::Interpolate(fixed_t smoothratio)
}
else
{
side->SetTextureXOffset(part, oldx + FixedMul(bakx - oldx, smoothratio));
side->SetTextureYOffset(part, oldy + FixedMul(baky - oldy, smoothratio));
side->SetTextureXOffset(part, oldx + (bakx - oldx) * smoothratio);
side->SetTextureYOffset(part, oldy + (baky - oldy) * smoothratio);
}
}
@ -788,8 +788,8 @@ void DPolyobjInterpolation::UpdateInterpolation()
{
for(unsigned int i = 0; i < poly->Vertices.Size(); i++)
{
oldverts[i*2 ] = poly->Vertices[i]->fixX();
oldverts[i*2+1] = poly->Vertices[i]->fixY();
oldverts[i*2 ] = poly->Vertices[i]->fX();
oldverts[i*2+1] = poly->Vertices[i]->fY();
}
oldcx = poly->CenterSpot.x;
oldcy = poly->CenterSpot.y;
@ -818,7 +818,7 @@ void DPolyobjInterpolation::Restore()
//
//==========================================================================
void DPolyobjInterpolation::Interpolate(fixed_t smoothratio)
void DPolyobjInterpolation::Interpolate(double smoothratio)
{
bool changed = false;
for(unsigned int i = 0; i < poly->Vertices.Size(); i++)
@ -830,8 +830,8 @@ void DPolyobjInterpolation::Interpolate(fixed_t smoothratio)
{
changed = true;
poly->Vertices[i]->set(
oldverts[i * 2] + FixedMul(bakverts[i * 2] - oldverts[i * 2], smoothratio),
oldverts[i * 2 + 1] + FixedMul(bakverts[i * 2 + 1] - oldverts[i * 2 + 1], smoothratio));
oldverts[i * 2] + (bakverts[i * 2] - oldverts[i * 2]) * smoothratio,
oldverts[i * 2 + 1] + (bakverts[i * 2 + 1] - oldverts[i * 2 + 1]) * smoothratio);
}
}
if (refcount == 0 && !changed)
@ -842,8 +842,8 @@ void DPolyobjInterpolation::Interpolate(fixed_t smoothratio)
{
bakcx = poly->CenterSpot.x;
bakcy = poly->CenterSpot.y;
poly->CenterSpot.x = bakcx + FixedMul(bakcx - oldcx, smoothratio);
poly->CenterSpot.y = bakcy + FixedMul(bakcy - oldcy, smoothratio);
poly->CenterSpot.x = bakcx + (bakcx - oldcx) * smoothratio;
poly->CenterSpot.y = bakcy + (bakcy - oldcy) * smoothratio;
poly->ClearSubsectorLinks();
}

View file

@ -30,7 +30,7 @@ public:
virtual void Destroy();
virtual void UpdateInterpolation() = 0;
virtual void Restore() = 0;
virtual void Interpolate(fixed_t smoothratio) = 0;
virtual void Interpolate(double smoothratio) = 0;
virtual void Serialize(FArchive &arc);
};
@ -58,7 +58,7 @@ public:
void UpdateInterpolations();
void AddInterpolation(DInterpolation *);
void RemoveInterpolation(DInterpolation *);
void DoInterpolations(fixed_t smoothratio);
void DoInterpolations(double smoothratio);
void RestoreInterpolations();
void ClearInterpolations();
};

View file

@ -388,6 +388,10 @@ public:
{
return FIXED2DBL(d);
}
double fiC() const
{
return FIXED2DBL(ic);
}
bool isSlope() const
{
@ -421,11 +425,6 @@ public:
return FixedMul(ic, -d - DMulScale16(a, spot.x, b, spot.y));
}
double ZatPointF(const fixedvec3 &spot) const
{
return FIXED2DBL(FixedMul(ic, -d - DMulScale16(a, spot.x, b, spot.y)));
}
// Returns the value of z at (x,y)
fixed_t ZatPoint (fixed_t x, fixed_t y) const
{
@ -443,39 +442,21 @@ public:
return (d + a*pos.X + b*pos.Y) * ic / (-65536.0 * 65536.0);
}
// Returns the value of z at vertex v
fixed_t ZatPoint (const vertex_t *v) const
{
return FixedMul (ic, -d - DMulScale16 (a, v->fixX(), b, v->fixY()));
}
double ZatPointF(const vertex_t *v) const
double ZatPoint(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()));
}
double ZatPointF(const AActor *ac) const
double ZatPoint(const AActor *ac) const
{
return (d + a*ac->X() + b*ac->Y()) * ic / (-65536.0 * 65536.0);
}
// Returns the value of z at (x,y) if d is equal to dist
fixed_t ZatPointDist (fixed_t x, fixed_t y, fixed_t dist) const
{
return FixedMul (ic, -dist - DMulScale16 (a, x, b, y));
}
// Returns the value of z at vertex v if d is equal to dist
fixed_t ZatPointDist (const vertex_t *v, fixed_t dist)
double ZatPointDist(const vertex_t *v, double dist)
{
return FixedMul (ic, -dist - DMulScale16 (a, v->fixX(), b, v->fixY()));
return FIXED2DBL(FixedMul(ic, -FLOAT2FIXED(dist) - DMulScale16(a, v->fixX(), b, v->fixY())));
}
// Flips the plane's vertical orientiation, so that if it pointed up,
// it will point down, and vice versa.
void FlipVert ()
@ -500,15 +481,15 @@ public:
}
// Moves a plane up/down by hdiff units
void ChangeHeight (fixed_t hdiff)
void ChangeHeight(double hdiff)
{
d = d - FixedMul (hdiff, c);
d = d - fixed_t(hdiff * c);
}
// Moves a plane up/down by hdiff units
fixed_t GetChangedHeight (fixed_t hdiff)
double GetChangedHeight(double hdiff)
{
return d - FixedMul (hdiff, c);
return fD() - hdiff * fC();
}
// Returns how much this plane's height would change if d were set to oldd
@ -518,9 +499,15 @@ public:
}
// Returns how much this plane's height would change if d were set to oldd
fixed_t HeightDiff (fixed_t oldd, fixed_t newd) const
double HeightDiff(double oldd) const
{
return FixedMul (oldd - newd, ic);
return (oldd - fD()) * fiC();
}
// Returns how much this plane's height would change if d were set to oldd
double HeightDiff(double oldd, double newd) const
{
return (oldd - newd) * fiC();
}
fixed_t PointToDist (fixed_t x, fixed_t y, fixed_t z) const
@ -538,6 +525,16 @@ public:
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.;
}
double PointToDist(const vertex_t *v, double z) const
{
return -(a * v->fX() + b * v->fY() + c * z) / 65536.;
}
void SetAtHeight(fixed_t height, int ceiling)
{
a = b = 0;
@ -723,22 +720,23 @@ struct sector_t
{
// Member functions
bool IsLinked(sector_t *other, bool ceiling) const;
fixed_t FindLowestFloorSurrounding (vertex_t **v) const;
fixed_t FindHighestFloorSurrounding (vertex_t **v) const;
fixed_t FindNextHighestFloor (vertex_t **v) const;
fixed_t FindNextLowestFloor (vertex_t **v) const;
fixed_t FindLowestCeilingSurrounding (vertex_t **v) const; // jff 2/04/98
fixed_t FindHighestCeilingSurrounding (vertex_t **v) const; // jff 2/04/98
fixed_t FindNextLowestCeiling (vertex_t **v) const; // jff 2/04/98
fixed_t FindNextHighestCeiling (vertex_t **v) const; // jff 2/04/98
fixed_t FindShortestTextureAround () const; // jff 2/04/98
fixed_t FindShortestUpperAround () const; // jff 2/04/98
sector_t *FindModelFloorSector (fixed_t floordestheight) const; // jff 2/04/98
sector_t *FindModelCeilingSector (fixed_t floordestheight) const; // jff 2/04/98
double FindLowestFloorSurrounding(vertex_t **v) const;
double FindHighestFloorSurrounding(vertex_t **v) const;
double FindNextHighestFloor(vertex_t **v) const;
double FindNextLowestFloor(vertex_t **v) const;
double FindLowestCeilingSurrounding(vertex_t **v) const; // jff 2/04/98
double FindHighestCeilingSurrounding(vertex_t **v) const; // jff 2/04/98
double FindNextLowestCeiling(vertex_t **v) const; // jff 2/04/98
double FindNextHighestCeiling(vertex_t **v) const; // jff 2/04/98
double FindShortestTextureAround() const; // jff 2/04/98
double FindShortestUpperAround() const; // jff 2/04/98
sector_t *FindModelFloorSector(double floordestheight) const; // jff 2/04/98
sector_t *FindModelCeilingSector(double floordestheight) const; // jff 2/04/98
int FindMinSurroundingLight (int max) const;
sector_t *NextSpecialSector (int type, sector_t *prev) const; // [RH]
fixed_t FindLowestCeilingPoint (vertex_t **v) const;
fixed_t FindHighestFloorPoint (vertex_t **v) const;
double FindLowestCeilingPoint(vertex_t **v) const;
double FindHighestFloorPoint(vertex_t **v) const;
void AdjustFloorClip () const;
void SetColor(int r, int g, int b, int desat);
void SetFade(int r, int g, int b);
@ -851,6 +849,11 @@ struct sector_t
planes[pos].xform.xscale = o;
}
void SetXScale(int pos, double o)
{
planes[pos].xform.xscale = FLOAT2FIXED(o);
}
fixed_t GetXScale(int pos) const
{
return planes[pos].xform.xscale;
@ -866,6 +869,11 @@ struct sector_t
planes[pos].xform.yscale = o;
}
void SetYScale(int pos, double o)
{
planes[pos].xform.yscale = FLOAT2FIXED(o);
}
fixed_t GetYScale(int pos) const
{
return planes[pos].xform.yscale;
@ -910,10 +918,10 @@ struct sector_t
}
}
void SetBase(int pos, fixed_t y, angle_t o)
void SetBase(int pos, double y, DAngle o)
{
planes[pos].xform.base_yoffs = y;
planes[pos].xform.base_angle = o;
planes[pos].xform.base_yoffs = FLOAT2FIXED(y);
planes[pos].xform.base_angle = o.BAMs();
}
void SetAlpha(int pos, fixed_t o)
@ -1126,24 +1134,12 @@ struct sector_t
return LowestFloorAt(a->Pos(), resultsec);
}
fixed_t NextHighestCeilingAt(fixed_t x, fixed_t y, fixed_t bottomz, fixed_t topz, int flags = 0, sector_t **resultsec = NULL, F3DFloor **resultffloor = NULL);
fixed_t NextLowestFloorAt(fixed_t x, fixed_t y, fixed_t z, int flags = 0, fixed_t steph = 0, sector_t **resultsec = NULL, F3DFloor **resultffloor = NULL);
inline double NextHighestCeilingAt(double x, double y, double bottomz, double topz, int flags = 0, sector_t **resultsec = NULL, F3DFloor **resultffloor = NULL)
{
return FIXED2DBL(NextHighestCeilingAt(FLOAT2FIXED(x), FLOAT2FIXED(y), FLOAT2FIXED(bottomz), FLOAT2FIXED(topz), flags, resultsec, resultffloor));
}
double NextLowestFloorAt(double x, double y, double z, int flags = 0, double steph = 0, sector_t **resultsec = NULL, F3DFloor **resultffloor = NULL)
{
return FIXED2DBL(NextLowestFloorAt(FLOAT2FIXED(x), FLOAT2FIXED(y), FLOAT2FIXED(z), flags, FLOAT2FIXED(steph), resultsec, resultffloor));
}
double NextHighestCeilingAt(double x, double y, double bottomz, double topz, int flags = 0, sector_t **resultsec = NULL, F3DFloor **resultffloor = NULL);
double NextLowestFloorAt(double x, double y, double z, int flags = 0, double steph = 0, sector_t **resultsec = NULL, F3DFloor **resultffloor = NULL);
// Member variables
fixed_t CenterFloor () const { return floorplane.ZatPoint (_f_centerspot()); }
fixed_t CenterCeiling () const { return ceilingplane.ZatPoint (_f_centerspot()); }
double CenterFloorF() const { return floorplane.ZatPoint(centerspot); }
double CenterCeilingF() const { return ceilingplane.ZatPoint(centerspot); }
double CenterFloor() const { return floorplane.ZatPoint(centerspot); }
double CenterCeiling() const { return ceilingplane.ZatPoint(centerspot); }
// [RH] store floor and ceiling planes instead of heights
secplane_t floorplane, ceilingplane;
@ -1351,6 +1347,16 @@ struct side_t
textures[mid].xoffset =
textures[bottom].xoffset = offset;
}
void SetTextureXOffset(int which, double offset)
{
textures[which].xoffset = FLOAT2FIXED(offset);
}
void SetTextureXOffset(double offset)
{
textures[top].xoffset =
textures[mid].xoffset =
textures[bottom].xoffset = FLOAT2FIXED(offset);
}
fixed_t GetTextureXOffset(int which) const
{
return textures[which].xoffset;
@ -1378,6 +1384,16 @@ struct side_t
textures[mid].yoffset =
textures[bottom].yoffset = offset;
}
void SetTextureYOffset(int which, double offset)
{
textures[which].yoffset = FLOAT2FIXED(offset);
}
void SetTextureYOffset(double offset)
{
textures[top].yoffset =
textures[mid].yoffset =
textures[bottom].yoffset = FLOAT2FIXED(offset);
}
fixed_t GetTextureYOffset(int which) const
{
return textures[which].yoffset;
@ -1399,10 +1415,18 @@ struct side_t
{
textures[which].xscale = scale == 0 ? FRACUNIT : scale;
}
void SetTextureXScale(int which, double scale)
{
textures[which].xscale = scale == 0 ? FRACUNIT : FLOAT2FIXED(scale);
}
void SetTextureXScale(fixed_t scale)
{
textures[top].xscale = textures[mid].xscale = textures[bottom].xscale = scale == 0 ? FRACUNIT : scale;
}
void SetTextureXScale(double scale)
{
textures[top].xscale = textures[mid].xscale = textures[bottom].xscale = scale == 0 ? FRACUNIT : FLOAT2FIXED(scale);
}
fixed_t GetTextureXScale(int which) const
{
return textures[which].xscale;
@ -1417,10 +1441,20 @@ struct side_t
{
textures[which].yscale = scale == 0 ? FRACUNIT : scale;
}
void SetTextureYScale(int which, double scale)
{
textures[which].yscale = scale == 0 ? FRACUNIT : FLOAT2FIXED(scale);
}
void SetTextureYScale(fixed_t scale)
{
textures[top].yscale = textures[mid].yscale = textures[bottom].yscale = scale == 0 ? FRACUNIT : scale;
}
void SetTextureYScale(double scale)
{
textures[top].yscale = textures[mid].yscale = textures[bottom].yscale = scale == 0 ? FRACUNIT : FLOAT2FIXED(scale);
}
fixed_t GetTextureYScale(int which) const
{
return textures[which].yscale;
@ -1506,6 +1540,11 @@ public:
dy = FLOAT2FIXED(y);
}
void setAlpha(double a)
{
Alpha = FLOAT2FIXED(a);
}
FLinePortal *getPortal() const
{
return portalindex >= linePortals.Size() ? (FLinePortal*)NULL : &linePortals[portalindex];
@ -1708,31 +1747,6 @@ inline sector_t *P_PointInSector(double X, double Y)
return P_PointInSubsector(FLOAT2FIXED(X), FLOAT2FIXED(Y))->sector;
}
inline fixedvec3 AActor::_f_PosRelative(int portalgroup) const
{
return _f_Pos() + Displacements._f_getOffset(Sector->PortalGroup, portalgroup);
}
inline fixedvec3 AActor::_f_PosRelative(const AActor *other) const
{
return _f_Pos() + Displacements._f_getOffset(Sector->PortalGroup, other->Sector->PortalGroup);
}
inline fixedvec3 AActor::_f_PosRelative(sector_t *sec) const
{
return _f_Pos() + Displacements._f_getOffset(Sector->PortalGroup, sec->PortalGroup);
}
inline fixedvec3 AActor::_f_PosRelative(line_t *line) const
{
return _f_Pos() + Displacements._f_getOffset(Sector->PortalGroup, line->frontsector->PortalGroup);
}
inline fixedvec3 _f_PosRelative(const fixedvec3 &pos, line_t *line, sector_t *refsec = NULL)
{
return pos + Displacements._f_getOffset(refsec->PortalGroup, line->frontsector->PortalGroup);
}
inline DVector3 AActor::PosRelative(int portalgroup) const
{
return Pos() + Displacements.getOffset(Sector->PortalGroup, portalgroup);

View file

@ -1071,7 +1071,7 @@ void R_DrawSpanP_C (void)
#ifdef RANGECHECK
if (ds_x2 < ds_x1 || ds_x1 < 0
|| ds_x2 >= screen->width || ds_y > screen->_f_height())
|| ds_x2 >= screen->width || ds_y > screen->height)
{
I_Error ("R_DrawSpan: %i to %i at %i", ds_x1, ds_x2, ds_y);
}

View file

@ -1531,7 +1531,7 @@ void R_DrawNormalPlane (visplane_t *pl, fixed_t alpha, bool additive, bool maske
yscale = pl->yscale << (16 - ds_ybits);
if (planeang != 0)
{
double rad = ANGLE2RAD(planeang);
double rad = planeang * (M_PI / ANGLE_180);
double cosine = cos(rad), sine = sin(rad);
pviewx = xs_RoundToInt(pl->xoffs + viewx * cosine - viewy * sine);
@ -1668,29 +1668,29 @@ void R_DrawTiltedPlane (visplane_t *pl, fixed_t alpha, bool additive, bool maske
// p is the texture origin in view space
// Don't add in the offsets at this stage, because doing so can result in
// errors if the flat is rotated.
ang = ANGLE2RAD(ANG270 - viewangle);
ang = (ANG270 - viewangle) * (M_PI / ANGLE_180);
p[0] = vx * cos(ang) - vy * sin(ang);
p[2] = vx * sin(ang) + vy * cos(ang);
p[1] = pl->height.ZatPoint(0.0, 0.0) - vz;
// m is the v direction vector in view space
ang = ANGLE2RAD(ANG180 - viewangle - pl->angle);
ang = (ANG180 - viewangle - pl->angle) * (M_PI / ANGLE_180);
m[0] = yscale * cos(ang);
m[2] = yscale * sin(ang);
// m[1] = FIXED2FLOAT(pl->height.ZatPoint (0, iyscale) - pl->height.ZatPoint (0,0));
// m[1] = pl->height.ZatPointF (0, iyscale) - pl->height.ZatPointF (0,0));
// VectorScale2 (m, 64.f/VectorLength(m));
// n is the u direction vector in view space
ang += PI/2;
n[0] = -xscale * cos(ang);
n[2] = -xscale * sin(ang);
// n[1] = FIXED2FLOAT(pl->height.ZatPoint (ixscale, 0) - pl->height.ZatPoint (0,0));
// n[1] = pl->height.ZatPointF (ixscale, 0) - pl->height.ZatPointF (0,0));
// VectorScale2 (n, 64.f/VectorLength(n));
// This code keeps the texture coordinates constant across the x,y plane no matter
// how much you slope the surface. Use the commented-out code above instead to keep
// the textures a constant size across the surface's plane instead.
ang = ANGLE2RAD(pl->angle);
ang = pl->angle * (M_PI / ANGLE_180);
m[1] = pl->height.ZatPoint(vx + yscale * sin(ang), vy + yscale * cos(ang)) - zeroheight;
ang += PI/2;
n[1] = pl->height.ZatPoint(vx + xscale * sin(ang), vy + xscale * cos(ang)) - zeroheight;

View file

@ -687,16 +687,16 @@ void R_RenderFakeWallRange (drawseg_t *ds, int x1, int x2)
frontsector = sec;
}
floorheight = backsector->CenterFloor();
ceilingheight = backsector->CenterCeiling();
floorheight = FLOAT2FIXED(backsector->CenterFloor());
ceilingheight = FLOAT2FIXED(backsector->CenterCeiling());
// maybe fix clipheights
if (!(fake3D & FAKE3D_CLIPBOTTOM)) sclipBottom = floorheight;
if (!(fake3D & FAKE3D_CLIPTOP)) sclipTop = ceilingheight;
// maybe not visible
if (sclipBottom >= frontsector->CenterCeiling()) return;
if (sclipTop <= frontsector->CenterFloor()) return;
if (sclipBottom >= FLOAT2FIXED(frontsector->CenterCeiling())) return;
if (sclipTop <= FLOAT2FIXED(frontsector->CenterFloor())) return;
if (fake3D & FAKE3D_DOWN2UP)
{ // bottom to viewz
@ -2266,7 +2266,7 @@ void R_NewWall (bool needlights)
int planeside;
planeside = frontsector->floorplane.PointOnSide(viewx, viewy, viewz);
if (frontsector->floorplane.fixC() < 0) // 3D floors have the floor backwards
if (frontsector->floorplane.fC() < 0) // 3D floors have the floor backwards
planeside = -planeside;
if (planeside <= 0) // above view plane
markfloor = false;
@ -2274,7 +2274,7 @@ void R_NewWall (bool needlights)
if (frontsector->GetTexture(sector_t::ceiling) != skyflatnum)
{
planeside = frontsector->ceilingplane.PointOnSide(viewx, viewy, viewz);
if (frontsector->ceilingplane.fixC() > 0) // 3D floors have the ceiling backwards
if (frontsector->ceilingplane.fC() > 0) // 3D floors have the ceiling backwards
planeside = -planeside;
if (planeside <= 0) // below view plane
markceiling = false;

View file

@ -763,7 +763,7 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor
// [ZZ] Or less definitely not visible (hue)
// [ZZ] 10.01.2016: don't try to clip stuff inside a skybox against the current portal.
if (!CurrentPortalInSkybox && CurrentPortal && !!P_PointOnLineSidePrecise(thing->_f_X(), thing->_f_Y(), CurrentPortal->dst))
if (!CurrentPortalInSkybox && CurrentPortal && !!P_PointOnLineSidePrecise(thing->Pos(), CurrentPortal->dst))
return;
// [RH] Interpolate the sprite's position to make it look smooth
@ -806,11 +806,11 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor
angle_t rot;
if (sprframe->Texture[0] == sprframe->Texture[1])
{
rot = (ang - thing->_f_angle() + (angle_t)(ANGLE_45/2)*9) >> 28;
rot = (ang - thing->Angles.Yaw.BAMs() + (angle_t)(ANGLE_45/2)*9) >> 28;
}
else
{
rot = (ang - thing->_f_angle() + (angle_t)(ANGLE_45/2)*9-(angle_t)(ANGLE_180/16)) >> 28;
rot = (ang - thing->Angles.Yaw.BAMs() + (angle_t)(ANGLE_45/2)*9-(angle_t)(ANGLE_180/16)) >> 28;
}
picnum = sprframe->Texture[rot];
if (sprframe->Flip & (1 << rot))
@ -845,11 +845,11 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor
angle_t rot;
if (sprframe->Texture[0] == sprframe->Texture[1])
{
rot = (ang - thing->_f_angle() + (angle_t)(ANGLE_45/2)*9) >> 28;
rot = (ang - thing->Angles.Yaw.BAMs() + (angle_t)(ANGLE_45/2)*9) >> 28;
}
else
{
rot = (ang - thing->_f_angle() + (angle_t)(ANGLE_45/2)*9-(angle_t)(ANGLE_180/16)) >> 28;
rot = (ang - thing->Angles.Yaw.BAMs() + (angle_t)(ANGLE_45/2)*9-(angle_t)(ANGLE_180/16)) >> 28;
}
picnum = sprframe->Texture[rot];
if (sprframe->Flip & (1 << rot))
@ -1001,7 +1001,7 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor
vis->texturemid = (tex->TopOffset << FRACBITS) - FixedDiv (viewz - fz + FLOAT2FIXED(thing->Floorclip), yscale);
vis->x1 = x1 < WindowLeft ? WindowLeft : x1;
vis->x2 = x2 > WindowRight ? WindowRight : x2;
vis->angle = thing->_f_angle();
vis->angle = thing->Angles.Yaw.BAMs();
if (renderflags & RF_XFLIP)
{
@ -1036,8 +1036,8 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor
int voxelspin = (thing->flags & MF_DROPPED) ? voxel->DroppedSpin : voxel->PlacedSpin;
if (voxelspin != 0)
{
double ang = double(I_FPSTime()) * voxelspin / 1000;
vis->angle -= FLOAT2ANGLE(ang);
DAngle ang = double(I_FPSTime()) * voxelspin / 1000;
vis->angle -= ang.BAMs();
}
vis->vx = viewx;
@ -1151,7 +1151,7 @@ static void R_ProjectWallSprite(AActor *thing, fixed_t fx, fixed_t fy, fixed_t f
fixed_t lx1, lx2, ly1, ly2;
fixed_t gzb, gzt, tz;
FTexture *pic = TexMan(picnum, true);
angle_t ang = (thing->_f_angle() + ANGLE_90) >> ANGLETOFINESHIFT;
angle_t ang = (thing->Angles.Yaw.BAMs() + ANGLE_90) >> ANGLETOFINESHIFT;
vissprite_t *vis;
// Determine left and right edges of sprite. The sprite's angle is its normal,
@ -1256,12 +1256,12 @@ void R_AddSprites (sector_t *sec, int lightlevel, int fakeside)
{
if(!rover->top.plane->isSlope())
{
if(rover->top.plane->Zat0() <= thing->_f_Z()) fakefloor = rover;
if(rover->top.plane->ZatPoint(0., 0.) <= thing->Z()) fakefloor = rover;
}
}
if(!rover->bottom.plane->isSlope())
{
if(rover->bottom.plane->Zat0() >= thing->_f_Top()) fakeceiling = rover;
if(rover->bottom.plane->ZatPoint(0., 0.) >= thing->Top()) fakeceiling = rover;
}
}
R_ProjectSprite (thing, fakeside, fakefloor, fakeceiling);

View file

@ -105,6 +105,7 @@ fixed_t viewx;
fixed_t viewy;
fixed_t viewz;
int viewpitch;
angle_t viewangle;
extern "C"
{
@ -117,7 +118,6 @@ extern "C"
int otic;
angle_t viewangle;
sector_t *viewsector;
fixed_t viewcos, viewtancos;
@ -125,7 +125,6 @@ fixed_t viewsin, viewtansin;
AActor *camera; // [RH] camera to draw from. doesn't have to be a player
fixed_t r_TicFrac; // [RH] Fractional tic to render
double r_TicFracF; // same as floating point
DWORD r_FrameTime; // [RH] Time this frame started drawing (in ms)
bool r_NoInterpolate;
@ -572,9 +571,9 @@ static void R_Shutdown ()
//CVAR (Int, tf, 0, 0)
EXTERN_CVAR (Bool, cl_noprediction)
void R_InterpolateView (player_t *player, fixed_t frac, InterpolationViewer *iview)
void R_InterpolateView (player_t *player, double Frac, InterpolationViewer *iview)
{
// frac = tf;
fixed_t frac = FLOAT2FIXED(Frac);
if (NoInterpolateView)
{
InterpolationPath.Clear();
@ -619,7 +618,7 @@ void R_InterpolateView (player_t *player, fixed_t frac, InterpolationViewer *ivi
DVector3a &end = InterpolationPath[i];
pathlen += FLOAT2FIXED((end.pos-start.pos).Length());
totalzdiff += FLOAT2FIXED(start.pos.Z);
totaladiff += FLOAT2ANGLE(start.angle.Degrees);
totaladiff += start.angle.BAMs();
}
fixed_t interpolatedlen = FixedMul(frac, pathlen);
@ -629,7 +628,7 @@ void R_InterpolateView (player_t *player, fixed_t frac, InterpolationViewer *ivi
DVector3a &end = InterpolationPath[i];
fixed_t fraglen = FLOAT2FIXED((end.pos - start.pos).Length());
zdiff += FLOAT2FIXED(start.pos.Z);
adiff += FLOAT2ANGLE(start.angle.Degrees);
adiff += start.angle.BAMs();
if (fraglen <= interpolatedlen)
{
interpolatedlen -= fraglen;
@ -683,11 +682,11 @@ void R_InterpolateView (player_t *player, fixed_t frac, InterpolationViewer *ivi
// Avoid overflowing viewpitch (can happen when a netgame is stalled)
if (viewpitch > INT_MAX - delta)
{
viewpitch = FLOAT2ANGLE(player->MaxPitch.Degrees);
viewpitch = player->MaxPitch.BAMs();
}
else
{
viewpitch = MIN<int>(viewpitch + delta, FLOAT2ANGLE(player->MaxPitch.Degrees));
viewpitch = MIN<int>(viewpitch + delta, player->MaxPitch.BAMs());
}
}
else if (delta < 0)
@ -695,11 +694,11 @@ void R_InterpolateView (player_t *player, fixed_t frac, InterpolationViewer *ivi
// Avoid overflowing viewpitch (can happen when a netgame is stalled)
if (viewpitch < INT_MIN - delta)
{
viewpitch = FLOAT2ANGLE(player->MinPitch.Degrees);
viewpitch = player->MinPitch.BAMs();
}
else
{
viewpitch = MAX<int>(viewpitch + delta, FLOAT2ANGLE(player->MinPitch.Degrees));
viewpitch = MAX<int>(viewpitch + delta, player->MinPitch.BAMs());
}
}
}
@ -994,13 +993,13 @@ void R_SetupFrame (AActor *actor)
viewsector = camera->Sector;
r_showviewer = false;
}
iview->nviewpitch = camera->_f_pitch();
iview->nviewpitch = camera->Angles.Pitch.BAMs();
if (camera->player != 0)
{
player = camera->player;
}
iview->nviewangle = camera->_f_angle();
iview->nviewangle = camera->Angles.Yaw.BAMs();
if (iview->otic == -1 || r_NoInterpolate)
{
R_ResetViewInterpolation ();
@ -1012,9 +1011,7 @@ void R_SetupFrame (AActor *actor)
{
r_TicFracF = 1.;
}
r_TicFrac = FLOAT2FIXED(r_TicFracF);
R_InterpolateView (player, r_TicFrac, iview);
R_InterpolateView (player, r_TicFracF, iview);
#ifdef TEST_X
viewx = TEST_X;
@ -1025,7 +1022,7 @@ void R_SetupFrame (AActor *actor)
R_SetViewAngle ();
interpolator.DoInterpolations (r_TicFrac);
interpolator.DoInterpolations (r_TicFracF);
// Keep the view within the sector's floor and ceiling
if (viewsector->PortalBlocksMovement(sector_t::ceiling))

View file

@ -33,7 +33,6 @@ extern int LocalViewPitch; // [RH] Used directly instead of consoleplayer's
extern bool LocalKeyboardTurner; // [RH] The local player used the keyboard to turn, so interpolate
extern int WidescreenRatio;
extern fixed_t r_TicFrac;
extern double r_TicFracF;
extern DWORD r_FrameTime;
extern int extralight;

View file

@ -34,6 +34,7 @@
#define GetCommand(a) ((a) & 255)
#define GetData(a) (SDWORD(a) >> 8 )
#define GetFloatData(a) float((SDWORD(a) >> 8 )/65536.f)
#define MakeCommand(a,b) ((a) | ((b) << 8))
#define HexenPlatSeq(a) (a)
#define HexenDoorSeq(a) ((a) | 0x40)
@ -675,18 +676,18 @@ void S_ParseSndSeq (int levellump)
case SS_STRING_VOLUME: // volume is in range 0..100
sc.MustGetFloat ();
ScriptTemp.Push(MakeCommand(SS_CMD_VOLUME, int(sc.Float * (FRACUNIT/100.f))));
ScriptTemp.Push(MakeCommand(SS_CMD_VOLUME, int(sc.Float * (65536.f / 100.f))));
break;
case SS_STRING_VOLUMEREL:
sc.MustGetFloat ();
ScriptTemp.Push(MakeCommand(SS_CMD_VOLUMEREL, int(sc.Float * (FRACUNIT/100.f))));
ScriptTemp.Push(MakeCommand(SS_CMD_VOLUMEREL, int(sc.Float * (65536.f / 100.f))));
break;
case SS_STRING_VOLUMERAND:
sc.MustGetFloat ();
volumebase = float(sc.Float);
ScriptTemp.Push(MakeCommand(SS_CMD_VOLUMERAND, int(sc.Float * (FRACUNIT/100.f))));
ScriptTemp.Push(MakeCommand(SS_CMD_VOLUMERAND, int(sc.Float * (65536.f / 100.f))));
sc.MustGetFloat ();
ScriptTemp.Push(int((sc.Float - volumebase) * (256/100.f)));
break;
@ -705,12 +706,12 @@ void S_ParseSndSeq (int levellump)
case SS_STRING_ATTENUATION:
if (sc.CheckFloat())
{
val = FLOAT2FIXED(sc.Float);
val = int(sc.Float*65536.);
}
else
{
sc.MustGetString ();
val = sc.MustMatchString(&Attenuations[0].name, sizeof(Attenuations[0])) << FRACBITS;
val = sc.MustMatchString(&Attenuations[0].name, sizeof(Attenuations[0])) * 65536;
}
ScriptTemp.Push(MakeCommand(SS_CMD_ATTENUATION, val));
break;
@ -1179,19 +1180,19 @@ void DSeqNode::Tick ()
return;
case SS_CMD_VOLUME:
m_Volume = GetData(*m_SequencePtr) / float(FRACUNIT);
m_Volume = GetFloatData(*m_SequencePtr);
m_SequencePtr++;
break;
case SS_CMD_VOLUMEREL:
// like SS_CMD_VOLUME, but the new volume is added to the old volume
m_Volume += GetData(*m_SequencePtr) / float(FRACUNIT);
m_Volume += GetFloatData(*m_SequencePtr);
m_SequencePtr++;
break;
case SS_CMD_VOLUMERAND:
// like SS_CMD_VOLUME, but the new volume is chosen randomly from a range
m_Volume = GetData(m_SequencePtr[0]) / float(FRACUNIT) + (pr_sndseq() % m_SequencePtr[1]) / 255.f;
m_Volume = GetFloatData(m_SequencePtr[0]) + (pr_sndseq() % m_SequencePtr[1]) / 255.f;
m_SequencePtr += 2;
break;
@ -1200,7 +1201,7 @@ void DSeqNode::Tick ()
return;
case SS_CMD_ATTENUATION:
m_Atten = FIXED2FLOAT(GetData(*m_SequencePtr));
m_Atten = GetFloatData(*m_SequencePtr);
m_SequencePtr++;
break;

View file

@ -1952,7 +1952,7 @@ static void S_SetListener(SoundListener &listener, AActor *listenactor)
{
if (listenactor != NULL)
{
listener.angle = (float)ToRadians(listenactor->Angles.Yaw);
listener.angle = (float)listenactor->Angles.Yaw.Radians();
/*
listener.velocity.X = listenactor->vel.x * (TICRATE/65536.f);
listener.velocity.Y = listenactor->vel.z * (TICRATE/65536.f);

View file

@ -1,6 +1,7 @@
#ifndef __TEXTURES_H
#define __TEXTURES_H
#include "doomtype.h"
#include "vectors.h"
struct FloatRect

View file

@ -4589,22 +4589,46 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetSpecial)
//
//===========================================================================
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetUserVar)
static PField *GetVar(AActor *self, FName varname)
{
PARAM_ACTION_PROLOGUE;
PARAM_NAME (varname);
PARAM_INT (value);
PField *var = dyn_cast<PField>(self->GetClass()->Symbols.FindSymbol(varname, true));
if (var == NULL || (var->Flags & VARF_Native) || !var->Type->IsKindOf(RUNTIME_CLASS(PBasicType)))
{
Printf("%s is not a user variable in class %s\n", varname.GetChars(),
self->GetClass()->TypeName.GetChars());
return 0;
return nullptr;
}
return var;
}
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetUserVar)
{
PARAM_ACTION_PROLOGUE;
PARAM_NAME (varname);
PARAM_INT (value);
// Set the value of the specified user variable.
var->Type->SetValue(reinterpret_cast<BYTE *>(self) + var->Offset, value);
PField *var = GetVar(self, varname);
if (var != nullptr)
{
var->Type->SetValue(reinterpret_cast<BYTE *>(self) + var->Offset, value);
}
return 0;
}
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetUserVarFloat)
{
PARAM_ACTION_PROLOGUE;
PARAM_NAME (varname);
PARAM_FLOAT (value);
// Set the value of the specified user variable.
PField *var = GetVar(self, varname);
if (var != nullptr)
{
var->Type->SetValue(reinterpret_cast<BYTE *>(self) + var->Offset, value);
}
return 0;
}
@ -4614,13 +4638,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetUserVar)
//
//===========================================================================
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetUserArray)
static PField *GetArrayVar(AActor *self, FName varname, int pos)
{
PARAM_ACTION_PROLOGUE;
PARAM_NAME (varname);
PARAM_INT (pos);
PARAM_INT (value);
PField *var = dyn_cast<PField>(self->GetClass()->Symbols.FindSymbol(varname, true));
if (var == NULL || (var->Flags & VARF_Native) ||
@ -4629,17 +4648,48 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetUserArray)
{
Printf("%s is not a user array in class %s\n", varname.GetChars(),
self->GetClass()->TypeName.GetChars());
return 0;
return nullptr;
}
PArray *arraytype = static_cast<PArray *>(var->Type);
if ((unsigned)pos >= arraytype->ElementCount)
if ((unsigned)pos >= static_cast<PArray *>(var->Type)->ElementCount)
{
Printf("%d is out of bounds in array %s in class %s\n", pos, varname.GetChars(),
self->GetClass()->TypeName.GetChars());
return 0;
return nullptr;
}
return var;
}
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetUserArray)
{
PARAM_ACTION_PROLOGUE;
PARAM_NAME (varname);
PARAM_INT (pos);
PARAM_INT (value);
// Set the value of the specified user array at index pos.
arraytype->ElementType->SetValue(reinterpret_cast<BYTE *>(self) + var->Offset + arraytype->ElementSize * pos, value);
PField *var = GetArrayVar(self, varname, pos);
if (var != nullptr)
{
PArray *arraytype = static_cast<PArray *>(var->Type);
arraytype->ElementType->SetValue(reinterpret_cast<BYTE *>(self) + var->Offset + arraytype->ElementSize * pos, value);
}
return 0;
}
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetUserArrayFloat)
{
PARAM_ACTION_PROLOGUE;
PARAM_NAME (varname);
PARAM_INT (pos);
PARAM_FLOAT (value);
// Set the value of the specified user array at index pos.
PField *var = GetArrayVar(self, varname, pos);
if (var != nullptr)
{
PArray *arraytype = static_cast<PArray *>(var->Type);
arraytype->ElementType->SetValue(reinterpret_cast<BYTE *>(self) + var->Offset + arraytype->ElementSize * pos, value);
}
return 0;
}

View file

@ -523,14 +523,14 @@ static void ParseUserVariable (FScanner &sc, PSymbolTable *symt, PClassActor *cl
sc.ScriptError("Native classes may not have user variables");
}
// Read the type and make sure it's int.
// Read the type and make sure it's acceptable.
sc.MustGetAnyToken();
if (sc.TokenType != TK_Int)
if (sc.TokenType != TK_Int && sc.TokenType != TK_Float)
{
sc.ScriptMessage("User variables must be of type int");
sc.ScriptMessage("User variables must be of type 'int' or 'float'");
FScriptPosition::ErrorCounter++;
}
type = TypeSInt32;
type = sc.TokenType == TK_Int ? (PType *)TypeSInt32 : (PType *)TypeFloat64;
sc.MustGetToken(TK_Identifier);
// For now, restrict user variables to those that begin with "user_" to guarantee
@ -577,7 +577,7 @@ static void ParseUserVariable (FScanner &sc, PSymbolTable *symt, PClassActor *cl
sc.MustGetToken(';');
PField *sym = new PField(symname, type, 0);
sym->Offset = cls->Extend(sizeof(int) * maxelems);
sym->Offset = cls->Extend(type);
if (symt->AddSymbol(sym) == NULL)
{
delete sym;

View file

@ -1205,8 +1205,8 @@ void DCanvas::FillSimplePoly(FTexture *tex, FVector2 *points, int npoints,
scaley /= tex->Scale.Y;
// Use the CRT's functions here.
cosrot = cos(ToRadians(rotation));
sinrot = sin(ToRadians(rotation));
cosrot = cos(rotation.Radians());
sinrot = sin(rotation.Radians());
// Setup constant texture mapping parameters.
R_SetupSpanBits(tex);

View file

@ -42,16 +42,19 @@
#include <math.h>
#include <string.h>
#include "m_fixed.h"
#include "tables.h"
#include "xs_Float.h"
#include "math/cmath.h"
#define EQUAL_EPSILON (1/65536.f)
// make this a local inline function to avoid any dependencies on other headers and not pollute the global namespace
namespace pi
{
inline double pi() { return 3.14159265358979323846; }
}
//#define DEG2RAD(d) ((d)*M_PI/180.)
//#define RAD2DEG(r) ((r)*180./M_PI)
template<class vec_t> struct TVector3;
template<class vec_t> struct TRotator;
@ -783,6 +786,10 @@ struct TAngle
{
vec_t Degrees;
private:
const double BAM_FACTOR = (90. / 0x40000000);
public:
// This is to catch any accidental attempt to assign an angle_t to this type. Any explicit exception will require a type cast.
TAngle(int) = delete;
@ -990,51 +997,27 @@ struct TAngle
}
// Ensure the angle is between [0.0,360.0) degrees
TAngle &Normalize360()
TAngle Normalized360() const
{
// Normalizing the angle converts it to a BAM, which masks it, and converts it back to a float.
// Note: We MUST use xs_Float here because it is the only method that guarantees reliable wraparound.
Degrees = (vec_t)ANGLE2DBL((unsigned int)FLOAT2ANGLE(Degrees));
return *this;
}
// Ensures the angle is between (-180.0,180.0] degrees
TAngle &Normalize180()
{
Degrees = (vec_t)ANGLE2DBL((signed int)FLOAT2ANGLE(Degrees));
return *this;
}
// Same as above but doesn't alter the calling object itself
// Ensure the angle is between [0.0,360.0) degrees
TAngle Normalized360() const
{
return (vec_t)ANGLE2DBL((unsigned int)FLOAT2ANGLE(Degrees));
return (vec_t)(BAM_FACTOR * BAMs());
}
// Ensures the angle is between (-180.0,180.0] degrees
TAngle Normalized180() const
{
return (vec_t)ANGLE2DBL((signed int)FLOAT2ANGLE(Degrees));
}
// Like Normalize360(), except the integer value is not converted back to a float.
// The steps parameter must be a power of 2.
int Quantize(int steps) const
{
return xs_CRoundToInt((Degrees * (steps/360.0)) & (steps-1));
return (vec_t)(BAM_FACTOR * (signed int)BAMs());
}
vec_t Radians() const
{
return Degrees * (M_PI / 180.0);
return Degrees * (pi::pi() / 180.0);
}
unsigned BAMs() const
{
return FLOAT2ANGLE(Degrees);
return xs_CRoundToInt(Degrees * (0x40000000 / 90.));
}
TVector2<vec_t> ToVector(vec_t length = 1) const
@ -1054,7 +1037,7 @@ struct TAngle
double Tan() const
{
return g_tan(Degrees * (M_PI / 180.));
return g_tan(Degrees * (pi::pi() / 180.));
}
// This is for calculating vertical velocity. For high pitches the tangent will become too large to be useful.
@ -1063,20 +1046,13 @@ struct TAngle
return clamp(Tan(), -max, max);
}
static inline TAngle ToDegrees(double rad)
{
return TAngle(double(rad * (180.0 / pi::pi())));
}
};
template<class T>
inline double ToRadians (const TAngle<T> &deg)
{
return double(deg.Degrees * (M_PI / 180.0));
}
// If this gets templated there will be countless instantiation errors.
inline TAngle<double> ToDegrees (double rad)
{
return TAngle<double> (double(rad * (180.0 / M_PI)));
}
// Emulates the old floatbob offset table with direct calls to trig functions.
inline double BobSin(double fb)
{
@ -1092,48 +1068,48 @@ inline TAngle<T> fabs (const TAngle<T> &deg)
template<class T>
inline TAngle<T> deltaangle(const TAngle<T> &a1, const TAngle<T> &a2)
{
return (a2 - a1).Normalize180();
return (a2 - a1).Normalized180();
}
template<class T>
inline TAngle<T> deltaangle(const TAngle<T> &a1, double a2)
{
return (a2 - a1).Normalize180();
return (a2 - a1).Normalized180();
}
template<class T>
inline TAngle<T> deltaangle(double a1, const TAngle<T> &a2)
{
return (a2 - a1).Normalize180();
return (a2 - a1).Normalized180();
}
template<class T>
inline TAngle<T> absangle(const TAngle<T> &a1, const TAngle<T> &a2)
{
return fabs((a1 - a2).Normalize180());
return fabs((a1 - a2).Normalized180());
}
template<class T>
inline TAngle<T> absangle(const TAngle<T> &a1, double a2)
{
return fabs((a1 - a2).Normalize180());
return fabs((a1 - a2).Normalized180());
}
inline TAngle<double> VecToAngle(double x, double y)
{
return g_atan2(y, x) * (180.0 / M_PI);
return g_atan2(y, x) * (180.0 / pi::pi());
}
template<class T>
inline TAngle<T> VecToAngle (const TVector2<T> &vec)
{
return (T)g_atan2(vec.Y, vec.X) * (180.0 / M_PI);
return (T)g_atan2(vec.Y, vec.X) * (180.0 / pi::pi());
}
template<class T>
inline TAngle<T> VecToAngle (const TVector3<T> &vec)
{
return (T)g_atan2(vec.Y, vec.X) * (180.0 / M_PI);
return (T)g_atan2(vec.Y, vec.X) * (180.0 / pi::pi());
}
template<class T>
@ -1296,25 +1272,6 @@ struct TRotator
{
return TRotator(Pitch - other.Pitch, Yaw - other.Yaw, Roll - other.Roll);
}
// Normalize each component
TRotator &Normalize180 ()
{
for (int i = -3; i; ++i)
{
(*this)[i+3].Normalize180();
}
return *this;
}
TRotator &Normalize360 ()
{
for (int i = -3; i; ++i)
{
(*this)[i+3].Normalize360();
}
return *this;
}
};
// Create a forward vector from a rotation (ignoring roll)

View file

@ -3105,8 +3105,8 @@ void D3DFB::FillSimplePoly(FTexture *texture, FVector2 *points, int npoints,
return;
}
cosrot = (float)cos(ToRadians(rotation));
sinrot = (float)sin(ToRadians(rotation));
cosrot = (float)cos(rotation.Radians());
sinrot = (float)sin(rotation.Radians());
CheckQuadBatch(npoints - 2, npoints);
quad = &QuadExtra[QuadBatchPos];

View file

@ -275,6 +275,8 @@ ACTOR Actor native //: Thinker
action native A_SetArg(int pos, int value);
action native A_SetUserVar(name varname, int value);
action native A_SetUserArray(name varname, int index, int value);
action native A_SetUserVarFloat(name varname, float value);
action native A_SetUserArrayFloat(name varname, int index, float value);
action native A_SetSpecial(int spec, int arg0 = 0, int arg1 = 0, int arg2 = 0, int arg3 = 0, int arg4 = 0);
action native A_Quake(int intensity, int duration, int damrad, int tremrad, sound sfx = "world/quake");
action native A_QuakeEx(int intensityX, int intensityY, int intensityZ, int duration, int damrad, int tremrad, sound sfx = "world/quake", int flags = 0, float mulWaveX = 1, float mulWaveY = 1, float mulWaveZ = 1, int falloff = 0, int highpoint = 0);