From 1666418510434649ef435b32015ac0004cfa746f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 30 Mar 2016 20:05:29 +0200 Subject: [PATCH 1/4] - fixed incomplete interpolation floatification. --- src/r_data/r_interpolate.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/r_data/r_interpolate.cpp b/src/r_data/r_interpolate.cpp index 535173e30..2b9944a92 100644 --- a/src/r_data/r_interpolate.cpp +++ b/src/r_data/r_interpolate.cpp @@ -494,8 +494,8 @@ void DSectorPlaneInterpolation::Interpolate(double smoothratio) pos = sector_t::ceiling; } - bakheight = pplane->fixD(); - baktexz = sector->GetPlaneTexZ(pos); + bakheight = pplane->fD(); + baktexz = sector->GetPlaneTexZF(pos); if (refcount == 0 && oldheight == bakheight) { @@ -628,8 +628,8 @@ void DSectorScrollInterpolation::Restore() void DSectorScrollInterpolation::Interpolate(double smoothratio) { - bakx = sector->GetXOffset(ceiling); - baky = sector->GetYOffset(ceiling, false); + bakx = sector->GetXOffsetF(ceiling); + baky = sector->GetYOffsetF(ceiling, false); if (refcount == 0 && oldx == bakx && oldy == baky) { @@ -719,8 +719,8 @@ void DWallScrollInterpolation::Restore() void DWallScrollInterpolation::Interpolate(double smoothratio) { - bakx = side->GetTextureXOffset(part); - baky = side->GetTextureYOffset(part); + bakx = side->GetTextureXOffsetF(part); + baky = side->GetTextureYOffsetF(part); if (refcount == 0 && oldx == bakx && oldy == baky) { @@ -823,8 +823,8 @@ void DPolyobjInterpolation::Interpolate(double smoothratio) bool changed = false; for(unsigned int i = 0; i < poly->Vertices.Size(); i++) { - bakverts[i*2 ] = poly->Vertices[i]->fixX(); - bakverts[i*2+1] = poly->Vertices[i]->fixY(); + bakverts[i*2 ] = poly->Vertices[i]->fX(); + bakverts[i*2+1] = poly->Vertices[i]->fY(); if (bakverts[i * 2] != oldverts[i * 2] || bakverts[i * 2 + 1] != oldverts[i * 2 + 1]) { From 7a2c8fdc1cd6fc33ab37c7103b6a96cfb36e14ca Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 31 Mar 2016 00:41:21 +0200 Subject: [PATCH 2/4] - floatified po_man.cpp and the remaining bits in p_lnspec.cpp --- src/am_map.cpp | 17 +- src/nodebuild_utility.cpp | 8 +- src/p_acs.cpp | 4 +- src/p_lnspec.cpp | 130 +++++++------- src/p_saveg.cpp | 15 +- src/po_man.cpp | 332 ++++++++++++++++------------------- src/po_man.h | 23 ++- src/r_data/r_interpolate.cpp | 16 +- src/r_defs.h | 8 +- src/r_utility.h | 8 + src/s_sound.cpp | 5 +- 11 files changed, 273 insertions(+), 293 deletions(-) diff --git a/src/am_map.cpp b/src/am_map.cpp index 0c1f837cf..5b6d6a7cc 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -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)) { diff --git a/src/nodebuild_utility.cpp b/src/nodebuild_utility.cpp index 96da22b8a..dcf5b7036 100644 --- a/src/nodebuild_utility.cpp +++ b/src/nodebuild_utility.cpp @@ -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); diff --git a/src/p_acs.cpp b/src/p_acs.cpp index d287a47bd..89aaea088 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -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; diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp index 802541f49..cbcbf134e 100644 --- a/src/p_lnspec.cpp +++ b/src/p_lnspec.cpp @@ -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< 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< 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); } } } diff --git a/src/p_saveg.cpp b/src/p_saveg.cpp index f6e023392..d16b76457 100644 --- a/src/p_saveg.cpp +++ b/src/p_saveg.cpp @@ -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); } } } diff --git a/src/po_man.cpp b/src/po_man.cpp index e3c4ddecd..ca7a03f19 100644 --- a/src/po_man.cpp +++ b/src/po_man.cpp @@ -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 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;ifixX(); - 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;idx; - 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) { diff --git a/src/po_man.h b/src/po_man.h index e989ad4f5..2fbc433cf 100644 --- a/src/po_man.h +++ b/src/po_man.h @@ -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 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); diff --git a/src/r_data/r_interpolate.cpp b/src/r_data/r_interpolate.cpp index 2b9944a92..a159e22bc 100644 --- a/src/r_data/r_interpolate.cpp +++ b/src/r_data/r_interpolate.cpp @@ -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(); } diff --git a/src/r_defs.h b/src/r_defs.h index a41a9044b..851fc2a7a 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -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); diff --git a/src/r_utility.h b/src/r_utility.h index b3cfb10ad..7df9c3606 100644 --- a/src/r_utility.h +++ b/src/r_utility.h @@ -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); diff --git a/src/s_sound.cpp b/src/s_sound.cpp index 2e41a54a7..e30e43852 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -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)); } From f41afde5452e338590ae2c4135e951ee7d4efbe1 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 31 Mar 2016 01:22:49 +0200 Subject: [PATCH 3/4] - floatified line_t::bbox. --- src/p_enemy.cpp | 7 ++---- src/p_maputl.cpp | 8 +++---- src/p_setup.cpp | 20 ++++++++-------- src/po_man.cpp | 62 ++++++++++++------------------------------------ src/portal.cpp | 16 ++----------- src/r_defs.h | 10 ++++---- 6 files changed, 38 insertions(+), 85 deletions(-) diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index 67ebdbfca..57b2200d2 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -885,11 +885,8 @@ void P_NewChaseDir(AActor * actor) double deltay = 0; while ((line = it.Next())) { - if (line->backsector && // Ignore one-sided linedefs - box.Right() > line->bbox[BOXLEFT] && - box.Left() < line->bbox[BOXRIGHT] && - box.Top() > line->bbox[BOXBOTTOM] && // Linedef must be contacted - box.Bottom() < line->bbox[BOXTOP] && + if (line->backsector && // Ignore one-sided linedefs + box.inRange(line) && box.BoxOnLineSide(line) == -1) { double front = line->frontsector->floorplane.ZatPoint(actor->PosRelative(line)); diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index f6246b7a4..6dce13926 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -403,10 +403,10 @@ bool AActor::FixMapthingPos() } // Not inside the line's bounding box - if (_f_X() + _f_radius() <= ldef->bbox[BOXLEFT] - || _f_X() - _f_radius() >= ldef->bbox[BOXRIGHT] - || _f_Y() + _f_radius() <= ldef->bbox[BOXBOTTOM] - || _f_Y() - _f_radius() >= ldef->bbox[BOXTOP]) + if (X() + radius <= ldef->bbox[BOXLEFT] + || X() - radius >= ldef->bbox[BOXRIGHT] + || Y() + radius <= ldef->bbox[BOXBOTTOM] + || Y() - radius >= ldef->bbox[BOXTOP]) continue; // Get the exact distance to the line diff --git a/src/p_setup.cpp b/src/p_setup.cpp index e751957d3..91ea7086f 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -1905,26 +1905,26 @@ void P_AdjustLine (line_t *ld) 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[BOXRIGHT] = v2->fixX(); + ld->bbox[BOXLEFT] = v1->fX(); + ld->bbox[BOXRIGHT] = v2->fX(); } else { - ld->bbox[BOXLEFT] = v2->fixX(); - ld->bbox[BOXRIGHT] = v1->fixX(); + ld->bbox[BOXLEFT] = v2->fX(); + ld->bbox[BOXRIGHT] = v1->fX(); } - if (v1->fixY() < v2->fixY()) + if (v1->fY() < v2->fY()) { - ld->bbox[BOXBOTTOM] = v1->fixY(); - ld->bbox[BOXTOP] = v2->fixY(); + ld->bbox[BOXBOTTOM] = v1->fY(); + ld->bbox[BOXTOP] = v2->fY(); } else { - ld->bbox[BOXBOTTOM] = v2->fixY(); - ld->bbox[BOXTOP] = v1->fixY(); + ld->bbox[BOXBOTTOM] = v2->fY(); + ld->bbox[BOXTOP] = v1->fY(); } } diff --git a/src/po_man.cpp b/src/po_man.cpp index ca7a03f19..3a5ac69ad 100644 --- a/src/po_man.cpp +++ b/src/po_man.cpp @@ -168,6 +168,7 @@ public: // EXTERNAL FUNCTION PROTOTYPES -------------------------------------------- void PO_Init (void); +void P_AdjustLine(line_t *ld); // PRIVATE FUNCTION PROTOTYPES --------------------------------------------- @@ -893,33 +894,7 @@ void FPolyObj::UpdateBBox () { for(unsigned i=0;iv1->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()); + P_AdjustLine(Linedefs[i]); } CalcCenter(); } @@ -987,10 +962,10 @@ void FPolyObj::DoMovePolyobj (const DVector2 &pos) } for (unsigned i = 0; i < Linedefs.Size(); i++) { - 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); + Linedefs[i]->bbox[BOXTOP] += pos.Y; + Linedefs[i]->bbox[BOXBOTTOM] += pos.Y; + Linedefs[i]->bbox[BOXLEFT] += pos.X; + Linedefs[i]->bbox[BOXRIGHT] += pos.X; } } @@ -1120,10 +1095,10 @@ bool FPolyObj::CheckMobjBlocking (side_t *sd) ld = sd->linedef; - top = GetSafeBlockY(ld->bbox[BOXTOP]-bmaporgy); - bottom = GetSafeBlockY(ld->bbox[BOXBOTTOM]-bmaporgy); - left = GetSafeBlockX(ld->bbox[BOXLEFT]-bmaporgx); - right = GetSafeBlockX(ld->bbox[BOXRIGHT]-bmaporgx); + top = int((ld->bbox[BOXTOP] - FIXED2DBL(bmaporgy)) / 128.); + bottom = int((ld->bbox[BOXBOTTOM] - FIXED2DBL(bmaporgy)) / 128.); + left = int((ld->bbox[BOXLEFT] - FIXED2DBL(bmaporgx)) / 128.); + right = int((ld->bbox[BOXRIGHT] - FIXED2DBL(bmaporgx)) / 128.); blocked = false; checker.Clear(); @@ -1183,14 +1158,7 @@ bool FPolyObj::CheckMobjBlocking (side_t *sd) FBoundingBox box(mobj->X(), mobj->Y(), mobj->radius); - if (box.Right() <= ld->bbox[BOXLEFT] - || box.Left() >= ld->bbox[BOXRIGHT] - || box.Top() <= ld->bbox[BOXBOTTOM] - || box.Bottom() >= ld->bbox[BOXTOP]) - { - continue; - } - if (box.BoxOnLineSide(ld) != -1) + if (!box.inRange(ld) || box.BoxOnLineSide(ld) != -1) { continue; } @@ -1648,10 +1616,10 @@ static void TranslateToStartSpot (int tag, const DVector2 &origin) } for (unsigned i = 0; i < po->Linedefs.Size(); i++) { - 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); + po->Linedefs[i]->bbox[BOXTOP] -= delta.Y; + po->Linedefs[i]->bbox[BOXBOTTOM] -= delta.Y; + po->Linedefs[i]->bbox[BOXLEFT] -= delta.X; + po->Linedefs[i]->bbox[BOXRIGHT] -= delta.X; } for (unsigned i = 0; i < po->Vertices.Size(); i++) { diff --git a/src/portal.cpp b/src/portal.cpp index 882b4da52..dab6bf009 100644 --- a/src/portal.cpp +++ b/src/portal.cpp @@ -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); - if (box.Right() <= ld->bbox[BOXLEFT] - || 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 + if (!box.inRange(ld) || box.BoxOnLineSide(linkedPortals[i]->mOrigin) != -1) continue; // not touched foundPortals.Push(linkedPortals[i]); } bool foundone = true; @@ -1241,13 +1235,7 @@ bool P_CollectConnectedGroups(int startgroup, const fixedvec3 &position, fixed_t line_t *ld; while ((ld = it.Next())) { - if (box.Right() <= ld->bbox[BOXLEFT] - || box.Left() >= ld->bbox[BOXRIGHT] - || box.Top() <= ld->bbox[BOXBOTTOM] - || box.Bottom() >= ld->bbox[BOXTOP]) - continue; - - if (box.BoxOnLineSide(ld) != -1) + if (!box.inRange(ld) || box.BoxOnLineSide(ld) != -1) continue; if (!(thisgroup & FPortalGroupArray::LOWER)) diff --git a/src/r_defs.h b/src/r_defs.h index 851fc2a7a..7814d2c11 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -1407,7 +1407,7 @@ public: fixed_t Alpha; // <--- translucency (0=invisibile, FRACUNIT=opaque) int args[5]; // <--- hexen-style arguments (expanded to ZDoom's full width) 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; int validcount; // if == validcount, already checked int locknumber; // [Dusk] lock number for special @@ -1672,10 +1672,10 @@ inline void AActor::ClearInterpolation() inline bool FBoundingBox::inRange(const line_t *ld) const { - return Left() < ld->bbox[BOXRIGHT] && - Right() > ld->bbox[BOXLEFT] && - Top() > ld->bbox[BOXBOTTOM] && - Bottom() < ld->bbox[BOXTOP]; + return FIXED2DBL(Left()) < ld->bbox[BOXRIGHT] && + FIXED2DBL(Right()) > ld->bbox[BOXLEFT] && + FIXED2DBL(Top()) > ld->bbox[BOXBOTTOM] && + FIXED2DBL(Bottom()) < ld->bbox[BOXTOP]; } From 8fd76f0c8aa7cf79bf6e0a90b3ef204e5dedb7be Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 31 Mar 2016 09:23:14 +0200 Subject: [PATCH 4/4] - floatified bmaporgx and bmaporgy, allowing to remove the gross overflow prevention hacks present in the blockmap code. --- src/am_map.cpp | 6 ++--- src/p_blockmap.h | 14 ++++++++-- src/p_checkposition.h | 14 ---------- src/p_local.h | 34 +----------------------- src/p_map.cpp | 2 +- src/p_maputl.cpp | 62 ++++++++++++++++++++++--------------------- src/p_setup.cpp | 15 +++-------- src/p_sight.cpp | 3 --- src/p_spec.h | 9 ------- src/p_trace.cpp | 6 ++--- src/po_man.cpp | 17 ++++++------ src/portal.cpp | 8 +++--- src/r_defs.h | 26 ------------------ src/r_plane.cpp | 6 ++--- src/s_advsound.cpp | 4 +-- src/s_sndseq.cpp | 2 +- 16 files changed, 74 insertions(+), 154 deletions(-) diff --git a/src/am_map.cpp b/src/am_map.cpp index 5b6d6a7cc..e71177860 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -1839,8 +1839,7 @@ void AM_drawGrid (int color) // Figure out start of vertical gridlines start = minx - extx; - double bmorgx = FIXED2DBL(bmaporgx); - start = ceil((start - bmorgx) / MAPBLOCKUNITS) * MAPBLOCKUNITS + bmorgx; + start = ceil((start - bmaporgx) / MAPBLOCKUNITS) * MAPBLOCKUNITS + bmaporgx; end = minx + minlen - extx; @@ -1861,8 +1860,7 @@ void AM_drawGrid (int color) // Figure out start of horizontal gridlines start = miny - exty; - double bmorgy = FIXED2DBL(bmaporgy); - start = ceil((start - bmorgy) / MAPBLOCKUNITS) * MAPBLOCKUNITS + bmorgy; + start = ceil((start - bmaporgy) / MAPBLOCKUNITS) * MAPBLOCKUNITS + bmaporgy; end = miny + minlen - exty; // draw horizontal gridlines diff --git a/src/p_blockmap.h b/src/p_blockmap.h index 9cbe2e84b..b2cee1bdd 100644 --- a/src/p_blockmap.h +++ b/src/p_blockmap.h @@ -27,8 +27,18 @@ extern int* blockmaplump; // offsets in blockmap are from here extern int* blockmap; extern int bmapwidth; extern int bmapheight; // in mapblocks -extern fixed_t bmaporgx; -extern fixed_t bmaporgy; // origin of block map +extern double bmaporgx; +extern double bmaporgy; // origin of block map 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 diff --git a/src/p_checkposition.h b/src/p_checkposition.h index b593f0ff0..d0d4a3826 100644 --- a/src/p_checkposition.h +++ b/src/p_checkposition.h @@ -44,20 +44,6 @@ struct FCheckPosition PushTime = 0; 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); - } - }; diff --git a/src/p_local.h b/src/p_local.h index e8a18742e..a9b6c802d 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -34,7 +34,6 @@ class player_t; class AActor; struct FPlayerStart; class PClassActor; -struct fixedvec3; class APlayerPawn; struct line_t; struct sector_t; @@ -61,28 +60,6 @@ struct FTranslatedLineTarget; extern int bmapnegx; 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 MAXMOVE (30.) @@ -242,17 +219,11 @@ extern TArray portalhit; bool P_TestMobjLocation (AActor *mobj); bool P_TestMobjZ (AActor *mobj, bool quick=true, AActor **pOnmobj = NULL); 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); 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 = 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); 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 bool P_HitFloor (AActor *thing); bool P_HitWater (AActor *thing, sector_t *sec, const DVector3 &pos, bool checkabove = false, bool alert = true, bool force = false); -inline bool P_HitWater(AActor *thing, sector_t *sec, const fixedvec3 &pos, bool checkabove = false, bool alert = true, bool force = false) = delete; void P_CheckSplash(AActor *self, double distance); struct FRailParams @@ -389,8 +359,6 @@ bool Check_Sides(AActor *, int, int); // phares // [RH] const secplane_t * P_CheckSlopeWalk(AActor *actor, DVector2 &move); -inline const secplane_t * P_CheckSlopeWalk(AActor *actor, fixed_t &xmove, fixed_t &ymove) = delete; - // // P_SETUP // diff --git a/src/p_map.cpp b/src/p_map.cpp index 71cca8303..c26cfc5e8 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -2947,7 +2947,7 @@ const secplane_t * P_CheckSlopeWalk(AActor *actor, DVector2 &move) if (t < 0) { // Desired location is behind (below) 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 if (actor->flags & MF_NOCLIP) { diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index 6dce13926..58c186593 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -376,8 +376,8 @@ bool AActor::FixMapthingPos() { sector_t *secstart = P_PointInSectorBuggy(_f_X(), _f_Y()); - int blockx = GetSafeBlockX(_f_X() - bmaporgx); - int blocky = GetSafeBlockY(_f_Y() - bmaporgy); + int blockx = GetBlockX(X()); + int blocky = GetBlockY(Y()); bool success = false; if ((unsigned int)blockx < (unsigned int)bmapwidth && @@ -519,13 +519,12 @@ void AActor::LinkToWorld(bool spawningmapthing, sector_t *sector) for (int i = -1; i < (int)check.Size(); i++) { - DVector3 _pos = i==-1? Pos() : PosRelative(check[i]); - fixedvec3 pos = { FLOAT2FIXED(_pos.X), FLOAT2FIXED(_pos.Y),FLOAT2FIXED(_pos.Z) }; + DVector3 pos = i==-1? Pos() : PosRelative(check[i]); - int x1 = GetSafeBlockX(pos.x - _f_radius() - bmaporgx); - int x2 = GetSafeBlockX(pos.x + _f_radius() - bmaporgx); - int y1 = GetSafeBlockY(pos.y - _f_radius() - bmaporgy); - int y2 = GetSafeBlockY(pos.y + _f_radius() - bmaporgy); + int x1 = GetBlockX(pos.X - radius); + int x2 = GetBlockX(pos.X + radius); + int y1 = GetBlockY(pos.Y - radius); + int y2 = GetBlockY(pos.Y + radius); if (x1 >= bmapwidth || x2 < 0 || y1 >= bmapheight || y2 < 0) { // 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) { validcount++; - maxy = GetSafeBlockY(box.Top() - bmaporgy); - miny = GetSafeBlockY(box.Bottom() - bmaporgy); - maxx = GetSafeBlockX(box.Right() - bmaporgx); - minx = GetSafeBlockX(box.Left() - bmaporgx); + maxy = GetBlockY(FIXED2DBL(box.Top())); + miny = GetBlockY(FIXED2DBL(box.Bottom())); + maxx = GetBlockX(FIXED2DBL(box.Right())); + minx = GetBlockX(FIXED2DBL(box.Left())); Reset(); } @@ -945,10 +944,10 @@ FBlockThingsIterator::FBlockThingsIterator(int _minx, int _miny, int _maxx, int void FBlockThingsIterator::init(const FBoundingBox &box) { - maxy = GetSafeBlockY(box.Top() - bmaporgy); - miny = GetSafeBlockY(box.Bottom() - bmaporgy); - maxx = GetSafeBlockX(box.Right() - bmaporgx); - minx = GetSafeBlockX(box.Left() - bmaporgx); + maxy = GetBlockY(FIXED2DBL(box.Top())); + miny = GetBlockY(FIXED2DBL(box.Bottom())); + maxx = GetBlockX(FIXED2DBL(box.Right())); + minx = GetBlockX(FIXED2DBL(box.Left())); ClearHash(); Reset(); } @@ -1026,9 +1025,9 @@ AActor *FBlockThingsIterator::Next(bool centeronly) if (centeronly) { // 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 blockbottom = (cury << MAPBLOCKSHIFT) + bmaporgy; + fixed_t blockbottom = (cury << MAPBLOCKSHIFT) + FLOAT2FIXED(bmaporgy); fixed_t blocktop = blockbottom + MAPBLOCKSIZE; // 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(); 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 - if ( ((y1-bmaporgy)&(MAPBLOCKSIZE-1)) == 0) + if ( ((y1-_f_bmaporgy)&(MAPBLOCKSIZE-1)) == 0) y1 += FRACUNIT; // don't side exactly on a line - _x1 = (long long)x1 - bmaporgx; - _y1 = (long long)y1 - bmaporgy; - x1 -= bmaporgx; - y1 -= bmaporgy; + _x1 = (long long)x1 - _f_bmaporgx; + _y1 = (long long)y1 - _f_bmaporgy; + x1 -= _f_bmaporgx; + y1 -= _f_bmaporgy; xt1 = int(_x1 >> 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 { - _x2 = (long long)x2 - bmaporgx; - _y2 = (long long)y2 - bmaporgy; - x2 -= bmaporgx; - y2 -= bmaporgy; + _x2 = (long long)x2 - _f_bmaporgx; + _y2 = (long long)y2 - _f_bmaporgy; + x2 -= _f_bmaporgx; + y2 -= _f_bmaporgy; xt2 = int(_x2 >> MAPBLOCKSHIFT); yt2 = int(_y2 >> MAPBLOCKSHIFT); } @@ -1758,8 +1760,8 @@ AActor *P_BlockmapSearch (AActor *mo, int distance, AActor *(*check)(AActor*, in int count; AActor *target; - startX = GetSafeBlockX(mo->_f_X()-bmaporgx); - startY = GetSafeBlockY(mo->_f_Y()-bmaporgy); + startX = GetBlockX(mo->X()); + startY = GetBlockY(mo->Y()); validcount++; if (startX >= 0 && startX < bmapwidth && startY >= 0 && startY < bmapheight) diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 91ea7086f..4cb422949 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -171,10 +171,8 @@ int bmapheight; // size in mapblocks int *blockmap; // int for larger maps ([RH] Made int because BOOM does) int *blockmaplump; // offsets in blockmap are from here -fixed_t bmaporgx; // origin of block map -fixed_t bmaporgy; -int bmapnegx; // min negs of block map before wrapping -int bmapnegy; +double bmaporgx; // origin of block map +double bmaporgy; FBlockNode** blocklinks; // for thing chains @@ -3076,15 +3074,10 @@ void P_LoadBlockMap (MapData * map) } - bmaporgx = blockmaplump[0] << FRACBITS; - bmaporgy = blockmaplump[1] << FRACBITS; + bmaporgx = blockmaplump[0]; + bmaporgy = blockmaplump[1]; bmapwidth = blockmaplump[2]; 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 count = bmapwidth*bmapheight; diff --git a/src/p_sight.cpp b/src/p_sight.cpp index c29b4e6ac..d6048f678 100644 --- a/src/p_sight.cpp +++ b/src/p_sight.cpp @@ -632,9 +632,6 @@ bool SightCheck::P_SightPathTraverse () 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; y1 -= bmaporgy; xt1 = x1 / MAPBLOCKUNITS; diff --git a/src/p_spec.h b/src/p_spec.h index bb7f1c64f..236c28790 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -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). 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); 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); diff --git a/src/p_trace.cpp b/src/p_trace.cpp index 543eaf301..a6b46f32d 100644 --- a/src/p_trace.cpp +++ b/src/p_trace.cpp @@ -165,8 +165,8 @@ void FTraceInfo::EnterSectorPortal(int position, double frac, sector_t *entersec if (aimdir != -1 && aimdir != position) return; AActor *portal = entersec->SkyBoxes[position]; - if (aimdir == sector_t::ceiling && FLOAT2FIXED(portal->specialf1) < limitz) return; - else if (aimdir == sector_t::floor && FLOAT2FIXED(portal->specialf1) > limitz) return; + if (aimdir == sector_t::ceiling && portal->specialf1 < limitz) return; + else if (aimdir == sector_t::floor && portal->specialf1 > limitz) return; FTraceInfo newtrace; FTraceResults results; @@ -785,7 +785,7 @@ bool FTraceInfo::TraceTraverse (int ptflags) } // 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; } diff --git a/src/po_man.cpp b/src/po_man.cpp index 3a5ac69ad..04798dc49 100644 --- a/src/po_man.cpp +++ b/src/po_man.cpp @@ -32,6 +32,7 @@ #include "p_blockmap.h" #include "p_maputl.h" #include "r_utility.h" +#include "p_blockmap.h" // MACROS ------------------------------------------------------------------ @@ -1095,10 +1096,10 @@ bool FPolyObj::CheckMobjBlocking (side_t *sd) ld = sd->linedef; - top = int((ld->bbox[BOXTOP] - FIXED2DBL(bmaporgy)) / 128.); - bottom = int((ld->bbox[BOXBOTTOM] - FIXED2DBL(bmaporgy)) / 128.); - left = int((ld->bbox[BOXLEFT] - FIXED2DBL(bmaporgx)) / 128.); - right = int((ld->bbox[BOXRIGHT] - FIXED2DBL(bmaporgx)) / 128.); + top = GetBlockY(ld->bbox[BOXTOP]); + bottom = GetBlockY(ld->bbox[BOXBOTTOM]); + left = GetBlockX(ld->bbox[BOXLEFT]); + right = GetBlockX(ld->bbox[BOXRIGHT]); blocked = false; checker.Clear(); @@ -1219,10 +1220,10 @@ void FPolyObj::LinkPolyobj () vt = Sidedefs[i]->linedef->v2; Bounds.AddToBox(vt->fixX(), vt->fixY()); } - bbox[BOXRIGHT] = GetSafeBlockX(Bounds.Right() - bmaporgx); - bbox[BOXLEFT] = GetSafeBlockX(Bounds.Left() - bmaporgx); - bbox[BOXTOP] = GetSafeBlockY(Bounds.Top() - bmaporgy); - bbox[BOXBOTTOM] = GetSafeBlockY(Bounds.Bottom() - bmaporgy); + bbox[BOXRIGHT] = GetBlockX(FIXED2DBL(Bounds.Right())); + bbox[BOXLEFT] = GetBlockX(FIXED2DBL(Bounds.Left())); + bbox[BOXTOP] = GetBlockY(FIXED2DBL(Bounds.Top())); + bbox[BOXBOTTOM] = GetBlockY(FIXED2DBL(Bounds.Bottom())); // add the polyobj to each blockmap section for(int j = bbox[BOXBOTTOM]*bmapwidth; j <= bbox[BOXTOP]*bmapwidth; j += bmapwidth) diff --git a/src/portal.cpp b/src/portal.cpp index dab6bf009..c56a79098 100644 --- a/src/portal.cpp +++ b/src/portal.cpp @@ -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. if (dx < 128 * FRACUNIT && dy < 128 * FRACUNIT) { - fixed_t blockx = GetSafeBlockX(actx - bmaporgx); - fixed_t blocky = GetSafeBlockY(acty - bmaporgy); + int blockx = GetBlockX(FIXED2DBL(actx)); + int blocky = GetBlockY(FIXED2DBL(acty)); 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 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(); - fixed_t fp = -sectors[i].ceilingplane.fixD(); + double cp = -sectors[i].ceilingplane.fD(); + double fp = -sectors[i].ceilingplane.fD(); if (cp < fp || fz == fp) { sectors[i].SkyBoxes[sector_t::ceiling] = NULL; diff --git a/src/r_defs.h b/src/r_defs.h index 7814d2c11..ceb849c01 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -315,32 +315,6 @@ public: 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 { return FIXED2DBL(a); diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 9423ca4ee..2bf47154a 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -91,7 +91,7 @@ visplane_t *ceilingplane; // Empirically verified to be fairly uniform: #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. // 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 // 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. - plane.set(0, 0, height.fixC(), 0); + plane.set(0., 0., height.fC(), 0.); isskybox = skybox != NULL && !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; 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); if (fixedlightlev >= 0) diff --git a/src/s_advsound.cpp b/src/s_advsound.cpp index 63d4026d3..7995f2655 100644 --- a/src/s_advsound.cpp +++ b/src/s_advsound.cpp @@ -162,8 +162,8 @@ enum SICommands struct FBloodSFX { DWORD RelVol; // volume, 0-255 - fixed_t Pitch; // pitch change - fixed_t PitchRange; // range of random pitch + int Pitch; // pitch change + int PitchRange; // range of random pitch DWORD Format; // format of audio 1=11025 5=22050 SDWORD LoopStart; // loop position (-1 means no looping) char RawName[9]; // name of RAW resource diff --git a/src/s_sndseq.cpp b/src/s_sndseq.cpp index 1864b3da0..06d5883b6 100644 --- a/src/s_sndseq.cpp +++ b/src/s_sndseq.cpp @@ -540,7 +540,7 @@ void S_ParseSndSeq (int levellump) int delaybase; float volumebase; int curseq = -1; - fixed_t val; + int val; // First free the old SNDSEQ data. This allows us to reload this for each level // and specify a level specific SNDSEQ lump!