diff --git a/src/engine/engine.hh b/src/engine/engine.hh index 6a51460..5d58f0a 100644 --- a/src/engine/engine.hh +++ b/src/engine/engine.hh @@ -290,21 +290,6 @@ static inline model *loadmapmodel(int n) static inline mapmodelinfo *getmminfo(int n) { return mapmodels.inrange(n) ? &mapmodels[n] : NULL; } -// renderparticles -extern int particlelayers; - -enum { PL_ALL = 0, PL_UNDER, PL_OVER, PL_NOLAYER }; - -extern void initparticles(); -extern void clearparticles(); -extern void clearparticleemitters(); -extern void seedparticles(); -extern void updateparticles(); -extern void debugparticles(); -extern void renderparticles(int layer = PL_ALL); -extern bool printparticles(extentity &e, char *buf, int len); -extern void cleanupparticles(); - #endif #endif diff --git a/src/engine/main.cc b/src/engine/main.cc index 036313a..c848294 100644 --- a/src/engine/main.cc +++ b/src/engine/main.cc @@ -3,6 +3,7 @@ #include "blend.hh" #include "movie.hh" #include "rendergl.hh" +#include "renderparticles.hh" #include "rendersky.hh" #include "rendertext.hh" #include "renderva.hh" diff --git a/src/engine/octarender.cc b/src/engine/octarender.cc index 85da46d..70d0f38 100644 --- a/src/engine/octarender.cc +++ b/src/engine/octarender.cc @@ -4,6 +4,7 @@ #include "grass.hh" #include "material.hh" #include "rendergl.hh" +#include "renderparticles.hh" #include "rendersky.hh" #include "renderva.hh" #include "texture.hh" diff --git a/src/engine/rendergl.cc b/src/engine/rendergl.cc index f94e06d..2dd9a62 100644 --- a/src/engine/rendergl.cc +++ b/src/engine/rendergl.cc @@ -6,6 +6,7 @@ #include "material.hh" #include "pvs.hh" #include "rendergl.hh" +#include "renderparticles.hh" #include "rendersky.hh" #include "rendertext.hh" #include "renderva.hh" diff --git a/src/engine/renderlights.cc b/src/engine/renderlights.cc index 0e22542..5f76d94 100644 --- a/src/engine/renderlights.cc +++ b/src/engine/renderlights.cc @@ -4,6 +4,7 @@ #include "material.hh" #include "pvs.hh" #include "rendergl.hh" +#include "renderparticles.hh" #include "rendersky.hh" #include "renderva.hh" #include "stain.hh" diff --git a/src/engine/renderparticles.cc b/src/engine/renderparticles.cc index badfb15..78622fb 100644 --- a/src/engine/renderparticles.cc +++ b/src/engine/renderparticles.cc @@ -1,5 +1,6 @@ // renderparticles.cpp +#include "renderparticles.hh" #include "pvs.hh" #include "rendergl.hh" #include "rendertext.hh" @@ -11,6 +12,39 @@ #include "engine.hh" +#if 0 +void regular_particle_flame(int type, const vec &p, float radius, float height, int color, int density = 3, float scale = 2.0f, float speed = 200.0f, float fade = 600.0f, int gravity = -15); +void particle_splash(int type, int num, int fade, const vec &p, int color = 0xFFFFFF, float size = 1.0f, int radius = 150, int gravity = 2); +void particle_trail(int type, int fade, const vec &from, const vec &to, int color = 0xFFFFFF, float size = 1.0f, int gravity = 20); +void particle_text(const vec &s, const char *t, int type, int fade = 2000, int color = 0xFFFFFF, float size = 2.0f, int gravity = 0); +void particle_icon(const vec &s, int ix, int iy, int type, int fade = 2000, int color = 0xFFFFFF, float size = 2.0f, int gravity = 0); +void particle_meter(const vec &s, float val, int type, int fade = 1, int color = 0xFFFFFF, int color2 = 0xFFFFF, float size = 2.0f); +void particle_flare(const vec &p, const vec &dest, int fade, int type, int color = 0xFFFFFF, float size = 0.28f, physent *owner = NULL); +void particle_fireball(const vec &dest, float max, int type, int fade = -1, int color = 0xFFFFFF, float size = 4.0f); +void removetrackedparticles(physent *owner = NULL); +#endif + +enum +{ + PART_BLOOD = 0, + PART_WATER, + PART_SMOKE, + PART_STEAM, + PART_FLAME, + PART_STREAK, + PART_RAIL_TRAIL, PART_PULSE_SIDE, PART_PULSE_FRONT, + PART_LIGHTNING, + PART_EXPLOSION, PART_PULSE_BURST, + PART_SPARK, PART_EDIT, + PART_SNOW, + PART_RAIL_MUZZLE_FLASH, PART_PULSE_MUZZLE_FLASH, + PART_HUD_ICON, + PART_HUD_ICON_GREY, + PART_TEXT, + PART_METER, PART_METER_VS, + PART_LENS_FLARE +}; + Shader *particleshader = NULL, *particlenotextureshader = NULL, *particlesoftshader = NULL, *particletextshader = NULL; VARP(particlelayers, 0, 1, 1); @@ -86,7 +120,7 @@ void clearparticleemitters() regenemitters = true; } -void addparticleemitters() +static void addparticleemitters() { emitters.setsize(0); const vector &ents = entities::getents(); @@ -903,10 +937,12 @@ void cleanupparticles() loopi(sizeof(parts)/sizeof(parts[0])) parts[i]->cleanup(); } -void removetrackedparticles(physent *owner) +#if 0 +static void removetrackedparticles(physent *owner) { loopi(sizeof(parts)/sizeof(parts[0])) parts[i]->resettracked(owner); } +#endif VARN(debugparticles, dbgparts, 0, 0, 1); @@ -1039,17 +1075,47 @@ static void regularsplash(int type, int color, int radius, int num, int fade, co splash(type, color, radius, num, fade, p, size, gravity); } -bool canaddparticles() +static void regular_particle_splash(int type, int num, int fade, const vec &p, int color = 0xFFFFFF, float size = 1.0f, int radius = 150, int gravity = 2, int delay = 0); +static void particle_textcopy(const vec &s, const char *t, int type, int fade = 2000, int color = 0xFFFFFF, float size = 2.0f, int gravity = 0); + +static bool canaddparticles() { return !minimized; } -void regular_particle_splash(int type, int num, int fade, const vec &p, int color, float size, int radius, int gravity, int delay) +static void regular_particle_splash(int type, int num, int fade, const vec &p, int color, float size, int radius, int gravity, int delay) { if(!canaddparticles()) return; regularsplash(type, color, radius, num, fade, p, size, gravity, delay); } +VARP(particletext, 0, 1, 1); +VARP(maxparticletextdistance, 0, 128, 10000); + +static void particle_textcopy(const vec &s, const char *t, int type, int fade, int color, float size, int gravity) +{ + if(!canaddparticles()) return; + if(!particletext || camera1->o.dist(s) > maxparticletextdistance) return; + particle *p = newparticle(s, vec(0, 0, 1), fade, type, color, size, gravity); + p->text = newstring(t); + p->flags = 1; +} + +//dir = 0..6 where 0=up +static inline vec offsetvec(vec o, int dir, int dist) +{ + vec v = vec(o); + v[(2+dir)%3] += (dir>2)?(-dist):dist; + return v; +} + +//converts a 16bit color to 24bit +static inline int colorfromattr(int attr) +{ + return (((attr&0xF)<<4) | ((attr&0xF0)<<8) | ((attr&0xF00)<<12)) + 0x0F0F0F; +} + +#if 0 void particle_splash(int type, int num, int fade, const vec &p, int color, float size, int radius, int gravity) { if(!canaddparticles()) return; @@ -1074,9 +1140,6 @@ void particle_trail(int type, int fade, const vec &s, const vec &e, int color, f } } -VARP(particletext, 0, 1, 1); -VARP(maxparticletextdistance, 0, 128, 10000); - void particle_text(const vec &s, const char *t, int type, int fade, int color, float size, int gravity) { if(!canaddparticles()) return; @@ -1085,15 +1148,6 @@ void particle_text(const vec &s, const char *t, int type, int fade, int color, f p->text = t; } -void particle_textcopy(const vec &s, const char *t, int type, int fade, int color, float size, int gravity) -{ - if(!canaddparticles()) return; - if(!particletext || camera1->o.dist(s) > maxparticletextdistance) return; - particle *p = newparticle(s, vec(0, 0, 1), fade, type, color, size, gravity); - p->text = newstring(t); - p->flags = 1; -} - void particle_icon(const vec &s, int ix, int iy, int type, int fade, int color, float size, int gravity) { if(!canaddparticles()) return; @@ -1124,20 +1178,7 @@ void particle_fireball(const vec &dest, float maxsize, int type, int fade, int c if(fade < 0) fade = int(growth*20); newparticle(dest, vec(0, 0, 1), fade, type, color, size)->val = growth; } - -//dir = 0..6 where 0=up -static inline vec offsetvec(vec o, int dir, int dist) -{ - vec v = vec(o); - v[(2+dir)%3] += (dir>2)?(-dist):dist; - return v; -} - -//converts a 16bit color to 24bit -static inline int colorfromattr(int attr) -{ - return (((attr&0xF)<<4) | ((attr&0xF0)<<8) | ((attr&0xF00)<<12)) + 0x0F0F0F; -} +#endif /* 0 */ /* Experiments in shapes... * dir: (where dir%3 is similar to offsetvec with 0=up) @@ -1263,11 +1304,13 @@ static void regularflame(int type, const vec &p, float radius, float height, int } } +#if 0 void regular_particle_flame(int type, const vec &p, float radius, float height, int color, int density, float scale, float speed, float fade, int gravity) { if(!canaddparticles()) return; regularflame(type, p, radius, height, color, density, scale, speed, fade, gravity); } +#endif /* 0 */ static void makeparticles(entity &e) { diff --git a/src/engine/renderparticles.hh b/src/engine/renderparticles.hh new file mode 100644 index 0000000..9c19bed --- /dev/null +++ b/src/engine/renderparticles.hh @@ -0,0 +1,20 @@ +#ifndef ENGINE_RENDERPARTICLES_HH +#define ENGINE_RENDERPARTICLES_HH + +extern int particlelayers; + +struct extentity; + +enum { PL_ALL = 0, PL_UNDER, PL_OVER, PL_NOLAYER }; + +void initparticles(); +void clearparticles(); +void clearparticleemitters(); +void seedparticles(); +void updateparticles(); +void debugparticles(); +void renderparticles(int layer = PL_ALL); +bool printparticles(extentity &e, char *buf, int len); +void cleanupparticles(); + +#endif diff --git a/src/engine/world.cc b/src/engine/world.cc index 087fc06..a146f01 100644 --- a/src/engine/world.cc +++ b/src/engine/world.cc @@ -5,6 +5,7 @@ #include "pvs.hh" #include "rendergl.hh" /* fovy */ #include "renderlights.hh" +#include "renderparticles.hh" #include "stain.hh" #include "texture.hh" #include "worldio.hh" diff --git a/src/shared/iengine.hh b/src/shared/iengine.hh index e79a57f..29679b7 100644 --- a/src/shared/iengine.hh +++ b/src/shared/iengine.hh @@ -180,41 +180,6 @@ extern void pushhudscale(float sx, float sy = 0); extern void pushhudtranslate(float tx, float ty, float sx = 0, float sy = 0); extern void resethudshader(); -// renderparticles -enum -{ - PART_BLOOD = 0, - PART_WATER, - PART_SMOKE, - PART_STEAM, - PART_FLAME, - PART_STREAK, - PART_RAIL_TRAIL, PART_PULSE_SIDE, PART_PULSE_FRONT, - PART_LIGHTNING, - PART_EXPLOSION, PART_PULSE_BURST, - PART_SPARK, PART_EDIT, - PART_SNOW, - PART_RAIL_MUZZLE_FLASH, PART_PULSE_MUZZLE_FLASH, - PART_HUD_ICON, - PART_HUD_ICON_GREY, - PART_TEXT, - PART_METER, PART_METER_VS, - PART_LENS_FLARE -}; - -extern bool canaddparticles(); -extern void regular_particle_splash(int type, int num, int fade, const vec &p, int color = 0xFFFFFF, float size = 1.0f, int radius = 150, int gravity = 2, int delay = 0); -extern void regular_particle_flame(int type, const vec &p, float radius, float height, int color, int density = 3, float scale = 2.0f, float speed = 200.0f, float fade = 600.0f, int gravity = -15); -extern void particle_splash(int type, int num, int fade, const vec &p, int color = 0xFFFFFF, float size = 1.0f, int radius = 150, int gravity = 2); -extern void particle_trail(int type, int fade, const vec &from, const vec &to, int color = 0xFFFFFF, float size = 1.0f, int gravity = 20); -extern void particle_text(const vec &s, const char *t, int type, int fade = 2000, int color = 0xFFFFFF, float size = 2.0f, int gravity = 0); -extern void particle_textcopy(const vec &s, const char *t, int type, int fade = 2000, int color = 0xFFFFFF, float size = 2.0f, int gravity = 0); -extern void particle_icon(const vec &s, int ix, int iy, int type, int fade = 2000, int color = 0xFFFFFF, float size = 2.0f, int gravity = 0); -extern void particle_meter(const vec &s, float val, int type, int fade = 1, int color = 0xFFFFFF, int color2 = 0xFFFFF, float size = 2.0f); -extern void particle_flare(const vec &p, const vec &dest, int fade, int type, int color = 0xFFFFFF, float size = 0.28f, physent *owner = NULL); -extern void particle_fireball(const vec &dest, float max, int type, int fade = -1, int color = 0xFFFFFF, float size = 4.0f); -extern void removetrackedparticles(physent *owner = NULL); - // stain enum {