From 02840cd978a8b1ad0f1e30810a2737ede16b3e70 Mon Sep 17 00:00:00 2001 From: Rafael Barreto Date: Wed, 7 Jul 2010 15:38:10 +0000 Subject: [PATCH] testvel... quite perfect git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@5298 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/clients2c.cpp | 11 ++++++----- source/src/entity.h | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/source/src/clients2c.cpp b/source/src/clients2c.cpp index ffa27e24..51c21661 100644 --- a/source/src/clients2c.cpp +++ b/source/src/clients2c.cpp @@ -171,11 +171,11 @@ void parsepositions(ucharbuf &p) { loopi(3) { - float dr = o.v[i] - d->o.v[i]; - if ( fabs(d->vel.v[i]) > 0.25f ) - d->vel.v[i] = (i == 2 ? ( dr + d->eyeheight > 0.0f ? ( dr + d->eyeheight ) * 5.0f : 0.0f ) : dr ) * 0.1f + d->vel.v[i] * 0.9f; - else - d->vel.v[i] = (i == 2 ? ( dr + d->eyeheight > 0.0f ? ( dr + d->eyeheight ) * 5.0f : 0.0f ) : dr ) * 0.3f + d->vel.v[i] * 0.7f; + // the idea here is to send only dv, instead of vel + float dv = vel.v[i] - d->vel_t.v[i]; + d->vel_t.v[i] = vel.v[i]; + float dr = o.v[i] - d->o.v[i] + ( i == 2 ? d->eyeheight : 0); + d->vel.v[i] = dr * 0.05f + d->vel.v[i] * 0.95f + ( dv * d->vel_t.v[i] > 0 ? dv : 0 ); } } else loopi(3) d->vel.v[i] = 0.0f; @@ -187,6 +187,7 @@ void parsepositions(ucharbuf &p) d->yaw = yaw; d->pitch = pitch; d->roll = roll; +// if (roll != 0) printf("roll: %f\n",roll); d->strafe = (f&3)==3 ? -1 : f&3; f >>= 2; d->move = (f&3)==3 ? -1 : f&3; diff --git a/source/src/entity.h b/source/src/entity.h index c5fdf98f..9e8bac5f 100644 --- a/source/src/entity.h +++ b/source/src/entity.h @@ -96,7 +96,7 @@ public: class physent : public worldobject { public: - vec o, vel; // origin, velocity + vec o, vel, vel_t; // origin, velocity vec deltapos, newpos; // movement interpolation float yaw, pitch, roll; // used as vec in one place float pitchvel; @@ -128,7 +128,7 @@ public: void reset() { - vel.x = vel.y = vel.z = eyeheightvel = 0.0f; + vel.x = vel.y = vel.z = eyeheightvel = vel_t.x = vel_t.y = vel_t.z = 0.0f; move = strafe = 0; timeinair = lastjump = lastsplash = 0; onfloor = onladder = inwater = jumpnext = crouching = crouchedinair = trycrouch = stuck = false;