[renderer] Clean up particles a little

The quake-specific enums are now in the client header, and the particle
system now has a gravity field rather than getting it from
vid_render_data (which I hope to eventually get rid of entirely).
This commit is contained in:
Bill Currie 2022-03-29 13:46:11 +09:00
parent ca9e18b9d6
commit 75d7f4cecb
8 changed files with 32 additions and 24 deletions

View file

@ -142,7 +142,6 @@ typedef struct vid_render_data_s {
qboolean paused;
int lineadj;
struct entity_s *view_model;
float gravity;
double frametime;
double realtime;
lightstyle_t *lightstyle;

View file

@ -35,25 +35,6 @@
#include "QF/simd/types.h"
#include "QF/ui/vrect.h"
typedef enum {
pt_static,
pt_grav,
pt_slowgrav,
pt_fire,
pt_explode,
pt_explode2,
pt_blob,
pt_blob2,
pt_smoke,
pt_smokecloud,
pt_bloodcloud,
pt_fadespark,
pt_fadespark2,
pt_fallfade,
pt_fallfadespark,
pt_flame
} ptype_t;
typedef enum {
part_tex_dot,
part_tex_spark,
@ -91,6 +72,7 @@ typedef struct partparm_s {
} partparm_t;
typedef struct psystem_s {
vec4f_t gravity;
uint32_t maxparticles;
uint32_t numparticles;
particle_t *particles;

View file

@ -29,6 +29,25 @@
#include "QF/render.h"
typedef enum {
pt_static,
pt_grav,
pt_slowgrav,
pt_fire,
pt_explode,
pt_explode2,
pt_blob,
pt_blob2,
pt_smoke,
pt_smokecloud,
pt_bloodcloud,
pt_fadespark,
pt_fadespark2,
pt_fallfade,
pt_fallfadespark,
pt_flame
} ptype_t;
typedef struct cl_particle_funcs_s {
void (*RocketTrail) (vec4f_t start, vec4f_t end);
void (*GrenadeTrail) (vec4f_t start, vec4f_t end);
@ -70,6 +89,7 @@ extern float cl_frametime;
extern float cl_realtime;
void CL_Particles_Init (void);
void CL_ParticlesGravity (float gravity);
struct model_s;
void CL_LoadPointFile (const struct model_s *model);

View file

@ -1279,3 +1279,9 @@ CL_Particles_Init (void)
"Sets particle style. 0 for Id, 1 for QF.");
CL_ParticleFunctionInit ();
}
void
CL_ParticlesGravity (float gravity)
{
cl_psystem->gravity = (vec4f_t) { 0, 0, -gravity, 0 };
}

View file

@ -88,7 +88,7 @@ void
R_RunParticles (float dT)
{
psystem_t *ps = &r_psystem;//FIXME
vec4f_t gravity = {0, 0, -r_data->gravity, 0};
vec4f_t gravity = ps->gravity;
unsigned j = 0;
for (unsigned i = 0; i < ps->numparticles; i++) {

View file

@ -55,7 +55,6 @@ vid_render_data_t vid_render_data = {
.paused = false,
.lineadj = 0,
.view_model = 0,
.gravity = 0,
.frametime = 0.0,
.realtime = 0.0,
.lightstyle = 0,

View file

@ -56,6 +56,7 @@
#include "QF/plugin/vid_render.h"
#include "QF/scene/entity.h"
#include "client/particles.h"
#include "client/temp_entities.h"
#include "client/world.h"
@ -378,7 +379,7 @@ CL_ParseServerInfo (void)
Hunk_Check (0); // make sure nothing is hurt
noclip_anglehack = false; // noclip is turned off at start
r_data->gravity = 800.0; // Set up gravity for renderer effects
CL_ParticlesGravity (800); // Set up gravity for renderer effects
done:
S_UnblockSound ();
}

View file

@ -67,6 +67,7 @@
#include "sbar.h"
#include "client/effects.h"
#include "client/particles.h"
#include "client/temp_entities.h"
#include "client/view.h"
#include "client/world.h"
@ -782,7 +783,7 @@ CL_ParseServerData (void)
// get the movevars
movevars.gravity = MSG_ReadFloat (net_message);
r_data->gravity = movevars.gravity; // Gravity for renderer effects
CL_ParticlesGravity (movevars.gravity);// Gravity for renderer effects
movevars.stopspeed = MSG_ReadFloat (net_message);
movevars.maxspeed = MSG_ReadFloat (net_message);
movevars.spectatormaxspeed = MSG_ReadFloat (net_message);