diff --git a/src/p_local.h b/src/p_local.h index 4d2cb75be..d6e8bdb44 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -280,25 +280,16 @@ 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); AActor *P_CheckOnmobj (AActor *thing); void P_FakeZMovement (AActor *mo); -bool P_TryMove (AActor* thing, fixed_t x, fixed_t y, int dropoff, const secplane_t * onfloor, FCheckPosition &tm, bool missileCheck = false); -bool P_TryMove (AActor* thing, fixed_t x, fixed_t y, int dropoff, const secplane_t * onfloor = NULL); +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); } -inline bool P_TryMove(AActor* thing, const DVector2 &pos, int dropoff, const secplane_t * onfloor = NULL) -{ - return P_TryMove(thing, FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y), dropoff, onfloor); -} -inline bool P_TryMove(AActor* thing, const DVector2 &pos, int dropoff, const secplane_t * onfloor, FCheckPosition &tm, bool missileCheck = false) -{ - return P_TryMove(thing, FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y), dropoff, onfloor, tm, missileCheck); -} -bool P_CheckMove(AActor *thing, fixed_t x, fixed_t y); -inline bool P_CheckMove(AActor *thing, double x, double y) -{ - return P_CheckMove(thing, FLOAT2FIXED(x), FLOAT2FIXED(y)); -} +*/ + +bool P_CheckMove(AActor *thing, const DVector2 &pos); void P_ApplyTorque(AActor *mo); bool P_TeleportMove(AActor* thing, const DVector3 &pos, bool telefrag, bool modifyactor = true); // [RH] Added z and telefrag parameters @@ -313,7 +304,7 @@ inline bool P_TeleportMove(AActor* thing, const fixedvec3 &pos, bool telefrag, b } void P_PlayerStartStomp (AActor *actor, bool mononly=false); // [RH] Stomp on things for a newly spawned player -void P_SlideMove (AActor* mo, fixed_t tryx, fixed_t tryy, int numsteps); +void P_SlideMove (AActor* mo, const DVector2 &pos, int numsteps); bool P_BounceWall (AActor *mo); bool P_BounceActor (AActor *mo, AActor *BlockingMobj, bool ontop); bool P_CheckSight (AActor *t1, AActor *t2, int flags=0); @@ -455,6 +446,13 @@ bool Check_Sides(AActor *, int, int); // phares // [RH] const secplane_t * P_CheckSlopeWalk (AActor *actor, fixed_t &xmove, fixed_t &ymove); +inline const secplane_t * P_CheckSlopeWalk(AActor *actor, DVector2 &move) +{ + fixedvec2 mov = { FLOAT2FIXED(move.X), FLOAT2FIXED(move.Y) }; + const secplane_t *ret = P_CheckSlopeWalk(actor, mov.x, mov.y); + move = { FIXED2DBL(mov.x), FIXED2DBL(mov.y) }; + return ret; +} // // P_SETUP diff --git a/src/p_map.cpp b/src/p_map.cpp index edea639e6..849d70874 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -1481,7 +1481,7 @@ MOVEMENT CLIPPING // // out: // newsubsec -// _f_floorz() +// floorz // ceilingz // tmdropoffz = the lowest point contacted (monsters won't move to a dropoff) // speciallines[] @@ -1703,14 +1703,14 @@ bool P_TestMobjLocation(AActor *mobj) AActor *P_CheckOnmobj(AActor *thing) { - fixed_t oldz; + double oldz; bool good; AActor *onmobj; - oldz = thing->_f_Z(); + oldz = thing->Z(); P_FakeZMovement(thing); good = P_TestMobjZ(thing, false, &onmobj); - thing->_f_SetZ(oldz); + thing->SetZ(oldz); return good ? NULL : onmobj; } @@ -1738,8 +1738,8 @@ bool P_TestMobjZ(AActor *actor, bool quick, AActor **pOnmobj) { AActor *thing = cres.thing; - fixed_t blockdist = thing->_f_radius() + actor->_f_radius(); - if (abs(thing->_f_X() - cres.position.x) >= blockdist || abs(thing->_f_Y() - cres.position.y) >= blockdist) + double blockdist = thing->radius + actor->radius; + if (fabs(thing->X() - cres.Position.X) >= blockdist || fabs(thing->Y() - cres.Position.Y) >= blockdist) { continue; } @@ -1784,7 +1784,7 @@ bool P_TestMobjZ(AActor *actor, bool quick, AActor **pOnmobj) { // under thing continue; } - else if (!quick && onmobj != NULL && thing->_f_Top() < onmobj->_f_Top()) + else if (!quick && onmobj != NULL && thing->Top() < onmobj->Top()) { // something higher is in the way continue; } @@ -1808,22 +1808,22 @@ void P_FakeZMovement(AActor *mo) // // adjust height // - mo->_f_AddZ(mo->_f_velz()); + mo->AddZ(mo->Vel.Z); if ((mo->flags&MF_FLOAT) && mo->target) { // float down towards target if too close if (!(mo->flags & MF_SKULLFLY) && !(mo->flags & MF_INFLOAT)) { - fixed_t dist = mo->AproxDistance(mo->target); - fixed_t delta = (mo->target->_f_Z() + (mo->_f_height() >> 1)) - mo->_f_Z(); + double dist = mo->Distance2D(mo->target); + double delta = mo->target->Center() - mo->Z(); if (delta < 0 && dist < -(delta * 3)) - mo->_f_AddZ(-mo->_f_floatspeed()); + mo->AddZ(-mo->FloatSpeed); else if (delta > 0 && dist < (delta * 3)) - mo->_f_AddZ(mo->_f_floatspeed()); + mo->AddZ(mo->FloatSpeed); } } if (mo->player && mo->flags&MF_NOGRAVITY && (mo->Z() > mo->floorz) && !mo->IsNoClip2()) { - mo->_f_AddZ(finesine[(FINEANGLES / 80 * level.maptime)&FINEMASK] / 8); + mo->AddZ(DAngle(4.5 * level.maptime).Sin()); } // @@ -1906,28 +1906,26 @@ static void CheckForPushSpecial(line_t *line, int side, AActor *mobj, DVector2 * // //========================================================================== -bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, +bool P_TryMove(AActor *thing, const DVector2 &pos, int dropoff, // killough 3/15/98: allow dropoff as option const secplane_t *onfloor, // [RH] Let P_TryMove keep the thing on the floor FCheckPosition &tm, bool missileCheck) // [GZ] Fired missiles ignore the drop-off test { - fixedvec3 oldpos; sector_t *oldsector; - fixed_t oldz; + double oldz; int side; int oldside; sector_t* oldsec = thing->Sector; // [RH] for sector actions sector_t* newsec; tm.floatok = false; - oldz = thing->_f_Z(); + oldz = thing->Z(); if (onfloor) { - thing->_f_SetZ(onfloor->ZatPoint(x, y)); + thing->SetZ(onfloor->ZatPoint(pos)); } thing->flags6 |= MF6_INTRYMOVE; - DVector2 pos = { FIXED2DBL(x), FIXED2DBL(y) }; if (!P_CheckPosition(thing, pos, tm)) { AActor *BlockingMobj = thing->BlockingMobj; @@ -1943,7 +1941,7 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, goto pushline; } else if (BlockingMobj->Top() - thing->Z() > thing->MaxStepHeight - || (BlockingMobj->Sector->ceilingplane._f_ZatPointF(x, y) - (BlockingMobj->Top()) < thing->Height) + || (BlockingMobj->Sector->ceilingplane.ZatPoint(pos) - (BlockingMobj->Top()) < thing->Height) || (tm.ceilingz - (BlockingMobj->Top()) < thing->Height)) { goto pushline; @@ -1951,7 +1949,7 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, } if (!(tm.thing->flags2 & MF2_PASSMOBJ) || (i_compatflags & COMPATF_NO_PASSMOBJ)) { - thing->_f_SetZ(oldz); + thing->SetZ(oldz); thing->flags6 &= ~MF6_INTRYMOVE; return false; } @@ -2078,7 +2076,7 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, !(thing->flags2 & MF2_BLASTED) && !missileCheck) { // Can't move over a dropoff unless it's been blasted // [GZ] Or missile-spawned - thing->_f_SetZ(oldz); + thing->SetZ(oldz); thing->flags6 &= ~MF6_INTRYMOVE; return false; } @@ -2099,7 +2097,7 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, && (tm.floorpic != thing->floorpic || tm.floorz - thing->Z() != 0)) { // must stay within a sector of a certain floor type - thing->_f_SetZ(oldz); + thing->SetZ(oldz); thing->flags6 &= ~MF6_INTRYMOVE; return false; } @@ -2113,7 +2111,7 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, thing->player->Bot->prev = thing->player->Bot->dest; thing->player->Bot->dest = NULL; thing->Vel.X = thing->Vel.Y = 0; - thing->_f_SetZ(oldz); + thing->SetZ(oldz); thing->flags6 &= ~MF6_INTRYMOVE; return false; } @@ -2129,7 +2127,7 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, if (oldsec->heightsec) { - fixed_t eyez = oldz + viewheight; + double eyez = oldz + FIXED2DBL(viewheight); oldAboveFakeFloor = eyez > oldsec->heightsec->floorplane.ZatPoint(thing); oldAboveFakeCeiling = eyez > oldsec->heightsec->ceilingplane.ZatPoint(thing); @@ -2151,7 +2149,7 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, while (true) { - fixed_t bestfrac = FIXED_MAX; + double bestfrac = 1.1; spechit_t besthit; int besthitnum; // find the portal nearest to the crossing actor @@ -2169,7 +2167,7 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, { divline_t dl2 = { ld->v1->fX(), ld->v1->fY(), ld->Delta().X, ld->Delta().Y }; divline_t dl1 = { spec.Oldrefpos.X, spec.Oldrefpos.Y, spec.Refpos.X - spec.Oldrefpos.X, spec.Refpos.Y - spec.Oldrefpos.Y }; - fixed_t frac = FLOAT2FIXED(P_InterceptVector(&dl1, &dl2)); + double frac = P_InterceptVector(&dl1, &dl2); if (frac < bestfrac) { besthit = spec; @@ -2179,7 +2177,7 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, } } - if (bestfrac < FIXED_MAX) + if (bestfrac < 1.1) { portalhit.Delete(besthitnum); line_t *ld = besthit.line; @@ -2187,9 +2185,8 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, if (port->mType == PORTT_LINKED) { thing->UnlinkFromWorld(); - thing->SetXY(tm._f_X() + port->mXDisplacement, tm._f_Y() + port->mYDisplacement); - thing->Prev.X += FIXED2DBL(port->mXDisplacement); - thing->Prev.Y += FIXED2DBL(port->mYDisplacement); + thing->SetXY(tm.pos + port->mDisplacement); + thing->Prev += port->mDisplacement; thing->LinkToWorld(); P_FindFloorCeiling(thing); portalcrossed = true; @@ -2223,22 +2220,20 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, // so that the renderer can properly calculate an interpolated position along the movement path. if (thing == players[consoleplayer].camera) { - //divline_t dl1 = { besthit.Oldrefpos.X,besthit.Oldrefpos.Y, besthit.Refpos.X - besthit.Oldrefpos.Y, besthit.Refpos.Y - besthit.Oldrefpos.Y }; - //DVector3 hit = { dl1.x + dl1.dx * bestfrac, dl1.y + dl1.dy * bestfrac, 0.,0. }; - fdivline_t dl1 = { FLOAT2FIXED(besthit.Oldrefpos.X),FLOAT2FIXED(besthit.Oldrefpos.Y), FLOAT2FIXED(besthit.Refpos.X - besthit.Oldrefpos.Y), FLOAT2FIXED(besthit.Refpos.Y - besthit.Oldrefpos.Y) }; - fixedvec3a hit = { dl1.x + FixedMul(dl1.dx, bestfrac), dl1.y + FixedMul(dl1.dy, bestfrac), 0, 0. }; + divline_t dl1 = { besthit.Oldrefpos.X,besthit.Oldrefpos.Y, besthit.Refpos.X - besthit.Oldrefpos.Y, besthit.Refpos.Y - besthit.Oldrefpos.Y }; + DVector3a hit = { {dl1.x + dl1.dx * bestfrac, dl1.y + dl1.dy * bestfrac, 0.},0. }; R_AddInterpolationPoint(hit); if (port->mType == PORTT_LINKED) { - hit.x += port->mXDisplacement; - hit.y += port->mYDisplacement; + hit.pos.X += port->mDisplacement.X; + hit.pos.Y += port->mDisplacement.Y; } else { - P_TranslatePortalXY(ld, hit.x, hit.y); - P_TranslatePortalZ(ld, hit.z); - players[consoleplayer].viewz += FIXED2DBL(hit.z); // needs to be done here because otherwise the renderer will not catch the change. + P_TranslatePortalXY(ld, hit.pos.X, hit.pos.Y); + P_TranslatePortalZ(ld, hit.pos.Z); + players[consoleplayer].viewz += hit.pos.Z; // needs to be done here because otherwise the renderer will not catch the change. P_TranslatePortalAngle(ld, hit.angle); } R_AddInterpolationPoint(hit); @@ -2258,7 +2253,6 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, // the move is ok, so link the thing into its new position thing->UnlinkFromWorld(); - oldpos = thing->_f_Pos(); oldsector = thing->Sector; thing->floorz = tm.floorz; thing->ceilingz= tm.ceilingz; @@ -2268,7 +2262,7 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, thing->floorsector = tm.floorsector; thing->ceilingpic = tm.ceilingpic; thing->ceilingsector = tm.ceilingsector; - thing->SetXY(x, y); + thing->SetXY(pos); thing->LinkToWorld(); } @@ -2339,8 +2333,8 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, if (newsec->heightsec && oldsec->heightsec && newsec->SecActTarget) { const sector_t *hs = newsec->heightsec; - fixed_t eyez = thing->_f_Z() + viewheight; - fixed_t fakez = hs->floorplane.ZatPoint(x, y); + double eyez = thing->Z() + FIXED2DBL(viewheight); + double fakez = hs->floorplane.ZatPoint(pos); if (!oldAboveFakeFloor && eyez > fakez) { // View went above fake floor @@ -2353,7 +2347,7 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, if (!(hs->MoreFlags & SECF_FAKEFLOORONLY)) { - fakez = hs->ceilingplane.ZatPoint(x, y); + fakez = hs->ceilingplane.ZatPoint(pos); if (!oldAboveFakeCeiling && eyez > fakez) { // View went above fake ceiling newsec->SecActTarget->TriggerAction(thing, SECSPAC_EyesAboveC); @@ -2379,7 +2373,7 @@ pushline: return false; } - thing->_f_SetZ(oldz); + thing->SetZ(oldz); if (!(thing->flags&(MF_TELEPORT | MF_NOCLIP))) { int numSpecHitTemp; @@ -2400,12 +2394,12 @@ pushline: return false; } -bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, +bool P_TryMove(AActor *thing, const DVector2 &pos, int dropoff, // killough 3/15/98: allow dropoff as option const secplane_t *onfloor) // [RH] Let P_TryMove keep the thing on the floor { FCheckPosition tm; - return P_TryMove(thing, x, y, dropoff, onfloor, tm); + return P_TryMove(thing, pos, dropoff, onfloor, tm); } @@ -2417,12 +2411,11 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, // //========================================================================== -bool P_CheckMove(AActor *thing, fixed_t x, fixed_t y) +bool P_CheckMove(AActor *thing, const DVector2 &pos) { FCheckPosition tm; - fixed_t newz = thing->_f_Z(); + double newz = thing->Z(); - DVector2 pos = { FIXED2DBL(x), FIXED2DBL(y) }; if (!P_CheckPosition(thing, pos, tm)) { return false; @@ -2430,11 +2423,11 @@ bool P_CheckMove(AActor *thing, fixed_t x, fixed_t y) if (thing->flags3 & MF3_FLOORHUGGER) { - newz = tm._f_floorz(); + newz = tm.floorz; } else if (thing->flags3 & MF3_CEILINGHUGGER) { - newz = tm._f_ceilingz() - thing->_f_height(); + newz = tm.ceilingz - thing->Height; } if (!(thing->flags & MF_NOCLIP)) @@ -2458,20 +2451,20 @@ bool P_CheckMove(AActor *thing, fixed_t x, fixed_t y) } if (!(thing->flags & MF_TELEPORT) && !(thing->flags3 & MF3_FLOORHUGGER)) { - if (tm._f_floorz() - newz > thing->_f_MaxStepHeight()) + if (tm.floorz - newz > thing->MaxStepHeight) { // too big a step up return false; } - else if ((thing->flags & MF_MISSILE) && !(thing->flags6 & MF6_STEPMISSILE) && tm._f_floorz() > newz) + else if ((thing->flags & MF_MISSILE) && !(thing->flags6 & MF6_STEPMISSILE) && tm.floorz > newz) { // [RH] Don't let normal missiles climb steps return false; } - else if (newz < tm._f_floorz()) + else if (newz < tm.floorz) { // [RH] Check to make sure there's nothing in the way for the step up - fixed_t savedz = thing->_f_Z(); - thing->_f_SetZ(newz = tm._f_floorz()); + double savedz = thing->Z(); + thing->SetZ(newz = tm.floorz); bool good = P_TestMobjZ(thing); - thing->_f_SetZ(savedz); + thing->SetZ(savedz); if (!good) { return false; @@ -2481,7 +2474,7 @@ bool P_CheckMove(AActor *thing, fixed_t x, fixed_t y) if (thing->flags2 & MF2_CANTLEAVEFLOORPIC && (tm.floorpic != thing->floorpic - || tm._f_floorz() - newz != 0)) + || tm.floorz - newz != 0)) { // must stay within a sector of a certain floor type return false; } @@ -2501,23 +2494,22 @@ bool P_CheckMove(AActor *thing, fixed_t x, fixed_t y) struct FSlide { - fixed_t bestslidefrac; - fixed_t secondslidefrac; + double bestSlidefrac; + double secondSlidefrac; line_t* bestslideline; line_t* secondslideline; AActor* slidemo; - fixed_t tmxmove; - fixed_t tmymove; + DVector2 tmmove; void HitSlideLine(line_t *ld); - void SlideTraverse(fixed_t startx, fixed_t starty, fixed_t endx, fixed_t endy); - void SlideMove(AActor *mo, fixed_t tryx, fixed_t tryy, int numsteps); + void SlideTraverse(const DVector2 &start, const DVector2 &end); + void SlideMove(AActor *mo, DVector2 tryp, int numsteps); // The bouncing code uses the same data structure - bool BounceTraverse(fixed_t startx, fixed_t starty, fixed_t endx, fixed_t endy); + bool BounceTraverse(const DVector2 &start, const DVector2 &end); bool BounceWall(AActor *mo); }; @@ -2534,11 +2526,11 @@ void FSlide::HitSlideLine(line_t* ld) { int side; - angle_t lineangle; - angle_t moveangle; - angle_t deltaangle; + DAngle lineangle; + DAngle moveangle; + DAngle deltaangle; - fixed_t movelen; + double movelen; bool icyfloor; // is floor icy? // phares // | // Under icy conditions, if the angle of approach to the wall // V @@ -2550,121 +2542,108 @@ void FSlide::HitSlideLine(line_t* ld) // killough 10/98: only bounce if hit hard (prevents wobbling) icyfloor = - (P_AproxDistance(tmxmove, tmymove) > 4 * FRACUNIT) && + tmmove.LengthSquared() > 4*4 && var_friction && // killough 8/28/98: calc friction on demand slidemo->Z() <= slidemo->floorz && P_GetFriction(slidemo, NULL) > ORIG_FRICTION; - if (ld->dx == 0) + if (ld->Delta().X == 0) { // ST_VERTICAL - if (icyfloor && (abs(tmxmove) > abs(tmymove))) + if (icyfloor && (fabs(tmmove.X) > fabs(tmmove.Y))) { - tmxmove = -tmxmove / 2; // absorb half the velocity - tmymove /= 2; + tmmove.X = -tmmove.X / 2; + tmmove.Y /= 2; // absorb half the velocity if (slidemo->player && slidemo->health > 0 && !(slidemo->player->cheats & CF_PREDICTING)) { S_Sound(slidemo, CHAN_VOICE, "*grunt", 1, ATTN_IDLE); // oooff!// ^ } } // | else // phares - tmxmove = 0; // no more movement in the X direction + tmmove.X = 0; // no more movement in the X direction return; } - if (ld->dy == 0) + if (ld->Delta().Y == 0) { // ST_HORIZONTAL - if (icyfloor && (abs(tmymove) > abs(tmxmove))) + if (icyfloor && (fabs(tmmove.Y) > fabs(tmmove.X))) { - tmxmove /= 2; // absorb half the velocity - tmymove = -tmymove / 2; + tmmove.X /= 2; // absorb half the velocity + tmmove.Y = -tmmove.Y / 2; if (slidemo->player && slidemo->health > 0 && !(slidemo->player->cheats & CF_PREDICTING)) { S_Sound(slidemo, CHAN_VOICE, "*grunt", 1, ATTN_IDLE); // oooff! } } else - tmymove = 0; // no more movement in the Y direction + tmmove.Y = 0; // no more movement in the Y direction return; } // The wall is angled. Bounce if the angle of approach is // phares // less than 45 degrees. // phares - fixedvec3 pos = slidemo->_f_PosRelative(ld); - side = P_PointOnLineSide(pos.x, pos.y, ld); + DVector3 pos = slidemo->PosRelative(ld); + side = P_PointOnLineSide(pos, ld); - lineangle = R_PointToAngle2(0, 0, ld->dx, ld->dy); + lineangle = ld->Delta().Angle(); if (side == 1) - lineangle += ANG180; + lineangle += 180.; - moveangle = R_PointToAngle2(0, 0, tmxmove, tmymove); + moveangle = tmmove.Angle(); - moveangle += 10; // prevents sudden path reversal due to // phares - // rounding error // | - deltaangle = moveangle - lineangle; // V - movelen = P_AproxDistance(tmxmove, tmymove); - if (icyfloor && (deltaangle > ANG45) && (deltaangle < ANG90 + ANG45)) + // prevents sudden path reversal due to rounding error | // phares + moveangle += 3600/65536.*65536.; // Boom added 10 to the angle_t here. + + deltaangle = ::deltaangle(lineangle, moveangle); // V + movelen = tmmove.Length(); + if (icyfloor && (deltaangle > 45) && (deltaangle < 135)) { - moveangle = lineangle - deltaangle; + moveangle = ::deltaangle(deltaangle, lineangle); movelen /= 2; // absorb if (slidemo->player && slidemo->health > 0 && !(slidemo->player->cheats & CF_PREDICTING)) { S_Sound(slidemo, CHAN_VOICE, "*grunt", 1, ATTN_IDLE); // oooff! } - moveangle >>= ANGLETOFINESHIFT; - tmxmove = FixedMul(movelen, finecosine[moveangle]); - tmymove = FixedMul(movelen, finesine[moveangle]); - } // ^ - else // | - { // phares - // Doom's original algorithm here does not work well due to imprecisions of the sine table. - // However, keep it active if the wallrunning compatibility flag is on - if (i_compatflags & COMPATF_WALLRUN) + tmmove = moveangle.ToVector(movelen); + } + else + { + // The compatibility option that used to be here had to be removed because + // with floating point math it was no longer possible to reproduce. + +#if 0 + // with full precision this should work now. Needs some testing + if (deltaangle < 0) deltaangle += 180.; + tmmove = lineangle.ToVector(movelen * deltaangle.Cos()); +#else + divline_t dll, dlv; + double inter1, inter2, inter3; + + P_MakeDivline(ld, &dll); + + dlv.x = pos.X; + dlv.y = pos.Y; + dlv.dx = dll.dy; + dlv.dy = -dll.dx; + + inter1 = P_InterceptVector(&dll, &dlv); + + dlv.dx = tmmove.X; + dlv.dy = tmmove.Y; + inter2 = P_InterceptVector(&dll, &dlv); + inter3 = P_InterceptVector(&dlv, &dll); + + if (inter3 != 0) { - fixed_t newlen; - - if (deltaangle > ANG180) - deltaangle += ANG180; - // I_Error ("SlideLine: ang>ANG180"); - - lineangle >>= ANGLETOFINESHIFT; - deltaangle >>= ANGLETOFINESHIFT; - - newlen = FixedMul(movelen, finecosine[deltaangle]); - - tmxmove = FixedMul(newlen, finecosine[lineangle]); - tmymove = FixedMul(newlen, finesine[lineangle]); + tmmove.X = (inter2 - inter1) * dll.dx / inter3; + tmmove.Y = (inter2 - inter1) * dll.dy / inter3; } else { - fdivline_t dll, dlv; - fixed_t inter1, inter2, inter3; - - P_MakeDivline(ld, &dll); - - dlv.x = pos.x; - dlv.y = pos.y; - dlv.dx = dll.dy; - dlv.dy = -dll.dx; - - inter1 = P_InterceptVector(&dll, &dlv); - - dlv.dx = tmxmove; - dlv.dy = tmymove; - inter2 = P_InterceptVector(&dll, &dlv); - inter3 = P_InterceptVector(&dlv, &dll); - - if (inter3 != 0) - { - tmxmove = Scale(inter2 - inter1, dll.dx, inter3); - tmymove = Scale(inter2 - inter1, dll.dy, inter3); - } - else - { - tmxmove = tmymove = 0; - } + tmmove.Zero(); } +#endif } // phares } @@ -2675,10 +2654,10 @@ void FSlide::HitSlideLine(line_t* ld) // //========================================================================== -void FSlide::SlideTraverse(fixed_t startx, fixed_t starty, fixed_t endx, fixed_t endy) +void FSlide::SlideTraverse(const DVector2 &start, const DVector2 &end) { FLineOpening open; - FPathTraverse it(startx, starty, endx, endy, PT_ADDLINES); + FPathTraverse it(start.X, start.Y, end.X, end.Y, PT_ADDLINES); intercept_t *in; while ((in = it.Next())) @@ -2696,8 +2675,8 @@ void FSlide::SlideTraverse(fixed_t startx, fixed_t starty, fixed_t endx, fixed_t if (!(li->flags & ML_TWOSIDED) || !li->backsector) { - fixedvec3 pos = slidemo->_f_PosRelative(li); - if (P_PointOnLineSide(pos.x, pos.y, li)) + DVector3 pos = slidemo->PosRelative(li); + if (P_PointOnLineSide(pos, li)) { // don't hit the back side continue; @@ -2719,7 +2698,7 @@ void FSlide::SlideTraverse(fixed_t startx, fixed_t starty, fixed_t endx, fixed_t } // set openrange, opentop, openbottom - P_LineOpening(open, slidemo, li, it._f_InterceptPoint(in)); + P_LineOpening(open, slidemo, li, it.InterceptPoint(in)); if (open.range < slidemo->Height) goto isblocking; // doesn't fit @@ -2749,11 +2728,11 @@ void FSlide::SlideTraverse(fixed_t startx, fixed_t starty, fixed_t endx, fixed_t // the line does block movement, // see if it is closer than best so far isblocking: - if (in->frac < bestslidefrac) + if (in->Frac < bestSlidefrac) { - secondslidefrac = bestslidefrac; + secondSlidefrac = bestSlidefrac; secondslideline = bestslideline; - bestslidefrac = in->frac; + bestSlidefrac = in->Frac; bestslideline = li; } @@ -2775,12 +2754,12 @@ void FSlide::SlideTraverse(fixed_t startx, fixed_t starty, fixed_t endx, fixed_t // //========================================================================== -void FSlide::SlideMove(AActor *mo, fixed_t tryx, fixed_t tryy, int numsteps) +void FSlide::SlideMove(AActor *mo, DVector2 tryp, int numsteps) { - fixed_t leadx, leady; - fixed_t trailx, traily; - fixed_t newx, newy; - fixed_t xmove, ymove; + DVector2 lead; + DVector2 trail; + DVector2 newpos; + DVector2 move; const secplane_t * walkplane; int hitcount; @@ -2795,84 +2774,81 @@ retry: goto stairstep; // don't loop forever // trace along the three leading corners - if (tryx > 0) + if (tryp.X > 0) { - leadx = mo->_f_X() + mo->_f_radius(); - trailx = mo->_f_X() - mo->_f_radius(); + lead.X = mo->X() + mo->radius; + trail.X = mo->X() - mo->radius; } else { - leadx = mo->_f_X() - mo->_f_radius(); - trailx = mo->_f_X() + mo->_f_radius(); + lead.X = mo->X() - mo->radius; + trail.X = mo->X() + mo->radius; } - if (tryy > 0) + if (tryp.Y > 0) { - leady = mo->_f_Y() + mo->_f_radius(); - traily = mo->_f_Y() - mo->_f_radius(); + lead.Y = mo->Y() + mo->radius; + trail.Y = mo->Y() - mo->radius; } else { - leady = mo->_f_Y() - mo->_f_radius(); - traily = mo->_f_Y() + mo->_f_radius(); + lead.Y = mo->Y() - mo->radius; + trail.Y = mo->Y() + mo->radius; } - bestslidefrac = FRACUNIT + 1; + bestSlidefrac = 1.01; - SlideTraverse(leadx, leady, leadx + tryx, leady + tryy); - SlideTraverse(trailx, leady, trailx + tryx, leady + tryy); - SlideTraverse(leadx, traily, leadx + tryx, traily + tryy); + SlideTraverse(lead, lead + tryp); + SlideTraverse(DVector2(trail.X, lead.Y), tryp + DVector2(trail.X, lead.Y)); + SlideTraverse(DVector2(lead.X, trail.Y), tryp + DVector2(lead.X, trail.Y)); // move up to the wall - if (bestslidefrac == FRACUNIT + 1) + if (bestSlidefrac > 1) { // the move must have hit the middle, so stairstep stairstep: // killough 3/15/98: Allow objects to drop off ledges - xmove = 0, ymove = tryy; - walkplane = P_CheckSlopeWalk(mo, xmove, ymove); - if (!P_TryMove(mo, mo->_f_X() + xmove, mo->_f_Y() + ymove, true, walkplane)) + move = { 0, tryp.Y }; + walkplane = P_CheckSlopeWalk(mo, move); + if (!P_TryMove(mo, mo->Pos() + move, true, walkplane)) { - xmove = tryx, ymove = 0; - walkplane = P_CheckSlopeWalk(mo, xmove, ymove); - P_TryMove(mo, mo->_f_X() + xmove, mo->_f_Y() + ymove, true, walkplane); + move = { tryp.X, 0 }; + walkplane = P_CheckSlopeWalk(mo, move); + P_TryMove(mo, mo->Pos() + move, true, walkplane); } return; } // fudge a bit to make sure it doesn't hit - bestslidefrac -= FRACUNIT / 32; - if (bestslidefrac > 0) + bestSlidefrac -= FRACUNIT / 32; + if (bestSlidefrac > 0) { - newx = FixedMul(tryx, bestslidefrac); - newy = FixedMul(tryy, bestslidefrac); + newpos = tryp * bestSlidefrac; // [BL] We need to abandon this function if we end up going through a teleporter - const fixed_t startvelx = mo->_f_velx(); - const fixed_t startvely = mo->_f_vely(); + const DVector2 startvel = mo->Vel.XY(); // killough 3/15/98: Allow objects to drop off ledges - if (!P_TryMove(mo, mo->_f_X() + newx, mo->_f_Y() + newy, true)) + if (!P_TryMove(mo, mo->Pos() + newpos, true)) goto stairstep; - if (mo->_f_velx() != startvelx || mo->_f_vely() != startvely) + if (mo->Vel.XY() != startvel) return; } // Now continue along the wall. - bestslidefrac = FRACUNIT - (bestslidefrac + FRACUNIT / 32); // remainder - if (bestslidefrac > FRACUNIT) - bestslidefrac = FRACUNIT; - else if (bestslidefrac <= 0) + bestSlidefrac = 1. - (bestSlidefrac + 1. / 32); // remainder + if (bestSlidefrac > 1) + bestSlidefrac = 1; + else if (bestSlidefrac <= 0) return; - tryx = tmxmove = FixedMul(tryx, bestslidefrac); - tryy = tmymove = FixedMul(tryy, bestslidefrac); + tryp = tmmove = tryp*bestSlidefrac; HitSlideLine(bestslideline); // clip the moves - mo->Vel.X = FIXED2DBL(tmxmove * numsteps); - mo->Vel.Y = FIXED2DBL(tmymove * numsteps); + mo->Vel.X = tmmove.X * numsteps; + mo->Vel.Y = tmmove.Y * numsteps; // killough 10/98: affect the bobbing the same way (but not voodoo dolls) if (mo->player && mo->player->mo == mo) @@ -2883,19 +2859,19 @@ retry: mo->player->Vel.Y = mo->Vel.Y; } - walkplane = P_CheckSlopeWalk(mo, tmxmove, tmymove); + walkplane = P_CheckSlopeWalk(mo, tmmove); // killough 3/15/98: Allow objects to drop off ledges - if (!P_TryMove(mo, mo->_f_X() + tmxmove, mo->_f_Y() + tmymove, true, walkplane)) + if (!P_TryMove(mo, mo->Pos() + tmmove, true, walkplane)) { goto retry; } } -void P_SlideMove(AActor *mo, fixed_t tryx, fixed_t tryy, int numsteps) +void P_SlideMove(AActor *mo, const DVector2 &pos, int numsteps) { FSlide slide; - slide.SlideMove(mo, tryx, tryy, numsteps); + slide.SlideMove(mo, pos, numsteps); } //============================================================================ @@ -3044,10 +3020,10 @@ const secplane_t * P_CheckSlopeWalk(AActor *actor, fixed_t &xmove, fixed_t &ymov // //============================================================================ -bool FSlide::BounceTraverse(fixed_t startx, fixed_t starty, fixed_t endx, fixed_t endy) +bool FSlide::BounceTraverse(const DVector2 &start, const DVector2 &end) { FLineOpening open; - FPathTraverse it(startx, starty, endx, endy, PT_ADDLINES); + FPathTraverse it(start.X, start.Y, end.X, end.Y, PT_ADDLINES); intercept_t *in; while ((in = it.Next())) @@ -3089,11 +3065,11 @@ bool FSlide::BounceTraverse(fixed_t startx, fixed_t starty, fixed_t endx, fixed_ // the line does block movement, see if it is closer than best so far bounceblocking: - if (in->frac < bestslidefrac) + if (in->Frac < bestSlidefrac) { - secondslidefrac = bestslidefrac; + secondSlidefrac = bestSlidefrac; secondslideline = bestslideline; - bestslidefrac = in->frac; + bestSlidefrac = in->Frac; bestslideline = li; } return false; // stop @@ -3109,10 +3085,10 @@ bool FSlide::BounceTraverse(fixed_t startx, fixed_t starty, fixed_t endx, fixed_ bool FSlide::BounceWall(AActor *mo) { - fixed_t leadx, leady; + DVector2 lead; int side; - angle_t lineangle, moveangle, deltaangle; - fixed_t movelen; + DAngle lineangle, moveangle, deltaangle; + double movelen; line_t *line; if (!(mo->BounceFlags & BOUNCE_Walls)) @@ -3126,23 +3102,23 @@ bool FSlide::BounceWall(AActor *mo) // if (mo->Vel.X > 0) { - leadx = mo->_f_X() + mo->_f_radius(); + lead.X = mo->X() + mo->radius; } else { - leadx = mo->_f_X() - mo->_f_radius(); + lead.X = mo->X() - mo->radius; } if (mo->Vel.Y > 0) { - leady = mo->_f_Y() + mo->_f_radius(); + lead.Y = mo->Y() + mo->radius; } else { - leady = mo->_f_Y() - mo->_f_radius(); + lead.Y = mo->Y() - mo->radius; } - bestslidefrac = FRACUNIT + 1; + bestSlidefrac = 1.01; bestslideline = mo->BlockingLine; - if (BounceTraverse(leadx, leady, leadx + mo->_f_velx(), leady + mo->_f_vely()) && mo->BlockingLine == NULL) + if (BounceTraverse(lead, lead+mo->Vel.XY()) && mo->BlockingLine == NULL) { // Could not find a wall, so bounce off the floor/ceiling instead. double floordist = mo->Z() - mo->floorz; double ceildist = mo->ceilingz - mo->Z(); @@ -3176,36 +3152,33 @@ bool FSlide::BounceWall(AActor *mo) return true; } - side = P_PointOnLineSide(mo->_f_X(), mo->_f_Y(), line); - lineangle = R_PointToAngle2(0, 0, line->dx, line->dy); + side = P_PointOnLineSide(mo->Pos(), line); + lineangle = line->Delta().Angle(); if (side == 1) { - lineangle += ANG180; + lineangle += 180; } - moveangle = R_PointToAngle2(0, 0, mo->_f_velx(), mo->_f_vely()); - deltaangle = (2 * lineangle) - moveangle; - mo->Angles.Yaw = ANGLE2DBL(deltaangle); + moveangle = mo->Vel.Angle(); + deltaangle = (lineangle * 2) - moveangle; + mo->Angles.Yaw = deltaangle; - deltaangle >>= ANGLETOFINESHIFT; + movelen = mo->Vel.XY().Length() * mo->wallbouncefactor; - movelen = fixed_t(g_sqrt(double(mo->_f_velx())*mo->_f_velx() + double(mo->_f_vely())*mo->_f_vely())); - movelen = fixed_t(movelen * mo->wallbouncefactor); - - FBoundingBox box(mo->_f_X(), mo->_f_Y(), mo->_f_radius()); + FBoundingBox box(mo->X(), mo->Y(), mo->radius); if (box.BoxOnLineSide(line) == -1) { - fixedvec3 pos = mo->Vec3Offset( - FixedMul(mo->_f_radius(), finecosine[deltaangle]), - FixedMul(mo->_f_radius(), finesine[deltaangle]), 0); + DVector2 ofs = deltaangle.ToVector(mo->radius); + DVector3 pos = mo->Vec3Offset(ofs.X, ofs.Y, 0.); mo->SetOrigin(pos, true); } - if (movelen < FRACUNIT) + if (movelen < 1) { - movelen = 2 * FRACUNIT; + movelen = 2; } - mo->Vel.X = FIXED2DBL(FixedMul(movelen, finecosine[deltaangle])); - mo->Vel.Y = FIXED2DBL(FixedMul(movelen, finesine[deltaangle])); + DVector2 vel = deltaangle.ToVector(movelen); + mo->Vel.X = vel.X; + mo->Vel.Y = vel.Y; if (mo->BounceFlags & BOUNCE_UseBounceState) { FState *bouncestate = mo->FindState(NAME_Bounce, NAME_Wall); diff --git a/src/p_maputl.h b/src/p_maputl.h index b49149b21..eee499481 100644 --- a/src/p_maputl.h +++ b/src/p_maputl.h @@ -122,6 +122,14 @@ inline void P_MakeDivline (const line_t *li, fdivline_t *dl) dl->dy = li->dy; } +inline void P_MakeDivline(const line_t *li, divline_t *dl) +{ + dl->x = li->v1->fX(); + dl->y = li->v1->fY(); + dl->dx = li->Delta().X; + dl->dy = li->Delta().Y; +} + struct FLineOpening { double top; @@ -143,7 +151,7 @@ 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, const DVector2 &xy, const DVector3 *ref = NULL, int flags = 0) +inline void P_LineOpening(FLineOpening &open, AActor *thing, const line_t *linedef, const DVector2 &xy, const DVector3 *ref, int flags = 0) { P_LineOpening(open, thing, linedef, xy, reinterpret_cast(ref), flags); } diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index b218a5248..84a6ee1dc 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -1939,7 +1939,7 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) // killough 3/15/98: Allow objects to drop off fixed_t startvelx = mo->_f_velx(), startvely = mo->_f_vely(); - if (!P_TryMove (mo, ptryx, ptryy, true, walkplane, tm)) + if (!P_TryMove (mo, DVector2(FIXED2DBL(ptryx), FIXED2DBL(ptryy)), true, walkplane, tm)) { // blocked move AActor *BlockingMobj = mo->BlockingMobj; @@ -1972,11 +1972,11 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) // If the move is done a second time (because it was too fast for one move), it // is still clipped against the wall at its full speed, so you effectively // execute two moves in one tic. - P_SlideMove (mo, mo->_f_velx(), mo->_f_vely(), 1); + P_SlideMove (mo, mo->Vel, 1); } else { - P_SlideMove (mo, onestepx, onestepy, totalsteps); + P_SlideMove (mo, DVector2(FIXED2DBL(onestepx), FIXED2DBL(onestepy)), totalsteps); } if ((mo->_f_velx() | mo->_f_vely()) == 0) { @@ -2006,7 +2006,7 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) fixed_t tx, ty; tx = 0, ty = onestepy; walkplane = P_CheckSlopeWalk (mo, tx, ty); - if (P_TryMove (mo, mo->_f_X() + tx, mo->_f_Y() + ty, true, walkplane, tm)) + if (P_TryMove (mo, mo->Pos() + DVector2(FIXED2DBL(tx), FIXED2DBL(ty)), true, walkplane, tm)) { mo->Vel.X = 0; } @@ -2014,7 +2014,7 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) { tx = onestepx, ty = 0; walkplane = P_CheckSlopeWalk (mo, tx, ty); - if (P_TryMove (mo, mo->_f_X() + tx, mo->_f_Y() + ty, true, walkplane, tm)) + if (P_TryMove (mo, mo->Pos() + DVector2(FIXED2DBL(tx), FIXED2DBL(ty)), true, walkplane, tm)) { mo->Vel.Y = 0; } @@ -5744,7 +5744,7 @@ bool P_CheckMissileSpawn (AActor* th, double maxdist) bool MBFGrenade = (!(th->flags & MF_MISSILE) || (th->BounceFlags & BOUNCE_MBF)); // killough 3/15/98: no dropoff (really = don't care for missiles) - if (!(P_TryMove (th, th->_f_X(), th->_f_Y(), false, NULL, tm, true))) + if (!(P_TryMove (th, th->Pos(), false, NULL, tm, true))) { // [RH] Don't explode ripping missiles that spawn inside something if (th->BlockingMobj == NULL || !(th->flags2 & MF2_RIP) || (th->BlockingMobj->flags5 & MF5_DONTRIP)) diff --git a/src/po_man.cpp b/src/po_man.cpp index 91d4218ef..f083da738 100644 --- a/src/po_man.cpp +++ b/src/po_man.cpp @@ -899,8 +899,8 @@ void FPolyObj::ThrustMobj (AActor *actor, side_t *side) if (crush) { - fixedvec2 pos = actor->Vec2Offset(FLOAT2FIXED(thrust.X), FLOAT2FIXED(thrust.Y)); - if (bHurtOnTouch || !P_CheckMove (actor, pos.x, pos.y)) + DVector2 pos = actor->Vec2Offset(thrust.X, thrust.Y); + if (bHurtOnTouch || !P_CheckMove (actor, pos)) { int newdam = P_DamageMobj (actor, NULL, NULL, crush, NAME_Crush); P_TraceBleed (newdam > 0 ? newdam : crush, actor); diff --git a/src/portal.cpp b/src/portal.cpp index 81a8e4467..79470d410 100644 --- a/src/portal.cpp +++ b/src/portal.cpp @@ -205,8 +205,7 @@ FArchive &operator<< (FArchive &arc, FLinePortal &port) { arc << port.mOrigin << port.mDestination - << port.mXDisplacement - << port.mYDisplacement + << port.mDisplacement << port.mType << port.mFlags << port.mDefFlags @@ -385,8 +384,8 @@ void P_UpdatePortal(FLinePortal *port) } else { - port->mXDisplacement = port->mDestination->v2->x - port->mOrigin->v1->x; - port->mYDisplacement = port->mDestination->v2->y - port->mOrigin->v1->y; + port->mDisplacement.X = port->mDestination->v2->fX() - port->mOrigin->v1->fX(); + port->mDisplacement.Y = port->mDestination->v2->fY() - port->mOrigin->v1->fY(); } } } @@ -721,10 +720,10 @@ fixedvec2 P_GetOffsetPosition(fixed_t x, fixed_t y, fixed_t dx, fixed_t dy) if (port->mType == PORTT_LINKED) { // optimized handling for linked portals where we only need to add an offset. - hit.x += port->mXDisplacement; - hit.y += port->mYDisplacement; - dest.x += port->mXDisplacement; - dest.y += port->mYDisplacement; + hit.x += FLOAT2FIXED(port->mDisplacement.X); + hit.y += FLOAT2FIXED(port->mDisplacement.Y); + dest.x += FLOAT2FIXED(port->mDisplacement.X); + dest.y += FLOAT2FIXED(port->mDisplacement.Y); } else { @@ -851,13 +850,13 @@ static void AddDisplacementForPortal(FLinePortal *portal) FDisplacement & disp = Displacements(thisgroup, othergroup); if (!disp.isSet) { - disp.pos.x = portal->mXDisplacement; - disp.pos.y = portal->mYDisplacement; + disp.pos.x = FLOAT2FIXED(portal->mDisplacement.X); + disp.pos.y = FLOAT2FIXED(portal->mDisplacement.Y); disp.isSet = true; } else { - if (disp.pos.x != portal->mXDisplacement || disp.pos.y != portal->mYDisplacement) + if (disp.pos.x != FLOAT2FIXED(portal->mDisplacement.X) || disp.pos.y != FLOAT2FIXED(portal->mDisplacement.Y)) { Printf("Portal between lines %d and %d has displacement mismatch\n", int(portal->mOrigin - lines), int(portal->mDestination - lines)); portal->mType = linePortals[portal->mDestination->portalindex].mType = PORTT_TELEPORT; diff --git a/src/portal.h b/src/portal.h index 32844943c..935d6cf6c 100644 --- a/src/portal.h +++ b/src/portal.h @@ -185,8 +185,7 @@ struct FLinePortal { line_t *mOrigin; line_t *mDestination; - fixed_t mXDisplacement; - fixed_t mYDisplacement; + DVector2 mDisplacement; BYTE mType; BYTE mFlags; BYTE mDefFlags; diff --git a/src/r_utility.cpp b/src/r_utility.cpp index 810410e08..f76b32d53 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -82,7 +82,7 @@ static TArray PastViewers; static FRandom pr_torchflicker ("TorchFlicker"); static FRandom pr_hom; static bool NoInterpolateView; -static TArray InterpolationPath; +static TArray InterpolationPath; // PUBLIC DATA DEFINITIONS ------------------------------------------------- @@ -609,26 +609,26 @@ void R_InterpolateView (player_t *player, fixed_t frac, InterpolationViewer *ivi angle_t totaladiff = 0; fixed_t oviewz = iview->oviewz; fixed_t nviewz = iview->nviewz; - fixedvec3a oldpos = { iview->oviewx, iview->oviewy, 0, 0. }; - fixedvec3a newpos = { iview->nviewx, iview->nviewy, 0, 0. }; + DVector3a oldpos = { {FIXED2DBL(iview->oviewx), FIXED2DBL(iview->oviewy), 0.}, 0. }; + DVector3a newpos = { {FIXED2DBL(iview->nviewx), FIXED2DBL(iview->nviewy), 0. }, 0. }; InterpolationPath.Push(newpos); // add this to the array to simplify the loops below for (unsigned i = 0; i < InterpolationPath.Size(); i += 2) { - fixedvec3a &start = i == 0 ? oldpos : InterpolationPath[i - 1]; - fixedvec3a &end = InterpolationPath[i]; - pathlen += xs_CRoundToInt(DVector2(end.x - start.x, end.y - start.y).Length()); - totalzdiff += start.z; + DVector3a &start = i == 0 ? oldpos : InterpolationPath[i - 1]; + DVector3a &end = InterpolationPath[i]; + pathlen += FLOAT2FIXED((end.pos-start.pos).Length()); + totalzdiff += FLOAT2FIXED(start.pos.Z); totaladiff += FLOAT2ANGLE(start.angle.Degrees); } fixed_t interpolatedlen = FixedMul(frac, pathlen); for (unsigned i = 0; i < InterpolationPath.Size(); i += 2) { - fixedvec3a &start = i == 0 ? oldpos : InterpolationPath[i - 1]; - fixedvec3a &end = InterpolationPath[i]; - fixed_t fraglen = xs_CRoundToInt(DVector2(end.x - start.x, end.y - start.y).Length()); - zdiff += start.z; + DVector3a &start = i == 0 ? oldpos : InterpolationPath[i - 1]; + DVector3a &end = InterpolationPath[i]; + fixed_t fraglen = FLOAT2FIXED((end.pos - start.pos).Length()); + zdiff += FLOAT2FIXED(start.pos.Z); adiff += FLOAT2ANGLE(start.angle.Degrees); if (fraglen <= interpolatedlen) { @@ -636,13 +636,14 @@ void R_InterpolateView (player_t *player, fixed_t frac, InterpolationViewer *ivi } else { - fixed_t fragfrac = FixedDiv(interpolatedlen, fraglen); + double fragfrac = FIXED2DBL(FixedDiv(interpolatedlen, fraglen)); oviewz += zdiff; nviewz -= totalzdiff - zdiff; oviewangle += adiff; nviewangle -= totaladiff - adiff; - viewx = start.x + FixedMul(fragfrac, end.x - start.x); - viewy = start.y + FixedMul(fragfrac, end.y - start.y); + DVector2 viewpos = start.pos + (fragfrac * (end.pos - start.pos)); + viewx = FLOAT2FIXED(viewpos.X); + viewy = FLOAT2FIXED(viewpos.Y); viewz = oviewz + FixedMul(frac, nviewz - oviewz); break; } @@ -887,7 +888,7 @@ void R_ClearInterpolationPath() // //========================================================================== -void R_AddInterpolationPoint(const fixedvec3a &vec) +void R_AddInterpolationPoint(const DVector3a &vec) { InterpolationPath.Push(vec); } diff --git a/src/r_utility.h b/src/r_utility.h index dcfb31d65..ff7d552af 100644 --- a/src/r_utility.h +++ b/src/r_utility.h @@ -65,9 +65,9 @@ inline angle_t R_PointToAnglePrecise (fixed_t viewx, fixed_t viewy, fixed_t x, f } // Used for interpolation waypoints. -struct fixedvec3a +struct DVector3a { - fixed_t x, y, z; + DVector3 pos; DAngle angle; }; @@ -78,7 +78,7 @@ void R_ResetViewInterpolation (); void R_RebuildViewInterpolation(player_t *player); bool R_GetViewInterpolationStatus(); void R_ClearInterpolationPath(); -void R_AddInterpolationPoint(const fixedvec3a &vec); +void R_AddInterpolationPoint(const DVector3a &vec); void R_SetViewSize (int blocks); void R_SetFOV (float fov); float R_GetFOV (); diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 1a356796d..19cd555e6 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -6642,7 +6642,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckBlock) if (flags & CBF_DROPOFF) { mobj->SetZ(pos.Z); - checker = P_CheckMove(mobj, pos.X, pos.Y); + checker = P_CheckMove(mobj, pos); mobj->SetZ(oldpos.Z); } else