From 90553bb61c07406c75afbab838077cec99624ecd Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 6 Mar 2016 13:10:42 +0100 Subject: [PATCH] - deal with portals in P_AimCamera. This will most likely need some more testing and refining but at least it should work through line portals now. --- src/p_local.h | 2 +- src/p_map.cpp | 3 ++- src/r_utility.cpp | 16 +++++++++++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/p_local.h b/src/p_local.h index 19315dedb..e1c12e652 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -351,7 +351,7 @@ bool P_CheckMissileSpawn (AActor *missile, fixed_t maxdist); void P_PlaySpawnSound(AActor *missile, AActor *spawner); // [RH] Position the chasecam -void P_AimCamera (AActor *t1, fixed_t &x, fixed_t &y, fixed_t &z, sector_t *&sec); +void P_AimCamera (AActor *t1, fixed_t &x, fixed_t &y, fixed_t &z, sector_t *&sec, bool &unlinked); // [RH] Means of death enum diff --git a/src/p_map.cpp b/src/p_map.cpp index 7894e7382..a0ecc58f7 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -4874,7 +4874,7 @@ void P_RailAttack(AActor *source, int damage, int offset_xy, fixed_t offset_z, i CVAR(Float, chase_height, -8.f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) CVAR(Float, chase_dist, 90.f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) -void P_AimCamera(AActor *t1, fixed_t &CameraX, fixed_t &CameraY, fixed_t &CameraZ, sector_t *&CameraSector) +void P_AimCamera(AActor *t1, fixed_t &CameraX, fixed_t &CameraY, fixed_t &CameraZ, sector_t *&CameraSector, bool &unlinked) { fixed_t distance = (fixed_t)(clamp(chase_dist, 0, 30000) * FRACUNIT); angle_t angle = (t1->angle - ANG180) >> ANGLETOFINESHIFT; @@ -4905,6 +4905,7 @@ void P_AimCamera(AActor *t1, fixed_t &CameraX, fixed_t &CameraY, fixed_t &Camera CameraZ = trace.Z; } CameraSector = trace.Sector; + unlinked = trace.unlinked; } diff --git a/src/r_utility.cpp b/src/r_utility.cpp index d301b45fc..dbe5fadd6 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -927,6 +927,7 @@ void R_SetupFrame (AActor *actor) player_t *player = actor->player; unsigned int newblend; InterpolationViewer *iview; + bool unlinked = false; if (player != NULL && player->mo == actor) { // [RH] Use camera instead of viewplayer @@ -962,9 +963,22 @@ void R_SetupFrame (AActor *actor) if (player != NULL && gamestate != GS_TITLELEVEL && ((player->cheats & CF_CHASECAM) || (r_deathcamera && camera->health <= 0))) { + sector_t *oldsector = R_PointInSubsector(iview->oviewx, iview->oviewy)->sector; // [RH] Use chasecam view - P_AimCamera (camera, iview->nviewx, iview->nviewy, iview->nviewz, viewsector); + P_AimCamera (camera, iview->nviewx, iview->nviewy, iview->nviewz, viewsector, unlinked); r_showviewer = true; + // Interpolating this is a very complicated thing because nothing keeps track of the aim camera's movement, so whenever we detect a portal transition + // it's probably best to just reset the interpolation for this move. + // Note that this can still cause problems with unusually linked portals + if (viewsector->PortalGroup != oldsector->PortalGroup || (unlinked && P_AproxDistance(iview->oviewx - iview->nviewx, iview->oviewy - iview->nviewy) > 256 * FRACUNIT)) + { + iview->otic = nowtic; + iview->oviewx = iview->nviewx; + iview->oviewy = iview->nviewy; + iview->oviewz = iview->nviewz; + iview->oviewpitch = iview->nviewpitch; + iview->oviewangle = iview->nviewangle; + } } else {