View Issue Details

IDProjectCategoryView StatusLast Update
0004741The Dark ModPhysicspublic01.02.2019 05:50
Reportergrayman Assigned Tograyman  
PrioritynormalSeveritynormalReproducibilityrandom
Status resolvedResolutionfixed 
Product VersionTDM 2.06 
Target VersionTDM 2.06Fixed in VersionTDM 2.06 
Summary0004741: Possible stutter in player movement
DescriptionPlayer movement sometimes stutters, as if something is holding you back for a brief moment.
TagsNo tags attached.
Attached Files
framelock+curb_fix.txt (3,779 bytes)   
Index: game/physics/Physics_Player.cpp
===================================================================
--- game/physics/Physics_Player.cpp	(Revision 7370)
+++ game/physics/Physics_Player.cpp	(Arbeitskopie)
@@ -449,6 +449,9 @@
 						// greebo: HACK ALARM: We add a "counter-gravity" this frame to avoid us from being dragged down again in the next frame
 						// TODO: Maybe we can do this somewhere else, where the player is sliding off slopes.
 						current.velocity -= gravityVector * frametime * 3;
+
+						// BluePill: HACK to prevent sliding down curbs on high framerates.
+						m_SlopeIgnoreTimer = (framemsec < USERCMD_MSEC) ? 250 : 0;
 					}
 				}
 
@@ -901,14 +904,6 @@
 */
 void idPhysics_Player::WalkMove( void ) 
 {
-	static float moveTimeAccum = 0;
-	moveTimeAccum += frametime;
-	while ( moveTimeAccum < MS2SEC( USERCMD_MSEC ) ) {
-		return;
-	}
-	frametime = moveTimeAccum;
-	moveTimeAccum = 0;
-
 	if ( waterLevel > WATERLEVEL_WAIST && (viewForward * groundTrace.c.normal) > 0.0f )
 	{
 		// begin swimming
@@ -1911,24 +1906,27 @@
 		current.velocity += 3*velocityChange;
 		walkNormal = MIN_WALK_SLICK_NORMAL;
 	}
+	
+	// don't check for slopes for a short time (only used for high framerates)
+	if (m_SlopeIgnoreTimer <= 0) {
+		// slopes that are too steep will not be considered onground
+		if ( ( groundTrace.c.normal * -gravityNormal ) < walkNormal ) // grayman #2409
+		{
+			if ( debugLevel ) {
+				gameLocal.Printf( "%i:steep\n", c_pmove );
+			}
 
-	// slopes that are too steep will not be considered onground
-	if ( ( groundTrace.c.normal * -gravityNormal ) < walkNormal ) // grayman #2409
-	{
-		if ( debugLevel ) {
-			gameLocal.Printf( "%i:steep\n", c_pmove );
-		}
+			// FIXME: if they can't slide down the slope, let them walk (sharp crevices)
 
-		// FIXME: if they can't slide down the slope, let them walk (sharp crevices)
+			// make sure we don't die from sliding down a steep slope
+			if ( current.velocity * gravityNormal > 150.0f ) {
+				current.velocity -= ( current.velocity * gravityNormal - 150.0f ) * gravityNormal;
+			}
 
-		// make sure we don't die from sliding down a steep slope
-		if ( current.velocity * gravityNormal > 150.0f ) {
-			current.velocity -= ( current.velocity * gravityNormal - 150.0f ) * gravityNormal;
+			groundPlane = true;
+			walking = false;
+			return;
 		}
-
-		groundPlane = true;
-		walking = false;
-		return;
 	}
 
 	groundPlane = true;
@@ -2588,6 +2586,10 @@
 	current.movementFlags &= ~(PMF_JUMPED|PMF_STEPPED_UP|PMF_STEPPED_DOWN);
 	current.stepUp = 0.0f;
 
+	// update the slope ignore timer
+	if (m_SlopeIgnoreTimer > 0)
+		m_SlopeIgnoreTimer -= framemsec;
+
 	if ( command.upmove < 10 ) {
 		// not holding jump
 		current.movementFlags &= ~PMF_JUMP_HELD;
@@ -2913,6 +2915,8 @@
 
 	m_PushForce = CForcePushPtr(new CForcePush);
 
+	m_SlopeIgnoreTimer = 0;
+
 	// swimming
 	waterLevel = WATERLEVEL_NONE;
 	waterType = 0;
@@ -3136,6 +3140,8 @@
 
 	savefile->ReadInt( m_NextAttachTime );
 
+	m_SlopeIgnoreTimer = 0;
+
 	savefile->ReadInt( (int &)waterLevel );
 	savefile->ReadInt( waterType );
 
Index: game/physics/Physics_Player.h
===================================================================
--- game/physics/Physics_Player.h	(Revision 7370)
+++ game/physics/Physics_Player.h	(Arbeitskopie)
@@ -364,6 +364,12 @@
 	int						m_NextAttachTime;
 
 	/**
+	* Timer value used as a workaround to step up curbs on high framerates.
+	* Only set at a frametime below USERCMD_MSEC and decreased by the frametime each movement frame.
+	**/
+	int						m_SlopeIgnoreTimer;
+
+	/**
 	* View yaw and pitch changes between this frame and last frame
 	* In degrees.
 	**/
framelock+curb_fix.txt (3,779 bytes)   

Relationships

child of 0004493 resolvedduzenko Some physics events have changed in 2.05 due to faster fps 

Activities

grayman

grayman

08.02.2018 11:29

viewer   ~0010044

Comment from duzenko:

"You might want to look at rev 7133 and 6968."
grayman

grayman

08.02.2018 20:13

viewer   ~0010045

Spent another hour on this today and I couldn't reproduce it.

It might have to wait to get fixed in 2.07.
BluePill

BluePill

12.03.2018 21:17

reporter   ~0010050

Uploaded framelock+curb_fix.txt, which should address the movement stutter and an issue walking to the curb with high framerates in TD4 : The Alchemist (leaving framerates below 63fps completely untouched).
grayman

grayman

13.03.2018 02:41

viewer   ~0010051

Unless someone beats me to it, I'll look at this tomorrow.

Thanks.
nbohr1more

nbohr1more

13.03.2018 02:52

developer   ~0010052

Speak o' the devil...

SVN Rev 7371

Physics_Player.h
Physics_Player.cpp

Issue History

Date Modified Username Field Change
08.02.2018 11:27 grayman New Issue
08.02.2018 11:27 grayman Status new => assigned
08.02.2018 11:27 grayman Assigned To => grayman
08.02.2018 11:29 grayman Note Added: 0010044
08.02.2018 20:13 grayman Note Added: 0010045
12.03.2018 21:13 BluePill File Added: framelock+curb_fix.txt
12.03.2018 21:17 BluePill Note Added: 0010050
13.03.2018 02:41 grayman Note Added: 0010051
13.03.2018 02:52 nbohr1more Note Added: 0010052
14.03.2018 16:32 grayman Status assigned => resolved
14.03.2018 16:32 grayman Resolution open => fixed
14.03.2018 16:32 grayman Fixed in Version => TDM 2.06
01.02.2019 05:50 nbohr1more Relationship added child of 0004493