From 4d01a285bf854691d10de6998cc35b2808175d75 Mon Sep 17 00:00:00 2001 From: cloudwalk Date: Tue, 29 Sep 2020 19:19:06 +0000 Subject: [PATCH] client: Add cl_particles.h and move cl_particles definitions to it. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12971 d7cf8633-e32d-0410-b094-e92efae38249 --- cl_particles.h | 167 +++++++++++++++++++++++++++++++++ client.h | 164 +------------------------------- darkplaces-sdl2-vs2017.vcxproj | 1 + darkplaces-sdl2-vs2019.vcxproj | 1 + 4 files changed, 170 insertions(+), 163 deletions(-) create mode 100644 cl_particles.h diff --git a/cl_particles.h b/cl_particles.h new file mode 100644 index 00000000..a37bc489 --- /dev/null +++ b/cl_particles.h @@ -0,0 +1,167 @@ +#ifndef CL_PARTICLES_H +#define CL_PARTICLES_H + +#include "qtypes.h" +#include "cvar.h" +typedef struct entity_s entity_t; + +extern cvar_t cl_particles; +extern cvar_t cl_particles_quality; +extern cvar_t cl_particles_size; +extern cvar_t cl_particles_quake; +extern cvar_t cl_particles_blood; +extern cvar_t cl_particles_blood_alpha; +extern cvar_t cl_particles_blood_decal_alpha; +extern cvar_t cl_particles_blood_decal_scalemin; +extern cvar_t cl_particles_blood_decal_scalemax; +extern cvar_t cl_particles_blood_bloodhack; +extern cvar_t cl_particles_bulletimpacts; +extern cvar_t cl_particles_explosions_sparks; +extern cvar_t cl_particles_explosions_shell; +extern cvar_t cl_particles_rain; +extern cvar_t cl_particles_snow; +extern cvar_t cl_particles_smoke; +extern cvar_t cl_particles_smoke_alpha; +extern cvar_t cl_particles_smoke_alphafade; +extern cvar_t cl_particles_sparks; +extern cvar_t cl_particles_bubbles; +extern cvar_t cl_decals; +extern cvar_t cl_decals_time; +extern cvar_t cl_decals_fadetime; + +typedef enum +{ + PARTICLE_BILLBOARD = 0, + PARTICLE_SPARK = 1, + PARTICLE_ORIENTED_DOUBLESIDED = 2, + PARTICLE_VBEAM = 3, + PARTICLE_HBEAM = 4, + PARTICLE_INVALID = -1 +} +porientation_t; + +typedef enum +{ + PBLEND_ALPHA = 0, + PBLEND_ADD = 1, + PBLEND_INVMOD = 2, + PBLEND_INVALID = -1 +} +pblend_t; + +typedef struct particletype_s +{ + pblend_t blendmode; + porientation_t orientation; + qbool lighting; +} +particletype_t; + +typedef enum ptype_e +{ + pt_dead, pt_alphastatic, pt_static, pt_spark, pt_beam, pt_rain, pt_raindecal, pt_snow, pt_bubble, pt_blood, pt_smoke, pt_decal, pt_entityparticle, pt_total +} +ptype_t; + +typedef struct particle_s +{ + // for faster batch rendering, particles are rendered in groups by effect (resulting in less perfect sorting but far less state changes) + + // fields used by rendering: (48 bytes) + vec3_t sortorigin; // sort by this group origin, not particle org + vec3_t org; + vec3_t vel; // velocity of particle, or orientation of decal, or end point of beam + float size; + float alpha; // 0-255 + float stretch; // only for sparks + + // fields not used by rendering: (44 bytes) + float stainsize; + float stainalpha; + float sizeincrease; // rate of size change per second + float alphafade; // how much alpha reduces per second + float time2; // used for snow fluttering and decal fade + float bounce; // how much bounce-back from a surface the particle hits (0 = no physics, 1 = stop and slide, 2 = keep bouncing forever, 1.5 is typical) + float gravity; // how much gravity affects this particle (1.0 = normal gravity, 0.0 = none) + float airfriction; // how much air friction affects this object (objects with a low mass/size ratio tend to get more air friction) + float liquidfriction; // how much liquid friction affects this object (objects with a low mass/size ratio tend to get more liquid friction) +// float delayedcollisions; // time that p->bounce becomes active + float delayedspawn; // time that particle appears and begins moving + float die; // time when this particle should be removed, regardless of alpha + + // short variables grouped to save memory (4 bytes) + short angle; // base rotation of particle + short spin; // geometry rotation speed around the particle center normal + + // byte variables grouped to save memory (12 bytes) + unsigned char color[3]; + unsigned char qualityreduction; // enables skipping of this particle according to r_refdef.view.qualityreduction + unsigned char typeindex; + unsigned char blendmode; + unsigned char orientation; + unsigned char texnum; + unsigned char staincolor[3]; + signed char staintexnum; +} +particle_t; + +void CL_Particles_Clear(void); +void CL_Particles_Init(void); +void CL_Particles_Shutdown(void); +particle_t *CL_NewParticle(const vec3_t sortorigin, unsigned short ptypeindex, int pcolor1, int pcolor2, int ptex, float psize, float psizeincrease, float palpha, float palphafade, float pgravity, float pbounce, float px, float py, float pz, float pvx, float pvy, float pvz, float pairfriction, float pliquidfriction, float originjitter, float velocityjitter, qbool pqualityreduction, float lifetime, float stretch, pblend_t blendmode, porientation_t orientation, int staincolor1, int staincolor2, int staintex, float stainalpha, float stainsize, float angle, float spin, float tint[4]); + +typedef enum effectnameindex_s +{ + EFFECT_NONE, + EFFECT_TE_GUNSHOT, + EFFECT_TE_GUNSHOTQUAD, + EFFECT_TE_SPIKE, + EFFECT_TE_SPIKEQUAD, + EFFECT_TE_SUPERSPIKE, + EFFECT_TE_SUPERSPIKEQUAD, + EFFECT_TE_WIZSPIKE, + EFFECT_TE_KNIGHTSPIKE, + EFFECT_TE_EXPLOSION, + EFFECT_TE_EXPLOSIONQUAD, + EFFECT_TE_TAREXPLOSION, + EFFECT_TE_TELEPORT, + EFFECT_TE_LAVASPLASH, + EFFECT_TE_SMALLFLASH, + EFFECT_TE_FLAMEJET, + EFFECT_EF_FLAME, + EFFECT_TE_BLOOD, + EFFECT_TE_SPARK, + EFFECT_TE_PLASMABURN, + EFFECT_TE_TEI_G3, + EFFECT_TE_TEI_SMOKE, + EFFECT_TE_TEI_BIGEXPLOSION, + EFFECT_TE_TEI_PLASMAHIT, + EFFECT_EF_STARDUST, + EFFECT_TR_ROCKET, + EFFECT_TR_GRENADE, + EFFECT_TR_BLOOD, + EFFECT_TR_WIZSPIKE, + EFFECT_TR_SLIGHTBLOOD, + EFFECT_TR_KNIGHTSPIKE, + EFFECT_TR_VORESPIKE, + EFFECT_TR_NEHAHRASMOKE, + EFFECT_TR_NEXUIZPLASMA, + EFFECT_TR_GLOWTRAIL, + EFFECT_SVC_PARTICLE, + EFFECT_TOTAL +} +effectnameindex_t; + +int CL_ParticleEffectIndexForName(const char *name); +const char *CL_ParticleEffectNameForIndex(int i); +void CL_ParticleEffect(int effectindex, float pcount, const vec3_t originmins, const vec3_t originmaxs, const vec3_t velocitymins, const vec3_t velocitymaxs, entity_t *ent, int palettecolor); +void CL_ParticleTrail(int effectindex, float pcount, const vec3_t originmins, const vec3_t originmaxs, const vec3_t velocitymins, const vec3_t velocitymaxs, entity_t *ent, int palettecolor, qbool spawndlight, qbool spawnparticles, float tintmins[4], float tintmaxs[4], float fade); +void CL_ParticleBox(int effectindex, float pcount, const vec3_t originmins, const vec3_t originmaxs, const vec3_t velocitymins, const vec3_t velocitymaxs, entity_t *ent, int palettecolor, qbool spawndlight, qbool spawnparticles, float tintmins[4], float tintmaxs[4], float fade); +void CL_ParseParticleEffect (void); +void CL_ParticleCube (const vec3_t mins, const vec3_t maxs, const vec3_t dir, int count, int colorbase, vec_t gravity, vec_t randomvel); +void CL_ParticleRain (const vec3_t mins, const vec3_t maxs, const vec3_t dir, int count, int colorbase, int type); +void CL_EntityParticles (const entity_t *ent); +void CL_ParticleExplosion (const vec3_t org); +void CL_ParticleExplosion2 (const vec3_t org, int colorStart, int colorLength); + +#endif \ No newline at end of file diff --git a/client.h b/client.h index 769f57e9..61c2ede9 100644 --- a/client.h +++ b/client.h @@ -27,6 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "view.h" #include "cap.h" #include "cl_parse.h" +#include "cl_particles.h" // NOTE: r_stat_name[] must match this indexing typedef enum r_stat_e @@ -906,82 +907,6 @@ typedef struct qbool drawcrosshair; }csqc_vidvars_t; -typedef enum -{ - PARTICLE_BILLBOARD = 0, - PARTICLE_SPARK = 1, - PARTICLE_ORIENTED_DOUBLESIDED = 2, - PARTICLE_VBEAM = 3, - PARTICLE_HBEAM = 4, - PARTICLE_INVALID = -1 -} -porientation_t; - -typedef enum -{ - PBLEND_ALPHA = 0, - PBLEND_ADD = 1, - PBLEND_INVMOD = 2, - PBLEND_INVALID = -1 -} -pblend_t; - -typedef struct particletype_s -{ - pblend_t blendmode; - porientation_t orientation; - qbool lighting; -} -particletype_t; - -typedef enum ptype_e -{ - pt_dead, pt_alphastatic, pt_static, pt_spark, pt_beam, pt_rain, pt_raindecal, pt_snow, pt_bubble, pt_blood, pt_smoke, pt_decal, pt_entityparticle, pt_total -} -ptype_t; - -typedef struct particle_s -{ - // for faster batch rendering, particles are rendered in groups by effect (resulting in less perfect sorting but far less state changes) - - // fields used by rendering: (48 bytes) - vec3_t sortorigin; // sort by this group origin, not particle org - vec3_t org; - vec3_t vel; // velocity of particle, or orientation of decal, or end point of beam - float size; - float alpha; // 0-255 - float stretch; // only for sparks - - // fields not used by rendering: (44 bytes) - float stainsize; - float stainalpha; - float sizeincrease; // rate of size change per second - float alphafade; // how much alpha reduces per second - float time2; // used for snow fluttering and decal fade - float bounce; // how much bounce-back from a surface the particle hits (0 = no physics, 1 = stop and slide, 2 = keep bouncing forever, 1.5 is typical) - float gravity; // how much gravity affects this particle (1.0 = normal gravity, 0.0 = none) - float airfriction; // how much air friction affects this object (objects with a low mass/size ratio tend to get more air friction) - float liquidfriction; // how much liquid friction affects this object (objects with a low mass/size ratio tend to get more liquid friction) -// float delayedcollisions; // time that p->bounce becomes active - float delayedspawn; // time that particle appears and begins moving - float die; // time when this particle should be removed, regardless of alpha - - // short variables grouped to save memory (4 bytes) - short angle; // base rotation of particle - short spin; // geometry rotation speed around the particle center normal - - // byte variables grouped to save memory (12 bytes) - unsigned char color[3]; - unsigned char qualityreduction; // enables skipping of this particle according to r_refdef.view.qualityreduction - unsigned char typeindex; - unsigned char blendmode; - unsigned char orientation; - unsigned char texnum; - unsigned char staincolor[3]; - signed char staintexnum; -} -particle_t; - typedef enum cl_parsingtextmode_e { CL_PARSETEXTMODE_NONE, @@ -1574,93 +1499,6 @@ void CL_TimeDemo_f(cmd_state_t *cmd); void CL_Demo_Init(void); -// -// cl_part -// - -extern cvar_t cl_particles; -extern cvar_t cl_particles_quality; -extern cvar_t cl_particles_size; -extern cvar_t cl_particles_quake; -extern cvar_t cl_particles_blood; -extern cvar_t cl_particles_blood_alpha; -extern cvar_t cl_particles_blood_decal_alpha; -extern cvar_t cl_particles_blood_decal_scalemin; -extern cvar_t cl_particles_blood_decal_scalemax; -extern cvar_t cl_particles_blood_bloodhack; -extern cvar_t cl_particles_bulletimpacts; -extern cvar_t cl_particles_explosions_sparks; -extern cvar_t cl_particles_explosions_shell; -extern cvar_t cl_particles_rain; -extern cvar_t cl_particles_snow; -extern cvar_t cl_particles_smoke; -extern cvar_t cl_particles_smoke_alpha; -extern cvar_t cl_particles_smoke_alphafade; -extern cvar_t cl_particles_sparks; -extern cvar_t cl_particles_bubbles; -extern cvar_t cl_decals; -extern cvar_t cl_decals_time; -extern cvar_t cl_decals_fadetime; - -void CL_Particles_Clear(void); -void CL_Particles_Init(void); -void CL_Particles_Shutdown(void); -particle_t *CL_NewParticle(const vec3_t sortorigin, unsigned short ptypeindex, int pcolor1, int pcolor2, int ptex, float psize, float psizeincrease, float palpha, float palphafade, float pgravity, float pbounce, float px, float py, float pz, float pvx, float pvy, float pvz, float pairfriction, float pliquidfriction, float originjitter, float velocityjitter, qbool pqualityreduction, float lifetime, float stretch, pblend_t blendmode, porientation_t orientation, int staincolor1, int staincolor2, int staintex, float stainalpha, float stainsize, float angle, float spin, float tint[4]); - -typedef enum effectnameindex_s -{ - EFFECT_NONE, - EFFECT_TE_GUNSHOT, - EFFECT_TE_GUNSHOTQUAD, - EFFECT_TE_SPIKE, - EFFECT_TE_SPIKEQUAD, - EFFECT_TE_SUPERSPIKE, - EFFECT_TE_SUPERSPIKEQUAD, - EFFECT_TE_WIZSPIKE, - EFFECT_TE_KNIGHTSPIKE, - EFFECT_TE_EXPLOSION, - EFFECT_TE_EXPLOSIONQUAD, - EFFECT_TE_TAREXPLOSION, - EFFECT_TE_TELEPORT, - EFFECT_TE_LAVASPLASH, - EFFECT_TE_SMALLFLASH, - EFFECT_TE_FLAMEJET, - EFFECT_EF_FLAME, - EFFECT_TE_BLOOD, - EFFECT_TE_SPARK, - EFFECT_TE_PLASMABURN, - EFFECT_TE_TEI_G3, - EFFECT_TE_TEI_SMOKE, - EFFECT_TE_TEI_BIGEXPLOSION, - EFFECT_TE_TEI_PLASMAHIT, - EFFECT_EF_STARDUST, - EFFECT_TR_ROCKET, - EFFECT_TR_GRENADE, - EFFECT_TR_BLOOD, - EFFECT_TR_WIZSPIKE, - EFFECT_TR_SLIGHTBLOOD, - EFFECT_TR_KNIGHTSPIKE, - EFFECT_TR_VORESPIKE, - EFFECT_TR_NEHAHRASMOKE, - EFFECT_TR_NEXUIZPLASMA, - EFFECT_TR_GLOWTRAIL, - EFFECT_SVC_PARTICLE, - EFFECT_TOTAL -} -effectnameindex_t; - -int CL_ParticleEffectIndexForName(const char *name); -const char *CL_ParticleEffectNameForIndex(int i); -void CL_ParticleEffect(int effectindex, float pcount, const vec3_t originmins, const vec3_t originmaxs, const vec3_t velocitymins, const vec3_t velocitymaxs, entity_t *ent, int palettecolor); -void CL_ParticleTrail(int effectindex, float pcount, const vec3_t originmins, const vec3_t originmaxs, const vec3_t velocitymins, const vec3_t velocitymaxs, entity_t *ent, int palettecolor, qbool spawndlight, qbool spawnparticles, float tintmins[4], float tintmaxs[4], float fade); -void CL_ParticleBox(int effectindex, float pcount, const vec3_t originmins, const vec3_t originmaxs, const vec3_t velocitymins, const vec3_t velocitymaxs, entity_t *ent, int palettecolor, qbool spawndlight, qbool spawnparticles, float tintmins[4], float tintmaxs[4], float fade); -void CL_ParseParticleEffect (void); -void CL_ParticleCube (const vec3_t mins, const vec3_t maxs, const vec3_t dir, int count, int colorbase, vec_t gravity, vec_t randomvel); -void CL_ParticleRain (const vec3_t mins, const vec3_t maxs, const vec3_t dir, int count, int colorbase, int type); -void CL_EntityParticles (const entity_t *ent); -void CL_ParticleExplosion (const vec3_t org); -void CL_ParticleExplosion2 (const vec3_t org, int colorStart, int colorLength); - #include "cl_screen.h" extern qbool sb_showscores; diff --git a/darkplaces-sdl2-vs2017.vcxproj b/darkplaces-sdl2-vs2017.vcxproj index 87cd0335..0186e20c 100644 --- a/darkplaces-sdl2-vs2017.vcxproj +++ b/darkplaces-sdl2-vs2017.vcxproj @@ -322,6 +322,7 @@ + diff --git a/darkplaces-sdl2-vs2019.vcxproj b/darkplaces-sdl2-vs2019.vcxproj index 5265e7c6..3f254cb1 100644 --- a/darkplaces-sdl2-vs2019.vcxproj +++ b/darkplaces-sdl2-vs2019.vcxproj @@ -323,6 +323,7 @@ + -- 2.39.2