[client] Get the basic chase camera working

The more advanced modes are rather broken (continuous spinning), but
they may have been for a while. The bulk of the various changes were due
to renaming viewstate's origin and angles to make their meaning more
explicit.
This commit is contained in:
Bill Currie 2022-03-01 11:43:23 +09:00
parent fb83d87a0e
commit 43a329dcb5
17 changed files with 105 additions and 100 deletions

View file

@ -39,11 +39,12 @@
#define INFO_CSHIFT_POWERUP (1 << 3) #define INFO_CSHIFT_POWERUP (1 << 3)
typedef struct viewstate_s { typedef struct viewstate_s {
vec4f_t player_origin;
vec3_t player_angles;
int chase;
vec4f_t movecmd; vec4f_t movecmd;
vec4f_t velocity; vec4f_t velocity;
vec4f_t origin;
vec4f_t punchangle; vec4f_t punchangle;
vec3_t angles;
float frametime; float frametime;
struct transform_s *camera_transform; struct transform_s *camera_transform;
double time; double time;
@ -77,7 +78,6 @@ typedef struct viewstate_s {
struct entity_s *player_entity; struct entity_s *player_entity;
struct chasestate_s *chasestate; struct chasestate_s *chasestate;
int chase;
} viewstate_t; } viewstate_t;
#define VF_DEAD 1 #define VF_DEAD 1

View file

@ -41,7 +41,7 @@
#include "QF/mathlib.h" #include "QF/mathlib.h"
#include "QF/plugin/vid_render.h" #include "QF/plugin/vid_render.h"
#include "QF/simd/vec4f.h" #include "QF/scene/transform.h"
#include "world.h" #include "world.h"
@ -83,21 +83,22 @@ Chase_Reset (void)
// start position 12 units behind head // start position 12 units behind head
} }
static inline void static inline vec4f_t
TraceLine (chasestate_t *cs, vec3_t start, vec3_t end, vec3_t impact) TraceLine (chasestate_t *cs, vec4f_t start, vec4f_t end)
{ {
trace_t trace; trace_t trace;
memset (&trace, 0, sizeof (trace)); memset (&trace, 0, sizeof (trace));
trace.fraction = 1; trace.fraction = 1;
MOD_TraceLine (cs->worldmodel->brush.hulls, 0, start, end, &trace); MOD_TraceLine (cs->worldmodel->brush.hulls, 0, &start[0], &end[0], &trace);
VectorCopy (trace.endpos, impact); return (vec4f_t) {trace.endpos[0], trace.endpos[1], trace.endpos[2], 1};
} }
void void
Chase_Update (chasestate_t *cs) Chase_Update (chasestate_t *cs)
{ {
viewstate_t *vs = cs->viewstate;
float pitch, yaw, fwd; float pitch, yaw, fwd;
vec4f_t move = {}; vec4f_t move = {};
vec4f_t forward = {}, up = {}, right = {}, stop = {}, dir = {}; vec4f_t forward = {}, up = {}, right = {}, stop = {}, dir = {};
@ -107,28 +108,25 @@ Chase_Update (chasestate_t *cs)
if (chase_active->int_val == 2 || chase_active->int_val == 3) { if (chase_active->int_val == 2 || chase_active->int_val == 3) {
// control camera angles with key/mouse/joy-look // control camera angles with key/mouse/joy-look
vec3_t d; vec3_t d;
VectorSubtract (cs->viewstate->angles, player_angles, d); VectorSubtract (vs->player_angles, player_angles, d);
VectorAdd (camera_angles, d, camera_angles); VectorAdd (camera_angles, d, camera_angles);
if (chase_active->int_val == 2) { if (chase_active->int_val == 2) {
if (camera_angles[PITCH] < -60) camera_angles[PITCH] = bound (-60, camera_angles[PITCH], 60);
camera_angles[PITCH] = -60;
if (camera_angles[PITCH] > 60)
camera_angles[PITCH] = 60;
} }
// move camera, it's not enough to just change the angles because // move camera, it's not enough to just change the angles because
// the angles are automatically changed to look toward the player // the angles are automatically changed to look toward the player
if (chase_active->int_val == 3) { if (chase_active->int_val == 3) {
player_origin = r_data->refdef->viewposition; player_origin = vs->player_origin;
} }
AngleVectors (camera_angles, &forward[0], &right[0], &up[0]); AngleVectors (camera_angles, &forward[0], &right[0], &up[0]);
camera_origin = player_origin - chase_back->value * forward; camera_origin = player_origin - chase_back->value * forward;
if (chase_active->int_val == 2) { if (chase_active->int_val == 2) {
player_origin = r_data->refdef->viewposition; player_origin = vs->player_origin;
// don't let camera get too low // don't let camera get too low
if (camera_origin[2] < player_origin[2] + chase_up->value) { if (camera_origin[2] < player_origin[2] + chase_up->value) {
@ -148,14 +146,12 @@ Chase_Update (chasestate_t *cs)
// check for walls between player and camera // check for walls between player and camera
camera_origin += 8 * forward; camera_origin += 8 * forward;
//FIXME stop = TraceLine (cs, player_origin, camera_origin);
TraceLine (cs, &player_origin[0], &camera_origin[0], &stop[0]);
stop[3] = 1;
if (magnitude3f (stop)[0] != 0) { if (magnitude3f (stop)[0] != 0) {
camera_origin = stop - forward; camera_origin = stop - forward;
} }
dir = camera_origin - r_data->refdef->viewposition; dir = camera_origin - vs->player_origin;
forward = normalf (dir); forward = normalf (dir);
if (chase_active->int_val == 2) { if (chase_active->int_val == 2) {
@ -184,12 +180,14 @@ Chase_Update (chasestate_t *cs)
} }
} }
AngleQuat (camera_angles, &r_data->refdef->viewrotation[0]);//FIXME rotate camera vec4f_t rotation;
r_data->refdef->viewposition = camera_origin; // move camera AngleQuat (camera_angles, &rotation[0]);//FIXME
Transform_SetWorldRotation (vs->camera_transform, rotation);
Transform_SetWorldPosition (vs->camera_transform, camera_origin);
// get basic movement from keyboard // get basic movement from keyboard
// VectorCopy (cs->viewstate->angles, cmd.angles); // VectorCopy (vs->player_angles, cmd.angles);
if (in_strafe.state & 1) { if (in_strafe.state & 1) {
move[SIDE] += cl_sidespeed->value * IN_ButtonState (&in_right); move[SIDE] += cl_sidespeed->value * IN_ButtonState (&in_right);
@ -208,7 +206,7 @@ Chase_Update (chasestate_t *cs)
} }
// mouse and joystick controllers add to movement // mouse and joystick controllers add to movement
VectorSet (0, cs->viewstate->angles[1] - camera_angles[1], 0, dir); VectorSet (0, vs->player_angles[1] - camera_angles[1], 0, dir);
AngleVectors (&dir[0], &forward[0], &right[0], &up[0]); //FIXME AngleVectors (&dir[0], &forward[0], &right[0], &up[0]); //FIXME
//forward *= viewdelta.position[2] * m_forward->value; FIXME //forward *= viewdelta.position[2] * m_forward->value; FIXME
//right *= viewdelta.position[0] * m_side->value; FIXME //right *= viewdelta.position[0] * m_side->value; FIXME
@ -224,16 +222,16 @@ Chase_Update (chasestate_t *cs)
VectorAdd (forward, right, dir); VectorAdd (forward, right, dir);
if (dir[1] || dir[0]) { if (dir[1] || dir[0]) {
cs->viewstate->angles[YAW] = (atan2 (dir[1], dir[0]) * 180 / M_PI); vs->player_angles[YAW] = (atan2 (dir[1], dir[0]) * 180 / M_PI);
if (cs->viewstate->angles[YAW] < 0) { if (vs->player_angles[YAW] < 0) {
cs->viewstate->angles[YAW] += 360; vs->player_angles[YAW] += 360;
} }
} }
cs->viewstate->angles[PITCH] = 0; vs->player_angles[PITCH] = 0;
// remember the new angle to calculate the difference next frame // remember the new angle to calculate the difference next frame
VectorCopy (cs->viewstate->angles, player_angles); VectorCopy (vs->player_angles, player_angles);
return; return;
} }
@ -241,21 +239,19 @@ Chase_Update (chasestate_t *cs)
// regular camera, faces same direction as player // regular camera, faces same direction as player
//FIXME //FIXME
AngleVectors (cs->viewstate->angles, &forward[0], &right[0], &up[0]); AngleVectors (vs->player_angles, &forward[0], &right[0], &up[0]);
// calc exact destination // calc exact destination
camera_origin = r_data->refdef->viewposition camera_origin = vs->player_origin
- forward * chase_back->value - right * chase_right->value; - forward * chase_back->value - right * chase_right->value;
// chase_up is world up // chase_up is world up
camera_origin[2] += chase_up->value; camera_origin[2] += chase_up->value;
// check for walls between player and camera // check for walls between player and camera
//FIXME stop = TraceLine (cs, vs->player_origin, camera_origin);
TraceLine (cs, &r_data->refdef->viewposition[0], &camera_origin[0], &stop[0]);
stop[3] = 1;
if (magnitude3f (stop)[0] != 0) { if (magnitude3f (stop)[0] != 0) {
camera_origin = stop + forward * 8; camera_origin = stop + forward * 8;
} }
r_data->refdef->viewposition = camera_origin; Transform_SetWorldPosition (vs->camera_transform, camera_origin);
} }

View file

@ -246,7 +246,7 @@ V_DriftPitch (viewstate_t *vs)
return; return;
} }
delta = vs->idealpitch - vs->angles[PITCH]; delta = vs->idealpitch - vs->player_angles[PITCH];
if (!delta) { if (!delta) {
vs->pitchvel = 0; vs->pitchvel = 0;
@ -261,13 +261,13 @@ V_DriftPitch (viewstate_t *vs)
vs->pitchvel = 0; vs->pitchvel = 0;
move = delta; move = delta;
} }
vs->angles[PITCH] += move; vs->player_angles[PITCH] += move;
} else if (delta < 0) { } else if (delta < 0) {
if (move > -delta) { if (move > -delta) {
vs->pitchvel = 0; vs->pitchvel = 0;
move = -delta; move = -delta;
} }
vs->angles[PITCH] -= move; vs->player_angles[PITCH] -= move;
} }
} }
@ -278,8 +278,8 @@ V_ParseDamage (qmsg_t *net_message, viewstate_t *vs)
{ {
float count, side; float count, side;
int armor, blood; int armor, blood;
vec4f_t origin = vs->origin; vec4f_t origin = vs->player_origin;
vec_t *angles = vs->angles; vec_t *angles = vs->player_angles;
vec3_t from, forward, right, up; vec3_t from, forward, right, up;
armor = MSG_ReadByte (net_message); armor = MSG_ReadByte (net_message);
@ -485,7 +485,7 @@ static void
V_BoundOffsets (viewstate_t *vs) V_BoundOffsets (viewstate_t *vs)
{ {
vec4f_t offset = Transform_GetWorldPosition (vs->camera_transform); vec4f_t offset = Transform_GetWorldPosition (vs->camera_transform);
offset -= vs->origin; offset -= vs->player_origin;
// absolutely bound refresh reletive to entity clipping hull // absolutely bound refresh reletive to entity clipping hull
// so the view can never be inside a solid wall // so the view can never be inside a solid wall
@ -493,7 +493,8 @@ V_BoundOffsets (viewstate_t *vs)
offset[0] = bound (-14, offset[0], 14); offset[0] = bound (-14, offset[0], 14);
offset[1] = bound (-14, offset[1], 14); offset[1] = bound (-14, offset[1], 14);
offset[2] = bound (-22, offset[2], 30); offset[2] = bound (-22, offset[2], 30);
Transform_SetWorldPosition (vs->camera_transform, vs->origin + offset); Transform_SetWorldPosition (vs->camera_transform,
vs->player_origin + offset);
} }
static vec4f_t static vec4f_t
@ -544,7 +545,7 @@ V_AddIdle (viewstate_t *vs)
static void static void
V_CalcViewRoll (viewstate_t *vs) V_CalcViewRoll (viewstate_t *vs)
{ {
vec_t *angles = vs->angles; vec_t *angles = vs->player_angles;
vec4f_t velocity = vs->velocity; vec4f_t velocity = vs->velocity;
vec3_t ang = { }; vec3_t ang = { };
@ -598,8 +599,8 @@ V_CalcRefdef (viewstate_t *vs)
float bob; float bob;
static float oldz = 0; static float oldz = 0;
vec4f_t forward = {}, right = {}, up = {}; vec4f_t forward = {}, right = {}, up = {};
vec4f_t origin = vs->origin; vec4f_t origin = vs->player_origin;
vec_t *viewangles = vs->angles; vec_t *viewangles = vs->player_angles;
V_DriftPitch (vs); V_DriftPitch (vs);
@ -615,7 +616,7 @@ V_CalcRefdef (viewstate_t *vs)
origin += (vec4f_t) { 1.0/16, 1.0/16, 1.0/16, 0}; origin += (vec4f_t) { 1.0/16, 1.0/16, 1.0/16, 0};
vec4f_t rotation; vec4f_t rotation;
AngleQuat (vs->angles, &rotation[0]);//FIXME AngleQuat (vs->player_angles, &rotation[0]);//FIXME
Transform_SetWorldRotation (vs->camera_transform, rotation); Transform_SetWorldRotation (vs->camera_transform, rotation);
V_CalcViewRoll (vs); V_CalcViewRoll (vs);
V_AddIdle (vs); V_AddIdle (vs);
@ -635,7 +636,7 @@ V_CalcRefdef (viewstate_t *vs)
V_BoundOffsets (vs); V_BoundOffsets (vs);
// set up gun position // set up gun position
vec4f_t gun_origin = vs->origin; vec4f_t gun_origin = vs->player_origin;
CalcGunAngle (vs); CalcGunAngle (vs);
gun_origin += (vec4f_t) { 0, 0, vs->height, 0 }; gun_origin += (vec4f_t) { 0, 0, vs->height, 0 };

View file

@ -105,7 +105,7 @@ CL_WriteDemoMessage (sizebuf_t *msg)
len = LittleLong (msg->cursize); len = LittleLong (msg->cursize);
Qwrite (cls.demofile, &len, 4); Qwrite (cls.demofile, &len, 4);
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
f = LittleFloat (cl.viewstate.angles[i]); f = LittleFloat (cl.viewstate.player_angles[i]);
Qwrite (cls.demofile, &f, 4); Qwrite (cls.demofile, &f, 4);
} }
Qwrite (cls.demofile, msg->data, msg->cursize); Qwrite (cls.demofile, msg->data, msg->cursize);

View file

@ -170,7 +170,8 @@ CL_RelinkEntities (void)
d[j] += 360; d[j] += 360;
} }
} }
VectorMultAdd (cl.frameViewAngles[1], frac, d, cl.viewstate.angles); VectorMultAdd (cl.frameViewAngles[1], frac, d,
cl.viewstate.player_angles);
} }
bobjrotate = anglemod (100 * cl.time); bobjrotate = anglemod (100 * cl.time);
@ -304,6 +305,6 @@ CL_RelinkEntities (void)
cl_forcelink[i] = false; cl_forcelink[i] = false;
} }
cl.viewstate.origin cl.viewstate.player_origin
= Transform_GetWorldPosition (cl_entities[cl.viewentity].transform); = Transform_GetWorldPosition (cl_entities[cl.viewentity].transform);
} }

View file

@ -74,14 +74,15 @@ CL_BaseMove (usercmd_t *cmd)
if (cls.state != ca_active) { if (cls.state != ca_active) {
return; return;
} }
VectorCopy (cl.viewstate.angles, cl.movestate.angles);//FIXME VectorCopy (cl.viewstate.player_angles, cl.movestate.angles);//FIXME
CL_Input_BuildMove (host_frametime, &cl.movestate, &cl.viewstate); CL_Input_BuildMove (host_frametime, &cl.movestate, &cl.viewstate);
VectorCopy (cl.movestate.angles, cl.viewstate.angles);//FIXME VectorCopy (cl.movestate.angles, cl.viewstate.player_angles);//FIXME
memset (cmd, 0, sizeof (*cmd)); memset (cmd, 0, sizeof (*cmd));
cmd->forwardmove = cl.movestate.move[FORWARD]; cmd->forwardmove = cl.movestate.move[FORWARD];
cmd->sidemove = cl.movestate.move[SIDE]; cmd->sidemove = cl.movestate.move[SIDE];
cmd->upmove = cl.movestate.move[UP]; cmd->upmove = cl.movestate.move[UP];
cl.viewstate.movecmd = cl.movestate.move;
} }
@ -103,7 +104,7 @@ CL_SendMove (usercmd_t *cmd)
MSG_WriteFloat (&buf, cl.mtime[0]); // so server can get ping times MSG_WriteFloat (&buf, cl.mtime[0]); // so server can get ping times
write_angles (&buf, cl.viewstate.angles); write_angles (&buf, cl.viewstate.player_angles);
MSG_WriteShort (&buf, cmd->forwardmove); MSG_WriteShort (&buf, cmd->forwardmove);
MSG_WriteShort (&buf, cmd->sidemove); MSG_WriteShort (&buf, cmd->sidemove);

View file

@ -204,6 +204,7 @@ CL_ClearState (void)
cl.viewstate.camera_transform = cam; cl.viewstate.camera_transform = cam;
cl.viewstate.chase = 1; cl.viewstate.chase = 1;
cl.viewstate.chasestate = &cl.chasestate; cl.viewstate.chasestate = &cl.chasestate;
cl.chasestate.viewstate = &cl.viewstate;
cl.watervis = 1; cl.watervis = 1;
r_data->force_fullscreen = 0; r_data->force_fullscreen = 0;
r_data->lightstyle = cl.lightstyle; r_data->lightstyle = cl.lightstyle;
@ -534,7 +535,7 @@ CL_SetState (cactive_t state)
static void static void
Force_CenterView_f (void) Force_CenterView_f (void)
{ {
cl.viewstate.angles[PITCH] = 0; cl.viewstate.player_angles[PITCH] = 0;
} }
void void

View file

@ -440,6 +440,7 @@ CL_ParseServerInfo (void)
// local state // local state
cl_entities[0].renderer.model = cl.worldmodel = cl.model_precache[1]; cl_entities[0].renderer.model = cl.worldmodel = cl.model_precache[1];
cl.chasestate.worldmodel = cl.worldmodel;
if (!centerprint) if (!centerprint)
centerprint = dstring_newstr (); centerprint = dstring_newstr ();
else else
@ -959,7 +960,7 @@ CL_ParseServerMessage (void)
case svc_setangle: case svc_setangle:
{ {
vec_t *dest = cl.viewstate.angles; vec_t *dest = cl.viewstate.player_angles;
MSG_ReadAngleV (net_message, dest); MSG_ReadAngleV (net_message, dest);
break; break;

View file

@ -438,7 +438,7 @@ Cam_Track (usercmd_t *cmd)
if (cl_chasecam->int_val) { if (cl_chasecam->int_val) {
cmd->forwardmove = cmd->sidemove = cmd->upmove = 0; cmd->forwardmove = cmd->sidemove = cmd->upmove = 0;
VectorCopy (player->viewangles, cl.viewstate.angles); VectorCopy (player->viewangles, cl.viewstate.player_angles);
VectorCopy (player->pls.es.origin, desired_position); VectorCopy (player->pls.es.origin, desired_position);
if (memcmp (&desired_position, &self->pls.es.origin, if (memcmp (&desired_position, &self->pls.es.origin,
sizeof (desired_position)) != 0) { sizeof (desired_position)) != 0) {
@ -467,8 +467,8 @@ Cam_Track (usercmd_t *cmd)
VectorCopy (desired_position, self->pls.es.origin); VectorCopy (desired_position, self->pls.es.origin);
VectorSubtract (player->pls.es.origin, desired_position, vec); VectorSubtract (player->pls.es.origin, desired_position, vec);
vectoangles (vec, cl.viewstate.angles); vectoangles (vec, cl.viewstate.player_angles);
cl.viewstate.angles[0] = -cl.viewstate.angles[0]; cl.viewstate.player_angles[0] = -cl.viewstate.player_angles[0];
} }
} }
@ -535,8 +535,8 @@ Cam_SetView (void)
adjustang (cam_viewangles[YAW], vec2[YAW], adjustang (cam_viewangles[YAW], vec2[YAW],
cl_camera_maxyaw->value); cl_camera_maxyaw->value);
} }
VectorCopy (cam_viewangles, cl.viewstate.angles); VectorCopy (cam_viewangles, cl.viewstate.player_angles);
VectorCopy (cl.viewstate.angles, cl.simangles); VectorCopy (cl.viewstate.player_angles, cl.simangles);
cl.simangles[ROLL] = 0; // FIXME @@@ cl.simangles[ROLL] = 0; // FIXME @@@
} }
#endif #endif
@ -575,7 +575,7 @@ Cam_FinishMove (usercmd_t *cmd)
adjustang (cam_viewangles[YAW], vec2[YAW], adjustang (cam_viewangles[YAW], vec2[YAW],
cl_camera_maxyaw->value); cl_camera_maxyaw->value);
} }
VectorCopy (cam_viewangles, cl.viewstate.angles); VectorCopy (cam_viewangles, cl.viewstate.player_angles);
} }
#endif #endif
@ -586,7 +586,7 @@ Cam_FinishMove (usercmd_t *cmd)
if (autocam > CAM_TRACK) { if (autocam > CAM_TRACK) {
Cam_Unlock (); Cam_Unlock ();
VectorCopy (cl.viewstate.angles, cmd->angles); VectorCopy (cl.viewstate.player_angles, cmd->angles);
return; return;
} }
} else } else

View file

@ -333,7 +333,7 @@ nextdemomessage:
cls.netchan.outgoing_sequence++; cls.netchan.outgoing_sequence++;
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
Qread (cls.demofile, &f, 4); Qread (cls.demofile, &f, 4);
cl.viewstate.angles[i] = LittleFloat (f); cl.viewstate.player_angles[i] = LittleFloat (f);
} }
break; break;
@ -462,7 +462,7 @@ CL_WriteDemoCmd (usercmd_t *pcmd)
Qwrite (cls.demofile, &cmd, sizeof (cmd)); Qwrite (cls.demofile, &cmd, sizeof (cmd));
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
fl = LittleFloat (cl.viewstate.angles[i]); fl = LittleFloat (cl.viewstate.player_angles[i]);
Qwrite (cls.demofile, &fl, 4); Qwrite (cls.demofile, &fl, 4);
} }

View file

@ -394,7 +394,7 @@ CL_LinkPlayers (void)
// spawn light flashes, even ones coming from invisible objects // spawn light flashes, even ones coming from invisible objects
if (j == cl.playernum) { if (j == cl.playernum) {
org = cl.viewstate.origin; org = cl.viewstate.player_origin;
r_data->player_entity = &cl_player_ents[j]; r_data->player_entity = &cl_player_ents[j];
clientplayer = true; clientplayer = true;
} else { } else {
@ -444,8 +444,8 @@ CL_LinkPlayers (void)
// angles // angles
if (j == cl.playernum) if (j == cl.playernum)
{ {
ang[PITCH] = -cl.viewstate.angles[PITCH] / 3.0; ang[PITCH] = -cl.viewstate.player_angles[PITCH] / 3.0;
ang[YAW] = cl.viewstate.angles[YAW]; ang[YAW] = cl.viewstate.player_angles[YAW];
} else { } else {
ang[PITCH] = -state->viewangles[PITCH] / 3.0; ang[PITCH] = -state->viewangles[PITCH] / 3.0;
ang[YAW] = state->viewangles[YAW]; ang[YAW] = state->viewangles[YAW];
@ -516,14 +516,14 @@ CL_EmitEntities (void)
return; return;
TEntContext_t tentCtx = { TEntContext_t tentCtx = {
cl.viewstate.origin, cl.worldmodel, cl.viewentity cl.viewstate.player_origin, cl.worldmodel, cl.viewentity
}; };
CL_LinkPlayers (); CL_LinkPlayers ();
CL_LinkPacketEntities (); CL_LinkPacketEntities ();
CL_UpdateTEnts (cl.time, &tentCtx); CL_UpdateTEnts (cl.time, &tentCtx);
if (cl_draw_locs->int_val) { if (cl_draw_locs->int_val) {
locs_draw (cl.time, cl.viewstate.origin); locs_draw (cl.time, cl.viewstate.player_origin);
} }
} }

View file

@ -90,9 +90,9 @@ CL_BaseMove (usercmd_t *cmd)
if (cls.state != ca_active) { if (cls.state != ca_active) {
return; return;
} }
VectorCopy (cl.viewstate.angles, cl.movestate.angles);//FIXME VectorCopy (cl.viewstate.player_angles, cl.movestate.angles);//FIXME
CL_Input_BuildMove (host_frametime, &cl.movestate, &cl.viewstate); CL_Input_BuildMove (host_frametime, &cl.movestate, &cl.viewstate);
VectorCopy (cl.movestate.angles, cl.viewstate.angles);//FIXME VectorCopy (cl.movestate.angles, cl.viewstate.player_angles);//FIXME
memset (cmd, 0, sizeof (*cmd)); memset (cmd, 0, sizeof (*cmd));
cmd->forwardmove = cl.movestate.move[FORWARD]; cmd->forwardmove = cl.movestate.move[FORWARD];
@ -139,7 +139,7 @@ CL_FinishMove (usercmd_t *cmd)
} }
cmd->msec = ms; cmd->msec = ms;
VectorCopy (cl.viewstate.angles, cmd->angles); VectorCopy (cl.viewstate.player_angles, cmd->angles);
cmd->impulse = in_impulse; cmd->impulse = in_impulse;
in_impulse = 0; in_impulse = 0;

View file

@ -1102,7 +1102,7 @@ CL_Download_f (void)
static void static void
Force_CenterView_f (void) Force_CenterView_f (void)
{ {
cl.viewstate.angles[PITCH] = 0; cl.viewstate.player_angles[PITCH] = 0;
} }
static void static void
@ -1111,12 +1111,12 @@ CL_PRotate_f (void)
if ((cl.fpd & FPD_LIMIT_PITCH) || Cmd_Argc() < 2) if ((cl.fpd & FPD_LIMIT_PITCH) || Cmd_Argc() < 2)
return; return;
cl.viewstate.angles[PITCH] += atoi (Cmd_Argv (1)); cl.viewstate.player_angles[PITCH] += atoi (Cmd_Argv (1));
if (cl.viewstate.angles[PITCH] < -70) if (cl.viewstate.player_angles[PITCH] < -70)
cl.viewstate.angles[PITCH] = -70; cl.viewstate.player_angles[PITCH] = -70;
else if (cl.viewstate.angles[PITCH] > 80) else if (cl.viewstate.player_angles[PITCH] > 80)
cl.viewstate.angles[PITCH] = 80; cl.viewstate.player_angles[PITCH] = 80;
} }
static void static void
@ -1125,8 +1125,8 @@ CL_Rotate_f (void)
if ((cl.fpd & FPD_LIMIT_YAW) || Cmd_Argc() < 2) if ((cl.fpd & FPD_LIMIT_YAW) || Cmd_Argc() < 2)
return; return;
cl.viewstate.angles[YAW] += atoi (Cmd_Argv (1)); cl.viewstate.player_angles[YAW] += atoi (Cmd_Argv (1));
cl.viewstate.angles[YAW] = anglemod (cl.viewstate.angles[YAW]); cl.viewstate.player_angles[YAW] = anglemod(cl.viewstate.player_angles[YAW]);
} }
void void

View file

@ -1295,7 +1295,7 @@ CL_ParseMuzzleFlash (void)
pl = &cl.frames[parsecountmod].playerstate[i - 1]; pl = &cl.frames[parsecountmod].playerstate[i - 1];
if (i - 1 == cl.playernum) if (i - 1 == cl.playernum)
AngleVectors (cl.viewstate.angles, f, r, u); AngleVectors (cl.viewstate.player_angles, f, r, u);
else else
AngleVectors (pl->viewangles, f, r, u); AngleVectors (pl->viewangles, f, r, u);
@ -1317,7 +1317,7 @@ CL_ParseServerMessage (void)
const char *str; const char *str;
static dstring_t *stuffbuf; static dstring_t *stuffbuf;
TEntContext_t tentCtx = { TEntContext_t tentCtx = {
cl.viewstate.origin, cl.worldmodel, cl.viewentity cl.viewstate.player_origin, cl.worldmodel, cl.viewentity
}; };
received_framecount = host_framecount; received_framecount = host_framecount;
@ -1437,7 +1437,7 @@ CL_ParseServerMessage (void)
case svc_setangle: case svc_setangle:
{ {
vec_t *dest = cl.viewstate.angles; vec_t *dest = cl.viewstate.player_angles;
vec3_t dummy; vec3_t dummy;
if (cls.demoplayback2) { if (cls.demoplayback2) {
@ -1565,15 +1565,15 @@ CL_ParseServerMessage (void)
cl.completed_time = realtime; cl.completed_time = realtime;
r_data->vid->recalc_refdef = true; // go to full screen r_data->vid->recalc_refdef = true; // go to full screen
Sys_MaskPrintf (SYS_dev, "intermission simorg: "); Sys_MaskPrintf (SYS_dev, "intermission simorg: ");
MSG_ReadCoordV (net_message, &cl.viewstate.origin[0]);//FIXME MSG_ReadCoordV (net_message, &cl.viewstate.player_origin[0]);//FIXME
cl.viewstate.origin[3] = 1; cl.viewstate.player_origin[3] = 1;
Sys_MaskPrintf (SYS_dev, VEC4F_FMT, Sys_MaskPrintf (SYS_dev, VEC4F_FMT,
VEC4_EXP (cl.viewstate.origin)); VEC4_EXP (cl.viewstate.player_origin));
Sys_MaskPrintf (SYS_dev, "\nintermission simangles: "); Sys_MaskPrintf (SYS_dev, "\nintermission simangles: ");
MSG_ReadAngleV (net_message, cl.viewstate.angles); MSG_ReadAngleV (net_message, cl.viewstate.player_angles);
cl.viewstate.angles[ROLL] = 0; // FIXME @@@ cl.viewstate.player_angles[ROLL] = 0; // FIXME @@@
Sys_MaskPrintf (SYS_dev, "%f %f %f", Sys_MaskPrintf (SYS_dev, "%f %f %f",
VectorExpand (cl.viewstate.angles)); VectorExpand (cl.viewstate.player_angles));
Sys_MaskPrintf (SYS_dev, "\n"); Sys_MaskPrintf (SYS_dev, "\n");
cl.viewstate.velocity = (vec4f_t) { }; cl.viewstate.velocity = (vec4f_t) { };

View file

@ -133,7 +133,7 @@ CL_PredictMove (void)
return; return;
//VectorCopy (cl.viewstate.angles, cl.viewstate.angles); //VectorCopy (cl.viewstate.angles, cl.viewstate.angles);
cl.viewstate.angles[ROLL] = 0; // FIXME @@@ cl.viewstate.player_angles[ROLL] = 0; // FIXME @@@
// this is the last frame received from the server // this is the last frame received from the server
from = &cl.frames[cls.netchan.incoming_sequence & UPDATE_MASK]; from = &cl.frames[cls.netchan.incoming_sequence & UPDATE_MASK];
@ -141,7 +141,7 @@ CL_PredictMove (void)
if (!cl_predict->int_val) { if (!cl_predict->int_val) {
cl.viewstate.velocity = fromes->velocity; cl.viewstate.velocity = fromes->velocity;
cl.viewstate.origin = fromes->origin; cl.viewstate.player_origin = fromes->origin;
return; return;
} }
@ -182,11 +182,12 @@ CL_PredictMove (void)
if (fabs (fromes->origin[i] - toes->origin[i]) > 128) { if (fabs (fromes->origin[i] - toes->origin[i]) > 128) {
// teleported, so don't lerp // teleported, so don't lerp
cl.viewstate.velocity = toes->velocity; cl.viewstate.velocity = toes->velocity;
cl.viewstate.origin = toes->origin; cl.viewstate.player_origin = toes->origin;
return; return;
} }
cl.viewstate.origin = fromes->origin + f * (toes->origin - fromes->origin); cl.viewstate.player_origin = fromes->origin
+ f * (toes->origin - fromes->origin);
} }
void void

View file

@ -201,6 +201,9 @@ CL_UpdateScreen (double realtime)
cl.viewstate.intermission = cl.intermission != 0; cl.viewstate.intermission = cl.intermission != 0;
V_PrepBlend (&cl.viewstate); V_PrepBlend (&cl.viewstate);
int seq = (cls.netchan.outgoing_sequence - 1) & UPDATE_MASK;
frame_t *frame = &cl.frames[seq];
cl.viewstate.movecmd[FORWARD] = frame->cmd.forwardmove;
V_RenderView (&cl.viewstate); V_RenderView (&cl.viewstate);
SCR_UpdateScreen (cl.viewstate.camera_transform, SCR_UpdateScreen (cl.viewstate.camera_transform,
realtime, scr_funcs[index]); realtime, scr_funcs[index]);

View file

@ -184,10 +184,10 @@ Team_ParseSay (dstring_t *buf, const char *s)
case 'l': case 'l':
location: location:
bracket = 0; bracket = 0;
location = locs_find (cl.viewstate.origin); location = locs_find (cl.viewstate.player_origin);
if (location) { if (location) {
recorded_location = true; recorded_location = true;
last_recorded_location = cl.viewstate.origin; last_recorded_location = cl.viewstate.player_origin;
t1 = location->name; t1 = location->name;
} else } else
snprintf (t2, sizeof (t2), "Unknown!"); snprintf (t2, sizeof (t2), "Unknown!");
@ -279,7 +279,7 @@ void
Team_Dead (void) Team_Dead (void)
{ {
died = true; died = true;
death_location = cl.viewstate.origin; death_location = cl.viewstate.player_origin;
} }
void void
@ -370,7 +370,7 @@ locs_loc (void)
if (strcasecmp (Cmd_Argv (1), "add") == 0) { if (strcasecmp (Cmd_Argv (1), "add") == 0) {
if (Cmd_Argc () >= 3) if (Cmd_Argc () >= 3)
locs_mark (cl.viewstate.origin, desc); locs_mark (cl.viewstate.player_origin, desc);
else else
Sys_Printf ("loc add <description> :marks the current location " Sys_Printf ("loc add <description> :marks the current location "
"with the description and records the information " "with the description and records the information "
@ -379,7 +379,7 @@ locs_loc (void)
if (strcasecmp (Cmd_Argv (1), "rename") == 0) { if (strcasecmp (Cmd_Argv (1), "rename") == 0) {
if (Cmd_Argc () >= 3) if (Cmd_Argc () >= 3)
locs_edit (cl.viewstate.origin, desc); locs_edit (cl.viewstate.player_origin, desc);
else else
Sys_Printf ("loc rename <description> :changes the description of " Sys_Printf ("loc rename <description> :changes the description of "
"the nearest location marker\n"); "the nearest location marker\n");
@ -387,14 +387,14 @@ locs_loc (void)
if (strcasecmp (Cmd_Argv (1),"delete") == 0) { if (strcasecmp (Cmd_Argv (1),"delete") == 0) {
if (Cmd_Argc () == 2) if (Cmd_Argc () == 2)
locs_del (cl.viewstate.origin); locs_del (cl.viewstate.player_origin);
else else
Sys_Printf ("loc delete :removes nearest location marker\n"); Sys_Printf ("loc delete :removes nearest location marker\n");
} }
if (strcasecmp (Cmd_Argv (1),"move") == 0) { if (strcasecmp (Cmd_Argv (1),"move") == 0) {
if (Cmd_Argc () == 2) if (Cmd_Argc () == 2)
locs_edit (cl.viewstate.origin, NULL); locs_edit (cl.viewstate.player_origin, NULL);
else else
Sys_Printf ("loc move :moves the nearest location marker to your " Sys_Printf ("loc move :moves the nearest location marker to your "
"current location\n"); "current location\n");
@ -409,7 +409,7 @@ Locs_Loc_Get (void)
if (GIB_Argc () != 1) if (GIB_Argc () != 1)
GIB_USAGE (""); GIB_USAGE ("");
else { else {
location = locs_find (cl.viewstate.origin); location = locs_find (cl.viewstate.player_origin);
GIB_Return (location ? location->name : "unknown"); GIB_Return (location ? location->name : "unknown");
} }
} }