- floatified po_man.cpp and the remaining bits in p_lnspec.cpp

This commit is contained in:
Christoph Oelckers 2016-03-31 00:41:21 +02:00
parent 1666418510
commit 7a2c8fdc1c
11 changed files with 273 additions and 293 deletions

View file

@ -1143,6 +1143,9 @@ static void AM_ScrollParchment (double dmapx, double dmapy)
mapxstart = mapxstart - dmapx * scale_mtof;
mapystart = mapystart - dmapy * scale_mtof;
mapxstart = clamp(mapxstart, -40000., 40000.);
mapystart = clamp(mapxstart, -40000., 40000.);
if (mapback.isValid())
{
FTexture *backtex = TexMan[mapback];
@ -1927,7 +1930,7 @@ void AM_drawSubsectors()
points[j].Y = float(f_y + (f_h - (pt.y - m_y) * scale));
}
// For lighting and texture determination
sector_t *sec = Renderer->FakeFlat (subsectors[i].render_sector, &tempsec, &floorlight, &ceilinglight, false);
sector_t *sec = Renderer->FakeFlat(subsectors[i].render_sector, &tempsec, &floorlight, &ceilinglight, false);
// Find texture origin.
originpt.x = -sec->GetXOffsetF(sector_t::floor);
originpt.y = sec->GetYOffset(sector_t::floor);
@ -1967,7 +1970,7 @@ void AM_drawSubsectors()
}
seczb = floorplane->ZatPoint(secx, secy);
seczt = sec->ceilingplane.ZatPoint(secx, secy);
for (unsigned int i = 0; i < sec->e->XFloor.ffloors.Size(); ++i)
{
F3DFloor *rover = sec->e->XFloor.ffloors[i];
@ -2030,7 +2033,7 @@ void AM_drawSubsectors()
(colormap->Color.b + 160) / 2),
colormap->Fade,
255 - (255 - colormap->Desaturate) / 4);
floorlight = (floorlight + 200*15) / 16;
floorlight = (floorlight + 200 * 15) / 16;
}
// Draw the polygon.
@ -2106,10 +2109,10 @@ void AM_drawSeg(seg_t *seg, const AMColor &color)
void AM_drawPolySeg(FPolySeg *seg, const AMColor &color)
{
mline_t l;
l.a.x = seg->v1.x;
l.a.y = seg->v1.y;
l.b.x = seg->v2.x;
l.b.y = seg->v2.y;
l.a.x = seg->v1.pos.X;
l.a.y = seg->v1.pos.Y;
l.b.x = seg->v2.pos.X;
l.b.y = seg->v2.pos.Y;
if (am_rotate == 1 || (am_rotate == 2 && viewactive))
{

View file

@ -262,11 +262,11 @@ void FNodeBuilder::AddPolySegs(FPolySeg *segs, int numsegs)
seg.frontsector = side->sector;
seg.backsector = side->linedef->frontsector == side->sector ? side->linedef->backsector : side->linedef->frontsector;
vert.x = segs[i].v1.x;
vert.y = segs[i].v1.y;
vert.x = FLOAT2FIXED(segs[i].v1.pos.X);
vert.y = FLOAT2FIXED(segs[i].v1.pos.Y);
seg.v1 = VertexMap->SelectVertexExact(vert);
vert.x = segs[i].v2.x;
vert.y = segs[i].v2.y;
vert.x = FLOAT2FIXED(segs[i].v2.pos.X);
vert.y = FLOAT2FIXED(segs[i].v2.pos.Y);
seg.v2 = VertexMap->SelectVertexExact(vert);
seg.linedef = int(side->linedef - Level.Lines);
seg.sidedef = int(side - Level.Sides);

View file

@ -5320,7 +5320,7 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, SDWORD *args)
FPolyObj *poly = PO_GetPolyobj(args[0]);
if (poly != NULL)
{
return poly->StartSpot.x;
return DoubleToACS(poly->StartSpot.pos.X);
}
}
return FIXED_MAX;
@ -5330,7 +5330,7 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, SDWORD *args)
FPolyObj *poly = PO_GetPolyobj(args[0]);
if (poly != NULL)
{
return poly->StartSpot.y;
return DoubleToACS(poly->StartSpot.pos.Y);
}
}
return FIXED_MAX;

View file

@ -80,10 +80,8 @@ static const BYTE ChangeMap[8] = { 0, 1, 5, 3, 7, 2, 6, 0 };
int arg0, int arg1, int arg2, int arg3, int arg4)
#define SPEED(a) ((a) / 8.)
#define _f_SPEED(a) ((a)*(FRACUNIT/8))
#define TICS(a) (((a)*TICRATE)/35)
#define OCTICS(a) (((a)*TICRATE)/8)
#define _f_BYTEANGLE(a) ((angle_t)((a)<<24))
#define BYTEANGLE(a) ((a) * (360./256.))
#define CRUSH(a) ((a) > 0? (a) : -1)
#define CHANGE(a) (((a) >= 0 && (a)<=7)? ChangeMap[a]:0)
@ -160,19 +158,19 @@ FUNC(LS_Polyobj_RotateRight)
FUNC(LS_Polyobj_Move)
// Polyobj_Move (po, speed, angle, distance)
{
return EV_MovePoly (ln, arg0, _f_SPEED(arg1), _f_BYTEANGLE(arg2), arg3 * FRACUNIT, false);
return EV_MovePoly (ln, arg0, SPEED(arg1), BYTEANGLE(arg2), arg3, false);
}
FUNC(LS_Polyobj_MoveTimes8)
// Polyobj_MoveTimes8 (po, speed, angle, distance)
{
return EV_MovePoly (ln, arg0, _f_SPEED(arg1), _f_BYTEANGLE(arg2), arg3 * FRACUNIT * 8, false);
return EV_MovePoly (ln, arg0, SPEED(arg1), BYTEANGLE(arg2), arg3 * 8, false);
}
FUNC(LS_Polyobj_MoveTo)
// Polyobj_MoveTo (po, speed, x, y)
{
return EV_MovePolyTo (ln, arg0, _f_SPEED(arg1), arg2 << FRACBITS, arg3 << FRACBITS, false);
return EV_MovePolyTo (ln, arg0, SPEED(arg1), DVector2(arg2, arg3), false);
}
FUNC(LS_Polyobj_MoveToSpot)
@ -181,19 +179,19 @@ FUNC(LS_Polyobj_MoveToSpot)
FActorIterator iterator (arg2);
AActor *spot = iterator.Next();
if (spot == NULL) return false;
return EV_MovePolyTo (ln, arg0, _f_SPEED(arg1), spot->_f_X(), spot->_f_Y(), false);
return EV_MovePolyTo (ln, arg0, SPEED(arg1), spot->Pos(), false);
}
FUNC(LS_Polyobj_DoorSwing)
// Polyobj_DoorSwing (po, speed, angle, delay)
{
return EV_OpenPolyDoor (ln, arg0, arg1, _f_BYTEANGLE(arg2), arg3, 0, PODOOR_SWING);
return EV_OpenPolyDoor (ln, arg0, arg1, BYTEANGLE(arg2), arg3, 0, PODOOR_SWING);
}
FUNC(LS_Polyobj_DoorSlide)
// Polyobj_DoorSlide (po, speed, angle, distance, delay)
{
return EV_OpenPolyDoor (ln, arg0, _f_SPEED(arg1), _f_BYTEANGLE(arg2), arg4, arg3*FRACUNIT, PODOOR_SLIDE);
return EV_OpenPolyDoor (ln, arg0, SPEED(arg1), BYTEANGLE(arg2), arg4, arg3, PODOOR_SLIDE);
}
FUNC(LS_Polyobj_OR_RotateLeft)
@ -211,19 +209,19 @@ FUNC(LS_Polyobj_OR_RotateRight)
FUNC(LS_Polyobj_OR_Move)
// Polyobj_OR_Move (po, speed, angle, distance)
{
return EV_MovePoly (ln, arg0, _f_SPEED(arg1), _f_BYTEANGLE(arg2), arg3 * FRACUNIT, true);
return EV_MovePoly (ln, arg0, SPEED(arg1), BYTEANGLE(arg2), arg3, true);
}
FUNC(LS_Polyobj_OR_MoveTimes8)
// Polyobj_OR_MoveTimes8 (po, speed, angle, distance)
{
return EV_MovePoly (ln, arg0, _f_SPEED(arg1), _f_BYTEANGLE(arg2), arg3 * FRACUNIT * 8, true);
return EV_MovePoly (ln, arg0, SPEED(arg1), BYTEANGLE(arg2), arg3 * 8, true);
}
FUNC(LS_Polyobj_OR_MoveTo)
// Polyobj_OR_MoveTo (po, speed, x, y)
{
return EV_MovePolyTo (ln, arg0, _f_SPEED(arg1), arg2 << FRACBITS, arg3 << FRACBITS, true);
return EV_MovePolyTo (ln, arg0, SPEED(arg1), DVector2(arg2, arg3), true);
}
FUNC(LS_Polyobj_OR_MoveToSpot)
@ -232,7 +230,7 @@ FUNC(LS_Polyobj_OR_MoveToSpot)
FActorIterator iterator (arg2);
AActor *spot = iterator.Next();
if (spot == NULL) return false;
return EV_MovePolyTo (ln, arg0, _f_SPEED(arg1), spot->_f_X(), spot->_f_Y(), true);
return EV_MovePolyTo (ln, arg0, SPEED(arg1), spot->Pos(), true);
}
FUNC(LS_Polyobj_Stop)
@ -806,13 +804,13 @@ FUNC(LS_Ceiling_LowerToNearest)
FUNC(LS_Ceiling_ToHighestInstant)
// Ceiling_ToHighestInstant (tag, change, crush)
{
return EV_DoCeiling (DCeiling::ceilLowerToHighest, ln, arg0, FRACUNIT*2, 0, 0, CRUSH(arg2), 0, CHANGE(arg1));
return EV_DoCeiling (DCeiling::ceilLowerToHighest, ln, arg0, 2, 0, 0, CRUSH(arg2), 0, CHANGE(arg1));
}
FUNC(LS_Ceiling_ToFloorInstant)
// Ceiling_ToFloorInstant (tag, change, crush)
{
return EV_DoCeiling (DCeiling::ceilRaiseToFloor, ln, arg0, FRACUNIT*2, 0, 0, CRUSH(arg2), 0, CHANGE(arg1));
return EV_DoCeiling (DCeiling::ceilRaiseToFloor, ln, arg0, 2, 0, 0, CRUSH(arg2), 0, CHANGE(arg1));
}
FUNC(LS_Ceiling_LowerToFloor)
@ -2373,8 +2371,8 @@ FUNC(LS_Sector_SetFade)
FUNC(LS_Sector_SetCeilingPanning)
// Sector_SetCeilingPanning (tag, x-int, x-frac, y-int, y-frac)
{
fixed_t xofs = arg1 * FRACUNIT + arg2 * (FRACUNIT/100);
fixed_t yofs = arg3 * FRACUNIT + arg4 * (FRACUNIT/100);
double xofs = arg1 + arg2 / 100.;
double yofs = arg3 + arg4 / 100.;
FSectorTagIterator itr(arg0);
int secnum;
@ -2389,8 +2387,8 @@ FUNC(LS_Sector_SetCeilingPanning)
FUNC(LS_Sector_SetFloorPanning)
// Sector_SetFloorPanning (tag, x-int, x-frac, y-int, y-frac)
{
fixed_t xofs = arg1 * FRACUNIT + arg2 * (FRACUNIT/100);
fixed_t yofs = arg3 * FRACUNIT + arg4 * (FRACUNIT/100);
double xofs = arg1 + arg2 / 100.;
double yofs = arg3 + arg4 / 100.;
FSectorTagIterator itr(arg0);
int secnum;
@ -2405,13 +2403,13 @@ FUNC(LS_Sector_SetFloorPanning)
FUNC(LS_Sector_SetFloorScale)
// Sector_SetFloorScale (tag, x-int, x-frac, y-int, y-frac)
{
fixed_t xscale = arg1 * FRACUNIT + arg2 * (FRACUNIT/100);
fixed_t yscale = arg3 * FRACUNIT + arg4 * (FRACUNIT/100);
double xscale = arg1 + arg2 / 100.;
double yscale = arg3 + arg4 / 100.;
if (xscale)
xscale = FixedDiv (FRACUNIT, xscale);
xscale = 1. / xscale;
if (yscale)
yscale = FixedDiv (FRACUNIT, yscale);
yscale = 1. / yscale;
FSectorTagIterator itr(arg0);
int secnum;
@ -2428,13 +2426,13 @@ FUNC(LS_Sector_SetFloorScale)
FUNC(LS_Sector_SetCeilingScale)
// Sector_SetCeilingScale (tag, x-int, x-frac, y-int, y-frac)
{
fixed_t xscale = arg1 * FRACUNIT + arg2 * (FRACUNIT/100);
fixed_t yscale = arg3 * FRACUNIT + arg4 * (FRACUNIT/100);
double xscale = arg1 + arg2 / 100.;
double yscale = arg3 + arg4 / 100.;
if (xscale)
xscale = FixedDiv (FRACUNIT, xscale);
xscale = 1. / xscale;
if (yscale)
yscale = FixedDiv (FRACUNIT, yscale);
yscale = 1. / yscale;
FSectorTagIterator itr(arg0);
int secnum;
@ -2451,10 +2449,12 @@ FUNC(LS_Sector_SetCeilingScale)
FUNC(LS_Sector_SetFloorScale2)
// Sector_SetFloorScale2 (tag, x-factor, y-factor)
{
if (arg1)
arg1 = FixedDiv (FRACUNIT, arg1);
if (arg2)
arg2 = FixedDiv (FRACUNIT, arg2);
double xscale = arg1 / 65536., yscale = arg2 / 65536.;
if (xscale)
xscale = 1. / xscale;
if (yscale)
yscale = 1. / yscale;
FSectorTagIterator itr(arg0);
int secnum;
@ -2471,10 +2471,12 @@ FUNC(LS_Sector_SetFloorScale2)
FUNC(LS_Sector_SetCeilingScale2)
// Sector_SetFloorScale2 (tag, x-factor, y-factor)
{
if (arg1)
arg1 = FixedDiv (FRACUNIT, arg1);
if (arg2)
arg2 = FixedDiv (FRACUNIT, arg2);
double xscale = arg1 / 65536., yscale = arg2 / 65536.;
if (xscale)
xscale = 1. / xscale;
if (yscale)
yscale = 1. / yscale;
FSectorTagIterator itr(arg0);
int secnum;
@ -2491,8 +2493,8 @@ FUNC(LS_Sector_SetCeilingScale2)
FUNC(LS_Sector_SetRotation)
// Sector_SetRotation (tag, floor-angle, ceiling-angle)
{
angle_t ceiling = arg2 * ANGLE_1;
angle_t floor = arg1 * ANGLE_1;
DAngle ceiling = (double)arg2;
DAngle floor = (double)arg1;
FSectorTagIterator itr(arg0);
int secnum;
@ -2535,7 +2537,9 @@ FUNC(LS_Line_AlignFloor)
FUNC(LS_Line_SetTextureOffset)
// Line_SetTextureOffset (id, x, y, side, flags)
{
const fixed_t NO_CHANGE = 32767<<FRACBITS;
const double NO_CHANGE = FLT_MAX;
double farg1 = arg1 / 65536.;
double farg2 = arg2 / 65536.;
if (arg0 == 0 || arg3 < 0 || arg3 > 1)
return false;
@ -2553,15 +2557,15 @@ FUNC(LS_Line_SetTextureOffset)
// set
if (arg1 != NO_CHANGE)
{
if (arg4&1) side->SetTextureXOffset(side_t::top, arg1);
if (arg4&2) side->SetTextureXOffset(side_t::mid, arg1);
if (arg4&4) side->SetTextureXOffset(side_t::bottom, arg1);
if (arg4&1) side->SetTextureXOffset(side_t::top, farg1);
if (arg4&2) side->SetTextureXOffset(side_t::mid, farg1);
if (arg4&4) side->SetTextureXOffset(side_t::bottom, farg1);
}
if (arg2 != NO_CHANGE)
{
if (arg4&1) side->SetTextureYOffset(side_t::top, arg2);
if (arg4&2) side->SetTextureYOffset(side_t::mid, arg2);
if (arg4&4) side->SetTextureYOffset(side_t::bottom, arg2);
if (arg4&1) side->SetTextureYOffset(side_t::top, farg2);
if (arg4&2) side->SetTextureYOffset(side_t::mid, farg2);
if (arg4&4) side->SetTextureYOffset(side_t::bottom, farg2);
}
}
else
@ -2569,15 +2573,15 @@ FUNC(LS_Line_SetTextureOffset)
// add
if (arg1 != NO_CHANGE)
{
if (arg4&1) side->AddTextureXOffset(side_t::top, arg1);
if (arg4&2) side->AddTextureXOffset(side_t::mid, arg1);
if (arg4&4) side->AddTextureXOffset(side_t::bottom, arg1);
if (arg4&1) side->AddTextureXOffset(side_t::top, farg1);
if (arg4&2) side->AddTextureXOffset(side_t::mid, farg1);
if (arg4&4) side->AddTextureXOffset(side_t::bottom, farg1);
}
if (arg2 != NO_CHANGE)
{
if (arg4&1) side->AddTextureYOffset(side_t::top, arg2);
if (arg4&2) side->AddTextureYOffset(side_t::mid, arg2);
if (arg4&4) side->AddTextureYOffset(side_t::bottom, arg2);
if (arg4&1) side->AddTextureYOffset(side_t::top, farg2);
if (arg4&2) side->AddTextureYOffset(side_t::mid, farg2);
if (arg4&4) side->AddTextureYOffset(side_t::bottom, farg2);
}
}
}
@ -2588,7 +2592,9 @@ FUNC(LS_Line_SetTextureOffset)
FUNC(LS_Line_SetTextureScale)
// Line_SetTextureScale (id, x, y, side, flags)
{
const fixed_t NO_CHANGE = 32767<<FRACBITS;
const double NO_CHANGE = FLT_MAX;
double farg1 = arg1 / 65536.;
double farg2 = arg2 / 65536.;
if (arg0 == 0 || arg3 < 0 || arg3 > 1)
return false;
@ -2605,15 +2611,15 @@ FUNC(LS_Line_SetTextureScale)
// set
if (arg1 != NO_CHANGE)
{
if (arg4&1) side->SetTextureXScale(side_t::top, arg1);
if (arg4&2) side->SetTextureXScale(side_t::mid, arg1);
if (arg4&4) side->SetTextureXScale(side_t::bottom, arg1);
if (arg4&1) side->SetTextureXScale(side_t::top, farg1);
if (arg4&2) side->SetTextureXScale(side_t::mid, farg1);
if (arg4&4) side->SetTextureXScale(side_t::bottom, farg1);
}
if (arg2 != NO_CHANGE)
{
if (arg4&1) side->SetTextureYScale(side_t::top, arg2);
if (arg4&2) side->SetTextureYScale(side_t::mid, arg2);
if (arg4&4) side->SetTextureYScale(side_t::bottom, arg2);
if (arg4&1) side->SetTextureYScale(side_t::top, farg2);
if (arg4&2) side->SetTextureYScale(side_t::mid, farg2);
if (arg4&4) side->SetTextureYScale(side_t::bottom, farg2);
}
}
else
@ -2621,15 +2627,15 @@ FUNC(LS_Line_SetTextureScale)
// add
if (arg1 != NO_CHANGE)
{
if (arg4&1) side->MultiplyTextureXScale(side_t::top, arg1);
if (arg4&2) side->MultiplyTextureXScale(side_t::mid, arg1);
if (arg4&4) side->MultiplyTextureXScale(side_t::bottom, arg1);
if (arg4&1) side->MultiplyTextureXScale(side_t::top, farg1);
if (arg4&2) side->MultiplyTextureXScale(side_t::mid, farg1);
if (arg4&4) side->MultiplyTextureXScale(side_t::bottom, farg1);
}
if (arg2 != NO_CHANGE)
{
if (arg4&1) side->MultiplyTextureYScale(side_t::top, arg2);
if (arg4&2) side->MultiplyTextureYScale(side_t::mid, arg2);
if (arg4&4) side->MultiplyTextureYScale(side_t::bottom, arg2);
if (arg4&1) side->MultiplyTextureYScale(side_t::top, farg2);
if (arg4&2) side->MultiplyTextureYScale(side_t::mid, farg2);
if (arg4&4) side->MultiplyTextureYScale(side_t::bottom, farg2);
}
}
}

View file

@ -614,15 +614,14 @@ void P_SerializePolyobjs (FArchive &arc)
arc << seg << po_NumPolyobjs;
for(i = 0, po = polyobjs; i < po_NumPolyobjs; i++, po++)
{
arc << po->tag << po->angle << po->StartSpot.x <<
po->StartSpot.y << po->interpolation;
arc << po->tag << po->Angle << po->StartSpot.pos << po->interpolation;
}
}
else
{
int data;
angle_t angle;
fixed_t deltaX, deltaY;
DAngle angle;
DVector2 delta;
arc << data;
if (data != ASEG_POLYOBJS)
@ -640,12 +639,10 @@ void P_SerializePolyobjs (FArchive &arc)
{
I_Error ("UnarchivePolyobjs: Invalid polyobj tag");
}
arc << angle;
arc << angle << delta << po->interpolation;
po->RotatePolyobj (angle, true);
arc << deltaX << deltaY << po->interpolation;
deltaX -= po->StartSpot.x;
deltaY -= po->StartSpot.y;
po->MovePolyobj (deltaX, deltaY, true);
delta -= po->StartSpot.pos;
po->MovePolyobj (delta, true);
}
}
}

View file

@ -77,14 +77,14 @@ public:
void Serialize (FArchive &arc);
void Destroy();
void Stop();
int GetSpeed() const { return m_Speed; }
double GetSpeed() const { return m_Speed; }
void StopInterpolation ();
protected:
DPolyAction ();
int m_PolyObj;
int m_Speed;
int m_Dist;
double m_Speed;
double m_Dist;
TObjPtr<DInterpolation> m_Interpolation;
void SetInterpolation ();
@ -112,11 +112,10 @@ public:
void Tick ();
protected:
DMovePoly ();
int m_Angle;
fixed_t m_xSpeed; // for sliding walls
fixed_t m_ySpeed;
DAngle m_Angle;
DVector2 m_Speedv;
friend bool EV_MovePoly (line_t *line, int polyNum, int speed, angle_t angle, fixed_t dist, bool overRide);
friend bool EV_MovePoly(line_t *line, int polyNum, double speed, DAngle angle, double dist, bool overRide);
};
class DMovePolyTo : public DPolyAction
@ -128,12 +127,10 @@ public:
void Tick();
protected:
DMovePolyTo();
fixed_t m_xSpeed;
fixed_t m_ySpeed;
fixed_t m_xTarget;
fixed_t m_yTarget;
DVector2 m_Speedv;
DVector2 m_Target;
friend bool EV_MovePolyTo(line_t *line, int polyNum, int speed, fixed_t x, fixed_t y, bool overRide);
friend bool EV_MovePolyTo(line_t *line, int polyNum, double speed, const DVector2 &pos, bool overRide);
};
@ -145,14 +142,14 @@ public:
void Serialize (FArchive &arc);
void Tick ();
protected:
int m_Direction;
int m_TotalDist;
DAngle m_Direction;
double m_TotalDist;
int m_Tics;
int m_WaitTics;
podoortype_t m_Type;
bool m_Close;
friend bool EV_OpenPolyDoor (line_t *line, int polyNum, int speed, angle_t angle, int delay, int distance, podoortype_t type);
friend bool EV_OpenPolyDoor(line_t *line, int polyNum, double speed, DAngle angle, int delay, double distance, podoortype_t type);
private:
DPolyDoor ();
};
@ -180,8 +177,8 @@ static bool CheckMobjBlocking (side_t *seg, FPolyObj *po);
static void InitBlockMap (void);
static void IterFindPolySides (FPolyObj *po, side_t *side);
static void SpawnPolyobj (int index, int tag, int type);
static void TranslateToStartSpot (int tag, int originX, int originY);
static void DoMovePolyobj (FPolyObj *po, int x, int y);
static void TranslateToStartSpot (int tag, const DVector2 &origin);
static void DoMovePolyobj (FPolyObj *po, const DVector2 & move);
static void InitSegLists ();
static void KillSegLists ();
static FPolyNode *NewPolyNode();
@ -303,15 +300,14 @@ DMovePoly::DMovePoly ()
void DMovePoly::Serialize (FArchive &arc)
{
Super::Serialize (arc);
arc << m_Angle << m_xSpeed << m_ySpeed;
arc << m_Angle << m_Speed;
}
DMovePoly::DMovePoly (int polyNum)
: Super (polyNum)
{
m_Angle = 0;
m_xSpeed = 0;
m_ySpeed = 0;
m_Angle = 0.;
m_Speedv = { 0,0 };
}
//==========================================================================
@ -330,16 +326,13 @@ DMovePolyTo::DMovePolyTo()
void DMovePolyTo::Serialize(FArchive &arc)
{
Super::Serialize(arc);
arc << m_xSpeed << m_ySpeed << m_xTarget << m_yTarget;
arc << m_Speedv << m_Target;
}
DMovePolyTo::DMovePolyTo(int polyNum)
: Super(polyNum)
{
m_xSpeed = 0;
m_ySpeed = 0;
m_xTarget = 0;
m_yTarget = 0;
m_Speedv = m_Target = { 0,0 };
}
//==========================================================================
@ -363,7 +356,7 @@ void DPolyDoor::Serialize (FArchive &arc)
DPolyDoor::DPolyDoor (int polyNum, podoortype_t type)
: Super (polyNum), m_Type (type)
{
m_Direction = 0;
m_Direction = 0.;
m_TotalDist = 0;
m_Tics = 0;
m_WaitTics = 0;
@ -384,7 +377,7 @@ void DRotatePoly::Tick ()
if (poly == NULL) return;
// Don't let non-perpetual polyobjs overshoot their targets.
if (m_Dist != -1 && (unsigned int)m_Dist < (unsigned int)abs(m_Speed))
if (m_Dist != -1 && m_Dist < fabs(m_Speed))
{
m_Speed = m_Speed < 0 ? -m_Dist : m_Dist;
}
@ -395,7 +388,7 @@ void DRotatePoly::Tick ()
{ // perpetual polyobj
return;
}
m_Dist -= abs(m_Speed);
m_Dist -= fabs(m_Speed);
if (m_Dist == 0)
{
SN_StopSequence (poly);
@ -436,18 +429,18 @@ bool EV_RotatePoly (line_t *line, int polyNum, int speed, int byteAngle,
{
if (byteAngle == 255)
{
pe->m_Dist = ~0;
pe->m_Dist = -1.;
}
else
{
pe->m_Dist = byteAngle*(ANGLE_90/64); // Angle
pe->m_Dist = byteAngle*(90./64); // Angle
}
}
else
{
pe->m_Dist = ANGLE_MAX-1;
pe->m_Dist = 360.;
}
pe->m_Speed = speed*direction*(ANGLE_90/(64<<3));
pe->m_Speed = speed*direction*(90./(64<<3));
SN_StartSequence (poly, poly->seqType, SEQ_DOOR, 0);
direction = -direction; // Reverse the direction
}
@ -466,9 +459,9 @@ void DMovePoly::Tick ()
if (poly != NULL)
{
if (poly->MovePolyobj (m_xSpeed, m_ySpeed))
if (poly->MovePolyobj (m_Speedv))
{
int absSpeed = abs (m_Speed);
double absSpeed = fabs (m_Speed);
m_Dist -= absSpeed;
if (m_Dist <= 0)
{
@ -478,8 +471,7 @@ void DMovePoly::Tick ()
else if (m_Dist < absSpeed)
{
m_Speed = m_Dist * (m_Speed < 0 ? -1 : 1);
m_xSpeed = FixedMul (m_Speed, finecosine[m_Angle]);
m_ySpeed = FixedMul (m_Speed, finesine[m_Angle]);
m_Speedv = m_Angle.ToVector(m_Speed);
}
}
}
@ -491,12 +483,12 @@ void DMovePoly::Tick ()
//
//==========================================================================
bool EV_MovePoly (line_t *line, int polyNum, int speed, angle_t angle,
fixed_t dist, bool overRide)
bool EV_MovePoly (line_t *line, int polyNum, double speed, DAngle angle,
double dist, bool overRide)
{
DMovePoly *pe = NULL;
FPolyObj *poly;
angle_t an = angle;
DAngle an = angle;
if ((poly = PO_GetPolyobj(polyNum)) == NULL)
{
@ -515,9 +507,8 @@ bool EV_MovePoly (line_t *line, int polyNum, int speed, angle_t angle,
poly->specialdata = pe;
pe->m_Dist = dist; // Distance
pe->m_Speed = speed;
pe->m_Angle = an >> ANGLETOFINESHIFT;
pe->m_xSpeed = FixedMul (pe->m_Speed, finecosine[pe->m_Angle]);
pe->m_ySpeed = FixedMul (pe->m_Speed, finesine[pe->m_Angle]);
pe->m_Angle = angle;
pe->m_Speedv = angle.ToVector(speed);
SN_StartSequence (poly, poly->seqType, SEQ_DOOR, 0);
// Do not interpolate very fast moving polyobjects. The minimum tic count is
@ -529,7 +520,7 @@ bool EV_MovePoly (line_t *line, int polyNum, int speed, angle_t angle,
pe->StopInterpolation ();
}
an = an + ANGLE_180; // Reverse the angle.
angle += 180.; // Reverse the angle.
}
return pe != NULL; // Return true if something started moving.
}
@ -546,9 +537,9 @@ void DMovePolyTo::Tick ()
if (poly != NULL)
{
if (poly->MovePolyobj (m_xSpeed, m_ySpeed))
if (poly->MovePolyobj (m_Speedv))
{
int absSpeed = abs (m_Speed);
double absSpeed = fabs (m_Speed);
m_Dist -= absSpeed;
if (m_Dist <= 0)
{
@ -558,8 +549,7 @@ void DMovePolyTo::Tick ()
else if (m_Dist < absSpeed)
{
m_Speed = m_Dist * (m_Speed < 0 ? -1 : 1);
m_xSpeed = m_xTarget - poly->StartSpot.x;
m_ySpeed = m_yTarget - poly->StartSpot.y;
m_Speedv = m_Target - poly->StartSpot.pos;
}
}
}
@ -571,7 +561,7 @@ void DMovePolyTo::Tick ()
//
//==========================================================================
bool EV_MovePolyTo(line_t *line, int polyNum, int speed, fixed_t targx, fixed_t targy, bool overRide)
bool EV_MovePolyTo(line_t *line, int polyNum, double speed, const DVector2 &targ, bool overRide)
{
DMovePolyTo *pe = NULL;
FPolyObj *poly;
@ -585,8 +575,7 @@ bool EV_MovePolyTo(line_t *line, int polyNum, int speed, fixed_t targx, fixed_t
}
FPolyMirrorIterator it(poly);
dist.X = targx - poly->StartSpot.x;
dist.Y = targy - poly->StartSpot.y;
dist = targ - poly->StartSpot.pos;
distlen = dist.MakeUnit();
while ((poly = it.NextMirror()) != NULL)
{
@ -596,12 +585,10 @@ bool EV_MovePolyTo(line_t *line, int polyNum, int speed, fixed_t targx, fixed_t
}
pe = new DMovePolyTo(poly->tag);
poly->specialdata = pe;
pe->m_Dist = xs_RoundToInt(distlen);
pe->m_Dist = distlen;
pe->m_Speed = speed;
pe->m_xSpeed = xs_RoundToInt(speed * dist.X);
pe->m_ySpeed = xs_RoundToInt(speed * dist.Y);
pe->m_xTarget = xs_RoundToInt(poly->StartSpot.x + distlen * dist.X);
pe->m_yTarget = xs_RoundToInt(poly->StartSpot.y + distlen * dist.Y);
pe->m_Speedv = dist * speed;
pe->m_Target = poly->StartSpot.pos + dist * distlen;
if ((pe->m_Dist / pe->m_Speed) <= 2)
{
pe->StopInterpolation();
@ -619,7 +606,6 @@ bool EV_MovePolyTo(line_t *line, int polyNum, int speed, fixed_t targx, fixed_t
void DPolyDoor::Tick ()
{
int absSpeed;
FPolyObj *poly = PO_GetPolyobj (m_PolyObj);
if (poly == NULL) return;
@ -635,9 +621,9 @@ void DPolyDoor::Tick ()
switch (m_Type)
{
case PODOOR_SLIDE:
if (m_Dist <= 0 || poly->MovePolyobj (m_xSpeed, m_ySpeed))
if (m_Dist <= 0 || poly->MovePolyobj (m_Speedv))
{
absSpeed = abs (m_Speed);
double absSpeed = fabs (m_Speed);
m_Dist -= absSpeed;
if (m_Dist <= 0)
{
@ -647,9 +633,8 @@ void DPolyDoor::Tick ()
m_Dist = m_TotalDist;
m_Close = true;
m_Tics = m_WaitTics;
m_Direction = (ANGLE_MAX>>ANGLETOFINESHIFT) - m_Direction;
m_xSpeed = -m_xSpeed;
m_ySpeed = -m_ySpeed;
m_Direction = -m_Direction;
m_Speedv = -m_Speedv;
}
else
{
@ -666,10 +651,8 @@ void DPolyDoor::Tick ()
else
{ // open back up
m_Dist = m_TotalDist - m_Dist;
m_Direction = (ANGLE_MAX>>ANGLETOFINESHIFT)-
m_Direction;
m_xSpeed = -m_xSpeed;
m_ySpeed = -m_ySpeed;
m_Direction = -m_Direction;
m_Speedv = -m_Speedv;
m_Close = false;
SN_StartSequence (poly, poly->seqType, SEQ_DOOR, 0);
}
@ -679,7 +662,7 @@ void DPolyDoor::Tick ()
case PODOOR_SWING:
if (m_Dist <= 0 || poly->RotatePolyobj (m_Speed))
{
absSpeed = abs (m_Speed);
double absSpeed = fabs (m_Speed);
m_Dist -= absSpeed;
if (m_Dist <= 0)
{
@ -724,8 +707,7 @@ void DPolyDoor::Tick ()
//
//==========================================================================
bool EV_OpenPolyDoor (line_t *line, int polyNum, int speed, angle_t angle,
int delay, int distance, podoortype_t type)
bool EV_OpenPolyDoor(line_t *line, int polyNum, double speed, DAngle angle, int delay, double distance, podoortype_t type)
{
DPolyDoor *pd = NULL;
FPolyObj *poly;
@ -751,18 +733,17 @@ bool EV_OpenPolyDoor (line_t *line, int polyNum, int speed, angle_t angle,
pd->m_WaitTics = delay;
pd->m_Speed = speed;
pd->m_Dist = pd->m_TotalDist = distance; // Distance
pd->m_Direction = angle >> ANGLETOFINESHIFT;
pd->m_xSpeed = FixedMul (pd->m_Speed, finecosine[pd->m_Direction]);
pd->m_ySpeed = FixedMul (pd->m_Speed, finesine[pd->m_Direction]);
pd->m_Direction = angle;
pd->m_Speedv = angle.ToVector(speed);
SN_StartSequence (poly, poly->seqType, SEQ_DOOR, 0);
angle += ANGLE_180; // reverse the angle
angle += 180.; // reverse the angle
}
else if (type == PODOOR_SWING)
{
pd->m_WaitTics = delay;
pd->m_Direction = swingdir;
pd->m_Speed = (speed*pd->m_Direction*(ANGLE_90/64))>>3;
pd->m_Dist = pd->m_TotalDist = angle;
pd->m_Direction.Degrees = swingdir;
pd->m_Speed = (speed*swingdir*(90. / 64)) / 8;
pd->m_Dist = pd->m_TotalDist = angle.Degrees;
SN_StartSequence (poly, poly->seqType, SEQ_DOOR, 0);
swingdir = -swingdir; // reverse the direction
}
@ -823,15 +804,15 @@ FPolyObj *PO_GetPolyobj (int polyNum)
FPolyObj::FPolyObj()
{
StartSpot.x = StartSpot.y = 0;
angle = 0;
StartSpot.pos = { 0,0 };
Angle = 0.;
tag = 0;
memset(bbox, 0, sizeof(bbox));
validcount = 0;
crush = 0;
bHurtOnTouch = false;
seqType = 0;
size = 0;
Size = 0;
subsectorlinks = NULL;
specialdata = NULL;
interpolation = NULL;
@ -859,7 +840,7 @@ void FPolyObj::ThrustMobj (AActor *actor, side_t *side)
DAngle thrustAngle;
DPolyAction *pe;
int force;
double force;
if (!(actor->flags&MF_SHOOTABLE) && !actor->player)
{
@ -874,27 +855,20 @@ void FPolyObj::ThrustMobj (AActor *actor, side_t *side)
{
if (pe->IsKindOf (RUNTIME_CLASS (DRotatePoly)))
{
force = pe->GetSpeed() >> 8;
force = pe->GetSpeed() * (90. / 2048); // For DRotatePoly m_Speed stores an angle which needs to be converted differently
}
else
{
force = pe->GetSpeed() >> 3;
}
if (force < FRACUNIT)
{
force = FRACUNIT;
}
else if (force > 4*FRACUNIT)
{
force = 4*FRACUNIT;
force = pe->GetSpeed() / 8;
}
force = clamp(force, 1., 4.);
}
else
{
force = FRACUNIT;
force = 1;
}
DVector2 thrust = thrustAngle.ToVector(FIXED2FLOAT(force));
DVector2 thrust = thrustAngle.ToVector(force);
actor->Vel += thrust;
if (crush)
@ -952,14 +926,12 @@ void FPolyObj::UpdateBBox ()
void FPolyObj::CalcCenter()
{
SQWORD cx = 0, cy = 0;
DVector2 c = { 0, 0 };
for(unsigned i=0;i<Vertices.Size(); i++)
{
cx += Vertices[i]->fixX();
cy += Vertices[i]->fixY();
c += Vertices[i]->fPos();
}
CenterSpot.x = (fixed_t)(cx / Vertices.Size());
CenterSpot.y = (fixed_t)(cy / Vertices.Size());
CenterSpot.pos = c / Vertices.Size();
}
//==========================================================================
@ -968,11 +940,11 @@ void FPolyObj::CalcCenter()
//
//==========================================================================
bool FPolyObj::MovePolyobj (int x, int y, bool force)
bool FPolyObj::MovePolyobj (const DVector2 &pos, bool force)
{
FBoundingBox oldbounds = Bounds;
UnLinkPolyobj ();
DoMovePolyobj (x, y);
DoMovePolyobj (pos);
if (!force)
{
@ -987,15 +959,13 @@ bool FPolyObj::MovePolyobj (int x, int y, bool force)
}
if (blocked)
{
DoMovePolyobj (-x, -y);
DoMovePolyobj (-pos);
LinkPolyobj();
return false;
}
}
StartSpot.x += x;
StartSpot.y += y;
CenterSpot.x += x;
CenterSpot.y += y;
StartSpot.pos += pos;
CenterSpot.pos += pos;
LinkPolyobj ();
ClearSubsectorLinks();
RecalcActorFloorCeil(Bounds | oldbounds);
@ -1008,20 +978,19 @@ bool FPolyObj::MovePolyobj (int x, int y, bool force)
//
//==========================================================================
void FPolyObj::DoMovePolyobj (int x, int y)
void FPolyObj::DoMovePolyobj (const DVector2 &pos)
{
for(unsigned i=0;i < Vertices.Size(); i++)
{
Vertices[i]->set(Vertices[i]->fixX() + x, Vertices[i]->fixY() + y);
PrevPts[i].x += x;
PrevPts[i].y += y;
Vertices[i]->set(Vertices[i]->fX() + pos.X, Vertices[i]->fY() + pos.Y);
PrevPts[i].pos += pos;
}
for (unsigned i = 0; i < Linedefs.Size(); i++)
{
Linedefs[i]->bbox[BOXTOP] += y;
Linedefs[i]->bbox[BOXBOTTOM] += y;
Linedefs[i]->bbox[BOXLEFT] += x;
Linedefs[i]->bbox[BOXRIGHT] += x;
Linedefs[i]->bbox[BOXTOP] += FLOAT2FIXED(pos.Y);
Linedefs[i]->bbox[BOXBOTTOM] += FLOAT2FIXED(pos.Y);
Linedefs[i]->bbox[BOXLEFT] += FLOAT2FIXED(pos.X);
Linedefs[i]->bbox[BOXRIGHT] += FLOAT2FIXED(pos.X);
}
}
@ -1031,16 +1000,15 @@ void FPolyObj::DoMovePolyobj (int x, int y)
//
//==========================================================================
static void RotatePt (DAngle an, fixed_t *x, fixed_t *y, fixed_t startSpotX, fixed_t startSpotY)
static void RotatePt (DAngle an, DVector2 &out, const DVector2 &start)
{
fixed_t tr_x = *x;
fixed_t tr_y = *y;
DVector2 tr = out;
double s = an.Sin();
double c = an.Cos();
*x = (xs_CRoundToInt(tr_x * c - tr_y*s) & 0xfffffe00) + startSpotX;
*y = (xs_CRoundToInt(tr_x * s + tr_y*c) & 0xfffffe00) + startSpotY;
out.X = tr.X * c - tr.Y * s + start.X;
out.Y = tr.X * s + tr.Y * c + start.Y;
}
//==========================================================================
@ -1049,23 +1017,22 @@ static void RotatePt (DAngle an, fixed_t *x, fixed_t *y, fixed_t startSpotX, fix
//
//==========================================================================
bool FPolyObj::RotatePolyobj (angle_t angle, bool fromsave)
bool FPolyObj::RotatePolyobj (DAngle angle, bool fromsave)
{
DAngle an;
bool blocked;
FBoundingBox oldbounds = Bounds;
an = ANGLE2DBL(this->angle + angle);
an = Angle + angle;
UnLinkPolyobj();
for(unsigned i=0;i < Vertices.Size(); i++)
{
PrevPts[i].x = Vertices[i]->fixX();
PrevPts[i].y = Vertices[i]->fixY();
PrevPts[i].pos = Vertices[i]->fPos();
FPolyVertex torot = OriginalPts[i];
RotatePt(an, &torot.x, &torot.y, StartSpot.x, StartSpot.y);
Vertices[i]->set(torot.x, torot.y);
RotatePt(an, torot.pos, StartSpot.pos);
Vertices[i]->set(torot.pos.X, torot.pos.Y);
}
blocked = false;
validcount++;
@ -1085,14 +1052,14 @@ bool FPolyObj::RotatePolyobj (angle_t angle, bool fromsave)
{
for(unsigned i=0;i < Vertices.Size(); i++)
{
Vertices[i]->set(PrevPts[i].x, PrevPts[i].y);
Vertices[i]->set(PrevPts[i].pos.X, PrevPts[i].pos.Y);
}
UpdateBBox();
LinkPolyobj();
return false;
}
}
this->angle += angle;
Angle += angle;
LinkPolyobj();
ClearSubsectorLinks();
RecalcActorFloorCeil(Bounds | oldbounds);
@ -1214,7 +1181,7 @@ bool FPolyObj::CheckMobjBlocking (side_t *sd)
performBlockingThrust = true;
}
FBoundingBox box(mobj->_f_X(), mobj->_f_Y(), mobj->_f_radius());
FBoundingBox box(mobj->X(), mobj->Y(), mobj->radius);
if (box.Right() <= ld->bbox[BOXLEFT]
|| box.Left() >= ld->bbox[BOXRIGHT]
@ -1360,10 +1327,10 @@ void FPolyObj::RecalcActorFloorCeil(FBoundingBox bounds) const
//
//===========================================================================
void FPolyObj::ClosestPoint(fixed_t fx, fixed_t fy, fixed_t &ox, fixed_t &oy, side_t **side) const
void FPolyObj::ClosestPoint(const DVector2 &fpos, DVector2 &out, side_t **side) const
{
unsigned int i;
double x = fx, y = fy;
double x = fpos.X, y = fpos.Y;
double bestdist = HUGE_VAL;
double bestx = 0, besty = 0;
side_t *bestline = NULL;
@ -1372,34 +1339,34 @@ void FPolyObj::ClosestPoint(fixed_t fx, fixed_t fy, fixed_t &ox, fixed_t &oy, si
{
vertex_t *v1 = Sidedefs[i]->V1();
vertex_t *v2 = Sidedefs[i]->V2();
double a = v2->fixX() - v1->fixX();
double b = v2->fixY() - v1->fixY();
double a = v2->fX() - v1->fX();
double b = v2->fY() - v1->fY();
double den = a*a + b*b;
double ix, iy, dist;
if (den == 0)
{ // Line is actually a point!
ix = v1->fixX();
iy = v1->fixY();
ix = v1->fX();
iy = v1->fY();
}
else
{
double num = (x - v1->fixX()) * a + (y - v1->fixY()) * b;
double num = (x - v1->fX()) * a + (y - v1->fY()) * b;
double u = num / den;
if (u <= 0)
{
ix = v1->fixX();
iy = v1->fixY();
ix = v1->fX();
iy = v1->fY();
}
else if (u >= 1)
{
ix = v2->fixX();
iy = v2->fixY();
ix = v2->fX();
iy = v2->fY();
}
else
{
ix = v1->fixX() + u * a;
iy = v1->fixY() + u * b;
ix = v1->fX() + u * a;
iy = v1->fY() + u * b;
}
}
a = (ix - x);
@ -1413,8 +1380,7 @@ void FPolyObj::ClosestPoint(fixed_t fx, fixed_t fy, fixed_t &ox, fixed_t &oy, si
bestline = Sidedefs[i];
}
}
ox = fixed_t(bestx);
oy = fixed_t(besty);
out = { bestx, besty };
if (side != NULL)
{
*side = bestline;
@ -1650,11 +1616,10 @@ static void SpawnPolyobj (int index, int tag, int type)
//
//==========================================================================
static void TranslateToStartSpot (int tag, int originX, int originY)
static void TranslateToStartSpot (int tag, const DVector2 &origin)
{
FPolyObj *po;
int deltaX;
int deltaY;
DVector2 delta;
po = NULL;
for (int i = 0; i < po_NumPolyobjs; i++)
@ -1675,8 +1640,7 @@ static void TranslateToStartSpot (int tag, int originX, int originY)
}
po->OriginalPts.Resize(po->Sidedefs.Size());
po->PrevPts.Resize(po->Sidedefs.Size());
deltaX = originX - po->StartSpot.x;
deltaY = originY - po->StartSpot.y;
delta = origin - po->StartSpot.pos;
for (unsigned i = 0; i < po->Sidedefs.Size(); i++)
{
@ -1684,20 +1648,19 @@ static void TranslateToStartSpot (int tag, int originX, int originY)
}
for (unsigned i = 0; i < po->Linedefs.Size(); i++)
{
po->Linedefs[i]->bbox[BOXTOP] -= deltaY;
po->Linedefs[i]->bbox[BOXBOTTOM] -= deltaY;
po->Linedefs[i]->bbox[BOXLEFT] -= deltaX;
po->Linedefs[i]->bbox[BOXRIGHT] -= deltaX;
po->Linedefs[i]->bbox[BOXTOP] -= FLOAT2FIXED(delta.Y);
po->Linedefs[i]->bbox[BOXBOTTOM] -= FLOAT2FIXED(delta.Y);
po->Linedefs[i]->bbox[BOXLEFT] -= FLOAT2FIXED(delta.X);
po->Linedefs[i]->bbox[BOXRIGHT] -= FLOAT2FIXED(delta.X);
}
for (unsigned i = 0; i < po->Vertices.Size(); i++)
{
po->Vertices[i]->set(po->Vertices[i]->fixX() - deltaX, po->Vertices[i]->fixY() - deltaY);
po->OriginalPts[i].x = po->Vertices[i]->fixX() - po->StartSpot.x;
po->OriginalPts[i].y = po->Vertices[i]->fixY() - po->StartSpot.y;
po->Vertices[i]->set(po->Vertices[i]->fX() - delta.X, po->Vertices[i]->fY() - delta.Y);
po->OriginalPts[i].pos = po->Vertices[i]->fPos() - po->StartSpot.pos;
}
po->CalcCenter();
// For compatibility purposes
po->CenterSubsector = R_PointInSubsector(po->CenterSpot.x, po->CenterSpot.y);
po->CenterSubsector = R_PointInSubsector(po->CenterSpot.pos);
}
//==========================================================================
@ -1728,8 +1691,7 @@ void PO_Init (void)
if (polyspawn->type >= SMT_PolySpawn && polyspawn->type <= SMT_PolySpawnHurt)
{
// Polyobj StartSpot Pt.
polyobjs[polyIndex].StartSpot.x = FLOAT2FIXED(polyspawn->pos.X);
polyobjs[polyIndex].StartSpot.y = FLOAT2FIXED(polyspawn->pos.Y);
polyobjs[polyIndex].StartSpot.pos = polyspawn->pos;
SpawnPolyobj(polyIndex, polyspawn->angle, polyspawn->type);
polyIndex++;
*prev = polyspawn->next;
@ -1748,7 +1710,7 @@ void PO_Init (void)
if (polyspawn->type == SMT_PolyAnchor)
{
// Polyobj Anchor Pt.
TranslateToStartSpot (polyspawn->angle, FLOAT2FIXED(polyspawn->pos.X), FLOAT2FIXED(polyspawn->pos.Y));
TranslateToStartSpot (polyspawn->angle, polyspawn->pos);
}
delete polyspawn;
polyspawn = next;
@ -1766,14 +1728,14 @@ void PO_Init (void)
}
InitBlockMap();
// [RH] Don't need the seg lists anymore
// [RH] Don't need the side lists anymore
KillSideLists ();
for(int i=0;i<numnodes;i++)
{
node_t *no = &nodes[i];
double fdx = (double)no->dx;
double fdy = (double)no->dy;
double fdx = FIXED2DBL(no->dx);
double fdy = FIXED2DBL(no->dy);
no->len = (float)g_sqrt(fdx * fdx + fdy * fdy);
}
@ -1876,14 +1838,14 @@ static bool GetIntersection(FPolySeg *seg, node_t *bsp, FPolyVertex *v)
double num;
double den;
double v2x = (double)seg->v1.x;
double v2y = (double)seg->v1.y;
double v2dx = (double)(seg->v2.x - seg->v1.x);
double v2dy = (double)(seg->v2.y - seg->v1.y);
double v1x = (double)bsp->x;
double v1y = (double)bsp->y;
double v1dx = (double)bsp->dx;
double v1dy = (double)bsp->dy;
double v2x = seg->v1.pos.X;
double v2y = seg->v1.pos.Y;
double v2dx = seg->v2.pos.X - v2x;
double v2dy = seg->v2.pos.Y - v2y;
double v1x = FIXED2DBL(bsp->x);
double v1y = FIXED2DBL(bsp->y);
double v1dx = FIXED2DBL(bsp->dx);
double v1dy = FIXED2DBL(bsp->dy);
den = v1dy*v2dx - v1dx*v2dy;
@ -1895,8 +1857,8 @@ static bool GetIntersection(FPolySeg *seg, node_t *bsp, FPolyVertex *v)
if (frac < 0. || frac > 1.) return false;
v->x = xs_RoundToInt(v2x + frac * v2dx);
v->y = xs_RoundToInt(v2y + frac * v2dy);
v->pos.X = v2x + frac * v2dx;
v->pos.Y = v2y + frac * v2dy;
return true;
}
@ -1910,7 +1872,7 @@ static bool GetIntersection(FPolySeg *seg, node_t *bsp, FPolyVertex *v)
static double PartitionDistance(FPolyVertex *vt, node_t *node)
{
return fabs(double(-node->dy) * (vt->x - node->x) + double(node->dx) * (vt->y - node->y)) / node->len;
return fabs(FIXED2DBL(-node->dy) * (vt->pos.X - FIXED2DBL(node->x)) + FIXED2DBL(node->dx) * (vt->pos.Y - FIXED2DBL(node->y))) / node->len;
}
//==========================================================================
@ -1947,21 +1909,23 @@ static void AddToBBox(fixed_t child[4], fixed_t parent[4])
static void AddToBBox(FPolyVertex *v, fixed_t bbox[4])
{
if (v->x < bbox[BOXLEFT])
fixed_t x = FLOAT2FIXED(v->pos.X);
fixed_t y = FLOAT2FIXED(v->pos.Y);
if (x < bbox[BOXLEFT])
{
bbox[BOXLEFT] = v->x;
bbox[BOXLEFT] = x;
}
if (v->x > bbox[BOXRIGHT])
if (x > bbox[BOXRIGHT])
{
bbox[BOXRIGHT] = v->x;
bbox[BOXRIGHT] = x;
}
if (v->y < bbox[BOXBOTTOM])
if (y < bbox[BOXBOTTOM])
{
bbox[BOXBOTTOM] = v->y;
bbox[BOXBOTTOM] = y;
}
if (v->y > bbox[BOXTOP])
if (y > bbox[BOXTOP])
{
bbox[BOXTOP] = v->y;
bbox[BOXTOP] = y;
}
}
@ -1980,7 +1944,7 @@ static void SplitPoly(FPolyNode *pnode, void *node, fixed_t bbox[4])
{
node_t *bsp = (node_t *)node;
int centerside = R_PointOnSide(pnode->poly->CenterSpot.x, pnode->poly->CenterSpot.y, bsp);
int centerside = R_PointOnSide(pnode->poly->CenterSpot.pos, bsp);
lists[0].Clear();
lists[1].Clear();
@ -2016,19 +1980,19 @@ static void SplitPoly(FPolyNode *pnode, void *node, fixed_t bbox[4])
}
else
{
int side = R_PointOnSide(seg->v2.x, seg->v2.y, bsp);
int side = R_PointOnSide(seg->v2.pos, bsp);
lists[side].Push(*seg);
}
}
else if (dist_v2 <= POLY_EPSILON)
{
int side = R_PointOnSide(seg->v1.x, seg->v1.y, bsp);
int side = R_PointOnSide(seg->v1.pos, bsp);
lists[side].Push(*seg);
}
else
{
int side1 = R_PointOnSide(seg->v1.x, seg->v1.y, bsp);
int side2 = R_PointOnSide(seg->v2.x, seg->v2.y, bsp);
int side1 = R_PointOnSide(seg->v1.pos, bsp);
int side2 = R_PointOnSide(seg->v2.pos, bsp);
if(side1 != side2)
{

View file

@ -9,12 +9,11 @@ class DPolyAction;
struct FPolyVertex
{
fixed_t x, y;
DVector2 pos;
FPolyVertex &operator=(vertex_t *v)
{
x = v->fixX();
y = v->fixX();
pos = v->fPos();
return *this;
}
};
@ -57,14 +56,14 @@ struct FPolyObj
subsector_t *CenterSubsector;
int MirrorNum;
angle_t angle;
DAngle Angle;
int tag; // reference tag assigned in HereticEd
int bbox[4]; // bounds in blockmap coordinates
int validcount;
int crush; // should the polyobj attempt to crush mobjs?
bool bHurtOnTouch; // should the polyobj hurt anything it touches?
int seqType;
fixed_t size; // polyobj size (area of POLY_AREAUNIT == size of FRACUNIT)
double Size; // polyobj size (area of POLY_AREAUNIT == size of FRACUNIT)
FPolyNode *subsectorlinks;
DPolyAction *specialdata; // pointer to a thinker, if the poly is moving
TObjPtr<DInterpolation> interpolation;
@ -74,9 +73,9 @@ struct FPolyObj
void StopInterpolation();
int GetMirror();
bool MovePolyobj (int x, int y, bool force = false);
bool RotatePolyobj (angle_t angle, bool fromsave = false);
void ClosestPoint(fixed_t fx, fixed_t fy, fixed_t &ox, fixed_t &oy, side_t **side) const;
bool MovePolyobj (const DVector2 &pos, bool force = false);
bool RotatePolyobj (DAngle angle, bool fromsave = false);
void ClosestPoint(const DVector2 &fpos, DVector2 &out, side_t **side) const;
void LinkPolyobj ();
void RecalcActorFloorCeil(FBoundingBox bounds) const;
void CreateSubsectorLinks();
@ -88,7 +87,7 @@ private:
void ThrustMobj (AActor *actor, side_t *side);
void UpdateBBox ();
void DoMovePolyobj (int x, int y);
void DoMovePolyobj (const DVector2 &pos);
void UnLinkPolyobj ();
bool CheckMobjBlocking (side_t *sd);
@ -118,9 +117,9 @@ typedef enum
} podoortype_t;
bool EV_RotatePoly (line_t *line, int polyNum, int speed, int byteAngle, int direction, bool overRide);
bool EV_MovePoly (line_t *line, int polyNum, int speed, angle_t angle, fixed_t dist, bool overRide);
bool EV_MovePolyTo (line_t *line, int polyNum, int speed, fixed_t x, fixed_t y, bool overRide);
bool EV_OpenPolyDoor (line_t *line, int polyNum, int speed, angle_t angle, int delay, int distance, podoortype_t type);
bool EV_MovePoly (line_t *line, int polyNum, double speed, DAngle angle, double dist, bool overRide);
bool EV_MovePolyTo (line_t *line, int polyNum, double speed, const DVector2 &pos, bool overRide);
bool EV_OpenPolyDoor (line_t *line, int polyNum, double speed, DAngle angle, int delay, double distance, podoortype_t type);
bool EV_StopPoly (int polyNum);

View file

@ -791,8 +791,8 @@ void DPolyobjInterpolation::UpdateInterpolation()
oldverts[i*2 ] = poly->Vertices[i]->fX();
oldverts[i*2+1] = poly->Vertices[i]->fY();
}
oldcx = poly->CenterSpot.x;
oldcy = poly->CenterSpot.y;
oldcx = poly->CenterSpot.pos.X;
oldcy = poly->CenterSpot.pos.Y;
}
//==========================================================================
@ -807,8 +807,8 @@ void DPolyobjInterpolation::Restore()
{
poly->Vertices[i]->set(bakverts[i*2 ], bakverts[i*2+1]);
}
poly->CenterSpot.x = bakcx;
poly->CenterSpot.y = bakcy;
poly->CenterSpot.pos.X = bakcx;
poly->CenterSpot.pos.Y = bakcy;
poly->ClearSubsectorLinks();
}
@ -840,10 +840,10 @@ void DPolyobjInterpolation::Interpolate(double smoothratio)
}
else
{
bakcx = poly->CenterSpot.x;
bakcy = poly->CenterSpot.y;
poly->CenterSpot.x = bakcx + (bakcx - oldcx) * smoothratio;
poly->CenterSpot.y = bakcy + (bakcy - oldcy) * smoothratio;
bakcx = poly->CenterSpot.pos.X;
bakcy = poly->CenterSpot.pos.Y;
poly->CenterSpot.pos.X = bakcx + (bakcx - oldcx) * smoothratio;
poly->CenterSpot.pos.Y = bakcy + (bakcy - oldcy) * smoothratio;
poly->ClearSubsectorLinks();
}

View file

@ -1349,9 +1349,9 @@ struct side_t
{
return textures[which].xscale;
}
void MultiplyTextureXScale(int which, fixed_t delta)
void MultiplyTextureXScale(int which, double delta)
{
textures[which].xscale = FixedMul(textures[which].xscale, delta);
textures[which].xscale = fixed_t(textures[which].xscale * delta);
}
@ -1381,9 +1381,9 @@ struct side_t
{
return FIXED2DBL(textures[which].yscale);
}
void MultiplyTextureYScale(int which, fixed_t delta)
void MultiplyTextureYScale(int which, double delta)
{
textures[which].yscale = FixedMul(textures[which].yscale, delta);
textures[which].yscale = fixed_t(textures[which].yscale * delta);
}
DInterpolation *SetInterpolation(int position);

View file

@ -55,6 +55,10 @@ inline int R_PointOnSide (fixed_t x, fixed_t y, const node_t *node)
{
return DMulScale32 (y-node->y, node->dx, node->x-x, node->dy) > 0;
}
inline int R_PointOnSide(const DVector2 &pos, const node_t *node)
{
return DMulScale32(FLOAT2FIXED(pos.Y) - node->y, node->dx, node->x - FLOAT2FIXED(pos.X), node->dy) > 0;
}
angle_t R_PointToAngle2 (fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2);
inline angle_t R_PointToAngle (fixed_t x, fixed_t y) { return R_PointToAngle2 (viewx, viewy, x, y); }
@ -72,6 +76,10 @@ struct DVector3a
subsector_t *R_PointInSubsector (fixed_t x, fixed_t y);
inline subsector_t *R_PointInSubsector(const DVector2 &pos)
{
return R_PointInSubsector(FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y));
}
fixed_t R_PointToDist2 (fixed_t dx, fixed_t dy);
void R_ResetViewInterpolation ();
void R_RebuildViewInterpolation(player_t *player);

View file

@ -812,7 +812,10 @@ static void CalcPolyobjSoundOrg(const FPolyObj *poly, fixed_t *x, fixed_t *y, fi
side_t *side;
sector_t *sec;
poly->ClosestPoint(*x, *y, *x, *y, &side);
DVector2 pos(FIXED2DBL(*x), FIXED2DBL(*y));
poly->ClosestPoint(pos, pos, &side);
*x = FLOAT2FIXED(pos.X);
*y = FLOAT2FIXED(pos.Y);
sec = side->sector;
*z = clamp(*z, sec->floorplane.ZatPoint(*x, *y), sec->ceilingplane.ZatPoint(*x, *y));
}