From: divverent Date: Sun, 11 Sep 2011 12:55:33 +0000 (+0000) Subject: clip velocity when detecting ground X-Git-Tag: xonotic-v0.6.0~163^2~212 X-Git-Url: https://de.git.xonotic.org/?a=commitdiff_plain;h=06c238641cc16b65e1c4964019107665b29e4507;p=xonotic%2Fdarkplaces.git clip velocity when detecting ground git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11340 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/cl_input.c b/cl_input.c index fb430089..c74b4ec0 100644 --- a/cl_input.c +++ b/cl_input.c @@ -883,6 +883,7 @@ qboolean CL_ClientMovement_Unstick(cl_clientmovement_state_t *s) void CL_ClientMovement_UpdateStatus(cl_clientmovement_state_t *s) { + vec_t f; vec3_t origin1, origin2; trace_t trace; @@ -922,7 +923,17 @@ void CL_ClientMovement_UpdateStatus(cl_clientmovement_state_t *s) VectorSet(origin1, s->origin[0], s->origin[1], s->origin[2] + 1); VectorSet(origin2, s->origin[0], s->origin[1], s->origin[2] - 1); // -2 causes clientside doublejump bug at above 150fps, raising that to 300fps :) trace = CL_TraceBox(origin1, s->mins, s->maxs, origin2, MOVE_NORMAL, NULL, SUPERCONTENTS_SOLID | SUPERCONTENTS_BODY | SUPERCONTENTS_PLAYERCLIP, true, true, NULL, false); - s->onground = trace.fraction < 1 && trace.plane.normal[2] > 0.7; + if(trace.fraction < 1 && trace.plane.normal[2] > 0.7) + { + s->onground = true; + + // this code actually "predicts" an impact; so let's clip velocity first + f = DotProduct(s->velocity, trace.plane.normal); + if(f < 0) // only if moving downwards actually + VectorMA(s->velocity, -f, trace.plane.normal, s->velocity); + } + else + s->onground = false; // set watertype/waterlevel VectorSet(origin1, s->origin[0], s->origin[1], s->origin[2] + s->mins[2] + 1);