2001-02-19 21:15:25 +00:00
|
|
|
/*
|
2021-03-10 09:00:16 +00:00
|
|
|
cl_temp_entities.c
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2021-03-10 09:00:16 +00:00
|
|
|
Client side temporary entity management
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2021-03-11 02:25:04 +00:00
|
|
|
Copyright (C) 1996-1997 Id Software, Inc.
|
2021-03-10 09:00:16 +00:00
|
|
|
Copyright (C) 2021 Bill Currie <bill@taniwha.org>
|
|
|
|
|
|
|
|
Author: Bill Currie <bill@taniwha.org>
|
|
|
|
Date: 2021/3/10
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
#ifdef HAVE_STRING_H
|
|
|
|
# include <string.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_STRINGS_H
|
|
|
|
# include <strings.h>
|
|
|
|
#endif
|
|
|
|
|
2023-08-04 05:56:16 +00:00
|
|
|
#include "QF/darray.h"
|
2001-05-15 21:34:54 +00:00
|
|
|
#include "QF/msg.h"
|
2021-03-21 14:05:13 +00:00
|
|
|
#include "QF/progs.h" // for PR_RESMAP
|
2021-03-10 09:00:16 +00:00
|
|
|
#include "QF/quakefs.h"
|
|
|
|
#include "QF/render.h"
|
2001-05-15 21:34:54 +00:00
|
|
|
#include "QF/sound.h"
|
|
|
|
|
2021-03-10 09:00:16 +00:00
|
|
|
#include "QF/plugin/vid_render.h" //FIXME
|
[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
|
|
|
//
|
2021-07-24 05:19:52 +00:00
|
|
|
#include "QF/scene/entity.h"
|
2023-08-04 05:56:16 +00:00
|
|
|
#include "QF/scene/light.h"
|
2022-02-14 11:01:36 +00:00
|
|
|
#include "QF/scene/scene.h"
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2021-12-19 04:08:39 +00:00
|
|
|
#include "client/effects.h"
|
2021-03-10 09:00:16 +00:00
|
|
|
#include "client/entities.h"
|
2021-12-19 04:08:39 +00:00
|
|
|
#include "client/particles.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"
|
2020-06-21 14:15:17 +00:00
|
|
|
|
2007-11-05 11:25:38 +00:00
|
|
|
typedef struct tent_s {
|
|
|
|
struct tent_s *next;
|
[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;
|
2007-11-05 11:25:38 +00:00
|
|
|
} tent_t;
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
typedef struct {
|
|
|
|
int entity;
|
|
|
|
struct model_s *model;
|
|
|
|
float endtime;
|
2021-03-19 11:18:45 +00:00
|
|
|
vec4f_t start, end;
|
|
|
|
vec4f_t rotation;
|
2007-11-05 11:25:38 +00:00
|
|
|
tent_t *tents;
|
2001-08-21 05:03:14 +00:00
|
|
|
int seed;
|
2001-02-19 21:15:25 +00:00
|
|
|
} beam_t;
|
|
|
|
|
2011-12-15 03:06:03 +00:00
|
|
|
#define BEAM_SEED_INTERVAL 72
|
|
|
|
#define BEAM_SEED_PRIME 3191
|
2001-05-09 05:41:34 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
typedef struct {
|
|
|
|
float start;
|
2007-11-05 11:25:38 +00:00
|
|
|
tent_t *tent;
|
2001-02-19 21:15:25 +00:00
|
|
|
} explosion_t;
|
|
|
|
|
2007-11-05 22:33:49 +00:00
|
|
|
typedef struct tent_obj_s {
|
|
|
|
struct tent_obj_s *next;
|
|
|
|
union {
|
|
|
|
beam_t beam;
|
|
|
|
explosion_t ex;
|
|
|
|
} to;
|
|
|
|
} tent_obj_t;
|
|
|
|
|
2021-03-21 14:05:13 +00:00
|
|
|
static PR_RESMAP (tent_t) temp_entities;
|
|
|
|
static PR_RESMAP (tent_obj_t) tent_objects;
|
2007-11-05 22:33:49 +00:00
|
|
|
static tent_obj_t *cl_beams;
|
|
|
|
static tent_obj_t *cl_explosions;
|
2021-03-21 14:05:13 +00:00
|
|
|
|
2010-12-01 08:15:28 +00:00
|
|
|
static tent_t *cl_projectiles;
|
2007-11-05 22:33:49 +00:00
|
|
|
|
2010-11-23 01:48:10 +00:00
|
|
|
static sfx_t *cl_sfx_wizhit;
|
|
|
|
static sfx_t *cl_sfx_knighthit;
|
|
|
|
static sfx_t *cl_sfx_tink1;
|
|
|
|
static sfx_t *cl_sfx_r_exp3;
|
2021-03-10 09:00:16 +00:00
|
|
|
static sfx_t *cl_sfx_ric[4];
|
2007-11-05 22:33:49 +00:00
|
|
|
|
2010-11-23 01:48:10 +00:00
|
|
|
static model_t *cl_mod_beam;
|
|
|
|
static model_t *cl_mod_bolt;
|
|
|
|
static model_t *cl_mod_bolt2;
|
|
|
|
static model_t *cl_mod_bolt3;
|
|
|
|
static model_t *cl_spr_explod;
|
2021-03-10 09:00:16 +00:00
|
|
|
static model_t *cl_spike;
|
2001-06-14 17:31:15 +00:00
|
|
|
|
2021-03-19 11:18:45 +00:00
|
|
|
static vec4f_t beam_rolls[360];
|
|
|
|
|
2022-05-13 12:24:45 +00:00
|
|
|
void
|
|
|
|
CL_TEnts_Precache (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
|
|
|
cl_sfx_wizhit = S_PrecacheSound ("wizard/hit.wav");
|
|
|
|
cl_sfx_knighthit = S_PrecacheSound ("hknight/hit.wav");
|
|
|
|
cl_sfx_tink1 = S_PrecacheSound ("weapons/tink1.wav");
|
2021-03-10 09:00:16 +00:00
|
|
|
cl_sfx_ric[3] = S_PrecacheSound ("weapons/ric1.wav");
|
|
|
|
cl_sfx_ric[2] = S_PrecacheSound ("weapons/ric2.wav");
|
|
|
|
cl_sfx_ric[1] = S_PrecacheSound ("weapons/ric3.wav");
|
|
|
|
cl_sfx_ric[0] = cl_sfx_ric[1];
|
2001-02-19 21:15:25 +00:00
|
|
|
cl_sfx_r_exp3 = S_PrecacheSound ("weapons/r_exp3.wav");
|
2001-06-14 17:31:15 +00:00
|
|
|
|
|
|
|
cl_mod_bolt = Mod_ForName ("progs/bolt.mdl", true);
|
|
|
|
cl_mod_bolt2 = Mod_ForName ("progs/bolt2.mdl", true);
|
|
|
|
cl_mod_bolt3 = Mod_ForName ("progs/bolt3.mdl", true);
|
|
|
|
cl_spr_explod = Mod_ForName ("progs/s_explod.spr", true);
|
2002-08-10 02:53:44 +00:00
|
|
|
cl_mod_beam = Mod_ForName ("progs/beam.mdl", false);
|
2021-03-10 09:00:16 +00:00
|
|
|
cl_spike = Mod_ForName ("progs/spike.mdl", false);
|
|
|
|
|
|
|
|
if (!cl_mod_beam) {
|
2002-08-10 02:53:44 +00:00
|
|
|
cl_mod_beam = cl_mod_bolt;
|
2021-03-10 09:00:16 +00:00
|
|
|
}
|
2022-06-06 05:29:14 +00:00
|
|
|
S_SetAmbient (AMBIENT_WATER, S_PrecacheSound ("ambience/water1.wav"));
|
|
|
|
S_SetAmbient (AMBIENT_SKY, S_PrecacheSound ("ambience/wind2.wav"));
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2022-05-13 12:24:45 +00:00
|
|
|
static void
|
2022-06-04 07:06:04 +00:00
|
|
|
cl_tents_precache (int phase, void *data)
|
2022-05-13 12:24:45 +00:00
|
|
|
{
|
|
|
|
if (!phase) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
CL_TEnts_Precache ();
|
|
|
|
}
|
|
|
|
|
2004-02-03 03:01:06 +00:00
|
|
|
void
|
|
|
|
CL_TEnts_Init (void)
|
|
|
|
{
|
2022-06-04 07:06:04 +00:00
|
|
|
QFS_GamedirCallback (cl_tents_precache, 0);
|
2021-03-19 11:18:45 +00:00
|
|
|
for (int i = 0; i < 360; i++) {
|
|
|
|
float ang = i * M_PI / 360;
|
|
|
|
beam_rolls[i] = (vec4f_t) { sin (ang), 0, 0, cos (ang) };
|
|
|
|
}
|
2004-02-03 03:01:06 +00:00
|
|
|
}
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
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_Init_Entity (entity_t ent)
|
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);
|
|
|
|
byte *active = Ent_GetComponent (ent.id, scene_active, cl_world.scene->reg);
|
|
|
|
vec4f_t *old_origin = Ent_GetComponent (ent.id, scene_old_origin, cl_world.scene->reg);
|
|
|
|
memset (animation, 0, sizeof (*animation));
|
|
|
|
memset (renderer, 0, sizeof (*renderer));
|
|
|
|
*active = 1;
|
|
|
|
*old_origin = (vec4f_t) {0, 0, 0, 1};
|
|
|
|
|
|
|
|
renderer->skin = 0;
|
|
|
|
QuatSet (1.0, 1.0, 1.0, 1.0, renderer->colormod);
|
|
|
|
animation->pose1 = animation->pose2 = -1;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2007-11-05 11:25:38 +00:00
|
|
|
static tent_t *
|
|
|
|
new_temp_entity (void)
|
|
|
|
{
|
2021-03-21 14:05:13 +00:00
|
|
|
tent_t *tent = PR_RESNEW_NC (temp_entities);
|
2022-03-04 16:48:10 +00:00
|
|
|
tent->ent = Scene_CreateEntity (cl_world.scene);
|
2007-11-05 11:25:38 +00:00
|
|
|
tent->next = 0;
|
2022-03-04 16:48:10 +00:00
|
|
|
CL_Init_Entity (tent->ent);
|
2007-11-05 11:25:38 +00:00
|
|
|
return tent;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
free_temp_entities (tent_t *tents)
|
|
|
|
{
|
|
|
|
tent_t **t = &tents;
|
|
|
|
|
2021-03-21 14:05:13 +00:00
|
|
|
while (*t) {
|
2022-03-04 16:48:10 +00:00
|
|
|
Scene_DestroyEntity (cl_world.scene, (*t)->ent);//FIXME reuse?
|
2007-11-05 11:25:38 +00:00
|
|
|
t = &(*t)->next;
|
2021-03-21 14:05:13 +00:00
|
|
|
}
|
|
|
|
*t = temp_entities._free;
|
|
|
|
temp_entities._free = tents;
|
2007-11-05 11:25:38 +00:00
|
|
|
}
|
|
|
|
|
2007-11-05 22:33:49 +00:00
|
|
|
static tent_obj_t *
|
|
|
|
new_tent_object (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2021-03-21 14:05:13 +00:00
|
|
|
tent_obj_t *tobj = PR_RESNEW_NC (tent_objects);
|
2007-11-05 22:33:49 +00:00
|
|
|
tobj->next = 0;
|
|
|
|
return tobj;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2007-11-05 22:33:49 +00:00
|
|
|
static void
|
2021-03-21 14:05:13 +00:00
|
|
|
free_tent_object (tent_obj_t *tobj)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2021-03-21 14:05:13 +00:00
|
|
|
tobj->next = tent_objects._free;
|
|
|
|
tent_objects._free = tobj;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2007-11-05 22:33:49 +00:00
|
|
|
void
|
|
|
|
CL_ClearTEnts (void)
|
2002-04-25 04:30:03 +00:00
|
|
|
{
|
2021-03-21 14:05:13 +00:00
|
|
|
PR_RESRESET (temp_entities);
|
|
|
|
PR_RESRESET (tent_objects);
|
2007-11-05 22:33:49 +00:00
|
|
|
cl_beams = 0;
|
2010-12-13 15:19:52 +00:00
|
|
|
cl_explosions = 0;
|
2002-04-25 04:30:03 +00:00
|
|
|
}
|
|
|
|
|
2002-04-27 04:08:30 +00:00
|
|
|
static inline void
|
2002-09-09 20:02:52 +00:00
|
|
|
beam_clear (beam_t *b)
|
2002-04-27 03:22:09 +00:00
|
|
|
{
|
2007-11-05 11:25:38 +00:00
|
|
|
if (b->tents) {
|
|
|
|
free_temp_entities (b->tents);
|
|
|
|
b->tents = 0;
|
2002-04-27 03:22:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-04-27 04:08:30 +00:00
|
|
|
static inline void
|
2023-06-13 09:06:11 +00:00
|
|
|
beam_setup (beam_t *b, bool settransform, double time, TEntContext_t *ctx)
|
2002-04-27 04:08:30 +00:00
|
|
|
{
|
2007-11-05 11:25:38 +00:00
|
|
|
tent_t *tent;
|
2021-03-19 11:18:45 +00:00
|
|
|
float d;
|
2002-04-27 04:08:30 +00:00
|
|
|
int ent_count;
|
2021-03-19 11:18:45 +00:00
|
|
|
vec4f_t dist, org;
|
|
|
|
vec4f_t rotation;
|
|
|
|
vec4f_t scale = { 1, 1, 1, 1 };
|
2011-12-15 03:06:03 +00:00
|
|
|
unsigned seed;
|
2002-04-27 04:08:30 +00:00
|
|
|
|
|
|
|
// calculate pitch and yaw
|
2021-03-19 11:18:45 +00:00
|
|
|
dist = b->end - b->start;
|
2002-04-27 04:08:30 +00:00
|
|
|
|
2021-03-19 11:18:45 +00:00
|
|
|
// FIXME interpolation may be off when passing through the -x axis
|
|
|
|
if (dist[0] < 0 && dist[1] == 0 && dist[2] == 0) {
|
|
|
|
// anti-parallel with the +x axis, so assome 180 degree rotation around
|
|
|
|
// the z-axis
|
|
|
|
rotation = (vec4f_t) { 0, 0, 1, 0 };
|
2002-04-27 04:08:30 +00:00
|
|
|
} else {
|
2021-03-19 11:18:45 +00:00
|
|
|
rotation = qrotf ((vec4f_t) { 1, 0, 0, 0 }, dist);
|
2002-04-27 04:08:30 +00:00
|
|
|
}
|
2021-03-19 11:18:45 +00:00
|
|
|
b->rotation = rotation;
|
2002-04-27 04:08:30 +00:00
|
|
|
|
|
|
|
// add new entities for the lightning
|
2021-03-19 11:18:45 +00:00
|
|
|
org = b->start;
|
|
|
|
d = magnitudef (dist)[0];
|
|
|
|
dist = normalf (dist) * 30;
|
2002-04-27 04:08:30 +00:00
|
|
|
ent_count = ceil (d / 30);
|
|
|
|
d = 0;
|
2011-12-15 03:06:03 +00:00
|
|
|
|
2021-03-10 09:00:16 +00:00
|
|
|
seed = b->seed + ((int) (time * BEAM_SEED_INTERVAL) % BEAM_SEED_INTERVAL);
|
2011-12-15 03:06:03 +00:00
|
|
|
|
2002-04-27 04:08:30 +00:00
|
|
|
while (ent_count--) {
|
2007-11-05 11:25:38 +00:00
|
|
|
tent = new_temp_entity ();
|
|
|
|
tent->next = b->tents;
|
|
|
|
b->tents = tent;
|
|
|
|
|
2021-03-19 11:18:45 +00:00
|
|
|
vec4f_t position = org + d * dist;
|
2002-07-03 05:40:33 +00:00
|
|
|
d += 1.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
|
|
|
transform_t transform = Entity_Transform (tent->ent);
|
|
|
|
renderer_t *renderer = Ent_GetComponent (tent->ent.id, scene_renderer, cl_world.scene->reg);
|
|
|
|
renderer->model = b->model;
|
|
|
|
if (settransform) {
|
2011-12-15 03:06:03 +00:00
|
|
|
seed = seed * BEAM_SEED_PRIME;
|
[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_SetLocalTransform (transform, scale,
|
2021-03-19 11:18:45 +00:00
|
|
|
qmulf (rotation,
|
|
|
|
beam_rolls[seed % 360]),
|
|
|
|
position);
|
|
|
|
} else {
|
[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_SetLocalPosition (transform, position);
|
2011-12-15 03:06:03 +00:00
|
|
|
}
|
2022-05-05 05:41:46 +00:00
|
|
|
R_AddEfrags (&cl_world.scene->worldmodel->brush, tent->ent);
|
2002-04-27 04:08:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2021-03-10 09:00:16 +00:00
|
|
|
CL_ParseBeam (qmsg_t *net_message, model_t *m, double time, TEntContext_t *ctx)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2007-11-05 22:33:49 +00:00
|
|
|
tent_obj_t *to;
|
2001-02-19 21:15:25 +00:00
|
|
|
beam_t *b;
|
2002-04-25 19:04:25 +00:00
|
|
|
int ent;
|
2021-03-21 10:56:17 +00:00
|
|
|
vec4f_t start, end;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
ent = MSG_ReadShort (net_message);
|
|
|
|
|
2022-03-30 15:07:20 +00:00
|
|
|
MSG_ReadCoordV (net_message, (vec_t*)&start);//FIXME
|
|
|
|
MSG_ReadCoordV (net_message, (vec_t*)&end);//FIXME
|
2021-03-21 10:56:17 +00:00
|
|
|
start[3] = end[3] = 1;//FIXME
|
2001-10-25 23:26:33 +00:00
|
|
|
|
2012-07-05 23:29:21 +00:00
|
|
|
to = 0;
|
|
|
|
if (ent) {
|
2021-03-10 09:00:16 +00:00
|
|
|
for (to = cl_beams; to; to = to->next) {
|
|
|
|
if (to->to.beam.entity == ent) {
|
2012-07-05 23:29:21 +00:00
|
|
|
break;
|
2021-03-10 09:00:16 +00:00
|
|
|
}
|
|
|
|
}
|
2012-07-05 23:29:21 +00:00
|
|
|
}
|
|
|
|
if (!to) {
|
|
|
|
to = new_tent_object ();
|
|
|
|
to->next = cl_beams;
|
|
|
|
cl_beams = to;
|
|
|
|
to->to.beam.tents = 0;
|
|
|
|
to->to.beam.entity = ent;
|
|
|
|
}
|
2007-11-05 22:33:49 +00:00
|
|
|
b = &to->to.beam;
|
|
|
|
|
|
|
|
beam_clear (b);
|
|
|
|
b->model = m;
|
2021-03-10 09:00:16 +00:00
|
|
|
b->endtime = time + 0.2;
|
2007-11-05 22:33:49 +00:00
|
|
|
b->seed = rand ();
|
2021-03-21 10:56:17 +00:00
|
|
|
b->end = end;
|
2021-03-10 09:00:16 +00:00
|
|
|
if (b->entity != ctx->playerEntity) {
|
2007-11-05 22:33:49 +00:00
|
|
|
// this will be done in CL_UpdateBeams
|
2021-03-21 10:56:17 +00:00
|
|
|
b->start = start;
|
2021-03-10 09:00:16 +00:00
|
|
|
beam_setup (b, true, time, ctx);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-04 05:56:16 +00:00
|
|
|
typedef struct tempent_s DARRAY_TYPE (entity_t) tempent_t;
|
|
|
|
static tempent_t light_entities = DARRAY_STATIC_INIT (32);
|
|
|
|
|
|
|
|
static void
|
|
|
|
free_stale_entities (void)
|
|
|
|
{
|
|
|
|
size_t i, j;
|
|
|
|
for (i = 0, j = 0; i < light_entities.size; i++) {
|
|
|
|
auto ent = light_entities.a[i];
|
|
|
|
if (Ent_HasComponent (ent.id, scene_dynlight, ent.reg)) {
|
|
|
|
if (j != i) {
|
|
|
|
light_entities.a[j] = ent;
|
|
|
|
}
|
|
|
|
j++;
|
|
|
|
} else {
|
|
|
|
ECS_DelEntity (ent.reg, ent.id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
light_entities.size = j;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
spawn_light (vec4f_t position, vec4f_t color, float radius, float die,
|
|
|
|
float decay)
|
|
|
|
{
|
|
|
|
entity_t ent = {
|
|
|
|
.reg = cl_world.scene->reg,
|
|
|
|
.id = ECS_NewEntity (cl_world.scene->reg),
|
|
|
|
};
|
|
|
|
DARRAY_APPEND (&light_entities, ent);
|
|
|
|
|
|
|
|
Ent_SetComponent (ent.id, scene_dynlight, ent.reg, &(dlight_t) {
|
|
|
|
.origin = position,
|
|
|
|
.color = color,
|
|
|
|
.radius = radius,
|
|
|
|
.die = die,
|
|
|
|
.decay = decay,
|
|
|
|
});
|
|
|
|
Light_LinkLight (cl_world.scene->lights, ent.id);
|
|
|
|
}
|
|
|
|
|
2021-03-10 09:00:16 +00:00
|
|
|
static void
|
|
|
|
parse_tent (qmsg_t *net_message, double time, TEntContext_t *ctx,
|
|
|
|
TE_Effect type)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2007-11-05 22:33:49 +00:00
|
|
|
tent_obj_t *to;
|
2001-02-19 21:15:25 +00:00
|
|
|
explosion_t *ex;
|
2010-11-23 01:48:10 +00:00
|
|
|
int colorStart, colorLength;
|
2023-08-04 05:56:16 +00:00
|
|
|
vec4f_t color;
|
2021-12-18 16:21:39 +00:00
|
|
|
vec4f_t position = {0, 0, 0, 1};
|
2021-03-10 09:00:16 +00:00
|
|
|
int count;
|
|
|
|
const char *name;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
switch (type) {
|
2021-03-10 09:00:16 +00:00
|
|
|
case TE_NoEffect:
|
|
|
|
// invalid mapping, can't do anything
|
2001-02-19 21:15:25 +00:00
|
|
|
break;
|
2021-03-10 09:00:16 +00:00
|
|
|
case TE_Beam:
|
|
|
|
CL_ParseBeam (net_message, cl_mod_beam, time, ctx);
|
2001-02-19 21:15:25 +00:00
|
|
|
break;
|
2021-03-10 09:00:16 +00:00
|
|
|
case TE_Blood:
|
|
|
|
count = MSG_ReadByte (net_message) * 20;
|
2022-03-30 15:07:20 +00:00
|
|
|
MSG_ReadCoordV (net_message, (vec_t*)&position);//FIXME
|
2021-12-19 04:08:39 +00:00
|
|
|
clp_funcs->BloodPuffEffect (position, count);
|
2001-02-19 21:15:25 +00:00
|
|
|
break;
|
2022-12-01 06:59:14 +00:00
|
|
|
case TE_Explosion1:
|
2022-03-30 15:07:20 +00:00
|
|
|
MSG_ReadCoordV (net_message, (vec_t*)&position);//FIXME
|
2001-05-09 05:41:34 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
// sprite
|
2007-11-05 22:33:49 +00:00
|
|
|
to = new_tent_object ();
|
|
|
|
to->next = cl_explosions;
|
|
|
|
cl_explosions = to;
|
|
|
|
ex = &to->to.ex;
|
|
|
|
ex->tent = new_temp_entity ();
|
|
|
|
|
2021-03-10 09:00:16 +00:00
|
|
|
ex->start = time;
|
2004-01-17 07:14:42 +00:00
|
|
|
//FIXME need better model management
|
2021-03-10 09:00:16 +00:00
|
|
|
if (!cl_spr_explod->cache.data) {
|
2004-01-17 07:14:42 +00:00
|
|
|
cl_spr_explod = Mod_ForName ("progs/s_explod.spr", true);
|
2021-03-10 09:00:16 +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 (ex->tent->ent);
|
|
|
|
renderer_t *renderer = Ent_GetComponent (ex->tent->ent.id, scene_renderer, cl_world.scene->reg);
|
|
|
|
renderer->model = cl_spr_explod;
|
|
|
|
Transform_SetLocalPosition (transform, position);
|
2023-08-04 05:56:16 +00:00
|
|
|
color = (vec4f_t) {0.86, 0.31, 0.24, 0.7};
|
2022-12-01 06:59:14 +00:00
|
|
|
goto TE_Explosion_no_sprite;
|
|
|
|
case TE_Explosion:
|
|
|
|
MSG_ReadCoordV (net_message, (vec_t*)&position);//FIXME
|
2023-08-04 05:56:16 +00:00
|
|
|
color = (vec4f_t) {1.0, 0.5, 0.25, 0.7};
|
2022-12-01 06:59:14 +00:00
|
|
|
TE_Explosion_no_sprite:
|
|
|
|
// particles
|
|
|
|
clp_funcs->ParticleExplosion (position);
|
|
|
|
|
2023-08-04 05:56:16 +00:00
|
|
|
spawn_light (position, color, 250, time + 0.5, 300);
|
2022-12-01 06:59:14 +00:00
|
|
|
|
|
|
|
// sound
|
|
|
|
S_StartSound (-1, 0, cl_sfx_r_exp3, position, 1, 1);
|
2001-02-19 21:15:25 +00:00
|
|
|
break;
|
2021-03-10 09:00:16 +00:00
|
|
|
case TE_Explosion2:
|
2022-03-30 15:07:20 +00:00
|
|
|
MSG_ReadCoordV (net_message, (vec_t*)&position);//FIXME
|
2001-11-07 08:24:56 +00:00
|
|
|
colorStart = MSG_ReadByte (net_message);
|
|
|
|
colorLength = MSG_ReadByte (net_message);
|
2022-03-30 14:38:01 +00:00
|
|
|
S_StartSound (-1, 0, cl_sfx_r_exp3, position, 1, 1);
|
2021-12-19 04:08:39 +00:00
|
|
|
clp_funcs->ParticleExplosion2 (position, colorStart, colorLength);
|
2023-08-04 05:56:16 +00:00
|
|
|
|
2003-03-21 21:25:44 +00:00
|
|
|
colorStart = (colorStart + (rand () % colorLength)) * 3;
|
2023-08-04 05:56:16 +00:00
|
|
|
VectorScale (&r_data->vid->palette[colorStart], 1.0 / 255.0, color);
|
|
|
|
color[3] = 0.7;
|
|
|
|
spawn_light (position, color, 350, time + 0.5, 300);
|
2001-05-15 21:34:54 +00:00
|
|
|
break;
|
2021-03-10 09:00:16 +00:00
|
|
|
case TE_Explosion3:
|
2022-03-30 15:07:20 +00:00
|
|
|
MSG_ReadCoordV (net_message, (vec_t*)&position);//FIXME
|
2023-08-04 05:56:16 +00:00
|
|
|
MSG_ReadCoordV (net_message, (vec_t*)&color); //FIXME OUCH!
|
2021-03-10 09:00:16 +00:00
|
|
|
color[3] = 0.7;
|
2021-12-19 04:08:39 +00:00
|
|
|
clp_funcs->ParticleExplosion (position);
|
2022-03-30 14:38:01 +00:00
|
|
|
S_StartSound (-1, 0, cl_sfx_r_exp3, position, 1, 1);
|
2023-08-04 05:56:16 +00:00
|
|
|
|
|
|
|
spawn_light (position, color, 350, time + 0.5, 300);
|
2001-12-11 22:37:30 +00:00
|
|
|
break;
|
2021-03-10 09:00:16 +00:00
|
|
|
case TE_Gunshot1:
|
2022-03-30 15:07:20 +00:00
|
|
|
MSG_ReadCoordV (net_message, (vec_t*)&position);//FIXME
|
2021-12-19 04:08:39 +00:00
|
|
|
clp_funcs->GunshotEffect (position, 20);
|
2001-09-27 00:43:46 +00:00
|
|
|
break;
|
2021-03-10 09:00:16 +00:00
|
|
|
case TE_Gunshot2:
|
|
|
|
count = MSG_ReadByte (net_message) * 20;
|
2022-03-30 15:07:20 +00:00
|
|
|
MSG_ReadCoordV (net_message, (vec_t*)&position);//FIXME
|
2021-12-19 04:08:39 +00:00
|
|
|
clp_funcs->GunshotEffect (position, count);
|
2021-03-10 09:00:16 +00:00
|
|
|
break;
|
|
|
|
case TE_KnightSpike:
|
2022-03-30 15:07:20 +00:00
|
|
|
MSG_ReadCoordV (net_message, (vec_t*)&position);//FIXME
|
2021-12-19 04:08:39 +00:00
|
|
|
clp_funcs->KnightSpikeEffect (position);
|
2022-03-30 14:38:01 +00:00
|
|
|
S_StartSound (-1, 0, cl_sfx_knighthit, position, 1, 1);
|
2021-03-10 09:00:16 +00:00
|
|
|
break;
|
|
|
|
case TE_LavaSplash:
|
2022-03-30 15:07:20 +00:00
|
|
|
MSG_ReadCoordV (net_message, (vec_t*)&position);//FIXME
|
2021-12-19 04:08:39 +00:00
|
|
|
clp_funcs->LavaSplash (position);
|
2021-03-10 09:00:16 +00:00
|
|
|
break;
|
|
|
|
case TE_Lightning1:
|
|
|
|
CL_ParseBeam (net_message, cl_mod_bolt, time, ctx);
|
|
|
|
break;
|
|
|
|
case TE_Lightning2:
|
|
|
|
CL_ParseBeam (net_message, cl_mod_bolt2, time, ctx);
|
|
|
|
break;
|
|
|
|
case TE_Lightning3:
|
|
|
|
CL_ParseBeam (net_message, cl_mod_bolt3, time, ctx);
|
|
|
|
break;
|
|
|
|
case TE_Lightning4:
|
|
|
|
name = MSG_ReadString (net_message);
|
|
|
|
CL_ParseBeam (net_message, Mod_ForName (name, true), time, ctx);
|
|
|
|
break;
|
|
|
|
case TE_LightningBlood:
|
2022-03-30 15:07:20 +00:00
|
|
|
MSG_ReadCoordV (net_message, (vec_t*)&position);//FIXME
|
2001-11-07 08:24:56 +00:00
|
|
|
|
2023-08-04 05:56:16 +00:00
|
|
|
color = (vec4f_t) {0.25, 0.40, 0.65, 1};
|
|
|
|
spawn_light (position, color, 150, time + 0.1, 200);
|
2001-09-27 00:43:46 +00:00
|
|
|
|
2021-12-19 04:08:39 +00:00
|
|
|
clp_funcs->LightningBloodEffect (position);
|
2001-02-19 21:15:25 +00:00
|
|
|
break;
|
2021-03-10 09:00:16 +00:00
|
|
|
case TE_Spike:
|
2022-03-30 15:07:20 +00:00
|
|
|
MSG_ReadCoordV (net_message, (vec_t*)&position);//FIXME
|
2021-12-19 04:08:39 +00:00
|
|
|
clp_funcs->SpikeEffect (position);
|
2021-03-10 09:00:16 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
sfx_t *sound;
|
|
|
|
|
|
|
|
i = (rand () % 20) - 16;
|
|
|
|
if (i >= 0) {
|
|
|
|
sound = cl_sfx_ric[i];
|
|
|
|
} else {
|
|
|
|
sound = cl_sfx_tink1;
|
|
|
|
}
|
2022-03-30 14:38:01 +00:00
|
|
|
S_StartSound (-1, 0, sound, position, 1, 1);
|
2021-03-10 09:00:16 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TE_SuperSpike:
|
2022-03-30 15:07:20 +00:00
|
|
|
MSG_ReadCoordV (net_message, (vec_t*)&position);//FIXME
|
2021-12-19 04:08:39 +00:00
|
|
|
clp_funcs->SuperSpikeEffect (position);
|
2021-03-10 09:00:16 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
sfx_t *sound;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2021-03-10 09:00:16 +00:00
|
|
|
i = (rand () % 20) - 16;
|
|
|
|
if (i >= 0) {
|
|
|
|
sound = cl_sfx_ric[i];
|
|
|
|
} else {
|
|
|
|
sound = cl_sfx_tink1;
|
|
|
|
}
|
2022-03-30 14:38:01 +00:00
|
|
|
S_StartSound (-1, 0, sound, position, 1, 1);
|
2021-03-10 09:00:16 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TE_TarExplosion:
|
2022-03-30 15:07:20 +00:00
|
|
|
MSG_ReadCoordV (net_message, (vec_t*)&position);//FIXME
|
2021-12-19 04:08:39 +00:00
|
|
|
clp_funcs->BlobExplosion (position);
|
2021-03-10 09:00:16 +00:00
|
|
|
|
2022-03-30 14:38:01 +00:00
|
|
|
S_StartSound (-1, 0, cl_sfx_r_exp3, position, 1, 1);
|
2021-03-10 09:00:16 +00:00
|
|
|
break;
|
|
|
|
case TE_Teleport:
|
2022-03-30 15:07:20 +00:00
|
|
|
MSG_ReadCoordV (net_message, (vec_t*)&position);//FIXME
|
2021-12-19 04:08:39 +00:00
|
|
|
clp_funcs->TeleportSplash (position);
|
2021-03-10 09:00:16 +00:00
|
|
|
break;
|
|
|
|
case TE_WizSpike:
|
2022-03-30 15:07:20 +00:00
|
|
|
MSG_ReadCoordV (net_message, (vec_t*)&position);//FIXME
|
2021-12-19 04:08:39 +00:00
|
|
|
clp_funcs->WizSpikeEffect (position);
|
2022-03-30 14:38:01 +00:00
|
|
|
S_StartSound (-1, 0, cl_sfx_wizhit, position, 1, 1);
|
2021-03-10 09:00:16 +00:00
|
|
|
break;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-10 09:00:16 +00:00
|
|
|
// the effect type is a byte so a max of 256 values
|
|
|
|
static const TE_Effect nqEffects[256] = {
|
|
|
|
[TE_nqSpike] = TE_Spike,
|
|
|
|
[TE_nqSuperSpike] = TE_SuperSpike,
|
|
|
|
[TE_nqGunshot] = TE_Gunshot1,
|
|
|
|
[TE_nqExplosion] = TE_Explosion,
|
|
|
|
[TE_nqTarExplosion] = TE_TarExplosion,
|
|
|
|
[TE_nqLightning1] = TE_Lightning1,
|
|
|
|
[TE_nqLightning2] = TE_Lightning2,
|
|
|
|
[TE_nqWizSpike] = TE_WizSpike,
|
|
|
|
[TE_nqKnightSpike] = TE_KnightSpike,
|
|
|
|
[TE_nqLightning3] = TE_Lightning3,
|
|
|
|
[TE_nqLavaSplash] = TE_LavaSplash,
|
|
|
|
[TE_nqTeleport] = TE_Teleport,
|
|
|
|
[TE_nqExplosion2] = TE_Explosion2,
|
|
|
|
[TE_nqBeam] = TE_Beam,
|
|
|
|
[TE_nqExplosion3] = TE_Explosion3,
|
|
|
|
[TE_nqLightning4] = TE_Lightning4,
|
|
|
|
};
|
|
|
|
|
|
|
|
void
|
|
|
|
CL_ParseTEnt_nq (qmsg_t *net_message, double time, TEntContext_t *ctx)
|
|
|
|
{
|
|
|
|
byte type = MSG_ReadByte (net_message);
|
|
|
|
parse_tent (net_message, time, ctx, nqEffects[type]);
|
|
|
|
}
|
|
|
|
|
|
|
|
// the effect type is a byte so a max of 256 values
|
|
|
|
static const TE_Effect qwEffects[256] = {
|
|
|
|
[TE_qwSpike] = TE_Spike,
|
|
|
|
[TE_qwSuperSpike] = TE_SuperSpike,
|
|
|
|
[TE_qwGunshot] = TE_Gunshot2,
|
2022-12-01 06:59:14 +00:00
|
|
|
[TE_qwExplosion] = TE_Explosion1,
|
2021-03-10 09:00:16 +00:00
|
|
|
[TE_qwTarExplosion] = TE_TarExplosion,
|
|
|
|
[TE_qwLightning1] = TE_Lightning1,
|
|
|
|
[TE_qwLightning2] = TE_Lightning2,
|
|
|
|
[TE_qwWizSpike] = TE_WizSpike,
|
|
|
|
[TE_qwKnightSpike] = TE_KnightSpike,
|
|
|
|
[TE_qwLightning3] = TE_Lightning3,
|
|
|
|
[TE_qwLavaSplash] = TE_LavaSplash,
|
|
|
|
[TE_qwTeleport] = TE_Teleport,
|
|
|
|
[TE_qwBlood] = TE_Blood,
|
|
|
|
[TE_qwLightningBlood] = TE_LightningBlood,
|
|
|
|
[TE_qwExplosion2] = TE_Explosion2,
|
|
|
|
[TE_qwBeam] = TE_Beam,
|
|
|
|
};
|
|
|
|
|
|
|
|
void
|
|
|
|
CL_ParseTEnt_qw (qmsg_t *net_message, double time, TEntContext_t *ctx)
|
|
|
|
{
|
|
|
|
byte type = MSG_ReadByte (net_message);
|
|
|
|
parse_tent (net_message, time, ctx, qwEffects[type]);
|
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2021-03-10 09:00:16 +00:00
|
|
|
CL_UpdateBeams (double time, TEntContext_t *ctx)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2007-11-05 22:33:49 +00:00
|
|
|
tent_obj_t **to;
|
2001-02-19 21:15:25 +00:00
|
|
|
beam_t *b;
|
2001-08-21 05:03:14 +00:00
|
|
|
unsigned seed;
|
2007-11-05 11:25:38 +00:00
|
|
|
tent_t *t;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// update lightning
|
2007-11-05 22:33:49 +00:00
|
|
|
for (to = &cl_beams; *to; ) {
|
|
|
|
b = &(*to)->to.beam;
|
2011-06-18 13:22:47 +00:00
|
|
|
if (!b->endtime)
|
|
|
|
continue;
|
2021-03-10 09:00:16 +00:00
|
|
|
if (!b->model || b->endtime < time) {
|
2007-11-05 22:33:49 +00:00
|
|
|
tent_obj_t *_to;
|
2002-10-11 22:13:40 +00:00
|
|
|
b->endtime = 0;
|
2002-09-09 20:02:52 +00:00
|
|
|
beam_clear (b);
|
2007-11-05 22:33:49 +00:00
|
|
|
_to = *to;
|
|
|
|
*to = _to->next;
|
2021-03-21 14:05:13 +00:00
|
|
|
free_tent_object (_to);
|
2001-02-19 21:15:25 +00:00
|
|
|
continue;
|
2002-04-25 04:30:03 +00:00
|
|
|
}
|
2007-11-05 22:33:49 +00:00
|
|
|
to = &(*to)->next;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// if coming from the player, update the start position
|
2021-03-10 09:00:16 +00:00
|
|
|
if (b->entity == ctx->playerEntity) {
|
2002-09-09 20:02:52 +00:00
|
|
|
beam_clear (b);
|
2021-03-21 10:56:17 +00:00
|
|
|
b->start = ctx->simorg;
|
2021-03-10 09:00:16 +00:00
|
|
|
beam_setup (b, false, time, ctx);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2021-03-10 09:00:16 +00:00
|
|
|
seed = b->seed + ((int) (time * BEAM_SEED_INTERVAL) %
|
2001-08-28 23:05:45 +00:00
|
|
|
BEAM_SEED_INTERVAL);
|
2001-08-21 05:03:14 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
// add new entities for the lightning
|
2007-11-05 11:25:38 +00:00
|
|
|
for (t = b->tents; t; t = t->next) {
|
2002-04-27 04:08:30 +00:00
|
|
|
seed = seed * BEAM_SEED_PRIME;
|
[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 (t->ent);
|
|
|
|
Transform_SetLocalRotation (transform,
|
2021-03-19 11:18:45 +00:00
|
|
|
qmulf (b->rotation,
|
|
|
|
beam_rolls[seed % 360]));
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2021-03-10 09:00:16 +00:00
|
|
|
CL_UpdateExplosions (double time, TEntContext_t *ctx)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2010-11-23 01:48:10 +00:00
|
|
|
int f;
|
2007-11-05 22:33:49 +00:00
|
|
|
tent_obj_t **to;
|
2001-08-28 23:05:45 +00:00
|
|
|
explosion_t *ex;
|
[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-02-19 21:15:25 +00:00
|
|
|
|
2007-11-05 22:33:49 +00:00
|
|
|
for (to = &cl_explosions; *to; ) {
|
|
|
|
ex = &(*to)->to.ex;
|
2022-03-04 16:48:10 +00:00
|
|
|
ent = ex->tent->ent;
|
2021-03-10 09:00:16 +00:00
|
|
|
f = 10 * (time - ex->start);
|
[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);
|
|
|
|
if (f >= renderer->model->numframes) {
|
2007-11-05 22:33:49 +00:00
|
|
|
tent_obj_t *_to;
|
2007-11-05 11:25:38 +00:00
|
|
|
free_temp_entities (ex->tent);
|
2007-11-05 22:33:49 +00:00
|
|
|
_to = *to;
|
|
|
|
*to = _to->next;
|
2021-03-21 14:05:13 +00:00
|
|
|
free_tent_object (_to);
|
2001-02-19 21:15:25 +00:00
|
|
|
continue;
|
|
|
|
}
|
2007-11-05 22:33:49 +00:00
|
|
|
to = &(*to)->next;
|
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
|
|
|
animation->frame = f;
|
2022-11-13 06:08:18 +00:00
|
|
|
R_AddEfrags (&cl_world.scene->worldmodel->brush, ent);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2021-03-10 09:00:16 +00:00
|
|
|
CL_UpdateTEnts (double time, TEntContext_t *ctx)
|
|
|
|
{
|
2023-08-04 05:56:16 +00:00
|
|
|
free_stale_entities ();
|
2021-03-10 09:00:16 +00:00
|
|
|
CL_UpdateBeams (time, ctx);
|
|
|
|
CL_UpdateExplosions (time, ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
CL_ParseParticleEffect
|
|
|
|
|
|
|
|
Parse an effect out of the server message
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
CL_ParseParticleEffect (qmsg_t *net_message)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2021-03-10 09:00:16 +00:00
|
|
|
int i, count, color;
|
2021-12-18 16:21:39 +00:00
|
|
|
vec4f_t org = {0, 0, 0, 1}, dir = {};
|
2021-03-10 09:00:16 +00:00
|
|
|
|
2022-03-30 15:07:20 +00:00
|
|
|
MSG_ReadCoordV (net_message, (vec_t*)&org);//FIXME
|
2021-03-10 09:00:16 +00:00
|
|
|
for (i = 0; i < 3; i++)
|
|
|
|
dir[i] = ((signed char) MSG_ReadByte (net_message)) * (15.0 / 16.0);
|
|
|
|
count = MSG_ReadByte (net_message);
|
|
|
|
color = MSG_ReadByte (net_message);
|
|
|
|
|
|
|
|
if (count == 255)
|
2021-12-19 04:08:39 +00:00
|
|
|
clp_funcs->ParticleExplosion (org);
|
2021-03-10 09:00:16 +00:00
|
|
|
else
|
2021-12-19 04:08:39 +00:00
|
|
|
clp_funcs->RunParticleEffect (org, dir, color, count);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2010-12-01 08:15:28 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
CL_ClearProjectiles (void)
|
|
|
|
{
|
|
|
|
free_temp_entities (cl_projectiles);
|
|
|
|
cl_projectiles = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Nails are passed as efficient temporary entities
|
|
|
|
*/
|
|
|
|
void
|
2023-06-13 09:06:11 +00:00
|
|
|
CL_ParseProjectiles (qmsg_t *net_message, bool nail2, TEntContext_t *ctx)
|
2010-12-01 08:15:28 +00:00
|
|
|
{
|
|
|
|
tent_t *tent;
|
|
|
|
tent_t *head = 0, **tail = &head;
|
|
|
|
byte bits[6];
|
|
|
|
int i, c, j, 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 pr;
|
2021-03-19 11:18:45 +00:00
|
|
|
vec4f_t position = { 0, 0, 0, 1 };
|
|
|
|
vec3_t angles;
|
2010-12-01 08:15:28 +00:00
|
|
|
|
|
|
|
c = MSG_ReadByte (net_message);
|
|
|
|
|
|
|
|
for (i = 0; i < c; i++) {
|
|
|
|
if (nail2)
|
|
|
|
num = MSG_ReadByte (net_message);
|
|
|
|
else
|
|
|
|
num = 0;
|
2011-06-19 01:48:02 +00:00
|
|
|
(void) num; //FIXME
|
2010-12-01 08:15:28 +00:00
|
|
|
|
|
|
|
for (j = 0; j < 6; j++)
|
|
|
|
bits[j] = MSG_ReadByte (net_message);
|
|
|
|
|
|
|
|
tent = new_temp_entity ();
|
|
|
|
*tail = tent;
|
|
|
|
tail = &tent->next;
|
|
|
|
|
2022-03-04 16:48:10 +00:00
|
|
|
pr = tent->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
|
|
|
renderer_t *renderer = Ent_GetComponent (pr.id, scene_renderer, cl_world.scene->reg);
|
|
|
|
renderer->model = cl_spike;
|
|
|
|
renderer->skin = 0;
|
2021-03-19 11:18:45 +00:00
|
|
|
position[0] = ((bits[0] + ((bits[1] & 15) << 8)) << 1) - 4096;
|
|
|
|
position[1] = (((bits[1] >> 4) + (bits[2] << 4)) << 1) - 4096;
|
|
|
|
position[2] = ((bits[3] + ((bits[4] & 15) << 8)) << 1) - 4096;
|
|
|
|
angles[0] = (bits[4] >> 4) * (360.0 / 16.0);
|
|
|
|
angles[1] = bits[5] * (360.0 / 256.0);
|
|
|
|
angles[2] = 0;
|
2022-03-04 16:48:10 +00:00
|
|
|
CL_TransformEntity (tent->ent, 1, angles, position);
|
2010-12-01 08:15:28 +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
|
|
|
R_AddEfrags (&cl_world.scene->worldmodel->brush, pr);
|
2010-12-01 08:15:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
*tail = cl_projectiles;
|
|
|
|
cl_projectiles = head;
|
|
|
|
}
|
2023-08-04 16:39:15 +00:00
|
|
|
|
|
|
|
#define c_muzzleflash (effect_system.base + effect_muzzleflash)
|
|
|
|
|
|
|
|
static bool
|
|
|
|
has_muzzleflash (entity_t ent)
|
|
|
|
{
|
|
|
|
return Ent_HasComponent (ent.id, c_muzzleflash, ent.reg);
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint32_t
|
|
|
|
get_muzzleflash (entity_t ent)
|
|
|
|
{
|
|
|
|
return *(uint32_t *) Ent_GetComponent (ent.id, c_muzzleflash, ent.reg);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
set_muzzleflash (entity_t ent, uint32_t light)
|
|
|
|
{
|
|
|
|
Ent_SetComponent (ent.id, c_muzzleflash, ent.reg, &light);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CL_MuzzleFlash (entity_t ent, vec4f_t position, vec4f_t fv, float zoffset,
|
|
|
|
double time)
|
|
|
|
{
|
|
|
|
// spawn a new entity so the light doesn't mess with the owner
|
|
|
|
uint32_t light = nullent;
|
|
|
|
if (has_muzzleflash (ent)) {
|
|
|
|
light = get_muzzleflash (ent);
|
|
|
|
}
|
|
|
|
if (!ECS_EntValid (light, ent.reg)) {
|
|
|
|
light = ECS_NewEntity (ent.reg);
|
|
|
|
set_muzzleflash (ent, light);
|
|
|
|
}
|
|
|
|
DARRAY_APPEND (&light_entities, ((entity_t) {.reg = ent.reg, .id = light}));
|
|
|
|
|
|
|
|
Ent_SetComponent (light, scene_dynlight, ent.reg, &(dlight_t) {
|
|
|
|
.origin = position + 18 * fv + zoffset * (vec4f_t) {0, 0, 1, 0},
|
|
|
|
.color = { 0.2, 0.1, 0.05, 0.7 },
|
|
|
|
.radius = 200 + (rand () & 31),
|
|
|
|
.die = time + 0.1,
|
|
|
|
.minlight = 32,
|
|
|
|
});
|
|
|
|
Light_LinkLight (cl_world.scene->lights, light);
|
|
|
|
}
|