- floatified viewheight variables and some related code.

This commit is contained in:
Christoph Oelckers 2016-03-22 18:06:08 +01:00
parent af427b80bd
commit 6b3c0ecbd3
14 changed files with 90 additions and 82 deletions

View file

@ -2668,7 +2668,8 @@ void AM_drawPlayers ()
mline_t *arrow; mline_t *arrow;
int numarrowlines; 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.x = pos.x >> FRACTOMAPBITS;
pt.y = pos.y >> FRACTOMAPBITS; pt.y = pos.y >> FRACTOMAPBITS;
if (am_rotate == 1 || (am_rotate == 2 && viewactive)) if (am_rotate == 1 || (am_rotate == 2 && viewactive))
@ -3078,7 +3079,8 @@ void AM_Drawer ()
if (am_portaloverlay) if (am_portaloverlay)
{ {
sector_t *sec; 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; MapPortalGroup = sec->PortalGroup;
} }
else MapPortalGroup = 0; else MapPortalGroup = 0;

View file

@ -152,7 +152,7 @@ public:
double JumpZ; double JumpZ;
fixed_t GruntSpeed; fixed_t GruntSpeed;
fixed_t FallingScreamMinSpeed, FallingScreamMaxSpeed; fixed_t FallingScreamMinSpeed, FallingScreamMaxSpeed;
fixed_t ViewHeight; double ViewHeight;
double ForwardMove1, ForwardMove2; double ForwardMove1, ForwardMove2;
double SideMove1, SideMove2; double SideMove1, SideMove2;
FTextureID ScoreIcon; FTextureID ScoreIcon;
@ -402,8 +402,8 @@ public:
float DesiredFOV; // desired field of vision float DesiredFOV; // desired field of vision
float FOV; // current field of vision float FOV; // current field of vision
fixed_t viewz; // focal origin above r.z double viewz; // focal origin above r.z
fixed_t viewheight; // base height above floor for viewz double viewheight; // base height above floor for viewz
double deltaviewheight; // squat speed. double deltaviewheight; // squat speed.
double bob; // bounded/scaled total velocity double bob; // bounded/scaled total velocity
@ -493,7 +493,7 @@ public:
double crouchfactor; double crouchfactor;
double crouchoffset; double crouchoffset;
fixed_t crouchviewdelta; double crouchviewdelta;
FWeaponSlots weapons; FWeaponSlots weapons;
@ -504,7 +504,7 @@ public:
double GetDeltaViewHeight() const double GetDeltaViewHeight() const
{ {
return FIXED2DBL((mo->ViewHeight + crouchviewdelta - viewheight) >> 3); return (mo->ViewHeight + crouchviewdelta - viewheight) / 8;
} }
void Uncrouch() void Uncrouch()

View file

@ -165,7 +165,7 @@ void FS_EmulateCmd(char * string)
else if (sc.Compare("viewheight")) else if (sc.Compare("viewheight"))
{ {
sc.MustGetFloat(); sc.MustGetFloat();
fixed_t playerviewheight = (fixed_t)(sc.Float*FRACUNIT); double playerviewheight = sc.Float*FRACUNIT;
for(int i=0;i<MAXPLAYERS;i++) for(int i=0;i<MAXPLAYERS;i++)
{ {
// No, this is not correct. But this is the way Legacy WADs expect it to be handled! // No, this is not correct. But this is the way Legacy WADs expect it to be handled!

View file

@ -3998,10 +3998,10 @@ void DLevelScript::DoSetActorProperty (AActor *actor, int property, int value)
case APROP_ViewHeight: case APROP_ViewHeight:
if (actor->IsKindOf (RUNTIME_CLASS (APlayerPawn))) if (actor->IsKindOf (RUNTIME_CLASS (APlayerPawn)))
{ {
static_cast<APlayerPawn *>(actor)->ViewHeight = value; static_cast<APlayerPawn *>(actor)->ViewHeight = ACSToDouble(value);
if (actor->player != NULL) if (actor->player != NULL)
{ {
actor->player->viewheight = value; actor->player->viewheight = ACSToDouble(value);
} }
} }
break; break;
@ -4093,7 +4093,7 @@ int DLevelScript::GetActorProperty (int tid, int property)
case APROP_MeleeRange: return actor->meleerange; case APROP_MeleeRange: return actor->meleerange;
case APROP_ViewHeight: if (actor->IsKindOf (RUNTIME_CLASS (APlayerPawn))) case APROP_ViewHeight: if (actor->IsKindOf (RUNTIME_CLASS (APlayerPawn)))
{ {
return static_cast<APlayerPawn *>(actor)->ViewHeight; return DoubleToACS(static_cast<APlayerPawn *>(actor)->ViewHeight);
} }
else else
{ {
@ -4994,7 +4994,7 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, SDWORD *args)
{ {
if (actor->player != NULL) if (actor->player != NULL)
{ {
return actor->player->mo->ViewHeight + actor->player->crouchviewdelta; return DoubleToACS(actor->player->mo->ViewHeight + actor->player->crouchviewdelta);
} }
else else
{ {

View file

@ -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. // it slopes or the player's eyes are bobbing in and out.
bool oldAboveFakeFloor, oldAboveFakeCeiling; bool oldAboveFakeFloor, oldAboveFakeCeiling;
fixed_t viewheight; double _viewheight = thing->player ? thing->player->viewheight : thing->Height / 2;
viewheight = thing->player ? thing->player->viewheight : thing->_f_height() / 2;
oldAboveFakeFloor = oldAboveFakeCeiling = false; // pacify GCC oldAboveFakeFloor = oldAboveFakeCeiling = false; // pacify GCC
if (oldsec->heightsec) 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_TranslatePortalXY(ld, hit.x, hit.y);
P_TranslatePortalZ(ld, hit.z); 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); P_TranslatePortalAngle(ld, hit.angle);
} }
R_AddInterpolationPoint(hit); R_AddInterpolationPoint(hit);
@ -5868,7 +5866,7 @@ void PIT_FloorRaise(AActor *thing, FChangePosition *cpos)
} }
if (thing->player && thing->player->mo == thing) 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) 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) if (thing->player && thing->player->mo == thing)
{ {
thing->player->viewz += thing->_f_Z() - oldz; thing->player->viewz += thing->Z() - FIXED2DBL(oldz);
} }
} }

View file

@ -24,6 +24,7 @@
// HEADER FILES ------------------------------------------------------------ // HEADER FILES ------------------------------------------------------------
#include <float.h>
#include "templates.h" #include "templates.h"
#include "i_system.h" #include "i_system.h"
#include "m_random.h" #include "m_random.h"
@ -1739,14 +1740,14 @@ bool P_SeekerMissile (AActor *actor, double thresh, double turnMax, bool precise
DAngle pitch = 0.; DAngle pitch = 0.;
if (!(actor->flags3 & (MF3_FLOORHUGGER|MF3_CEILINGHUGGER))) if (!(actor->flags3 & (MF3_FLOORHUGGER|MF3_CEILINGHUGGER)))
{ // Need to seek vertically { // 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. // 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))) if (target->IsKindOf(RUNTIME_CLASS(APlayerPawn)))
{ {
aimheight = static_cast<APlayerPawn *>(target)->ViewHeight; aimheight = static_cast<APlayerPawn *>(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); 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) 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(); mo->player->deltaviewheight = mo->player->GetDeltaViewHeight();
} }
@ -2623,8 +2624,9 @@ void P_ZMovement (AActor *mo, fixed_t oldfloorz)
P_CheckFakeFloorTriggers (mo, oldz); 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)) if (mo->player && (mo->player->cheats & CF_PREDICTING))
{ {
return; return;
@ -2638,9 +2640,9 @@ void P_CheckFakeFloorTriggers (AActor *mo, fixed_t oldz, bool oldz_has_viewheigh
if (sec->heightsec != NULL && sec->SecActTarget != NULL) if (sec->heightsec != NULL && sec->SecActTarget != NULL)
{ {
sector_t *hs = sec->heightsec; sector_t *hs = sec->heightsec;
fixed_t waterz = hs->floorplane.ZatPoint(mo); double waterz = hs->floorplane.ZatPointF(mo);
fixed_t newz; double newz;
fixed_t viewheight; double viewheight;
if (mo->player != NULL) if (mo->player != NULL)
{ {
@ -2648,15 +2650,15 @@ void P_CheckFakeFloorTriggers (AActor *mo, fixed_t oldz, bool oldz_has_viewheigh
} }
else 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 { // Feet hit fake floor
sec->SecActTarget->TriggerAction (mo, SECSPAC_HitFakeFloor); sec->SecActTarget->TriggerAction (mo, SECSPAC_HitFakeFloor);
} }
newz = mo->_f_Z() + viewheight; newz = mo->Z() + viewheight;
if (!oldz_has_viewheight) if (!oldz_has_viewheight)
{ {
oldz += viewheight; oldz += viewheight;
@ -2673,7 +2675,7 @@ void P_CheckFakeFloorTriggers (AActor *mo, fixed_t oldz, bool oldz_has_viewheigh
if (!(hs->MoreFlags & SECF_FAKEFLOORONLY)) if (!(hs->MoreFlags & SECF_FAKEFLOORONLY))
{ {
waterz = hs->ceilingplane.ZatPoint(mo); waterz = hs->ceilingplane.ZatPointF(mo);
if (oldz <= waterz && newz > waterz) if (oldz <= waterz && newz > waterz)
{ // View went above fake ceiling { // View went above fake ceiling
sec->SecActTarget->TriggerAction (mo, SECSPAC_EyesAboveC); sec->SecActTarget->TriggerAction (mo, SECSPAC_EyesAboveC);
@ -3814,14 +3816,14 @@ void AActor::Tick ()
{ {
if (player && player->mo == this) if (player && player->mo == this)
{ {
player->viewheight -= onmo->_f_Top() - _f_Z(); player->viewheight -= onmo->Top() - Z();
double deltaview = player->GetDeltaViewHeight(); double deltaview = player->GetDeltaViewHeight();
if (deltaview > player->deltaviewheight) if (deltaview > player->deltaviewheight)
{ {
player->deltaviewheight = deltaview; player->deltaviewheight = deltaview;
} }
} }
_f_SetZ(onmo->_f_Top()); SetZ(onmo->Top());
} }
// Check for MF6_BUMPSPECIAL // Check for MF6_BUMPSPECIAL
// By default, only players can activate things by bumping into them // 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) bool AActor::UpdateWaterLevel (fixed_t oldz, bool dosplash)
{ {
BYTE lastwaterlevel = waterlevel; BYTE lastwaterlevel = waterlevel;
fixed_t fh = FIXED_MIN; double fh = -FLT_MAX;
bool reset=false; bool reset=false;
waterlevel = 0; waterlevel = 0;
@ -4042,23 +4044,23 @@ bool AActor::UpdateWaterLevel (fixed_t oldz, bool dosplash)
const sector_t *hsec = Sector->GetHeightSec(); const sector_t *hsec = Sector->GetHeightSec();
if (hsec != NULL) 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 (hsec->MoreFlags & SECF_UNDERWATERMASK) // also check Boom-style non-swimmable sectors
{ {
if (_f_Z() < fh) if (Z() < fh)
{ {
waterlevel = 1; waterlevel = 1;
if (_f_Z() + _f_height()/2 < fh) if (Center() < fh)
{ {
waterlevel = 2; waterlevel = 2;
if ((player && _f_Z() + player->viewheight <= fh) || if ((player && Z() + player->viewheight <= fh) ||
(_f_Z() + _f_height() <= fh)) (Top() <= fh))
{ {
waterlevel = 3; 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; waterlevel = 3;
} }
@ -4084,20 +4086,20 @@ bool AActor::UpdateWaterLevel (fixed_t oldz, bool dosplash)
if (!(rover->flags & FF_EXISTS)) continue; if (!(rover->flags & FF_EXISTS)) continue;
if(!(rover->flags & FF_SWIMMABLE) || rover->flags & FF_SOLID) continue; if(!(rover->flags & FF_SWIMMABLE) || rover->flags & FF_SOLID) continue;
fixed_t ff_bottom=rover->bottom.plane->ZatPoint(this); double ff_bottom=rover->bottom.plane->ZatPointF(this);
fixed_t ff_top=rover->top.plane->ZatPoint(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; fh=ff_top;
if (_f_Z() < fh) if (Z() < fh)
{ {
waterlevel = 1; waterlevel = 1;
if (_f_Z() + _f_height()/2 < fh) if (Center() < fh)
{ {
waterlevel = 2; waterlevel = 2;
if ((player && _f_Z() + player->viewheight <= fh) || if ((player && Z() + player->viewheight <= fh) ||
(_f_Z() + _f_height() <= fh)) (Top() <= fh))
{ {
waterlevel = 3; waterlevel = 3;
} }
@ -4113,7 +4115,7 @@ bool AActor::UpdateWaterLevel (fixed_t oldz, bool dosplash)
// the water flags. // the water flags.
if (boomwaterlevel == 0 && waterlevel != 0 && dosplash) 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; boomwaterlevel = waterlevel;
if (reset) if (reset)
@ -4551,7 +4553,7 @@ void AActor::AdjustFloorClip ()
} }
if (player && player->mo == this && oldclip != Floorclip) if (player && player->mo == this && oldclip != Floorclip)
{ {
player->viewheight -= FLOAT2FIXED(oldclip - Floorclip); player->viewheight -= (oldclip - Floorclip);
player->deltaviewheight = player->GetDeltaViewHeight(); player->deltaviewheight = player->GetDeltaViewHeight();
} }
} }

View file

@ -24,6 +24,7 @@
#include <math.h> #include <math.h>
#include <float.h>
#ifdef _MSC_VER #ifdef _MSC_VER
#include <malloc.h> // for alloca() #include <malloc.h> // for alloca()
#endif #endif
@ -3608,7 +3609,7 @@ void P_SetupLevel (const char *lumpname, int position)
translationtables[TRANSLATION_LevelScripted].Clear(); translationtables[TRANSLATION_LevelScripted].Clear();
// Initial height of PointOfView will be set by player think. // 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. // Make sure all sounds are stopped before Z_FreeTags.
S_Start (); S_Start ();

View file

@ -2205,7 +2205,7 @@ void DPusher::Tick ()
sector_t *sec; sector_t *sec;
AActor *thing; AActor *thing;
msecnode_t *node; msecnode_t *node;
int ht; double ht;
if (!var_pushers) if (!var_pushers)
return; return;
@ -2307,8 +2307,8 @@ void DPusher::Tick ()
} }
else // special water sector else // special water sector
{ {
ht = hsec->floorplane.ZatPoint(pos); ht = hsec->floorplane.ZatPointF(pos);
if (thing->_f_Z() > ht) // above ground if (thing->Z() > ht) // above ground
{ {
pushvel = m_PushVec; // full force pushvel = m_PushVec; // full force
} }
@ -2334,7 +2334,7 @@ void DPusher::Tick ()
{ // special water sector { // special water sector
floor = &hsec->floorplane; floor = &hsec->floorplane;
} }
if (thing->_f_Z() > floor->ZatPoint(pos)) if (thing->Z() > floor->ZatPointF(pos))
{ // above ground { // above ground
pushvel.Zero(); // no force pushvel.Zero(); // no force
} }

View file

@ -168,7 +168,7 @@ bool P_Teleport (AActor *thing, fixed_t x, fixed_t y, fixed_t z, DAngle angle, i
} }
if (player) if (player)
{ {
player->viewz = thing->_f_Z() + player->viewheight; player->viewz = thing->Z() + player->viewheight;
if (resetpitch) if (resetpitch)
{ {
player->mo->Angles.Pitch = 0.; player->mo->Angles.Pitch = 0.;

View file

@ -21,7 +21,7 @@
// //
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#include <float.h>
#include "p_local.h" #include "p_local.h"
#include "p_effect.h" #include "p_effect.h"
#include "c_console.h" #include "c_console.h"
@ -57,7 +57,7 @@ bool P_CheckTickerPaused ()
ConsoleState == c_down || ConsoleState == c_falling) ConsoleState == c_down || ConsoleState == c_falling)
&& !demoplayback && !demoplayback
&& !demorecording && !demorecording
&& players[consoleplayer].viewz != 1 && players[consoleplayer].viewz != -FLT_MAX
&& wipegamestate == gamestate) && wipegamestate == gamestate)
{ {
S_PauseSound (!(level.flags2 & LEVEL2_PAUSE_MUSIC_IN_MENUS), false); S_PauseSound (!(level.flags2 & LEVEL2_PAUSE_MUSIC_IN_MENUS), false);

View file

@ -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) 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) if (player->viewz > player->mo->ceilingz-4)
player->viewz = player->mo->_f_ceilingz()-4*FRACUNIT; player->viewz = player->mo->ceilingz-4;
return; return;
} }
@ -1879,16 +1879,16 @@ void P_CalcHeight (player_t *player)
// move viewheight // move viewheight
if (player->playerstate == PST_LIVE) if (player->playerstate == PST_LIVE)
{ {
player->viewheight += FLOAT2FIXED(player->deltaviewheight); player->viewheight += player->deltaviewheight;
if (player->viewheight > defaultviewheight) if (player->viewheight > defaultviewheight)
{ {
player->viewheight = defaultviewheight; player->viewheight = defaultviewheight;
player->deltaviewheight = 0; 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) if (player->deltaviewheight <= 0)
player->deltaviewheight = 1 / 65536.; player->deltaviewheight = 1 / 65536.;
} }
@ -1905,19 +1905,19 @@ void P_CalcHeight (player_t *player)
{ {
bob = 0; 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 if (player->mo->Floorclip && player->playerstate != PST_DEAD
&& player->mo->Z() <= player->mo->floorz) && 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); player->onground = (player->mo->Z() <= player->mo->floorz);
if (player->mo->IsKindOf (RUNTIME_CLASS(APlayerChunk))) if (player->mo->IsKindOf (RUNTIME_CLASS(APlayerChunk)))
{ // Flying bloody skull or flying ice chunk { // Flying bloody skull or flying ice chunk
player->viewheight = 6 * FRACUNIT; player->viewheight = 6;
player->deltaviewheight = 0; player->deltaviewheight = 0;
if (player->onground) if (player->onground)
{ {
@ -2155,13 +2155,13 @@ void P_DeathThink (player_t *player)
else if (!(player->mo->flags & MF_ICECORPSE)) else if (!(player->mo->flags & MF_ICECORPSE))
{ // Fall to ground (if not frozen) { // Fall to ground (if not frozen)
player->deltaviewheight = 0; 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) 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 defaultheight = player->mo->GetDefault()->Height;
double savedheight = player->mo->Height; double savedheight = player->mo->Height;
double crouchspeed = direction * CROUCHSPEED; double crouchspeed = direction * CROUCHSPEED;
fixed_t oldheight = player->viewheight; double oldheight = player->viewheight;
player->crouchdir = (signed char) direction; player->crouchdir = (signed char) direction;
player->crouchfactor += crouchspeed; player->crouchfactor += crouchspeed;
// check whether the move is ok // check whether the move is ok
player->mo->Height = defaultheight * player->crouchfactor; 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; player->mo->Height = savedheight;
if (direction > 0) if (direction > 0)
@ -2264,11 +2264,11 @@ void P_CrouchMove(player_t * player, int direction)
player->mo->Height = savedheight; player->mo->Height = savedheight;
player->crouchfactor = clamp(player->crouchfactor, 0.5, 1.); 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; player->crouchviewdelta = player->viewheight - player->mo->ViewHeight;
// Check for eyes going above/below fake floor due to crouching motion. // 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->Uncrouch();
} }
player->crouchoffset = -(FIXED2DBL(player->mo->ViewHeight) * (1 - player->crouchfactor)); player->crouchoffset = -(player->mo->ViewHeight) * (1 - player->crouchfactor);
// MUSINFO stuff // MUSINFO stuff
if (player->MUSINFOtics >= 0 && player->MUSINFOactor != NULL) if (player->MUSINFOtics >= 0 && player->MUSINFOactor != NULL)

View file

@ -258,6 +258,11 @@ struct secplane_t
return FixedMul(ic, -d - DMulScale16(a, spot.x, b, spot.y)); 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) // Returns the value of z at (x,y)
fixed_t ZatPoint (fixed_t x, fixed_t y) const fixed_t ZatPoint (fixed_t x, fixed_t y) const
{ {

View file

@ -985,7 +985,7 @@ void R_SetupFrame (AActor *actor)
{ {
iview->nviewx = camera->_f_X(); iview->nviewx = camera->_f_X();
iview->nviewy = camera->_f_Y(); 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; viewsector = camera->Sector;
r_showviewer = false; r_showviewer = false;
} }

View file

@ -2573,7 +2573,7 @@ DEFINE_CLASS_PROPERTY_PREFIX(player, spawnclass, L, PlayerPawn)
//========================================================================== //==========================================================================
DEFINE_CLASS_PROPERTY_PREFIX(player, viewheight, F, PlayerPawn) DEFINE_CLASS_PROPERTY_PREFIX(player, viewheight, F, PlayerPawn)
{ {
PROP_FIXED_PARM(z, 0); PROP_DOUBLE_PARM(z, 0);
defaults->ViewHeight = z; defaults->ViewHeight = z;
} }