mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
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:
parent
a893d8ead3
commit
33d768ba73
2 changed files with 27 additions and 19 deletions
|
@ -91,11 +91,12 @@ SV_CheckAllEnts (void)
|
|||
void
|
||||
SV_CheckVelocity (edict_t *ent)
|
||||
{
|
||||
int i;
|
||||
float wishspeed;
|
||||
// int i;
|
||||
|
||||
// bound velocity
|
||||
for (i = 0; i < 3; i++) {
|
||||
#if 0
|
||||
for (i = 0; i < 3; i++) {
|
||||
if (IS_NAN (SVvector (ent, velocity)[i])) {
|
||||
Sys_Printf ("Got a NaN velocity on %s\n",
|
||||
PR_GetString (&sv_pr_state, SVstring (ent,
|
||||
|
@ -108,11 +109,12 @@ SV_CheckVelocity (edict_t *ent)
|
|||
classname)));
|
||||
SVvector (ent, origin)[i] = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (SVvector (ent, velocity)[i] > sv_maxvelocity->value)
|
||||
SVvector (ent, velocity)[i] = sv_maxvelocity->value;
|
||||
else if (SVvector (ent, velocity)[i] < -sv_maxvelocity->value)
|
||||
SVvector (ent, velocity)[i] = -sv_maxvelocity->value;
|
||||
wishspeed = VectorLength (SVvector (ent, velocity));
|
||||
if (wishspeed > sv_maxvelocity->value) {
|
||||
VectorScale (SVvector (ent, velocity), 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
|
||||
// otherwise, just stay in place until the obstacle is gone
|
||||
if (SVfunc (pusher, blocked)) {
|
||||
if (SVfunc (pusher, blocked))
|
||||
sv_pr_blocked (pusher, check);
|
||||
}
|
||||
|
||||
// move back any entities we already moved
|
||||
for (i = 0; i < num_moved; i++) {
|
||||
VectorCopy (moved_from[i], SVvector (moved_edict[i], origin));
|
||||
|
@ -754,7 +756,6 @@ SV_RunEntity (edict_t *ent)
|
|||
default:
|
||||
Sys_Error ("SV_Physics: bad movetype %i",
|
||||
(int) SVfloat (ent, movetype));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
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.
|
||||
Returns false if the entity removed itself.
|
||||
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
|
||||
in a frame. Not used for pushmove objects, because they must be exact.
|
||||
Returns false if the entity removed itself.
|
||||
*/
|
||||
qboolean
|
||||
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
|
||||
returns the blocked flags (1 = floor, 2 = step / wall)
|
||||
Slide off of the impacting object
|
||||
returns the blocked flags (1 = floor, 2 = step / wall)
|
||||
*/
|
||||
static int
|
||||
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;
|
||||
int num_moved, i, e;
|
||||
edict_t *check, *block;
|
||||
edict_t *moved_edict[MAX_EDICTS];
|
||||
edict_t **moved_edict;
|
||||
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, absmax), move, maxs);
|
||||
|
@ -402,6 +403,10 @@ SV_Push (edict_t *pusher, vec3_t move)
|
|||
VectorAdd (SVvector (pusher, origin), move, SVvector (pusher, origin));
|
||||
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
|
||||
num_moved = 0;
|
||||
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));
|
||||
SV_LinkEdict (moved_edict[i], false);
|
||||
}
|
||||
Hunk_FreeToLowMark (mark);
|
||||
return false;
|
||||
}
|
||||
Hunk_FreeToLowMark (mark);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue