2001-02-19 21:15:25 +00:00
|
|
|
/*
|
2012-05-20 10:17:41 +00:00
|
|
|
cl_view.c
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
player eye positioning
|
|
|
|
|
|
|
|
Copyright (C) 1996-1997 Id Software, Inc.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2001-03-27 20:33:07 +00:00
|
|
|
#include "QF/cmd.h"
|
|
|
|
#include "QF/cvar.h"
|
|
|
|
#include "QF/msg.h"
|
2001-04-15 08:04:15 +00:00
|
|
|
#include "QF/screen.h"
|
2001-05-13 22:57:27 +00:00
|
|
|
|
2022-02-28 03:12:51 +00:00
|
|
|
#include "QF/plugin/vid_render.h"
|
2022-03-29 05:40:48 +00:00
|
|
|
#include "QF/scene/entity.h"
|
[scene] Make entity_t just an entity id for ECS
This puts the hierarchy (transform) reference, animation, visibility,
renderer, active, and old_origin data in separate components. There are
a few bugs (crashes on grenade explosions in gl/glsl/vulkan, immediately
in sw, reasons known, missing brush models in vulkan).
While quake doesn't really need an ECS, the direction I want to take QF
does, and it does seem to have improved memory bandwidth a little
(uncertain). However, there's a lot more work to go (especially fixing
the above bugs), but this seems to be a good start.
2022-10-23 01:32:09 +00:00
|
|
|
#include "QF/scene/scene.h"
|
2021-03-11 07:19:49 +00:00
|
|
|
#include "QF/simd/vec4f.h"
|
|
|
|
|
2001-08-07 18:53:22 +00:00
|
|
|
#include "compat.h"
|
2021-03-12 02:48:53 +00:00
|
|
|
|
2022-02-22 06:23:09 +00:00
|
|
|
#include "client/chase.h"
|
2022-02-28 03:12:51 +00:00
|
|
|
#include "client/entities.h"
|
|
|
|
#include "client/hud.h"
|
|
|
|
#include "client/input.h"
|
|
|
|
#include "client/view.h"
|
2022-03-04 16:48:10 +00:00
|
|
|
#include "client/world.h"
|
2020-06-21 14:15:17 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
/*
|
2001-05-30 20:55:28 +00:00
|
|
|
The view is allowed to move slightly from it's true position for bobbing,
|
|
|
|
but if it exceeds 8 pixels linear distance (spherical, not box), the list
|
|
|
|
of entities sent from the server may not include everything in the pvs,
|
|
|
|
especially when crossing a water boudnary.
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
float scr_ofsx;
|
|
|
|
static cvar_t scr_ofsx_cvar = {
|
|
|
|
.name = "scr_ofsx",
|
|
|
|
.description =
|
|
|
|
"None",
|
|
|
|
.default_value = "0",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_float, .value = &scr_ofsx },
|
|
|
|
};
|
|
|
|
float scr_ofsy;
|
|
|
|
static cvar_t scr_ofsy_cvar = {
|
|
|
|
.name = "scr_ofsy",
|
|
|
|
.description =
|
|
|
|
"None",
|
|
|
|
.default_value = "0",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_float, .value = &scr_ofsy },
|
|
|
|
};
|
|
|
|
float scr_ofsz;
|
|
|
|
static cvar_t scr_ofsz_cvar = {
|
|
|
|
.name = "scr_ofsz",
|
|
|
|
.description =
|
|
|
|
"None",
|
|
|
|
.default_value = "0",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_float, .value = &scr_ofsz },
|
|
|
|
};
|
2012-05-31 23:19:22 +00:00
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
float cl_rollspeed;
|
|
|
|
static cvar_t cl_rollspeed_cvar = {
|
|
|
|
.name = "cl_rollspeed",
|
|
|
|
.description =
|
|
|
|
"How quickly you straighten out after strafing",
|
|
|
|
.default_value = "200",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_float, .value = &cl_rollspeed },
|
|
|
|
};
|
|
|
|
float cl_rollangle;
|
|
|
|
static cvar_t cl_rollangle_cvar = {
|
|
|
|
.name = "cl_rollangle",
|
|
|
|
.description =
|
|
|
|
"How much your screen tilts when strafing",
|
|
|
|
.default_value = "2.0",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_float, .value = &cl_rollangle },
|
|
|
|
};
|
2001-02-19 21:15:25 +00:00
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
float cl_bob;
|
|
|
|
static cvar_t cl_bob_cvar = {
|
|
|
|
.name = "cl_bob",
|
|
|
|
.description =
|
|
|
|
"How much your weapon moves up and down when walking",
|
|
|
|
.default_value = "0.02",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_float, .value = &cl_bob },
|
|
|
|
};
|
|
|
|
float cl_bobcycle;
|
|
|
|
static cvar_t cl_bobcycle_cvar = {
|
|
|
|
.name = "cl_bobcycle",
|
|
|
|
.description =
|
|
|
|
"How quickly your weapon moves up and down when walking",
|
|
|
|
.default_value = "0.6",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_float, .value = &cl_bobcycle },
|
|
|
|
};
|
|
|
|
float cl_bobup;
|
|
|
|
static cvar_t cl_bobup_cvar = {
|
|
|
|
.name = "cl_bobup",
|
|
|
|
.description =
|
|
|
|
"How long your weapon stays up before cycling when walking",
|
|
|
|
.default_value = "0.5",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_float, .value = &cl_bobup },
|
|
|
|
};
|
2001-02-19 21:15:25 +00:00
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
float v_centermove;
|
|
|
|
static cvar_t v_centermove_cvar = {
|
|
|
|
.name = "v_centermove",
|
|
|
|
.description =
|
|
|
|
"How far the player must move forward before the view re-centers",
|
|
|
|
.default_value = "0.15",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_float, .value = &v_centermove },
|
|
|
|
};
|
|
|
|
float v_centerspeed;
|
|
|
|
static cvar_t v_centerspeed_cvar = {
|
|
|
|
.name = "v_centerspeed",
|
|
|
|
.description =
|
|
|
|
"How quickly you return to a center view after a lookup or lookdown",
|
|
|
|
.default_value = "500",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_float, .value = &v_centerspeed },
|
|
|
|
};
|
2001-08-07 18:53:22 +00:00
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
float v_kicktime;
|
|
|
|
static cvar_t v_kicktime_cvar = {
|
|
|
|
.name = "v_kicktime",
|
|
|
|
.description =
|
|
|
|
"How long the kick from an attack lasts",
|
|
|
|
.default_value = "0.5",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_float, .value = &v_kicktime },
|
|
|
|
};
|
|
|
|
float v_kickroll;
|
|
|
|
static cvar_t v_kickroll_cvar = {
|
|
|
|
.name = "v_kickroll",
|
|
|
|
.description =
|
|
|
|
"How much you lean when hit",
|
|
|
|
.default_value = "0.6",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_float, .value = &v_kickroll },
|
|
|
|
};
|
|
|
|
float v_kickpitch;
|
|
|
|
static cvar_t v_kickpitch_cvar = {
|
|
|
|
.name = "v_kickpitch",
|
|
|
|
.description =
|
|
|
|
"How much you look up when hit",
|
|
|
|
.default_value = "0.6",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_float, .value = &v_kickpitch },
|
|
|
|
};
|
2001-02-19 21:15:25 +00:00
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
int cl_cshift_bonus;
|
|
|
|
static cvar_t cl_cshift_bonus_cvar = {
|
|
|
|
.name = "cl_cshift_bonus",
|
|
|
|
.description =
|
|
|
|
"Show bonus flash on item pickup",
|
|
|
|
.default_value = "1",
|
|
|
|
.flags = CVAR_ARCHIVE,
|
|
|
|
.value = { .type = &cexpr_int, .value = &cl_cshift_bonus },
|
|
|
|
};
|
|
|
|
int cl_cshift_contents;
|
|
|
|
static cvar_t cl_cshift_contents_cvar = {
|
|
|
|
.name = "cl_cshift_content",
|
|
|
|
.description =
|
|
|
|
"Shift view colors for contents (water, slime, etc)",
|
|
|
|
.default_value = "1",
|
|
|
|
.flags = CVAR_ARCHIVE,
|
|
|
|
.value = { .type = &cexpr_int, .value = &cl_cshift_contents },
|
|
|
|
};
|
|
|
|
int cl_cshift_damage;
|
|
|
|
static cvar_t cl_cshift_damage_cvar = {
|
|
|
|
.name = "cl_cshift_damage",
|
|
|
|
.description =
|
|
|
|
"Shift view colors on damage",
|
|
|
|
.default_value = "1",
|
|
|
|
.flags = CVAR_ARCHIVE,
|
|
|
|
.value = { .type = &cexpr_int, .value = &cl_cshift_damage },
|
|
|
|
};
|
|
|
|
int cl_cshift_powerup;
|
|
|
|
static cvar_t cl_cshift_powerup_cvar = {
|
|
|
|
.name = "cl_cshift_powerup",
|
|
|
|
.description =
|
|
|
|
"Shift view colors for powerups",
|
|
|
|
.default_value = "1",
|
|
|
|
.flags = CVAR_ARCHIVE,
|
|
|
|
.value = { .type = &cexpr_int, .value = &cl_cshift_powerup },
|
|
|
|
};
|
2022-02-28 03:12:51 +00:00
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
float v_iyaw_cycle;
|
|
|
|
static cvar_t v_iyaw_cycle_cvar = {
|
|
|
|
.name = "v_iyaw_cycle",
|
|
|
|
.description =
|
|
|
|
"How far you tilt right and left when v_idlescale is enabled",
|
|
|
|
.default_value = "2",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_float, .value = &v_iyaw_cycle },
|
|
|
|
};
|
|
|
|
float v_iroll_cycle;
|
|
|
|
static cvar_t v_iroll_cycle_cvar = {
|
|
|
|
.name = "v_iroll_cycle",
|
|
|
|
.description =
|
|
|
|
"How quickly you tilt right and left when v_idlescale is enabled",
|
|
|
|
.default_value = "0.5",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_float, .value = &v_iroll_cycle },
|
|
|
|
};
|
|
|
|
float v_ipitch_cycle;
|
|
|
|
static cvar_t v_ipitch_cycle_cvar = {
|
|
|
|
.name = "v_ipitch_cycle",
|
|
|
|
.description =
|
|
|
|
"How quickly you lean forwards and backwards when v_idlescale is "
|
|
|
|
"enabled",
|
|
|
|
.default_value = "1",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_float, .value = &v_ipitch_cycle },
|
|
|
|
};
|
|
|
|
float v_iyaw_level;
|
|
|
|
static cvar_t v_iyaw_level_cvar = {
|
|
|
|
.name = "v_iyaw_level",
|
|
|
|
.description =
|
|
|
|
"How far you tilt right and left when v_idlescale is enabled",
|
|
|
|
.default_value = "0.3",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_float, .value = &v_iyaw_level },
|
|
|
|
};
|
|
|
|
float v_iroll_level;
|
|
|
|
static cvar_t v_iroll_level_cvar = {
|
|
|
|
.name = "v_iroll_level",
|
|
|
|
.description =
|
|
|
|
"How far you tilt right and left when v_idlescale is enabled",
|
|
|
|
.default_value = "0.1",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_float, .value = &v_iroll_level },
|
|
|
|
};
|
|
|
|
float v_ipitch_level;
|
|
|
|
static cvar_t v_ipitch_level_cvar = {
|
|
|
|
.name = "v_ipitch_level",
|
|
|
|
.description =
|
|
|
|
"How far you lean forwards and backwards when v_idlescale is enabled",
|
|
|
|
.default_value = "0.3",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_float, .value = &v_ipitch_level },
|
|
|
|
};
|
2001-02-19 21:15:25 +00:00
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
float v_idlescale;
|
|
|
|
static cvar_t v_idlescale_cvar = {
|
|
|
|
.name = "v_idlescale",
|
|
|
|
.description =
|
|
|
|
"Toggles whether the view remains idle",
|
|
|
|
.default_value = "0",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_float, .value = &v_idlescale },
|
|
|
|
};
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-20 00:34:40 +00:00
|
|
|
float v_dmg_time, v_dmg_roll, v_dmg_pitch;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2021-03-19 11:18:45 +00:00
|
|
|
vec4f_t v_idle_yaw;
|
|
|
|
vec4f_t v_idle_roll;
|
|
|
|
vec4f_t v_idle_pitch;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2022-02-25 06:48:57 +00:00
|
|
|
static cshift_t cshift_empty = { {130, 80, 50}, 0};
|
|
|
|
static cshift_t cshift_water = { {130, 80, 50}, 128};
|
|
|
|
static cshift_t cshift_slime = { { 0, 25, 5}, 150};
|
|
|
|
static cshift_t cshift_lava = { {255, 80, 0}, 150};
|
|
|
|
static cshift_t cshift_bonus = { {215, 186, 60}, 50};
|
|
|
|
|
|
|
|
static cshift_t armor_blood[] = {
|
|
|
|
{ {255, 0, 0} }, // blood
|
|
|
|
{ {220, 50, 50} }, // armor + blood
|
|
|
|
{ {200, 100, 100} }, // armor > blood need two for logic
|
|
|
|
{ {200, 100, 100} }, // armor > blood need two for logic
|
|
|
|
};
|
|
|
|
|
|
|
|
static cshift_t powerup[] = {
|
|
|
|
{ { 0, 0, 0}, 0},
|
|
|
|
{ {100, 100, 100}, 100}, // IT_INVISIBILITY
|
|
|
|
{ {255, 255, 0}, 30}, // IT_INVULNERABILITY
|
|
|
|
{ {255, 255, 0}, 30}, // IT_INVULNERABILITY
|
|
|
|
{ { 0, 255, 0}, 20}, // IT_SUIT
|
|
|
|
{ { 0, 255, 0}, 20}, // IT_SUIT
|
|
|
|
{ { 0, 255, 0}, 20}, // IT_SUIT
|
|
|
|
{ { 0, 255, 0}, 20}, // IT_SUIT
|
|
|
|
{ { 0, 0, 255}, 30}, // IT_QUAD
|
|
|
|
{ { 0, 0, 255}, 30}, // IT_QUAD
|
|
|
|
{ {255, 0, 255}, 30}, // IT_INVULNERABILITY | IT_QUAD
|
|
|
|
{ {255, 0, 255}, 30}, // IT_INVULNERABILITY | IT_QUAD
|
|
|
|
{ {255, 0, 255}, 30}, // IT_INVULNERABILITY | IT_QUAD
|
|
|
|
{ {255, 0, 255}, 30}, // IT_INVULNERABILITY | IT_QUAD
|
|
|
|
{ {255, 0, 255}, 30}, // IT_INVULNERABILITY | IT_QUAD
|
|
|
|
{ {255, 0, 255}, 30}, // IT_INVULNERABILITY | IT_QUAD
|
|
|
|
};
|
2001-05-13 22:57:27 +00:00
|
|
|
|
2012-06-02 04:43:25 +00:00
|
|
|
#define sqr(x) ((x) * (x))
|
2001-08-28 23:05:45 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
float
|
2021-03-12 02:48:53 +00:00
|
|
|
V_CalcRoll (const vec3_t angles, vec4f_t velocity)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2012-05-21 13:00:58 +00:00
|
|
|
float side, sign, value;
|
|
|
|
vec3_t forward, right, up;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
AngleVectors (angles, forward, right, up);
|
|
|
|
side = DotProduct (velocity, right);
|
|
|
|
sign = side < 0 ? -1 : 1;
|
|
|
|
side = fabs (side);
|
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
value = cl_rollangle;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
if (side < cl_rollspeed)
|
|
|
|
side = side * value / cl_rollspeed;
|
2001-02-19 21:15:25 +00:00
|
|
|
else
|
|
|
|
side = value;
|
|
|
|
|
|
|
|
return side * sign;
|
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static float
|
2022-02-25 06:48:57 +00:00
|
|
|
V_CalcBob (viewstate_t *vs)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2022-02-25 06:48:57 +00:00
|
|
|
vec4f_t velocity = vs->velocity;
|
2011-06-19 10:04:49 +00:00
|
|
|
float cycle;
|
2012-06-02 04:43:25 +00:00
|
|
|
static double bobtime;
|
2011-06-19 10:04:49 +00:00
|
|
|
static float bob;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2022-02-25 06:48:57 +00:00
|
|
|
if (!vs->bob_enabled)
|
2001-02-19 21:15:25 +00:00
|
|
|
return 0;
|
|
|
|
|
2022-02-25 06:48:57 +00:00
|
|
|
if (vs->onground == -1)
|
2001-02-19 21:15:25 +00:00
|
|
|
return bob; // just use old value
|
|
|
|
|
2022-02-25 06:48:57 +00:00
|
|
|
bobtime += vs->frametime;
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
cycle = bobtime - (int) (bobtime / cl_bobcycle) *
|
|
|
|
cl_bobcycle;
|
|
|
|
cycle /= cl_bobcycle;
|
|
|
|
if (cycle < cl_bobup)
|
|
|
|
cycle = cycle / cl_bobup;
|
2001-02-19 21:15:25 +00:00
|
|
|
else
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
cycle = 1 + (cycle - cl_bobup) / (1.0 - cl_bobup);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2012-06-02 04:43:25 +00:00
|
|
|
// bob is proportional to velocity in the xy plane
|
2001-08-25 02:47:11 +00:00
|
|
|
// (don't count Z, or jumping messes it up)
|
2021-03-11 07:19:49 +00:00
|
|
|
velocity[2] = 0;
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
bob = sqrt (dotf (velocity, velocity)[0]) * cl_bob;
|
2012-06-02 04:43:25 +00:00
|
|
|
bob = bob * 0.3 + bob * 0.7 * sin (cycle * M_PI);
|
2001-02-19 21:15:25 +00:00
|
|
|
if (bob > 4)
|
|
|
|
bob = 4;
|
|
|
|
else if (bob < -7)
|
|
|
|
bob = -7;
|
|
|
|
return bob;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2022-02-25 06:48:57 +00:00
|
|
|
V_StartPitchDrift (viewstate_t *vs)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2022-02-25 06:48:57 +00:00
|
|
|
if (vs->laststop == vs->time) {
|
2001-08-25 02:47:11 +00:00
|
|
|
return; // something else is keeping it from drifting
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2001-08-25 02:47:11 +00:00
|
|
|
|
2022-02-25 06:48:57 +00:00
|
|
|
if (vs->nodrift || !vs->pitchvel) {
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
vs->pitchvel = v_centerspeed;
|
2022-02-25 06:48:57 +00:00
|
|
|
vs->nodrift = false;
|
|
|
|
vs->driftmove = 0;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-25 06:48:57 +00:00
|
|
|
static void
|
|
|
|
V_StartPitchDrift_f (void *data)
|
|
|
|
{
|
|
|
|
V_StartPitchDrift (data);
|
|
|
|
}
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
void
|
2022-02-25 06:48:57 +00:00
|
|
|
V_StopPitchDrift (viewstate_t *vs)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2022-02-25 06:48:57 +00:00
|
|
|
vs->laststop = vs->time;
|
|
|
|
vs->nodrift = true;
|
|
|
|
vs->pitchvel = 0;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
V_DriftPitch
|
|
|
|
|
2022-02-25 06:48:57 +00:00
|
|
|
Moves the client pitch angle towards vs->idealpitch sent by the server.
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
If the user is adjusting pitch manually, either with lookup/lookdown,
|
|
|
|
mlook and mouse, or klook and keyboard, pitch drifting is constantly
|
|
|
|
stopped.
|
|
|
|
|
|
|
|
Drifting is enabled when the center view key is hit, mlook is released
|
2012-05-21 23:23:22 +00:00
|
|
|
and lookspring is non 0, or when
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2022-02-25 06:48:57 +00:00
|
|
|
V_DriftPitch (viewstate_t *vs)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2011-06-18 13:22:47 +00:00
|
|
|
float delta, move;
|
2022-02-25 06:48:57 +00:00
|
|
|
float forwardmove = vs->movecmd[0];
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2022-02-25 06:48:57 +00:00
|
|
|
if (noclip_anglehack || vs->onground == -1 || !vs->drift_enabled) {
|
|
|
|
vs->driftmove = 0;
|
|
|
|
vs->pitchvel = 0;
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
2001-05-13 22:57:27 +00:00
|
|
|
|
|
|
|
// don't count small mouse motion
|
2022-02-25 06:48:57 +00:00
|
|
|
if (vs->nodrift) {
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
if (fabs (forwardmove) < cl_forwardspeed)
|
2022-02-25 06:48:57 +00:00
|
|
|
vs->driftmove = 0;
|
2001-02-19 21:15:25 +00:00
|
|
|
else
|
2022-02-25 06:48:57 +00:00
|
|
|
vs->driftmove += vs->frametime;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
if (vs->driftmove > v_centermove) {
|
2022-02-25 06:48:57 +00:00
|
|
|
V_StartPitchDrift (vs);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-03-01 02:43:23 +00:00
|
|
|
delta = vs->idealpitch - vs->player_angles[PITCH];
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (!delta) {
|
2022-02-25 06:48:57 +00:00
|
|
|
vs->pitchvel = 0;
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-02-25 06:48:57 +00:00
|
|
|
move = vs->frametime * vs->pitchvel;
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
vs->pitchvel += vs->frametime * v_centerspeed;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (delta > 0) {
|
|
|
|
if (move > delta) {
|
2022-02-25 06:48:57 +00:00
|
|
|
vs->pitchvel = 0;
|
2001-02-19 21:15:25 +00:00
|
|
|
move = delta;
|
|
|
|
}
|
2022-03-01 02:43:23 +00:00
|
|
|
vs->player_angles[PITCH] += move;
|
2001-02-19 21:15:25 +00:00
|
|
|
} else if (delta < 0) {
|
|
|
|
if (move > -delta) {
|
2022-02-25 06:48:57 +00:00
|
|
|
vs->pitchvel = 0;
|
2001-02-19 21:15:25 +00:00
|
|
|
move = -delta;
|
|
|
|
}
|
2022-03-01 02:43:23 +00:00
|
|
|
vs->player_angles[PITCH] -= move;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-08-28 23:05:45 +00:00
|
|
|
/* PALETTE FLASHES */
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
void
|
2022-02-28 03:12:51 +00:00
|
|
|
V_ParseDamage (qmsg_t *net_message, viewstate_t *vs)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2011-06-19 10:04:49 +00:00
|
|
|
float count, side;
|
|
|
|
int armor, blood;
|
2022-03-01 02:43:23 +00:00
|
|
|
vec4f_t origin = vs->player_origin;
|
|
|
|
vec_t *angles = vs->player_angles;
|
2011-06-19 10:04:49 +00:00
|
|
|
vec3_t from, forward, right, up;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
armor = MSG_ReadByte (net_message);
|
|
|
|
blood = MSG_ReadByte (net_message);
|
2011-06-18 13:22:47 +00:00
|
|
|
MSG_ReadCoordV (net_message, from);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
count = blood * 0.5 + armor * 0.5;
|
2001-02-19 21:15:25 +00:00
|
|
|
if (count < 10)
|
|
|
|
count = 10;
|
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
if (cl_cshift_damage
|
2022-02-25 06:48:57 +00:00
|
|
|
|| (vs->force_cshifts & INFO_CSHIFT_DAMAGE)) {
|
|
|
|
cshift_t *cshift = &vs->cshifts[CSHIFT_DAMAGE];
|
|
|
|
int percent = cshift->percent;
|
|
|
|
*cshift = armor_blood[(2 * (armor > blood)) + (armor > 0)];
|
|
|
|
cshift->percent = percent + 3 * count;
|
|
|
|
cshift->percent = bound (0, cshift->percent, 150);
|
2012-06-11 12:01:45 +00:00
|
|
|
cshift->initialpct = cshift->percent;
|
2022-02-25 06:48:57 +00:00
|
|
|
cshift->time = vs->time;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2001-05-13 22:57:27 +00:00
|
|
|
|
|
|
|
// calculate view angle kicks
|
2012-06-02 10:46:57 +00:00
|
|
|
VectorSubtract (from, origin, from);
|
2001-11-07 08:24:56 +00:00
|
|
|
VectorNormalize (from);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2012-06-02 10:46:57 +00:00
|
|
|
AngleVectors (angles, forward, right, up);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
side = DotProduct (from, right);
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
v_dmg_roll = count * side * v_kickroll;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
side = DotProduct (from, forward);
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
v_dmg_pitch = count * side * v_kickpitch;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
v_dmg_time = v_kicktime;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-19 21:15:25 +00:00
|
|
|
V_cshift_f (void)
|
|
|
|
{
|
|
|
|
cshift_empty.destcolor[0] = atoi (Cmd_Argv (1));
|
|
|
|
cshift_empty.destcolor[1] = atoi (Cmd_Argv (2));
|
|
|
|
cshift_empty.destcolor[2] = atoi (Cmd_Argv (3));
|
|
|
|
cshift_empty.percent = atoi (Cmd_Argv (4));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
V_BonusFlash_f
|
|
|
|
|
|
|
|
When you run over an item, the server sends this command
|
|
|
|
*/
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2022-02-25 06:48:57 +00:00
|
|
|
V_BonusFlash_f (void *data)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2022-02-25 06:48:57 +00:00
|
|
|
viewstate_t *vs = data;
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
if (!cl_cshift_bonus
|
2022-02-25 06:48:57 +00:00
|
|
|
&& !(vs->force_cshifts & INFO_CSHIFT_BONUS))
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
2012-05-21 23:23:22 +00:00
|
|
|
|
2022-02-25 06:48:57 +00:00
|
|
|
vs->cshifts[CSHIFT_BONUS] = cshift_bonus;
|
|
|
|
vs->cshifts[CSHIFT_BONUS].initialpct = vs->cshifts[CSHIFT_BONUS].percent;
|
|
|
|
vs->cshifts[CSHIFT_BONUS].time = vs->time;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
V_SetContentsColor
|
|
|
|
|
|
|
|
Underwater, lava, etc each has a color shift
|
|
|
|
*/
|
|
|
|
void
|
2022-02-25 06:48:57 +00:00
|
|
|
V_SetContentsColor (viewstate_t *vs, int contents)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
if (!cl_cshift_contents
|
2022-02-25 06:48:57 +00:00
|
|
|
&& !(vs->force_cshifts & INFO_CSHIFT_CONTENTS)) {
|
|
|
|
vs->cshifts[CSHIFT_CONTENTS] = cshift_empty;
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (contents) {
|
|
|
|
case CONTENTS_EMPTY:
|
2022-02-25 06:48:57 +00:00
|
|
|
vs->cshifts[CSHIFT_CONTENTS] = cshift_empty;
|
2001-02-19 21:15:25 +00:00
|
|
|
break;
|
|
|
|
case CONTENTS_LAVA:
|
2022-02-25 06:48:57 +00:00
|
|
|
vs->cshifts[CSHIFT_CONTENTS] = cshift_lava;
|
2001-02-19 21:15:25 +00:00
|
|
|
break;
|
|
|
|
case CONTENTS_SOLID:
|
|
|
|
case CONTENTS_SLIME:
|
2022-02-25 06:48:57 +00:00
|
|
|
vs->cshifts[CSHIFT_CONTENTS] = cshift_slime;
|
2001-02-19 21:15:25 +00:00
|
|
|
break;
|
|
|
|
default:
|
2022-02-25 06:48:57 +00:00
|
|
|
vs->cshifts[CSHIFT_CONTENTS] = cshift_water;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2022-02-25 06:48:57 +00:00
|
|
|
V_CalcPowerupCshift (viewstate_t *vs)
|
2001-05-21 19:53:57 +00:00
|
|
|
{
|
2022-02-25 06:48:57 +00:00
|
|
|
vs->cshifts[CSHIFT_POWERUP] = powerup[vs->powerup_index];
|
2001-08-10 00:28:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
V_CalcBlend
|
|
|
|
|
|
|
|
LordHavoc made this a real, true alpha blend. Cleaned it up
|
|
|
|
a bit, but otherwise this is his code. --KB
|
|
|
|
*/
|
2021-03-12 02:48:53 +00:00
|
|
|
static void
|
2022-02-25 06:48:57 +00:00
|
|
|
V_CalcBlend (viewstate_t *vs)
|
2001-08-10 00:28:57 +00:00
|
|
|
{
|
2011-06-18 13:22:47 +00:00
|
|
|
float a2, a3;
|
|
|
|
float r = 0, g = 0, b = 0, a = 0;
|
|
|
|
int i;
|
2001-08-10 00:28:57 +00:00
|
|
|
|
|
|
|
for (i = 0; i < NUM_CSHIFTS; i++) {
|
2022-02-25 06:48:57 +00:00
|
|
|
a2 = vs->cshifts[i].percent / 255.0;
|
2001-08-10 00:28:57 +00:00
|
|
|
|
|
|
|
if (!a2)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
a2 = min (a2, 1.0);
|
2022-02-25 06:48:57 +00:00
|
|
|
r += (vs->cshifts[i].destcolor[0] - r) * a2;
|
|
|
|
g += (vs->cshifts[i].destcolor[1] - g) * a2;
|
|
|
|
b += (vs->cshifts[i].destcolor[2] - b) * a2;
|
2001-08-10 00:28:57 +00:00
|
|
|
|
|
|
|
a3 = (1.0 - a) * (1.0 - a2);
|
|
|
|
a = 1.0 - a3;
|
2001-05-21 19:53:57 +00:00
|
|
|
}
|
2001-08-10 00:28:57 +00:00
|
|
|
|
|
|
|
// LordHavoc: saturate color
|
|
|
|
if (a) {
|
|
|
|
a2 = 1.0 / a;
|
|
|
|
r *= a2;
|
|
|
|
g *= a2;
|
|
|
|
b *= a2;
|
|
|
|
}
|
|
|
|
|
2022-02-28 07:55:12 +00:00
|
|
|
vs->cshift_color[0] = min (r, 255.0) / 255.0;
|
|
|
|
vs->cshift_color[1] = min (g, 255.0) / 255.0;
|
|
|
|
vs->cshift_color[2] = min (b, 255.0) / 255.0;
|
|
|
|
vs->cshift_color[3] = bound (0.0, a, 1.0);
|
2001-08-10 00:28:57 +00:00
|
|
|
}
|
|
|
|
|
2012-06-11 12:01:45 +00:00
|
|
|
static void
|
2022-02-25 06:48:57 +00:00
|
|
|
V_DropCShift (cshift_t *cs, double time, float droprate)
|
2012-06-11 12:01:45 +00:00
|
|
|
{
|
|
|
|
if (cs->time < 0) {
|
|
|
|
cs->percent = 0;
|
|
|
|
} else {
|
2022-02-25 06:48:57 +00:00
|
|
|
cs->percent = cs->initialpct - (time - cs->time) * droprate;
|
2012-06-11 12:01:45 +00:00
|
|
|
if (cs->percent <= 0) {
|
|
|
|
cs->percent = 0;
|
|
|
|
cs->time = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-08-10 00:28:57 +00:00
|
|
|
void
|
2022-02-25 06:48:57 +00:00
|
|
|
V_PrepBlend (viewstate_t *vs)
|
2012-05-21 23:23:22 +00:00
|
|
|
{
|
2011-06-18 13:22:47 +00:00
|
|
|
int i, j;
|
2001-08-10 00:28:57 +00:00
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
if (cl_cshift_powerup
|
2022-02-25 06:48:57 +00:00
|
|
|
|| (vs->force_cshifts & INFO_CSHIFT_POWERUP))
|
|
|
|
V_CalcPowerupCshift (vs);
|
2001-08-10 00:28:57 +00:00
|
|
|
|
2022-03-18 15:56:30 +00:00
|
|
|
qboolean cshift_changed = false;
|
2001-08-10 00:28:57 +00:00
|
|
|
|
|
|
|
for (i = 0; i < NUM_CSHIFTS; i++) {
|
2022-02-25 06:48:57 +00:00
|
|
|
if (vs->cshifts[i].percent != vs->prev_cshifts[i].percent) {
|
2022-03-18 15:56:30 +00:00
|
|
|
cshift_changed = true;
|
2022-02-25 06:48:57 +00:00
|
|
|
vs->prev_cshifts[i].percent = vs->cshifts[i].percent;
|
2001-08-10 00:28:57 +00:00
|
|
|
}
|
|
|
|
for (j = 0; j < 3; j++) {
|
2022-02-25 06:48:57 +00:00
|
|
|
if (vs->cshifts[i].destcolor[j] != vs->prev_cshifts[i].destcolor[j])
|
2001-08-28 23:05:45 +00:00
|
|
|
{
|
2022-03-18 15:56:30 +00:00
|
|
|
cshift_changed = true;
|
2022-02-25 06:48:57 +00:00
|
|
|
vs->prev_cshifts[i].destcolor[j] = vs->cshifts[i].destcolor[j];
|
2001-08-10 00:28:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// drop the damage value
|
2022-02-25 06:48:57 +00:00
|
|
|
V_DropCShift (&vs->cshifts[CSHIFT_DAMAGE], vs->time, 150);
|
2001-08-10 00:28:57 +00:00
|
|
|
// drop the bonus value
|
2022-02-25 06:48:57 +00:00
|
|
|
V_DropCShift (&vs->cshifts[CSHIFT_BONUS], vs->time, 100);
|
2001-08-10 00:28:57 +00:00
|
|
|
|
2022-03-18 15:56:30 +00:00
|
|
|
if (!cshift_changed)
|
2001-08-10 00:28:57 +00:00
|
|
|
return;
|
|
|
|
|
2022-02-25 06:48:57 +00:00
|
|
|
V_CalcBlend (vs);
|
2001-05-21 19:53:57 +00:00
|
|
|
}
|
|
|
|
|
2001-08-28 23:05:45 +00:00
|
|
|
/* VIEW RENDERING */
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2022-02-25 06:48:57 +00:00
|
|
|
CalcGunAngle (viewstate_t *vs)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2022-02-28 07:59:38 +00:00
|
|
|
vec4f_t rotation = Transform_GetWorldRotation (vs->camera_transform);
|
2021-03-19 11:18:45 +00:00
|
|
|
//FIXME make child of camera
|
[scene] Make entity_t just an entity id for ECS
This puts the hierarchy (transform) reference, animation, visibility,
renderer, active, and old_origin data in separate components. There are
a few bugs (crashes on grenade explosions in gl/glsl/vulkan, immediately
in sw, reasons known, missing brush models in vulkan).
While quake doesn't really need an ECS, the direction I want to take QF
does, and it does seem to have improved memory bandwidth a little
(uncertain). However, there's a lot more work to go (especially fixing
the above bugs), but this seems to be a good start.
2022-10-23 01:32:09 +00:00
|
|
|
transform_t wep_form = Entity_Transform (vs->weapon_entity);
|
|
|
|
Transform_SetWorldRotation (wep_form, rotation);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2012-05-31 23:19:22 +00:00
|
|
|
static void
|
2022-02-25 06:48:57 +00:00
|
|
|
V_BoundOffsets (viewstate_t *vs)
|
2012-05-31 23:19:22 +00:00
|
|
|
{
|
2022-02-28 07:59:38 +00:00
|
|
|
vec4f_t offset = Transform_GetWorldPosition (vs->camera_transform);
|
2022-03-01 02:43:23 +00:00
|
|
|
offset -= vs->player_origin;
|
2012-05-31 23:19:22 +00:00
|
|
|
|
|
|
|
// absolutely bound refresh reletive to entity clipping hull
|
|
|
|
// so the view can never be inside a solid wall
|
|
|
|
|
2021-03-19 11:18:45 +00:00
|
|
|
offset[0] = bound (-14, offset[0], 14);
|
|
|
|
offset[1] = bound (-14, offset[1], 14);
|
|
|
|
offset[2] = bound (-22, offset[2], 30);
|
2022-03-01 02:43:23 +00:00
|
|
|
Transform_SetWorldPosition (vs->camera_transform,
|
|
|
|
vs->player_origin + offset);
|
2021-03-19 11:18:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static vec4f_t
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
idle_quat (vec4f_t axis, float cycle, float level, double time)
|
2021-03-19 11:18:45 +00:00
|
|
|
{
|
|
|
|
vec4f_t identity = { 0, 0, 0, 1 };
|
|
|
|
if (!level || !cycle) {
|
|
|
|
return identity;
|
|
|
|
}
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
float scale = sin (time * cycle);
|
|
|
|
float ang = scale * level * v_idlescale;
|
2021-07-24 02:38:28 +00:00
|
|
|
float c = cos (ang * M_PI / 360);
|
|
|
|
float s = sin (ang * M_PI / 360);
|
2021-03-19 11:18:45 +00:00
|
|
|
return axis * s + identity * c;
|
2012-05-31 23:19:22 +00:00
|
|
|
}
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
/*
|
|
|
|
V_AddIdle
|
|
|
|
|
|
|
|
Idle swaying
|
|
|
|
*/
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2022-02-25 06:48:57 +00:00
|
|
|
V_AddIdle (viewstate_t *vs)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2021-03-19 11:18:45 +00:00
|
|
|
vec4f_t roll = idle_quat ((vec4f_t) { 1, 0, 0, 0},
|
2022-02-25 06:48:57 +00:00
|
|
|
v_iroll_cycle, v_iroll_level, vs->time);
|
2021-03-19 11:18:45 +00:00
|
|
|
vec4f_t pitch = idle_quat ((vec4f_t) { 0, 1, 0, 0},
|
2022-02-25 06:48:57 +00:00
|
|
|
v_ipitch_cycle, v_ipitch_level, vs->time);
|
2021-03-19 11:18:45 +00:00
|
|
|
vec4f_t yaw = idle_quat ((vec4f_t) { 0, 0, 1, 0},
|
2022-02-25 06:48:57 +00:00
|
|
|
v_iyaw_cycle, v_iyaw_level, vs->time);
|
2021-03-19 11:18:45 +00:00
|
|
|
vec4f_t rot = normalf (qmulf (yaw, qmulf (pitch, roll)));
|
|
|
|
|
|
|
|
// rotate the view
|
2022-02-28 07:59:38 +00:00
|
|
|
vec4f_t rotation = Transform_GetWorldRotation (vs->camera_transform);
|
|
|
|
Transform_SetWorldRotation (vs->camera_transform, qmulf (rot, rotation));
|
2021-03-19 11:18:45 +00:00
|
|
|
|
|
|
|
// counter-rotate the weapon
|
[scene] Make entity_t just an entity id for ECS
This puts the hierarchy (transform) reference, animation, visibility,
renderer, active, and old_origin data in separate components. There are
a few bugs (crashes on grenade explosions in gl/glsl/vulkan, immediately
in sw, reasons known, missing brush models in vulkan).
While quake doesn't really need an ECS, the direction I want to take QF
does, and it does seem to have improved memory bandwidth a little
(uncertain). However, there's a lot more work to go (especially fixing
the above bugs), but this seems to be a good start.
2022-10-23 01:32:09 +00:00
|
|
|
transform_t wep_form = Entity_Transform (vs->weapon_entity);
|
|
|
|
rot = qmulf (qconjf (rot), Transform_GetWorldRotation (wep_form));
|
|
|
|
Transform_SetWorldRotation (wep_form, rot);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
V_CalcViewRoll
|
|
|
|
|
|
|
|
Roll is induced by movement and damage
|
|
|
|
*/
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2022-02-25 06:48:57 +00:00
|
|
|
V_CalcViewRoll (viewstate_t *vs)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2022-03-01 02:43:23 +00:00
|
|
|
vec_t *angles = vs->player_angles;
|
2022-02-25 06:48:57 +00:00
|
|
|
vec4f_t velocity = vs->velocity;
|
2021-03-19 11:18:45 +00:00
|
|
|
vec3_t ang = { };
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2021-03-19 11:18:45 +00:00
|
|
|
ang[ROLL] = V_CalcRoll (angles, velocity);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (v_dmg_time > 0) {
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
ang[ROLL] += v_dmg_time / v_kicktime * v_dmg_roll;
|
|
|
|
ang[PITCH] += v_dmg_time / v_kicktime * v_dmg_pitch;
|
2022-02-25 06:48:57 +00:00
|
|
|
v_dmg_time -= vs->frametime;
|
2021-03-19 11:18:45 +00:00
|
|
|
}
|
|
|
|
|
2022-02-25 06:48:57 +00:00
|
|
|
if (vs->flags & VF_DEAD) { // VF_GIB will also set VF_DEAD
|
2021-03-19 11:18:45 +00:00
|
|
|
ang[ROLL] = 80; // dead view angle
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2021-03-19 11:18:45 +00:00
|
|
|
vec4f_t rot;
|
2022-03-30 15:07:20 +00:00
|
|
|
AngleQuat (ang, (vec_t*)&rot);//FIXME
|
2022-02-28 07:59:38 +00:00
|
|
|
vec4f_t rotation = Transform_GetWorldRotation (vs->camera_transform);
|
|
|
|
Transform_SetWorldRotation (vs->camera_transform, qmulf (rotation, rot));
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2022-02-25 06:48:57 +00:00
|
|
|
V_CalcIntermissionRefdef (viewstate_t *vs)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2022-02-25 06:48:57 +00:00
|
|
|
// vs->player_entity is the player model (visible when out of body)
|
[scene] Make entity_t just an entity id for ECS
This puts the hierarchy (transform) reference, animation, visibility,
renderer, active, and old_origin data in separate components. There are
a few bugs (crashes on grenade explosions in gl/glsl/vulkan, immediately
in sw, reasons known, missing brush models in vulkan).
While quake doesn't really need an ECS, the direction I want to take QF
does, and it does seem to have improved memory bandwidth a little
(uncertain). However, there's a lot more work to go (especially fixing
the above bugs), but this seems to be a good start.
2022-10-23 01:32:09 +00:00
|
|
|
entity_t ent = vs->player_entity;
|
|
|
|
entity_t view;
|
2001-02-19 21:15:25 +00:00
|
|
|
float old;
|
[scene] Make entity_t just an entity id for ECS
This puts the hierarchy (transform) reference, animation, visibility,
renderer, active, and old_origin data in separate components. There are
a few bugs (crashes on grenade explosions in gl/glsl/vulkan, immediately
in sw, reasons known, missing brush models in vulkan).
While quake doesn't really need an ECS, the direction I want to take QF
does, and it does seem to have improved memory bandwidth a little
(uncertain). However, there's a lot more work to go (especially fixing
the above bugs), but this seems to be a good start.
2022-10-23 01:32:09 +00:00
|
|
|
transform_t transform = Entity_Transform (ent);
|
|
|
|
vec4f_t origin = Transform_GetWorldPosition (transform);
|
|
|
|
vec4f_t rotation = Transform_GetWorldRotation (transform);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2011-06-18 13:22:47 +00:00
|
|
|
// view is the weapon model (visible only from inside body)
|
2022-02-25 06:48:57 +00:00
|
|
|
view = vs->weapon_entity;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2022-02-28 07:59:38 +00:00
|
|
|
Transform_SetWorldPosition (vs->camera_transform, origin);
|
|
|
|
Transform_SetWorldRotation (vs->camera_transform, rotation);
|
2022-11-02 00:53:52 +00:00
|
|
|
renderer_t *renderer = Ent_GetComponent (view.id, scene_renderer, view.reg);
|
[scene] Make entity_t just an entity id for ECS
This puts the hierarchy (transform) reference, animation, visibility,
renderer, active, and old_origin data in separate components. There are
a few bugs (crashes on grenade explosions in gl/glsl/vulkan, immediately
in sw, reasons known, missing brush models in vulkan).
While quake doesn't really need an ECS, the direction I want to take QF
does, and it does seem to have improved memory bandwidth a little
(uncertain). However, there's a lot more work to go (especially fixing
the above bugs), but this seems to be a good start.
2022-10-23 01:32:09 +00:00
|
|
|
renderer->model = NULL;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-13 22:57:27 +00:00
|
|
|
// always idle in intermission
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
old = v_idlescale;
|
|
|
|
v_idlescale = 1;
|
2022-02-25 06:48:57 +00:00
|
|
|
V_AddIdle (vs);
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
v_idlescale = old;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2022-02-25 06:48:57 +00:00
|
|
|
V_CalcRefdef (viewstate_t *vs)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2012-05-31 23:20:09 +00:00
|
|
|
// view is the weapon model (visible only from inside body)
|
[scene] Make entity_t just an entity id for ECS
This puts the hierarchy (transform) reference, animation, visibility,
renderer, active, and old_origin data in separate components. There are
a few bugs (crashes on grenade explosions in gl/glsl/vulkan, immediately
in sw, reasons known, missing brush models in vulkan).
While quake doesn't really need an ECS, the direction I want to take QF
does, and it does seem to have improved memory bandwidth a little
(uncertain). However, there's a lot more work to go (especially fixing
the above bugs), but this seems to be a good start.
2022-10-23 01:32:09 +00:00
|
|
|
entity_t view = vs->weapon_entity;
|
2011-06-18 13:22:47 +00:00
|
|
|
float bob;
|
2001-02-19 21:15:25 +00:00
|
|
|
static float oldz = 0;
|
2021-03-19 11:18:45 +00:00
|
|
|
vec4f_t forward = {}, right = {}, up = {};
|
2022-03-01 02:43:23 +00:00
|
|
|
vec4f_t origin = vs->player_origin;
|
|
|
|
vec_t *viewangles = vs->player_angles;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2022-11-02 00:53:52 +00:00
|
|
|
renderer_t *renderer = Ent_GetComponent (view.id, scene_renderer, view.reg);
|
|
|
|
animation_t *animation = Ent_GetComponent (view.id, scene_animation, view.reg);
|
[scene] Make entity_t just an entity id for ECS
This puts the hierarchy (transform) reference, animation, visibility,
renderer, active, and old_origin data in separate components. There are
a few bugs (crashes on grenade explosions in gl/glsl/vulkan, immediately
in sw, reasons known, missing brush models in vulkan).
While quake doesn't really need an ECS, the direction I want to take QF
does, and it does seem to have improved memory bandwidth a little
(uncertain). However, there's a lot more work to go (especially fixing
the above bugs), but this seems to be a good start.
2022-10-23 01:32:09 +00:00
|
|
|
|
2022-02-25 06:48:57 +00:00
|
|
|
V_DriftPitch (vs);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2022-02-25 06:48:57 +00:00
|
|
|
bob = V_CalcBob (vs);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2012-06-02 04:45:52 +00:00
|
|
|
// refresh position
|
2022-11-02 00:52:35 +00:00
|
|
|
if (vs->flags & VF_GIB) {
|
|
|
|
origin[2] += 8; // gib view height
|
|
|
|
} else if (vs->flags & VF_DEAD) {
|
|
|
|
origin[2] += -16; // corpse view height
|
|
|
|
} else {
|
|
|
|
origin[2] += vs->height + bob;
|
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-25 02:47:11 +00:00
|
|
|
// never let it sit exactly on a node line, because a water plane can
|
|
|
|
// disappear when viewed with the eye exactly on it.
|
2010-01-13 06:42:26 +00:00
|
|
|
// server protocol specifies to only 1/8 pixel, so add 1/16 in each axis
|
2022-02-28 07:59:38 +00:00
|
|
|
origin += (vec4f_t) { 1.0/16, 1.0/16, 1.0/16, 0};
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2022-02-28 07:59:38 +00:00
|
|
|
vec4f_t rotation;
|
2022-03-30 15:07:20 +00:00
|
|
|
AngleQuat (vs->player_angles, (vec_t*)&rotation);//FIXME
|
2022-02-28 07:59:38 +00:00
|
|
|
Transform_SetWorldRotation (vs->camera_transform, rotation);
|
2022-02-25 06:48:57 +00:00
|
|
|
V_CalcViewRoll (vs);
|
|
|
|
V_AddIdle (vs);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-13 22:57:27 +00:00
|
|
|
// offsets
|
2021-03-19 11:18:45 +00:00
|
|
|
//FIXME semi-duplicates AngleQuat (also, vec3_t vs vec4f_t)
|
2022-03-30 15:07:20 +00:00
|
|
|
AngleVectors (viewangles, (vec_t*)&forward, (vec_t*)&right, (vec_t*)&up);//FIXME
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2012-05-31 23:19:22 +00:00
|
|
|
// don't allow cheats in multiplayer
|
|
|
|
// FIXME check for dead
|
2022-02-25 06:48:57 +00:00
|
|
|
if (vs->voffs_enabled) {
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
origin += scr_ofsx * forward + scr_ofsy * right + scr_ofsz * up;
|
2012-05-31 23:19:22 +00:00
|
|
|
}
|
|
|
|
|
2022-02-25 06:48:57 +00:00
|
|
|
V_BoundOffsets (vs);
|
2012-05-31 23:19:22 +00:00
|
|
|
|
2001-05-13 22:57:27 +00:00
|
|
|
// set up gun position
|
2022-03-01 02:43:23 +00:00
|
|
|
vec4f_t gun_origin = vs->player_origin;
|
2022-02-25 06:48:57 +00:00
|
|
|
CalcGunAngle (vs);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2022-02-28 07:59:38 +00:00
|
|
|
gun_origin += (vec4f_t) { 0, 0, vs->height, 0 };
|
|
|
|
gun_origin += forward * bob * 0.4f + (vec4f_t) { 0, 0, bob, 0 };
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-25 02:47:11 +00:00
|
|
|
// fudge position around to keep amount of weapon visible
|
|
|
|
// roughly equal with different FOV
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
if (hud_sbar == 0 && *r_data->scr_viewsize >= 100) {
|
2001-02-21 19:13:03 +00:00
|
|
|
;
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
} else if (*r_data->scr_viewsize == 110) {
|
2022-02-28 07:59:38 +00:00
|
|
|
gun_origin += (vec4f_t) { 0, 0, 1, 0};
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
} else if (*r_data->scr_viewsize == 100) {
|
2022-02-28 07:59:38 +00:00
|
|
|
gun_origin += (vec4f_t) { 0, 0, 2, 0};
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
} else if (*r_data->scr_viewsize == 90) {
|
2022-02-28 07:59:38 +00:00
|
|
|
gun_origin += (vec4f_t) { 0, 0, 1, 0};
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
} else if (*r_data->scr_viewsize == 80) {
|
2022-02-28 07:59:38 +00:00
|
|
|
gun_origin += (vec4f_t) { 0, 0, 0.5, 0};
|
2021-03-19 11:18:45 +00:00
|
|
|
}
|
|
|
|
|
2022-02-25 06:48:57 +00:00
|
|
|
model_t *model = vs->weapon_model;
|
|
|
|
if (vs->flags & (VF_GIB | VF_DEAD)) {
|
2021-11-30 16:10:59 +00:00
|
|
|
model = NULL;
|
|
|
|
}
|
[scene] Make entity_t just an entity id for ECS
This puts the hierarchy (transform) reference, animation, visibility,
renderer, active, and old_origin data in separate components. There are
a few bugs (crashes on grenade explosions in gl/glsl/vulkan, immediately
in sw, reasons known, missing brush models in vulkan).
While quake doesn't really need an ECS, the direction I want to take QF
does, and it does seem to have improved memory bandwidth a little
(uncertain). However, there's a lot more work to go (especially fixing
the above bugs), but this seems to be a good start.
2022-10-23 01:32:09 +00:00
|
|
|
if (renderer->model != model) {
|
|
|
|
animation->pose2 = -1;
|
2021-03-09 14:52:40 +00:00
|
|
|
}
|
[scene] Make entity_t just an entity id for ECS
This puts the hierarchy (transform) reference, animation, visibility,
renderer, active, and old_origin data in separate components. There are
a few bugs (crashes on grenade explosions in gl/glsl/vulkan, immediately
in sw, reasons known, missing brush models in vulkan).
While quake doesn't really need an ECS, the direction I want to take QF
does, and it does seem to have improved memory bandwidth a little
(uncertain). However, there's a lot more work to go (especially fixing
the above bugs), but this seems to be a good start.
2022-10-23 01:32:09 +00:00
|
|
|
renderer->model = model;
|
|
|
|
animation->frame = vs->weaponframe;
|
|
|
|
renderer->skin = 0;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-13 22:57:27 +00:00
|
|
|
// set up the refresh position
|
2022-02-28 07:59:38 +00:00
|
|
|
Transform_SetWorldRotation (vs->camera_transform,
|
|
|
|
qmulf (vs->punchangle, rotation));
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-13 22:57:27 +00:00
|
|
|
// smooth out stair step ups
|
2022-02-28 07:59:38 +00:00
|
|
|
if ((vs->onground != -1) && (gun_origin[2] - oldz > 0)) {
|
2001-02-19 21:15:25 +00:00
|
|
|
float steptime;
|
|
|
|
|
2022-02-25 06:48:57 +00:00
|
|
|
steptime = vs->frametime;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
oldz += steptime * 80;
|
2022-02-28 07:59:38 +00:00
|
|
|
if (oldz > gun_origin[2])
|
|
|
|
oldz = gun_origin[2];
|
|
|
|
if (gun_origin[2] - oldz > 12)
|
|
|
|
oldz = gun_origin[2] - 12;
|
|
|
|
origin[2] += oldz - gun_origin[2];
|
|
|
|
gun_origin[2] += oldz - gun_origin[2];
|
2021-03-19 11:18:45 +00:00
|
|
|
} else {
|
2022-02-28 07:59:38 +00:00
|
|
|
oldz = gun_origin[2];
|
2021-03-19 11:18:45 +00:00
|
|
|
}
|
2022-02-28 07:59:38 +00:00
|
|
|
Transform_SetWorldPosition (vs->camera_transform, origin);
|
2021-03-19 11:18:45 +00:00
|
|
|
{
|
|
|
|
// FIXME sort out the alias model specific negation
|
|
|
|
vec3_t ang = {-viewangles[0], viewangles[1], viewangles[2]};
|
2022-02-28 07:59:38 +00:00
|
|
|
CL_TransformEntity (view, 1, ang, gun_origin);
|
2021-03-19 11:18:45 +00:00
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2022-02-25 06:48:57 +00:00
|
|
|
DropPunchAngle (viewstate_t *vs)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2022-02-25 06:48:57 +00:00
|
|
|
vec4f_t punch = vs->punchangle;
|
2021-03-19 11:18:45 +00:00
|
|
|
float ps = magnitude3f (punch)[0];
|
|
|
|
if (ps < 1e-3) {
|
|
|
|
// < 0.2 degree rotation, not worth worrying about
|
|
|
|
//ensure the quaternion is normalized
|
2022-02-25 06:48:57 +00:00
|
|
|
vs->punchangle = (vec4f_t) { 0, 0, 0, 1 };
|
2021-03-19 11:18:45 +00:00
|
|
|
return;
|
|
|
|
}
|
2022-02-25 02:39:11 +00:00
|
|
|
float pc = punch[3];
|
2022-02-25 06:48:57 +00:00
|
|
|
float ds = 0.0871557427 * vs->frametime;
|
2021-03-19 11:18:45 +00:00
|
|
|
float dc = sqrt (1 - ds * ds);
|
|
|
|
float s = ps * dc - pc * ds;
|
|
|
|
float c = pc * dc + ps * ds;
|
|
|
|
if (s <= 0 || c >= 1) {
|
2022-02-25 06:48:57 +00:00
|
|
|
vs->punchangle = (vec4f_t) { 0, 0, 0, 1 };
|
2021-03-19 11:18:45 +00:00
|
|
|
} else {
|
|
|
|
punch *= s / ps;
|
|
|
|
punch[3] = c;
|
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
V_RenderView
|
|
|
|
|
|
|
|
The player's clipping box goes from (-16 -16 -24) to (16 16 32) from
|
|
|
|
the entity origin, so any view position inside that will be valid
|
|
|
|
*/
|
|
|
|
void
|
2022-02-25 06:48:57 +00:00
|
|
|
V_RenderView (viewstate_t *vs)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2022-02-25 06:48:57 +00:00
|
|
|
if (!vs->active) {
|
2022-02-28 07:59:38 +00:00
|
|
|
vec4f_t base = { 0, 0, 0, 1 };
|
|
|
|
Transform_SetWorldPosition (vs->camera_transform, base);
|
|
|
|
Transform_SetWorldRotation (vs->camera_transform, base);
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
2021-03-19 11:18:45 +00:00
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2022-02-28 03:12:51 +00:00
|
|
|
if (vs->decay_punchangle) {
|
|
|
|
DropPunchAngle (vs);
|
|
|
|
}
|
2022-02-25 06:48:57 +00:00
|
|
|
if (vs->intermission) { // intermission / finale rendering
|
|
|
|
V_CalcIntermissionRefdef (vs);
|
2001-02-19 21:15:25 +00:00
|
|
|
} else {
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
if (vs->chase && chase_active) {
|
2022-03-01 05:44:53 +00:00
|
|
|
Chase_Update (vs->chasestate);
|
|
|
|
} else {
|
|
|
|
V_CalcRefdef (vs);
|
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2022-02-28 03:12:51 +00:00
|
|
|
V_Init (viewstate_t *viewstate)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2022-02-28 03:12:51 +00:00
|
|
|
Cmd_AddDataCommand ("bf", V_BonusFlash_f, viewstate,
|
2022-02-25 06:48:57 +00:00
|
|
|
"Background flash, used when you pick up an item");
|
2022-02-28 03:12:51 +00:00
|
|
|
Cmd_AddDataCommand ("centerview", V_StartPitchDrift_f, viewstate,
|
2022-02-25 06:48:57 +00:00
|
|
|
"Centers the player's "
|
2011-06-18 13:22:47 +00:00
|
|
|
"view ahead after +lookup or +lookdown\n"
|
2001-08-25 02:47:11 +00:00
|
|
|
"Will not work while mlook is active or freelook is 1.");
|
2001-09-10 17:32:22 +00:00
|
|
|
Cmd_AddCommand ("v_cshift", V_cshift_f, "This adjusts all of the colors "
|
|
|
|
"currently being displayed.\n"
|
|
|
|
"Used when you are underwater, hit, have the Ring of "
|
|
|
|
"Shadows, or Quad Damage. (v_cshift r g b intensity)");
|
2022-02-28 07:59:38 +00:00
|
|
|
|
2022-10-26 06:22:09 +00:00
|
|
|
viewstate->camera_transform = Transform_New (cl_world.scene->reg,
|
|
|
|
nulltransform);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
V_Init_Cvars (void)
|
|
|
|
{
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
Cvar_Register (&v_centermove_cvar, 0, 0);
|
|
|
|
Cvar_Register (&v_centerspeed_cvar, 0, 0);
|
|
|
|
Cvar_Register (&v_iyaw_cycle_cvar, 0, 0);
|
|
|
|
Cvar_Register (&v_iroll_cycle_cvar, 0, 0);
|
|
|
|
Cvar_Register (&v_ipitch_cycle_cvar, 0, 0);
|
|
|
|
Cvar_Register (&v_iyaw_level_cvar, 0, 0);
|
|
|
|
Cvar_Register (&v_iroll_level_cvar, 0, 0);
|
|
|
|
Cvar_Register (&v_ipitch_level_cvar, 0, 0);
|
|
|
|
Cvar_Register (&v_idlescale_cvar, 0, 0);
|
|
|
|
|
|
|
|
Cvar_Register (&scr_ofsx_cvar, 0, 0);
|
|
|
|
Cvar_Register (&scr_ofsy_cvar, 0, 0);
|
|
|
|
Cvar_Register (&scr_ofsz_cvar, 0, 0);
|
|
|
|
Cvar_Register (&cl_rollspeed_cvar, 0, 0);
|
|
|
|
Cvar_Register (&cl_rollangle_cvar, 0, 0);
|
|
|
|
Cvar_Register (&cl_bob_cvar, 0, 0);
|
|
|
|
Cvar_Register (&cl_bobcycle_cvar, 0, 0);
|
|
|
|
Cvar_Register (&cl_bobup_cvar, 0, 0);
|
|
|
|
Cvar_Register (&v_kicktime_cvar, 0, 0);
|
|
|
|
Cvar_Register (&v_kickroll_cvar, 0, 0);
|
|
|
|
Cvar_Register (&v_kickpitch_cvar, 0, 0);
|
|
|
|
Cvar_Register (&cl_cshift_bonus_cvar, 0, 0);
|
|
|
|
Cvar_Register (&cl_cshift_contents_cvar, 0, 0);
|
|
|
|
Cvar_Register (&cl_cshift_damage_cvar, 0, 0);
|
|
|
|
Cvar_Register (&cl_cshift_powerup_cvar, 0, 0);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|