From 3923039a1bbda2f910ba7af11a74b79b514ac623 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 7 Apr 2016 01:16:07 +0200 Subject: [PATCH 01/11] - fixed: a sight check that starts right on a linedef should ignore that linedef. Trying to calculate a slope to the target from this linedef's opening will always result in failure because it'd involve a division by zero. --- src/p_sight.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/p_sight.cpp b/src/p_sight.cpp index f8d2043fd..847448185 100644 --- a/src/p_sight.cpp +++ b/src/p_sight.cpp @@ -216,6 +216,9 @@ bool SightCheck::PTR_SightTraverse (intercept_t *in) if (open.range == 0 && open.portalflags == 0 && (lport == NULL || lport->mType != PORTT_LINKED)) // quick test for totally closed doors (must be delayed if portal checks are needed, though) return false; // stop + if (in->frac == 0) + return true; + // check bottom if (open.bottom > LINEOPEN_MIN) { From 4b10177e46e0473c8f6f6179e8e58040db527289 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Wed, 6 Apr 2016 20:09:12 -0500 Subject: [PATCH 02/11] Make the firelines fudging more "streamlined" --- src/p_setup.cpp | 10 +++------- src/r_defs.h | 5 +++++ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 89ca3a799..b88e3e2a0 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -1320,19 +1320,15 @@ void P_LoadSegs (MapData * map) if (delta_angle >= 1.) { double dis = (li->v2->fPos() - li->v1->fPos()).Length(); - DVector2 delta = seg_angle.ToVector(); + DVector2 delta = seg_angle.ToVector(dis); if ((vnum2 > vnum1) && (vertchanged[vnum2] == 0)) { - li->v2->set( - li->v1->fX() + dis * delta.X, - li->v1->fY() + dis * delta.Y); + li->v2->set(li->v1->fPos() + delta); vertchanged[vnum2] = 1; // this was changed } else if (vertchanged[vnum1] == 0) { - li->v1->set( - li->v2->fX() - dis * delta.X, - li->v2->fY() - dis * delta.Y); + li->v1->set(li->v2->fPos() - delta); vertchanged[vnum1] = 1; // this was changed } } diff --git a/src/r_defs.h b/src/r_defs.h index 2719ff7ee..6b2aa79a3 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -118,6 +118,11 @@ public: p.Y = y; } + void set(const DVector2 &pos) + { + p = pos; + } + double fX() const { return p.X; From 5409ada0e36bcfc9e71f39e6583e59fddf18e174 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 7 Apr 2016 10:26:19 +0200 Subject: [PATCH 03/11] let WM_DISPLAYCHANGE and WM_STYLECHANGED call DefWindowProc. At least on GZDoom it seems to be important on some systems. --- src/win32/i_input.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/win32/i_input.cpp b/src/win32/i_input.cpp index 2251e5275..2b0659c83 100644 --- a/src/win32/i_input.cpp +++ b/src/win32/i_input.cpp @@ -531,7 +531,7 @@ LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) SpawnEAXWindow = false; ShowEAXEditor (); } - break; + return DefWindowProc(hWnd, message, wParam, lParam); case WM_GETMINMAXINFO: if (screen && !VidResizing) From 14b370df66fb50d0247b3ec4d5796ea5a6597a8a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 7 Apr 2016 10:39:15 +0200 Subject: [PATCH 04/11] - fixed automap rotation to point upward, not downward when am_rotate is on. --- src/am_map.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/am_map.cpp b/src/am_map.cpp index 58082a7bf..76f6270fa 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -1191,7 +1191,7 @@ void AM_changeWindowLoc () oincy = incy = m_paninc.y * SCREENHEIGHT / 200; if (am_rotate == 1 || (am_rotate == 2 && viewactive)) { - AM_rotate(&incx, &incy, players[consoleplayer].camera->Angles.Yaw - 90.); + AM_rotate(&incx, &incy, players[consoleplayer].camera->Angles.Yaw + 90.); } m_x += incx; @@ -1573,7 +1573,7 @@ void AM_doFollowPlayer () sy = (f_oldloc.y - players[consoleplayer].camera->Y()); if (am_rotate == 1 || (am_rotate == 2 && viewactive)) { - AM_rotate (&sx, &sy, players[consoleplayer].camera->Angles.Yaw - 90); + AM_rotate (&sx, &sy, players[consoleplayer].camera->Angles.Yaw + 90); } AM_ScrollParchment (sx, sy); @@ -2559,7 +2559,7 @@ void AM_rotatePoint (double *x, double *y) double pivoty = m_y + m_h/2; *x -= pivotx; *y -= pivoty; - AM_rotate (x, y, -players[consoleplayer].camera->Angles.Yaw - 90.); + AM_rotate (x, y, -players[consoleplayer].camera->Angles.Yaw + 90.); *x += pivotx; *y += pivoty; } @@ -2645,7 +2645,7 @@ void AM_drawPlayers () pt.y = pos.Y; if (am_rotate == 1 || (am_rotate == 2 && viewactive)) { - angle = -90.; + angle = 90.; AM_rotatePoint (&pt.x, &pt.y); } else @@ -2713,7 +2713,7 @@ void AM_drawPlayers () if (am_rotate == 1 || (am_rotate == 2 && viewactive)) { AM_rotatePoint (&pt.x, &pt.y); - angle -= players[consoleplayer].camera->Angles.Yaw - 90.; + angle -= players[consoleplayer].camera->Angles.Yaw + 90.; } AM_drawLineCharacter(&MapArrow[0], MapArrow.Size(), 0, angle, color, pt.x, pt.y); @@ -2802,7 +2802,7 @@ void AM_drawThings () const size_t spriteIndex = sprite.spriteframes + (show > 1 ? t->frame : 0); frame = &SpriteFrames[spriteIndex]; - DAngle angle = -t->Angles.Yaw + 270.; + DAngle angle = -t->Angles.Yaw + 90.; if (frame->Texture[0] != frame->Texture[1]) angle += 180. / 16; if (am_rotate == 1 || (am_rotate == 2 && viewactive)) { @@ -2830,7 +2830,7 @@ void AM_drawThings () if (am_rotate == 1 || (am_rotate == 2 && viewactive)) { AM_rotatePoint (&p.x, &p.y); - angle += -players[consoleplayer].camera->Angles.Yaw - 90.; + angle += -players[consoleplayer].camera->Angles.Yaw + 90.; } color = AMColors[AMColors.ThingColor]; From 7f23a91488b97989957132082852a72feb3dbec7 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 7 Apr 2016 11:14:39 +0200 Subject: [PATCH 05/11] - fixed: smooth bobbing uses the full angular range to calculate its position. --- src/p_pspr.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_pspr.cpp b/src/p_pspr.cpp index ed4c97409..59399dd00 100644 --- a/src/p_pspr.cpp +++ b/src/p_pspr.cpp @@ -443,12 +443,12 @@ void P_BobWeapon (player_t *player, pspdef_t *psp, float *x, float *y) case AWeapon::BobSmooth: *x = bobx*angle.Cos(); - *y = 0.5f * (boby * (1.f - fabsf((angle * 2).Cos()))); + *y = 0.5f * (boby * (1.f - ((angle * 2).Cos()))); break; case AWeapon::BobInverseSmooth: *x = bobx*angle.Cos(); - *y = 0.5f * (boby * (1.f + fabsf((angle * 2).Cos()))); + *y = 0.5f * (boby * (1.f + ((angle * 2).Cos()))); } } else From 7ebb961917ba87a09dbd02028c064f4e5b55ebf9 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 7 Apr 2016 11:48:23 +0200 Subject: [PATCH 06/11] - added weapon bobbing interpolation. This was so ridiculously simple that I really fail to understand why the previous attempt was so overcomplicated that it just failed for that. --- src/p_pspr.cpp | 118 +++++++++++++++++++++++++---------------------- src/p_pspr.h | 2 +- src/r_things.cpp | 2 +- 3 files changed, 64 insertions(+), 58 deletions(-) diff --git a/src/p_pspr.cpp b/src/p_pspr.cpp index 59399dd00..d7da8fa4c 100644 --- a/src/p_pspr.cpp +++ b/src/p_pspr.cpp @@ -367,9 +367,10 @@ void P_DropWeapon (player_t *player) // //============================================================================ -void P_BobWeapon (player_t *player, pspdef_t *psp, float *x, float *y) +void P_BobWeapon (player_t *player, pspdef_t *psp, float *x, float *y, double ticfrac) { static float curbob; + double xx[2], yy[2]; AWeapon *weapon; float bobtarget; @@ -388,74 +389,79 @@ void P_BobWeapon (player_t *player, pspdef_t *psp, float *x, float *y) float Rangex = weapon->BobRangeX; float Rangey = weapon->BobRangeY; - // Bob the weapon based on movement speed. - FAngle angle = (BobSpeed * 35 / TICRATE*level.time) * (360.f / 8192.f); - - // [RH] Smooth transitions between bobbing and not-bobbing frames. - // This also fixes the bug where you can "stick" a weapon off-center by - // shooting it when it's at the peak of its swing. - bobtarget = float((player->WeaponState & WF_WEAPONBOBBING) ? player->bob : 0.); - if (curbob != bobtarget) + for (int i = 0; i < 2; i++) { - if (fabsf (bobtarget - curbob) <= 1) + // Bob the weapon based on movement speed. + FAngle angle = (BobSpeed * 35 / TICRATE*(level.time - 1 + i)) * (360.f / 8192.f); + + // [RH] Smooth transitions between bobbing and not-bobbing frames. + // This also fixes the bug where you can "stick" a weapon off-center by + // shooting it when it's at the peak of its swing. + bobtarget = float((player->WeaponState & WF_WEAPONBOBBING) ? player->bob : 0.); + if (curbob != bobtarget) { - curbob = bobtarget; - } - else - { - float zoom = MAX (1.f, fabsf (curbob - bobtarget) / 40); - if (curbob > bobtarget) + if (fabsf(bobtarget - curbob) <= 1) { - curbob -= zoom; + curbob = bobtarget; } else { - curbob += zoom; + float zoom = MAX(1.f, fabsf(curbob - bobtarget) / 40); + if (curbob > bobtarget) + { + curbob -= zoom; + } + else + { + curbob += zoom; + } } } - } - if (curbob != 0) - { - float bobx = float(player->bob * Rangex); - float boby = float(player->bob * Rangey); - switch (bobstyle) + if (curbob != 0) { - case AWeapon::BobNormal: - *x = bobx * angle.Cos(); - *y = boby * fabsf(angle.Sin()); - break; - - case AWeapon::BobInverse: - *x = bobx*angle.Cos(); - *y = boby * (1.f - fabsf(angle.Sin())); - break; - - case AWeapon::BobAlpha: - *x = bobx * angle.Sin(); - *y = boby * fabsf(angle.Sin()); - break; - - case AWeapon::BobInverseAlpha: - *x = bobx * angle.Sin(); - *y = boby * (1.f - fabsf(angle.Sin())); - break; - - case AWeapon::BobSmooth: - *x = bobx*angle.Cos(); - *y = 0.5f * (boby * (1.f - ((angle * 2).Cos()))); - break; + float bobx = float(player->bob * Rangex); + float boby = float(player->bob * Rangey); + switch (bobstyle) + { + case AWeapon::BobNormal: + xx[i] = bobx * angle.Cos(); + yy[i] = boby * fabsf(angle.Sin()); + break; - case AWeapon::BobInverseSmooth: - *x = bobx*angle.Cos(); - *y = 0.5f * (boby * (1.f + ((angle * 2).Cos()))); + case AWeapon::BobInverse: + xx[i] = bobx*angle.Cos(); + yy[i] = boby * (1.f - fabsf(angle.Sin())); + break; + + case AWeapon::BobAlpha: + xx[i] = bobx * angle.Sin(); + yy[i] = boby * fabsf(angle.Sin()); + break; + + case AWeapon::BobInverseAlpha: + xx[i] = bobx * angle.Sin(); + yy[i] = boby * (1.f - fabsf(angle.Sin())); + break; + + case AWeapon::BobSmooth: + xx[i] = bobx*angle.Cos(); + yy[i] = 0.5f * (boby * (1.f - ((angle * 2).Cos()))); + break; + + case AWeapon::BobInverseSmooth: + xx[i] = bobx*angle.Cos(); + yy[i] = 0.5f * (boby * (1.f + ((angle * 2).Cos()))); + } + } + else + { + xx[i] = 0; + yy[i] = 0; } } - else - { - *x = 0; - *y = 0; - } + *x = (float)(xx[0] * (1. - ticfrac) + xx[1] * ticfrac); + *y = (float)(yy[0] * (1. - ticfrac) + yy[1] * ticfrac); } //============================================================================ diff --git a/src/p_pspr.h b/src/p_pspr.h index 7045f96a5..27f1778f3 100644 --- a/src/p_pspr.h +++ b/src/p_pspr.h @@ -87,7 +87,7 @@ void P_CalcSwing (player_t *player); void P_BringUpWeapon (player_t *player); void P_FireWeapon (player_t *player); void P_DropWeapon (player_t *player); -void P_BobWeapon (player_t *player, pspdef_t *psp, float *x, float *y); +void P_BobWeapon (player_t *player, pspdef_t *psp, float *x, float *y, double ticfrac); DAngle P_BulletSlope (AActor *mo, FTranslatedLineTarget *pLineTarget = NULL, int aimflags = 0); void P_GunShot (AActor *mo, bool accurate, PClassActor *pufftype, DAngle pitch); diff --git a/src/r_things.cpp b/src/r_things.cpp index 465b6c30f..d2c0dcdb4 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -1579,7 +1579,7 @@ void R_DrawPlayerSprites () centery = viewheight >> 1; centeryfrac = centery << FRACBITS; - P_BobWeapon (camera->player, &camera->player->psprites[ps_weapon], &ofsx, &ofsy); + P_BobWeapon (camera->player, &camera->player->psprites[ps_weapon], &ofsx, &ofsy, r_TicFracF); // add all active psprites for (i = 0, psp = camera->player->psprites; From 790e13e5cb5ce802cfc5be81f51b9fccf658271a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 7 Apr 2016 12:14:34 +0200 Subject: [PATCH 07/11] fixed: For sight checks the 'eye' of the seeing thing should be placed at 3/4 height, not half its height. --- src/p_sight.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_sight.cpp b/src/p_sight.cpp index 847448185..469cc8783 100644 --- a/src/p_sight.cpp +++ b/src/p_sight.cpp @@ -873,7 +873,7 @@ sightcounts[0]++; portals.Clear(); { sector_t *sec; - double lookheight = t1->Center(); + double lookheight = t1->Z() + t1->Height*0.75; t1->GetPortalTransition(lookheight, &sec); double bottomslope = t2->Z() - lookheight; From a1c03c9a62d1b44e50323c8cd1b9c87fcaa44653 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 7 Apr 2016 12:44:46 +0200 Subject: [PATCH 08/11] - fixed: P_AimCamera inverted the pitch. --- src/p_map.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_map.cpp b/src/p_map.cpp index 26c08af26..8fbbb3e99 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -4689,7 +4689,7 @@ void P_AimCamera(AActor *t1, DVector3 &campos, sector_t *&CameraSector, bool &un double pc = pitch.Cos(); - vvec = { pc * angle.Cos(), pc * angle.Sin(), -pitch.Sin() }; + vvec = { pc * angle.Cos(), pc * angle.Sin(), pitch.Sin() }; sz = t1->Top() - t1->Floorclip + clamp(chase_height, -1000, 1000); if (Trace(t1->PosAtZ(sz), t1->Sector, vvec, distance, 0, 0, NULL, trace) && From 1eeaee1ac78900acfaed243b264b3431789b45e3 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 7 Apr 2016 13:05:29 +0200 Subject: [PATCH 09/11] - completely reviewed and fixed all codes using angles in the automap. --- src/am_map.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/am_map.cpp b/src/am_map.cpp index 76f6270fa..765443c20 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -1191,7 +1191,7 @@ void AM_changeWindowLoc () oincy = incy = m_paninc.y * SCREENHEIGHT / 200; if (am_rotate == 1 || (am_rotate == 2 && viewactive)) { - AM_rotate(&incx, &incy, players[consoleplayer].camera->Angles.Yaw + 90.); + AM_rotate(&incx, &incy, players[consoleplayer].camera->Angles.Yaw - 90.); } m_x += incx; @@ -1573,7 +1573,7 @@ void AM_doFollowPlayer () sy = (f_oldloc.y - players[consoleplayer].camera->Y()); if (am_rotate == 1 || (am_rotate == 2 && viewactive)) { - AM_rotate (&sx, &sy, players[consoleplayer].camera->Angles.Yaw + 90); + AM_rotate (&sx, &sy, players[consoleplayer].camera->Angles.Yaw - 90); } AM_ScrollParchment (sx, sy); @@ -2713,7 +2713,7 @@ void AM_drawPlayers () if (am_rotate == 1 || (am_rotate == 2 && viewactive)) { AM_rotatePoint (&pt.x, &pt.y); - angle -= players[consoleplayer].camera->Angles.Yaw + 90.; + angle -= players[consoleplayer].camera->Angles.Yaw - 90.; } AM_drawLineCharacter(&MapArrow[0], MapArrow.Size(), 0, angle, color, pt.x, pt.y); @@ -2802,11 +2802,11 @@ void AM_drawThings () const size_t spriteIndex = sprite.spriteframes + (show > 1 ? t->frame : 0); frame = &SpriteFrames[spriteIndex]; - DAngle angle = -t->Angles.Yaw + 90.; + DAngle angle = 270. -t->Angles.Yaw; if (frame->Texture[0] != frame->Texture[1]) angle += 180. / 16; if (am_rotate == 1 || (am_rotate == 2 && viewactive)) { - angle += players[consoleplayer].camera->Angles.Yaw + 90.; + angle += players[consoleplayer].camera->Angles.Yaw - 90.; } rotation = int((angle.Normalized360() * (16. / 360.)).Degrees); From ddb2f6b6cbe3347940c9f1bd4a3a65f383b8a68c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 7 Apr 2016 13:11:23 +0200 Subject: [PATCH 10/11] - fixed: P_SpawnPlayerMissile still used the angle_t values for offsetting the autoaim traces. --- src/p_mobj.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index bacef28e4..2c7c4ea42 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -5955,8 +5955,7 @@ AActor *P_SpawnPlayerMissile (AActor *source, double x, double y, double z, PClassActor *type, DAngle angle, FTranslatedLineTarget *pLineTarget, AActor **pMissileActor, bool nofreeaim, bool noautoaim, int aimflags) { - //static const double angdiff[3] = { -5.625, 5.625, 0 }; - static const int angdiff[3] = { -(1<<26), 1<<26, 0 }; + static const double angdiff[3] = { -5.625, 5.625, 0 }; DAngle an = angle; DAngle pitch; FTranslatedLineTarget scratch; From 1d286d5bd5bda8a58955af90cc98a611e7634887 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 7 Apr 2016 13:41:54 +0200 Subject: [PATCH 11/11] - added APROP_MaxStepHeight + APROP_MaxDropOffHeight. --- src/p_acs.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 40fe650c1..186e9c3d4 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -3737,6 +3737,8 @@ enum APROP_StencilColor = 41, APROP_Friction = 42, APROP_DamageMultiplier=43, + APROP_MaxStepHeight = 44, + APROP_MaxDropOffHeight= 45, }; // These are needed for ACS's APROP_RenderStyle @@ -3987,6 +3989,15 @@ void DLevelScript::DoSetActorProperty (AActor *actor, int property, int value) case APROP_Friction: actor->Friction = ACSToDouble(value); + case APROP_MaxStepHeight: + actor->MaxStepHeight = ACSToDouble(value); + break; + + case APROP_MaxDropOffHeight: + actor->MaxDropOffHeight = ACSToDouble(value); + break; + + default: // do nothing. break; @@ -4087,6 +4098,8 @@ int DLevelScript::GetActorProperty (int tid, int property) case APROP_NameTag: return GlobalACSStrings.AddString(actor->GetTag()); case APROP_StencilColor:return actor->fillcolor; case APROP_Friction: return DoubleToACS(actor->Friction); + case APROP_MaxStepHeight: return DoubleToACS(actor->MaxStepHeight); + case APROP_MaxDropOffHeight: return DoubleToACS(actor->MaxDropOffHeight); default: return 0; } @@ -4133,6 +4146,8 @@ int DLevelScript::CheckActorProperty (int tid, int property, int value) case APROP_MeleeRange: case APROP_ViewHeight: case APROP_AttackZOffset: + case APROP_MaxStepHeight: + case APROP_MaxDropOffHeight: case APROP_StencilColor: return (GetActorProperty(tid, property) == value);