2001-02-19 21:15:25 +00:00
|
|
|
/*
|
|
|
|
cl_ents.c
|
|
|
|
|
|
|
|
entity parsing and management
|
|
|
|
|
|
|
|
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
|
2003-01-15 15:31:36 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
#ifdef HAVE_STRING_H
|
|
|
|
# include <string.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_STRINGS_H
|
|
|
|
# include <strings.h>
|
|
|
|
#endif
|
|
|
|
|
2001-05-31 03:41:35 +00:00
|
|
|
#include "QF/cvar.h"
|
2001-05-21 00:22:35 +00:00
|
|
|
#include "QF/msg.h"
|
|
|
|
#include "QF/render.h"
|
2001-05-21 22:25:35 +00:00
|
|
|
#include "QF/skin.h"
|
2007-11-06 10:17:14 +00:00
|
|
|
#include "QF/sys.h"
|
2001-05-21 00:22:35 +00:00
|
|
|
|
2021-07-24 05:19:52 +00:00
|
|
|
#include "QF/scene/entity.h"
|
|
|
|
|
2001-08-25 02:47:11 +00:00
|
|
|
#include "compat.h"
|
2020-06-21 14:15:17 +00:00
|
|
|
|
2021-03-11 02:25:04 +00:00
|
|
|
#include "client/effects.h"
|
2021-03-11 02:38:33 +00:00
|
|
|
#include "client/locs.h"
|
2021-03-10 09:00:16 +00:00
|
|
|
#include "client/temp_entities.h"
|
2021-03-12 02:48:53 +00:00
|
|
|
#include "client/view.h"
|
2022-03-04 16:48:10 +00:00
|
|
|
#include "client/world.h"
|
2021-03-10 09:00:16 +00:00
|
|
|
|
2020-06-21 14:15:17 +00:00
|
|
|
#include "qw/bothdefs.h"
|
|
|
|
#include "qw/msg_ucmd.h"
|
2005-05-02 04:09:15 +00:00
|
|
|
#include "qw/pmove.h"
|
2020-06-21 14:15:17 +00:00
|
|
|
|
|
|
|
#include "qw/include/cl_cam.h"
|
|
|
|
#include "qw/include/cl_ents.h"
|
|
|
|
#include "qw/include/cl_main.h"
|
|
|
|
#include "qw/include/cl_parse.h"
|
|
|
|
#include "qw/include/cl_pred.h"
|
|
|
|
#include "qw/include/host.h"
|
2001-02-19 21:15:25 +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
|
|
|
entity_t cl_flag_ents[MAX_CLIENTS];
|
|
|
|
entity_t cl_entities[512]; // FIXME: magic number
|
2012-07-05 10:06:35 +00:00
|
|
|
byte cl_entity_valid[2][512];
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
void
|
2011-08-27 01:25:41 +00:00
|
|
|
CL_ClearEnts (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2011-08-27 01:25:41 +00:00
|
|
|
size_t i;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2022-03-04 16:48:10 +00:00
|
|
|
for (i = 0; i < MAX_CLIENTS; i++) {
|
[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 (Entity_Valid (cl_flag_ents[i])) {
|
2022-03-04 16:48:10 +00:00
|
|
|
Scene_DestroyEntity (cl_world.scene, cl_flag_ents[i]);
|
[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
|
|
|
cl_flag_ents[i] = nullentity;
|
2022-03-04 16:48:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < 512; i++) {
|
[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 (Entity_Valid (cl_entities[i])) {
|
2022-03-04 16:48:10 +00:00
|
|
|
Scene_DestroyEntity (cl_world.scene, cl_entities[i]);
|
[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
|
|
|
cl_entities[i] = nullentity;
|
2022-03-04 16:48:10 +00:00
|
|
|
}
|
|
|
|
}
|
2012-07-01 02:36:47 +00:00
|
|
|
i = qw_entstates.num_frames * qw_entstates.num_entities;
|
|
|
|
memset (qw_entstates.frame[0], 0, i * sizeof (entity_state_t));
|
2012-07-05 10:06:35 +00:00
|
|
|
memset (cl_entity_valid, 0, sizeof (cl_entity_valid));
|
2022-03-04 16:48:10 +00:00
|
|
|
}
|
|
|
|
|
2022-11-13 06:08:18 +00:00
|
|
|
static entity_t
|
|
|
|
CL_GetInvalidEntity (int num)
|
|
|
|
{
|
|
|
|
return cl_entities[num];
|
|
|
|
}
|
|
|
|
|
[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
|
2022-03-04 16:48:10 +00:00
|
|
|
CL_GetEntity (int num)
|
|
|
|
{
|
[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 (!Entity_Valid (cl_entities[num])) {
|
2022-03-04 16:48:10 +00:00
|
|
|
cl_entities[num] = Scene_CreateEntity (cl_world.scene);
|
|
|
|
CL_Init_Entity (cl_entities[num]);
|
|
|
|
}
|
|
|
|
return cl_entities[num];
|
2001-02-19 21:15:25 +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
|
|
|
static entity_t
|
2022-10-22 03:42:32 +00:00
|
|
|
CL_GetFlagEnt (int key)
|
|
|
|
{
|
[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 (!Entity_Valid (cl_flag_ents[key])) {
|
2022-10-22 03:42:32 +00:00
|
|
|
cl_flag_ents[key] = Scene_CreateEntity (cl_world.scene);
|
|
|
|
CL_Init_Entity (cl_flag_ents[key]);
|
|
|
|
}
|
|
|
|
return cl_flag_ents[key];
|
|
|
|
}
|
|
|
|
|
2010-12-03 05:10:53 +00:00
|
|
|
// Hack hack hack
|
|
|
|
static inline int
|
|
|
|
is_dead_body (entity_state_t *s1)
|
|
|
|
{
|
|
|
|
int i = s1->frame;
|
|
|
|
|
|
|
|
if (s1->modelindex == cl_playerindex
|
|
|
|
&& (i == 49 || i == 60 || i == 69 || i == 84 || i == 93 || i == 102))
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Hack hack hack
|
|
|
|
static inline int
|
|
|
|
is_gib (entity_state_t *s1)
|
|
|
|
{
|
|
|
|
if (s1->modelindex == cl_h_playerindex || s1->modelindex == cl_gib1index
|
|
|
|
|| s1->modelindex == cl_gib2index || s1->modelindex == cl_gib3index)
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
[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
|
|
|
set_entity_model (entity_t ent, int modelindex)
|
2001-02-19 21:15:25 +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_t *renderer = Ent_GetComponent (ent.id, scene_renderer,
|
|
|
|
cl_world.scene->reg);
|
|
|
|
animation_t *animation = Ent_GetComponent (ent.id, scene_animation,
|
|
|
|
cl_world.scene->reg);
|
2022-03-04 16:48:10 +00:00
|
|
|
renderer->model = cl_world.models.a[modelindex];
|
2012-07-05 10:06:35 +00:00
|
|
|
// automatic animation (torches, etc) can be either all together
|
|
|
|
// or randomized
|
2021-03-09 14:52:40 +00:00
|
|
|
if (renderer->model) {
|
|
|
|
if (renderer->model->synctype == ST_RAND) {
|
|
|
|
animation->syncbase = (float) (rand () & 0x7fff) / 0x7fff;
|
|
|
|
} else {
|
|
|
|
animation->syncbase = 0.0;
|
|
|
|
}
|
2012-07-05 10:06:35 +00:00
|
|
|
}
|
2021-03-11 02:25:04 +00:00
|
|
|
animation->nolerp = 1; // don't try to lerp when the model has changed
|
2012-07-05 10:06:35 +00:00
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2012-07-05 10:06:35 +00:00
|
|
|
static void
|
|
|
|
CL_LinkPacketEntities (void)
|
|
|
|
{
|
|
|
|
int i, j, forcelink;
|
|
|
|
float frac, f;
|
[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;
|
2012-07-05 10:06:35 +00:00
|
|
|
entity_state_t *new, *old;
|
|
|
|
|
|
|
|
frac = 1;
|
2022-03-04 16:48:10 +00:00
|
|
|
for (i = MAX_CLIENTS + 1; i < 512; i++) {
|
2012-07-05 10:06:35 +00:00
|
|
|
new = &qw_entstates.frame[cl.link_sequence & UPDATE_MASK][i];
|
|
|
|
old = &qw_entstates.frame[cl.prev_sequence & UPDATE_MASK][i];
|
2022-11-13 06:08:18 +00:00
|
|
|
|
|
|
|
ent = CL_GetInvalidEntity (i);
|
2012-07-05 10:06:35 +00:00
|
|
|
forcelink = cl_entity_valid[0][i] != cl_entity_valid[1][i];
|
|
|
|
cl_entity_valid[1][i] = cl_entity_valid[0][i];
|
2022-11-13 06:08:18 +00:00
|
|
|
// if the object wasn't included in the last packet, or set
|
|
|
|
// to invisible, remove it
|
|
|
|
if (!cl_entity_valid[0][i]
|
|
|
|
|| !new->modelindex
|
|
|
|
|| (cl_deadbodyfilter && is_dead_body (new))
|
|
|
|
|| (cl_gibfilter && is_gib (new))) {
|
|
|
|
if (Entity_Valid (ent)) {
|
|
|
|
Scene_DestroyEntity (cl_world.scene, ent);
|
2021-03-09 14:52:40 +00:00
|
|
|
}
|
2012-07-05 10:06:35 +00:00
|
|
|
continue;
|
|
|
|
}
|
2022-11-13 06:08:18 +00:00
|
|
|
if (!Entity_Valid (ent)) {
|
|
|
|
ent = CL_GetEntity (i);
|
|
|
|
forcelink = true;
|
|
|
|
}
|
|
|
|
transform_t transform = Entity_Transform (ent);
|
|
|
|
renderer_t *renderer = Ent_GetComponent (ent.id, scene_renderer,
|
|
|
|
ent.reg);
|
|
|
|
animation_t *animation = Ent_GetComponent (ent.id, scene_animation,
|
|
|
|
ent.reg);
|
|
|
|
vec4f_t *old_origin = Ent_GetComponent (ent.id, scene_old_origin,
|
|
|
|
ent.reg);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// spawn light flashes, even ones coming from invisible objects
|
2012-07-05 10:06:35 +00:00
|
|
|
CL_NewDlight (i, new->origin, new->effects, new->glow_size,
|
2021-03-11 02:25:04 +00:00
|
|
|
new->glow_color, cl.time);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2012-07-05 10:06:35 +00:00
|
|
|
if (forcelink)
|
|
|
|
*old = *new;
|
|
|
|
|
|
|
|
if (forcelink || new->modelindex != old->modelindex) {
|
|
|
|
old->modelindex = new->modelindex;
|
|
|
|
set_entity_model (ent, new->modelindex);
|
|
|
|
}
|
2021-03-09 14:52:40 +00:00
|
|
|
animation->frame = new->frame;
|
2012-07-05 10:06:35 +00:00
|
|
|
if (forcelink || new->colormap != old->colormap
|
|
|
|
|| new->skinnum != old->skinnum) {
|
|
|
|
old->skinnum = new->skinnum;
|
2021-03-09 14:52:40 +00:00
|
|
|
renderer->skinnum = new->skinnum;
|
2012-07-05 10:06:35 +00:00
|
|
|
old->colormap = new->colormap;
|
|
|
|
if (new->colormap && (new->colormap <= MAX_CLIENTS)
|
|
|
|
&& cl.players[new->colormap - 1].name
|
2013-02-14 00:54:36 +00:00
|
|
|
&& cl.players[new->colormap - 1].name->value[0]
|
|
|
|
&& new->modelindex == cl_playerindex) {
|
2012-07-05 10:06:35 +00:00
|
|
|
player_info_t *player = &cl.players[new->colormap - 1];
|
2021-03-09 14:52:40 +00:00
|
|
|
renderer->skin
|
|
|
|
= mod_funcs->Skin_SetSkin (renderer->skin, new->colormap,
|
|
|
|
player->skinname->value);
|
|
|
|
renderer->skin = mod_funcs->Skin_SetColormap (renderer->skin,
|
|
|
|
new->colormap);
|
2012-07-05 10:06:35 +00:00
|
|
|
} else {
|
2021-03-09 14:52:40 +00:00
|
|
|
renderer->skin = mod_funcs->Skin_SetColormap (renderer->skin,
|
|
|
|
0);
|
2012-07-05 10:06:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-09 14:52:40 +00:00
|
|
|
VectorCopy (ent_colormod[new->colormod], renderer->colormod);
|
|
|
|
renderer->colormod[3] = new->alpha / 255.0;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2021-03-09 14:52:40 +00:00
|
|
|
renderer->min_light = 0;
|
|
|
|
renderer->fullbright = 0;
|
2012-07-05 10:06:35 +00:00
|
|
|
if (new->modelindex == cl_playerindex) {
|
[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
|
|
|
renderer->min_light = min (cl.fbskins, cl_fb_players);
|
2021-03-09 14:52:40 +00:00
|
|
|
if (renderer->min_light >= 1.0) {
|
|
|
|
renderer->fullbright = 1;
|
|
|
|
}
|
2004-07-11 01:41:01 +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
|
|
|
*old_origin = Transform_GetWorldPosition (transform);
|
2012-07-05 10:06:35 +00:00
|
|
|
if (forcelink) {
|
2021-03-09 14:52:40 +00:00
|
|
|
animation->pose1 = animation->pose2 = -1;
|
2021-03-19 11:18:45 +00:00
|
|
|
CL_TransformEntity (ent, new->scale / 16, new->angles,
|
|
|
|
new->origin);
|
[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 (i != cl.viewentity || chase_active) {
|
2022-05-05 05:41:46 +00:00
|
|
|
R_AddEfrags (&cl_world.scene->worldmodel->brush, ent);
|
2012-07-05 10:06:35 +00:00
|
|
|
}
|
2002-03-14 21:33:56 +00:00
|
|
|
} else {
|
2021-03-19 11:18:45 +00:00
|
|
|
vec4f_t delta = new->origin - old->origin;
|
2012-07-05 10:06:35 +00:00
|
|
|
f = frac;
|
|
|
|
// If the delta is large, assume a teleport and don't lerp
|
2022-03-30 15:28:26 +00:00
|
|
|
if (fabs (delta[0]) > 100 || fabs (delta[1]) > 100
|
2012-07-05 10:06:35 +00:00
|
|
|
|| fabs (delta[2]) > 100) {
|
|
|
|
// assume a teleportation, not a motion
|
2021-03-19 11:18:45 +00:00
|
|
|
CL_TransformEntity (ent, new->scale / 16, new->angles,
|
|
|
|
new->origin);
|
2021-03-09 14:52:40 +00:00
|
|
|
animation->pose1 = animation->pose2 = -1;
|
2021-07-11 03:31:34 +00:00
|
|
|
} else if (!(renderer->model->flags & EF_ROTATE)) {
|
2012-07-05 10:06:35 +00:00
|
|
|
vec3_t angles, d;
|
2021-03-19 11:18:45 +00:00
|
|
|
vec4f_t origin = old->origin + f * delta;
|
2012-07-05 10:06:35 +00:00
|
|
|
// interpolate the origin and angles
|
2021-07-11 03:31:34 +00:00
|
|
|
VectorSubtract (new->angles, old->angles, d);
|
|
|
|
for (j = 0; j < 3; j++) {
|
|
|
|
if (d[j] > 180)
|
|
|
|
d[j] -= 360;
|
|
|
|
else if (d[j] < -180)
|
|
|
|
d[j] += 360;
|
2012-07-05 10:06:35 +00:00
|
|
|
}
|
2021-07-11 03:31:34 +00:00
|
|
|
VectorMultAdd (old->angles, f, d, angles);
|
2021-03-19 11:18:45 +00:00
|
|
|
CL_TransformEntity (ent, new->scale / 16.0, angles, origin);
|
2012-07-05 10:06:35 +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 (i != cl.viewentity || chase_active) {
|
[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
|
|
|
vec4f_t org = Transform_GetWorldPosition (transform);
|
2022-11-13 06:08:18 +00:00
|
|
|
if (!VectorCompare (org, *old_origin)) {//FIXME
|
2022-05-05 05:41:46 +00:00
|
|
|
R_AddEfrags (&cl_world.scene->worldmodel->brush, ent);
|
2012-07-05 10:06:35 +00:00
|
|
|
}
|
2010-12-03 05:10:53 +00:00
|
|
|
}
|
2001-12-03 05:36:39 +00:00
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2012-06-19 23:02:29 +00:00
|
|
|
// rotate binary objects locally
|
2021-03-09 14:52:40 +00:00
|
|
|
if (renderer->model->flags & EF_ROTATE) {
|
2012-06-19 23:02:29 +00:00
|
|
|
vec3_t angles;
|
|
|
|
angles[PITCH] = 0;
|
|
|
|
angles[YAW] = anglemod (100 * cl.time);
|
|
|
|
angles[ROLL] = 0;
|
2021-03-19 11:18:45 +00:00
|
|
|
CL_TransformEntity (ent, new->scale / 16.0, angles, new->origin);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2012-07-05 10:06:35 +00:00
|
|
|
//CL_EntityEffects (i, ent, new);
|
2021-03-11 02:25:04 +00:00
|
|
|
//CL_NewDlight (i, ent->origin, new->effects, 0, 0, cl.time);
|
[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
|
|
|
vec4f_t org = Transform_GetWorldPosition (transform);
|
2021-03-19 11:18:45 +00:00
|
|
|
if (VectorDistance_fast (old->origin, org) > (256 * 256))
|
|
|
|
old->origin = org;
|
2021-03-09 14:52:40 +00:00
|
|
|
if (renderer->model->flags & ~EF_ROTATE) {
|
2021-03-11 02:25:04 +00:00
|
|
|
CL_ModelEffects (ent, -new->number, new->glow_color, cl.time);
|
2021-03-09 14:52:40 +00:00
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
[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
|
|
|
CL_UpdateFlagModels (entity_t ent, int key)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2002-08-06 03:52:38 +00:00
|
|
|
static float flag_offsets[] = {
|
|
|
|
16.0, 22.0, 26.0, 25.0, 24.0, 18.0, // 29-34 axpain
|
|
|
|
16.0, 24.0, 24.0, 22.0, 18.0, 16.0, // 35-40 pain
|
|
|
|
};
|
2011-12-15 03:06:03 +00:00
|
|
|
float f;
|
[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 fent = CL_GetFlagEnt (key);
|
|
|
|
byte *active = Ent_GetComponent (fent.id, scene_active,
|
|
|
|
cl_world.scene->reg);
|
2001-02-19 21:15:25 +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
|
|
|
if (!*active) {
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
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
|
|
|
animation_t *animation = Ent_GetComponent (ent.id, scene_animation,
|
|
|
|
cl_world.scene->reg);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2002-06-30 16:19:37 +00:00
|
|
|
f = 14.0;
|
[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 (animation->frame >= 29 && animation->frame <= 40) {
|
|
|
|
f = flag_offsets[animation->frame - 29];
|
|
|
|
} else if (animation->frame >= 103 && animation->frame <= 118) {
|
|
|
|
if (animation->frame <= 106) { // 103-104 nailattack
|
2021-03-09 14:52:40 +00:00
|
|
|
f = 20.0; // 105-106 light
|
|
|
|
} else { // 107-112 rocketattack
|
|
|
|
f = 21.0; // 112-118 shotattack
|
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2021-07-22 10:35:12 +00:00
|
|
|
vec4f_t scale = { 1, 1, 1, 1 };
|
|
|
|
// -45 degree roll (x is forward)
|
|
|
|
vec4f_t rotation = { -0.382683432, 0, 0, 0.923879533 };
|
2022-10-22 03:42:32 +00:00
|
|
|
vec4f_t position = { -f, -22, -16, 1};
|
2021-07-22 10:35:12 +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
|
|
|
transform_t transform = Entity_Transform (fent);
|
|
|
|
Transform_SetLocalTransform (transform, scale, rotation, position);
|
2021-07-22 10:35:12 +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
|
|
|
static entity_t
|
|
|
|
CL_AddFlagModels (entity_t ent, int team, int key)
|
2021-07-22 10:35:12 +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
|
|
|
entity_t fent;
|
2021-07-22 10:35:12 +00:00
|
|
|
|
2022-10-22 03:42:32 +00:00
|
|
|
fent = CL_GetFlagEnt (key);
|
[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
|
|
|
byte *active = Ent_GetComponent (fent.id, scene_active,
|
|
|
|
cl_world.scene->reg);
|
2021-07-22 10:35:12 +00:00
|
|
|
|
|
|
|
if (cl_flagindex == -1) {
|
[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
|
|
|
*active = 0;
|
|
|
|
return nullentity;
|
2021-07-22 10:35:12 +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
|
|
|
*active = 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
|
|
|
transform_t ftransform = Entity_Transform (fent);
|
|
|
|
transform_t transform = Entity_Transform (ent);
|
|
|
|
if (!Transform_Valid (Transform_GetParent (ftransform))) {
|
2022-10-26 06:22:09 +00:00
|
|
|
Transform_SetParent (ftransform, transform);
|
2021-03-09 14:52:40 +00:00
|
|
|
}
|
2021-07-22 10:35:12 +00:00
|
|
|
CL_UpdateFlagModels (ent, key);
|
|
|
|
|
[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_t *renderer = Ent_GetComponent (fent.id, scene_renderer,
|
|
|
|
cl_world.scene->reg);
|
|
|
|
renderer->model = cl_world.models.a[cl_flagindex];
|
|
|
|
renderer->skinnum = team;
|
2010-12-03 05:54:39 +00:00
|
|
|
|
2021-07-22 10:35:12 +00:00
|
|
|
return fent;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
CL_RemoveFlagModels (int key)
|
|
|
|
{
|
[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 fent;
|
2021-07-22 10:35:12 +00:00
|
|
|
|
2022-10-22 03:42:32 +00:00
|
|
|
fent = CL_GetFlagEnt (key);
|
[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
|
|
|
byte *active = Ent_GetComponent (fent.id, scene_active,
|
|
|
|
cl_world.scene->reg);
|
|
|
|
transform_t transform = Entity_Transform (fent);
|
|
|
|
*active = 0;
|
2022-10-26 06:22:09 +00:00
|
|
|
Transform_SetParent (transform, nulltransform);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
CL_LinkPlayers
|
|
|
|
|
|
|
|
Create visible entities in the correct position
|
|
|
|
for all current players
|
|
|
|
*/
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-19 21:15:25 +00:00
|
|
|
CL_LinkPlayers (void)
|
|
|
|
{
|
2001-09-10 17:32:22 +00:00
|
|
|
double playertime;
|
2021-03-11 05:27:36 +00:00
|
|
|
int msec, oldphysent, j;
|
[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;
|
2001-09-10 17:32:22 +00:00
|
|
|
frame_t *frame;
|
2021-07-22 10:35:12 +00:00
|
|
|
player_info_t *player;
|
2001-09-10 17:32:22 +00:00
|
|
|
player_state_t exact;
|
2001-02-19 21:15:25 +00:00
|
|
|
player_state_t *state;
|
2002-07-27 00:44:54 +00:00
|
|
|
qboolean clientplayer;
|
2021-03-11 07:19:49 +00:00
|
|
|
vec3_t ang = {0, 0, 0};
|
|
|
|
vec4f_t org;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
playertime = realtime - cls.latency + 0.02;
|
|
|
|
if (playertime > realtime)
|
|
|
|
playertime = realtime;
|
|
|
|
|
|
|
|
frame = &cl.frames[cl.parsecount & UPDATE_MASK];
|
|
|
|
|
2021-07-22 10:35:12 +00:00
|
|
|
for (j = 0, player = cl.players, state = frame->playerstate;
|
|
|
|
j < MAX_CLIENTS; j++, player++, state++) {
|
2022-11-13 06:08:18 +00:00
|
|
|
ent = CL_GetInvalidEntity (j + 1);
|
|
|
|
if (state->messagenum != cl.parsecount
|
|
|
|
|| !player->name || !player->name->value[0]) {
|
|
|
|
// not present this frame
|
|
|
|
if (Entity_Valid (ent)) {
|
|
|
|
Scene_DestroyEntity (cl_world.scene, ent);
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!Entity_Valid (ent)) {
|
|
|
|
ent = CL_GetEntity (j + 1);
|
|
|
|
}
|
[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_t *renderer = Ent_GetComponent (ent.id, scene_renderer,
|
|
|
|
cl_world.scene->reg);
|
|
|
|
animation_t *animation = Ent_GetComponent (ent.id, scene_animation,
|
|
|
|
cl_world.scene->reg);
|
2002-03-15 16:49:40 +00:00
|
|
|
|
2002-06-18 21:41:24 +00:00
|
|
|
// spawn light flashes, even ones coming from invisible objects
|
|
|
|
if (j == cl.playernum) {
|
2022-03-01 02:43:23 +00:00
|
|
|
org = cl.viewstate.player_origin;
|
2022-03-04 16:48:10 +00:00
|
|
|
cl.viewstate.player_entity = ent;
|
2002-07-27 00:44:54 +00:00
|
|
|
clientplayer = true;
|
|
|
|
} else {
|
2021-03-11 07:19:49 +00:00
|
|
|
org = state->pls.es.origin;
|
2002-07-27 00:44:54 +00:00
|
|
|
clientplayer = false;
|
|
|
|
}
|
2021-07-22 10:35:12 +00:00
|
|
|
if (player->chat && player->chat->value[0] != '0') {
|
2022-03-07 04:40:04 +00:00
|
|
|
dlight_t *dl = R_AllocDlight (j + 1);
|
2012-06-29 08:59:30 +00:00
|
|
|
VectorCopy (org, dl->origin);
|
|
|
|
dl->radius = 100;
|
|
|
|
dl->die = cl.time + 0.1;
|
|
|
|
QuatSet (0.0, 1.0, 0.0, 1.0, dl->color);
|
|
|
|
} else {
|
2021-03-11 05:27:36 +00:00
|
|
|
CL_NewDlight (j + 1, org, state->pls.es.effects,
|
|
|
|
state->pls.es.glow_size, state->pls.es.glow_color,
|
|
|
|
cl.time);
|
2012-06-29 08:59:30 +00:00
|
|
|
}
|
2002-06-18 21:41:24 +00:00
|
|
|
|
2002-07-27 00:44:54 +00:00
|
|
|
// Draw player?
|
|
|
|
if (!Cam_DrawPlayer (j))
|
|
|
|
continue;
|
2002-07-03 00:37:28 +00:00
|
|
|
|
2021-03-11 05:27:36 +00:00
|
|
|
if (!state->pls.es.modelindex)
|
2001-02-19 21:15:25 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
// Hack hack hack
|
[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_deadbodyfilter
|
2021-03-11 05:27:36 +00:00
|
|
|
&& state->pls.es.modelindex == cl_playerindex
|
|
|
|
&& is_dead_body (&state->pls.es))
|
2001-02-19 21:15:25 +00:00
|
|
|
continue;
|
|
|
|
|
2010-01-13 06:42:26 +00:00
|
|
|
// predict only half the move to minimize overruns
|
2002-06-07 11:25:47 +00:00
|
|
|
msec = 500 * (playertime - state->state_time);
|
[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 (msec <= 0 || (!cl_predict_players) || cls.demoplayback2) {
|
2021-03-19 11:18:45 +00:00
|
|
|
Sys_Printf("a\n");
|
|
|
|
exact.pls.es.origin = state->pls.es.origin;
|
2002-06-30 16:19:37 +00:00
|
|
|
} else { // predict players movement
|
2005-04-30 03:59:23 +00:00
|
|
|
state->pls.cmd.msec = msec = min (msec, 255);
|
2002-06-07 11:25:47 +00:00
|
|
|
|
|
|
|
oldphysent = pmove.numphysent;
|
|
|
|
CL_SetSolidPlayers (j);
|
2021-03-19 11:18:45 +00:00
|
|
|
exact.pls.es.origin[3] = 1;//FIXME should be done by prediction
|
2005-04-30 03:59:23 +00:00
|
|
|
CL_PredictUsercmd (state, &exact, &state->pls.cmd, clientplayer);
|
2002-06-07 11:25:47 +00:00
|
|
|
pmove.numphysent = oldphysent;
|
|
|
|
}
|
|
|
|
|
|
|
|
// angles
|
|
|
|
if (j == cl.playernum)
|
|
|
|
{
|
2022-03-01 02:43:23 +00:00
|
|
|
ang[PITCH] = -cl.viewstate.player_angles[PITCH] / 3.0;
|
|
|
|
ang[YAW] = cl.viewstate.player_angles[YAW];
|
2002-06-18 21:41:24 +00:00
|
|
|
} else {
|
2011-12-15 03:06:03 +00:00
|
|
|
ang[PITCH] = -state->viewangles[PITCH] / 3.0;
|
|
|
|
ang[YAW] = state->viewangles[YAW];
|
2002-06-07 11:25:47 +00:00
|
|
|
}
|
2021-03-11 05:27:36 +00:00
|
|
|
ang[ROLL] = V_CalcRoll (ang, state->pls.es.velocity) * 4.0;
|
2002-06-07 11:25:47 +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
|
|
|
if (renderer->model
|
2022-03-04 16:48:10 +00:00
|
|
|
!= cl_world.models.a[state->pls.es.modelindex]) {
|
[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 = cl_world.models.a[state->pls.es.modelindex];
|
|
|
|
animation->nolerp = 1;
|
2021-03-19 13:54:20 +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
|
|
|
animation->frame = state->pls.es.frame;
|
|
|
|
renderer->skinnum = state->pls.es.skinnum;
|
2004-07-11 01:41:01 +00:00
|
|
|
|
2021-03-19 11:18:45 +00:00
|
|
|
//FIXME scale
|
|
|
|
CL_TransformEntity (ent, 1, ang, exact.pls.es.origin);
|
2011-12-15 03:06:03 +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->min_light = 0;
|
|
|
|
renderer->fullbright = 0;
|
2004-07-11 01:41:01 +00:00
|
|
|
|
2021-03-11 05:27:36 +00:00
|
|
|
if (state->pls.es.modelindex == cl_playerindex) { //XXX
|
2001-12-03 05:36:39 +00:00
|
|
|
// use custom skin
|
[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->skin = player->skin;
|
2012-01-23 14:38:32 +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->min_light = min (cl.fbskins, cl_fb_players);
|
2004-07-11 01:41:01 +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
|
|
|
if (renderer->min_light >= 1.0) {
|
|
|
|
renderer->fullbright = 1;
|
2021-03-09 14:52:40 +00:00
|
|
|
}
|
2001-12-03 05:36:39 +00:00
|
|
|
} else {
|
2012-01-24 01:28:07 +00:00
|
|
|
// FIXME no team colors on nonstandard player models
|
[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->skin = 0;
|
2001-12-03 05:36:39 +00:00
|
|
|
}
|
2002-06-19 17:01:31 +00:00
|
|
|
|
2021-07-22 10:35:12 +00:00
|
|
|
int flag_state = state->pls.es.effects & (EF_FLAG1 | EF_FLAG2);
|
[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 (Entity_Valid (player->flag_ent) && !flag_state) {
|
2021-07-22 10:35:12 +00:00
|
|
|
CL_RemoveFlagModels (j);
|
[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
|
|
|
player->flag_ent = (entity_t) nullentity;
|
|
|
|
} else if (!Entity_Valid (player->flag_ent) && flag_state) {
|
2021-07-22 10:35:12 +00:00
|
|
|
if (flag_state & EF_FLAG1)
|
|
|
|
player->flag_ent = CL_AddFlagModels (ent, 0, j);
|
|
|
|
else if (flag_state & EF_FLAG2)
|
|
|
|
player->flag_ent = CL_AddFlagModels (ent, 1, j);
|
|
|
|
}
|
|
|
|
|
2002-06-19 17:32:39 +00:00
|
|
|
// stuff entity in map
|
2022-05-05 05:41:46 +00:00
|
|
|
R_AddEfrags (&cl_world.scene->worldmodel->brush, ent);
|
[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 (Entity_Valid (player->flag_ent)) {
|
2021-07-22 10:35:12 +00:00
|
|
|
CL_UpdateFlagModels (ent, j);
|
[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 fent = player->flag_ent;
|
|
|
|
R_AddEfrags (&cl_world.scene->worldmodel->brush, fent);
|
2021-07-22 10:35:12 +00:00
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
CL_EmitEntities
|
|
|
|
|
|
|
|
Builds the visedicts array for cl.time
|
|
|
|
|
|
|
|
Made up of: clients, packet_entities, nails, and tents
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
CL_EmitEntities (void)
|
|
|
|
{
|
|
|
|
if (cls.state != ca_active)
|
|
|
|
return;
|
|
|
|
if (!cl.validsequence)
|
|
|
|
return;
|
|
|
|
|
2021-03-10 09:00:16 +00:00
|
|
|
TEntContext_t tentCtx = {
|
2022-03-04 16:48:10 +00:00
|
|
|
cl.viewstate.player_origin, cl.viewentity
|
2021-03-10 09:00:16 +00:00
|
|
|
};
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
CL_LinkPlayers ();
|
|
|
|
CL_LinkPacketEntities ();
|
2021-03-10 09:00:16 +00:00
|
|
|
CL_UpdateTEnts (cl.time, &tentCtx);
|
[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_draw_locs) {
|
2022-03-01 02:43:23 +00:00
|
|
|
locs_draw (cl.time, cl.viewstate.player_origin);
|
2004-03-23 22:39:17 +00:00
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CL_Ents_Init (void)
|
|
|
|
{
|
|
|
|
}
|