mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-31 05:00:35 +00:00
[renderer] Move particles over to simd
This has the advantage of getting entity_t out of the particle system, and much easier to read math. Also, it served as a nice test for my particle physics shaders (implemented the ideas in C). There's a lot of code that needs merging down: all but the actual drawing can be merged. There's some weirdness with color ramps, but I'll look into that later.
This commit is contained in:
parent
4d1e8b2375
commit
ce4bb1d56c
15 changed files with 2078 additions and 3244 deletions
|
@ -45,38 +45,36 @@ struct mod_sprite_ctx_s;
|
|||
*/
|
||||
|
||||
typedef struct vid_particle_funcs_s {
|
||||
void (*R_RocketTrail) (const struct entity_s *ent);
|
||||
void (*R_GrenadeTrail) (const struct entity_s *ent);
|
||||
void (*R_BloodTrail) (const struct entity_s *ent);
|
||||
void (*R_SlightBloodTrail) (const struct entity_s *ent);
|
||||
void (*R_WizTrail) (const struct entity_s *ent);
|
||||
void (*R_FlameTrail) (const struct entity_s *ent);
|
||||
void (*R_VoorTrail) (const struct entity_s *ent);
|
||||
void (*R_GlowTrail) (const struct entity_s *ent, int glow_color);
|
||||
void (*R_RocketTrail) (vec4f_t start, vec4f_t end);
|
||||
void (*R_GrenadeTrail) (vec4f_t start, vec4f_t end);
|
||||
void (*R_BloodTrail) (vec4f_t start, vec4f_t end);
|
||||
void (*R_SlightBloodTrail) (vec4f_t start, vec4f_t end);
|
||||
void (*R_WizTrail) (vec4f_t start, vec4f_t end);
|
||||
void (*R_FlameTrail) (vec4f_t start, vec4f_t end);
|
||||
void (*R_VoorTrail) (vec4f_t start, vec4f_t end);
|
||||
void (*R_GlowTrail) (vec4f_t start, vec4f_t end, int glow_color);
|
||||
|
||||
void (*R_RunParticleEffect) (const vec3_t org, const vec3_t dir,
|
||||
int color, int count);
|
||||
void (*R_BloodPuffEffect) (const vec3_t org, int count);
|
||||
void (*R_GunshotEffect) (const vec3_t org, int count);
|
||||
void (*R_LightningBloodEffect) (const vec3_t org);
|
||||
void (*R_SpikeEffect) (const vec3_t org);
|
||||
void (*R_KnightSpikeEffect) (const vec3_t org);
|
||||
void (*R_SuperSpikeEffect) (const vec3_t org);
|
||||
void (*R_WizSpikeEffect) (const vec3_t org);
|
||||
void (*R_RunParticleEffect) (vec4f_t org, vec4f_t dir, int color, int count);
|
||||
void (*R_BloodPuffEffect) (vec4f_t org, int count);
|
||||
void (*R_GunshotEffect) (vec4f_t org, int count);
|
||||
void (*R_LightningBloodEffect) (vec4f_t org);
|
||||
void (*R_SpikeEffect) (vec4f_t org);
|
||||
void (*R_KnightSpikeEffect) (vec4f_t org);
|
||||
void (*R_SuperSpikeEffect) (vec4f_t org);
|
||||
void (*R_WizSpikeEffect) (vec4f_t org);
|
||||
|
||||
void (*R_BlobExplosion) (const vec3_t org);
|
||||
void (*R_ParticleExplosion) (const vec3_t org);
|
||||
void (*R_ParticleExplosion2) (const vec3_t org, int colorStart,
|
||||
int colorLength);
|
||||
void (*R_LavaSplash) (const vec3_t org);
|
||||
void (*R_TeleportSplash) (const vec3_t org);
|
||||
void (*R_DarkFieldParticles) (const struct entity_s *ent);
|
||||
void (*R_EntityParticles) (const struct entity_s *ent);
|
||||
void (*R_BlobExplosion) (vec4f_t org);
|
||||
void (*R_ParticleExplosion) (vec4f_t org);
|
||||
void (*R_ParticleExplosion2) (vec4f_t org, int colorStart, int colorLength);
|
||||
void (*R_LavaSplash) (vec4f_t org);
|
||||
void (*R_TeleportSplash) (vec4f_t org);
|
||||
void (*R_DarkFieldParticles) (vec4f_t org);
|
||||
void (*R_EntityParticles) (vec4f_t org);
|
||||
|
||||
void (*R_Particle_New) (ptype_t type, int texnum, const vec3_t org,
|
||||
float scale, const vec3_t vel, float die,
|
||||
void (*R_Particle_New) (ptype_t type, int texnum, vec4f_t org,
|
||||
float scale, vec4f_t vel, float die,
|
||||
int color, float alpha, float ramp);
|
||||
void (*R_Particle_NewRandom) (ptype_t type, int texnum, const vec3_t org,
|
||||
void (*R_Particle_NewRandom) (ptype_t type, int texnum, vec4f_t org,
|
||||
int org_fuzz, float scale, int vel_fuzz,
|
||||
float die, int color, float alpha,
|
||||
float ramp);
|
||||
|
|
|
@ -63,28 +63,38 @@ typedef enum {
|
|||
} ptextype_t;
|
||||
|
||||
typedef struct particle_s particle_t;
|
||||
typedef void (*pt_phys_func)(particle_t *);
|
||||
|
||||
pt_phys_func R_ParticlePhysics (ptype_t type) __attribute__((pure));
|
||||
|
||||
// !!! if this is changed, it must be changed in d_ifacea.h too !!!
|
||||
struct particle_s
|
||||
{
|
||||
// driver-usable fields
|
||||
vec3_t org;
|
||||
int color;
|
||||
float alpha;
|
||||
struct particle_s {
|
||||
vec4f_t pos;
|
||||
vec4f_t vel;
|
||||
|
||||
union {
|
||||
struct {
|
||||
int icolor;
|
||||
int pad[2];
|
||||
float alpha;
|
||||
};
|
||||
vec4f_t color;
|
||||
};
|
||||
|
||||
ptextype_t tex;
|
||||
float scale;
|
||||
// drivers never touch the following fields
|
||||
vec3_t vel;
|
||||
ptype_t type;
|
||||
float die;
|
||||
float ramp;
|
||||
pt_phys_func phys;
|
||||
particle_t *next;
|
||||
float scale;
|
||||
float live;
|
||||
};
|
||||
|
||||
typedef struct partparm_s {
|
||||
vec4f_t drag; // drag[3] is grav scale
|
||||
float ramp;
|
||||
float ramp_max;
|
||||
float scale_rate;
|
||||
float alpha_rate;
|
||||
} partparm_t;
|
||||
|
||||
partparm_t R_ParticlePhysics (ptype_t type) __attribute__((pure));
|
||||
const int *R_ParticleRamp (ptype_t type) __attribute__((pure));
|
||||
|
||||
#define PARTICLE_Z_CLIP 8.0
|
||||
|
||||
typedef struct polyvert_s {
|
||||
|
|
|
@ -50,19 +50,15 @@
|
|||
|
||||
// particle_t structure
|
||||
// !!! if this is changed, it must be changed in d_iface.h too !!!
|
||||
// driver-usable fields
|
||||
#define pt_org 0
|
||||
#define pt_color 12
|
||||
#define pt_alpha 16
|
||||
#define pt_tex 20
|
||||
#define pt_scale 24
|
||||
// drivers never touch the following fields
|
||||
#define pt_vel 28
|
||||
#define pt_type 40
|
||||
#define pt_die 44
|
||||
#define pt_ramp 48
|
||||
#define pt_next 52
|
||||
#define pt_size 56
|
||||
#define pt_pos 0
|
||||
#define pt_vel 16
|
||||
#define pt_color 32
|
||||
#define pt_alpha 44
|
||||
#define pt_tex 48
|
||||
#define pt_ramp 52
|
||||
#define pt_scale 56
|
||||
#define pt_live 60
|
||||
#define pt_size 64
|
||||
|
||||
#define PARTICLE_Z_CLIP 8.0
|
||||
|
||||
|
|
|
@ -61,9 +61,8 @@ void R_InitSprites (void);
|
|||
|
||||
extern unsigned int r_maxparticles;
|
||||
extern unsigned int numparticles;
|
||||
extern struct particle_s *active_particles;
|
||||
extern struct particle_s *free_particles;
|
||||
extern struct particle_s *particles;
|
||||
extern struct particle_s **freeparticles;
|
||||
extern struct partparm_s *partparams;
|
||||
extern const int **partramps;
|
||||
|
||||
#endif // _R_DYNAMIC_H
|
||||
|
|
|
@ -118,35 +118,37 @@ CL_ModelEffects (entity_t *ent, int num, int glow_color, double time)
|
|||
{
|
||||
dlight_t *dl;
|
||||
model_t *model = ent->renderer.model;
|
||||
vec4f_t old_origin = ent->old_origin;
|
||||
vec4f_t ent_origin = Transform_GetWorldPosition (ent->transform);
|
||||
|
||||
// add automatic particle trails
|
||||
if (model->flags & EF_ROCKET) {
|
||||
dl = r_funcs->R_AllocDlight (num);
|
||||
if (dl) {
|
||||
VectorCopy (Transform_GetWorldPosition (ent->transform),
|
||||
dl->origin);
|
||||
VectorCopy (ent_origin, dl->origin);
|
||||
dl->radius = 200.0;
|
||||
dl->die = time + 0.1;
|
||||
//FIXME VectorCopy (r_firecolor->vec, dl->color);
|
||||
VectorSet (0.9, 0.7, 0.0, dl->color);
|
||||
dl->color[3] = 0.7;
|
||||
}
|
||||
r_funcs->particles->R_RocketTrail (ent);
|
||||
r_funcs->particles->R_RocketTrail (old_origin, ent_origin);
|
||||
} else if (model->flags & EF_GRENADE)
|
||||
r_funcs->particles->R_GrenadeTrail (ent);
|
||||
r_funcs->particles->R_GrenadeTrail (old_origin, ent_origin);
|
||||
else if (model->flags & EF_GIB)
|
||||
r_funcs->particles->R_BloodTrail (ent);
|
||||
r_funcs->particles->R_BloodTrail (old_origin, ent_origin);
|
||||
else if (model->flags & EF_ZOMGIB)
|
||||
r_funcs->particles->R_SlightBloodTrail (ent);
|
||||
r_funcs->particles->R_SlightBloodTrail (old_origin, ent_origin);
|
||||
else if (model->flags & EF_TRACER)
|
||||
r_funcs->particles->R_WizTrail (ent);
|
||||
r_funcs->particles->R_WizTrail (old_origin, ent_origin);
|
||||
else if (model->flags & EF_TRACER2)
|
||||
r_funcs->particles->R_FlameTrail (ent);
|
||||
r_funcs->particles->R_FlameTrail (old_origin, ent_origin);
|
||||
else if (model->flags & EF_TRACER3)
|
||||
r_funcs->particles->R_VoorTrail (ent);
|
||||
r_funcs->particles->R_VoorTrail (old_origin, ent_origin);
|
||||
else if (model->flags & EF_GLOWTRAIL)
|
||||
if (r_funcs->particles->R_GlowTrail)
|
||||
r_funcs->particles->R_GlowTrail (ent, glow_color);
|
||||
r_funcs->particles->R_GlowTrail (old_origin, ent_origin,
|
||||
glow_color);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -171,10 +173,10 @@ CL_MuzzleFlash (vec4f_t position, vec4f_t fv, float zoffset, int num,
|
|||
void
|
||||
CL_EntityEffects (int num, entity_t *ent, entity_state_t *state, double time)
|
||||
{
|
||||
vec4f_t position = Transform_GetWorldPosition (ent->transform);
|
||||
if (state->effects & EF_BRIGHTFIELD)
|
||||
r_funcs->particles->R_EntityParticles (ent);
|
||||
r_funcs->particles->R_EntityParticles (position);
|
||||
if (state->effects & EF_MUZZLEFLASH) {
|
||||
vec4f_t position = Transform_GetWorldPosition (ent->transform);
|
||||
vec4f_t fv = Transform_Forward (ent->transform);
|
||||
CL_MuzzleFlash (position, fv, 16, num, time);
|
||||
}
|
||||
|
|
|
@ -323,7 +323,7 @@ parse_tent (qmsg_t *net_message, double time, TEntContext_t *ctx,
|
|||
explosion_t *ex;
|
||||
int colorStart, colorLength;
|
||||
quat_t color;
|
||||
vec3_t position;
|
||||
vec4f_t position = {0, 0, 0, 1};
|
||||
int count;
|
||||
const char *name;
|
||||
|
||||
|
@ -336,11 +336,11 @@ parse_tent (qmsg_t *net_message, double time, TEntContext_t *ctx,
|
|||
break;
|
||||
case TE_Blood:
|
||||
count = MSG_ReadByte (net_message) * 20;
|
||||
MSG_ReadCoordV (net_message, position);
|
||||
MSG_ReadCoordV (net_message, &position[0]);
|
||||
r_funcs->particles->R_BloodPuffEffect (position, count);
|
||||
break;
|
||||
case TE_Explosion:
|
||||
MSG_ReadCoordV (net_message, position);
|
||||
MSG_ReadCoordV (net_message, &position[0]);
|
||||
|
||||
// particles
|
||||
r_funcs->particles->R_ParticleExplosion (position);
|
||||
|
@ -357,7 +357,7 @@ parse_tent (qmsg_t *net_message, double time, TEntContext_t *ctx,
|
|||
}
|
||||
|
||||
// sound
|
||||
S_StartSound (-1, 0, cl_sfx_r_exp3, position, 1, 1);
|
||||
S_StartSound (-1, 0, cl_sfx_r_exp3, &position[0], 1, 1);
|
||||
|
||||
// sprite
|
||||
to = new_tent_object ();
|
||||
|
@ -376,10 +376,10 @@ parse_tent (qmsg_t *net_message, double time, TEntContext_t *ctx,
|
|||
(vec4f_t) {VectorExpand (position), 1});
|
||||
break;
|
||||
case TE_Explosion2:
|
||||
MSG_ReadCoordV (net_message, position);
|
||||
MSG_ReadCoordV (net_message, &position[0]);
|
||||
colorStart = MSG_ReadByte (net_message);
|
||||
colorLength = MSG_ReadByte (net_message);
|
||||
S_StartSound (-1, 0, cl_sfx_r_exp3, position, 1, 1);
|
||||
S_StartSound (-1, 0, cl_sfx_r_exp3, &position[0], 1, 1);
|
||||
r_funcs->particles->R_ParticleExplosion2 (position, colorStart,
|
||||
colorLength);
|
||||
dl = r_funcs->R_AllocDlight (0);
|
||||
|
@ -395,11 +395,11 @@ parse_tent (qmsg_t *net_message, double time, TEntContext_t *ctx,
|
|||
dl->color[3] = 0.7;
|
||||
break;
|
||||
case TE_Explosion3:
|
||||
MSG_ReadCoordV (net_message, position);
|
||||
MSG_ReadCoordV (net_message, &position[0]);
|
||||
MSG_ReadCoordV (net_message, color); // OUCH!
|
||||
color[3] = 0.7;
|
||||
r_funcs->particles->R_ParticleExplosion (position);
|
||||
S_StartSound (-1, 0, cl_sfx_r_exp3, position, 1, 1);
|
||||
S_StartSound (-1, 0, cl_sfx_r_exp3, &position[0], 1, 1);
|
||||
dl = r_funcs->R_AllocDlight (0);
|
||||
if (dl) {
|
||||
VectorCopy (position, dl->origin);
|
||||
|
@ -410,21 +410,21 @@ parse_tent (qmsg_t *net_message, double time, TEntContext_t *ctx,
|
|||
}
|
||||
break;
|
||||
case TE_Gunshot1:
|
||||
MSG_ReadCoordV (net_message, position);
|
||||
MSG_ReadCoordV (net_message, &position[0]);
|
||||
r_funcs->particles->R_GunshotEffect (position, 20);
|
||||
break;
|
||||
case TE_Gunshot2:
|
||||
count = MSG_ReadByte (net_message) * 20;
|
||||
MSG_ReadCoordV (net_message, position);
|
||||
MSG_ReadCoordV (net_message, &position[0]);
|
||||
r_funcs->particles->R_GunshotEffect (position, count);
|
||||
break;
|
||||
case TE_KnightSpike:
|
||||
MSG_ReadCoordV (net_message, position);
|
||||
MSG_ReadCoordV (net_message, &position[0]);
|
||||
r_funcs->particles->R_KnightSpikeEffect (position);
|
||||
S_StartSound (-1, 0, cl_sfx_knighthit, position, 1, 1);
|
||||
S_StartSound (-1, 0, cl_sfx_knighthit, &position[0], 1, 1);
|
||||
break;
|
||||
case TE_LavaSplash:
|
||||
MSG_ReadCoordV (net_message, position);
|
||||
MSG_ReadCoordV (net_message, &position[0]);
|
||||
r_funcs->particles->R_LavaSplash (position);
|
||||
break;
|
||||
case TE_Lightning1:
|
||||
|
@ -441,7 +441,7 @@ parse_tent (qmsg_t *net_message, double time, TEntContext_t *ctx,
|
|||
CL_ParseBeam (net_message, Mod_ForName (name, true), time, ctx);
|
||||
break;
|
||||
case TE_LightningBlood:
|
||||
MSG_ReadCoordV (net_message, position);
|
||||
MSG_ReadCoordV (net_message, &position[0]);
|
||||
|
||||
// light
|
||||
dl = r_funcs->R_AllocDlight (0);
|
||||
|
@ -456,7 +456,7 @@ parse_tent (qmsg_t *net_message, double time, TEntContext_t *ctx,
|
|||
r_funcs->particles->R_LightningBloodEffect (position);
|
||||
break;
|
||||
case TE_Spike:
|
||||
MSG_ReadCoordV (net_message, position);
|
||||
MSG_ReadCoordV (net_message, &position[0]);
|
||||
r_funcs->particles->R_SpikeEffect (position);
|
||||
{
|
||||
int i;
|
||||
|
@ -468,11 +468,11 @@ parse_tent (qmsg_t *net_message, double time, TEntContext_t *ctx,
|
|||
} else {
|
||||
sound = cl_sfx_tink1;
|
||||
}
|
||||
S_StartSound (-1, 0, sound, position, 1, 1);
|
||||
S_StartSound (-1, 0, sound, &position[0], 1, 1);
|
||||
}
|
||||
break;
|
||||
case TE_SuperSpike:
|
||||
MSG_ReadCoordV (net_message, position);
|
||||
MSG_ReadCoordV (net_message, &position[0]);
|
||||
r_funcs->particles->R_SuperSpikeEffect (position);
|
||||
{
|
||||
int i;
|
||||
|
@ -484,23 +484,23 @@ parse_tent (qmsg_t *net_message, double time, TEntContext_t *ctx,
|
|||
} else {
|
||||
sound = cl_sfx_tink1;
|
||||
}
|
||||
S_StartSound (-1, 0, sound, position, 1, 1);
|
||||
S_StartSound (-1, 0, sound, &position[0], 1, 1);
|
||||
}
|
||||
break;
|
||||
case TE_TarExplosion:
|
||||
MSG_ReadCoordV (net_message, position);
|
||||
MSG_ReadCoordV (net_message, &position[0]);
|
||||
r_funcs->particles->R_BlobExplosion (position);
|
||||
|
||||
S_StartSound (-1, 0, cl_sfx_r_exp3, position, 1, 1);
|
||||
S_StartSound (-1, 0, cl_sfx_r_exp3, &position[0], 1, 1);
|
||||
break;
|
||||
case TE_Teleport:
|
||||
MSG_ReadCoordV (net_message, position);
|
||||
MSG_ReadCoordV (net_message, &position[0]);
|
||||
r_funcs->particles->R_TeleportSplash (position);
|
||||
break;
|
||||
case TE_WizSpike:
|
||||
MSG_ReadCoordV (net_message, position);
|
||||
MSG_ReadCoordV (net_message, &position[0]);
|
||||
r_funcs->particles->R_WizSpikeEffect (position);
|
||||
S_StartSound (-1, 0, cl_sfx_wizhit, position, 1, 1);
|
||||
S_StartSound (-1, 0, cl_sfx_wizhit, &position[0], 1, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -650,9 +650,9 @@ void
|
|||
CL_ParseParticleEffect (qmsg_t *net_message)
|
||||
{
|
||||
int i, count, color;
|
||||
vec3_t org, dir;
|
||||
vec4f_t org = {0, 0, 0, 1}, dir = {};
|
||||
|
||||
MSG_ReadCoordV (net_message, org);
|
||||
MSG_ReadCoordV (net_message, &org[0]);
|
||||
for (i = 0; i < 3; i++)
|
||||
dir[i] = ((signed char) MSG_ReadByte (net_message)) * (15.0 / 16.0);
|
||||
count = MSG_ReadByte (net_message);
|
||||
|
|
|
@ -291,6 +291,7 @@ locs_draw (vec4f_t simorg)
|
|||
dlight_t *dl;
|
||||
location_t *nearloc;
|
||||
vec4f_t trueloc;
|
||||
vec4f_t zero = {};
|
||||
int i;
|
||||
|
||||
nearloc = locs_find (simorg);
|
||||
|
@ -307,12 +308,12 @@ locs_draw (vec4f_t simorg)
|
|||
}
|
||||
trueloc = nearloc->loc;
|
||||
r_funcs->particles->R_Particle_New (pt_smokecloud, part_tex_smoke,
|
||||
&trueloc[0], 2.0,//FIXME
|
||||
vec3_origin, r_data->realtime + 9.0, 254,
|
||||
trueloc, 2.0,
|
||||
zero, r_data->realtime + 9.0, 254,
|
||||
0.25 + qfrandom (0.125), 0.0);
|
||||
for (i = 0; i < 15; i++)
|
||||
r_funcs->particles->R_Particle_NewRandom (pt_fallfade,
|
||||
part_tex_dot, &trueloc[0], 12,//FIXME
|
||||
part_tex_dot, trueloc, 12,
|
||||
0.7, 96, r_data->realtime + 5.0,
|
||||
104 + (rand () & 7), 1.0, 0.0);
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -36,9 +36,11 @@
|
|||
#include "compat.h"
|
||||
#include "r_internal.h"
|
||||
|
||||
unsigned int r_maxparticles, numparticles;
|
||||
particle_t *active_particles, *free_particles, *particles, **freeparticles;
|
||||
vec3_t r_pright, r_pup, r_ppn;
|
||||
unsigned int r_maxparticles, numparticles;
|
||||
particle_t *particles;
|
||||
partparm_t *partparams;
|
||||
const int **partramps;
|
||||
vec3_t r_pright, r_pup, r_ppn;
|
||||
|
||||
/*
|
||||
R_MaxParticlesCheck
|
||||
|
@ -50,34 +52,30 @@ vec3_t r_pright, r_pup, r_ppn;
|
|||
void
|
||||
R_MaxParticlesCheck (cvar_t *r_particles, cvar_t *r_particles_max)
|
||||
{
|
||||
/*
|
||||
Catchall. If the user changed the setting to a number less than zero *or*
|
||||
if we had a wacky cfg get past the init code check, this will make sure we
|
||||
don't have problems. Also note that grabbing the var->int_val is IMPORTANT:
|
||||
Prevents a segfault since if we grabbed the int_val of r_particles_max
|
||||
we'd sig11 right here at startup.
|
||||
*/
|
||||
if (r_particles && r_particles->int_val)
|
||||
r_maxparticles = r_particles_max ? r_particles_max->int_val : 0;
|
||||
else
|
||||
r_maxparticles = 0;
|
||||
unsigned maxparticles = 0;
|
||||
if (r_particles && r_particles->int_val) {
|
||||
maxparticles = r_particles_max ? r_particles_max->int_val : 0;
|
||||
}
|
||||
|
||||
/*
|
||||
Be very careful the next time we do something like this. calloc/free are
|
||||
IMPORTANT and the compiler doesn't know when we do bad things with them.
|
||||
*/
|
||||
if (particles)
|
||||
free (particles);
|
||||
if (freeparticles)
|
||||
free (freeparticles);
|
||||
if (r_maxparticles == maxparticles) {
|
||||
return;
|
||||
}
|
||||
|
||||
particles = 0;
|
||||
freeparticles = 0;
|
||||
size_t size = sizeof (particle_t) + sizeof (partparm_t)
|
||||
+ sizeof (int *);
|
||||
|
||||
if (particles) {
|
||||
Sys_Free (particles, r_maxparticles * size);
|
||||
particles = 0;
|
||||
partparams = 0;
|
||||
partramps = 0;
|
||||
}
|
||||
r_maxparticles = maxparticles;
|
||||
|
||||
if (r_maxparticles) {
|
||||
particles = (particle_t *) calloc (r_maxparticles, sizeof (particle_t));
|
||||
freeparticles = (particle_t **) calloc (r_maxparticles,
|
||||
sizeof (particle_t *));
|
||||
particles = Sys_Alloc (r_maxparticles * size);
|
||||
partparams = (partparm_t *) &particles[r_maxparticles];
|
||||
partramps = (const int **) &partparams[r_maxparticles];
|
||||
}
|
||||
|
||||
vr_funcs->R_ClearParticles ();
|
||||
|
@ -86,226 +84,53 @@ R_MaxParticlesCheck (cvar_t *r_particles, cvar_t *r_particles_max)
|
|||
vr_funcs->R_InitParticles ();
|
||||
}
|
||||
|
||||
static int ramp1[8] = { 0x6f, 0x6d, 0x6b, 0x69, 0x67, 0x65, 0x63, 0x61 };
|
||||
static int ramp2[8] = { 0x6f, 0x6e, 0x6d, 0x6c, 0x6b, 0x6a, 0x68, 0x66 };
|
||||
static int ramp3[8] = { 0x6d, 0x6b, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01 };
|
||||
|
||||
static inline float
|
||||
slow_grav (void)
|
||||
{
|
||||
return -vr_data.frametime * vr_data.gravity * 0.0375;
|
||||
}
|
||||
|
||||
static inline float
|
||||
grav (void)
|
||||
{
|
||||
return -vr_data.frametime * vr_data.gravity * 0.05;
|
||||
}
|
||||
|
||||
static inline float
|
||||
fast_grav (void)
|
||||
{
|
||||
return -vr_data.frametime * vr_data.gravity;
|
||||
}
|
||||
|
||||
static inline void
|
||||
add_vel (particle_t *part)
|
||||
{
|
||||
VectorMultAdd (part->org, vr_data.frametime, part->vel, part->org);
|
||||
}
|
||||
|
||||
static inline void
|
||||
sub_slowgrav (particle_t *part)
|
||||
{
|
||||
part->vel[2] -= slow_grav ();
|
||||
}
|
||||
|
||||
static inline void
|
||||
add_grav (particle_t *part)
|
||||
{
|
||||
part->vel[2] += grav ();
|
||||
}
|
||||
|
||||
static inline void
|
||||
sub_grav (particle_t *part)
|
||||
{
|
||||
part->vel[2] -= grav ();
|
||||
}
|
||||
|
||||
static inline void
|
||||
add_fastgrav (particle_t *part)
|
||||
{
|
||||
part->vel[2] += fast_grav ();
|
||||
}
|
||||
|
||||
static inline qboolean
|
||||
add_ramp (particle_t *part, float time, int max)
|
||||
{
|
||||
part->ramp += vr_data.frametime * time;
|
||||
if (part->ramp >= max) {
|
||||
part->die = -1;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline qboolean
|
||||
fade_alpha (particle_t *part, float time)
|
||||
{
|
||||
part->alpha -= vr_data.frametime * time;
|
||||
if (part->alpha <= 0.0) {
|
||||
part->die = -1;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static void
|
||||
part_phys_static (particle_t *part)
|
||||
{
|
||||
add_vel (part);
|
||||
}
|
||||
|
||||
static void
|
||||
part_phys_grav (particle_t *part)
|
||||
{
|
||||
add_vel (part);
|
||||
add_grav (part);
|
||||
}
|
||||
|
||||
static void
|
||||
part_phys_fire (particle_t *part)
|
||||
{
|
||||
if (add_ramp (part, 5.0, 6))
|
||||
return;
|
||||
add_vel (part);
|
||||
part->color = ramp3[(int) part->ramp];
|
||||
part->alpha = (6.0 - part->ramp) / 6.0;
|
||||
sub_grav (part);
|
||||
}
|
||||
|
||||
static void
|
||||
part_phys_explode (particle_t *part)
|
||||
{
|
||||
if (add_ramp (part, 10.0, 8))
|
||||
return;
|
||||
add_vel (part);
|
||||
part->color = ramp1[(int) part->ramp];
|
||||
VectorMultAdd (part->vel, vr_data.frametime * 4.0, part->vel, part->vel);
|
||||
add_grav (part);
|
||||
}
|
||||
|
||||
static void
|
||||
part_phys_explode2 (particle_t *part)
|
||||
{
|
||||
if (add_ramp (part, 15.0, 8))
|
||||
return;
|
||||
add_vel (part);
|
||||
part->color = ramp2[(int) part->ramp];
|
||||
VectorMultAdd (part->vel, vr_data.frametime, part->vel, part->vel);
|
||||
add_grav (part);
|
||||
}
|
||||
|
||||
static void
|
||||
part_phys_blob (particle_t *part)
|
||||
{
|
||||
add_vel (part);
|
||||
VectorMultAdd (part->vel, vr_data.frametime * 4.0, part->vel, part->vel);
|
||||
add_grav (part);
|
||||
}
|
||||
|
||||
static void
|
||||
part_phys_blob2 (particle_t *part)
|
||||
{
|
||||
add_vel (part);
|
||||
part->vel[0] -= part->vel[0] * vr_data.frametime * 4.0;
|
||||
part->vel[1] -= part->vel[1] * vr_data.frametime * 4.0;
|
||||
add_grav (part);
|
||||
}
|
||||
|
||||
static void
|
||||
part_phys_smoke (particle_t *part)
|
||||
{
|
||||
if (fade_alpha (part, 0.4))
|
||||
return;
|
||||
add_vel (part);
|
||||
part->scale += vr_data.frametime * 4.0;
|
||||
//sub_slowgrav (part);
|
||||
}
|
||||
|
||||
static void
|
||||
part_phys_smokecloud (particle_t *part)
|
||||
{
|
||||
if (fade_alpha (part, 0.55))
|
||||
return;
|
||||
add_vel (part);
|
||||
part->scale += vr_data.frametime * 50.0;
|
||||
sub_slowgrav (part);
|
||||
}
|
||||
|
||||
static void
|
||||
part_phys_bloodcloud (particle_t *part)
|
||||
{
|
||||
if (fade_alpha (part, 0.25))
|
||||
return;
|
||||
add_vel (part);
|
||||
part->scale += vr_data.frametime * 4.0;
|
||||
add_grav (part);
|
||||
}
|
||||
|
||||
static void
|
||||
part_phys_fallfade (particle_t *part)
|
||||
{
|
||||
if (fade_alpha (part, 1.0))
|
||||
return;
|
||||
add_vel (part);
|
||||
add_fastgrav (part);
|
||||
}
|
||||
|
||||
static void
|
||||
part_phys_fallfadespark (particle_t *part)
|
||||
{
|
||||
if (add_ramp (part, 15.0, 8))
|
||||
return;
|
||||
if (fade_alpha (part, 1.0))
|
||||
return;
|
||||
part->color = ramp1[(int) part->ramp];
|
||||
add_vel (part);
|
||||
add_fastgrav (part);
|
||||
}
|
||||
|
||||
static void
|
||||
part_phys_flame (particle_t *part)
|
||||
{
|
||||
if (fade_alpha (part, 0.125))
|
||||
return;
|
||||
add_vel (part);
|
||||
part->scale -= vr_data.frametime * 2.0;
|
||||
}
|
||||
|
||||
static pt_phys_func part_phys[] = {
|
||||
part_phys_static, // pt_static
|
||||
part_phys_grav, // pt_grav
|
||||
part_phys_grav, // pt_slowgrav
|
||||
part_phys_fire, // pt_fire
|
||||
part_phys_explode, // pt_explode
|
||||
part_phys_explode2, // pt_explode2
|
||||
part_phys_blob, // pt_blob
|
||||
part_phys_blob2, // pt_blob2
|
||||
part_phys_smoke, // pt_smoke
|
||||
part_phys_smokecloud, // pt_smokecloud
|
||||
part_phys_bloodcloud, // pt_bloodcloud
|
||||
part_phys_static, // pt_fadespark
|
||||
part_phys_static, // pt_fadespark2
|
||||
part_phys_fallfade, // pt_fallfade
|
||||
part_phys_fallfadespark,// pt_fallfadespark
|
||||
part_phys_flame, // pt_flame
|
||||
static int ramp[] = {
|
||||
/*ramp1*/ 0x6f, 0x6d, 0x6b, 0x69, 0x67, 0x65, 0x63, 0x61,
|
||||
/*ramp2*/ 0x6f, 0x6e, 0x6d, 0x6c, 0x6b, 0x6a, 0x68, 0x66,
|
||||
/*ramp3*/ 0x6d, 0x6b, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01,
|
||||
};
|
||||
|
||||
pt_phys_func
|
||||
static partparm_t part_params[] = {
|
||||
[pt_static] = {{0, 0, 0, 0}, 0, 1, 0, 0},
|
||||
[pt_grav] = {{0, 0, 0, 0.05}, 0, 1, 0, 0},
|
||||
[pt_slowgrav] = {{0, 0, 0, 0.05}, 0, 1, 0, 0},
|
||||
[pt_fire] = {{0, 0, 0, 0.05}, 5, 6, 0, 5./6},
|
||||
[pt_explode] = {{4, 4, 4, 0.05}, 10, 8, 0, 0},
|
||||
[pt_explode2] = {{1, 1, 1, 0.05}, 15, 8, 0, 0},
|
||||
[pt_blob] = {{4, 4, 4, 0.05}, 0, 1, 0, 0},
|
||||
[pt_blob2] = {{4, 4, 0, 0.05}, 0, 1, 0, 0},
|
||||
[pt_smoke] = {{0, 0, 0, 0}, 0, 1, 4, 0.4},
|
||||
[pt_smokecloud] = {{0, 0, 0, 0.0375}, 0, 1, 50, 0.55},
|
||||
[pt_bloodcloud] = {{0, 0, 0, 0.05}, 0, 1, 4, 0.25},
|
||||
[pt_fadespark] = {{0, 0, 0, 0}, 0, 1, 0, 0},
|
||||
[pt_fadespark2] = {{0, 0, 0, 0}, 0, 1, 0, 0},
|
||||
[pt_fallfade] = {{0, 0, 0, 1}, 0, 1, 0, 1},
|
||||
[pt_fallfadespark] = {{0, 0, 0, 1}, 15, 8, 0, 1},
|
||||
[pt_flame] = {{0, 0, 0, 0}, 0, 1, -2, 0.125},
|
||||
};
|
||||
|
||||
static const int *part_ramps[] = {
|
||||
[pt_fire] = ramp + 2 * 8, // ramp3
|
||||
[pt_explode] = ramp + 0 * 8, // ramp1
|
||||
[pt_explode2] = ramp + 1 * 8, // ramp2
|
||||
[pt_fallfadespark] = ramp + 0 * 8, // ramp1
|
||||
[pt_flame] = 0,
|
||||
};
|
||||
|
||||
partparm_t
|
||||
R_ParticlePhysics (ptype_t type)
|
||||
{
|
||||
if (type > pt_flame)
|
||||
if (type > pt_flame) {
|
||||
Sys_Error ("R_ParticlePhysics: invalid particle type");
|
||||
return part_phys[type];
|
||||
}
|
||||
return part_params[type];
|
||||
}
|
||||
|
||||
const int *
|
||||
R_ParticleRamp (ptype_t type)
|
||||
{
|
||||
if (type > pt_flame) {
|
||||
Sys_Error ("R_ParticleRamp: invalid particle type");
|
||||
}
|
||||
return part_ramps[type];
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ D_DrawParticle (particle_t *pparticle)
|
|||
int i, izi, pix, count, u, v;
|
||||
|
||||
// transform point
|
||||
VectorSubtract (pparticle->org, r_origin, local);
|
||||
VectorSubtract (pparticle->pos, r_origin, local);
|
||||
|
||||
transformed[0] = DotProduct (local, r_pright);
|
||||
transformed[1] = DotProduct (local, r_pup);
|
||||
|
@ -84,7 +84,7 @@ D_DrawParticle (particle_t *pparticle)
|
|||
for (; count; count--, pz += d_zwidth, pdest += screenwidth) {
|
||||
if (pz[0] <= izi) {
|
||||
pz[0] = izi;
|
||||
pdest[0] = pparticle->color;
|
||||
pdest[0] = pparticle->icolor;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -94,12 +94,12 @@ D_DrawParticle (particle_t *pparticle)
|
|||
for (; count; count--, pz += d_zwidth, pdest += screenwidth) {
|
||||
if (pz[0] <= izi) {
|
||||
pz[0] = izi;
|
||||
pdest[0] = pparticle->color;
|
||||
pdest[0] = pparticle->icolor;
|
||||
}
|
||||
|
||||
if (pz[1] <= izi) {
|
||||
pz[1] = izi;
|
||||
pdest[1] = pparticle->color;
|
||||
pdest[1] = pparticle->icolor;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -109,17 +109,17 @@ D_DrawParticle (particle_t *pparticle)
|
|||
for (; count; count--, pz += d_zwidth, pdest += screenwidth) {
|
||||
if (pz[0] <= izi) {
|
||||
pz[0] = izi;
|
||||
pdest[0] = pparticle->color;
|
||||
pdest[0] = pparticle->icolor;
|
||||
}
|
||||
|
||||
if (pz[1] <= izi) {
|
||||
pz[1] = izi;
|
||||
pdest[1] = pparticle->color;
|
||||
pdest[1] = pparticle->icolor;
|
||||
}
|
||||
|
||||
if (pz[2] <= izi) {
|
||||
pz[2] = izi;
|
||||
pdest[2] = pparticle->color;
|
||||
pdest[2] = pparticle->icolor;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -129,22 +129,22 @@ D_DrawParticle (particle_t *pparticle)
|
|||
for (; count; count--, pz += d_zwidth, pdest += screenwidth) {
|
||||
if (pz[0] <= izi) {
|
||||
pz[0] = izi;
|
||||
pdest[0] = pparticle->color;
|
||||
pdest[0] = pparticle->icolor;
|
||||
}
|
||||
|
||||
if (pz[1] <= izi) {
|
||||
pz[1] = izi;
|
||||
pdest[1] = pparticle->color;
|
||||
pdest[1] = pparticle->icolor;
|
||||
}
|
||||
|
||||
if (pz[2] <= izi) {
|
||||
pz[2] = izi;
|
||||
pdest[2] = pparticle->color;
|
||||
pdest[2] = pparticle->icolor;
|
||||
}
|
||||
|
||||
if (pz[3] <= izi) {
|
||||
pz[3] = izi;
|
||||
pdest[3] = pparticle->color;
|
||||
pdest[3] = pparticle->icolor;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -155,7 +155,7 @@ D_DrawParticle (particle_t *pparticle)
|
|||
for (i = 0; i < pix; i++) {
|
||||
if (pz[i] <= izi) {
|
||||
pz[i] = izi;
|
||||
pdest[i] = pparticle->color;
|
||||
pdest[i] = pparticle->icolor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -48,7 +48,7 @@ sw32_D_DrawParticle (particle_t *pparticle)
|
|||
int i, izi, pix, count, u, v;
|
||||
|
||||
// transform point
|
||||
VectorSubtract (pparticle->org, r_origin, local);
|
||||
VectorSubtract (pparticle->pos, r_origin, local);
|
||||
|
||||
transformed[0] = DotProduct (local, r_pright);
|
||||
transformed[1] = DotProduct (local, r_pup);
|
||||
|
@ -84,7 +84,7 @@ sw32_D_DrawParticle (particle_t *pparticle)
|
|||
case 1:
|
||||
{
|
||||
byte *pdest = (byte *) sw32_d_viewbuffer + sw32_d_scantable[v] + u,
|
||||
pixcolor = pparticle->color;
|
||||
pixcolor = pparticle->icolor;
|
||||
switch (pix) {
|
||||
case 1:
|
||||
count = 1 << sw32_d_y_aspect_shift;
|
||||
|
@ -180,7 +180,7 @@ sw32_D_DrawParticle (particle_t *pparticle)
|
|||
{
|
||||
unsigned short *pdest = (unsigned short *) sw32_d_viewbuffer +
|
||||
sw32_d_scantable[v] + u,
|
||||
pixcolor = sw32_8to16table[(int) pparticle->color];
|
||||
pixcolor = sw32_8to16table[(int) pparticle->icolor];
|
||||
switch (pix) {
|
||||
case 1:
|
||||
count = 1 << sw32_d_y_aspect_shift;
|
||||
|
@ -275,7 +275,7 @@ sw32_D_DrawParticle (particle_t *pparticle)
|
|||
case 4:
|
||||
{
|
||||
int *pdest = (int *) sw32_d_viewbuffer + sw32_d_scantable[v] + u,
|
||||
pixcolor = d_8to24table[(int) pparticle->color];
|
||||
pixcolor = d_8to24table[(int) pparticle->icolor];
|
||||
switch (pix) {
|
||||
case 1:
|
||||
count = 1 << sw32_d_y_aspect_shift;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -67,130 +67,130 @@ Vulkan_InitParticles (vulkan_ctx_t *ctx)
|
|||
}
|
||||
|
||||
static void
|
||||
R_RocketTrail_QF (const entity_t *ent)
|
||||
R_RocketTrail_QF (vec4f_t start, vec4f_t end)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
R_GrenadeTrail_QF (const entity_t *ent)
|
||||
R_GrenadeTrail_QF (vec4f_t start, vec4f_t end)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
R_BloodTrail_QF (const entity_t *ent)
|
||||
R_BloodTrail_QF (vec4f_t start, vec4f_t end)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
R_SlightBloodTrail_QF (const entity_t *ent)
|
||||
R_SlightBloodTrail_QF (vec4f_t start, vec4f_t end)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
R_WizTrail_QF (const entity_t *ent)
|
||||
R_WizTrail_QF (vec4f_t start, vec4f_t end)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
R_FlameTrail_QF (const entity_t *ent)
|
||||
R_FlameTrail_QF (vec4f_t start, vec4f_t end)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
R_VoorTrail_QF (const entity_t *ent)
|
||||
R_VoorTrail_QF (vec4f_t start, vec4f_t end)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
R_GlowTrail_QF (const entity_t *ent, int glow_color)
|
||||
R_GlowTrail_QF (vec4f_t start, vec4f_t end, int glow_color)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
R_RunParticleEffect_QF (const vec3_t org, const vec3_t dir, int color,
|
||||
R_RunParticleEffect_QF (vec4f_t org, vec4f_t dir, int color,
|
||||
int count)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
R_BloodPuffEffect_QF (const vec3_t org, int count)
|
||||
R_BloodPuffEffect_QF (vec4f_t org, int count)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
R_GunshotEffect_QF (const vec3_t org, int count)
|
||||
R_GunshotEffect_QF (vec4f_t org, int count)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
R_LightningBloodEffect_QF (const vec3_t org)
|
||||
R_LightningBloodEffect_QF (vec4f_t org)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
R_SpikeEffect_QF (const vec3_t org)
|
||||
R_SpikeEffect_QF (vec4f_t org)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
R_KnightSpikeEffect_QF (const vec3_t org)
|
||||
R_KnightSpikeEffect_QF (vec4f_t org)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
R_SuperSpikeEffect_QF (const vec3_t org)
|
||||
R_SuperSpikeEffect_QF (vec4f_t org)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
R_WizSpikeEffect_QF (const vec3_t org)
|
||||
R_WizSpikeEffect_QF (vec4f_t org)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
R_BlobExplosion_QF (const vec3_t org)
|
||||
R_BlobExplosion_QF (vec4f_t org)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
R_ParticleExplosion_QF (const vec3_t org)
|
||||
R_ParticleExplosion_QF (vec4f_t org)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
R_ParticleExplosion2_QF (const vec3_t org, int colorStart, int colorLength)
|
||||
R_ParticleExplosion2_QF (vec4f_t org, int colorStart, int colorLength)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
R_LavaSplash_QF (const vec3_t org)
|
||||
R_LavaSplash_QF (vec4f_t org)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
R_TeleportSplash_QF (const vec3_t org)
|
||||
R_TeleportSplash_QF (vec4f_t org)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
R_DarkFieldParticles_ID (const entity_t *ent)
|
||||
R_DarkFieldParticles_ID (vec4f_t org)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
R_EntityParticles_ID (const entity_t *ent)
|
||||
R_EntityParticles_ID (vec4f_t org)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
R_Particle_New (ptype_t type, int texnum, const vec3_t org,
|
||||
float scale, const vec3_t vel, float die,
|
||||
R_Particle_New (ptype_t type, int texnum, vec4f_t org,
|
||||
float scale, vec4f_t vel, float die,
|
||||
int color, float alpha, float ramp)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
R_Particle_NewRandom (ptype_t type, int texnum, const vec3_t org,
|
||||
R_Particle_NewRandom (ptype_t type, int texnum, vec4f_t org,
|
||||
int org_fuzz, float scale, int vel_fuzz,
|
||||
float die, int color, float alpha,
|
||||
float ramp)
|
||||
|
|
Loading…
Reference in a new issue