From ca5884cf5ec0561a93ab7e7ae6eafa8d1648504c Mon Sep 17 00:00:00 2001
From: Eidolon <furyhunter600@gmail.com>
Date: Sat, 20 Aug 2022 13:42:34 -0500
Subject: [PATCH] reset cam interpolation on P_ResetCamera

---
 src/p_local.h |  1 +
 src/p_user.c  |  1 +
 src/r_main.c  | 20 ++++++++++++++++++++
 3 files changed, 22 insertions(+)

diff --git a/src/p_local.h b/src/p_local.h
index a4062ff6f..cef7e736f 100644
--- a/src/p_local.h
+++ b/src/p_local.h
@@ -86,6 +86,7 @@ typedef struct camera_s
 	// Camera demobjerization
 	// Info for drawing: position.
 	fixed_t x, y, z;
+	boolean reset;
 
 	//More drawing info: to determine current sprite.
 	angle_t angle; // orientation
diff --git a/src/p_user.c b/src/p_user.c
index 5cbc69264..82e5fa3f7 100644
--- a/src/p_user.c
+++ b/src/p_user.c
@@ -7392,6 +7392,7 @@ void P_ResetCamera(player_t *player, camera_t *thiscam)
 	thiscam->x = x;
 	thiscam->y = y;
 	thiscam->z = z;
+	thiscam->reset = true;
 
 	if (!(thiscam == &camera[0] && (cv_cam_still.value || cv_analog.value))
 		&& !(thiscam == &camera[1] && (cv_cam2_still.value || cv_analog2.value))
diff --git a/src/r_main.c b/src/r_main.c
index 076605605..e55481512 100644
--- a/src/r_main.c
+++ b/src/r_main.c
@@ -1045,24 +1045,44 @@ void R_SetupFrame(player_t *player, boolean skybox)
 		thiscam = &camera[3];
 		chasecam = (cv_chasecam4.value != 0);
 		R_SetViewContext(VIEWCONTEXT_PLAYER4);
+		if (thiscam->reset)
+		{
+			R_ResetViewInterpolation(4);
+			thiscam->reset = false;
+		}
 	}
 	else if (splitscreen > 1 && player == &players[displayplayers[2]])
 	{
 		thiscam = &camera[2];
 		chasecam = (cv_chasecam3.value != 0);
 		R_SetViewContext(VIEWCONTEXT_PLAYER3);
+		if (thiscam->reset)
+		{
+			R_ResetViewInterpolation(3);
+			thiscam->reset = false;
+		}
 	}
 	else if (splitscreen && player == &players[displayplayers[1]])
 	{
 		thiscam = &camera[1];
 		chasecam = (cv_chasecam2.value != 0);
 		R_SetViewContext(VIEWCONTEXT_PLAYER2);
+		if (thiscam->reset)
+		{
+			R_ResetViewInterpolation(2);
+			thiscam->reset = false;
+		}
 	}
 	else
 	{
 		thiscam = &camera[0];
 		chasecam = (cv_chasecam.value != 0);
 		R_SetViewContext(VIEWCONTEXT_PLAYER1);
+		if (thiscam->reset)
+		{
+			R_ResetViewInterpolation(1);
+			thiscam->reset = false;
+		}
 	}
 
 	if (player->spectator) // no spectator chasecam
-- 
GitLab