From fb8e03d5eb3c2bcf3606c87fc1e4a62168dcc40b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 25 Mar 2016 18:19:54 +0100 Subject: [PATCH] - floatified FLineOpening. - some smaller fixes. --- src/actor.h | 13 +--- src/am_map.cpp | 2 +- src/b_func.cpp | 2 +- src/c_cmds.cpp | 2 +- src/g_shared/a_fastprojectile.cpp | 2 +- src/g_strife/a_sentinel.cpp | 2 +- src/p_3dfloors.cpp | 29 ++++----- src/p_3dfloors.h | 2 +- src/p_3dmidtex.cpp | 26 ++++++-- src/p_map.cpp | 101 +++++++++++++++--------------- src/p_maputl.cpp | 45 +++++++------ src/p_maputl.h | 33 +++++++--- src/p_spec.h | 2 +- src/p_switch.cpp | 6 +- src/p_things.cpp | 2 +- src/p_writemap.cpp | 2 +- src/po_man.cpp | 8 +-- src/posix/sdl/sdlvideo.cpp | 2 +- src/r_defs.h | 10 +++ src/r_plane.cpp | 2 - src/s_sound.cpp | 36 +++++------ src/thingdef/thingdef_codeptr.cpp | 4 +- 22 files changed, 182 insertions(+), 151 deletions(-) diff --git a/src/actor.h b/src/actor.h index aa5e48429..07e1f94a5 100644 --- a/src/actor.h +++ b/src/actor.h @@ -1415,17 +1415,10 @@ public: DVector3 PosRelative(sector_t *sec) const; DVector3 PosRelative(line_t *line) const; - fixed_t SoundX() const + FVector3 SoundPos() const { - return _f_X(); - } - fixed_t SoundY() const - { - return _f_Y(); - } - fixed_t SoundZ() const - { - return _f_Z(); + // fixme: This still needs portal handling + return{ float(X()), float(Y()), float(Z()) }; } DVector3 InterpolatedPosition(double ticFrac) const { diff --git a/src/am_map.cpp b/src/am_map.cpp index 48fbe1817..9bdf61c2f 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -648,7 +648,7 @@ CUSTOM_CVAR (Int, am_cheat, 0, 0) #define AM_NUMMARKPOINTS 10 -// player _f_radius() for automap checking +// player radius for automap checking #define PLAYERRADIUS 16*MAPUNIT // how much the automap moves window per tic in frame-buffer coordinates diff --git a/src/b_func.cpp b/src/b_func.cpp index e088f70ac..803643cea 100644 --- a/src/b_func.cpp +++ b/src/b_func.cpp @@ -458,7 +458,7 @@ void FCajunMaster::SetBodyAt (const DVector3 &pos, int hostnum) // //Returns NULL if shouldn't fire //else an angle (in degrees) are given -//This function assumes actor->player->_f_angle() +//This function assumes actor->player->angle //has been set an is the main aiming angle. diff --git a/src/c_cmds.cpp b/src/c_cmds.cpp index 44c37336f..2ebaca1f6 100644 --- a/src/c_cmds.cpp +++ b/src/c_cmds.cpp @@ -903,7 +903,7 @@ CCMD(info) PrintMiscActorInfo(t.linetarget); } else Printf("No target found. Info cannot find actors that have " - "the NOBLOCKMAP flag or have height/_f_radius() of 0.\n"); + "the NOBLOCKMAP flag or have height/radius of 0.\n"); } typedef bool (*ActorTypeChecker) (AActor *); diff --git a/src/g_shared/a_fastprojectile.cpp b/src/g_shared/a_fastprojectile.cpp index c82e0874b..55489cdcf 100644 --- a/src/g_shared/a_fastprojectile.cpp +++ b/src/g_shared/a_fastprojectile.cpp @@ -73,7 +73,7 @@ void AFastProjectile::Tick () if (tm.ceilingline && tm.ceilingline->backsector && tm.ceilingline->backsector->GetTexture(sector_t::ceiling) == skyflatnum && - Z() >= tm.ceilingline->backsector->ceilingplane.ZatPointF(_f_PosRelative(tm.ceilingline))) + Z() >= tm.ceilingline->backsector->ceilingplane.ZatPoint(PosRelative(tm.ceilingline))) { // Hack to prevent missiles exploding against the sky. // Does not handle sky floors. diff --git a/src/g_strife/a_sentinel.cpp b/src/g_strife/a_sentinel.cpp index 977098df4..fa99c827f 100644 --- a/src/g_strife/a_sentinel.cpp +++ b/src/g_strife/a_sentinel.cpp @@ -68,7 +68,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SentinelAttack) P_CheckMissileSpawn (trail, self->radius); } } - missile->_f_AddZ(missile->_f_velz() >> 2); + missile->AddZ(missile->Vel.Z / 4); } return 0; } diff --git a/src/p_3dfloors.cpp b/src/p_3dfloors.cpp index db98330ee..bb74986cc 100644 --- a/src/p_3dfloors.cpp +++ b/src/p_3dfloors.cpp @@ -753,23 +753,24 @@ lightlist_t * P_GetPlaneLight(sector_t * sector, secplane_t * plane, bool unders //========================================================================== void P_LineOpening_XFloors (FLineOpening &open, AActor * thing, const line_t *linedef, - fixed_t x, fixed_t y, fixed_t refx, fixed_t refy, bool restrict) + double x, double y, bool restrict) { if(thing) { - fixed_t thingbot, thingtop; + double thingbot, thingtop; + + thingbot = thing->Z(); + thingtop = thing->Top(); - thingbot = thing->_f_Z(); - thingtop = thingbot + (thing->_f_height()==0? 1:thing->_f_height()); extsector_t::xfloor *xf[2] = {&linedef->frontsector->e->XFloor, &linedef->backsector->e->XFloor}; // Check for 3D-floors in the sector (mostly identical to what Legacy does here) if(xf[0]->ffloors.Size() || xf[1]->ffloors.Size()) { - fixed_t lowestceiling = open.top; - fixed_t highestfloor = open.bottom; - fixed_t lowestfloor[2] = { + double lowestceiling = open.top; + double highestfloor = open.bottom; + double lowestfloor[2] = { linedef->frontsector->floorplane.ZatPoint(x, y), linedef->backsector->floorplane.ZatPoint(x, y) }; FTextureID highestfloorpic; @@ -790,20 +791,20 @@ void P_LineOpening_XFloors (FLineOpening &open, AActor * thing, const line_t *li if (!(rover->flags & FF_EXISTS)) continue; if (!(rover->flags & FF_SOLID)) continue; - fixed_t ff_bottom=rover->bottom.plane->ZatPoint(x, y); - fixed_t ff_top=rover->top.plane->ZatPoint(x, y); + double ff_bottom=rover->bottom.plane->ZatPoint(x, y); + double ff_top=rover->top.plane->ZatPoint(x, y); - fixed_t delta1 = abs(thingbot - ((ff_bottom + ff_top) / 2)); - fixed_t delta2 = abs(thingtop - ((ff_bottom + ff_top) / 2)); + double delta1 = fabs(thingbot - ((ff_bottom + ff_top) / 2)); + double delta2 = fabs(thingtop - ((ff_bottom + ff_top) / 2)); - if(ff_bottom < lowestceiling && delta1 >= delta2) + if(ff_bottom < lowestceiling && delta1 > delta2) { lowestceiling = ff_bottom; lowestceilingpic = *rover->bottom.texture; lowestceilingsec = j == 0 ? linedef->frontsector : linedef->backsector; } - if(ff_top > highestfloor && delta1 < delta2 && (!restrict || thing->_f_Z() >= ff_top)) + if(ff_top > highestfloor && delta1 < delta2 && (!restrict || thing->Z() >= ff_top)) { highestfloor = ff_top; highestfloorpic = *rover->top.texture; @@ -811,7 +812,7 @@ void P_LineOpening_XFloors (FLineOpening &open, AActor * thing, const line_t *li highestfloorsec = j == 0 ? linedef->frontsector : linedef->backsector; highestfloorplanes[j] = rover->top.plane; } - if(ff_top > lowestfloor[j] && ff_top <= thing->_f_Z() + thing->_f_MaxStepHeight()) lowestfloor[j] = ff_top; + if(ff_top > lowestfloor[j] && ff_top <= thing->Z() + thing->MaxStepHeight) lowestfloor[j] = ff_top; } } diff --git a/src/p_3dfloors.h b/src/p_3dfloors.h index baf7dd130..3ec2ab202 100644 --- a/src/p_3dfloors.h +++ b/src/p_3dfloors.h @@ -139,7 +139,7 @@ void P_Spawn3DFloors( void ); struct FLineOpening; void P_LineOpening_XFloors (FLineOpening &open, AActor * thing, const line_t *linedef, - fixed_t x, fixed_t y, fixed_t refx, fixed_t refy, bool restrict); + double x, double y, bool restrict); secplane_t P_FindFloorPlane(sector_t * sector, fixed_t x, fixed_t y, fixed_t z); int P_Find3DFloor(sector_t * sec, fixed_t x, fixed_t y, fixed_t z, bool above, bool floor, fixed_t &cmpz); diff --git a/src/p_3dmidtex.cpp b/src/p_3dmidtex.cpp index b86e46e2d..8b1e5aabb 100644 --- a/src/p_3dmidtex.cpp +++ b/src/p_3dmidtex.cpp @@ -36,6 +36,7 @@ #include "templates.h" +#include "p_3dmidtex.h" #include "p_local.h" #include "p_terrain.h" #include "p_maputl.h" @@ -256,6 +257,19 @@ bool P_GetMidTexturePosition(const line_t *line, int sideno, fixed_t *ptextop, f } +bool P_GetMidTexturePosition(const line_t *line, int sideno, double *ptextop, double *ptexbot) +{ + fixed_t t, b; + if (P_GetMidTexturePosition(line, sideno, &t, &b)) + { + *ptextop = FIXED2DBL(t); + *ptexbot = FIXED2DBL(b); + return true; + } + return false; +} + + //============================================================================ // // P_LineOpening_3dMidtex @@ -273,12 +287,12 @@ bool P_LineOpening_3dMidtex(AActor *thing, const line_t *linedef, FLineOpening & return false; } - fixed_t tt, tb; + double tt, tb; open.abovemidtex = false; if (P_GetMidTexturePosition(linedef, 0, &tt, &tb)) { - if (thing->_f_Z() + (thing->_f_height()/2) < (tt + tb)/2) + if (thing->Center() < (tt + tb)/2) { if (tb < open.top) { @@ -288,18 +302,18 @@ bool P_LineOpening_3dMidtex(AActor *thing, const line_t *linedef, FLineOpening & } else { - if (tt > open.bottom && (!restrict || thing->_f_Z() >= tt)) + if (tt > open.bottom && (!restrict || thing->Z() >= tt)) { open.bottom = tt; open.abovemidtex = true; open.floorpic = linedef->sidedef[0]->GetTexture(side_t::mid); open.floorterrain = TerrainTypes[open.floorpic]; - open.frontfloorplane.SetAtHeight(tt, sector_t::floor); - open.backfloorplane.SetAtHeight(tt, sector_t::floor); + open.frontfloorplane.SetAtHeight(FLOAT2FIXED(tt), sector_t::floor); + open.backfloorplane.SetAtHeight(FLOAT2FIXED(tt), sector_t::floor); } // returns true if it touches the midtexture - return (abs(thing->_f_Z() - tt) <= thing->_f_MaxStepHeight()); + return (fabs(thing->Z() - tt) <= thing->MaxStepHeight); } } return false; diff --git a/src/p_map.cpp b/src/p_map.cpp index c261d1e4c..b5857dad6 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -242,36 +242,36 @@ static bool PIT_FindFloorCeiling(FMultiBlockLinesIterator &mit, FMultiBlockLines // adjust floor / ceiling heights if (!(flags & FFCF_NOCEILING)) { - if (open.top < tmf._f_ceilingz()) + if (open.top < tmf.ceilingz) { tmf.ceilingz = open.top; if (open.topsec != NULL) tmf.ceilingsector = open.topsec; - if (ffcf_verbose) Printf(" Adjust ceilingz to %f\n", FIXED2FLOAT(open.top)); + if (ffcf_verbose) Printf(" Adjust ceilingz to %f\n", open.top); mit.StopUp(); } } if (!(flags & FFCF_NOFLOOR)) { - if (open.bottom > tmf._f_floorz()) + if (open.bottom > tmf.floorz) { - tmf.floorz = FIXED2DBL(open.bottom); + tmf.floorz = open.bottom; if (open.bottomsec != NULL) tmf.floorsector = open.bottomsec; tmf.touchmidtex = open.touchmidtex; tmf.abovemidtex = open.abovemidtex; - if (ffcf_verbose) Printf(" Adjust floorz to %f\n", FIXED2FLOAT(open.bottom)); + if (ffcf_verbose) Printf(" Adjust floorz to %f\n", open.bottom); if (tmf.floorz > tmf.dropoffz + tmf.thing->MaxDropOffHeight) mit.StopDown(); } - else if (open.bottom == tmf._f_floorz()) + else if (open.bottom == tmf.floorz) { tmf.touchmidtex |= open.touchmidtex; tmf.abovemidtex |= open.abovemidtex; } - if (open.lowfloor < tmf._f_dropoffz() && open.lowfloor > FIXED_MIN) + if (open.lowfloor < tmf.dropoffz && open.lowfloor > LINEOPEN_MIN) { - tmf.dropoffz = FIXED2DBL(open.lowfloor); - if (ffcf_verbose) Printf(" Adjust dropoffz to %f\n", FIXED2FLOAT(open.bottom)); + tmf.dropoffz = open.lowfloor; + if (ffcf_verbose) Printf(" Adjust dropoffz to %f\n", open.bottom); if (tmf.floorz > tmf.dropoffz + tmf.thing->MaxDropOffHeight) mit.StopDown(); } } @@ -915,9 +915,9 @@ bool PIT_CheckLine(FMultiBlockLinesIterator &mit, FMultiBlockLinesIterator::Chec // If the floor planes on both sides match we should recalculate open.bottom at the actual position we are checking // This is to avoid bumpy movement when crossing a linedef with the same slope on both sides. - if (open.frontfloorplane == open.backfloorplane && open.bottom > FIXED_MIN) + if (open.frontfloorplane == open.backfloorplane && open.bottom > LINEOPEN_MIN) { - open.bottom = open.frontfloorplane.ZatPoint(cres.position.x, cres.position.y); + open.bottom = open.frontfloorplane._f_ZatPointF(cres.position.x, cres.position.y); } if (rail && @@ -929,17 +929,17 @@ bool PIT_CheckLine(FMultiBlockLinesIterator &mit, FMultiBlockLinesIterator::Chec // from either side. How long until somebody reports this as a bug and I'm // forced to say, "It's not a bug. It's a feature?" Ugh. (!(level.flags2 & LEVEL2_RAILINGHACK) || - open.bottom == tm.thing->Sector->floorplane.ZatPoint(ref.x, ref.y))) + open.bottom == tm.thing->Sector->floorplane._f_ZatPointF(ref.x, ref.y))) { - open.bottom += 32 * FRACUNIT; + open.bottom += 32; } // adjust floor / ceiling heights if (!(cres.portalflags & FFCF_NOCEILING)) { - if (open.top < tm._f_ceilingz()) + if (open.top < tm.ceilingz) { - tm.ceilingz = FIXED2DBL(open.top); + tm.ceilingz = open.top; tm.ceilingsector = open.topsec; tm.ceilingpic = open.ceilingpic; tm.ceilingline = ld; @@ -949,9 +949,9 @@ bool PIT_CheckLine(FMultiBlockLinesIterator &mit, FMultiBlockLinesIterator::Chec if (!(cres.portalflags & FFCF_NOFLOOR)) { - if (open.bottom > tm._f_floorz()) + if (open.bottom > tm.floorz) { - tm.floorz = FIXED2DBL(open.bottom); + tm.floorz = open.bottom; tm.floorsector = open.bottomsec; tm.floorpic = open.floorpic; tm.floorterrain = open.floorterrain; @@ -959,15 +959,15 @@ bool PIT_CheckLine(FMultiBlockLinesIterator &mit, FMultiBlockLinesIterator::Chec tm.abovemidtex = open.abovemidtex; tm.thing->BlockingLine = ld; } - else if (open.bottom == tm._f_floorz()) + else if (open.bottom == tm.floorz) { tm.touchmidtex |= open.touchmidtex; tm.abovemidtex |= open.abovemidtex; } - if (open.lowfloor < tm._f_dropoffz()) + if (open.lowfloor < tm.dropoffz) { - tm.dropoffz = FIXED2FLOAT(open.lowfloor); + tm.dropoffz = open.lowfloor; } } @@ -1022,15 +1022,16 @@ static bool PIT_CheckPortal(FMultiBlockLinesIterator &mit, FMultiBlockLinesItera return false; line_t *lp = cres.line->getPortalDestination(); - fixed_t zofs = 0; + fixed_t _zofs = 0; P_TranslatePortalXY(cres.line, cres.position.x, cres.position.y); - P_TranslatePortalZ(cres.line, zofs); + P_TranslatePortalZ(cres.line, _zofs); + double zofs = FIXED2DBL(_zofs); // fudge a bit with the portal line so that this gets included in the checks that normally only get run on two-sided lines sector_t *sec = lp->backsector; if (lp->backsector == NULL) lp->backsector = lp->frontsector; - tm.thing->_f_AddZ(zofs); + tm.thing->AddZ(zofs); FBoundingBox pbox(cres.position.x, cres.position.y, tm.thing->_f_radius()); FBlockLinesIterator it(pbox); @@ -1058,9 +1059,9 @@ static bool PIT_CheckPortal(FMultiBlockLinesIterator &mit, FMultiBlockLinesItera P_LineOpening(open, tm.thing, ld, ref.x, ref.y, cres.position.x, cres.position.y, 0); // adjust floor / ceiling heights - if (open.top - zofs < tm._f_ceilingz()) + if (open.top - zofs < tm.ceilingz) { - tm.ceilingz = FIXED2FLOAT(open.top - zofs); + tm.ceilingz = open.top - zofs; tm.ceilingpic = open.ceilingpic; /* tm.ceilingsector = open.topsec; @@ -1070,9 +1071,9 @@ static bool PIT_CheckPortal(FMultiBlockLinesIterator &mit, FMultiBlockLinesItera ret = true; } - if (open.bottom - zofs > tm._f_floorz()) + if (open.bottom - zofs > tm.floorz) { - tm.floorz = FIXED2DBL(open.bottom - zofs); + tm.floorz = open.bottom - zofs; tm.floorpic = open.floorpic; tm.floorterrain = open.floorterrain; /* @@ -1084,10 +1085,10 @@ static bool PIT_CheckPortal(FMultiBlockLinesIterator &mit, FMultiBlockLinesItera ret = true; } - if (open.lowfloor - zofs < tm._f_dropoffz()) - tm.dropoffz = FIXED2FLOAT(open.lowfloor - zofs); + if (open.lowfloor - zofs < tm.dropoffz) + tm.dropoffz = open.lowfloor - zofs; } - tm.thing->_f_AddZ(-zofs); + tm.thing->AddZ(-zofs); lp->backsector = sec; return ret; @@ -2829,22 +2830,22 @@ void FSlide::SlideTraverse(fixed_t startx, fixed_t starty, fixed_t endx, fixed_t // set openrange, opentop, openbottom P_LineOpening(open, slidemo, li, it.InterceptPoint(in)); - if (open.range < slidemo->_f_height()) + if (open.range < slidemo->Height) goto isblocking; // doesn't fit - if (open.top - slidemo->_f_Z() < slidemo->_f_height()) + if (open.top < slidemo->Top()) goto isblocking; // mobj is too high - if (open.bottom - slidemo->_f_Z() > slidemo->MaxStepHeight) + if (open.bottom - slidemo->Z() > slidemo->MaxStepHeight) { goto isblocking; // too big a step up } - else if (slidemo->_f_Z() < open.bottom) + else if (slidemo->Z() < open.bottom) { // [RH] Check to make sure there's nothing in the way for the step up - fixed_t savedz = slidemo->_f_Z(); - slidemo->_f_SetZ(open.bottom); + double savedz = slidemo->Z(); + slidemo->SetZ(open.bottom); bool good = P_TestMobjZ(slidemo); - slidemo->_f_SetZ(savedz); + slidemo->SetZ(savedz); if (!good) { goto isblocking; @@ -3184,13 +3185,13 @@ bool FSlide::BounceTraverse(fixed_t startx, fixed_t starty, fixed_t endx, fixed_ P_LineOpening(open, slidemo, li, it.InterceptPoint(in)); // set openrange, opentop, openbottom - if (open.range < slidemo->_f_height()) + if (open.range < slidemo->Height) goto bounceblocking; // doesn't fit - if (open.top - slidemo->_f_Z() < slidemo->_f_height()) + if (open.top < slidemo->Top()) goto bounceblocking; // mobj is too high - if (open.bottom > slidemo->_f_Z()) + if (open.bottom > slidemo->Z()) goto bounceblocking; // mobj is too low continue; // this line doesn't block movement @@ -3809,20 +3810,20 @@ struct aim_t // The following code assumes that portals on the front of the line have already been processed. - if (open.range <= 0 || open.bottom >= open.top) + if (open.range <= 0 || open.bottom >= open.top) return; dist = FixedMul(attackrange, in->frac); - if (open.bottom != FIXED_MIN) + if (open.bottom != LINEOPEN_MIN) { - pitch = -(int)R_PointToAngle2(0, shootz, dist, open.bottom); + pitch = -(int)R_PointToAngle2(0, shootz, dist, FLOAT2FIXED(open.bottom)); if (pitch < bottompitch) bottompitch = pitch; } - if (open.top != FIXED_MAX) + if (open.top != LINEOPEN_MAX) { - pitch = -(int)R_PointToAngle2(0, shootz, dist, open.top); + pitch = -(int)R_PointToAngle2(0, shootz, dist, FLOAT2FIXED(open.top)); if (pitch > toppitch) toppitch = pitch; } @@ -3840,11 +3841,11 @@ struct aim_t sector_t *exitsec = frontflag ? li->backsector : li->frontsector; lastsector = entersec; // check portal in backsector when aiming up/downward is possible, the line doesn't have portals on both sides and there's actually a portal in the backsector - if ((planestocheck & aim_up) && toppitch < 0 && open.top != FIXED_MAX && !entersec->PortalBlocksMovement(sector_t::ceiling)) + if ((planestocheck & aim_up) && toppitch < 0 && open.top != LINEOPEN_MAX && !entersec->PortalBlocksMovement(sector_t::ceiling)) { EnterSectorPortal(sector_t::ceiling, in->frac, entersec, toppitch, MIN(0, bottompitch)); } - if ((planestocheck & aim_down) && bottompitch > 0 && open.bottom != FIXED_MIN && !entersec->PortalBlocksMovement(sector_t::floor)) + if ((planestocheck & aim_down) && bottompitch > 0 && open.bottom != LINEOPEN_MIN && !entersec->PortalBlocksMovement(sector_t::floor)) { EnterSectorPortal(sector_t::floor, in->frac, entersec, MAX(0, toppitch), bottompitch); } @@ -5067,8 +5068,8 @@ bool P_NoWayTraverse(AActor *usething, fixed_t startx, fixed_t starty, fixed_t e if (ld->flags&(ML_BLOCKING | ML_BLOCKEVERYTHING | ML_BLOCK_PLAYERS)) return true; P_LineOpening(open, NULL, ld, it.InterceptPoint(in)); if (open.range <= 0 || - open.bottom > usething->_f_Z() + usething->_f_MaxStepHeight() || - open.top < usething->_f_Top()) return true; + open.bottom > usething->Z() + usething->MaxStepHeight || + open.top < usething->Top()) return true; } return false; } @@ -6345,7 +6346,7 @@ void P_CreateSecNodeList(AActor *thing, fixed_t x, fixed_t y) sector_list = P_AddSecnode(ld->frontsector, thing, sector_list); // Don't assume all lines are 2-sided, since some Things - // like MT_TFOG are allowed regardless of whether their _f_radius() takes + // like MT_TFOG are allowed regardless of whether their radius takes // them beyond an impassable linedef. // killough 3/27/98, 4/4/98: diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index 4a3687083..91b45a373 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -144,13 +144,12 @@ fixed_t P_InterceptVector (const fdivline_t *v2, const fdivline_t *v1) // //========================================================================== -void P_LineOpening (FLineOpening &open, AActor *actor, const line_t *linedef, - fixed_t x, fixed_t y, fixed_t refx, fixed_t refy, int flags) +void P_LineOpening (FLineOpening &open, AActor *actor, const line_t *linedef, const DVector2 &pos, const DVector2 *ref, int flags) { if (!(flags & FFCF_ONLY3DFLOORS)) { sector_t *front, *back; - fixed_t fc = 0, ff = 0, bc = 0, bf = 0; + double fc = 0, ff = 0, bc = 0, bf = 0; if (linedef->backsector == NULL) { @@ -164,16 +163,16 @@ void P_LineOpening (FLineOpening &open, AActor *actor, const line_t *linedef, if (!(flags & FFCF_NOPORTALS) && (linedef->flags & ML_PORTALCONNECT)) { - if (!linedef->frontsector->PortalBlocksMovement(sector_t::ceiling)) fc = FIXED_MAX; - if (!linedef->backsector->PortalBlocksMovement(sector_t::ceiling)) bc = FIXED_MAX; - if (!linedef->frontsector->PortalBlocksMovement(sector_t::floor)) ff = FIXED_MIN; - if (!linedef->backsector->PortalBlocksMovement(sector_t::floor)) bf = FIXED_MIN; + if (!linedef->frontsector->PortalBlocksMovement(sector_t::ceiling)) fc = LINEOPEN_MAX; + if (!linedef->backsector->PortalBlocksMovement(sector_t::ceiling)) bc = LINEOPEN_MAX; + if (!linedef->frontsector->PortalBlocksMovement(sector_t::floor)) ff = LINEOPEN_MIN; + if (!linedef->backsector->PortalBlocksMovement(sector_t::floor)) bf = LINEOPEN_MIN; } - if (fc == 0) fc = front->ceilingplane.ZatPoint(x, y); - if (bc == 0) bc = back->ceilingplane.ZatPoint(x, y); - if (ff == 0) ff = front->floorplane.ZatPoint(x, y); - if (bf == 0) bf = back->floorplane.ZatPoint(x, y); + if (fc == 0) fc = front->ceilingplane.ZatPoint(pos); + if (bc == 0) bc = back->ceilingplane.ZatPoint(pos); + if (ff == 0) ff = front->floorplane.ZatPoint(pos); + if (bf == 0) bf = back->floorplane.ZatPoint(pos); /*Printf ("]]]]]] %d %d\n", ff, bf);*/ @@ -189,7 +188,7 @@ void P_LineOpening (FLineOpening &open, AActor *actor, const line_t *linedef, // that imprecisions in the plane equation mean there is a // good chance that even if a slope and non-slope look like // they line up, they won't be perfectly aligned. - if (ff == FIXED_MIN || bf == FIXED_MIN || (refx == FIXED_MIN || abs (ff-bf) > 256)) + if (ff == -FLT_MIN || bf == -FLT_MIN || ref == NULL || fabs (ff-bf) > 1./256) { usefront = (ff > bf); } @@ -200,7 +199,7 @@ void P_LineOpening (FLineOpening &open, AActor *actor, const line_t *linedef, else if ((back->floorplane.a | front->floorplane.b) == 0) usefront = false; else - usefront = !P_PointOnLineSide (refx, refy, linedef); + usefront = !P_PointOnLineSide (*ref, linedef); } if (usefront) @@ -209,12 +208,12 @@ void P_LineOpening (FLineOpening &open, AActor *actor, const line_t *linedef, open.bottomsec = front; open.floorpic = front->GetTexture(sector_t::floor); open.floorterrain = front->GetTerrain(sector_t::floor); - if (bf != FIXED_MIN) open.lowfloor = bf; + if (bf != -FLT_MIN) open.lowfloor = bf; else if (!(flags & FFCF_NODROPOFF)) { // We must check through the portal for the actual dropoff. // If there's no lines in the lower sections we'd never get a usable value otherwise. - open.lowfloor = back->NextLowestFloorAt(refx, refy, FLOAT2FIXED(back->SkyBoxes[sector_t::floor]->specialf1)-1); + open.lowfloor = back->NextLowestFloorAt(pos.X, pos.Y, back->SkyBoxes[sector_t::floor]->specialf1-1); } } else @@ -223,12 +222,12 @@ void P_LineOpening (FLineOpening &open, AActor *actor, const line_t *linedef, open.bottomsec = back; open.floorpic = back->GetTexture(sector_t::floor); open.floorterrain = back->GetTerrain(sector_t::floor); - if (ff != FIXED_MIN) open.lowfloor = ff; + if (ff != -FLT_MIN) open.lowfloor = ff; else if (!(flags & FFCF_NODROPOFF)) { // We must check through the portal for the actual dropoff. // If there's no lines in the lower sections we'd never get a usable value otherwise. - open.lowfloor = front->NextLowestFloorAt(refx, refy, FLOAT2FIXED(front->SkyBoxes[sector_t::floor]->specialf1) - 1); + open.lowfloor = front->NextLowestFloorAt(pos.X, pos.Y, front->SkyBoxes[sector_t::floor]->specialf1 - 1); } } open.frontfloorplane = front->floorplane; @@ -238,12 +237,12 @@ void P_LineOpening (FLineOpening &open, AActor *actor, const line_t *linedef, { // Dummy stuff to have some sort of opening for the 3D checks to modify open.topsec = NULL; open.ceilingpic.SetInvalid(); - open.top = FIXED_MAX; + open.top = LINEOPEN_MAX; open.bottomsec = NULL; open.floorpic.SetInvalid(); open.floorterrain = -1; - open.bottom = FIXED_MIN; - open.lowfloor = FIXED_MAX; + open.bottom = LINEOPEN_MIN; + open.lowfloor = LINEOPEN_MAX; open.frontfloorplane.SetAtHeight(FIXED_MIN, sector_t::floor); open.backfloorplane.SetAtHeight(FIXED_MIN, sector_t::floor); } @@ -251,7 +250,7 @@ void P_LineOpening (FLineOpening &open, AActor *actor, const line_t *linedef, // Check 3D floors if (actor != NULL) { - P_LineOpening_XFloors(open, actor, linedef, x, y, refx, refy, !!(flags & FFCF_3DRESTRICT)); + P_LineOpening_XFloors(open, actor, linedef, pos.X, pos.Y, !!(flags & FFCF_3DRESTRICT)); } if (actor != NULL && linedef->frontsector != NULL && linedef->backsector != NULL && @@ -265,7 +264,7 @@ void P_LineOpening (FLineOpening &open, AActor *actor, const line_t *linedef, } // avoid overflows in the opening. - open.range = (fixed_t)MIN((SQWORD)open.top - open.bottom, FIXED_MAX); + open.range = clamp(open.top - open.bottom, LINEOPEN_MIN, LINEOPEN_MAX); } @@ -446,7 +445,7 @@ void AActor::LinkToWorld(bool spawningmapthing, sector_t *sector) { if (!spawningmapthing || numgamenodes == 0) { - sector = P_PointInSector(_f_X(), _f_Y()); + sector = P_PointInSector(Pos()); } else { diff --git a/src/p_maputl.h b/src/p_maputl.h index 96053dc90..727b56c2b 100644 --- a/src/p_maputl.h +++ b/src/p_maputl.h @@ -57,6 +57,16 @@ inline int P_PointOnLineSidePrecise (fixed_t x, fixed_t y, const line_t *line) return DMulScale32 (y-line->v1->y, line->dx, line->v1->x-x, line->dy) > 0; } +inline int P_PointOnLineSide(double x, double y, const line_t *line) +{ + return P_PointOnLineSide(FLOAT2FIXED(x), FLOAT2FIXED(y), line); +} + +inline int P_PointOnLineSide(const DVector2 & p, const line_t *line) +{ + return P_PointOnLineSide(FLOAT2FIXED(p.X), FLOAT2FIXED(p.Y), line); +} + inline int P_PointOnLineSidePrecise(double x, double y, const line_t *line) { return DMulScale32(FLOAT2FIXED(y) - line->v1->y, line->dx, line->v1->x - FLOAT2FIXED(x), line->dy) > 0; @@ -67,10 +77,6 @@ inline int P_PointOnLineSidePrecise(const DVector2 &pt, const line_t *line) return DMulScale32(FLOAT2FIXED(pt.Y) - line->v1->y, line->dx, line->v1->x - FLOAT2FIXED(pt.X), line->dy) > 0; } -inline int P_PointOnLineSidePrecise(const DVector3 &pt, const line_t *line) -{ - return DMulScale32(FLOAT2FIXED(pt.Y) - line->v1->y, line->dx, line->v1->x - FLOAT2FIXED(pt.X), line->dy) > 0; -} //========================================================================== // @@ -117,10 +123,10 @@ inline void P_MakeDivline (const line_t *li, fdivline_t *dl) struct FLineOpening { - fixed_t top; - fixed_t bottom; - fixed_t range; - fixed_t lowfloor; + double top; + double bottom; + double range; + double lowfloor; sector_t *bottomsec; sector_t *topsec; FTextureID ceilingpic; @@ -132,11 +138,20 @@ struct FLineOpening bool abovemidtex; }; -void P_LineOpening (FLineOpening &open, AActor *thing, const line_t *linedef, fixed_t x, fixed_t y, fixed_t refx=FIXED_MIN, fixed_t refy=0, int flags=0); +static const double LINEOPEN_MIN = -FLT_MAX; +static const double LINEOPEN_MAX = FLT_MAX; + +void P_LineOpening(FLineOpening &open, AActor *thing, const line_t *linedef, const DVector2 &xy, const DVector2 *ref = NULL, int flags = 0); + +inline void P_LineOpening(FLineOpening &open, AActor *thing, const line_t *linedef, fixed_t x, fixed_t y, fixed_t refx = FIXED_MIN, fixed_t refy = 0, int flags = 0) +{ + P_LineOpening(open, thing, linedef, DVector2(FIXED2DBL(x), FIXED2DBL(y)), &DVector2(FIXED2DBL(refx), FIXED2DBL(refy)), flags); +} inline void P_LineOpening(FLineOpening &open, AActor *thing, const line_t *linedef, fixedvec2 xy, fixed_t refx = FIXED_MIN, fixed_t refy = 0, int flags = 0) { P_LineOpening(open, thing, linedef, xy.x, xy.y, refx, refy, flags); } +void P_LineOpening(FLineOpening &open, AActor *thing, const line_t *linedef, const DVector2 &xy, fixed_t refx = FIXED_MIN, const DVector2 *ref = NULL, int flags = 0); class FBoundingBox; struct polyblock_t; diff --git a/src/p_spec.h b/src/p_spec.h index cfdbd5241..78965581e 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -131,7 +131,7 @@ protected: TObjPtr m_Source;// Point source if point pusher DVector2 m_PushVec; double m_Magnitude; // Vector strength for point pusher - double m_Radius; // Effective _f_radius() for point pusher + double m_Radius; // Effective radius for point pusher int m_Affectee; // Number of affected sector friend bool PIT_PushThing (AActor *thing); diff --git a/src/p_switch.cpp b/src/p_switch.cpp index 2e5649d8e..91f579250 100644 --- a/src/p_switch.cpp +++ b/src/p_switch.cpp @@ -199,7 +199,7 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, fixedvec3 *optpo } } - return (user->_f_Top() > open.top); + return (user->Top() > open.top); } else if ((TexMan.FindSwitch(side->GetTexture(side_t::bottom))) != NULL) { @@ -221,7 +221,7 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, fixedvec3 *optpo } } - return (user->_f_Z() < open.bottom); + return (user->Z() < open.bottom); } else if ((flags & ML_3DMIDTEX) || (TexMan.FindSwitch(side->GetTexture(side_t::mid))) != NULL) { @@ -234,7 +234,7 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, fixedvec3 *optpo else { // no switch found. Check whether the player can touch either top or bottom texture - return (user->_f_Top() > open.top) || (user->_f_Z() < open.bottom); + return (user->Top() > open.top) || (user->Z() < open.bottom); } } diff --git a/src/p_things.cpp b/src/p_things.cpp index 3e37135f3..929f07482 100644 --- a/src/p_things.cpp +++ b/src/p_things.cpp @@ -427,7 +427,7 @@ bool P_Thing_Raise(AActor *thing, AActor *raiser) thing->flags |= MF_SOLID; thing->Height = info->Height; // [RH] Use real height thing->radius = info->radius; // [RH] Use real radius - if (!P_CheckPosition (thing, thing->_f_Pos())) + if (!P_CheckPosition (thing, thing->Pos())) { thing->flags = oldflags; thing->radius = oldradius; diff --git a/src/p_writemap.cpp b/src/p_writemap.cpp index a9ae49f12..ab3290619 100644 --- a/src/p_writemap.cpp +++ b/src/p_writemap.cpp @@ -102,7 +102,7 @@ static int WriteTHINGS (FILE *file) mt.x = LittleShort(short(mo->X())); mt.y = LittleShort(short(mo->Y())); - mt.angle = LittleShort(short(MulScale32 (mo->_f_angle() >> ANGLETOFINESHIFT, 360))); + mt.angle = LittleShort(short(mo->Angles.Yaw.Degrees)); mt.type = LittleShort((short)1); mt.flags = LittleShort((short)(7|224|MTF_SINGLE)); fwrite (&mt, sizeof(mt), 1, file); diff --git a/src/po_man.cpp b/src/po_man.cpp index fa94c198a..91d4218ef 100644 --- a/src/po_man.cpp +++ b/src/po_man.cpp @@ -1191,8 +1191,8 @@ bool FPolyObj::CheckMobjBlocking (side_t *sd) if ((mobj->flags&MF_SOLID) && !(mobj->flags&MF_NOCLIP)) { FLineOpening open; - open.top = INT_MAX; - open.bottom = -INT_MAX; + open.top = LINEOPEN_MAX; + open.bottom = LINEOPEN_MIN; // [TN] Check wether this actor gets blocked by the line. if (ld->backsector != NULL && !(ld->flags & (ML_BLOCKING|ML_BLOCKEVERYTHING)) @@ -1201,7 +1201,7 @@ bool FPolyObj::CheckMobjBlocking (side_t *sd) && !((mobj->flags & MF_FLOAT) && (ld->flags & ML_BLOCK_FLOATERS)) && (!(ld->flags & ML_3DMIDTEX) || (!P_LineOpening_3dMidtex(mobj, ld, open) && - (mobj->_f_Top() < open.top) + (mobj->Top() < open.top) ) || (open.abovemidtex && mobj->Z() > mobj->floorz)) ) { @@ -1233,7 +1233,7 @@ bool FPolyObj::CheckMobjBlocking (side_t *sd) // Best use the one facing the player and ignore the back side. if (ld->sidedef[1] != NULL) { - int side = P_PointOnLineSidePrecise(mobj->_f_X(), mobj->_f_Y(), ld); + int side = P_PointOnLineSidePrecise(mobj->Pos(), ld); if (ld->sidedef[side] != sd) { continue; diff --git a/src/posix/sdl/sdlvideo.cpp b/src/posix/sdl/sdlvideo.cpp index 90bc42663..04c3a3f2e 100644 --- a/src/posix/sdl/sdlvideo.cpp +++ b/src/posix/sdl/sdlvideo.cpp @@ -491,7 +491,7 @@ void SDLFB::Update () return; pixels = Surface->pixels; - pitch = Surface->_f_pitch(); + pitch = Surface->pitch; } if (NotPaletted) diff --git a/src/r_defs.h b/src/r_defs.h index a467ba6ee..8cadafb93 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -880,6 +880,16 @@ struct sector_t fixed_t NextHighestCeilingAt(fixed_t x, fixed_t y, fixed_t bottomz, fixed_t topz, int flags = 0, sector_t **resultsec = NULL, F3DFloor **resultffloor = NULL); fixed_t NextLowestFloorAt(fixed_t x, fixed_t y, fixed_t z, int flags = 0, fixed_t steph = 0, sector_t **resultsec = NULL, F3DFloor **resultffloor = NULL); + inline double NextHighestCeilingAt(double x, double y, double bottomz, double topz, int flags = 0, sector_t **resultsec = NULL, F3DFloor **resultffloor = NULL) + { + return FIXED2DBL(NextHighestCeilingAt(FLOAT2FIXED(x), FLOAT2FIXED(y), FLOAT2FIXED(bottomz), FLOAT2FIXED(topz), flags, resultsec, resultffloor)); + } + + double NextLowestFloorAt(double x, double y, double z, int flags = 0, double steph = 0, sector_t **resultsec = NULL, F3DFloor **resultffloor = NULL) + { + return FIXED2DBL(NextLowestFloorAt(FLOAT2FIXED(x), FLOAT2FIXED(y), FLOAT2FIXED(z), flags, FLOAT2FIXED(steph), resultsec, resultffloor)); + } + // Member variables fixed_t CenterFloor () const { return floorplane.ZatPoint (centerspot); } fixed_t CenterCeiling () const { return ceilingplane.ZatPoint (centerspot); } diff --git a/src/r_plane.cpp b/src/r_plane.cpp index e46dfa5fe..6a3aa803f 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -1106,8 +1106,6 @@ void R_DrawHeightPlanes(fixed_t height) void R_DrawSinglePlane (visplane_t *pl, fixed_t alpha, bool additive, bool masked) { -// pl->_f_angle() = pa<left >= pl->right) return; diff --git a/src/s_sound.cpp b/src/s_sound.cpp index 76d8e4956..e04542a5b 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -173,9 +173,7 @@ void S_NoiseDebug (void) } - listener.X = FIXED2FLOAT(players[consoleplayer].camera->SoundX()); - listener.Y = FIXED2FLOAT(players[consoleplayer].camera->SoundZ()); - listener.Z = FIXED2FLOAT(players[consoleplayer].camera->SoundY()); + listener = players[consoleplayer].camera->SoundPos(); // Display the oldest channel first. for (chan = Channels; chan->NextChan != NULL; chan = chan->NextChan) @@ -664,9 +662,10 @@ static void CalcPosVel(int type, const AActor *actor, const sector_t *sector, if (players[consoleplayer].camera != NULL) { - x = players[consoleplayer].camera->SoundX(); - y = players[consoleplayer].camera->SoundZ(); - z = players[consoleplayer].camera->SoundY(); + FVector3 v = players[consoleplayer].camera->SoundPos(); + x = FLOAT2FIXED(v.X); + y = FLOAT2FIXED(v.Y); + z = FLOAT2FIXED(v.Z); } else { @@ -693,9 +692,10 @@ static void CalcPosVel(int type, const AActor *actor, const sector_t *sector, //assert(actor != NULL); if (actor != NULL) { - x = actor->SoundX(); - y = actor->SoundZ(); - z = actor->SoundY(); + FVector3 v = actor->SoundPos(); + x = FLOAT2FIXED(v.X); + y = FLOAT2FIXED(v.Y); + z = FLOAT2FIXED(v.Z); } break; @@ -764,8 +764,9 @@ static void CalcSectorSoundOrg(const sector_t *sec, int channum, fixed_t *x, fix // Are we inside the sector? If yes, the closest point is the one we're on. if (P_PointInSector(*x, *y) == sec) { - *x = players[consoleplayer].camera->SoundX(); - *y = players[consoleplayer].camera->SoundY(); + FVector3 p = players[consoleplayer].camera->SoundPos(); + *x = FLOAT2FIXED(p.X); + *y = FLOAT2FIXED(p.Y); } else { @@ -1568,9 +1569,10 @@ void S_RelinkSound (AActor *from, AActor *to) { chan->Actor = NULL; chan->SourceType = SOURCE_Unattached; - chan->Point[0] = FIXED2FLOAT(from->SoundX()); - chan->Point[1] = FIXED2FLOAT(from->SoundZ()); - chan->Point[2] = FIXED2FLOAT(from->SoundY()); + FVector3 p = from->SoundPos(); + chan->Point[0] = p.X; + chan->Point[1] = p.Y; + chan->Point[2] = p.Z; } else { @@ -1950,16 +1952,14 @@ static void S_SetListener(SoundListener &listener, AActor *listenactor) { if (listenactor != NULL) { - listener.angle = ANGLE2RADF(listenactor->_f_angle()); + listener.angle = ToRadians(listenactor->Angles.Yaw); /* listener.velocity.X = listenactor->vel.x * (TICRATE/65536.f); listener.velocity.Y = listenactor->vel.z * (TICRATE/65536.f); listener.velocity.Z = listenactor->vel.y * (TICRATE/65536.f); */ listener.velocity.Zero(); - listener.position.X = FIXED2FLOAT(listenactor->SoundX()); - listener.position.Y = FIXED2FLOAT(listenactor->SoundZ()); - listener.position.Z = FIXED2FLOAT(listenactor->SoundY()); + listener.position = listenactor->SoundPos(); listener.underwater = listenactor->waterlevel == 3; assert(zones != NULL); listener.Environment = zones[listenactor->Sector->ZoneNumber].Environment; diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 6591525af..c79b2e6db 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -3297,7 +3297,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Burst) // with no relation to the size of the self shattering. I think it should // base the number of shards on the size of the dead thing, so bigger // things break up into more shards than smaller things. - // An self with _f_radius() 20 and height 64 creates ~40 chunks. + // An self with radius 20 and height 64 creates ~40 chunks. numChunks = MAX (4, int(self->radius * self->Height)/32); i = (pr_burst.Random2()) % (numChunks/4); for (i = MAX (24, numChunks + i); i >= 0; i--) @@ -3713,7 +3713,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckLOF) if (!(flags & CLOFF_FROMBASE)) { // default to hitscan origin - // Synced with hitscan: self->_f_height() is strangely NON-conscientious about getting the right actor for player + // Synced with hitscan: self->Height is strangely NON-conscientious about getting the right actor for player pos.Z += self->Height *0.5; if (self->player != NULL) {