DarkPlaces
Game engine based on the Quake 1 engine by id Software, developed by LadyHavoc
 
view.c
Go to the documentation of this file.
1/*
2Copyright (C) 1996-1997 Id Software, Inc.
3
4This program is free software; you can redistribute it and/or
5modify it under the terms of the GNU General Public License
6as published by the Free Software Foundation; either version 2
7of the License, or (at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13See the GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program; if not, write to the Free Software
17Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19*/
20// view.c -- player eye positioning
21
22#include "quakedef.h"
23#include "cl_collision.h"
24#include "image.h"
25
26/*
27
28The view is allowed to move slightly from it's true position for bobbing,
29but if it exceeds 8 pixels linear distance (spherical, not box), the list of
30entities sent from the server may not include everything in the pvs, especially
31when crossing a water boudnary.
32
33*/
34
35cvar_t cl_rollspeed = {CF_CLIENT | CF_ARCHIVE, "cl_rollspeed", "200", "how much strafing is necessary to tilt the view"};
36cvar_t cl_rollangle = {CF_CLIENT | CF_ARCHIVE, "cl_rollangle", "2.0", "how much to tilt the view when strafing"};
37
38cvar_t cl_bob = {CF_CLIENT | CF_ARCHIVE, "cl_bob","0.02", "view bobbing amount"};
39cvar_t cl_bobcycle = {CF_CLIENT | CF_ARCHIVE, "cl_bobcycle","0.6", "view bobbing speed"};
40cvar_t cl_bobup = {CF_CLIENT | CF_ARCHIVE, "cl_bobup","0.5", "view bobbing adjustment that makes the up or down swing of the bob last longer"};
41cvar_t cl_bob2 = {CF_CLIENT | CF_ARCHIVE, "cl_bob2","0", "sideways view bobbing amount"};
42cvar_t cl_bob2cycle = {CF_CLIENT | CF_ARCHIVE, "cl_bob2cycle","0.6", "sideways view bobbing speed"};
43cvar_t cl_bob2smooth = {CF_CLIENT | CF_ARCHIVE, "cl_bob2smooth","0.05", "how fast the view goes back when you stop touching the ground"};
44cvar_t cl_bobfall = {CF_CLIENT | CF_ARCHIVE, "cl_bobfall","0", "how much the view swings down when falling (influenced by the speed you hit the ground with)"};
45cvar_t cl_bobfallcycle = {CF_CLIENT | CF_ARCHIVE, "cl_bobfallcycle","3", "speed of the bobfall swing"};
46cvar_t cl_bobfallminspeed = {CF_CLIENT | CF_ARCHIVE, "cl_bobfallminspeed","200", "necessary amount of speed for bob-falling to occur"};
47cvar_t cl_bobmodel = {CF_CLIENT | CF_ARCHIVE, "cl_bobmodel", "1", "enables gun bobbing"};
48cvar_t cl_bobmodel_side = {CF_CLIENT | CF_ARCHIVE, "cl_bobmodel_side", "0.15", "gun bobbing sideways sway amount"};
49cvar_t cl_bobmodel_up = {CF_CLIENT | CF_ARCHIVE, "cl_bobmodel_up", "0.06", "gun bobbing upward movement amount"};
50cvar_t cl_bobmodel_forward = {CF_CLIENT | CF_ARCHIVE, "cl_bobmodel_forward", "0", "gun bobbing forward movement amount"};
51cvar_t cl_bobmodel_classic = {CF_CLIENT | CF_ARCHIVE, "cl_bobmodel_classic", "1", "classic Quake-style forward gun bobbing"};
52cvar_t cl_bobmodel_speed = {CF_CLIENT | CF_ARCHIVE, "cl_bobmodel_speed", "7", "gun bobbing speed"};
53cvar_t cl_bob_limit = {CF_CLIENT | CF_ARCHIVE, "cl_bob_limit", "7", "limits bobbing to this much distance from view_ofs"};
54cvar_t cl_bob_limit_heightcheck = {CF_CLIENT | CF_ARCHIVE, "cl_bob_limit_heightcheck", "0", "check ceiling and floor height against cl_bob_limit and scale down all view bobbing if could result in camera being in solid"};
55cvar_t cl_bob_limit_heightcheck_dontcrosswatersurface = {CF_CLIENT | CF_ARCHIVE, "cl_bob_limit_heightcheck_dontcrosswatersurface", "1", "limit cl_bob_limit to not crossing liquid surfaces also"};
56cvar_t cl_bob_velocity_limit = {CF_CLIENT | CF_ARCHIVE, "cl_bob_velocity_limit", "400", "limits the xyspeed value in the bobbing code"};
57
58cvar_t cl_leanmodel = {CF_CLIENT | CF_ARCHIVE, "cl_leanmodel", "0", "enables gun leaning"};
59cvar_t cl_leanmodel_side_speed = {CF_CLIENT | CF_ARCHIVE, "cl_leanmodel_side_speed", "0.7", "gun leaning sideways speed"};
60cvar_t cl_leanmodel_side_limit = {CF_CLIENT | CF_ARCHIVE, "cl_leanmodel_side_limit", "35", "gun leaning sideways limit"};
61cvar_t cl_leanmodel_side_highpass1 = {CF_CLIENT | CF_ARCHIVE, "cl_leanmodel_side_highpass1", "30", "gun leaning sideways pre-highpass in 1/s"};
62cvar_t cl_leanmodel_side_highpass = {CF_CLIENT | CF_ARCHIVE, "cl_leanmodel_side_highpass", "3", "gun leaning sideways highpass in 1/s"};
63cvar_t cl_leanmodel_side_lowpass = {CF_CLIENT | CF_ARCHIVE, "cl_leanmodel_side_lowpass", "20", "gun leaning sideways lowpass in 1/s"};
64cvar_t cl_leanmodel_up_speed = {CF_CLIENT | CF_ARCHIVE, "cl_leanmodel_up_speed", "0.65", "gun leaning upward speed"};
65cvar_t cl_leanmodel_up_limit = {CF_CLIENT | CF_ARCHIVE, "cl_leanmodel_up_limit", "50", "gun leaning upward limit"};
66cvar_t cl_leanmodel_up_highpass1 = {CF_CLIENT | CF_ARCHIVE, "cl_leanmodel_up_highpass1", "5", "gun leaning upward pre-highpass in 1/s"};
67cvar_t cl_leanmodel_up_highpass = {CF_CLIENT | CF_ARCHIVE, "cl_leanmodel_up_highpass", "15", "gun leaning upward highpass in 1/s"};
68cvar_t cl_leanmodel_up_lowpass = {CF_CLIENT | CF_ARCHIVE, "cl_leanmodel_up_lowpass", "20", "gun leaning upward lowpass in 1/s"};
69
70cvar_t cl_followmodel = {CF_CLIENT | CF_ARCHIVE, "cl_followmodel", "0", "enables gun following"};
71cvar_t cl_followmodel_side_speed = {CF_CLIENT | CF_ARCHIVE, "cl_followmodel_side_speed", "0.25", "gun following sideways speed"};
72cvar_t cl_followmodel_side_limit = {CF_CLIENT | CF_ARCHIVE, "cl_followmodel_side_limit", "6", "gun following sideways limit"};
73cvar_t cl_followmodel_side_highpass1 = {CF_CLIENT | CF_ARCHIVE, "cl_followmodel_side_highpass1", "30", "gun following sideways pre-highpass in 1/s"};
74cvar_t cl_followmodel_side_highpass = {CF_CLIENT | CF_ARCHIVE, "cl_followmodel_side_highpass", "5", "gun following sideways highpass in 1/s"};
75cvar_t cl_followmodel_side_lowpass = {CF_CLIENT | CF_ARCHIVE, "cl_followmodel_side_lowpass", "10", "gun following sideways lowpass in 1/s"};
76cvar_t cl_followmodel_up_speed = {CF_CLIENT | CF_ARCHIVE, "cl_followmodel_up_speed", "0.5", "gun following upward speed"};
77cvar_t cl_followmodel_up_limit = {CF_CLIENT | CF_ARCHIVE, "cl_followmodel_up_limit", "5", "gun following upward limit"};
78cvar_t cl_followmodel_up_highpass1 = {CF_CLIENT | CF_ARCHIVE, "cl_followmodel_up_highpass1", "60", "gun following upward pre-highpass in 1/s"};
79cvar_t cl_followmodel_up_highpass = {CF_CLIENT | CF_ARCHIVE, "cl_followmodel_up_highpass", "2", "gun following upward highpass in 1/s"};
80cvar_t cl_followmodel_up_lowpass = {CF_CLIENT | CF_ARCHIVE, "cl_followmodel_up_lowpass", "10", "gun following upward lowpass in 1/s"};
81
82cvar_t cl_viewmodel_scale = {CF_CLIENT, "cl_viewmodel_scale", "1", "changes size of gun model, lower values prevent poking into walls but cause strange artifacts on lighting and especially r_stereo/vid_stereobuffer options where the size of the gun becomes visible"};
83
84cvar_t v_kicktime = {CF_CLIENT, "v_kicktime", "0.5", "how long a view kick from damage lasts"};
85cvar_t v_kickroll = {CF_CLIENT, "v_kickroll", "0.6", "how much a view kick from damage rolls your view"};
86cvar_t v_kickpitch = {CF_CLIENT, "v_kickpitch", "0.6", "how much a view kick from damage pitches your view"};
87
88cvar_t v_iyaw_cycle = {CF_CLIENT, "v_iyaw_cycle", "2", "v_idlescale yaw speed"};
89cvar_t v_iroll_cycle = {CF_CLIENT, "v_iroll_cycle", "0.5", "v_idlescale roll speed"};
90cvar_t v_ipitch_cycle = {CF_CLIENT, "v_ipitch_cycle", "1", "v_idlescale pitch speed"};
91cvar_t v_iyaw_level = {CF_CLIENT, "v_iyaw_level", "0.3", "v_idlescale yaw amount"};
92cvar_t v_iroll_level = {CF_CLIENT, "v_iroll_level", "0.1", "v_idlescale roll amount"};
93cvar_t v_ipitch_level = {CF_CLIENT, "v_ipitch_level", "0.3", "v_idlescale pitch amount"};
94
95cvar_t v_idlescale = {CF_CLIENT, "v_idlescale", "0", "how much of the quake 'drunken view' effect to use"};
96
97cvar_t v_isometric = {CF_CLIENT, "v_isometric", "0", "changes view to isometric (non-perspective)"};
98cvar_t v_isometric_verticalfov = {CF_CLIENT, "v_isometric_verticalfov", "512", "vertical field of view in game units (horizontal is computed using aspect ratio based on this)"};
99cvar_t v_isometric_xx = {CF_CLIENT, "v_isometric_xx", "1", "camera matrix"};
100cvar_t v_isometric_xy = {CF_CLIENT, "v_isometric_xy", "0", "camera matrix"};
101cvar_t v_isometric_xz = {CF_CLIENT, "v_isometric_xz", "0", "camera matrix"};
102cvar_t v_isometric_yx = {CF_CLIENT, "v_isometric_yx", "0", "camera matrix"};
103cvar_t v_isometric_yy = {CF_CLIENT, "v_isometric_yy", "1", "camera matrix"};
104cvar_t v_isometric_yz = {CF_CLIENT, "v_isometric_yz", "0", "camera matrix"};
105cvar_t v_isometric_zx = {CF_CLIENT, "v_isometric_zx", "0", "camera matrix"};
106cvar_t v_isometric_zy = {CF_CLIENT, "v_isometric_zy", "0", "camera matrix"};
107cvar_t v_isometric_zz = {CF_CLIENT, "v_isometric_zz", "1", "camera matrix"};
108cvar_t v_isometric_tx = {CF_CLIENT, "v_isometric_tx", "0", "camera position (player-relative)"};
109cvar_t v_isometric_ty = {CF_CLIENT, "v_isometric_ty", "0", "camera position (player-relative)"};
110cvar_t v_isometric_tz = {CF_CLIENT, "v_isometric_tz", "0", "camera position (player-relative)"};
111cvar_t v_isometric_rot_pitch = {CF_CLIENT, "v_isometric_rot_pitch", "60", "camera rotation"};
112cvar_t v_isometric_rot_yaw = {CF_CLIENT, "v_isometric_rot_yaw", "135", "camera rotation"};
113cvar_t v_isometric_rot_roll = {CF_CLIENT, "v_isometric_rot_roll", "0", "camera rotation"};
114cvar_t v_isometric_relx = {CF_CLIENT, "v_isometric_relx", "0", "camera position*forward"};
115cvar_t v_isometric_rely = {CF_CLIENT, "v_isometric_rely", "0", "camera position*left"};
116cvar_t v_isometric_relz = {CF_CLIENT, "v_isometric_relz", "0", "camera position*up"};
117cvar_t v_isometric_flipcullface = {CF_CLIENT, "v_isometric_flipcullface", "0", "flips the backface culling"};
118cvar_t v_isometric_locked_orientation = {CF_CLIENT, "v_isometric_locked_orientation", "1", "camera rotation is fixed"};
119cvar_t v_isometric_usevieworiginculling = {CF_CLIENT, "v_isometric_usevieworiginculling", "0", "check visibility to the player location (can look pretty weird)"};
120
121cvar_t crosshair = {CF_CLIENT | CF_ARCHIVE, "crosshair", "0", "selects crosshair to use (0 is none)"};
122
123cvar_t v_centermove = {CF_CLIENT, "v_centermove", "0.15", "how long before the view begins to center itself (if freelook/+mlook/+jlook/+klook are off)"};
124cvar_t v_centerspeed = {CF_CLIENT, "v_centerspeed","500", "how fast the view centers itself"};
125
126cvar_t cl_stairsmoothspeed = {CF_CLIENT | CF_ARCHIVE, "cl_stairsmoothspeed", "160", "how fast your view moves upward/downward when running up/down stairs"};
127
128cvar_t cl_smoothviewheight = {CF_CLIENT | CF_ARCHIVE, "cl_smoothviewheight", "0", "time of the averaging to the viewheight value so that it creates a smooth transition. higher values = longer transition, 0 for instant transition."};
129
130cvar_t chase_back = {CF_CLIENT | CF_ARCHIVE, "chase_back", "48", "chase cam distance from the player"};
131cvar_t chase_up = {CF_CLIENT | CF_ARCHIVE, "chase_up", "24", "chase cam distance from the player"};
132cvar_t chase_active = {CF_CLIENT | CF_ARCHIVE, "chase_active", "0", "enables chase cam"};
133cvar_t chase_overhead = {CF_CLIENT | CF_ARCHIVE, "chase_overhead", "0", "chase cam looks straight down if this is not zero"};
134// GAME_GOODVSBAD2
135cvar_t chase_stevie = {CF_CLIENT, "chase_stevie", "0", "(GOODVSBAD2 only) chase cam view from above"};
136
137cvar_t v_deathtilt = {CF_CLIENT, "v_deathtilt", "1", "whether to use sideways view when dead"};
138cvar_t v_deathtiltangle = {CF_CLIENT, "v_deathtiltangle", "80", "what roll angle to use when tilting the view while dead"};
139
140// Prophecy camera pitchangle by Alexander "motorsep" Zubov
141cvar_t chase_pitchangle = {CF_CLIENT | CF_ARCHIVE, "chase_pitchangle", "55", "chase cam pitch angle"};
142
143cvar_t v_yshearing = {CF_CLIENT, "v_yshearing", "0", "be all out of gum (set this to the maximum angle to allow Y shearing for - try values like 75)"};
144
145cvar_t r_viewmodel_quake = {CF_CLIENT | CF_ARCHIVE, "r_viewmodel_quake", "0", "Quake-style weapon viewmodel angle adjustment"};
146
148
150
152{
153 if (cl.laststop == cl.time)
154 return; // something else is keeping it from drifting
155
156 if (cl.nodrift || !cl.pitchvel)
157 {
159 cl.nodrift = false;
160 cl.driftmove = 0;
161 }
162}
163
168
170{
171 cl.laststop = cl.time;
172 cl.nodrift = true;
173 cl.pitchvel = 0;
174}
175
176/*
177===============
178V_DriftPitch
179
180Moves the client pitch angle towards cl.idealpitch sent by the server.
181
182If the user is adjusting pitch manually, either with lookup/lookdown,
183mlook and mouse, or klook and keyboard, pitch drifting is constantly stopped.
184
185Drifting is enabled when the center view key is hit, mlook is released and
186lookspring is non 0, or when
187===============
188*/
189void V_DriftPitch (void)
190{
191 float delta, move;
192
194 {
195 cl.driftmove = 0;
196 cl.pitchvel = 0;
197 return;
198 }
199
200// don't count small mouse motion
201 if (cl.nodrift)
202 {
204 cl.driftmove = 0;
205 else
207
209 {
211 }
212 return;
213 }
214
215 delta = cl.idealpitch - cl.viewangles[PITCH];
216
217 if (!delta)
218 {
219 cl.pitchvel = 0;
220 return;
221 }
222
223 move = cl.realframetime * cl.pitchvel;
225
226 if (delta > 0)
227 {
228 if (move > delta)
229 {
230 cl.pitchvel = 0;
231 move = delta;
232 }
233 cl.viewangles[PITCH] += move;
234 }
235 else if (delta < 0)
236 {
237 if (move > -delta)
238 {
239 cl.pitchvel = 0;
240 move = -delta;
241 }
242 cl.viewangles[PITCH] -= move;
243 }
244}
245
246
247/*
248==============================================================================
249
250 SCREEN FLASHES
251
252==============================================================================
253*/
254
255
256/*
257===============
258V_ParseDamage
259===============
260*/
261void V_ParseDamage (void)
262{
263 int armor, blood;
264 vec3_t from;
265 //vec3_t forward, right;
266 vec3_t localfrom;
267 entity_t *ent;
268 //float side;
269 float count;
270
271 armor = MSG_ReadByte(&cl_message);
272 blood = MSG_ReadByte(&cl_message);
274
275 // Send the Dmg Globals to CSQC
276 CL_VM_UpdateDmgGlobals(blood, armor, from);
277
278 count = blood*0.5 + armor*0.5;
279 if (count < 10)
280 count = 10;
281
282 cl.faceanimtime = cl.time + 0.2; // put sbar face into pain frame
283
288 if (cl.cshifts[CSHIFT_DAMAGE].percent > 150)
290
291 if (armor > blood)
292 {
296 }
297 else if (armor)
298 {
302 }
303 else
304 {
308 }
309
310 // calculate view angle kicks
312 {
313 ent = &cl.entities[cl.viewentity];
314 Matrix4x4_Transform(&ent->render.inversematrix, from, localfrom);
315 VectorNormalize(localfrom);
316 v_dmg_pitch = count * localfrom[0] * v_kickpitch.value;
317 v_dmg_roll = count * localfrom[1] * v_kickroll.value;
319 }
320}
321
323
324/*
325==================
326V_cshift_f
327==================
328*/
330{
331 v_cshift.destcolor[0] = atof(Cmd_Argv(cmd, 1));
332 v_cshift.destcolor[1] = atof(Cmd_Argv(cmd, 2));
333 v_cshift.destcolor[2] = atof(Cmd_Argv(cmd, 3));
334 v_cshift.percent = atof(Cmd_Argv(cmd, 4));
335}
336
337
338/*
339==================
340V_BonusFlash_f
341
342When you run over an item, the server sends this command
343==================
344*/
346{
347 if(Cmd_Argc(cmd) == 1)
348 {
354 }
355 else if(Cmd_Argc(cmd) >= 4 && Cmd_Argc(cmd) <= 6)
356 {
357 cl.cshifts[CSHIFT_BONUS].destcolor[0] = atof(Cmd_Argv(cmd, 1)) * 255;
358 cl.cshifts[CSHIFT_BONUS].destcolor[1] = atof(Cmd_Argv(cmd, 2)) * 255;
359 cl.cshifts[CSHIFT_BONUS].destcolor[2] = atof(Cmd_Argv(cmd, 3)) * 255;
360 if(Cmd_Argc(cmd) >= 5)
361 cl.cshifts[CSHIFT_BONUS].percent = atof(Cmd_Argv(cmd, 4)) * 255; // yes, these are HEXADECIMAL percent ;)
362 else
364 if(Cmd_Argc(cmd) >= 6)
365 cl.cshifts[CSHIFT_BONUS].alphafade = atof(Cmd_Argv(cmd, 5)) * 255;
366 else
368 }
369 else
370 Con_Printf("usage:\nbf, or bf R G B [A [alphafade]]\n");
371}
372
373/*
374==============================================================================
375
376 VIEW RENDERING
377
378==============================================================================
379*/
380
383
384#include "cl_collision.h"
385#include "csprogs.h"
386
387/*
388==================
389V_CalcRefdef
390
391==================
392*/
393#if 0
394static vec3_t eyeboxmins = {-16, -16, -24};
395static vec3_t eyeboxmaxs = { 16, 16, 32};
396#endif
397
398static vec_t lowpass(vec_t value, vec_t frac, vec_t *store)
399{
400 frac = bound(0, frac, 1);
401 return (*store = *store * (1 - frac) + value * frac);
402}
403
404static vec_t lowpass_limited(vec_t value, vec_t frac, vec_t limit, vec_t *store)
405{
406 lowpass(value, frac, store);
407 return (*store = bound(value - limit, *store, value + limit));
408}
409
410static vec_t highpass(vec_t value, vec_t frac, vec_t *store)
411{
412 return value - lowpass(value, frac, store);
413}
414
415static vec_t highpass_limited(vec_t value, vec_t frac, vec_t limit, vec_t *store)
416{
417 return value - lowpass_limited(value, frac, limit, store);
418}
419
420static void lowpass3(vec3_t value, vec_t fracx, vec_t fracy, vec_t fracz, vec3_t store, vec3_t out)
421{
422 out[0] = lowpass(value[0], fracx, &store[0]);
423 out[1] = lowpass(value[1], fracy, &store[1]);
424 out[2] = lowpass(value[2], fracz, &store[2]);
425}
426
427static void highpass3(vec3_t value, vec_t fracx, vec_t fracy, vec_t fracz, vec3_t store, vec3_t out)
428{
429 out[0] = highpass(value[0], fracx, &store[0]);
430 out[1] = highpass(value[1], fracy, &store[1]);
431 out[2] = highpass(value[2], fracz, &store[2]);
432}
433
434static void highpass3_limited(vec3_t value, vec_t fracx, vec_t limitx, vec_t fracy, vec_t limity, vec_t fracz, vec_t limitz, vec3_t store, vec3_t out)
435{
436 out[0] = highpass_limited(value[0], fracx, limitx, &store[0]);
437 out[1] = highpass_limited(value[1], fracy, limity, &store[1]);
438 out[2] = highpass_limited(value[2], fracz, limitz, &store[2]);
439}
440
441/*
442 * State:
443 * cl.bob2_smooth
444 * cl.bobfall_speed
445 * cl.bobfall_swing
446 * cl.gunangles_adjustment_highpass
447 * cl.gunangles_adjustment_lowpass
448 * cl.gunangles_highpass
449 * cl.gunangles_prev
450 * cl.gunorg_adjustment_highpass
451 * cl.gunorg_adjustment_lowpass
452 * cl.gunorg_highpass
453 * cl.gunorg_prev
454 * cl.hitgroundtime
455 * cl.lastongroundtime
456 * cl.oldongrounbd
457 * cl.stairsmoothtime
458 * cl.stairsmoothz
459 * cl.calcrefdef_prevtime
460 * Extra input:
461 * cl.movecmd[0].time
462 * cl.movevars_stepheight
463 * cl.movevars_timescale
464 * cl.oldtime
465 * cl.punchangle
466 * cl.punchvector
467 * cl.qw_intermission_angles
468 * cl.qw_intermission_origin
469 * cl.qw_weaponkick
470 * cls.protocol
471 * cl.time
472 * Output:
473 * cl.csqc_viewanglesfromengine
474 * cl.csqc_viewmodelmatrixfromengine
475 * cl.csqc_vieworiginfromengine
476 * r_refdef.view.matrix
477 * viewmodelmatrix_nobob
478 * viewmodelmatrix_withbob
479 */
480
481/*
482==================
483V_CalcIntermissionRefdef
484
485==================
486*/
511
512void V_CalcRefdefUsing (const matrix4x4_t *entrendermatrix, const vec3_t clviewangles, qbool teleported, qbool clonground, qbool clcmdjump, float clstatsviewheight, qbool cldead, const vec3_t clvelocity)
513{
514 float vieworg[3], viewangles[3], smoothtime;
515 float gunorg[3], gunangles[3];
516 matrix4x4_t tmpmatrix;
517 static float viewheightavg;
518 float viewheight;
519 trace_t trace;
520
521 // react to clonground state changes (for gun bob)
522 if (clonground)
523 {
524 if (!cl.oldonground)
527 }
528 cl.oldonground = clonground;
530
531 VectorClear(gunangles);
532 VectorClear(gunorg);
536
537 // player can look around, so take the origin from the entity,
538 // and the angles from the input system
539 Matrix4x4_OriginFromMatrix(entrendermatrix, vieworg);
540 VectorCopy(clviewangles, viewangles);
541
542 // calculate how much time has passed since the last V_CalcRefdef
543 smoothtime = bound(0, cl.time - cl.stairsmoothtime, 0.1);
545
546 // fade damage flash
547 if (v_dmg_time > 0)
548 v_dmg_time -= bound(0, smoothtime, 0.1);
549
550 if (cl.intermission)
551 V_CalcIntermissionRefdef(vieworg, viewangles, entrendermatrix, clstatsviewheight);
552 else
553 {
554 // smooth stair stepping, but only if clonground and enabled
555 if (!clonground || cl_stairsmoothspeed.value <= 0 || teleported)
556 cl.stairsmoothz = vieworg[2];
557 else
558 {
559 if (cl.stairsmoothz < vieworg[2])
560 vieworg[2] = cl.stairsmoothz = bound(vieworg[2] - cl.movevars_stepheight, cl.stairsmoothz + smoothtime * cl_stairsmoothspeed.value, vieworg[2]);
561 else if (cl.stairsmoothz > vieworg[2])
562 vieworg[2] = cl.stairsmoothz = bound(vieworg[2], cl.stairsmoothz - smoothtime * cl_stairsmoothspeed.value, vieworg[2] + cl.movevars_stepheight);
563 }
564
565 // apply qw weapon recoil effect (this did not work in QW)
566 // TODO: add a cvar to disable this
567 viewangles[PITCH] += cl.qw_weaponkick;
568
569 // apply the viewofs (even if chasecam is used)
570 // Samual: Lets add smoothing for this too so that things like crouching are done with a transition.
571 viewheight = bound(0, (cl.time - cl.calcrefdef_prevtime) / max(0.0001, cl_smoothviewheight.value), 1);
572 viewheightavg = viewheightavg * (1 - viewheight) + clstatsviewheight * viewheight;
573 vieworg[2] += viewheightavg;
574
576 {
577 // observing entity from third person. Added "campitch" by Alexander "motorsep" Zubov
578 vec_t camback, camup, dist, campitch, forward[3], chase_dest[3];
579
580 camback = chase_back.value;
581 camup = chase_up.value;
582 campitch = chase_pitchangle.value;
583
584 AngleVectors(viewangles, forward, NULL, NULL);
585
587 {
589 vec3_t bestvieworg;
590 vec3_t up;
591 viewangles[PITCH] = 0;
592 AngleVectors(viewangles, forward, NULL, up);
593 // trace a little further so it hits a surface more consistently (to avoid 'snapping' on the edge of the range)
594 chase_dest[0] = vieworg[0] - forward[0] * camback + up[0] * camup;
595 chase_dest[1] = vieworg[1] - forward[1] * camback + up[1] * camup;
596 chase_dest[2] = vieworg[2] - forward[2] * camback + up[2] * camup;
597 // trace from first person view location to our chosen third person view location
599 VectorCopy(trace.endpos, bestvieworg);
600 offset[2] = 0;
601 for (offset[0] = -16;offset[0] <= 16;offset[0] += 8)
602 {
603 for (offset[1] = -16;offset[1] <= 16;offset[1] += 8)
604 {
605 AngleVectors(viewangles, NULL, NULL, up);
606 chase_dest[0] = vieworg[0] - forward[0] * camback + up[0] * camup + offset[0];
607 chase_dest[1] = vieworg[1] - forward[1] * camback + up[1] * camup + offset[1];
608 chase_dest[2] = vieworg[2] - forward[2] * camback + up[2] * camup + offset[2];
610 if (bestvieworg[2] > trace.endpos[2])
611 bestvieworg[2] = trace.endpos[2];
612 }
613 }
614 bestvieworg[2] -= 8;
615 VectorCopy(bestvieworg, vieworg);
616 viewangles[PITCH] = campitch;
617 }
618 else
619 {
621 {
622 // look straight down from high above
623 viewangles[PITCH] = 90;
624 camback = 2048;
625 VectorSet(forward, 0, 0, -1);
626 }
627
628 // trace a little further so it hits a surface more consistently (to avoid 'snapping' on the edge of the range)
629 dist = -camback - 8;
630 chase_dest[0] = vieworg[0] + forward[0] * dist;
631 chase_dest[1] = vieworg[1] + forward[1] * dist;
632 chase_dest[2] = vieworg[2] + forward[2] * dist + camup;
634 VectorMAMAM(1, trace.endpos, 8, forward, 4, trace.plane.normal, vieworg);
635 }
636 }
637 else
638 {
639 // first person view from entity
640 // angles
641 if (cldead && v_deathtilt.integer)
642 viewangles[ROLL] = v_deathtiltangle.value;
643
644 // origin
645 VectorAdd(vieworg, cl.punchvector, vieworg);
646 if (!cldead)
647 {
648 double xyspeed = 0, bob = 0, bobfall = 0;
649 double cycle = 0; // double-precision because cl.time can be a very large number, where float would get stuttery at high time values
651
653
655 {
656 // 1. if we teleported, clear the frametime... the lowpass will recover the previous value then
657 if(teleported)
658 {
659 // try to fix the first highpass; result is NOT
660 // perfect! TODO find a better fix
661 VectorCopy(viewangles, cl.gunangles_prev);
662 VectorCopy(vieworg, cl.gunorg_prev);
663 }
664
665 // 2. for the gun origin, only keep the high frequency (non-DC) parts, which is "somewhat like velocity"
668 VectorCopy(vieworg, cl.gunorg_prev);
670
671 // in the highpass, we _store_ the DIFFERENCE to the actual view angles...
673 cl.gunangles_highpass[PITCH] += 360 * floor((viewangles[PITCH] - cl.gunangles_highpass[PITCH]) / 360 + 0.5);
674 cl.gunangles_highpass[YAW] += 360 * floor((viewangles[YAW] - cl.gunangles_highpass[YAW]) / 360 + 0.5);
675 cl.gunangles_highpass[ROLL] += 360 * floor((viewangles[ROLL] - cl.gunangles_highpass[ROLL]) / 360 + 0.5);
677 VectorCopy(viewangles, cl.gunangles_prev);
679
680 // 3. calculate the RAW adjustment vectors
681 gunorg[0] *= -cl_followmodel_side_speed.value;
682 gunorg[1] *= -cl_followmodel_side_speed.value;
683 gunorg[2] *= -cl_followmodel_up_speed.value;
684
685 gunangles[PITCH] *= -cl_leanmodel_up_speed.value;
686 gunangles[YAW] *= -cl_leanmodel_side_speed.value;
687 gunangles[ROLL] = 0;
688
689 // 4. perform highpass/lowpass on the adjustment vectors (turning velocity into acceleration!)
690 // trick: we must do the lowpass LAST, so the lowpass vector IS the final vector!
693 // we assume here: PITCH = 0, YAW = 1, ROLL = 2
696
697 // 5. use the adjusted vectors
698 VectorAdd(vieworg, gunorg, gunorg);
699 VectorAdd(viewangles, gunangles, gunangles);
700 }
701 else
702 {
703 // Just initialize gunorg/gunangles.
704 VectorCopy(vieworg, gunorg);
705 VectorCopy(viewangles, gunangles);
706 }
707
708 // bounded XY speed, used by several effects below
709 xyspeed = bound (0, sqrt(clvelocity[0]*clvelocity[0] + clvelocity[1]*clvelocity[1]), cl_bob_velocity_limit.value);
710
711 // vertical view bobbing code
713 {
714 float bob_limit = cl_bobmodel_classic.integer ? 4 : cl_bob_limit.value;
715
717 {
718 // use traces to determine what range the view can bob in, and scale down the bob as needed
719 float trace1fraction;
720 float trace2fraction;
721 vec3_t bob_height_check_dest;
722
723 // these multipliers are expanded a bit (the actual bob sin range is from -0.4 to 1.0) to reduce nearclip issues, especially on water surfaces
724 bob_height_check_dest[0] = vieworg[0];
725 bob_height_check_dest[1] = vieworg[1];
726 bob_height_check_dest[2] = vieworg[2] + cl_bob_limit.value * 1.1f;
728 trace1fraction = trace.fraction;
729
730 bob_height_check_dest[0] = vieworg[0];
731 bob_height_check_dest[1] = vieworg[1];
732 bob_height_check_dest[2] = vieworg[2] + cl_bob_limit.value * -0.5f;
734 trace2fraction = trace.fraction;
735
736 bob_limit *= min(trace1fraction, trace2fraction);
737 }
738
739 // LadyHavoc: this code is *weird*, but not replacable (I think it
740 // should be done in QC on the server, but oh well, quake is quake)
741 // LadyHavoc: figured out bobup: the time at which the sin is at 180
742 // degrees (which allows lengthening or squishing the peak or valley)
743 cycle = cl.time / cl_bobcycle.value;
744 cycle -= (int) cycle;
745 if (cycle < cl_bobup.value)
746 cycle = M_PI * cycle / cl_bobup.value;
747 else
748 cycle = M_PI + M_PI * (cycle-cl_bobup.value)/(1.0 - cl_bobup.value);
749 // bob is proportional to velocity in the xy plane
750 // (don't count Z, or jumping messes it up)
751 bob = xyspeed * cl_bob.value;
752 bob = bob*0.3 + bob*0.7*sin(cycle);
753 bob = bound(-7, bob, bob_limit);
754
755 vieworg[2] += bob;
756
757 // we also need to adjust gunorg, or this appears like pushing the gun!
758 // In the old code, this was applied to vieworg BEFORE copying to gunorg,
759 // but this is not viable with the new followmodel code as that would mean
760 // that followmodel would work on the munged-by-bob vieworg and do feedback
762 gunorg[2] += bob;
763 }
764
765 // horizontal view bobbing code
767 {
768 vec3_t bob2vel;
770 float side, front;
771
772 cycle = cl.time / cl_bob2cycle.value;
773 cycle -= (int) cycle;
774 if (cycle < 0.5)
775 cycle = cos(M_PI * cycle / 0.5); // cos looks better here with the other view bobbing using sin
776 else
777 cycle = cos(M_PI + M_PI * (cycle-0.5)/0.5);
778 bob = cl_bob2.value * cycle;
779
780 // this value slowly decreases from 1 to 0 when we stop touching the ground.
781 // The cycle is later multiplied with it so the view smooths back to normal
782 if (clonground && !clcmdjump) // also block the effect while the jump button is pressed, to avoid twitches when bunny-hopping
783 cl.bob2_smooth = 1;
784 else
785 {
786 if(cl.bob2_smooth > 0)
788 else
789 cl.bob2_smooth = 0;
790 }
791
792 // calculate the front and side of the player between the X and Y axes
793 AngleVectors(viewangles, forward, right, up);
794 // now get the speed based on those angles. The bounds should match the same value as xyspeed's
798 VectorScale(right, bob, right);
799 // we use side with forward and front with right, so the bobbing goes
800 // to the side when we walk forward and to the front when we strafe
801 VectorMAMAM(side, forward, front, right, 0, up, bob2vel);
802 vieworg[0] += bob2vel[0];
803 vieworg[1] += bob2vel[1];
804 // we also need to adjust gunorg, or this appears like pushing the gun!
805 // In the old code, this was applied to vieworg BEFORE copying to gunorg,
806 // but this is not viable with the new followmodel code as that would mean
807 // that followmodel would work on the munged-by-bob vieworg and do feedback
808 gunorg[0] += bob2vel[0];
809 gunorg[1] += bob2vel[1];
810 }
811
812 // fall bobbing code
813 // causes the view to swing down and back up when touching the ground
815 {
816 if (!clonground)
817 {
818 cl.bobfall_speed = bound(-400, clvelocity[2], 0) * bound(0, cl_bobfall.value, 0.1);
819 if (clvelocity[2] < -cl_bobfallminspeed.value)
820 cl.bobfall_swing = 1;
821 else
822 cl.bobfall_swing = 0; // TODO really?
823 }
824 else
825 {
827
828 bobfall = sin(M_PI * cl.bobfall_swing) * cl.bobfall_speed;
829 vieworg[2] += bobfall;
830 gunorg[2] += bobfall;
831 }
832 }
833 VectorCopy(clviewangles, viewangles);
834
835 // Hanicef: don't apply punchangle twice if the scene is rendered more than once.
837 {
838 VectorAdd(viewangles, cl.punchangle, viewangles);
840 }
841 viewangles[ROLL] += Com_CalcRoll(clviewangles, clvelocity, cl_rollangle.value, cl_rollspeed.value);
842
843 if (v_dmg_time > 0)
844 {
847 }
848
849 // gun model bobbing code
850 if (cl_bobmodel.value)
851 {
853 AngleVectors (gunangles, forward, right, up);
854
856 {
857 // calculate for swinging gun model
858 // the gun bobs when running on the ground, but doesn't bob when you're in the air.
859 // Sajt: I tried to smooth out the transitions between bob and no bob, which works
860 // for the most part, but for some reason when you go through a message trigger or
861 // pick up an item or anything like that it will momentarily jolt the gun.
862 float bspeed;
863 float s;
864 float t;
865
867 if (clonground)
868 {
869 if (cl.time - cl.hitgroundtime < 0.2)
870 {
871 // just hit the ground, speed the bob back up over the next 0.2 seconds
872 t = cl.time - cl.hitgroundtime;
873 t = bound(0, t, 0.2);
874 t *= 5;
875 }
876 else
877 t = 1;
878 }
879 else
880 {
881 // recently left the ground, slow the bob down over the next 0.2 seconds
883 t = 0.2 - bound(0, t, 0.2);
884 t *= 5;
885 }
886
887 bspeed = xyspeed * 0.01f;
888 bob = bspeed * cl_bobmodel_side.value * cl_viewmodel_scale.value * sin (s) * t;
889 VectorMA (gunorg, bob, right, gunorg);
890 bob = bspeed * cl_bobmodel_up.value * cl_viewmodel_scale.value * cos (s * 2) * t;
891 VectorMA (gunorg, bob, up, gunorg);
892 }
893 else
894 {
895 // Classic Quake bobbing
896 for (int i = 0; i < 3; i++)
897 gunorg[i] += forward[i]*bob*0.4;
898 gunorg[2] += bob;
899
901 {
902 if (scr_viewsize.value == 110)
903 gunorg[2] += 1;
904 else if (scr_viewsize.value == 100)
905 gunorg[2] += 2;
906 else if (scr_viewsize.value == 90)
907 gunorg[2] += 1;
908 else if (scr_viewsize.value == 80)
909 gunorg[2] += 0.5;
910 }
911 }
912 }
913 }
914 }
915 // calculate a view matrix for rendering the scene
916 if (v_idlescale.value)
917 {
921 }
922 Matrix4x4_CreateFromQuakeEntity(&r_refdef.view.matrix, vieworg[0], vieworg[1], vieworg[2], viewangles[0], viewangles[1], viewangles[2], 1);
923 if (v_yshearing.value > 0)
925
926 // calculate a viewmodel matrix for use in view-attached entities
929
930 Matrix4x4_CreateFromQuakeEntity(&viewmodelmatrix_withbob, gunorg[0], gunorg[1], gunorg[2], gunangles[0], gunangles[1], gunangles[2], cl_viewmodel_scale.value);
931 if (v_yshearing.value > 0)
933
936
939 }
940
942}
943
944void V_CalcRefdef (void)
945{
946 entity_t *ent;
947 qbool cldead;
948
950 {
951 // ent is the view entity (visible when out of body)
952 ent = &cl.entities[cl.viewentity];
953
954 cldead = (cl.stats[STAT_HEALTH] <= 0 && cl.stats[STAT_HEALTH] != -666 && cl.stats[STAT_HEALTH] != -2342);
955 V_CalcRefdefUsing(&ent->render.matrix, cl.viewangles, !ent->persistent.trail_allowed, cl.onground, cl.cmd.jump, cl.stats[STAT_VIEWHEIGHT], cldead, cl.velocity); // FIXME use a better way to detect teleport/warp than trail_allowed
956 }
957 else
958 {
965 }
966}
967
969{
970 // when using isometric view to play normal games we have to rotate the camera to make the Ortho matrix do the right thing (forward as up the screen, etc)
971 matrix4x4_t relative;
972 matrix4x4_t modifiedview;
973 matrix4x4_t modify;
974 vec3_t forward, left, up, org;
975 float t[16];
976
983 r_refdef.view.ortho_x = r_refdef.view.frustum_x; // used by VM_CL_R_SetView
984 r_refdef.view.ortho_y = r_refdef.view.frustum_y; // used by VM_CL_R_SetView
985
986 t[0] = v_isometric_xx.value;
987 t[1] = v_isometric_xy.value;
988 t[2] = v_isometric_xz.value;
989 t[3] = 0.0f;
990 t[4] = v_isometric_yx.value;
991 t[5] = v_isometric_yy.value;
992 t[6] = v_isometric_yz.value;
993 t[7] = 0.0f;
994 t[8] = v_isometric_zx.value;
995 t[9] = v_isometric_zy.value;
996 t[10] = v_isometric_zz.value;
997 t[11] = 0.0f;
998 t[12] = 0.0f;
999 t[13] = 0.0f;
1000 t[14] = 0.0f;
1001 t[15] = 1.0f;
1002 Matrix4x4_FromArrayFloatGL(&modify, t);
1003
1004 // if the orientation is locked, extract the origin and create just a translate matrix to start with
1006 {
1007 vec3_t vx, vy, vz, origin;
1010 }
1011
1012 Matrix4x4_Concat(&modifiedview, &r_refdef.view.matrix, &modify);
1014 Matrix4x4_Concat(&r_refdef.view.matrix, &modifiedview, &relative);
1018
1020 {
1024 }
1025}
1026
1027
1029{
1030 // don't flash if time steps backwards
1031 if (cl.time <= cl.oldtime)
1032 return;
1033 // drop the damage value
1035 if (cl.cshifts[CSHIFT_DAMAGE].percent <= 0)
1037 // drop the bonus value
1039 if (cl.cshifts[CSHIFT_BONUS].percent <= 0)
1041}
1042
1044{
1045 float a2;
1046 int j;
1047 r_refdef.viewblend[0] = 0;
1048 r_refdef.viewblend[1] = 0;
1049 r_refdef.viewblend[2] = 0;
1050 r_refdef.viewblend[3] = 0;
1053 if (cls.state == ca_connected && cls.signon == SIGNONS)
1054 {
1055 // set contents color
1056 int supercontents;
1057 vec3_t vieworigin;
1059 supercontents = CL_PointSuperContents(vieworigin);
1060 if (supercontents & SUPERCONTENTS_LIQUIDSMASK)
1061 {
1062 cl.view_underwater = true;
1063 r_refdef.frustumscale_x *= 1 - (((sin(cl.time * 4.7) + 1) * 0.015) * r_waterwarp.value);
1064 r_refdef.frustumscale_y *= 1 - (((sin(cl.time * 3.0) + 1) * 0.015) * r_waterwarp.value);
1065 if (supercontents & SUPERCONTENTS_LAVA)
1066 {
1070 }
1071 else if (supercontents & SUPERCONTENTS_SLIME)
1072 {
1076 }
1077 else
1078 {
1082 }
1083 cl.cshifts[CSHIFT_CONTENTS].percent = 150 * 0.5;
1084 }
1085 else
1086 {
1087 cl.view_underwater = false;
1092 }
1093
1095 {
1096 if (cl.stats[STAT_ITEMS] & IT_QUAD)
1097 {
1102 }
1103 else if (cl.stats[STAT_ITEMS] & IT_SUIT)
1104 {
1109 }
1110 else if (cl.stats[STAT_ITEMS] & IT_INVISIBILITY)
1111 {
1116 }
1118 {
1123 }
1124 else
1126 }
1127
1132
1133 // LadyHavoc: fixed V_CalcBlend
1134 for (j = 0;j < NUM_CSHIFTS;j++)
1135 {
1136 a2 = bound(0.0f, cl.cshifts[j].percent * (1.0f / 255.0f), 1.0f);
1137 if (a2 > 0)
1138 {
1140 r_refdef.viewblend[3] = (1 - (1 - r_refdef.viewblend[3]) * (1 - a2)); // correct alpha multiply... took a while to find it on the web
1141 }
1142 }
1143 // saturate color (to avoid blending in black)
1144 if (r_refdef.viewblend[3])
1145 {
1146 a2 = 1 / r_refdef.viewblend[3];
1148 }
1149 r_refdef.viewblend[0] = bound(0.0f, r_refdef.viewblend[0], 255.0f);
1150 r_refdef.viewblend[1] = bound(0.0f, r_refdef.viewblend[1], 255.0f);
1151 r_refdef.viewblend[2] = bound(0.0f, r_refdef.viewblend[2], 255.0f);
1153 if (vid.sRGB3D)
1154 {
1158 }
1159 else
1160 {
1161 r_refdef.viewblend[0] *= (1.0f/256.0f);
1162 r_refdef.viewblend[1] *= (1.0f/256.0f);
1163 r_refdef.viewblend[2] *= (1.0f/256.0f);
1164 }
1165
1166 // Samual: Ugly hack, I know. But it's the best we can do since
1167 // there is no way to detect client states from the engine.
1168 if (cl.stats[STAT_HEALTH] <= 0 && cl.stats[STAT_HEALTH] != -666 &&
1169 cl.stats[STAT_HEALTH] != -2342 && cl_deathfade.value > 0)
1170 {
1171 cl.deathfade += cl_deathfade.value * max(0.00001, cl.time - cl.oldtime);
1172 cl.deathfade = bound(0.0f, cl.deathfade, 0.9f);
1173 }
1174 else
1175 cl.deathfade = 0.0f;
1176
1177 if(cl.deathfade > 0)
1178 {
1179 float a;
1180 float deathfadevec[3] = {0.3f, 0.0f, 0.0f};
1182 if(a > 0)
1184 r_refdef.viewblend[3] = a;
1185 }
1186 }
1187}
1188
1189//============================================================================
1190
1191/*
1192=============
1193V_Init
1194=============
1195*/
1196void V_Init (void)
1197{
1198 Cmd_AddCommand(CF_CLIENT | CF_CLIENT_FROM_SERVER, "v_cshift", V_cshift_f, "sets tint color of view");
1199 Cmd_AddCommand(CF_CLIENT | CF_CLIENT_FROM_SERVER, "bf", V_BonusFlash_f, "briefly flashes a bright color tint on view (used when items are picked up); optionally takes R G B [A [alphafade]] arguments to specify how the flash looks");
1200 Cmd_AddCommand(CF_CLIENT, "centerview", V_StartPitchDrift_f, "gradually recenter view (stop looking up/down)");
1201
1204
1211
1235
1238
1260
1272
1284
1286
1290
1292
1294
1301
1304
1307}
1308
#define SUPERCONTENTS_SKY
Definition bspfile.h:200
#define SUPERCONTENTS_LAVA
Definition bspfile.h:199
#define SUPERCONTENTS_SLIME
Definition bspfile.h:198
#define SUPERCONTENTS_SOLID
Definition bspfile.h:196
#define SUPERCONTENTS_LIQUIDSMASK
Definition bspfile.h:218
trace_t CL_TraceLine(const vec3_t start, const vec3_t end, int type, prvm_edict_t *passedict, int hitsupercontentsmask, int skipsupercontentsmask, int skipmaterialflagsmask, float extend, qbool hitnetworkbrushmodels, qbool hitnetworkplayers, int *hitnetworkentity, qbool hitcsqcentities, qbool hitsurfaces)
#define CL_PointSuperContents(point)
cvar_t cl_forwardspeed
Definition cl_input.c:365
client_state_t cl
Definition cl_main.c:117
client_static_t cls
Definition cl_main.c:116
cvar_t cl_deathfade
Definition cl_main.c:83
cvar_t scr_viewsize
Definition cl_screen.c:19
cvar_t vid_pixelheight
Definition cl_screen.c:58
@ ca_connected
Definition client.h:532
#define SIGNONS
Definition client.h:525
#define CSHIFT_VCSHIFT
Definition client.h:515
#define CSHIFT_CONTENTS
Definition client.h:511
#define CSHIFT_BONUS
Definition client.h:513
#define CSHIFT_POWERUP
Definition client.h:514
#define NUM_CSHIFTS
Definition client.h:516
#define CSHIFT_DAMAGE
Definition client.h:512
void Cmd_AddCommand(unsigned flags, const char *cmd_name, xcommand_t function, const char *description)
called by the init functions of other parts of the program to register commands and functions to call...
Definition cmd.c:1661
static int Cmd_Argc(cmd_state_t *cmd)
Definition cmd.h:249
static const char * Cmd_Argv(cmd_state_t *cmd, int arg)
Cmd_Argv(cmd, ) will return an empty string (not a NULL) if arg > argc, so string operations are alwa...
Definition cmd.h:254
#define CF_CLIENT
cvar/command that only the client can change/execute
Definition cmd.h:48
#define CF_CLIENT_FROM_SERVER
command that the server is allowed to execute on the client
Definition cmd.h:50
#define CF_ARCHIVE
cvar should have its set value saved to config.cfg and persist across sessions
Definition cmd.h:53
cvar_t collision_extendmovelength
Definition collision.c:14
gamemode_t gamemode
Definition com_game.c:26
@ GAME_TRANSFUSION
Definition com_game.h:35
@ GAME_GOODVSBAD2
Definition com_game.h:36
void MSG_ReadVector(sizebuf_t *sb, vec3_t v, protocolversion_t protocol)
Definition com_msg.c:401
float Com_CalcRoll(const vec3_t angles, const vec3_t velocity, const vec_t angleval, const vec_t velocityval)
Definition common.c:890
@ PROTOCOL_QUAKEWORLD
quakeworld protocol
Definition common.h:145
#define MSG_ReadByte(sb)
Definition common.h:188
void Con_Printf(const char *fmt,...)
Prints to all appropriate console targets.
Definition console.c:1514
void CL_VM_UpdateDmgGlobals(int dmg_take, int dmg_save, vec3_t dmg_origin)
Definition csprogs.c:222
float frametime
vector origin
void Cvar_RegisterVariable(cvar_t *variable)
registers a cvar that already has the name, string, and optionally the archive elements set.
Definition cvar.c:599
static int(ZEXPORT *qz_inflate)(z_stream *strm
cvar_t gl_polyblend
Definition gl_backend.c:17
cvar_t r_waterwarp
Definition gl_backend.c:13
r_refdef_t r_refdef
Definition gl_rmain.c:57
GLsizei const GLfloat * value
Definition glquake.h:740
GLenum GLenum GLsizei count
Definition glquake.h:656
GLuint GLuint GLintptr offset
Definition glquake.h:632
#define Image_LinearFloatFromsRGB(c)
Definition image.h:69
void AngleVectors(const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up)
Definition mathlib.c:444
#define VectorLerp(v1, lerp, v2, out)
Definition mathlib.h:120
#define max(A, B)
Definition mathlib.h:38
#define min(A, B)
Definition mathlib.h:37
#define VectorNormalize(v)
Definition mathlib.h:104
#define VectorClear(a)
Definition mathlib.h:97
#define bound(min, num, max)
Definition mathlib.h:34
#define VectorMAMAM(scale1, b1, scale2, b2, scale3, b3, out)
Definition mathlib.h:117
#define VectorSet(vec, x, y, z)
Definition mathlib.h:96
#define VectorSubtract(a, b, out)
Definition mathlib.h:99
#define DotProduct(a, b)
Definition mathlib.h:98
#define VectorCopy(in, out)
Definition mathlib.h:101
#define VectorScale(in, scale, out)
Definition mathlib.h:111
#define VectorMAM(scale1, b1, scale2, b2, out)
Definition mathlib.h:116
#define VectorAdd(a, b, out)
Definition mathlib.h:100
#define M_PI
Definition mathlib.h:28
#define VectorMA(a, scale, b, out)
Definition mathlib.h:114
#define VectorMAMAMAM(scale1, b1, scale2, b2, scale3, b3, scale4, b4, out)
Definition mathlib.h:118
void Matrix4x4_AdjustOrigin(matrix4x4_t *out, double x, double y, double z)
Definition matrixlib.c:1824
void Matrix4x4_Concat(matrix4x4_t *out, const matrix4x4_t *in1, const matrix4x4_t *in2)
Definition matrixlib.c:83
void Matrix4x4_Transform(const matrix4x4_t *in, const float v[3], float out[3])
Definition matrixlib.c:1657
void Matrix4x4_QuakeToDuke3D(const matrix4x4_t *in, matrix4x4_t *out, double maxShearAngle)
Definition matrixlib.c:891
void Matrix4x4_CreateTranslate(matrix4x4_t *out, double x, double y, double z)
Definition matrixlib.c:584
void Matrix4x4_FromArrayFloatGL(matrix4x4_t *out, const float in[16])
Definition matrixlib.c:1204
void Matrix4x4_CreateFromQuakeEntity(matrix4x4_t *out, double x, double y, double z, double pitch, double yaw, double roll, double scale)
Definition matrixlib.c:715
void Matrix4x4_ConcatScale(matrix4x4_t *out, double x)
Definition matrixlib.c:1775
void Matrix4x4_CreateScale(matrix4x4_t *out, double x)
Definition matrixlib.c:675
void Matrix4x4_Invert_Simple(matrix4x4_t *out, const matrix4x4_t *in1)
Definition matrixlib.c:422
void Matrix4x4_FromVectors(matrix4x4_t *out, const float vx[3], const float vy[3], const float vz[3], const float t[3])
Definition matrixlib.c:970
void Matrix4x4_ToVectors(const matrix4x4_t *in, float vx[3], float vy[3], float vz[3], float t[3])
Definition matrixlib.c:939
const matrix4x4_t identitymatrix
Definition matrixlib.c:9
void Matrix4x4_Copy(matrix4x4_t *out, const matrix4x4_t *in)
Definition matrixlib.c:19
void Matrix4x4_OriginFromMatrix(const matrix4x4_t *in, float *out)
Definition matrixlib.c:1792
float cos(float f)
float sqrt(float f)
void cmd(string command,...)
float sin(float f)
float fabs(float f)
float floor(float f)
cvar_t r_trippy
Definition model_brush.c:29
#define MATERIALFLAGMASK_TRANSLUCENT
sizebuf_t cl_message
Definition netconn.c:71
int i
#define STAT_HEALTH
Definition qstats.h:8
#define STAT_ITEMS
FTE, DP.
Definition qstats.h:23
#define STAT_VIEWHEIGHT
FTE, DP.
Definition qstats.h:24
#define NULL
Definition qtypes.h:12
float vec_t
Definition qtypes.h:68
vec_t vec3_t[3]
Definition qtypes.h:71
bool qbool
Definition qtypes.h:9
#define YAW
Definition qtypes.h:19
#define PITCH
Definition qtypes.h:16
#define ROLL
Definition qtypes.h:22
#define IT_SUIT
Definition quakedef.h:59
qbool noclip_anglehack
Definition sv_ccmds.c:190
#define IT_INVISIBILITY
Definition quakedef.h:57
#define IT_INVULNERABILITY
Definition quakedef.h:58
#define IT_QUAD
Definition quakedef.h:60
precision highp float
Definition shader_glsl.h:53
ret a
vec3_t csqc_viewanglesfromengine
Definition client.h:1114
float movevars_timescale
Definition client.h:1058
float deathfade
Definition client.h:879
double oldtime
Definition client.h:868
float idealpitch
Definition client.h:826
vec3_t qw_intermission_origin
Definition client.h:1095
unsigned short csqc_server2csqcentitynumber[MAX_EDICTS]
Definition client.h:1110
vec3_t velocity
Definition client.h:792
float faceanimtime
Definition client.h:769
qbool onground
Definition client.h:843
float pitchvel
Definition client.h:827
qbool nodrift
Definition client.h:828
double stairsmoothtime
Definition client.h:772
vec3_t gunangles_prev
Definition client.h:815
double hitgroundtime
Definition client.h:849
vec3_t csqc_vieworiginfromengine
Definition client.h:1113
double calcrefdef_prevtime
Definition client.h:853
cshift_t cshifts[NUM_CSHIFTS]
Definition client.h:775
vec3_t viewangles
Definition client.h:786
vec3_t gunorg_prev
Definition client.h:820
double lastongroundtime
Definition client.h:848
entity_t * entities
Definition client.h:991
int intermission
Definition client.h:856
matrix4x4_t csqc_viewmodelmatrixfromengine
Definition client.h:1115
double realframetime
Definition client.h:871
double time
Definition client.h:868
qbool view_underwater
Definition client.h:1139
vec_t viewzoom
Definition client.h:794
vec3_t punchvector
Definition client.h:790
vec3_t punchangle
Definition client.h:788
vec3_t gunangles_highpass
Definition client.h:816
usercmd_t movecmd[CL_MAX_USERCMDS]
Definition client.h:754
qbool oldonground
Definition client.h:847
vec3_t gunangles_adjustment_lowpass
Definition client.h:817
float movevars_stepheight
Definition client.h:1070
float bob2_smooth
Definition client.h:850
vec3_t qw_intermission_angles
Definition client.h:1096
int stats[MAX_CL_STATS]
Definition client.h:758
vec3_t gunorg_highpass
Definition client.h:821
usercmd_t cmd
Definition client.h:752
float driftmove
Definition client.h:829
double laststop
Definition client.h:830
vec3_t gunorg_adjustment_lowpass
Definition client.h:822
vec3_t gunangles_adjustment_highpass
Definition client.h:818
float bobfall_swing
Definition client.h:852
float stairsmoothz
Definition client.h:771
float bobfall_speed
Definition client.h:851
float qw_weaponkick
Definition client.h:1102
vec3_t gunorg_adjustment_highpass
Definition client.h:823
qbool demoplayback
Definition client.h:587
cactive_t state
Definition client.h:568
protocolversion_t protocol
Definition client.h:617
command interpreter state - the tokenizing and execution of commands, as well as pointers to which cv...
Definition cmd.h:127
float percent
Definition client.h:507
float destcolor[3]
Definition client.h:506
float alphafade
Definition client.h:508
Definition cvar.h:66
float value
Definition cvar.h:74
int integer
Definition cvar.h:73
matrix4x4_t inversematrix
Definition client.h:334
matrix4x4_t matrix
Definition client.h:332
unsigned char active
Definition protocol.h:459
entity_persistent_t persistent
Definition client.h:474
entity_state_t state_current
Definition client.h:471
entity_render_t render
Definition client.h:477
float viewblend[4]
Definition render.h:416
float frustumscale_y
Definition render.h:403
r_refdef_view_t view
Definition render.h:406
float frustumscale_x
Definition render.h:403
float frustum_y
Definition render.h:277
int cullface_back
Definition render.h:318
float frustum_x
Definition render.h:277
int useperspective
if turned off it renders an ortho view
Definition render.h:280
float ortho_x
Definition render.h:287
matrix4x4_t matrix
Definition render.h:266
int cullface_front
Definition render.h:317
float ortho_y
Definition render.h:287
int usevieworiginculling
allows visibility culling based on the view origin (e.g.
Definition render.h:286
double fraction
Definition collision.h:40
double endpos[3]
Definition collision.h:42
plane_t plane
Definition collision.h:44
qbool jump
Definition protocol.h:404
double time
Definition protocol.h:392
float forwardmove
Definition protocol.h:380
qbool sRGB3D
whether 3D rendering is sRGB corrected (based on sRGBcapable3D)
Definition vid.h:76
static vec3_t forward
Definition sv_user.c:305
static vec3_t right
Definition sv_user.c:305
static vec3_t up
Definition sv_user.c:305
vec3_t normal
Definition collision.h:13
viddef_t vid
global video state
Definition vid_shared.c:64
void V_StartPitchDrift_f(cmd_state_t *cmd)
Definition view.c:164
cvar_t cl_bob_velocity_limit
Definition view.c:56
cvar_t cl_followmodel_up_speed
Definition view.c:76
cvar_t cl_leanmodel_up_highpass
Definition view.c:67
cvar_t cl_leanmodel_up_speed
Definition view.c:64
cvar_t cl_bobmodel_speed
Definition view.c:52
cvar_t cl_bob_limit_heightcheck_dontcrosswatersurface
Definition view.c:55
cvar_t cl_followmodel
Definition view.c:70
static vec_t lowpass_limited(vec_t value, vec_t frac, vec_t limit, vec_t *store)
Definition view.c:404
cvar_t v_isometric_xx
Definition view.c:99
float v_dmg_time
Definition view.c:147
static void highpass3_limited(vec3_t value, vec_t fracx, vec_t limitx, vec_t fracy, vec_t limity, vec_t fracz, vec_t limitz, vec3_t store, vec3_t out)
Definition view.c:434
cvar_t cl_bob2cycle
Definition view.c:42
cvar_t cl_bobmodel_forward
Definition view.c:50
int cl_punchangle_applied
Definition view.c:149
void V_DriftPitch(void)
Definition view.c:189
cvar_t crosshair
Definition view.c:121
cvar_t cl_leanmodel
Definition view.c:58
cvar_t cl_bobcycle
Definition view.c:39
cvar_t v_isometric_rot_pitch
Definition view.c:111
static void highpass3(vec3_t value, vec_t fracx, vec_t fracy, vec_t fracz, vec3_t store, vec3_t out)
Definition view.c:427
cvar_t cl_bob_limit_heightcheck
Definition view.c:54
cvar_t v_iyaw_cycle
Definition view.c:88
cvar_t chase_stevie
Definition view.c:135
cvar_t v_idlescale
Definition view.c:95
cvar_t cl_viewmodel_scale
Definition view.c:82
cvar_t cl_bobfallminspeed
Definition view.c:46
cvar_t v_isometric_verticalfov
Definition view.c:98
cvar_t cl_leanmodel_up_highpass1
Definition view.c:66
cvar_t cl_leanmodel_up_lowpass
Definition view.c:68
void V_CalcRefdefUsing(const matrix4x4_t *entrendermatrix, const vec3_t clviewangles, qbool teleported, qbool clonground, qbool clcmdjump, float clstatsviewheight, qbool cldead, const vec3_t clvelocity)
Definition view.c:512
cvar_t v_isometric_flipcullface
Definition view.c:117
cvar_t cl_bobfall
Definition view.c:44
cvar_t cl_followmodel_up_highpass1
Definition view.c:78
cvar_t cl_bobup
Definition view.c:40
cvar_t v_isometric_zz
Definition view.c:107
cvar_t cl_bob2smooth
Definition view.c:43
cvar_t cl_leanmodel_side_limit
Definition view.c:60
void V_StartPitchDrift(void)
Definition view.c:151
cvar_t cl_leanmodel_up_limit
Definition view.c:65
cvar_t v_kickroll
Definition view.c:85
cvar_t v_isometric_zx
Definition view.c:105
cvar_t v_ipitch_cycle
Definition view.c:90
cvar_t v_deathtiltangle
Definition view.c:138
cvar_t cl_rollangle
Definition view.c:36
cvar_t v_isometric_usevieworiginculling
Definition view.c:119
cvar_t cl_followmodel_up_lowpass
Definition view.c:80
void V_FadeViewFlashs(void)
Definition view.c:1028
cvar_t v_isometric_relx
Definition view.c:114
cvar_t v_ipitch_level
Definition view.c:93
static void V_CalcIntermissionRefdef(vec3_t vieworg, vec3_t viewangles, const matrix4x4_t *entrendermatrix, float clstatsviewheight)
Definition view.c:487
static void V_BonusFlash_f(cmd_state_t *cmd)
Definition view.c:345
cvar_t v_isometric_yy
Definition view.c:103
void V_MakeViewIsometric(void)
Definition view.c:968
cvar_t v_deathtilt
Definition view.c:137
cvar_t v_isometric_relz
Definition view.c:116
static void V_cshift_f(cmd_state_t *cmd)
Definition view.c:329
cvar_t v_iyaw_level
Definition view.c:91
static void lowpass3(vec3_t value, vec_t fracx, vec_t fracy, vec_t fracz, vec3_t store, vec3_t out)
Definition view.c:420
cvar_t v_isometric
Definition view.c:97
cvar_t cl_bobfallcycle
Definition view.c:45
cvar_t v_iroll_level
Definition view.c:92
cvar_t v_iroll_cycle
Definition view.c:89
cvar_t cl_leanmodel_side_highpass1
Definition view.c:61
cvar_t chase_back
Definition view.c:130
cvar_t chase_active
Definition view.c:132
void V_StopPitchDrift(void)
Definition view.c:169
cvar_t cl_leanmodel_side_speed
Definition view.c:59
cvar_t v_isometric_rely
Definition view.c:115
cvar_t cl_followmodel_side_speed
Definition view.c:71
cvar_t v_isometric_zy
Definition view.c:106
cvar_t cl_bob2
Definition view.c:41
cvar_t v_isometric_rot_roll
Definition view.c:113
cvar_t cl_followmodel_side_lowpass
Definition view.c:75
cvar_t chase_pitchangle
Definition view.c:141
void V_ParseDamage(void)
Definition view.c:261
cvar_t v_kickpitch
Definition view.c:86
cvar_t v_centerspeed
Definition view.c:124
cvar_t cl_bobmodel_up
Definition view.c:49
cvar_t v_isometric_tz
Definition view.c:110
matrix4x4_t viewmodelmatrix_withbob
Definition cl_main.c:1056
matrix4x4_t viewmodelmatrix_nobob
Definition cl_main.c:1057
void V_Init(void)
Definition view.c:1196
cvar_t cl_bob_limit
Definition view.c:53
cvar_t cl_bob
Definition view.c:38
cvar_t cl_stairsmoothspeed
Definition view.c:126
cvar_t v_isometric_ty
Definition view.c:109
cvar_t cl_bobmodel
Definition view.c:47
cvar_t chase_overhead
Definition view.c:133
static vec_t highpass_limited(vec_t value, vec_t frac, vec_t limit, vec_t *store)
Definition view.c:415
cvar_t cl_bobmodel_classic
Definition view.c:51
cvar_t v_isometric_tx
Definition view.c:108
cvar_t cl_rollspeed
Definition view.c:35
cvar_t cl_followmodel_side_limit
Definition view.c:72
cvar_t cl_leanmodel_side_lowpass
Definition view.c:63
cvar_t cl_smoothviewheight
Definition view.c:128
float v_dmg_pitch
Definition view.c:147
cvar_t v_isometric_yx
Definition view.c:102
cvar_t cl_leanmodel_side_highpass
Definition view.c:62
static vec_t highpass(vec_t value, vec_t frac, vec_t *store)
Definition view.c:410
cvar_t v_isometric_rot_yaw
Definition view.c:112
cvar_t r_viewmodel_quake
Definition view.c:145
static vec_t lowpass(vec_t value, vec_t frac, vec_t *store)
Definition view.c:398
static cshift_t v_cshift
Definition view.c:322
void V_CalcRefdef(void)
Definition view.c:944
cvar_t v_yshearing
Definition view.c:143
cvar_t v_kicktime
Definition view.c:84
cvar_t v_isometric_xy
Definition view.c:100
float v_dmg_roll
Definition view.c:147
cvar_t v_isometric_locked_orientation
Definition view.c:118
cvar_t v_isometric_xz
Definition view.c:101
cvar_t cl_followmodel_side_highpass1
Definition view.c:73
cvar_t cl_followmodel_up_highpass
Definition view.c:79
cvar_t cl_bobmodel_side
Definition view.c:48
cvar_t v_isometric_yz
Definition view.c:104
cvar_t cl_followmodel_up_limit
Definition view.c:77
void V_CalcViewBlend(void)
Definition view.c:1043
cvar_t chase_up
Definition view.c:131
cvar_t v_centermove
Definition view.c:123
cvar_t cl_followmodel_side_highpass
Definition view.c:74
#define MOVE_NOMONSTERS
Definition world.h:29