diff --git a/src/am_map.cpp b/src/am_map.cpp index 7c01b2a2f..2da1dee9c 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -2668,7 +2668,8 @@ void AM_drawPlayers () mline_t *arrow; int numarrowlines; - fixedvec2 pos = am_portaloverlay? players[consoleplayer].camera->GetPortalTransition(players[consoleplayer].viewheight) : (fixedvec2)players[consoleplayer].camera->_f_Pos(); + fixed_t vh = FLOAT2FIXED(players[consoleplayer].viewheight); + fixedvec2 pos = am_portaloverlay? players[consoleplayer].camera->GetPortalTransition(vh) : (fixedvec2)players[consoleplayer].camera->_f_Pos(); pt.x = pos.x >> FRACTOMAPBITS; pt.y = pos.y >> FRACTOMAPBITS; if (am_rotate == 1 || (am_rotate == 2 && viewactive)) @@ -3078,7 +3079,8 @@ void AM_Drawer () if (am_portaloverlay) { sector_t *sec; - players[consoleplayer].camera->GetPortalTransition(players[consoleplayer].viewheight, &sec); + fixed_t vh = FLOAT2FIXED(players[consoleplayer].viewheight); + players[consoleplayer].camera->GetPortalTransition(vh, &sec); MapPortalGroup = sec->PortalGroup; } else MapPortalGroup = 0; diff --git a/src/d_player.h b/src/d_player.h index 7a8a0944e..2a2c99027 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -152,7 +152,7 @@ public: double JumpZ; fixed_t GruntSpeed; fixed_t FallingScreamMinSpeed, FallingScreamMaxSpeed; - fixed_t ViewHeight; + double ViewHeight; double ForwardMove1, ForwardMove2; double SideMove1, SideMove2; FTextureID ScoreIcon; @@ -402,8 +402,8 @@ public: float DesiredFOV; // desired field of vision float FOV; // current field of vision - fixed_t viewz; // focal origin above r.z - fixed_t viewheight; // base height above floor for viewz + double viewz; // focal origin above r.z + double viewheight; // base height above floor for viewz double deltaviewheight; // squat speed. double bob; // bounded/scaled total velocity @@ -493,7 +493,7 @@ public: double crouchfactor; double crouchoffset; - fixed_t crouchviewdelta; + double crouchviewdelta; FWeaponSlots weapons; @@ -504,7 +504,7 @@ public: double GetDeltaViewHeight() const { - return FIXED2DBL((mo->ViewHeight + crouchviewdelta - viewheight) >> 3); + return (mo->ViewHeight + crouchviewdelta - viewheight) / 8; } void Uncrouch() diff --git a/src/fragglescript/t_cmd.cpp b/src/fragglescript/t_cmd.cpp index 7398558bb..c5f77776f 100644 --- a/src/fragglescript/t_cmd.cpp +++ b/src/fragglescript/t_cmd.cpp @@ -165,7 +165,7 @@ void FS_EmulateCmd(char * string) else if (sc.Compare("viewheight")) { sc.MustGetFloat(); - fixed_t playerviewheight = (fixed_t)(sc.Float*FRACUNIT); + double playerviewheight = sc.Float*FRACUNIT; for(int i=0;iIsKindOf (RUNTIME_CLASS (APlayerPawn))) { - static_cast(actor)->ViewHeight = value; + static_cast(actor)->ViewHeight = ACSToDouble(value); if (actor->player != NULL) { - actor->player->viewheight = value; + actor->player->viewheight = ACSToDouble(value); } } break; @@ -4093,7 +4093,7 @@ int DLevelScript::GetActorProperty (int tid, int property) case APROP_MeleeRange: return actor->meleerange; case APROP_ViewHeight: if (actor->IsKindOf (RUNTIME_CLASS (APlayerPawn))) { - return static_cast(actor)->ViewHeight; + return DoubleToACS(static_cast(actor)->ViewHeight); } else { @@ -4994,7 +4994,7 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, SDWORD *args) { if (actor->player != NULL) { - return actor->player->mo->ViewHeight + actor->player->crouchviewdelta; + return DoubleToACS(actor->player->mo->ViewHeight + actor->player->crouchviewdelta); } else { diff --git a/src/p_map.cpp b/src/p_map.cpp index 318f2b95f..b36517507 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -2236,9 +2236,7 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, // it slopes or the player's eyes are bobbing in and out. bool oldAboveFakeFloor, oldAboveFakeCeiling; - fixed_t viewheight; - - viewheight = thing->player ? thing->player->viewheight : thing->_f_height() / 2; + double _viewheight = thing->player ? thing->player->viewheight : thing->Height / 2; oldAboveFakeFloor = oldAboveFakeCeiling = false; // pacify GCC if (oldsec->heightsec) @@ -2350,7 +2348,7 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, { P_TranslatePortalXY(ld, hit.x, hit.y); P_TranslatePortalZ(ld, hit.z); - players[consoleplayer].viewz += hit.z; // needs to be done here because otherwise the renderer will not catch the change. + players[consoleplayer].viewz += FIXED2DBL(hit.z); // needs to be done here because otherwise the renderer will not catch the change. P_TranslatePortalAngle(ld, hit.angle); } R_AddInterpolationPoint(hit); @@ -5868,7 +5866,7 @@ void PIT_FloorRaise(AActor *thing, FChangePosition *cpos) } if (thing->player && thing->player->mo == thing) { - thing->player->viewz += thing->_f_Z() - oldz; + thing->player->viewz += thing->Z() - FIXED2DBL(oldz); } } @@ -5920,7 +5918,7 @@ void PIT_CeilingLower(AActor *thing, FChangePosition *cpos) } if (thing->player && thing->player->mo == thing) { - thing->player->viewz += thing->_f_Z() - oldz; + thing->player->viewz += thing->Z() - FIXED2DBL(oldz); } } @@ -5962,7 +5960,7 @@ void PIT_CeilingRaise(AActor *thing, FChangePosition *cpos) } if (thing->player && thing->player->mo == thing) { - thing->player->viewz += thing->_f_Z() - oldz; + thing->player->viewz += thing->Z() - FIXED2DBL(oldz); } } diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index c7090f60d..c62498c13 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -24,6 +24,7 @@ // HEADER FILES ------------------------------------------------------------ +#include #include "templates.h" #include "i_system.h" #include "m_random.h" @@ -1739,14 +1740,14 @@ bool P_SeekerMissile (AActor *actor, double thresh, double turnMax, bool precise DAngle pitch = 0.; if (!(actor->flags3 & (MF3_FLOORHUGGER|MF3_CEILINGHUGGER))) { // Need to seek vertically - fixed_t dist = MAX(1, FLOAT2FIXED(actor->Distance2D(target))); + double dist = MAX(1., actor->Distance2D(target)); // Aim at a player's eyes and at the middle of the actor for everything else. - fixed_t aimheight = target->_f_height()/2; + double aimheight = target->Height/2; if (target->IsKindOf(RUNTIME_CLASS(APlayerPawn))) { aimheight = static_cast(target)->ViewHeight; } - pitch = ANGLE2DBL(R_PointToAngle2(0, actor->_f_Z() + actor->_f_height()/2, dist, target->_f_Z() + aimheight)); + pitch = DVector2(dist, target->Z() + aimheight - actor->Center()).Angle(); } actor->Vel3DFromAngle(pitch, speed); } @@ -2335,7 +2336,7 @@ void P_ZMovement (AActor *mo, fixed_t oldfloorz) // if (mo->player && mo->player->mo == mo && mo->Z() < mo->floorz) { - mo->player->viewheight -= mo->_f_floorz() - mo->_f_Z(); + mo->player->viewheight -= mo->floorz - mo->Z(); mo->player->deltaviewheight = mo->player->GetDeltaViewHeight(); } @@ -2623,8 +2624,9 @@ void P_ZMovement (AActor *mo, fixed_t oldfloorz) P_CheckFakeFloorTriggers (mo, oldz); } -void P_CheckFakeFloorTriggers (AActor *mo, fixed_t oldz, bool oldz_has_viewheight) +void P_CheckFakeFloorTriggers (AActor *mo, fixed_t _oldz, bool oldz_has_viewheight) { + double oldz = FIXED2FLOAT(_oldz); if (mo->player && (mo->player->cheats & CF_PREDICTING)) { return; @@ -2638,9 +2640,9 @@ void P_CheckFakeFloorTriggers (AActor *mo, fixed_t oldz, bool oldz_has_viewheigh if (sec->heightsec != NULL && sec->SecActTarget != NULL) { sector_t *hs = sec->heightsec; - fixed_t waterz = hs->floorplane.ZatPoint(mo); - fixed_t newz; - fixed_t viewheight; + double waterz = hs->floorplane.ZatPointF(mo); + double newz; + double viewheight; if (mo->player != NULL) { @@ -2648,15 +2650,15 @@ void P_CheckFakeFloorTriggers (AActor *mo, fixed_t oldz, bool oldz_has_viewheigh } else { - viewheight = mo->_f_height() / 2; + viewheight = mo->Height; } - if (oldz > waterz && mo->_f_Z() <= waterz) + if (oldz > waterz && mo->Z() <= waterz) { // Feet hit fake floor sec->SecActTarget->TriggerAction (mo, SECSPAC_HitFakeFloor); } - newz = mo->_f_Z() + viewheight; + newz = mo->Z() + viewheight; if (!oldz_has_viewheight) { oldz += viewheight; @@ -2673,7 +2675,7 @@ void P_CheckFakeFloorTriggers (AActor *mo, fixed_t oldz, bool oldz_has_viewheigh if (!(hs->MoreFlags & SECF_FAKEFLOORONLY)) { - waterz = hs->ceilingplane.ZatPoint(mo); + waterz = hs->ceilingplane.ZatPointF(mo); if (oldz <= waterz && newz > waterz) { // View went above fake ceiling sec->SecActTarget->TriggerAction (mo, SECSPAC_EyesAboveC); @@ -3814,14 +3816,14 @@ void AActor::Tick () { if (player && player->mo == this) { - player->viewheight -= onmo->_f_Top() - _f_Z(); + player->viewheight -= onmo->Top() - Z(); double deltaview = player->GetDeltaViewHeight(); if (deltaview > player->deltaviewheight) { player->deltaviewheight = deltaview; } } - _f_SetZ(onmo->_f_Top()); + SetZ(onmo->Top()); } // Check for MF6_BUMPSPECIAL // By default, only players can activate things by bumping into them @@ -4023,7 +4025,7 @@ void AActor::CheckSectorTransition(sector_t *oldsec) bool AActor::UpdateWaterLevel (fixed_t oldz, bool dosplash) { BYTE lastwaterlevel = waterlevel; - fixed_t fh = FIXED_MIN; + double fh = -FLT_MAX; bool reset=false; waterlevel = 0; @@ -4042,23 +4044,23 @@ bool AActor::UpdateWaterLevel (fixed_t oldz, bool dosplash) const sector_t *hsec = Sector->GetHeightSec(); if (hsec != NULL) { - fh = hsec->floorplane.ZatPoint (this); + fh = hsec->floorplane.ZatPointF (this); //if (hsec->MoreFlags & SECF_UNDERWATERMASK) // also check Boom-style non-swimmable sectors { - if (_f_Z() < fh) + if (Z() < fh) { waterlevel = 1; - if (_f_Z() + _f_height()/2 < fh) + if (Center() < fh) { waterlevel = 2; - if ((player && _f_Z() + player->viewheight <= fh) || - (_f_Z() + _f_height() <= fh)) + if ((player && Z() + player->viewheight <= fh) || + (Top() <= fh)) { waterlevel = 3; } } } - else if (!(hsec->MoreFlags & SECF_FAKEFLOORONLY) && (_f_Top() > hsec->ceilingplane.ZatPoint (this))) + else if (!(hsec->MoreFlags & SECF_FAKEFLOORONLY) && (Top() > hsec->ceilingplane.ZatPointF (this))) { waterlevel = 3; } @@ -4084,20 +4086,20 @@ bool AActor::UpdateWaterLevel (fixed_t oldz, bool dosplash) if (!(rover->flags & FF_EXISTS)) continue; if(!(rover->flags & FF_SWIMMABLE) || rover->flags & FF_SOLID) continue; - fixed_t ff_bottom=rover->bottom.plane->ZatPoint(this); - fixed_t ff_top=rover->top.plane->ZatPoint(this); + double ff_bottom=rover->bottom.plane->ZatPointF(this); + double ff_top=rover->top.plane->ZatPointF(this); - if(ff_top <= _f_Z() || ff_bottom > (_f_Z() + (_f_height() >> 1))) continue; + if(ff_top <= Z() || ff_bottom > (Center())) continue; fh=ff_top; - if (_f_Z() < fh) + if (Z() < fh) { waterlevel = 1; - if (_f_Z() + _f_height()/2 < fh) + if (Center() < fh) { waterlevel = 2; - if ((player && _f_Z() + player->viewheight <= fh) || - (_f_Z() + _f_height() <= fh)) + if ((player && Z() + player->viewheight <= fh) || + (Top() <= fh)) { waterlevel = 3; } @@ -4113,7 +4115,7 @@ bool AActor::UpdateWaterLevel (fixed_t oldz, bool dosplash) // the water flags. if (boomwaterlevel == 0 && waterlevel != 0 && dosplash) { - P_HitWater(this, Sector, FIXED_MIN, FIXED_MIN, fh, true); + P_HitWater(this, Sector, FIXED_MIN, FIXED_MIN, FLOAT2FIXED(fh), true); } boomwaterlevel = waterlevel; if (reset) @@ -4551,7 +4553,7 @@ void AActor::AdjustFloorClip () } if (player && player->mo == this && oldclip != Floorclip) { - player->viewheight -= FLOAT2FIXED(oldclip - Floorclip); + player->viewheight -= (oldclip - Floorclip); player->deltaviewheight = player->GetDeltaViewHeight(); } } diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 45b490bf7..3c3bc91d9 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -24,6 +24,7 @@ #include +#include #ifdef _MSC_VER #include // for alloca() #endif @@ -3608,7 +3609,7 @@ void P_SetupLevel (const char *lumpname, int position) translationtables[TRANSLATION_LevelScripted].Clear(); // Initial height of PointOfView will be set by player think. - players[consoleplayer].viewz = 1; + players[consoleplayer].viewz = -FLT_MAX; // Make sure all sounds are stopped before Z_FreeTags. S_Start (); diff --git a/src/p_spec.cpp b/src/p_spec.cpp index 3d5e07638..1f20af78a 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -2205,7 +2205,7 @@ void DPusher::Tick () sector_t *sec; AActor *thing; msecnode_t *node; - int ht; + double ht; if (!var_pushers) return; @@ -2307,8 +2307,8 @@ void DPusher::Tick () } else // special water sector { - ht = hsec->floorplane.ZatPoint(pos); - if (thing->_f_Z() > ht) // above ground + ht = hsec->floorplane.ZatPointF(pos); + if (thing->Z() > ht) // above ground { pushvel = m_PushVec; // full force } @@ -2334,7 +2334,7 @@ void DPusher::Tick () { // special water sector floor = &hsec->floorplane; } - if (thing->_f_Z() > floor->ZatPoint(pos)) + if (thing->Z() > floor->ZatPointF(pos)) { // above ground pushvel.Zero(); // no force } diff --git a/src/p_teleport.cpp b/src/p_teleport.cpp index 1441ae39b..577438c20 100644 --- a/src/p_teleport.cpp +++ b/src/p_teleport.cpp @@ -168,7 +168,7 @@ bool P_Teleport (AActor *thing, fixed_t x, fixed_t y, fixed_t z, DAngle angle, i } if (player) { - player->viewz = thing->_f_Z() + player->viewheight; + player->viewz = thing->Z() + player->viewheight; if (resetpitch) { player->mo->Angles.Pitch = 0.; diff --git a/src/p_tick.cpp b/src/p_tick.cpp index 0c9550428..9aa48c147 100644 --- a/src/p_tick.cpp +++ b/src/p_tick.cpp @@ -21,7 +21,7 @@ // //----------------------------------------------------------------------------- - +#include #include "p_local.h" #include "p_effect.h" #include "c_console.h" @@ -57,7 +57,7 @@ bool P_CheckTickerPaused () ConsoleState == c_down || ConsoleState == c_falling) && !demoplayback && !demorecording - && players[consoleplayer].viewz != 1 + && players[consoleplayer].viewz != -FLT_MAX && wipegamestate == gamestate) { S_PauseSound (!(level.flags2 & LEVEL2_PAUSE_MUSIC_IN_MENUS), false); diff --git a/src/p_user.cpp b/src/p_user.cpp index 2409a7475..8a27c3ecb 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -1846,14 +1846,14 @@ void P_CalcHeight (player_t *player) } } - fixed_t defaultviewheight = player->mo->ViewHeight + player->crouchviewdelta; + double defaultviewheight = player->mo->ViewHeight + player->crouchviewdelta; if (player->cheats & CF_NOVELOCITY) { - player->viewz = player->mo->_f_Z() + defaultviewheight; + player->viewz = player->mo->Z() + defaultviewheight; - if (player->viewz > player->mo->_f_ceilingz()-4*FRACUNIT) - player->viewz = player->mo->_f_ceilingz()-4*FRACUNIT; + if (player->viewz > player->mo->ceilingz-4) + player->viewz = player->mo->ceilingz-4; return; } @@ -1879,16 +1879,16 @@ void P_CalcHeight (player_t *player) // move viewheight if (player->playerstate == PST_LIVE) { - player->viewheight += FLOAT2FIXED(player->deltaviewheight); + player->viewheight += player->deltaviewheight; if (player->viewheight > defaultviewheight) { player->viewheight = defaultviewheight; player->deltaviewheight = 0; } - else if (player->viewheight < (defaultviewheight>>1)) + else if (player->viewheight < (defaultviewheight/2)) { - player->viewheight = defaultviewheight>>1; + player->viewheight = defaultviewheight/2; if (player->deltaviewheight <= 0) player->deltaviewheight = 1 / 65536.; } @@ -1905,19 +1905,19 @@ void P_CalcHeight (player_t *player) { bob = 0; } - player->viewz = player->mo->_f_Z() + player->viewheight + FLOAT2FIXED(bob); + player->viewz = player->mo->Z() + player->viewheight + bob; if (player->mo->Floorclip && player->playerstate != PST_DEAD && player->mo->Z() <= player->mo->floorz) { - player->viewz -= player->mo->_f_floorclip(); + player->viewz -= player->mo->Floorclip; } - if (player->viewz > player->mo->_f_ceilingz() - 4*FRACUNIT) + if (player->viewz > player->mo->ceilingz - 4) { - player->viewz = player->mo->_f_ceilingz() - 4*FRACUNIT; + player->viewz = player->mo->ceilingz - 4; } - if (player->viewz < player->mo->_f_floorz() + 4*FRACUNIT) + if (player->viewz < player->mo->floorz + 4) { - player->viewz = player->mo->_f_floorz() + 4*FRACUNIT; + player->viewz = player->mo->floorz + 4; } } @@ -2141,7 +2141,7 @@ void P_DeathThink (player_t *player) player->onground = (player->mo->Z() <= player->mo->floorz); if (player->mo->IsKindOf (RUNTIME_CLASS(APlayerChunk))) { // Flying bloody skull or flying ice chunk - player->viewheight = 6 * FRACUNIT; + player->viewheight = 6; player->deltaviewheight = 0; if (player->onground) { @@ -2155,13 +2155,13 @@ void P_DeathThink (player_t *player) else if (!(player->mo->flags & MF_ICECORPSE)) { // Fall to ground (if not frozen) player->deltaviewheight = 0; - if (player->viewheight > 6*FRACUNIT) + if (player->viewheight > 6) { - player->viewheight -= FRACUNIT; + player->viewheight -= 1; } - if (player->viewheight < 6*FRACUNIT) + if (player->viewheight < 6) { - player->viewheight = 6*FRACUNIT; + player->viewheight = 6; } if (player->mo->Angles.Pitch < 0) { @@ -2244,14 +2244,14 @@ void P_CrouchMove(player_t * player, int direction) double defaultheight = player->mo->GetDefault()->Height; double savedheight = player->mo->Height; double crouchspeed = direction * CROUCHSPEED; - fixed_t oldheight = player->viewheight; + double oldheight = player->viewheight; player->crouchdir = (signed char) direction; player->crouchfactor += crouchspeed; // check whether the move is ok player->mo->Height = defaultheight * player->crouchfactor; - if (!P_TryMove(player->mo, player->mo->_f_X(), player->mo->_f_Y(), false, NULL)) + if (!P_TryMove(player->mo, player->mo->Pos(), false, NULL)) { player->mo->Height = savedheight; if (direction > 0) @@ -2264,11 +2264,11 @@ void P_CrouchMove(player_t * player, int direction) player->mo->Height = savedheight; player->crouchfactor = clamp(player->crouchfactor, 0.5, 1.); - player->viewheight = fixed_t(player->mo->ViewHeight * player->crouchfactor); + player->viewheight = player->mo->ViewHeight * player->crouchfactor; player->crouchviewdelta = player->viewheight - player->mo->ViewHeight; // Check for eyes going above/below fake floor due to crouching motion. - P_CheckFakeFloorTriggers(player->mo, player->mo->_f_Z() + oldheight, true); + P_CheckFakeFloorTriggers(player->mo, player->mo->_f_Z() + FLOAT2FIXED(oldheight), true); } //---------------------------------------------------------------------------- @@ -2430,7 +2430,7 @@ void P_PlayerThink (player_t *player) player->Uncrouch(); } - player->crouchoffset = -(FIXED2DBL(player->mo->ViewHeight) * (1 - player->crouchfactor)); + player->crouchoffset = -(player->mo->ViewHeight) * (1 - player->crouchfactor); // MUSINFO stuff if (player->MUSINFOtics >= 0 && player->MUSINFOactor != NULL) diff --git a/src/r_defs.h b/src/r_defs.h index 5f63045ca..241f66f61 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -258,6 +258,11 @@ struct secplane_t return FixedMul(ic, -d - DMulScale16(a, spot.x, b, spot.y)); } + double ZatPointF(const fixedvec3 &spot) const + { + return FIXED2DBL(FixedMul(ic, -d - DMulScale16(a, spot.x, b, spot.y))); + } + // Returns the value of z at (x,y) fixed_t ZatPoint (fixed_t x, fixed_t y) const { diff --git a/src/r_utility.cpp b/src/r_utility.cpp index f69427a1c..3bc2fee2e 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -985,7 +985,7 @@ void R_SetupFrame (AActor *actor) { iview->nviewx = camera->_f_X(); iview->nviewy = camera->_f_Y(); - iview->nviewz = camera->player ? camera->player->viewz : FLOAT2FIXED(camera->Z() + camera->GetCameraHeight()); + iview->nviewz = FLOAT2FIXED(camera->player ? camera->player->viewz : camera->Z() + camera->GetCameraHeight()); viewsector = camera->Sector; r_showviewer = false; } diff --git a/src/thingdef/thingdef_properties.cpp b/src/thingdef/thingdef_properties.cpp index 1d92a00e5..ebc89dc4a 100644 --- a/src/thingdef/thingdef_properties.cpp +++ b/src/thingdef/thingdef_properties.cpp @@ -2573,7 +2573,7 @@ DEFINE_CLASS_PROPERTY_PREFIX(player, spawnclass, L, PlayerPawn) //========================================================================== DEFINE_CLASS_PROPERTY_PREFIX(player, viewheight, F, PlayerPawn) { - PROP_FIXED_PARM(z, 0); + PROP_DOUBLE_PARM(z, 0); defaults->ViewHeight = z; }