2011-06-19 11:02:00 +00:00
|
|
|
/*
|
2011-08-27 01:25:41 +00:00
|
|
|
cl_ents.c
|
2011-06-19 11:02:00 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
#include "QF/cbuf.h"
|
|
|
|
#include "QF/cmd.h"
|
|
|
|
#include "QF/console.h"
|
|
|
|
#include "QF/cvar.h"
|
|
|
|
#include "QF/input.h"
|
|
|
|
#include "QF/keys.h"
|
|
|
|
#include "QF/msg.h"
|
2021-03-21 07:13:03 +00:00
|
|
|
#include "QF/plist.h"
|
2011-06-19 11:02:00 +00:00
|
|
|
#include "QF/render.h"
|
|
|
|
#include "QF/screen.h"
|
|
|
|
#include "QF/skin.h"
|
|
|
|
#include "QF/sys.h"
|
|
|
|
#include "QF/va.h"
|
|
|
|
|
2012-02-14 08:28:09 +00:00
|
|
|
#include "QF/plugin/vid_render.h"
|
2021-07-24 05:19:52 +00:00
|
|
|
#include "QF/scene/entity.h"
|
2022-03-04 16:48:10 +00:00
|
|
|
#include "QF/scene/scene.h"
|
2012-02-14 08:28:09 +00:00
|
|
|
|
2011-06-19 11:02:00 +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-10 09:00:16 +00:00
|
|
|
#include "client/temp_entities.h"
|
2022-03-04 16:48:10 +00:00
|
|
|
#include "client/world.h"
|
2021-03-10 09:00:16 +00:00
|
|
|
|
2022-02-22 06:23:09 +00:00
|
|
|
#include "client/chase.h"
|
|
|
|
|
2020-06-21 14:15:17 +00:00
|
|
|
#include "nq/include/client.h"
|
|
|
|
#include "nq/include/host.h"
|
|
|
|
#include "nq/include/host.h"
|
|
|
|
#include "nq/include/server.h"
|
2011-06-19 11:02:00 +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_entities[MAX_EDICTS];
|
2022-03-04 16:48:10 +00:00
|
|
|
double cl_msgtime[MAX_EDICTS];
|
|
|
|
static byte forcelink_bytes[SET_SIZE(MAX_EDICTS)];
|
|
|
|
#define alloc_forcelink(s) (set_bits_t *)forcelink_bytes
|
|
|
|
set_t cl_forcelink = SET_STATIC_INIT (MAX_EDICTS, alloc_forcelink);
|
|
|
|
#undef alloc_forcelink
|
2012-06-26 06:12:17 +00:00
|
|
|
|
2011-06-19 11:02:00 +00:00
|
|
|
void
|
|
|
|
CL_ClearEnts (void)
|
|
|
|
{
|
2011-08-27 01:25:41 +00:00
|
|
|
size_t i;
|
2011-06-19 11:02:00 +00:00
|
|
|
|
2021-03-21 14:05:13 +00:00
|
|
|
for (i = 0; i < MAX_EDICTS; i++) {
|
2023-07-22 07:43:08 +00:00
|
|
|
cl_entities[i] = nullentity;
|
2021-03-21 14:05:13 +00:00
|
|
|
}
|
|
|
|
|
2012-05-21 23:23:22 +00:00
|
|
|
// clear other arrays
|
2012-07-01 02:36:47 +00:00
|
|
|
i = nq_entstates.num_frames * nq_entstates.num_entities;
|
|
|
|
memset (nq_entstates.frame[0], 0, i * sizeof (entity_state_t));
|
2022-10-23 13:43:45 +00:00
|
|
|
memset (cl_msgtime, -1, sizeof (cl_msgtime));
|
2022-03-04 16:48:10 +00:00
|
|
|
set_empty (&cl_forcelink);
|
|
|
|
}
|
|
|
|
|
2022-10-23 13:43:45 +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];
|
2011-06-19 11:02:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
CL_LerpPoint
|
|
|
|
|
2011-08-27 01:25:41 +00:00
|
|
|
Determines the fraction between the last two messages at which the
|
|
|
|
objects should be put.
|
2011-06-19 11:02:00 +00:00
|
|
|
*/
|
|
|
|
static float
|
|
|
|
CL_LerpPoint (void)
|
|
|
|
{
|
|
|
|
float f, frac;
|
|
|
|
|
|
|
|
f = cl.mtime[0] - cl.mtime[1];
|
|
|
|
|
[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 (!f || cl_nolerp || cls.timedemo || sv.active) {
|
2011-06-19 11:02:00 +00:00
|
|
|
cl.time = cl.mtime[0];
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (f > 0.1) { // dropped packet, or start of demo
|
|
|
|
cl.mtime[1] = cl.mtime[0] - 0.1;
|
|
|
|
f = 0.1;
|
|
|
|
}
|
|
|
|
frac = (cl.time - cl.mtime[1]) / f;
|
|
|
|
|
|
|
|
if (frac < 0) {
|
|
|
|
if (frac < -0.01)
|
|
|
|
cl.time = cl.mtime[1];
|
|
|
|
frac = 0;
|
|
|
|
} else if (frac > 1) {
|
|
|
|
if (frac > 1.01)
|
|
|
|
cl.time = cl.mtime[0];
|
|
|
|
frac = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return frac;
|
|
|
|
}
|
|
|
|
|
2012-06-26 06:12:17 +00:00
|
|
|
static void
|
2022-03-04 16:48:10 +00:00
|
|
|
set_entity_model (int ent_ind, int modelindex)
|
2012-06-26 06:12:17 +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 ent = cl_entities[ent_ind];
|
2022-11-13 06:08:18 +00:00
|
|
|
renderer_t *renderer = Ent_GetComponent (ent.id, scene_renderer, ent.reg);
|
|
|
|
animation_t *animation = Ent_GetComponent (ent.id, scene_animation, ent.reg);
|
2022-03-04 16:48:10 +00:00
|
|
|
renderer->model = cl_world.models.a[modelindex];
|
2012-06-26 06:12:17 +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;
|
|
|
|
}
|
2023-08-05 09:09:20 +00:00
|
|
|
renderer->noshadows = renderer->model->shadow_alpha < 0.5;
|
2012-06-26 06:12:17 +00:00
|
|
|
}
|
2022-11-13 06:08:18 +00:00
|
|
|
// Changing the model can change the visibility of the entity and even
|
|
|
|
// the model type
|
|
|
|
SET_ADD (&cl_forcelink, ent_ind);
|
2021-03-09 14:52:40 +00:00
|
|
|
animation->nolerp = 1; // don't try to lerp when the model has changed
|
2022-03-04 16:48:10 +00:00
|
|
|
if (ent_ind <= cl.maxclients) {
|
|
|
|
renderer->skin = mod_funcs->Skin_SetColormap (renderer->skin, ent_ind);
|
2021-03-09 14:52:40 +00:00
|
|
|
}
|
2012-06-26 06:12:17 +00:00
|
|
|
}
|
|
|
|
|
2011-06-19 11:02:00 +00:00
|
|
|
void
|
|
|
|
CL_RelinkEntities (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
|
|
|
entity_t ent;
|
2012-06-26 06:12:17 +00:00
|
|
|
entity_state_t *new, *old;
|
2021-03-19 11:18:45 +00:00
|
|
|
float bobjrotate, frac, f;
|
2011-06-19 11:02:00 +00:00
|
|
|
int i, j;
|
2013-11-27 07:08:30 +00:00
|
|
|
int model_flags;
|
2012-05-21 23:23:22 +00:00
|
|
|
|
|
|
|
// determine partial update time
|
2011-06-19 11:02:00 +00:00
|
|
|
frac = CL_LerpPoint ();
|
|
|
|
|
|
|
|
// interpolate player info
|
2021-03-19 11:18:45 +00:00
|
|
|
cl.viewstate.velocity = cl.frameVelocity[1]
|
2021-03-11 07:19:49 +00:00
|
|
|
+ frac * (cl.frameVelocity[0] - cl.frameVelocity[1]);
|
2011-06-19 11:02:00 +00:00
|
|
|
|
|
|
|
if (cls.demoplayback) {
|
2012-05-21 23:23:22 +00:00
|
|
|
// interpolate the angles
|
2021-03-19 11:18:45 +00:00
|
|
|
vec3_t d;
|
|
|
|
VectorSubtract (cl.frameViewAngles[0], cl.frameViewAngles[1], d);
|
2011-06-19 11:02:00 +00:00
|
|
|
for (j = 0; j < 3; j++) {
|
2021-03-19 11:18:45 +00:00
|
|
|
if (d[j] > 180) {
|
|
|
|
d[j] -= 360;
|
|
|
|
} else if (d[j] < -180) {
|
|
|
|
d[j] += 360;
|
|
|
|
}
|
2011-06-19 11:02:00 +00:00
|
|
|
}
|
2022-03-01 02:43:23 +00:00
|
|
|
VectorMultAdd (cl.frameViewAngles[1], frac, d,
|
|
|
|
cl.viewstate.player_angles);
|
2011-06-19 11:02:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bobjrotate = anglemod (100 * cl.time);
|
|
|
|
|
|
|
|
// start on the entity after the world
|
2012-06-26 06:12:17 +00:00
|
|
|
for (i = 1; i < cl.num_entities; i++) {
|
2021-03-11 07:19:49 +00:00
|
|
|
new = &nq_entstates.frame[0 + cl.frameIndex][i];
|
|
|
|
old = &nq_entstates.frame[1 - cl.frameIndex][i];
|
2021-03-09 14:52:40 +00:00
|
|
|
|
2022-11-13 06:08:18 +00:00
|
|
|
ent = CL_GetInvalidEntity (i);
|
|
|
|
// if the object wasn't included in the last packet, or the model
|
|
|
|
// has been removed, remove the entity
|
|
|
|
if (cl_msgtime[i] != cl.mtime[0] || !new->modelindex) {
|
2022-10-23 13:43:45 +00:00
|
|
|
if (Entity_Valid (ent)) {
|
|
|
|
Scene_DestroyEntity (cl_world.scene, ent);
|
2021-03-09 14:52:40 +00:00
|
|
|
}
|
2011-06-19 11:02:00 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2022-11-13 06:08:18 +00:00
|
|
|
if (!Entity_Valid (ent)) {
|
|
|
|
ent = CL_GetEntity (i);
|
|
|
|
SET_ADD (&cl_forcelink, i);
|
|
|
|
}
|
2022-10-23 13:43:45 +00:00
|
|
|
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);
|
|
|
|
|
2022-03-04 16:48:10 +00:00
|
|
|
if (SET_TEST_MEMBER (&cl_forcelink, i)) {
|
2012-06-26 11:45:47 +00:00
|
|
|
*old = *new;
|
2022-03-04 16:48:10 +00:00
|
|
|
}
|
2012-06-26 11:45:47 +00:00
|
|
|
|
2022-03-04 16:48:10 +00:00
|
|
|
if (SET_TEST_MEMBER (&cl_forcelink, i)
|
|
|
|
|| new->modelindex != old->modelindex) {
|
2012-06-26 06:12:17 +00:00
|
|
|
old->modelindex = new->modelindex;
|
2022-03-04 16:48:10 +00:00
|
|
|
set_entity_model (i, new->modelindex);
|
2012-06-26 06:12:17 +00:00
|
|
|
}
|
2021-03-09 14:52:40 +00:00
|
|
|
animation->frame = new->frame;
|
2022-03-04 16:48:10 +00:00
|
|
|
if (SET_TEST_MEMBER (&cl_forcelink, i)
|
|
|
|
|| new->colormap != old->colormap) {
|
2012-06-28 05:36:05 +00:00
|
|
|
old->colormap = new->colormap;
|
2021-03-09 14:52:40 +00:00
|
|
|
renderer->skin = mod_funcs->Skin_SetColormap (renderer->skin,
|
|
|
|
new->colormap);
|
2012-06-26 06:12:17 +00:00
|
|
|
}
|
2022-03-04 16:48:10 +00:00
|
|
|
if (SET_TEST_MEMBER (&cl_forcelink, i)
|
|
|
|
|| new->skinnum != old->skinnum) {
|
2012-06-26 06:12:17 +00:00
|
|
|
old->skinnum = new->skinnum;
|
2021-03-09 14:52:40 +00:00
|
|
|
renderer->skinnum = new->skinnum;
|
2012-06-26 06:12:17 +00:00
|
|
|
if (i <= cl.maxclients) {
|
2022-11-15 06:21:20 +00:00
|
|
|
colormap_t colormap = {
|
|
|
|
.top = cl.players[i - 1].topcolor,
|
|
|
|
.bottom = cl.players[i - 1].bottomcolor,
|
|
|
|
};
|
|
|
|
Ent_SetComponent (ent.id, scene_colormap, ent.reg, &colormap);
|
2021-03-09 14:52:40 +00:00
|
|
|
renderer->skin = mod_funcs->Skin_SetColormap (renderer->skin,
|
|
|
|
i);
|
2013-02-02 07:54:05 +00:00
|
|
|
mod_funcs->Skin_SetTranslation (i, cl.players[i - 1].topcolor,
|
|
|
|
cl.players[i - 1].bottomcolor);
|
2012-06-26 06:12:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-09 14:52:40 +00:00
|
|
|
VectorCopy (ent_colormod[new->colormod], renderer->colormod);
|
|
|
|
renderer->colormod[3] = ENTALPHA_DECODE (new->alpha);
|
2011-06-19 11:02:00 +00:00
|
|
|
|
2013-11-27 07:08:30 +00:00
|
|
|
model_flags = 0;
|
2021-03-09 14:52:40 +00:00
|
|
|
if (renderer->model) {
|
|
|
|
model_flags = renderer->model->flags;
|
|
|
|
}
|
2011-06-19 11:02:00 +00:00
|
|
|
|
2022-03-04 16:48:10 +00:00
|
|
|
if (SET_TEST_MEMBER (&cl_forcelink, i)) {
|
2011-06-19 11:02:00 +00:00
|
|
|
// The entity was not updated in the last message so move to the
|
|
|
|
// final spot
|
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.0, new->angles,
|
|
|
|
new->origin);
|
2023-08-05 10:58:37 +00:00
|
|
|
if (i != cl.viewentity || chase_active || cl_player_shadows) {
|
2022-05-05 05:41:46 +00:00
|
|
|
R_AddEfrags (&cl_world.scene->worldmodel->brush, ent);
|
2011-06-19 11:02:00 +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 = new->origin;
|
2011-06-19 11:02:00 +00:00
|
|
|
} else {
|
2021-03-19 11:18:45 +00:00
|
|
|
vec4f_t delta = new->origin - old->origin;
|
2011-06-19 11:02:00 +00:00
|
|
|
f = frac;
|
[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 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
|
2011-06-19 11:02:00 +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.0, new->angles,
|
|
|
|
new->origin);
|
2021-03-09 14:52:40 +00:00
|
|
|
animation->pose1 = animation->pose2 = -1;
|
2011-06-19 11:02:00 +00:00
|
|
|
} else {
|
2011-12-13 07:57:45 +00:00
|
|
|
// interpolate the origin and angles
|
2021-03-19 11:18:45 +00:00
|
|
|
vec3_t angles, d;
|
|
|
|
vec4f_t origin = old->origin + f * delta;
|
2013-11-27 07:08:30 +00:00
|
|
|
if (!(model_flags & EF_ROTATE)) {
|
2012-06-26 06:12:17 +00:00
|
|
|
VectorSubtract (new->angles, old->angles, d);
|
2011-12-15 03:06:03 +00:00
|
|
|
for (j = 0; j < 3; j++) {
|
|
|
|
if (d[j] > 180)
|
|
|
|
d[j] -= 360;
|
|
|
|
else if (d[j] < -180)
|
|
|
|
d[j] += 360;
|
|
|
|
}
|
2012-06-26 06:12:17 +00:00
|
|
|
VectorMultAdd (old->angles, f, d, angles);
|
2011-06-19 11:02:00 +00:00
|
|
|
}
|
2021-03-19 11:18:45 +00:00
|
|
|
CL_TransformEntity (ent, new->scale / 16.0, angles, origin);
|
2011-06-19 11:02:00 +00:00
|
|
|
}
|
2023-08-05 10:58:37 +00:00
|
|
|
if (i != cl.viewentity || chase_active || cl_player_shadows) {
|
[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);
|
2011-06-19 11:02:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-08-05 10:58:37 +00:00
|
|
|
renderer->onlyshadows = (cl_player_shadows && i == cl.viewentity
|
|
|
|
&& !chase_active);
|
2011-06-19 11:02:00 +00:00
|
|
|
|
|
|
|
// rotate binary objects locally
|
2013-11-27 07:08:30 +00:00
|
|
|
if (model_flags & EF_ROTATE) {
|
2011-12-15 03:06:03 +00:00
|
|
|
vec3_t angles;
|
2012-06-26 06:12:17 +00:00
|
|
|
VectorCopy (new->angles, angles);
|
2011-12-15 03:06:03 +00:00
|
|
|
angles[YAW] = bobjrotate;
|
2021-03-19 11:18:45 +00:00
|
|
|
CL_TransformEntity (ent, new->scale / 16.0, angles, new->origin);
|
2011-12-15 03:06:03 +00:00
|
|
|
}
|
2023-08-04 05:56:16 +00:00
|
|
|
CL_EntityEffects (ent, new, 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);
|
2022-05-18 02:02:42 +00:00
|
|
|
int effects = new->effects;
|
|
|
|
if (cl.maxclients == 1 && effects) {
|
|
|
|
// Enable blue and red lights for quad and invulnerability,
|
|
|
|
// but only for single-player as such information isn't provided
|
|
|
|
// by the server for other players and thus it would probably be
|
|
|
|
// confusing if the player could see the colored effects but not
|
|
|
|
// for others.
|
|
|
|
int it = cl.stats[STAT_ITEMS];
|
|
|
|
effects |= (it & IT_QUAD)
|
|
|
|
>> (BITOP_LOG2(IT_QUAD) - BITOP_LOG2 (EF_BLUE));
|
|
|
|
effects |= (it & IT_INVULNERABILITY)
|
|
|
|
>> (BITOP_LOG2(IT_INVULNERABILITY) - BITOP_LOG2 (EF_RED));
|
|
|
|
}
|
2023-08-04 05:56:16 +00:00
|
|
|
CL_NewDlight (ent, org, effects, new->glow_size,
|
2021-03-11 02:25:04 +00:00
|
|
|
new->glow_color, cl.time);
|
2021-03-19 11:18:45 +00:00
|
|
|
if (VectorDistance_fast (old->origin, org) > (256 * 256)) {
|
|
|
|
old->origin = org;
|
2011-12-15 03:06:03 +00:00
|
|
|
}
|
2013-11-27 07:08:30 +00:00
|
|
|
if (model_flags & ~EF_ROTATE)
|
2023-08-04 05:56:16 +00:00
|
|
|
CL_ModelEffects (ent, new->glow_color, cl.time);
|
2011-06-19 11:02:00 +00:00
|
|
|
|
2022-03-04 16:48:10 +00:00
|
|
|
SET_REMOVE (&cl_forcelink, i);
|
2011-06-19 11:02:00 +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 player_entity = CL_GetEntity (cl.viewentity);
|
|
|
|
transform_t transform = Entity_Transform (player_entity);
|
|
|
|
cl.viewstate.player_entity = player_entity;
|
|
|
|
cl.viewstate.player_origin = Transform_GetWorldPosition (transform);
|
|
|
|
}
|
2011-06-19 11:02:00 +00:00
|
|
|
}
|