1
0
Fork 0
forked from fte/fteqw

That should make NQ physics (sv_nomsec 1) work a bit better. And yeah, slide works now, though QuakeRally seems to have too much gravity on slopes.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@236 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2004-09-22 15:29:33 +00:00
parent 7b411a7abe
commit 527e3ee7a0
2 changed files with 91 additions and 54 deletions

View file

@ -210,31 +210,20 @@ returns the blocked flags (1 = floor, 2 = step / wall)
==================
*/
#define STOP_EPSILON 0.1
int ClipVelocity (vec3_t in, vec3_t normal, vec3_t out, float overbounce)
//courtesy of darkplaces, it's just more efficient.
void ClipVelocity (vec3_t in, vec3_t normal, vec3_t out, float overbounce)
{
int i;
float backoff;
float change;
int i, blocked;
blocked = 0;
if (normal[2] > 0)
blocked |= 1; // floor
if (!normal[2])
blocked |= 2; // step
backoff = DotProduct (in, normal) * overbounce;
backoff = -DotProduct (in, normal) * overbounce;
VectorMA(in, backoff, normal, out);
for (i = 0;i < 3;i++)
{
change = normal[i]*backoff;
out[i] = in[i] - change;
if (out[i] > -STOP_EPSILON && out[i] < STOP_EPSILON)
out[i] = 0;
}
return blocked;
}
/*
@ -332,6 +321,13 @@ int SV_FlyMove (edict_t *ent, float time, trace_t *steptrace)
return 3;
}
if (1)
{
ClipVelocity(ent->v.velocity, trace.plane.normal, ent->v.velocity, 1);
break;
}
else
{
VectorCopy (trace.plane.normal, planes[numplanes]);
numplanes++;
@ -359,14 +355,16 @@ int SV_FlyMove (edict_t *ent, float time, trace_t *steptrace)
{ // go along the crease
if (numplanes != 2)
{
// Con_Printf ("clip velocity, numplanes == %i\n",numplanes);
Con_Printf ("clip velocity, numplanes == %i\n",numplanes);
VectorCopy (vec3_origin, ent->v.velocity);
return 7;
}
CrossProduct (planes[0], planes[1], dir);
VectorNormalize(dir); //fixes slow falling in corners
d = DotProduct (dir, ent->v.velocity);
VectorScale (dir, d, ent->v.velocity);
}
}
//
// if original velocity is against the original velocity, stop dead
@ -1334,6 +1332,8 @@ void SV_WalkMove (edict_t *ent)
&& fabs(oldorg[0] - ent->v.origin[0]) < 0.03125 )
{ // stepping up didn't make any progress
clip = SV_TryUnstick (ent, oldvel);
// Con_Printf("Try unstick fwd\n");
}
}
@ -1341,6 +1341,9 @@ void SV_WalkMove (edict_t *ent)
if ( clip & 2 )
{
vec3_t lastpos, lastvel, lastdown;
// Con_Printf("couldn't do it\n");
//retry with a smaller step (allows entering smaller areas with a step of 4)
VectorCopy (downmove, lastdown);
VectorCopy (ent->v.origin, lastpos);
@ -1373,6 +1376,8 @@ void SV_WalkMove (edict_t *ent)
&& fabs(oldorg[0] - ent->v.origin[0]) < 0.03125 )
{ // stepping up didn't make any progress
clip = SV_TryUnstick (ent, oldvel);
// Con_Printf("Try unstick up\n");
}
}
@ -1384,10 +1389,15 @@ void SV_WalkMove (edict_t *ent)
VectorCopy (lastvel, ent->v.velocity);
SV_WallFriction (ent, &steptrace);
// Con_Printf("wall friction\n");
}
else if (clip & 2)
{
SV_WallFriction (ent, &steptrace);
// Con_Printf("wall friction 2\n");
}
}
// move down
@ -1408,6 +1418,8 @@ void SV_WalkMove (edict_t *ent)
// cause the player to hop up higher on a slope too steep to climb
VectorCopy (nosteporg, ent->v.origin);
VectorCopy (nostepvel, ent->v.velocity);
// Con_Printf("down not good\n");
}
}
@ -1427,6 +1439,7 @@ From normal Quake in an attempt to fix physics in QuakeRally
void SV_Physics_Client (edict_t *ent, int num)
{
qboolean readyforjump;
float oldvel;
if ( svs.clients[num-1].state < cs_spawned )
return; // unconnected slot
@ -1464,14 +1477,25 @@ void SV_Physics_Client (edict_t *ent, int num)
break;
case MOVETYPE_WALK:
oldvel = ent->v.velocity[0];
if (!SV_RunThink (ent))
return;
if (!SV_CheckWater (ent) && ! ((int)ent->v.flags & FL_WATERJUMP) )
SV_AddGravity (ent, ent->v.gravity);
if (fabs(oldvel - ent->v.velocity[0])> 100)
Con_Printf("grav: %f -> %f\n", oldvel, ent->v.velocity[0]);
SV_CheckStuck (ent);
if (fabs(oldvel - ent->v.velocity[0])> 100)
Con_Printf("stuck: %f -> %f\n", oldvel, ent->v.velocity[0]);
SV_WalkMove (ent);
if (fabs(oldvel - ent->v.velocity[0])> 100)
Con_Printf("walk: %f -> %f\n", oldvel, ent->v.velocity[0]);
break;
case MOVETYPE_TOSS:
@ -1671,6 +1695,19 @@ qboolean SV_Physics (void)
pr_global_struct->frametime = host_frametime;
for (i = 0; i < sv.allocated_client_slots; i++)
{
host_client = &svs.clients[i];
if (host_client->state == cs_spawned)
if (sv_nomsec.value || SV_PlayerPhysicsQC
#ifndef NQPROT
)
#else
|| (host_client->nqprot))
#endif
SV_ClientThink();
}
SV_ProgStartFrame ();
PR_RunThreads();

View file

@ -3914,9 +3914,6 @@ haveannothergo:
sv_player->v.button0 = newcmd.buttons & 1;
sv_player->v.button2 = (newcmd.buttons & 2)>>1;
cmd = newcmd;
SV_ClientThink ();
cl->lastcmd = newcmd;
cl->lastcmd.buttons = 0; // avoid multiple fires on lag
continue;
@ -4104,7 +4101,7 @@ void SVQ2_ExecuteClientMessage (client_t *cl)
if (!sv.paused)
{
if (sv_nomsec.value)
/*if (sv_nomsec.value)
{
cmd = newcmd;
SV_ClientThink ();
@ -4112,7 +4109,7 @@ void SVQ2_ExecuteClientMessage (client_t *cl)
cl->lastcmd = newcmd;
cl->lastcmd.buttons = 0; // avoid multiple fires on lag
break;
}
}*/
SV_PreRunCmd();
if (net_drop < 20)
@ -4603,6 +4600,9 @@ void SV_ClientThink (void)
{
vec3_t v_angle;
cmd = host_client->lastcmd;
sv_player = host_client->edict;
sv_player->v.movement[0] = cmd.forwardmove;
sv_player->v.movement[1] = cmd.sidemove;
sv_player->v.movement[2] = cmd.upmove;