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

# Conflicts:
#	src/r_utility.h
This commit is contained in:
Christoph Oelckers 2016-03-31 09:24:41 +02:00
commit a5c4e2dab3
25 changed files with 377 additions and 529 deletions

View file

@ -1143,6 +1143,9 @@ static void AM_ScrollParchment (double dmapx, double dmapy)
mapxstart = mapxstart - dmapx * scale_mtof; mapxstart = mapxstart - dmapx * scale_mtof;
mapystart = mapystart - dmapy * scale_mtof; mapystart = mapystart - dmapy * scale_mtof;
mapxstart = clamp(mapxstart, -40000., 40000.);
mapystart = clamp(mapxstart, -40000., 40000.);
if (mapback.isValid()) if (mapback.isValid())
{ {
FTexture *backtex = TexMan[mapback]; FTexture *backtex = TexMan[mapback];
@ -1836,8 +1839,7 @@ void AM_drawGrid (int color)
// Figure out start of vertical gridlines // Figure out start of vertical gridlines
start = minx - extx; start = minx - extx;
double bmorgx = FIXED2DBL(bmaporgx); start = ceil((start - bmaporgx) / MAPBLOCKUNITS) * MAPBLOCKUNITS + bmaporgx;
start = ceil((start - bmorgx) / MAPBLOCKUNITS) * MAPBLOCKUNITS + bmorgx;
end = minx + minlen - extx; end = minx + minlen - extx;
@ -1858,8 +1860,7 @@ void AM_drawGrid (int color)
// Figure out start of horizontal gridlines // Figure out start of horizontal gridlines
start = miny - exty; start = miny - exty;
double bmorgy = FIXED2DBL(bmaporgy); start = ceil((start - bmaporgy) / MAPBLOCKUNITS) * MAPBLOCKUNITS + bmaporgy;
start = ceil((start - bmorgy) / MAPBLOCKUNITS) * MAPBLOCKUNITS + bmorgy;
end = miny + minlen - exty; end = miny + minlen - exty;
// draw horizontal gridlines // draw horizontal gridlines
@ -1927,7 +1928,7 @@ void AM_drawSubsectors()
points[j].Y = float(f_y + (f_h - (pt.y - m_y) * scale)); points[j].Y = float(f_y + (f_h - (pt.y - m_y) * scale));
} }
// For lighting and texture determination // 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. // Find texture origin.
originpt.x = -sec->GetXOffsetF(sector_t::floor); originpt.x = -sec->GetXOffsetF(sector_t::floor);
originpt.y = sec->GetYOffset(sector_t::floor); originpt.y = sec->GetYOffset(sector_t::floor);
@ -1967,7 +1968,7 @@ void AM_drawSubsectors()
} }
seczb = floorplane->ZatPoint(secx, secy); seczb = floorplane->ZatPoint(secx, secy);
seczt = sec->ceilingplane.ZatPoint(secx, secy); seczt = sec->ceilingplane.ZatPoint(secx, secy);
for (unsigned int i = 0; i < sec->e->XFloor.ffloors.Size(); ++i) for (unsigned int i = 0; i < sec->e->XFloor.ffloors.Size(); ++i)
{ {
F3DFloor *rover = sec->e->XFloor.ffloors[i]; F3DFloor *rover = sec->e->XFloor.ffloors[i];
@ -2030,7 +2031,7 @@ void AM_drawSubsectors()
(colormap->Color.b + 160) / 2), (colormap->Color.b + 160) / 2),
colormap->Fade, colormap->Fade,
255 - (255 - colormap->Desaturate) / 4); 255 - (255 - colormap->Desaturate) / 4);
floorlight = (floorlight + 200*15) / 16; floorlight = (floorlight + 200 * 15) / 16;
} }
// Draw the polygon. // Draw the polygon.
@ -2106,10 +2107,10 @@ void AM_drawSeg(seg_t *seg, const AMColor &color)
void AM_drawPolySeg(FPolySeg *seg, const AMColor &color) void AM_drawPolySeg(FPolySeg *seg, const AMColor &color)
{ {
mline_t l; mline_t l;
l.a.x = seg->v1.x; l.a.x = seg->v1.pos.X;
l.a.y = seg->v1.y; l.a.y = seg->v1.pos.Y;
l.b.x = seg->v2.x; l.b.x = seg->v2.pos.X;
l.b.y = seg->v2.y; l.b.y = seg->v2.pos.Y;
if (am_rotate == 1 || (am_rotate == 2 && viewactive)) 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.frontsector = side->sector;
seg.backsector = side->linedef->frontsector == side->sector ? side->linedef->backsector : side->linedef->frontsector; seg.backsector = side->linedef->frontsector == side->sector ? side->linedef->backsector : side->linedef->frontsector;
vert.x = segs[i].v1.x; vert.x = FLOAT2FIXED(segs[i].v1.pos.X);
vert.y = segs[i].v1.y; vert.y = FLOAT2FIXED(segs[i].v1.pos.Y);
seg.v1 = VertexMap->SelectVertexExact(vert); seg.v1 = VertexMap->SelectVertexExact(vert);
vert.x = segs[i].v2.x; vert.x = FLOAT2FIXED(segs[i].v2.pos.X);
vert.y = segs[i].v2.y; vert.y = FLOAT2FIXED(segs[i].v2.pos.Y);
seg.v2 = VertexMap->SelectVertexExact(vert); seg.v2 = VertexMap->SelectVertexExact(vert);
seg.linedef = int(side->linedef - Level.Lines); seg.linedef = int(side->linedef - Level.Lines);
seg.sidedef = int(side - Level.Sides); 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]); FPolyObj *poly = PO_GetPolyobj(args[0]);
if (poly != NULL) if (poly != NULL)
{ {
return poly->StartSpot.x; return DoubleToACS(poly->StartSpot.pos.X);
} }
} }
return FIXED_MAX; return FIXED_MAX;
@ -5330,7 +5330,7 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, SDWORD *args)
FPolyObj *poly = PO_GetPolyobj(args[0]); FPolyObj *poly = PO_GetPolyobj(args[0]);
if (poly != NULL) if (poly != NULL)
{ {
return poly->StartSpot.y; return DoubleToACS(poly->StartSpot.pos.Y);
} }
} }
return FIXED_MAX; return FIXED_MAX;

View file

@ -27,8 +27,18 @@ extern int* blockmaplump; // offsets in blockmap are from here
extern int* blockmap; extern int* blockmap;
extern int bmapwidth; extern int bmapwidth;
extern int bmapheight; // in mapblocks extern int bmapheight; // in mapblocks
extern fixed_t bmaporgx; extern double bmaporgx;
extern fixed_t bmaporgy; // origin of block map extern double bmaporgy; // origin of block map
extern FBlockNode** blocklinks; // for thing chains extern FBlockNode** blocklinks; // for thing chains
inline int GetBlockX(double xpos)
{
return int((xpos - bmaporgx) / MAPBLOCKUNITS);
}
inline int GetBlockY(double ypos)
{
return int((ypos - bmaporgy) / MAPBLOCKUNITS);
}
#endif #endif

View file

@ -44,20 +44,6 @@ struct FCheckPosition
PushTime = 0; PushTime = 0;
FromPMove = false; FromPMove = false;
} }
inline fixed_t _f_X()
{
return FLOAT2FIXED(pos.X);
}
inline fixed_t _f_Y()
{
return FLOAT2FIXED(pos.Y);
}
inline fixed_t _f_Z()
{
return FLOAT2FIXED(pos.Z);
}
}; };

View file

@ -885,11 +885,8 @@ void P_NewChaseDir(AActor * actor)
double deltay = 0; double deltay = 0;
while ((line = it.Next())) while ((line = it.Next()))
{ {
if (line->backsector && // Ignore one-sided linedefs if (line->backsector && // Ignore one-sided linedefs
box.Right() > line->bbox[BOXLEFT] && box.inRange(line) &&
box.Left() < line->bbox[BOXRIGHT] &&
box.Top() > line->bbox[BOXBOTTOM] && // Linedef must be contacted
box.Bottom() < line->bbox[BOXTOP] &&
box.BoxOnLineSide(line) == -1) box.BoxOnLineSide(line) == -1)
{ {
double front = line->frontsector->floorplane.ZatPoint(actor->PosRelative(line)); double front = line->frontsector->floorplane.ZatPoint(actor->PosRelative(line));

View file

@ -84,10 +84,8 @@ int LS_SetGlobalFogParameter(line_t *ln, AActor *it, bool backSide, int arg0, in
int arg0, int arg1, int arg2, int arg3, int arg4) int arg0, int arg1, int arg2, int arg3, int arg4)
#define SPEED(a) ((a) / 8.) #define SPEED(a) ((a) / 8.)
#define _f_SPEED(a) ((a)*(FRACUNIT/8))
#define TICS(a) (((a)*TICRATE)/35) #define TICS(a) (((a)*TICRATE)/35)
#define OCTICS(a) (((a)*TICRATE)/8) #define OCTICS(a) (((a)*TICRATE)/8)
#define _f_BYTEANGLE(a) ((angle_t)((a)<<24))
#define BYTEANGLE(a) ((a) * (360./256.)) #define BYTEANGLE(a) ((a) * (360./256.))
#define CRUSH(a) ((a) > 0? (a) : -1) #define CRUSH(a) ((a) > 0? (a) : -1)
#define CHANGE(a) (((a) >= 0 && (a)<=7)? ChangeMap[a]:0) #define CHANGE(a) (((a) >= 0 && (a)<=7)? ChangeMap[a]:0)
@ -164,19 +162,19 @@ FUNC(LS_Polyobj_RotateRight)
FUNC(LS_Polyobj_Move) FUNC(LS_Polyobj_Move)
// Polyobj_Move (po, speed, angle, distance) // 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) FUNC(LS_Polyobj_MoveTimes8)
// Polyobj_MoveTimes8 (po, speed, angle, distance) // 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) FUNC(LS_Polyobj_MoveTo)
// Polyobj_MoveTo (po, speed, x, y) // 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) FUNC(LS_Polyobj_MoveToSpot)
@ -185,19 +183,19 @@ FUNC(LS_Polyobj_MoveToSpot)
FActorIterator iterator (arg2); FActorIterator iterator (arg2);
AActor *spot = iterator.Next(); AActor *spot = iterator.Next();
if (spot == NULL) return false; 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) FUNC(LS_Polyobj_DoorSwing)
// Polyobj_DoorSwing (po, speed, angle, delay) // 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) FUNC(LS_Polyobj_DoorSlide)
// Polyobj_DoorSlide (po, speed, angle, distance, delay) // 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) FUNC(LS_Polyobj_OR_RotateLeft)
@ -215,19 +213,19 @@ FUNC(LS_Polyobj_OR_RotateRight)
FUNC(LS_Polyobj_OR_Move) FUNC(LS_Polyobj_OR_Move)
// Polyobj_OR_Move (po, speed, angle, distance) // 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) FUNC(LS_Polyobj_OR_MoveTimes8)
// Polyobj_OR_MoveTimes8 (po, speed, angle, distance) // 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) FUNC(LS_Polyobj_OR_MoveTo)
// Polyobj_OR_MoveTo (po, speed, x, y) // 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) FUNC(LS_Polyobj_OR_MoveToSpot)
@ -236,7 +234,7 @@ FUNC(LS_Polyobj_OR_MoveToSpot)
FActorIterator iterator (arg2); FActorIterator iterator (arg2);
AActor *spot = iterator.Next(); AActor *spot = iterator.Next();
if (spot == NULL) return false; 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) FUNC(LS_Polyobj_Stop)
@ -810,13 +808,13 @@ FUNC(LS_Ceiling_LowerToNearest)
FUNC(LS_Ceiling_ToHighestInstant) FUNC(LS_Ceiling_ToHighestInstant)
// Ceiling_ToHighestInstant (tag, change, crush) // 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) FUNC(LS_Ceiling_ToFloorInstant)
// Ceiling_ToFloorInstant (tag, change, crush) // 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) FUNC(LS_Ceiling_LowerToFloor)
@ -2377,8 +2375,8 @@ FUNC(LS_Sector_SetFade)
FUNC(LS_Sector_SetCeilingPanning) FUNC(LS_Sector_SetCeilingPanning)
// Sector_SetCeilingPanning (tag, x-int, x-frac, y-int, y-frac) // Sector_SetCeilingPanning (tag, x-int, x-frac, y-int, y-frac)
{ {
fixed_t xofs = arg1 * FRACUNIT + arg2 * (FRACUNIT/100); double xofs = arg1 + arg2 / 100.;
fixed_t yofs = arg3 * FRACUNIT + arg4 * (FRACUNIT/100); double yofs = arg3 + arg4 / 100.;
FSectorTagIterator itr(arg0); FSectorTagIterator itr(arg0);
int secnum; int secnum;
@ -2393,8 +2391,8 @@ FUNC(LS_Sector_SetCeilingPanning)
FUNC(LS_Sector_SetFloorPanning) FUNC(LS_Sector_SetFloorPanning)
// Sector_SetFloorPanning (tag, x-int, x-frac, y-int, y-frac) // Sector_SetFloorPanning (tag, x-int, x-frac, y-int, y-frac)
{ {
fixed_t xofs = arg1 * FRACUNIT + arg2 * (FRACUNIT/100); double xofs = arg1 + arg2 / 100.;
fixed_t yofs = arg3 * FRACUNIT + arg4 * (FRACUNIT/100); double yofs = arg3 + arg4 / 100.;
FSectorTagIterator itr(arg0); FSectorTagIterator itr(arg0);
int secnum; int secnum;
@ -2409,13 +2407,13 @@ FUNC(LS_Sector_SetFloorPanning)
FUNC(LS_Sector_SetFloorScale) FUNC(LS_Sector_SetFloorScale)
// Sector_SetFloorScale (tag, x-int, x-frac, y-int, y-frac) // Sector_SetFloorScale (tag, x-int, x-frac, y-int, y-frac)
{ {
fixed_t xscale = arg1 * FRACUNIT + arg2 * (FRACUNIT/100); double xscale = arg1 + arg2 / 100.;
fixed_t yscale = arg3 * FRACUNIT + arg4 * (FRACUNIT/100); double yscale = arg3 + arg4 / 100.;
if (xscale) if (xscale)
xscale = FixedDiv (FRACUNIT, xscale); xscale = 1. / xscale;
if (yscale) if (yscale)
yscale = FixedDiv (FRACUNIT, yscale); yscale = 1. / yscale;
FSectorTagIterator itr(arg0); FSectorTagIterator itr(arg0);
int secnum; int secnum;
@ -2432,13 +2430,13 @@ FUNC(LS_Sector_SetFloorScale)
FUNC(LS_Sector_SetCeilingScale) FUNC(LS_Sector_SetCeilingScale)
// Sector_SetCeilingScale (tag, x-int, x-frac, y-int, y-frac) // Sector_SetCeilingScale (tag, x-int, x-frac, y-int, y-frac)
{ {
fixed_t xscale = arg1 * FRACUNIT + arg2 * (FRACUNIT/100); double xscale = arg1 + arg2 / 100.;
fixed_t yscale = arg3 * FRACUNIT + arg4 * (FRACUNIT/100); double yscale = arg3 + arg4 / 100.;
if (xscale) if (xscale)
xscale = FixedDiv (FRACUNIT, xscale); xscale = 1. / xscale;
if (yscale) if (yscale)
yscale = FixedDiv (FRACUNIT, yscale); yscale = 1. / yscale;
FSectorTagIterator itr(arg0); FSectorTagIterator itr(arg0);
int secnum; int secnum;
@ -2455,10 +2453,12 @@ FUNC(LS_Sector_SetCeilingScale)
FUNC(LS_Sector_SetFloorScale2) FUNC(LS_Sector_SetFloorScale2)
// Sector_SetFloorScale2 (tag, x-factor, y-factor) // Sector_SetFloorScale2 (tag, x-factor, y-factor)
{ {
if (arg1) double xscale = arg1 / 65536., yscale = arg2 / 65536.;
arg1 = FixedDiv (FRACUNIT, arg1);
if (arg2) if (xscale)
arg2 = FixedDiv (FRACUNIT, arg2); xscale = 1. / xscale;
if (yscale)
yscale = 1. / yscale;
FSectorTagIterator itr(arg0); FSectorTagIterator itr(arg0);
int secnum; int secnum;
@ -2475,10 +2475,12 @@ FUNC(LS_Sector_SetFloorScale2)
FUNC(LS_Sector_SetCeilingScale2) FUNC(LS_Sector_SetCeilingScale2)
// Sector_SetFloorScale2 (tag, x-factor, y-factor) // Sector_SetFloorScale2 (tag, x-factor, y-factor)
{ {
if (arg1) double xscale = arg1 / 65536., yscale = arg2 / 65536.;
arg1 = FixedDiv (FRACUNIT, arg1);
if (arg2) if (xscale)
arg2 = FixedDiv (FRACUNIT, arg2); xscale = 1. / xscale;
if (yscale)
yscale = 1. / yscale;
FSectorTagIterator itr(arg0); FSectorTagIterator itr(arg0);
int secnum; int secnum;
@ -2495,8 +2497,8 @@ FUNC(LS_Sector_SetCeilingScale2)
FUNC(LS_Sector_SetRotation) FUNC(LS_Sector_SetRotation)
// Sector_SetRotation (tag, floor-angle, ceiling-angle) // Sector_SetRotation (tag, floor-angle, ceiling-angle)
{ {
angle_t ceiling = arg2 * ANGLE_1; DAngle ceiling = (double)arg2;
angle_t floor = arg1 * ANGLE_1; DAngle floor = (double)arg1;
FSectorTagIterator itr(arg0); FSectorTagIterator itr(arg0);
int secnum; int secnum;
@ -2539,7 +2541,9 @@ FUNC(LS_Line_AlignFloor)
FUNC(LS_Line_SetTextureOffset) FUNC(LS_Line_SetTextureOffset)
// Line_SetTextureOffset (id, x, y, side, flags) // 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) if (arg0 == 0 || arg3 < 0 || arg3 > 1)
return false; return false;
@ -2557,15 +2561,15 @@ FUNC(LS_Line_SetTextureOffset)
// set // set
if (arg1 != NO_CHANGE) if (arg1 != NO_CHANGE)
{ {
if (arg4&1) side->SetTextureXOffset(side_t::top, arg1); if (arg4&1) side->SetTextureXOffset(side_t::top, farg1);
if (arg4&2) side->SetTextureXOffset(side_t::mid, arg1); if (arg4&2) side->SetTextureXOffset(side_t::mid, farg1);
if (arg4&4) side->SetTextureXOffset(side_t::bottom, arg1); if (arg4&4) side->SetTextureXOffset(side_t::bottom, farg1);
} }
if (arg2 != NO_CHANGE) if (arg2 != NO_CHANGE)
{ {
if (arg4&1) side->SetTextureYOffset(side_t::top, arg2); if (arg4&1) side->SetTextureYOffset(side_t::top, farg2);
if (arg4&2) side->SetTextureYOffset(side_t::mid, arg2); if (arg4&2) side->SetTextureYOffset(side_t::mid, farg2);
if (arg4&4) side->SetTextureYOffset(side_t::bottom, arg2); if (arg4&4) side->SetTextureYOffset(side_t::bottom, farg2);
} }
} }
else else
@ -2573,15 +2577,15 @@ FUNC(LS_Line_SetTextureOffset)
// add // add
if (arg1 != NO_CHANGE) if (arg1 != NO_CHANGE)
{ {
if (arg4&1) side->AddTextureXOffset(side_t::top, arg1); if (arg4&1) side->AddTextureXOffset(side_t::top, farg1);
if (arg4&2) side->AddTextureXOffset(side_t::mid, arg1); if (arg4&2) side->AddTextureXOffset(side_t::mid, farg1);
if (arg4&4) side->AddTextureXOffset(side_t::bottom, arg1); if (arg4&4) side->AddTextureXOffset(side_t::bottom, farg1);
} }
if (arg2 != NO_CHANGE) if (arg2 != NO_CHANGE)
{ {
if (arg4&1) side->AddTextureYOffset(side_t::top, arg2); if (arg4&1) side->AddTextureYOffset(side_t::top, farg2);
if (arg4&2) side->AddTextureYOffset(side_t::mid, arg2); if (arg4&2) side->AddTextureYOffset(side_t::mid, farg2);
if (arg4&4) side->AddTextureYOffset(side_t::bottom, arg2); if (arg4&4) side->AddTextureYOffset(side_t::bottom, farg2);
} }
} }
} }
@ -2592,7 +2596,9 @@ FUNC(LS_Line_SetTextureOffset)
FUNC(LS_Line_SetTextureScale) FUNC(LS_Line_SetTextureScale)
// Line_SetTextureScale (id, x, y, side, flags) // 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) if (arg0 == 0 || arg3 < 0 || arg3 > 1)
return false; return false;
@ -2609,15 +2615,15 @@ FUNC(LS_Line_SetTextureScale)
// set // set
if (arg1 != NO_CHANGE) if (arg1 != NO_CHANGE)
{ {
if (arg4&1) side->SetTextureXScale(side_t::top, arg1); if (arg4&1) side->SetTextureXScale(side_t::top, farg1);
if (arg4&2) side->SetTextureXScale(side_t::mid, arg1); if (arg4&2) side->SetTextureXScale(side_t::mid, farg1);
if (arg4&4) side->SetTextureXScale(side_t::bottom, arg1); if (arg4&4) side->SetTextureXScale(side_t::bottom, farg1);
} }
if (arg2 != NO_CHANGE) if (arg2 != NO_CHANGE)
{ {
if (arg4&1) side->SetTextureYScale(side_t::top, arg2); if (arg4&1) side->SetTextureYScale(side_t::top, farg2);
if (arg4&2) side->SetTextureYScale(side_t::mid, arg2); if (arg4&2) side->SetTextureYScale(side_t::mid, farg2);
if (arg4&4) side->SetTextureYScale(side_t::bottom, arg2); if (arg4&4) side->SetTextureYScale(side_t::bottom, farg2);
} }
} }
else else
@ -2625,15 +2631,15 @@ FUNC(LS_Line_SetTextureScale)
// add // add
if (arg1 != NO_CHANGE) if (arg1 != NO_CHANGE)
{ {
if (arg4&1) side->MultiplyTextureXScale(side_t::top, arg1); if (arg4&1) side->MultiplyTextureXScale(side_t::top, farg1);
if (arg4&2) side->MultiplyTextureXScale(side_t::mid, arg1); if (arg4&2) side->MultiplyTextureXScale(side_t::mid, farg1);
if (arg4&4) side->MultiplyTextureXScale(side_t::bottom, arg1); if (arg4&4) side->MultiplyTextureXScale(side_t::bottom, farg1);
} }
if (arg2 != NO_CHANGE) if (arg2 != NO_CHANGE)
{ {
if (arg4&1) side->MultiplyTextureYScale(side_t::top, arg2); if (arg4&1) side->MultiplyTextureYScale(side_t::top, farg2);
if (arg4&2) side->MultiplyTextureYScale(side_t::mid, arg2); if (arg4&2) side->MultiplyTextureYScale(side_t::mid, farg2);
if (arg4&4) side->MultiplyTextureYScale(side_t::bottom, arg2); if (arg4&4) side->MultiplyTextureYScale(side_t::bottom, farg2);
} }
} }
} }

View file

@ -34,7 +34,6 @@ class player_t;
class AActor; class AActor;
struct FPlayerStart; struct FPlayerStart;
class PClassActor; class PClassActor;
struct fixedvec3;
class APlayerPawn; class APlayerPawn;
struct line_t; struct line_t;
struct sector_t; struct sector_t;
@ -61,28 +60,6 @@ struct FTranslatedLineTarget;
extern int bmapnegx; extern int bmapnegx;
extern int bmapnegy; extern int bmapnegy;
inline int GetSafeBlockX(int blockx)
{
blockx >>= MAPBLOCKSHIFT;
return (blockx <= bmapnegx) ? blockx & 0x1FF : blockx;
}
inline int GetSafeBlockX(long long blockx)
{
blockx >>= MAPBLOCKSHIFT;
return int((blockx <= bmapnegx) ? blockx & 0x1FF : blockx);
}
inline int GetSafeBlockY(int blocky)
{
blocky >>= MAPBLOCKSHIFT;
return (blocky <= bmapnegy) ? blocky & 0x1FF: blocky;
}
inline int GetSafeBlockY(long long blocky)
{
blocky >>= MAPBLOCKSHIFT;
return int((blocky <= bmapnegy) ? blocky & 0x1FF: blocky);
}
//#define GRAVITY FRACUNIT //#define GRAVITY FRACUNIT
#define MAXMOVE (30.) #define MAXMOVE (30.)
@ -242,17 +219,11 @@ extern TArray<spechit_t> portalhit;
bool P_TestMobjLocation (AActor *mobj); bool P_TestMobjLocation (AActor *mobj);
bool P_TestMobjZ (AActor *mobj, bool quick=true, AActor **pOnmobj = NULL); bool P_TestMobjZ (AActor *mobj, bool quick=true, AActor **pOnmobj = NULL);
bool P_CheckPosition(AActor *thing, const DVector2 &pos, bool actorsonly = false); bool P_CheckPosition(AActor *thing, const DVector2 &pos, bool actorsonly = false);
inline bool P_CheckPosition(AActor *thing, const DVector2 &pos, FCheckPosition &tm, bool actorsonly = false); bool P_CheckPosition(AActor *thing, const DVector2 &pos, FCheckPosition &tm, bool actorsonly = false);
AActor *P_CheckOnmobj (AActor *thing); AActor *P_CheckOnmobj (AActor *thing);
void P_FakeZMovement (AActor *mo); void P_FakeZMovement (AActor *mo);
bool P_TryMove(AActor* thing, const DVector2 &pos, int dropoff, const secplane_t * onfloor, FCheckPosition &tm, bool missileCheck = false); bool P_TryMove(AActor* thing, const DVector2 &pos, int dropoff, const secplane_t * onfloor, FCheckPosition &tm, bool missileCheck = false);
bool P_TryMove(AActor* thing, const DVector2 &pos, int dropoff, const secplane_t * onfloor = NULL); bool P_TryMove(AActor* thing, const DVector2 &pos, int dropoff, const secplane_t * onfloor = NULL);
/*
inline bool P_TryMove(AActor* thing, double x, double y, int dropoff, const secplane_t * onfloor = NULL)
{
return P_TryMove(thing, FLOAT2FIXED(x), FLOAT2FIXED(y), dropoff, onfloor);
}
*/
bool P_CheckMove(AActor *thing, const DVector2 &pos); bool P_CheckMove(AActor *thing, const DVector2 &pos);
void P_ApplyTorque(AActor *mo); void P_ApplyTorque(AActor *mo);
@ -325,7 +296,6 @@ void P_TraceBleed(int damage, FTranslatedLineTarget *t, AActor *puff); // hitsc
void P_TraceBleed (int damage, AActor *target); // random direction version void P_TraceBleed (int damage, AActor *target); // random direction version
bool P_HitFloor (AActor *thing); 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); 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) = delete;
void P_CheckSplash(AActor *self, double distance); void P_CheckSplash(AActor *self, double distance);
struct FRailParams struct FRailParams
@ -389,8 +359,6 @@ bool Check_Sides(AActor *, int, int); // phares
// [RH] // [RH]
const secplane_t * P_CheckSlopeWalk(AActor *actor, DVector2 &move); const secplane_t * P_CheckSlopeWalk(AActor *actor, DVector2 &move);
inline const secplane_t * P_CheckSlopeWalk(AActor *actor, fixed_t &xmove, fixed_t &ymove) = delete;
// //
// P_SETUP // P_SETUP
// //

View file

@ -2947,7 +2947,7 @@ const secplane_t * P_CheckSlopeWalk(AActor *actor, DVector2 &move)
if (t < 0) if (t < 0)
{ // Desired location is behind (below) the plane { // Desired location is behind (below) the plane
// (i.e. Walking up the plane) // (i.e. Walking up the plane)
if (plane->fixC() < STEEPSLOPE) if (plane->fC() < STEEPSLOPE)
{ // Can't climb up slopes of ~45 degrees or more { // Can't climb up slopes of ~45 degrees or more
if (actor->flags & MF_NOCLIP) if (actor->flags & MF_NOCLIP)
{ {

View file

@ -376,8 +376,8 @@ bool AActor::FixMapthingPos()
{ {
sector_t *secstart = P_PointInSectorBuggy(_f_X(), _f_Y()); sector_t *secstart = P_PointInSectorBuggy(_f_X(), _f_Y());
int blockx = GetSafeBlockX(_f_X() - bmaporgx); int blockx = GetBlockX(X());
int blocky = GetSafeBlockY(_f_Y() - bmaporgy); int blocky = GetBlockY(Y());
bool success = false; bool success = false;
if ((unsigned int)blockx < (unsigned int)bmapwidth && if ((unsigned int)blockx < (unsigned int)bmapwidth &&
@ -403,10 +403,10 @@ bool AActor::FixMapthingPos()
} }
// Not inside the line's bounding box // Not inside the line's bounding box
if (_f_X() + _f_radius() <= ldef->bbox[BOXLEFT] if (X() + radius <= ldef->bbox[BOXLEFT]
|| _f_X() - _f_radius() >= ldef->bbox[BOXRIGHT] || X() - radius >= ldef->bbox[BOXRIGHT]
|| _f_Y() + _f_radius() <= ldef->bbox[BOXBOTTOM] || Y() + radius <= ldef->bbox[BOXBOTTOM]
|| _f_Y() - _f_radius() >= ldef->bbox[BOXTOP]) || Y() - radius >= ldef->bbox[BOXTOP])
continue; continue;
// Get the exact distance to the line // Get the exact distance to the line
@ -519,13 +519,12 @@ void AActor::LinkToWorld(bool spawningmapthing, sector_t *sector)
for (int i = -1; i < (int)check.Size(); i++) for (int i = -1; i < (int)check.Size(); i++)
{ {
DVector3 _pos = i==-1? Pos() : 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 x1 = GetBlockX(pos.X - radius);
int x2 = GetSafeBlockX(pos.x + _f_radius() - bmaporgx); int x2 = GetBlockX(pos.X + radius);
int y1 = GetSafeBlockY(pos.y - _f_radius() - bmaporgy); int y1 = GetBlockY(pos.Y - radius);
int y2 = GetSafeBlockY(pos.y + _f_radius() - bmaporgy); int y2 = GetBlockY(pos.Y + radius);
if (x1 >= bmapwidth || x2 < 0 || y1 >= bmapheight || y2 < 0) if (x1 >= bmapwidth || x2 < 0 || y1 >= bmapheight || y2 < 0)
{ // thing is off the map { // thing is off the map
@ -639,10 +638,10 @@ FBlockLinesIterator::FBlockLinesIterator(int _minx, int _miny, int _maxx, int _m
void FBlockLinesIterator::init(const FBoundingBox &box) void FBlockLinesIterator::init(const FBoundingBox &box)
{ {
validcount++; validcount++;
maxy = GetSafeBlockY(box.Top() - bmaporgy); maxy = GetBlockY(FIXED2DBL(box.Top()));
miny = GetSafeBlockY(box.Bottom() - bmaporgy); miny = GetBlockY(FIXED2DBL(box.Bottom()));
maxx = GetSafeBlockX(box.Right() - bmaporgx); maxx = GetBlockX(FIXED2DBL(box.Right()));
minx = GetSafeBlockX(box.Left() - bmaporgx); minx = GetBlockX(FIXED2DBL(box.Left()));
Reset(); Reset();
} }
@ -945,10 +944,10 @@ FBlockThingsIterator::FBlockThingsIterator(int _minx, int _miny, int _maxx, int
void FBlockThingsIterator::init(const FBoundingBox &box) void FBlockThingsIterator::init(const FBoundingBox &box)
{ {
maxy = GetSafeBlockY(box.Top() - bmaporgy); maxy = GetBlockY(FIXED2DBL(box.Top()));
miny = GetSafeBlockY(box.Bottom() - bmaporgy); miny = GetBlockY(FIXED2DBL(box.Bottom()));
maxx = GetSafeBlockX(box.Right() - bmaporgx); maxx = GetBlockX(FIXED2DBL(box.Right()));
minx = GetSafeBlockX(box.Left() - bmaporgx); minx = GetBlockX(FIXED2DBL(box.Left()));
ClearHash(); ClearHash();
Reset(); Reset();
} }
@ -1026,9 +1025,9 @@ AActor *FBlockThingsIterator::Next(bool centeronly)
if (centeronly) if (centeronly)
{ {
// Block boundaries for compatibility mode // Block boundaries for compatibility mode
fixed_t blockleft = (curx << MAPBLOCKSHIFT) + bmaporgx; fixed_t blockleft = (curx << MAPBLOCKSHIFT) + FLOAT2FIXED(bmaporgx);
fixed_t blockright = blockleft + MAPBLOCKSIZE; fixed_t blockright = blockleft + MAPBLOCKSIZE;
fixed_t blockbottom = (cury << MAPBLOCKSHIFT) + bmaporgy; fixed_t blockbottom = (cury << MAPBLOCKSHIFT) + FLOAT2FIXED(bmaporgy);
fixed_t blocktop = blockbottom + MAPBLOCKSIZE; fixed_t blocktop = blockbottom + MAPBLOCKSIZE;
// only return actors with the center in this block // only return actors with the center in this block
@ -1517,16 +1516,19 @@ void FPathTraverse::init (fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2, int fl
intercept_index = intercepts.Size(); intercept_index = intercepts.Size();
this->startfrac = startfrac; this->startfrac = startfrac;
if ( ((x1-bmaporgx)&(MAPBLOCKSIZE-1)) == 0) fixed_t _f_bmaporgx = FLOAT2FIXED(bmaporgx);
fixed_t _f_bmaporgy = FLOAT2FIXED(bmaporgy);
if ( ((x1-_f_bmaporgx)&(MAPBLOCKSIZE-1)) == 0)
x1 += FRACUNIT; // don't side exactly on a line x1 += FRACUNIT; // don't side exactly on a line
if ( ((y1-bmaporgy)&(MAPBLOCKSIZE-1)) == 0) if ( ((y1-_f_bmaporgy)&(MAPBLOCKSIZE-1)) == 0)
y1 += FRACUNIT; // don't side exactly on a line y1 += FRACUNIT; // don't side exactly on a line
_x1 = (long long)x1 - bmaporgx; _x1 = (long long)x1 - _f_bmaporgx;
_y1 = (long long)y1 - bmaporgy; _y1 = (long long)y1 - _f_bmaporgy;
x1 -= bmaporgx; x1 -= _f_bmaporgx;
y1 -= bmaporgy; y1 -= _f_bmaporgy;
xt1 = int(_x1 >> MAPBLOCKSHIFT); xt1 = int(_x1 >> MAPBLOCKSHIFT);
yt1 = int(_y1 >> MAPBLOCKSHIFT); yt1 = int(_y1 >> MAPBLOCKSHIFT);
@ -1541,10 +1543,10 @@ void FPathTraverse::init (fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2, int fl
} }
else else
{ {
_x2 = (long long)x2 - bmaporgx; _x2 = (long long)x2 - _f_bmaporgx;
_y2 = (long long)y2 - bmaporgy; _y2 = (long long)y2 - _f_bmaporgy;
x2 -= bmaporgx; x2 -= _f_bmaporgx;
y2 -= bmaporgy; y2 -= _f_bmaporgy;
xt2 = int(_x2 >> MAPBLOCKSHIFT); xt2 = int(_x2 >> MAPBLOCKSHIFT);
yt2 = int(_y2 >> MAPBLOCKSHIFT); yt2 = int(_y2 >> MAPBLOCKSHIFT);
} }
@ -1758,8 +1760,8 @@ AActor *P_BlockmapSearch (AActor *mo, int distance, AActor *(*check)(AActor*, in
int count; int count;
AActor *target; AActor *target;
startX = GetSafeBlockX(mo->_f_X()-bmaporgx); startX = GetBlockX(mo->X());
startY = GetSafeBlockY(mo->_f_Y()-bmaporgy); startY = GetBlockY(mo->Y());
validcount++; validcount++;
if (startX >= 0 && startX < bmapwidth && startY >= 0 && startY < bmapheight) if (startX >= 0 && startX < bmapwidth && startY >= 0 && startY < bmapheight)

View file

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

View file

@ -171,10 +171,8 @@ int bmapheight; // size in mapblocks
int *blockmap; // int for larger maps ([RH] Made int because BOOM does) int *blockmap; // int for larger maps ([RH] Made int because BOOM does)
int *blockmaplump; // offsets in blockmap are from here int *blockmaplump; // offsets in blockmap are from here
fixed_t bmaporgx; // origin of block map double bmaporgx; // origin of block map
fixed_t bmaporgy; double bmaporgy;
int bmapnegx; // min negs of block map before wrapping
int bmapnegy;
FBlockNode** blocklinks; // for thing chains FBlockNode** blocklinks; // for thing chains
@ -1905,26 +1903,26 @@ void P_AdjustLine (line_t *ld)
ld->setDelta(v2->fX() - v1->fX(), v2->fY() - v1->fY()); ld->setDelta(v2->fX() - v1->fX(), v2->fY() - v1->fY());
if (v1->fixX() < v2->fixX()) if (v1->fX() < v2->fX())
{ {
ld->bbox[BOXLEFT] = v1->fixX(); ld->bbox[BOXLEFT] = v1->fX();
ld->bbox[BOXRIGHT] = v2->fixX(); ld->bbox[BOXRIGHT] = v2->fX();
} }
else else
{ {
ld->bbox[BOXLEFT] = v2->fixX(); ld->bbox[BOXLEFT] = v2->fX();
ld->bbox[BOXRIGHT] = v1->fixX(); ld->bbox[BOXRIGHT] = v1->fX();
} }
if (v1->fixY() < v2->fixY()) if (v1->fY() < v2->fY())
{ {
ld->bbox[BOXBOTTOM] = v1->fixY(); ld->bbox[BOXBOTTOM] = v1->fY();
ld->bbox[BOXTOP] = v2->fixY(); ld->bbox[BOXTOP] = v2->fY();
} }
else else
{ {
ld->bbox[BOXBOTTOM] = v2->fixY(); ld->bbox[BOXBOTTOM] = v2->fY();
ld->bbox[BOXTOP] = v1->fixY(); ld->bbox[BOXTOP] = v1->fY();
} }
} }
@ -3076,15 +3074,10 @@ void P_LoadBlockMap (MapData * map)
} }
bmaporgx = blockmaplump[0] << FRACBITS; bmaporgx = blockmaplump[0];
bmaporgy = blockmaplump[1] << FRACBITS; bmaporgy = blockmaplump[1];
bmapwidth = blockmaplump[2]; bmapwidth = blockmaplump[2];
bmapheight = blockmaplump[3]; bmapheight = blockmaplump[3];
// MAES: set blockmapxneg and blockmapyneg
// E.g. for a full 512x512 map, they should be both
// -1. For a 257*257, they should be both -255 etc.
bmapnegx = bmapwidth > 255 ? bmapwidth - 512 : -257;
bmapnegy = bmapheight > 255 ? bmapheight - 512 : -257;
// clear out mobj chains // clear out mobj chains
count = bmapwidth*bmapheight; count = bmapwidth*bmapheight;

View file

@ -632,9 +632,6 @@ bool SightCheck::P_SightPathTraverse ()
portals.Push({ 0, topslope, bottomslope, sector_t::floor, lastsector->SkyBoxes[sector_t::floor]->Sector->PortalGroup }); portals.Push({ 0, topslope, bottomslope, sector_t::floor, lastsector->SkyBoxes[sector_t::floor]->Sector->PortalGroup });
} }
double bmaporgx = FIXED2DBL(::bmaporgx);
double bmaporgy = FIXED2DBL(::bmaporgy);
x1 -= bmaporgx; x1 -= bmaporgx;
y1 -= bmaporgy; y1 -= bmaporgy;
xt1 = x1 / MAPBLOCKUNITS; xt1 = x1 / MAPBLOCKUNITS;

View file

@ -837,15 +837,6 @@ enum
//Spawns teleport fog. Pass the actor to pluck TeleFogFromType and TeleFogToType. 'from' determines if this is the fog to spawn at the old position (true) or new (false). //Spawns teleport fog. Pass the actor to pluck TeleFogFromType and TeleFogToType. 'from' determines if this is the fog to spawn at the old position (true) or new (false).
void P_SpawnTeleportFog(AActor *mobj, const DVector3 &pos, bool beforeTele = true, bool setTarget = false); void P_SpawnTeleportFog(AActor *mobj, const DVector3 &pos, bool beforeTele = true, bool setTarget = false);
void P_SpawnTeleportFog(AActor *mobj, fixed_t x, fixed_t y, fixed_t z, bool beforeTele = true, bool setTarget = false) = delete;
inline void P_SpawnTeleportFog(AActor *mobj, const fixedvec3 &pos, bool beforeTele = true, bool setTarget = false) = delete;
inline void P_SpawnTeleportFog(AActor *mobj, double x, double y, double z, bool beforeTele = true, bool setTarget = false) = delete;
/*
{
P_SpawnTeleportFog(mobj, FLOAT2FIXED(x), FLOAT2FIXED(y), FLOAT2FIXED(z), beforeTele, setTarget);
}
*/
inline bool P_Teleport(AActor *thing, DVector3 pos, DAngle angle, int flags); inline bool P_Teleport(AActor *thing, DVector3 pos, DAngle angle, int flags);
bool EV_Teleport (int tid, int tag, line_t *line, int side, AActor *thing, int flags); bool EV_Teleport (int tid, int tag, line_t *line, int side, AActor *thing, int flags);
bool EV_SilentLineTeleport (line_t *line, int side, AActor *thing, int id, INTBOOL reverse); bool EV_SilentLineTeleport (line_t *line, int side, AActor *thing, int id, INTBOOL reverse);

View file

@ -165,8 +165,8 @@ void FTraceInfo::EnterSectorPortal(int position, double frac, sector_t *entersec
if (aimdir != -1 && aimdir != position) return; if (aimdir != -1 && aimdir != position) return;
AActor *portal = entersec->SkyBoxes[position]; AActor *portal = entersec->SkyBoxes[position];
if (aimdir == sector_t::ceiling && FLOAT2FIXED(portal->specialf1) < limitz) return; if (aimdir == sector_t::ceiling && portal->specialf1 < limitz) return;
else if (aimdir == sector_t::floor && FLOAT2FIXED(portal->specialf1) > limitz) return; else if (aimdir == sector_t::floor && portal->specialf1 > limitz) return;
FTraceInfo newtrace; FTraceInfo newtrace;
FTraceResults results; FTraceResults results;
@ -785,7 +785,7 @@ bool FTraceInfo::TraceTraverse (int ptflags)
} }
// We have something closer in the storage for portal subtraces. // We have something closer in the storage for portal subtraces.
if (TempResults->HitType != TRACE_HitNone && FIXED2DBL(in->frac) > TempResults->Fraction) if (TempResults->HitType != TRACE_HitNone && in->Frac > TempResults->Fraction)
{ {
break; break;
} }

View file

@ -32,6 +32,7 @@
#include "p_blockmap.h" #include "p_blockmap.h"
#include "p_maputl.h" #include "p_maputl.h"
#include "r_utility.h" #include "r_utility.h"
#include "p_blockmap.h"
// MACROS ------------------------------------------------------------------ // MACROS ------------------------------------------------------------------
@ -77,14 +78,14 @@ public:
void Serialize (FArchive &arc); void Serialize (FArchive &arc);
void Destroy(); void Destroy();
void Stop(); void Stop();
int GetSpeed() const { return m_Speed; } double GetSpeed() const { return m_Speed; }
void StopInterpolation (); void StopInterpolation ();
protected: protected:
DPolyAction (); DPolyAction ();
int m_PolyObj; int m_PolyObj;
int m_Speed; double m_Speed;
int m_Dist; double m_Dist;
TObjPtr<DInterpolation> m_Interpolation; TObjPtr<DInterpolation> m_Interpolation;
void SetInterpolation (); void SetInterpolation ();
@ -112,11 +113,10 @@ public:
void Tick (); void Tick ();
protected: protected:
DMovePoly (); DMovePoly ();
int m_Angle; DAngle m_Angle;
fixed_t m_xSpeed; // for sliding walls DVector2 m_Speedv;
fixed_t m_ySpeed;
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 class DMovePolyTo : public DPolyAction
@ -128,12 +128,10 @@ public:
void Tick(); void Tick();
protected: protected:
DMovePolyTo(); DMovePolyTo();
fixed_t m_xSpeed; DVector2 m_Speedv;
fixed_t m_ySpeed; DVector2 m_Target;
fixed_t m_xTarget;
fixed_t m_yTarget;
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 +143,14 @@ public:
void Serialize (FArchive &arc); void Serialize (FArchive &arc);
void Tick (); void Tick ();
protected: protected:
int m_Direction; DAngle m_Direction;
int m_TotalDist; double m_TotalDist;
int m_Tics; int m_Tics;
int m_WaitTics; int m_WaitTics;
podoortype_t m_Type; podoortype_t m_Type;
bool m_Close; 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: private:
DPolyDoor (); DPolyDoor ();
}; };
@ -171,6 +169,7 @@ public:
// EXTERNAL FUNCTION PROTOTYPES -------------------------------------------- // EXTERNAL FUNCTION PROTOTYPES --------------------------------------------
void PO_Init (void); void PO_Init (void);
void P_AdjustLine(line_t *ld);
// PRIVATE FUNCTION PROTOTYPES --------------------------------------------- // PRIVATE FUNCTION PROTOTYPES ---------------------------------------------
@ -180,8 +179,8 @@ static bool CheckMobjBlocking (side_t *seg, FPolyObj *po);
static void InitBlockMap (void); static void InitBlockMap (void);
static void IterFindPolySides (FPolyObj *po, side_t *side); static void IterFindPolySides (FPolyObj *po, side_t *side);
static void SpawnPolyobj (int index, int tag, int type); 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);
static void DoMovePolyobj (FPolyObj *po, int x, int y); static void DoMovePolyobj (FPolyObj *po, const DVector2 & move);
static void InitSegLists (); static void InitSegLists ();
static void KillSegLists (); static void KillSegLists ();
static FPolyNode *NewPolyNode(); static FPolyNode *NewPolyNode();
@ -303,15 +302,14 @@ DMovePoly::DMovePoly ()
void DMovePoly::Serialize (FArchive &arc) void DMovePoly::Serialize (FArchive &arc)
{ {
Super::Serialize (arc); Super::Serialize (arc);
arc << m_Angle << m_xSpeed << m_ySpeed; arc << m_Angle << m_Speed;
} }
DMovePoly::DMovePoly (int polyNum) DMovePoly::DMovePoly (int polyNum)
: Super (polyNum) : Super (polyNum)
{ {
m_Angle = 0; m_Angle = 0.;
m_xSpeed = 0; m_Speedv = { 0,0 };
m_ySpeed = 0;
} }
//========================================================================== //==========================================================================
@ -330,16 +328,13 @@ DMovePolyTo::DMovePolyTo()
void DMovePolyTo::Serialize(FArchive &arc) void DMovePolyTo::Serialize(FArchive &arc)
{ {
Super::Serialize(arc); Super::Serialize(arc);
arc << m_xSpeed << m_ySpeed << m_xTarget << m_yTarget; arc << m_Speedv << m_Target;
} }
DMovePolyTo::DMovePolyTo(int polyNum) DMovePolyTo::DMovePolyTo(int polyNum)
: Super(polyNum) : Super(polyNum)
{ {
m_xSpeed = 0; m_Speedv = m_Target = { 0,0 };
m_ySpeed = 0;
m_xTarget = 0;
m_yTarget = 0;
} }
//========================================================================== //==========================================================================
@ -363,7 +358,7 @@ void DPolyDoor::Serialize (FArchive &arc)
DPolyDoor::DPolyDoor (int polyNum, podoortype_t type) DPolyDoor::DPolyDoor (int polyNum, podoortype_t type)
: Super (polyNum), m_Type (type) : Super (polyNum), m_Type (type)
{ {
m_Direction = 0; m_Direction = 0.;
m_TotalDist = 0; m_TotalDist = 0;
m_Tics = 0; m_Tics = 0;
m_WaitTics = 0; m_WaitTics = 0;
@ -384,7 +379,7 @@ void DRotatePoly::Tick ()
if (poly == NULL) return; if (poly == NULL) return;
// Don't let non-perpetual polyobjs overshoot their targets. // 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; m_Speed = m_Speed < 0 ? -m_Dist : m_Dist;
} }
@ -395,7 +390,7 @@ void DRotatePoly::Tick ()
{ // perpetual polyobj { // perpetual polyobj
return; return;
} }
m_Dist -= abs(m_Speed); m_Dist -= fabs(m_Speed);
if (m_Dist == 0) if (m_Dist == 0)
{ {
SN_StopSequence (poly); SN_StopSequence (poly);
@ -436,18 +431,18 @@ bool EV_RotatePoly (line_t *line, int polyNum, int speed, int byteAngle,
{ {
if (byteAngle == 255) if (byteAngle == 255)
{ {
pe->m_Dist = ~0; pe->m_Dist = -1.;
} }
else else
{ {
pe->m_Dist = byteAngle*(ANGLE_90/64); // Angle pe->m_Dist = byteAngle*(90./64); // Angle
} }
} }
else 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); SN_StartSequence (poly, poly->seqType, SEQ_DOOR, 0);
direction = -direction; // Reverse the direction direction = -direction; // Reverse the direction
} }
@ -466,9 +461,9 @@ void DMovePoly::Tick ()
if (poly != NULL) 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; m_Dist -= absSpeed;
if (m_Dist <= 0) if (m_Dist <= 0)
{ {
@ -478,8 +473,7 @@ void DMovePoly::Tick ()
else if (m_Dist < absSpeed) else if (m_Dist < absSpeed)
{ {
m_Speed = m_Dist * (m_Speed < 0 ? -1 : 1); m_Speed = m_Dist * (m_Speed < 0 ? -1 : 1);
m_xSpeed = FixedMul (m_Speed, finecosine[m_Angle]); m_Speedv = m_Angle.ToVector(m_Speed);
m_ySpeed = FixedMul (m_Speed, finesine[m_Angle]);
} }
} }
} }
@ -491,12 +485,12 @@ void DMovePoly::Tick ()
// //
//========================================================================== //==========================================================================
bool EV_MovePoly (line_t *line, int polyNum, int speed, angle_t angle, bool EV_MovePoly (line_t *line, int polyNum, double speed, DAngle angle,
fixed_t dist, bool overRide) double dist, bool overRide)
{ {
DMovePoly *pe = NULL; DMovePoly *pe = NULL;
FPolyObj *poly; FPolyObj *poly;
angle_t an = angle; DAngle an = angle;
if ((poly = PO_GetPolyobj(polyNum)) == NULL) if ((poly = PO_GetPolyobj(polyNum)) == NULL)
{ {
@ -515,9 +509,8 @@ bool EV_MovePoly (line_t *line, int polyNum, int speed, angle_t angle,
poly->specialdata = pe; poly->specialdata = pe;
pe->m_Dist = dist; // Distance pe->m_Dist = dist; // Distance
pe->m_Speed = speed; pe->m_Speed = speed;
pe->m_Angle = an >> ANGLETOFINESHIFT; pe->m_Angle = angle;
pe->m_xSpeed = FixedMul (pe->m_Speed, finecosine[pe->m_Angle]); pe->m_Speedv = angle.ToVector(speed);
pe->m_ySpeed = FixedMul (pe->m_Speed, finesine[pe->m_Angle]);
SN_StartSequence (poly, poly->seqType, SEQ_DOOR, 0); SN_StartSequence (poly, poly->seqType, SEQ_DOOR, 0);
// Do not interpolate very fast moving polyobjects. The minimum tic count is // Do not interpolate very fast moving polyobjects. The minimum tic count is
@ -529,7 +522,7 @@ bool EV_MovePoly (line_t *line, int polyNum, int speed, angle_t angle,
pe->StopInterpolation (); pe->StopInterpolation ();
} }
an = an + ANGLE_180; // Reverse the angle. angle += 180.; // Reverse the angle.
} }
return pe != NULL; // Return true if something started moving. return pe != NULL; // Return true if something started moving.
} }
@ -546,9 +539,9 @@ void DMovePolyTo::Tick ()
if (poly != NULL) 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; m_Dist -= absSpeed;
if (m_Dist <= 0) if (m_Dist <= 0)
{ {
@ -558,8 +551,7 @@ void DMovePolyTo::Tick ()
else if (m_Dist < absSpeed) else if (m_Dist < absSpeed)
{ {
m_Speed = m_Dist * (m_Speed < 0 ? -1 : 1); m_Speed = m_Dist * (m_Speed < 0 ? -1 : 1);
m_xSpeed = m_xTarget - poly->StartSpot.x; m_Speedv = m_Target - poly->StartSpot.pos;
m_ySpeed = m_yTarget - poly->StartSpot.y;
} }
} }
} }
@ -571,7 +563,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; DMovePolyTo *pe = NULL;
FPolyObj *poly; FPolyObj *poly;
@ -585,8 +577,7 @@ bool EV_MovePolyTo(line_t *line, int polyNum, int speed, fixed_t targx, fixed_t
} }
FPolyMirrorIterator it(poly); FPolyMirrorIterator it(poly);
dist.X = targx - poly->StartSpot.x; dist = targ - poly->StartSpot.pos;
dist.Y = targy - poly->StartSpot.y;
distlen = dist.MakeUnit(); distlen = dist.MakeUnit();
while ((poly = it.NextMirror()) != NULL) while ((poly = it.NextMirror()) != NULL)
{ {
@ -596,12 +587,10 @@ bool EV_MovePolyTo(line_t *line, int polyNum, int speed, fixed_t targx, fixed_t
} }
pe = new DMovePolyTo(poly->tag); pe = new DMovePolyTo(poly->tag);
poly->specialdata = pe; poly->specialdata = pe;
pe->m_Dist = xs_RoundToInt(distlen); pe->m_Dist = distlen;
pe->m_Speed = speed; pe->m_Speed = speed;
pe->m_xSpeed = xs_RoundToInt(speed * dist.X); pe->m_Speedv = dist * speed;
pe->m_ySpeed = xs_RoundToInt(speed * dist.Y); pe->m_Target = poly->StartSpot.pos + dist * distlen;
pe->m_xTarget = xs_RoundToInt(poly->StartSpot.x + distlen * dist.X);
pe->m_yTarget = xs_RoundToInt(poly->StartSpot.y + distlen * dist.Y);
if ((pe->m_Dist / pe->m_Speed) <= 2) if ((pe->m_Dist / pe->m_Speed) <= 2)
{ {
pe->StopInterpolation(); pe->StopInterpolation();
@ -619,7 +608,6 @@ bool EV_MovePolyTo(line_t *line, int polyNum, int speed, fixed_t targx, fixed_t
void DPolyDoor::Tick () void DPolyDoor::Tick ()
{ {
int absSpeed;
FPolyObj *poly = PO_GetPolyobj (m_PolyObj); FPolyObj *poly = PO_GetPolyobj (m_PolyObj);
if (poly == NULL) return; if (poly == NULL) return;
@ -635,9 +623,9 @@ void DPolyDoor::Tick ()
switch (m_Type) switch (m_Type)
{ {
case PODOOR_SLIDE: 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; m_Dist -= absSpeed;
if (m_Dist <= 0) if (m_Dist <= 0)
{ {
@ -647,9 +635,8 @@ void DPolyDoor::Tick ()
m_Dist = m_TotalDist; m_Dist = m_TotalDist;
m_Close = true; m_Close = true;
m_Tics = m_WaitTics; m_Tics = m_WaitTics;
m_Direction = (ANGLE_MAX>>ANGLETOFINESHIFT) - m_Direction; m_Direction = -m_Direction;
m_xSpeed = -m_xSpeed; m_Speedv = -m_Speedv;
m_ySpeed = -m_ySpeed;
} }
else else
{ {
@ -666,10 +653,8 @@ void DPolyDoor::Tick ()
else else
{ // open back up { // open back up
m_Dist = m_TotalDist - m_Dist; m_Dist = m_TotalDist - m_Dist;
m_Direction = (ANGLE_MAX>>ANGLETOFINESHIFT)- m_Direction = -m_Direction;
m_Direction; m_Speedv = -m_Speedv;
m_xSpeed = -m_xSpeed;
m_ySpeed = -m_ySpeed;
m_Close = false; m_Close = false;
SN_StartSequence (poly, poly->seqType, SEQ_DOOR, 0); SN_StartSequence (poly, poly->seqType, SEQ_DOOR, 0);
} }
@ -679,7 +664,7 @@ void DPolyDoor::Tick ()
case PODOOR_SWING: case PODOOR_SWING:
if (m_Dist <= 0 || poly->RotatePolyobj (m_Speed)) if (m_Dist <= 0 || poly->RotatePolyobj (m_Speed))
{ {
absSpeed = abs (m_Speed); double absSpeed = fabs (m_Speed);
m_Dist -= absSpeed; m_Dist -= absSpeed;
if (m_Dist <= 0) if (m_Dist <= 0)
{ {
@ -724,8 +709,7 @@ void DPolyDoor::Tick ()
// //
//========================================================================== //==========================================================================
bool EV_OpenPolyDoor (line_t *line, int polyNum, int speed, angle_t angle, bool EV_OpenPolyDoor(line_t *line, int polyNum, double speed, DAngle angle, int delay, double distance, podoortype_t type)
int delay, int distance, podoortype_t type)
{ {
DPolyDoor *pd = NULL; DPolyDoor *pd = NULL;
FPolyObj *poly; FPolyObj *poly;
@ -751,18 +735,17 @@ bool EV_OpenPolyDoor (line_t *line, int polyNum, int speed, angle_t angle,
pd->m_WaitTics = delay; pd->m_WaitTics = delay;
pd->m_Speed = speed; pd->m_Speed = speed;
pd->m_Dist = pd->m_TotalDist = distance; // Distance pd->m_Dist = pd->m_TotalDist = distance; // Distance
pd->m_Direction = angle >> ANGLETOFINESHIFT; pd->m_Direction = angle;
pd->m_xSpeed = FixedMul (pd->m_Speed, finecosine[pd->m_Direction]); pd->m_Speedv = angle.ToVector(speed);
pd->m_ySpeed = FixedMul (pd->m_Speed, finesine[pd->m_Direction]);
SN_StartSequence (poly, poly->seqType, SEQ_DOOR, 0); SN_StartSequence (poly, poly->seqType, SEQ_DOOR, 0);
angle += ANGLE_180; // reverse the angle angle += 180.; // reverse the angle
} }
else if (type == PODOOR_SWING) else if (type == PODOOR_SWING)
{ {
pd->m_WaitTics = delay; pd->m_WaitTics = delay;
pd->m_Direction = swingdir; pd->m_Direction.Degrees = swingdir;
pd->m_Speed = (speed*pd->m_Direction*(ANGLE_90/64))>>3; pd->m_Speed = (speed*swingdir*(90. / 64)) / 8;
pd->m_Dist = pd->m_TotalDist = angle; pd->m_Dist = pd->m_TotalDist = angle.Degrees;
SN_StartSequence (poly, poly->seqType, SEQ_DOOR, 0); SN_StartSequence (poly, poly->seqType, SEQ_DOOR, 0);
swingdir = -swingdir; // reverse the direction swingdir = -swingdir; // reverse the direction
} }
@ -823,15 +806,15 @@ FPolyObj *PO_GetPolyobj (int polyNum)
FPolyObj::FPolyObj() FPolyObj::FPolyObj()
{ {
StartSpot.x = StartSpot.y = 0; StartSpot.pos = { 0,0 };
angle = 0; Angle = 0.;
tag = 0; tag = 0;
memset(bbox, 0, sizeof(bbox)); memset(bbox, 0, sizeof(bbox));
validcount = 0; validcount = 0;
crush = 0; crush = 0;
bHurtOnTouch = false; bHurtOnTouch = false;
seqType = 0; seqType = 0;
size = 0; Size = 0;
subsectorlinks = NULL; subsectorlinks = NULL;
specialdata = NULL; specialdata = NULL;
interpolation = NULL; interpolation = NULL;
@ -859,7 +842,7 @@ void FPolyObj::ThrustMobj (AActor *actor, side_t *side)
DAngle thrustAngle; DAngle thrustAngle;
DPolyAction *pe; DPolyAction *pe;
int force; double force;
if (!(actor->flags&MF_SHOOTABLE) && !actor->player) if (!(actor->flags&MF_SHOOTABLE) && !actor->player)
{ {
@ -874,27 +857,20 @@ void FPolyObj::ThrustMobj (AActor *actor, side_t *side)
{ {
if (pe->IsKindOf (RUNTIME_CLASS (DRotatePoly))) 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 else
{ {
force = pe->GetSpeed() >> 3; force = pe->GetSpeed() / 8;
}
if (force < FRACUNIT)
{
force = FRACUNIT;
}
else if (force > 4*FRACUNIT)
{
force = 4*FRACUNIT;
} }
force = clamp(force, 1., 4.);
} }
else else
{ {
force = FRACUNIT; force = 1;
} }
DVector2 thrust = thrustAngle.ToVector(FIXED2FLOAT(force)); DVector2 thrust = thrustAngle.ToVector(force);
actor->Vel += thrust; actor->Vel += thrust;
if (crush) if (crush)
@ -919,47 +895,19 @@ void FPolyObj::UpdateBBox ()
{ {
for(unsigned i=0;i<Linedefs.Size(); i++) for(unsigned i=0;i<Linedefs.Size(); i++)
{ {
line_t *line = Linedefs[i]; P_AdjustLine(Linedefs[i]);
if (line->v1->fixX() < line->v2->fixX())
{
line->bbox[BOXLEFT] = line->v1->fixX();
line->bbox[BOXRIGHT] = line->v2->fixX();
}
else
{
line->bbox[BOXLEFT] = line->v2->fixX();
line->bbox[BOXRIGHT] = line->v1->fixX();
}
if (line->v1->fixY() < line->v2->fixY())
{
line->bbox[BOXBOTTOM] = line->v1->fixY();
line->bbox[BOXTOP] = line->v2->fixY();
}
else
{
line->bbox[BOXBOTTOM] = line->v2->fixY();
line->bbox[BOXTOP] = line->v1->fixY();
}
// Update the line's slopetype
line->setDelta(
line->v2->fixX() - line->v1->fixX(),
line->v2->fixY() - line->v1->fixY());
} }
CalcCenter(); CalcCenter();
} }
void FPolyObj::CalcCenter() void FPolyObj::CalcCenter()
{ {
SQWORD cx = 0, cy = 0; DVector2 c = { 0, 0 };
for(unsigned i=0;i<Vertices.Size(); i++) for(unsigned i=0;i<Vertices.Size(); i++)
{ {
cx += Vertices[i]->fixX(); c += Vertices[i]->fPos();
cy += Vertices[i]->fixY();
} }
CenterSpot.x = (fixed_t)(cx / Vertices.Size()); CenterSpot.pos = c / Vertices.Size();
CenterSpot.y = (fixed_t)(cy / Vertices.Size());
} }
//========================================================================== //==========================================================================
@ -968,11 +916,11 @@ void FPolyObj::CalcCenter()
// //
//========================================================================== //==========================================================================
bool FPolyObj::MovePolyobj (int x, int y, bool force) bool FPolyObj::MovePolyobj (const DVector2 &pos, bool force)
{ {
FBoundingBox oldbounds = Bounds; FBoundingBox oldbounds = Bounds;
UnLinkPolyobj (); UnLinkPolyobj ();
DoMovePolyobj (x, y); DoMovePolyobj (pos);
if (!force) if (!force)
{ {
@ -987,15 +935,13 @@ bool FPolyObj::MovePolyobj (int x, int y, bool force)
} }
if (blocked) if (blocked)
{ {
DoMovePolyobj (-x, -y); DoMovePolyobj (-pos);
LinkPolyobj(); LinkPolyobj();
return false; return false;
} }
} }
StartSpot.x += x; StartSpot.pos += pos;
StartSpot.y += y; CenterSpot.pos += pos;
CenterSpot.x += x;
CenterSpot.y += y;
LinkPolyobj (); LinkPolyobj ();
ClearSubsectorLinks(); ClearSubsectorLinks();
RecalcActorFloorCeil(Bounds | oldbounds); RecalcActorFloorCeil(Bounds | oldbounds);
@ -1008,20 +954,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++) for(unsigned i=0;i < Vertices.Size(); i++)
{ {
Vertices[i]->set(Vertices[i]->fixX() + x, Vertices[i]->fixY() + y); Vertices[i]->set(Vertices[i]->fX() + pos.X, Vertices[i]->fY() + pos.Y);
PrevPts[i].x += x; PrevPts[i].pos += pos;
PrevPts[i].y += y;
} }
for (unsigned i = 0; i < Linedefs.Size(); i++) for (unsigned i = 0; i < Linedefs.Size(); i++)
{ {
Linedefs[i]->bbox[BOXTOP] += y; Linedefs[i]->bbox[BOXTOP] += pos.Y;
Linedefs[i]->bbox[BOXBOTTOM] += y; Linedefs[i]->bbox[BOXBOTTOM] += pos.Y;
Linedefs[i]->bbox[BOXLEFT] += x; Linedefs[i]->bbox[BOXLEFT] += pos.X;
Linedefs[i]->bbox[BOXRIGHT] += x; Linedefs[i]->bbox[BOXRIGHT] += pos.X;
} }
} }
@ -1031,16 +976,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; DVector2 tr = out;
fixed_t tr_y = *y;
double s = an.Sin(); double s = an.Sin();
double c = an.Cos(); double c = an.Cos();
*x = (xs_CRoundToInt(tr_x * c - tr_y*s) & 0xfffffe00) + startSpotX; out.X = tr.X * c - tr.Y * s + start.X;
*y = (xs_CRoundToInt(tr_x * s + tr_y*c) & 0xfffffe00) + startSpotY; out.Y = tr.X * s + tr.Y * c + start.Y;
} }
//========================================================================== //==========================================================================
@ -1049,23 +993,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; DAngle an;
bool blocked; bool blocked;
FBoundingBox oldbounds = Bounds; FBoundingBox oldbounds = Bounds;
an = ANGLE2DBL(this->angle + angle); an = Angle + angle;
UnLinkPolyobj(); UnLinkPolyobj();
for(unsigned i=0;i < Vertices.Size(); i++) for(unsigned i=0;i < Vertices.Size(); i++)
{ {
PrevPts[i].x = Vertices[i]->fixX(); PrevPts[i].pos = Vertices[i]->fPos();
PrevPts[i].y = Vertices[i]->fixY();
FPolyVertex torot = OriginalPts[i]; FPolyVertex torot = OriginalPts[i];
RotatePt(an, &torot.x, &torot.y, StartSpot.x, StartSpot.y); RotatePt(an, torot.pos, StartSpot.pos);
Vertices[i]->set(torot.x, torot.y); Vertices[i]->set(torot.pos.X, torot.pos.Y);
} }
blocked = false; blocked = false;
validcount++; validcount++;
@ -1085,14 +1028,14 @@ bool FPolyObj::RotatePolyobj (angle_t angle, bool fromsave)
{ {
for(unsigned i=0;i < Vertices.Size(); i++) 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(); UpdateBBox();
LinkPolyobj(); LinkPolyobj();
return false; return false;
} }
} }
this->angle += angle; Angle += angle;
LinkPolyobj(); LinkPolyobj();
ClearSubsectorLinks(); ClearSubsectorLinks();
RecalcActorFloorCeil(Bounds | oldbounds); RecalcActorFloorCeil(Bounds | oldbounds);
@ -1153,10 +1096,10 @@ bool FPolyObj::CheckMobjBlocking (side_t *sd)
ld = sd->linedef; ld = sd->linedef;
top = GetSafeBlockY(ld->bbox[BOXTOP]-bmaporgy); top = GetBlockY(ld->bbox[BOXTOP]);
bottom = GetSafeBlockY(ld->bbox[BOXBOTTOM]-bmaporgy); bottom = GetBlockY(ld->bbox[BOXBOTTOM]);
left = GetSafeBlockX(ld->bbox[BOXLEFT]-bmaporgx); left = GetBlockX(ld->bbox[BOXLEFT]);
right = GetSafeBlockX(ld->bbox[BOXRIGHT]-bmaporgx); right = GetBlockX(ld->bbox[BOXRIGHT]);
blocked = false; blocked = false;
checker.Clear(); checker.Clear();
@ -1214,16 +1157,9 @@ bool FPolyObj::CheckMobjBlocking (side_t *sd)
performBlockingThrust = true; 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] if (!box.inRange(ld) || box.BoxOnLineSide(ld) != -1)
|| box.Left() >= ld->bbox[BOXRIGHT]
|| box.Top() <= ld->bbox[BOXBOTTOM]
|| box.Bottom() >= ld->bbox[BOXTOP])
{
continue;
}
if (box.BoxOnLineSide(ld) != -1)
{ {
continue; continue;
} }
@ -1284,10 +1220,10 @@ void FPolyObj::LinkPolyobj ()
vt = Sidedefs[i]->linedef->v2; vt = Sidedefs[i]->linedef->v2;
Bounds.AddToBox(vt->fixX(), vt->fixY()); Bounds.AddToBox(vt->fixX(), vt->fixY());
} }
bbox[BOXRIGHT] = GetSafeBlockX(Bounds.Right() - bmaporgx); bbox[BOXRIGHT] = GetBlockX(FIXED2DBL(Bounds.Right()));
bbox[BOXLEFT] = GetSafeBlockX(Bounds.Left() - bmaporgx); bbox[BOXLEFT] = GetBlockX(FIXED2DBL(Bounds.Left()));
bbox[BOXTOP] = GetSafeBlockY(Bounds.Top() - bmaporgy); bbox[BOXTOP] = GetBlockY(FIXED2DBL(Bounds.Top()));
bbox[BOXBOTTOM] = GetSafeBlockY(Bounds.Bottom() - bmaporgy); bbox[BOXBOTTOM] = GetBlockY(FIXED2DBL(Bounds.Bottom()));
// add the polyobj to each blockmap section // add the polyobj to each blockmap section
for(int j = bbox[BOXBOTTOM]*bmapwidth; j <= bbox[BOXTOP]*bmapwidth; for(int j = bbox[BOXBOTTOM]*bmapwidth; j <= bbox[BOXTOP]*bmapwidth;
j += bmapwidth) j += bmapwidth)
@ -1360,10 +1296,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; unsigned int i;
double x = fx, y = fy; double x = fpos.X, y = fpos.Y;
double bestdist = HUGE_VAL; double bestdist = HUGE_VAL;
double bestx = 0, besty = 0; double bestx = 0, besty = 0;
side_t *bestline = NULL; side_t *bestline = NULL;
@ -1372,34 +1308,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 *v1 = Sidedefs[i]->V1();
vertex_t *v2 = Sidedefs[i]->V2(); vertex_t *v2 = Sidedefs[i]->V2();
double a = v2->fixX() - v1->fixX(); double a = v2->fX() - v1->fX();
double b = v2->fixY() - v1->fixY(); double b = v2->fY() - v1->fY();
double den = a*a + b*b; double den = a*a + b*b;
double ix, iy, dist; double ix, iy, dist;
if (den == 0) if (den == 0)
{ // Line is actually a point! { // Line is actually a point!
ix = v1->fixX(); ix = v1->fX();
iy = v1->fixY(); iy = v1->fY();
} }
else 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; double u = num / den;
if (u <= 0) if (u <= 0)
{ {
ix = v1->fixX(); ix = v1->fX();
iy = v1->fixY(); iy = v1->fY();
} }
else if (u >= 1) else if (u >= 1)
{ {
ix = v2->fixX(); ix = v2->fX();
iy = v2->fixY(); iy = v2->fY();
} }
else else
{ {
ix = v1->fixX() + u * a; ix = v1->fX() + u * a;
iy = v1->fixY() + u * b; iy = v1->fY() + u * b;
} }
} }
a = (ix - x); a = (ix - x);
@ -1413,8 +1349,7 @@ void FPolyObj::ClosestPoint(fixed_t fx, fixed_t fy, fixed_t &ox, fixed_t &oy, si
bestline = Sidedefs[i]; bestline = Sidedefs[i];
} }
} }
ox = fixed_t(bestx); out = { bestx, besty };
oy = fixed_t(besty);
if (side != NULL) if (side != NULL)
{ {
*side = bestline; *side = bestline;
@ -1650,11 +1585,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; FPolyObj *po;
int deltaX; DVector2 delta;
int deltaY;
po = NULL; po = NULL;
for (int i = 0; i < po_NumPolyobjs; i++) for (int i = 0; i < po_NumPolyobjs; i++)
@ -1675,8 +1609,7 @@ static void TranslateToStartSpot (int tag, int originX, int originY)
} }
po->OriginalPts.Resize(po->Sidedefs.Size()); po->OriginalPts.Resize(po->Sidedefs.Size());
po->PrevPts.Resize(po->Sidedefs.Size()); po->PrevPts.Resize(po->Sidedefs.Size());
deltaX = originX - po->StartSpot.x; delta = origin - po->StartSpot.pos;
deltaY = originY - po->StartSpot.y;
for (unsigned i = 0; i < po->Sidedefs.Size(); i++) for (unsigned i = 0; i < po->Sidedefs.Size(); i++)
{ {
@ -1684,20 +1617,19 @@ static void TranslateToStartSpot (int tag, int originX, int originY)
} }
for (unsigned i = 0; i < po->Linedefs.Size(); i++) for (unsigned i = 0; i < po->Linedefs.Size(); i++)
{ {
po->Linedefs[i]->bbox[BOXTOP] -= deltaY; po->Linedefs[i]->bbox[BOXTOP] -= delta.Y;
po->Linedefs[i]->bbox[BOXBOTTOM] -= deltaY; po->Linedefs[i]->bbox[BOXBOTTOM] -= delta.Y;
po->Linedefs[i]->bbox[BOXLEFT] -= deltaX; po->Linedefs[i]->bbox[BOXLEFT] -= delta.X;
po->Linedefs[i]->bbox[BOXRIGHT] -= deltaX; po->Linedefs[i]->bbox[BOXRIGHT] -= delta.X;
} }
for (unsigned i = 0; i < po->Vertices.Size(); i++) for (unsigned i = 0; i < po->Vertices.Size(); i++)
{ {
po->Vertices[i]->set(po->Vertices[i]->fixX() - deltaX, po->Vertices[i]->fixY() - deltaY); po->Vertices[i]->set(po->Vertices[i]->fX() - delta.X, po->Vertices[i]->fY() - delta.Y);
po->OriginalPts[i].x = po->Vertices[i]->fixX() - po->StartSpot.x; po->OriginalPts[i].pos = po->Vertices[i]->fPos() - po->StartSpot.pos;
po->OriginalPts[i].y = po->Vertices[i]->fixY() - po->StartSpot.y;
} }
po->CalcCenter(); po->CalcCenter();
// For compatibility purposes // For compatibility purposes
po->CenterSubsector = R_PointInSubsector(po->CenterSpot.x, po->CenterSpot.y); po->CenterSubsector = R_PointInSubsector(po->CenterSpot.pos);
} }
//========================================================================== //==========================================================================
@ -1728,8 +1660,7 @@ void PO_Init (void)
if (polyspawn->type >= SMT_PolySpawn && polyspawn->type <= SMT_PolySpawnHurt) if (polyspawn->type >= SMT_PolySpawn && polyspawn->type <= SMT_PolySpawnHurt)
{ {
// Polyobj StartSpot Pt. // Polyobj StartSpot Pt.
polyobjs[polyIndex].StartSpot.x = FLOAT2FIXED(polyspawn->pos.X); polyobjs[polyIndex].StartSpot.pos = polyspawn->pos;
polyobjs[polyIndex].StartSpot.y = FLOAT2FIXED(polyspawn->pos.Y);
SpawnPolyobj(polyIndex, polyspawn->angle, polyspawn->type); SpawnPolyobj(polyIndex, polyspawn->angle, polyspawn->type);
polyIndex++; polyIndex++;
*prev = polyspawn->next; *prev = polyspawn->next;
@ -1748,7 +1679,7 @@ void PO_Init (void)
if (polyspawn->type == SMT_PolyAnchor) if (polyspawn->type == SMT_PolyAnchor)
{ {
// Polyobj Anchor Pt. // Polyobj Anchor Pt.
TranslateToStartSpot (polyspawn->angle, FLOAT2FIXED(polyspawn->pos.X), FLOAT2FIXED(polyspawn->pos.Y)); TranslateToStartSpot (polyspawn->angle, polyspawn->pos);
} }
delete polyspawn; delete polyspawn;
polyspawn = next; polyspawn = next;
@ -1766,14 +1697,14 @@ void PO_Init (void)
} }
InitBlockMap(); InitBlockMap();
// [RH] Don't need the seg lists anymore // [RH] Don't need the side lists anymore
KillSideLists (); KillSideLists ();
for(int i=0;i<numnodes;i++) for(int i=0;i<numnodes;i++)
{ {
node_t *no = &nodes[i]; node_t *no = &nodes[i];
double fdx = (double)no->dx; double fdx = FIXED2DBL(no->dx);
double fdy = (double)no->dy; double fdy = FIXED2DBL(no->dy);
no->len = (float)g_sqrt(fdx * fdx + fdy * fdy); no->len = (float)g_sqrt(fdx * fdx + fdy * fdy);
} }
@ -1876,14 +1807,14 @@ static bool GetIntersection(FPolySeg *seg, node_t *bsp, FPolyVertex *v)
double num; double num;
double den; double den;
double v2x = (double)seg->v1.x; double v2x = seg->v1.pos.X;
double v2y = (double)seg->v1.y; double v2y = seg->v1.pos.Y;
double v2dx = (double)(seg->v2.x - seg->v1.x); double v2dx = seg->v2.pos.X - v2x;
double v2dy = (double)(seg->v2.y - seg->v1.y); double v2dy = seg->v2.pos.Y - v2y;
double v1x = (double)bsp->x; double v1x = FIXED2DBL(bsp->x);
double v1y = (double)bsp->y; double v1y = FIXED2DBL(bsp->y);
double v1dx = (double)bsp->dx; double v1dx = FIXED2DBL(bsp->dx);
double v1dy = (double)bsp->dy; double v1dy = FIXED2DBL(bsp->dy);
den = v1dy*v2dx - v1dx*v2dy; den = v1dy*v2dx - v1dx*v2dy;
@ -1895,8 +1826,8 @@ static bool GetIntersection(FPolySeg *seg, node_t *bsp, FPolyVertex *v)
if (frac < 0. || frac > 1.) return false; if (frac < 0. || frac > 1.) return false;
v->x = xs_RoundToInt(v2x + frac * v2dx); v->pos.X = v2x + frac * v2dx;
v->y = xs_RoundToInt(v2y + frac * v2dy); v->pos.Y = v2y + frac * v2dy;
return true; return true;
} }
@ -1910,7 +1841,7 @@ static bool GetIntersection(FPolySeg *seg, node_t *bsp, FPolyVertex *v)
static double PartitionDistance(FPolyVertex *vt, node_t *node) 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 +1878,23 @@ static void AddToBBox(fixed_t child[4], fixed_t parent[4])
static void AddToBBox(FPolyVertex *v, fixed_t bbox[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 +1913,7 @@ static void SplitPoly(FPolyNode *pnode, void *node, fixed_t bbox[4])
{ {
node_t *bsp = (node_t *)node; 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[0].Clear();
lists[1].Clear(); lists[1].Clear();
@ -2016,19 +1949,19 @@ static void SplitPoly(FPolyNode *pnode, void *node, fixed_t bbox[4])
} }
else else
{ {
int side = R_PointOnSide(seg->v2.x, seg->v2.y, bsp); int side = R_PointOnSide(seg->v2.pos, bsp);
lists[side].Push(*seg); lists[side].Push(*seg);
} }
} }
else if (dist_v2 <= POLY_EPSILON) 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); lists[side].Push(*seg);
} }
else else
{ {
int side1 = R_PointOnSide(seg->v1.x, seg->v1.y, bsp); int side1 = R_PointOnSide(seg->v1.pos, bsp);
int side2 = R_PointOnSide(seg->v2.x, seg->v2.y, bsp); int side2 = R_PointOnSide(seg->v2.pos, bsp);
if(side1 != side2) if(side1 != side2)
{ {

View file

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

View file

@ -693,8 +693,8 @@ fixedvec2 P_GetOffsetPosition(fixed_t x, fixed_t y, fixed_t dx, fixed_t dy)
// Try some easily discoverable early-out first. If we know that the trace cannot possibly find a portal, this saves us from calling the traverser completely for vast parts of the map. // Try some easily discoverable early-out first. If we know that the trace cannot possibly find a portal, this saves us from calling the traverser completely for vast parts of the map.
if (dx < 128 * FRACUNIT && dy < 128 * FRACUNIT) if (dx < 128 * FRACUNIT && dy < 128 * FRACUNIT)
{ {
fixed_t blockx = GetSafeBlockX(actx - bmaporgx); int blockx = GetBlockX(FIXED2DBL(actx));
fixed_t blocky = GetSafeBlockY(acty - bmaporgy); int blocky = GetBlockY(FIXED2DBL(acty));
if (blockx < 0 || blocky < 0 || blockx >= bmapwidth || blocky >= bmapheight || !PortalBlockmap(blockx, blocky).neighborContainsLines) return dest; if (blockx < 0 || blocky < 0 || blockx >= bmapwidth || blocky >= bmapheight || !PortalBlockmap(blockx, blocky).neighborContainsLines) return dest;
} }
@ -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 // 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); 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.fixD(); double cp = -sectors[i].ceilingplane.fD();
fixed_t fp = -sectors[i].ceilingplane.fixD(); double fp = -sectors[i].ceilingplane.fD();
if (cp < fp || fz == fp) if (cp < fp || fz == fp)
{ {
sectors[i].SkyBoxes[sector_t::ceiling] = NULL; sectors[i].SkyBoxes[sector_t::ceiling] = NULL;
@ -1174,13 +1174,7 @@ bool P_CollectConnectedGroups(int startgroup, const fixedvec3 &position, fixed_t
FBoundingBox box(position.x + disp.pos.x, position.y + disp.pos.y, checkradius); FBoundingBox box(position.x + disp.pos.x, position.y + disp.pos.y, checkradius);
if (box.Right() <= ld->bbox[BOXLEFT] if (!box.inRange(ld) || box.BoxOnLineSide(linkedPortals[i]->mOrigin) != -1) continue; // not touched
|| box.Left() >= ld->bbox[BOXRIGHT]
|| box.Top() <= ld->bbox[BOXBOTTOM]
|| box.Bottom() >= ld->bbox[BOXTOP])
continue; // not touched
if (box.BoxOnLineSide(linkedPortals[i]->mOrigin) != -1) continue; // not touched
foundPortals.Push(linkedPortals[i]); foundPortals.Push(linkedPortals[i]);
} }
bool foundone = true; bool foundone = true;
@ -1241,13 +1235,7 @@ bool P_CollectConnectedGroups(int startgroup, const fixedvec3 &position, fixed_t
line_t *ld; line_t *ld;
while ((ld = it.Next())) while ((ld = it.Next()))
{ {
if (box.Right() <= ld->bbox[BOXLEFT] if (!box.inRange(ld) || box.BoxOnLineSide(ld) != -1)
|| box.Left() >= ld->bbox[BOXRIGHT]
|| box.Top() <= ld->bbox[BOXBOTTOM]
|| box.Bottom() >= ld->bbox[BOXTOP])
continue;
if (box.BoxOnLineSide(ld) != -1)
continue; continue;
if (!(thisgroup & FPortalGroupArray::LOWER)) if (!(thisgroup & FPortalGroupArray::LOWER))

View file

@ -494,8 +494,8 @@ void DSectorPlaneInterpolation::Interpolate(double smoothratio)
pos = sector_t::ceiling; pos = sector_t::ceiling;
} }
bakheight = pplane->fixD(); bakheight = pplane->fD();
baktexz = sector->GetPlaneTexZ(pos); baktexz = sector->GetPlaneTexZF(pos);
if (refcount == 0 && oldheight == bakheight) if (refcount == 0 && oldheight == bakheight)
{ {
@ -628,8 +628,8 @@ void DSectorScrollInterpolation::Restore()
void DSectorScrollInterpolation::Interpolate(double smoothratio) void DSectorScrollInterpolation::Interpolate(double smoothratio)
{ {
bakx = sector->GetXOffset(ceiling); bakx = sector->GetXOffsetF(ceiling);
baky = sector->GetYOffset(ceiling, false); baky = sector->GetYOffsetF(ceiling, false);
if (refcount == 0 && oldx == bakx && oldy == baky) if (refcount == 0 && oldx == bakx && oldy == baky)
{ {
@ -719,8 +719,8 @@ void DWallScrollInterpolation::Restore()
void DWallScrollInterpolation::Interpolate(double smoothratio) void DWallScrollInterpolation::Interpolate(double smoothratio)
{ {
bakx = side->GetTextureXOffset(part); bakx = side->GetTextureXOffsetF(part);
baky = side->GetTextureYOffset(part); baky = side->GetTextureYOffsetF(part);
if (refcount == 0 && oldx == bakx && oldy == baky) if (refcount == 0 && oldx == bakx && oldy == baky)
{ {
@ -791,8 +791,8 @@ void DPolyobjInterpolation::UpdateInterpolation()
oldverts[i*2 ] = poly->Vertices[i]->fX(); oldverts[i*2 ] = poly->Vertices[i]->fX();
oldverts[i*2+1] = poly->Vertices[i]->fY(); oldverts[i*2+1] = poly->Vertices[i]->fY();
} }
oldcx = poly->CenterSpot.x; oldcx = poly->CenterSpot.pos.X;
oldcy = poly->CenterSpot.y; oldcy = poly->CenterSpot.pos.Y;
} }
//========================================================================== //==========================================================================
@ -807,8 +807,8 @@ void DPolyobjInterpolation::Restore()
{ {
poly->Vertices[i]->set(bakverts[i*2 ], bakverts[i*2+1]); poly->Vertices[i]->set(bakverts[i*2 ], bakverts[i*2+1]);
} }
poly->CenterSpot.x = bakcx; poly->CenterSpot.pos.X = bakcx;
poly->CenterSpot.y = bakcy; poly->CenterSpot.pos.Y = bakcy;
poly->ClearSubsectorLinks(); poly->ClearSubsectorLinks();
} }
@ -823,8 +823,8 @@ void DPolyobjInterpolation::Interpolate(double smoothratio)
bool changed = false; bool changed = false;
for(unsigned int i = 0; i < poly->Vertices.Size(); i++) for(unsigned int i = 0; i < poly->Vertices.Size(); i++)
{ {
bakverts[i*2 ] = poly->Vertices[i]->fixX(); bakverts[i*2 ] = poly->Vertices[i]->fX();
bakverts[i*2+1] = poly->Vertices[i]->fixY(); bakverts[i*2+1] = poly->Vertices[i]->fY();
if (bakverts[i * 2] != oldverts[i * 2] || bakverts[i * 2 + 1] != oldverts[i * 2 + 1]) if (bakverts[i * 2] != oldverts[i * 2] || bakverts[i * 2 + 1] != oldverts[i * 2 + 1])
{ {
@ -840,10 +840,10 @@ void DPolyobjInterpolation::Interpolate(double smoothratio)
} }
else else
{ {
bakcx = poly->CenterSpot.x; bakcx = poly->CenterSpot.pos.X;
bakcy = poly->CenterSpot.y; bakcy = poly->CenterSpot.pos.Y;
poly->CenterSpot.x = bakcx + (bakcx - oldcx) * smoothratio; poly->CenterSpot.pos.X = bakcx + (bakcx - oldcx) * smoothratio;
poly->CenterSpot.y = bakcy + (bakcy - oldcy) * smoothratio; poly->CenterSpot.pos.Y = bakcy + (bakcy - oldcy) * smoothratio;
poly->ClearSubsectorLinks(); poly->ClearSubsectorLinks();
} }

View file

@ -346,32 +346,6 @@ public:
d = FLOAT2FIXED(dd); d = FLOAT2FIXED(dd);
} }
void changeD(double dd)
{
d += FLOAT2FIXED(dd);
}
fixed_t fixA() const
{
return a;
}
fixed_t fixB() const
{
return b;
}
fixed_t fixC() const
{
return c;
}
fixed_t fixD() const
{
return d;
}
fixed_t fixiC() const
{
return ic;
}
double fA() const double fA() const
{ {
return FIXED2DBL(a); return FIXED2DBL(a);
@ -1431,9 +1405,9 @@ struct side_t
{ {
return textures[which].xscale; 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);
} }
@ -1463,9 +1437,9 @@ struct side_t
{ {
return FIXED2DBL(textures[which].yscale); 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); DInterpolation *SetInterpolation(int position);
@ -1496,7 +1470,7 @@ public:
fixed_t Alpha; // <--- translucency (0=invisibile, FRACUNIT=opaque) fixed_t Alpha; // <--- translucency (0=invisibile, FRACUNIT=opaque)
int args[5]; // <--- hexen-style arguments (expanded to ZDoom's full width) int args[5]; // <--- hexen-style arguments (expanded to ZDoom's full width)
side_t *sidedef[2]; side_t *sidedef[2];
fixed_t bbox[4]; // bounding box, for the extent of the LineDef. double bbox[4]; // bounding box, for the extent of the LineDef.
sector_t *frontsector, *backsector; sector_t *frontsector, *backsector;
int validcount; // if == validcount, already checked int validcount; // if == validcount, already checked
int locknumber; // [Dusk] lock number for special int locknumber; // [Dusk] lock number for special
@ -1783,10 +1757,10 @@ inline void AActor::ClearInterpolation()
inline bool FBoundingBox::inRange(const line_t *ld) const inline bool FBoundingBox::inRange(const line_t *ld) const
{ {
return Left() < ld->bbox[BOXRIGHT] && return FIXED2DBL(Left()) < ld->bbox[BOXRIGHT] &&
Right() > ld->bbox[BOXLEFT] && FIXED2DBL(Right()) > ld->bbox[BOXLEFT] &&
Top() > ld->bbox[BOXBOTTOM] && FIXED2DBL(Top()) > ld->bbox[BOXBOTTOM] &&
Bottom() < ld->bbox[BOXTOP]; FIXED2DBL(Bottom()) < ld->bbox[BOXTOP];
} }

View file

@ -91,7 +91,7 @@ visplane_t *ceilingplane;
// Empirically verified to be fairly uniform: // Empirically verified to be fairly uniform:
#define visplane_hash(picnum,lightlevel,height) \ #define visplane_hash(picnum,lightlevel,height) \
((unsigned)((picnum)*3+(lightlevel)+((height).fixD())*7) & (MAXVISPLANES-1)) ((unsigned)((picnum)*3+(lightlevel)+(FLOAT2FIXED((height).fD()))*7) & (MAXVISPLANES-1))
// These are copies of the main parameters used when drawing stacked sectors. // These are copies of the main parameters used when drawing stacked sectors.
// When you change the main parameters, you should copy them here too *unless* // When you change the main parameters, you should copy them here too *unless*
@ -605,7 +605,7 @@ visplane_t *R_FindPlane (const secplane_t &height, FTextureID picnum, int lightl
// always necessary, but it is needed if a floor and ceiling sky are in the // always necessary, but it is needed if a floor and ceiling sky are in the
// same column but separated by a wall. If they both try to reside in the // same column but separated by a wall. If they both try to reside in the
// same visplane, then only the floor sky will be drawn. // same visplane, then only the floor sky will be drawn.
plane.set(0, 0, height.fixC(), 0); plane.set(0., 0., height.fC(), 0.);
isskybox = skybox != NULL && !skybox->bInSkybox; isskybox = skybox != NULL && !skybox->bInSkybox;
} }
else if (skybox != NULL && skybox->bAlways && !skybox->bInSkybox) else if (skybox != NULL && skybox->bAlways && !skybox->bInSkybox)
@ -1564,7 +1564,7 @@ void R_DrawNormalPlane (visplane_t *pl, fixed_t alpha, bool additive, bool maske
basexfrac = FixedMul (xscale, finecosine[planeang]) + x*xstepscale; basexfrac = FixedMul (xscale, finecosine[planeang]) + x*xstepscale;
baseyfrac = FixedMul (yscale, -finesine[planeang]) + x*ystepscale; baseyfrac = FixedMul (yscale, -finesine[planeang]) + x*ystepscale;
planeheight = abs (FixedMul (pl->height.fixD(), -pl->height.fixiC()) - viewz); planeheight = abs (int(pl->height.fD() * -pl->height.fiC() * 65536) - viewz);
GlobVis = FixedDiv (r_FloorVisibility, planeheight); GlobVis = FixedDiv (r_FloorVisibility, planeheight);
if (fixedlightlev >= 0) if (fixedlightlev >= 0)

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; 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); angle_t R_PointToAngle2 (fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2);
inline angle_t R_PointToAngle (fixed_t x, fixed_t y) { return R_PointToAngle2 (viewx, viewy, x, y); } inline angle_t R_PointToAngle (fixed_t x, fixed_t y) { return R_PointToAngle2 (viewx, viewy, x, y); }
@ -76,7 +80,6 @@ inline subsector_t *R_PointInSubsector(const DVector2 &pos)
{ {
return R_PointInSubsector(FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y)); return R_PointInSubsector(FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y));
} }
fixed_t R_PointToDist2 (fixed_t dx, fixed_t dy); fixed_t R_PointToDist2 (fixed_t dx, fixed_t dy);
void R_ResetViewInterpolation (); void R_ResetViewInterpolation ();
void R_RebuildViewInterpolation(player_t *player); void R_RebuildViewInterpolation(player_t *player);

View file

@ -162,8 +162,8 @@ enum SICommands
struct FBloodSFX struct FBloodSFX
{ {
DWORD RelVol; // volume, 0-255 DWORD RelVol; // volume, 0-255
fixed_t Pitch; // pitch change int Pitch; // pitch change
fixed_t PitchRange; // range of random pitch int PitchRange; // range of random pitch
DWORD Format; // format of audio 1=11025 5=22050 DWORD Format; // format of audio 1=11025 5=22050
SDWORD LoopStart; // loop position (-1 means no looping) SDWORD LoopStart; // loop position (-1 means no looping)
char RawName[9]; // name of RAW resource char RawName[9]; // name of RAW resource

View file

@ -540,7 +540,7 @@ void S_ParseSndSeq (int levellump)
int delaybase; int delaybase;
float volumebase; float volumebase;
int curseq = -1; int curseq = -1;
fixed_t val; int val;
// First free the old SNDSEQ data. This allows us to reload this for each level // First free the old SNDSEQ data. This allows us to reload this for each level
// and specify a level specific SNDSEQ lump! // and specify a level specific SNDSEQ lump!

View file

@ -812,7 +812,10 @@ static void CalcPolyobjSoundOrg(const FPolyObj *poly, fixed_t *x, fixed_t *y, fi
side_t *side; side_t *side;
sector_t *sec; 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; sec = side->sector;
*z = clamp(*z, sec->floorplane.ZatPoint(*x, *y), sec->ceilingplane.ZatPoint(*x, *y)); *z = clamp(*z, sec->floorplane.ZatPoint(*x, *y), sec->ceilingplane.ZatPoint(*x, *y));
} }