[Quake2world-dev] r29 - quake2world/trunk/src
jdolan at jdolan.dyndns.org
jdolan at jdolan.dyndns.org
Sat Dec 20 05:09:36 UTC 2008
Author: jdolan
Date: 2008-12-20 05:09:36 +0000 (Sat, 20 Dec 2008)
New Revision: 29
Modified:
quake2world/trunk/src/cl_screen.c
quake2world/trunk/src/cl_view.c
quake2world/trunk/src/r_mesh.c
quake2world/trunk/src/renderer.h
Log:
Maintain interpolated player velocity on r_view. Add weapon bobbing effect.
Modified: quake2world/trunk/src/cl_screen.c
===================================================================
--- quake2world/trunk/src/cl_screen.c 2008-12-20 03:22:43 UTC (rev 28)
+++ quake2world/trunk/src/cl_screen.c 2008-12-20 05:09:36 UTC (rev 29)
@@ -545,14 +545,12 @@
int frames_this_second = 0, packets_this_second = 0, bytes_this_second = 0;
-static vec3_t horizontal_velocity;
-
/*
Cl_DrawCounters
*/
static void Cl_DrawCounters(void){
- player_state_t *ps;
+ static vec3_t velocity;
static char bps[8], pps[8], fps[8], spd[8];
static int millis;
@@ -568,16 +566,17 @@
frames_this_second++;
if(curtime - millis >= 1000){
- ps = &cl.frame.playerstate; // calculate horizontal velocity
- VectorSet(horizontal_velocity, ps->pmove.velocity[0] * 0.125,
- ps->pmove.velocity[1] * 0.125, 0);
- snprintf(spd, sizeof(spd), "%4.0fspd", VectorLength(horizontal_velocity));
+ VectorCopy(r_view.velocity, velocity);
+ velocity[2] = 0.0;
+
+ snprintf(spd, sizeof(spd), "%4.0fspd", VectorLength(velocity));
snprintf(fps, sizeof(fps), "%4dfps", frames_this_second);
snprintf(pps, sizeof(pps), "%4dpps", packets_this_second);
snprintf(bps, sizeof(bps), "%4dbps", bytes_this_second);
millis = curtime;
+
frames_this_second = 0;
packets_this_second = 0;
bytes_this_second = 0;
Modified: quake2world/trunk/src/cl_view.c
===================================================================
--- quake2world/trunk/src/cl_view.c 2008-12-20 03:22:43 UTC (rev 28)
+++ quake2world/trunk/src/cl_view.c 2008-12-20 05:09:36 UTC (rev 29)
@@ -186,7 +186,7 @@
VectorCopy(cl.predicted_angles, r_view.angles);
if(cl.frame.playerstate.pmove.pm_type == PM_DEAD) // look only on x axis
- r_view.angles[0] = r_view.angles[2] = 0;
+ r_view.angles[0] = r_view.angles[2] = 0.0;
}
else { // for demos and chasecams, lerp between states without prediction
AngleLerp(ops->angles, ps->angles, cl.lerp, r_view.angles);
@@ -195,6 +195,23 @@
/*
+Cl_UpdateVelocity
+*/
+static void Cl_UpdateVelocity(player_state_t *ps, player_state_t *ops){
+ vec3_t oldvel, newvel;
+
+ VectorCopy(ops->pmove.velocity, oldvel);
+ VectorCopy(ps->pmove.velocity, newvel);
+
+ // lerp it
+ VectorMix(oldvel, newvel, cl.lerp, r_view.velocity);
+
+ // convert back to float
+ VectorScale(r_view.velocity, 0.125, r_view.velocity);
+}
+
+
+/*
Cl_UpdateThirdperson
*/
static void Cl_UpdateThirdperson(player_state_t *ps){
@@ -261,6 +278,8 @@
Cl_UpdateAngles(ps, ops);
+ Cl_UpdateVelocity(ps, ops);
+
Cl_UpdateThirdperson(ps);
if(cl_fov->modified || r_view.update){
Modified: quake2world/trunk/src/r_mesh.c
===================================================================
--- quake2world/trunk/src/r_mesh.c 2008-12-20 03:22:43 UTC (rev 28)
+++ quake2world/trunk/src/r_mesh.c 2008-12-20 05:09:36 UTC (rev 29)
@@ -125,7 +125,7 @@
void R_ApplyMeshModelConfig(entity_t *e){
mesh_config_t *c;
vec3_t forward, right, up;
- vec3_t translate;
+ vec3_t translate, velocity;
float f;
int i;
@@ -139,8 +139,15 @@
AngleVectors(e->angles, forward, right, up);
VectorMA(e->origin, c->translate[0] + f, forward, e->origin);
- VectorMA(e->origin, c->translate[1], right, e->origin);
- VectorMA(e->origin, c->translate[2], up, e->origin);
+
+ // adjust up and right according to time and velocity
+ VectorCopy(r_view.velocity, velocity);
+ velocity[2] = 0.0;
+
+ f = sin(r_view.time * 5.0) * (0.25 + VectorLength(velocity) / 400.0);
+
+ VectorMA(e->origin, c->translate[1] + f, right, e->origin);
+ VectorMA(e->origin, c->translate[2] + f, up, e->origin);
}
else { // versus world entities
c = e->model->world_config;
Modified: quake2world/trunk/src/renderer.h
===================================================================
--- quake2world/trunk/src/renderer.h 2008-12-20 03:22:43 UTC (rev 28)
+++ quake2world/trunk/src/renderer.h 2008-12-20 05:09:36 UTC (rev 29)
@@ -137,8 +137,9 @@
int x, y, width, height; // in virtual screen coordinates
float fov_x, fov_y;
- vec3_t origin; // client's view origin and angles
+ vec3_t origin; // client's view origin, angles, and velocity
vec3_t angles;
+ vec3_t velocity;
float time;
More information about the Quake2World-dev
mailing list