View Issue Details

IDProjectCategoryView StatusLast Update
0004552The Dark ModPhysicspublic03.07.2017 04:06
ReporterAluminumHaste Assigned Tonbohr1more  
PrioritynormalSeveritynormalReproducibilityalways
Status resolvedResolutionfixed 
Platformx86OSWindowsOS Version7
Product VersionSVN 
Target VersionTDM 2.06Fixed in VersionTDM 2.06 
Summary0004552: Slide when coming to a stop
DescriptionThere is now a slide when coming to a stop which wasn't there before.

I've tried in 2.04, 2.05 and current SVN version, with and without uncapped FPS as high as 144 fps.

However, there are 4 exe's now in TDM folder.

TheDarkMod.exe - Sliding is present
TheDarkModTools.exe - Sliding is Not present
TheDarkModx64.exe - Sliding is NOT present
TheDarkModx64Tools.exe - Sliding is NOT present

The only one that is affect is the 32bit Tool-less TheDarkMod.exe
Steps To ReproduceLoad up any map, run then let go of forward.
You should stop almost immediately.

In SVN version TheDarkMod.exe, you slide a bit
Additional InformationVideos:
V2.04
https://www.youtube.com/watch?v=eO_axIBqTLQ

V2.05
https://www.youtube.com/watch?v=qFTsQUmYYl4

SVN version:
http://www.youtube.com/watch?v=w7Ol-8IG2FA
TagsNo tags attached.

Relationships

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

Activities

nbohr1more

nbohr1more

02.07.2017 18:22

developer   ~0008951

Not all executables are built every time a source change is made. TheDarkmod.exe is more frequently updated.
BluePill

BluePill

02.07.2017 23:34

reporter  

slidestats 2.05 vs SVN.txt (1,527 bytes)   
2.05 : 
Starting to slide, start speed 148.306213 (previous wish speed 148.399994) // Run
Sliding ends after 224 msecs (14 ticks)
Starting to slide, start speed 69.998970 (previous wish speed 70.000000) // Walk
Sliding ends after 112 msecs (7 ticks)
Starting to slide, start speed 30.754055 (previous wish speed 30.799997) // Slow walk
Sliding ends after 48 msecs (3 ticks)
Starting to slide, start speed 80.010994 (previous wish speed 80.136002) // Fast crouch
Sliding ends after 128 msecs (8 ticks)
Starting to slide, start speed 37.765442 (previous wish speed 37.800007) // Crouch
Sliding ends after 48 msecs (3 ticks)
Starting to slide, start speed 7.969896 (previous wish speed 16.632000) // Slow crouch
Sliding ends after 16 msecs (1 ticks)

SVN :
Starting to slide, start speed 148.389084 (previous wish speed 148.400009) // Run
Sliding ends after 768 msecs (48 ticks)
Starting to slide, start speed 70.000389 (previous wish speed 69.999985) // Walk
Sliding ends after 640 msecs (40 ticks)
Starting to slide, start speed 30.799822 (previous wish speed 30.799995) // Slow walk
Sliding ends after 512 msecs (32 ticks)
Starting to slide, start speed 80.136528 (previous wish speed 80.135994) // Fast crouch
Sliding ends after 672 msecs (42 ticks)
Starting to slide, start speed 37.800179 (previous wish speed 37.799999) // Crouch
Sliding ends after 544 msecs (34 ticks)
Starting to slide, start speed 16.632072 (previous wish speed 16.631998) // Slow crouch
Sliding ends after 416 msecs (26 ticks)
slidestats 2.05 vs SVN.txt (1,527 bytes)   
BluePill

BluePill

03.07.2017 00:10

reporter   ~0008952

Attached slide stats, created on AluminumHaste's falltest map in http://bugs.thedarkmod.com/view.php?id=4493 .
The sliding is a side-effect of my player acceleration/friction changes.
When the player accelerates, the player velocity converges the targeted movement velocity, while all velocity components pointing to another direction converge towards zero (friction).
If the player wants to stop, the total velocity converges towards zero, causing the slide phase.
There are various things that can be used to tweak the slide :
- The friction values (though these also affect movement if there's an outside force or residual velocity in another direction),
- the minimum velocity margin to fully stop the player and
- a stop friction value or multiplicator, which I haven't implemented yet.
I'll see what I can do by playing around with these, especially the second and third options.
BluePill

BluePill

03.07.2017 01:50

reporter  

adjusted_movefriction_patch.txt (2,371 bytes)   
Index: game/physics/Physics_Player.cpp
===================================================================
--- game/physics/Physics_Player.cpp	(Revision 6997)
+++ game/physics/Physics_Player.cpp	(Arbeitskopie)
@@ -47,6 +47,18 @@
 const float PM_SLICK			= 0.1f; // grayman - #2409 - for slippery surfaces
 
 /**
+* Friction multiplier to stop the player more quickly.
+* Should also be tested with slopes as the gravity direction is always treated equally.
+**/
+const float PM_STOPFRICTIONMUL	= 2.5f;
+
+/**
+* Low player speed boundary (squared), below which movement is fully stopped.
+* Affects all directions except the current acceleration direction if there is acceleration.
+**/
+const float PM_MAXSTOPSPEEDSQR	= 14.0f;
+
+/**
 *  Height unit increment for mantle test
 * This value should be >= 1.0
 * A larger value reduces the number of tests during a mantle
@@ -653,8 +665,11 @@
 	// float drop = 0;
 	float friction = 0.0f;
 
+	if (forceFriction > 1e-3f) {
+		friction = forceFriction;
+	}
 	// spectator friction
-	if ( current.movementType == PM_SPECTATOR ) {
+	else if ( current.movementType == PM_SPECTATOR ) {
 		// TODO if anyone is crazy enough to add multiplayer and spectator mode to TDM : Check whether this works as intented!
 		friction = PM_FLYFRICTION;
 		//drop += speed * PM_FLYFRICTION * frametime;
@@ -686,17 +701,22 @@
 		friction = PM_AIRFRICTION;
 		//drop += speed * PM_AIRFRICTION * frametime;
 	}
-	if (forceFriction > 0.0f)
-		friction = forceFriction;
 
+	// if there is no player intended movement
+	if (wishdir.LengthSqr() <= 1e-5f) {
+		friction *= PM_STOPFRICTIONMUL;
+	}
+
 	// bluepill: don't apply friction to the current acceleration direction as the acceleration calculation does that already.
 	// don't set drop as this friction calculation doesn't treat all velocity components equally
 	idVec3 frictionComponent = vel - ((vel * wishdir) * wishdir);
-	if (frictionComponent.LengthSqr() <= 1.5625f) // Length() <= 1.25f; value seems good enough
+	if (frictionComponent.LengthSqr() <= PM_MAXSTOPSPEEDSQR) { // fully stop movement for slow speeds
 		current.velocity -= frictionComponent;
-	else
+	}
+	else {
 		current.velocity += frictionComponent * (friction * frametime * (0.0f - 1.0f)); // -1.0 for 100% frictionComponent
-	
+	}
+
 	// scale the velocity
 	/*float newspeed = speed - drop;
 	if (newspeed < 0) {
BluePill

BluePill

03.07.2017 02:01

reporter   ~0008955

Last edited: 03.07.2017 02:05

View 2 revisions

Attached adjusted_movefriction_patch.txt.
The second pair of constants I've tried without prior calculations result in the same slide duration for running as in TDM 2.05, at least with com_fixedTic 0.
The new slide durations for com_fixedTic 0 are 224/176/128/192/144/96 ms, in TDM 2.05 it was 224/112/48/128/48/16 ms (fast/normal/slow for walk and crouch).
That's still more for slower movements but the difference should be hard to notice.

Note that I haven't tested this with slopes and slippery surfaces so far.

nbohr1more

nbohr1more

03.07.2017 04:04

developer   ~0008958

Thank you!!!

Applied patch at source rev. 6998
Binaries commited at 14842

Works well in all tested scenarios.

Issue History

Date Modified Username Field Change
02.07.2017 15:51 AluminumHaste New Issue
02.07.2017 15:51 AluminumHaste Status new => assigned
02.07.2017 15:51 AluminumHaste Assigned To => grayman
02.07.2017 16:07 grayman Assigned To grayman =>
02.07.2017 16:07 grayman Status assigned => new
02.07.2017 17:04 nbohr1more Relationship added child of 0004493
02.07.2017 18:22 nbohr1more Note Added: 0008951
02.07.2017 23:34 BluePill File Added: slidestats 2.05 vs SVN.txt
03.07.2017 00:10 BluePill Note Added: 0008952
03.07.2017 01:50 BluePill File Added: adjusted_movefriction_patch.txt
03.07.2017 02:01 BluePill Note Added: 0008955
03.07.2017 02:05 BluePill Note Edited: 0008955 View Revisions
03.07.2017 04:04 nbohr1more Note Added: 0008958
03.07.2017 04:06 nbohr1more Assigned To => nbohr1more
03.07.2017 04:06 nbohr1more Status new => resolved
03.07.2017 04:06 nbohr1more Resolution open => fixed
03.07.2017 04:06 nbohr1more Fixed in Version => TDM 2.06