Get nq and qw sv_phys.c mostly into sync.

nq's SV_CheckVelocity will be a little different (spherical rather than
cubical), but sv_maxvelocity defaults high enough for it to not matter to
most players. It might even improve play.

The remaining differences need some careful thought before the physics
merge is done.
This commit is contained in:
Bill Currie 2010-12-08 15:48:05 +09:00
parent a893d8ead3
commit 33d768ba73
2 changed files with 27 additions and 19 deletions

View file

@ -91,11 +91,12 @@ SV_CheckAllEnts (void)
void void
SV_CheckVelocity (edict_t *ent) SV_CheckVelocity (edict_t *ent)
{ {
int i; float wishspeed;
// int i;
// bound velocity // bound velocity
for (i = 0; i < 3; i++) {
#if 0 #if 0
for (i = 0; i < 3; i++) {
if (IS_NAN (SVvector (ent, velocity)[i])) { if (IS_NAN (SVvector (ent, velocity)[i])) {
Sys_Printf ("Got a NaN velocity on %s\n", Sys_Printf ("Got a NaN velocity on %s\n",
PR_GetString (&sv_pr_state, SVstring (ent, PR_GetString (&sv_pr_state, SVstring (ent,
@ -108,11 +109,12 @@ SV_CheckVelocity (edict_t *ent)
classname))); classname)));
SVvector (ent, origin)[i] = 0; SVvector (ent, origin)[i] = 0;
} }
}
#endif #endif
if (SVvector (ent, velocity)[i] > sv_maxvelocity->value) wishspeed = VectorLength (SVvector (ent, velocity));
SVvector (ent, velocity)[i] = sv_maxvelocity->value; if (wishspeed > sv_maxvelocity->value) {
else if (SVvector (ent, velocity)[i] < -sv_maxvelocity->value) VectorScale (SVvector (ent, velocity), sv_maxvelocity->value /
SVvector (ent, velocity)[i] = -sv_maxvelocity->value; wishspeed, SVvector (ent, velocity));
} }
} }
@ -486,9 +488,9 @@ SV_Push (edict_t *pusher, vec3_t move)
// if the pusher has a "blocked" function, call it // if the pusher has a "blocked" function, call it
// otherwise, just stay in place until the obstacle is gone // otherwise, just stay in place until the obstacle is gone
if (SVfunc (pusher, blocked)) { if (SVfunc (pusher, blocked))
sv_pr_blocked (pusher, check); sv_pr_blocked (pusher, check);
}
// move back any entities we already moved // move back any entities we already moved
for (i = 0; i < num_moved; i++) { for (i = 0; i < num_moved; i++) {
VectorCopy (moved_from[i], SVvector (moved_edict[i], origin)); VectorCopy (moved_from[i], SVvector (moved_edict[i], origin));
@ -754,7 +756,6 @@ SV_RunEntity (edict_t *ent)
default: default:
Sys_Error ("SV_Physics: bad movetype %i", Sys_Error ("SV_Physics: bad movetype %i",
(int) SVfloat (ent, movetype)); (int) SVfloat (ent, movetype));
break;
} }
} }

View file

@ -123,12 +123,12 @@ SV_CheckVelocity (edict_t *ent)
} }
/* /*
SV_RunThink SV_RunThink
Runs thinking code if time. There is some play in the exact time the think Runs thinking code if time. There is some play in the exact time the think
function will be called, because it is called before any movement is done function will be called, because it is called before any movement is done
in a frame. Not used for pushmove objects, because they must be exact. in a frame. Not used for pushmove objects, because they must be exact.
Returns false if the entity removed itself. Returns false if the entity removed itself.
*/ */
qboolean qboolean
SV_RunThink (edict_t *ent) SV_RunThink (edict_t *ent)
@ -182,10 +182,10 @@ SV_Impact (edict_t *e1, edict_t *e2)
} }
/* /*
ClipVelocity ClipVelocity
Slide off of the impacting object Slide off of the impacting object
returns the blocked flags (1 = floor, 2 = step / wall) returns the blocked flags (1 = floor, 2 = step / wall)
*/ */
static int static int
ClipVelocity (vec3_t in, vec3_t normal, vec3_t out, float overbounce) ClipVelocity (vec3_t in, vec3_t normal, vec3_t out, float overbounce)
@ -389,9 +389,10 @@ SV_Push (edict_t *pusher, vec3_t move)
float solid_save; float solid_save;
int num_moved, i, e; int num_moved, i, e;
edict_t *check, *block; edict_t *check, *block;
edict_t *moved_edict[MAX_EDICTS]; edict_t **moved_edict;
vec3_t mins, maxs, pushorig; vec3_t mins, maxs, pushorig;
vec3_t moved_from[MAX_EDICTS]; vec3_t *moved_from;
int mark;
VectorAdd (SVvector (pusher, absmin), move, mins); VectorAdd (SVvector (pusher, absmin), move, mins);
VectorAdd (SVvector (pusher, absmax), move, maxs); VectorAdd (SVvector (pusher, absmax), move, maxs);
@ -402,6 +403,10 @@ SV_Push (edict_t *pusher, vec3_t move)
VectorAdd (SVvector (pusher, origin), move, SVvector (pusher, origin)); VectorAdd (SVvector (pusher, origin), move, SVvector (pusher, origin));
SV_LinkEdict (pusher, false); SV_LinkEdict (pusher, false);
mark = Hunk_LowMark ();
moved_edict = Hunk_Alloc (sv.num_edicts * sizeof (edict_t *));
moved_from = Hunk_Alloc (sv.num_edicts * sizeof (vec_t));
// see if any solid entities are inside the final position // see if any solid entities are inside the final position
num_moved = 0; num_moved = 0;
check = NEXT_EDICT (&sv_pr_state, sv.edicts); check = NEXT_EDICT (&sv_pr_state, sv.edicts);
@ -484,8 +489,10 @@ SV_Push (edict_t *pusher, vec3_t move)
VectorCopy (moved_from[i], SVvector (moved_edict[i], origin)); VectorCopy (moved_from[i], SVvector (moved_edict[i], origin));
SV_LinkEdict (moved_edict[i], false); SV_LinkEdict (moved_edict[i], false);
} }
Hunk_FreeToLowMark (mark);
return false; return false;
} }
Hunk_FreeToLowMark (mark);
return true; return true;
} }