Inexor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Macros | Typedefs | Functions | Variables
renderparticles.cpp File Reference
#include "inexor/engine/renderparticles.hpp"
#include <SDL_opengl.h>
#include <boost/algorithm/clamp.hpp>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <memory>
#include "inexor/engine/decal.hpp"
#include "inexor/engine/depthfx.hpp"
#include "inexor/engine/glare.hpp"
#include "inexor/engine/glemu.hpp"
#include "inexor/engine/glexts.hpp"
#include "inexor/engine/material.hpp"
#include "inexor/engine/octaedit.hpp"
#include "inexor/engine/particles.hpp"
#include "inexor/engine/pvs.hpp"
#include "inexor/engine/renderbackground.hpp"
#include "inexor/engine/rendergl.hpp"
#include "inexor/engine/rendertext.hpp"
#include "inexor/engine/renderva.hpp"
#include "inexor/engine/shader.hpp"
#include "inexor/engine/shadowmap.hpp"
#include "inexor/engine/water.hpp"
#include "inexor/engine/world.hpp"
#include "inexor/fpsgame/entities.hpp"
#include "inexor/fpsgame/weapon.hpp"
#include "inexor/io/Logging.hpp"
#include "inexor/network/SharedVar.hpp"
#include "inexor/physics/physics.hpp"
#include "inexor/shared/command.hpp"
#include "inexor/shared/cube_formatting.hpp"
#include "inexor/shared/cube_loops.hpp"
#include "inexor/shared/cube_tools.hpp"
#include "inexor/shared/cube_types.hpp"
#include "inexor/shared/cube_vector.hpp"
#include "inexor/shared/ents.hpp"
#include "inexor/shared/geom.hpp"
#include "inexor/shared/tools.hpp"
#include "inexor/texture/texture.hpp"
#include "inexor/ui/screen/ScreenManager.hpp"
#include "inexor/util/legacy_time.hpp"
#include "inexor/engine/explosion.hpp"
#include "inexor/engine/lensflare.hpp"
#include "inexor/engine/lightning.hpp"

Classes

struct  meterrenderer
 
struct  textrenderer
 
struct  varenderer< T >
 

Macros

#define ROTCOEFFS(n)
 
#define SETTEXCOORDS(u1c, u2c, v1c, v2c, body)
 
#define SETCOLOR(r, g, b, a)
 
#define SETMODCOLOR   SETCOLOR((p->color.r*blend)>>8, (p->color.g*blend)>>8, (p->color.b*blend)>>8, 255)
 

Typedefs

typedef varenderer< PT_PARTquadrenderer
 
typedef varenderer< PT_TAPEtaperenderer
 
typedef varenderer< PT_TRAILtrailrenderer
 

Functions

 VARP (particlesize, 20, 100, 500)
 
 VARP (emitmillis, 1, 17, 1000)
 
static bool canemitparticles ()
 
 VARP (showparticles, 0, 1, 1)
 
 VAR (cullparticles, 0, 1, 1)
 
 VAR (replayparticles, 0, 1, 1)
 
 VARN (seedparticles, seedmillis, 0, 3000, 10000)
 
 VAR (dbgpcull, 0, 0, 1)
 
 VAR (dbgpseed, 0, 0, 1)
 
void clearparticleemitters ()
 
void addparticleemitters ()
 
 VARP (outlinemeters, 0, 0, 1)
 
static textrenderer texts (PT_TEXT|PT_LERP)
 
template<int T>
static void modifyblend (const vec &o, int &blend)
 
template<>
void modifyblend< PT_TAPE > (const vec &o, int &blend)
 
template<int T>
static void genpos (const vec &o, const vec &d, float size, int grav, int ts, partvert *vs)
 
template<>
void genpos< PT_TAPE > (const vec &o, const vec &d, float size, int ts, int grav, partvert *vs)
 
template<>
void genpos< PT_TRAIL > (const vec &o, const vec &d, float size, int ts, int grav, partvert *vs)
 
template<int T>
static void genrotpos (const vec &o, const vec &d, float size, int grav, int ts, partvert *vs, int rot)
 
template<>
void genrotpos< PT_PART > (const vec &o, const vec &d, float size, int grav, int ts, partvert *vs, int rot)
 
template<int T>
static void seedpos (particleemitter &pe, const vec &o, const vec &d, int fade, float size, int grav)
 
template<>
void seedpos< PT_TAPE > (particleemitter &pe, const vec &o, const vec &d, int fade, float size, int grav)
 
template<>
void seedpos< PT_TRAIL > (particleemitter &pe, const vec &o, const vec &d, int fade, float size, int grav)
 
 VAR (flarelights, 0, 0, 1)
 
 VARP (flarecutoff, 0, 1000, 10000)
 
 VARP (flaresize, 20, 100, 500)
 
 VAR (lnjittermillis, 0, 100, 1000)
 
 VAR (lnjitterradius, 0, 4, 100)
 
 FVAR (lnjitterscale, 0, 0.5f, 10)
 
 VAR (lnscrollmillis, 1, 300, 5000)
 
 FVAR (lnscrollscale, 0, 0.125f, 10)
 
 FVAR (lnblendpower, 0, 0.25f, 1000)
 
 VARFP (maxparticles, 10, 4000, 40000, particleinit())
 
 VARFP (fewparticles, 10, 100, 40000, particleinit())
 
void particleinit ()
 
void clearparticles ()
 
void cleanupparticles ()
 
void removetrackedparticles (physent *owner)
 
 VARP (particleglare, 0, 2, 100)
 
 VARN (debugparticles, dbgparts, 0, 0, 1)
 
void debugparticles ()
 
void renderparticles (bool mainpass)
 
static particlenewparticle (const vec &o, const vec &d, int fade, int type, int color, float size, int gravity=0)
 
 VARP (maxparticledistance, 256, 1024, 4096)
 
static void splash (int type, int color, int radius, int num, int fade, const vec &p, float size, int gravity)
 
static void regularsplash (int type, int color, int radius, int num, int fade, const vec &p, float size, int gravity, int delay=0)
 
bool canaddparticles ()
 
void regular_particle_splash (int type, int num, int fade, const vec &p, int color, float size, int radius, int gravity, int delay)
 
void particle_splash (int type, int num, int fade, const vec &p, int color, float size, int radius, int gravity)
 
 VARP (maxtrail, 1, 500, 10000)
 
void particle_trail (int type, int fade, const vec &s, const vec &e, int color, float size, int gravity)
 
 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)
 
void particle_textcopy (const vec &s, const char *t, int type, int fade, int color, float size, int gravity)
 
void particle_icon (const vec &s, int ix, int iy, int type, int fade, int color, float size, int gravity)
 
void particle_meter (const vec &s, float val, int type, int fade, int color, int color2, float size)
 
void particle_flare (const vec &p, const vec &dest, int fade, int type, int color, float size, physent *owner)
 
void particle_fireball (const vec &dest, float maxsize, int type, int fade, int color, float size)
 
static vec offsetvec (vec o, int dir, int dist)
 
static int colorfromattr (int attr)
 
void regularshape (int type, int radius, int color, int dir, int num, int fade, const vec &p, float size, int gravity, int vel, const vec *modfrom, const vec *modto)
 
static void regularflame (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 regular_particle_flame (int type, const vec &p, float radius, float height, int color, int density, float scale, float speed, float fade, int gravity)
 
static void makeparticles (entity &e)
 
bool printparticles (extentity &e, char *buf, int len)
 
void seedparticles ()
 
void updateparticles ()
 

Variables

Shaderparticleshader = nullptr
 
Shaderparticlenotextureshader = nullptr
 
static int lastemitframe = 0
 
static int emitoffset = 0
 
static bool canemit = false
 
static bool regenemitters = false
 
static bool canstep = false
 
static vector< particleemitteremitters
 
static particleemitterseedemitter = nullptr
 
static const char * partnames [] = { "part", "tape", "trail", "text", "textup", "meter", "metervs", "fireball", "lightning", "flare" }
 
static meterrenderer meters (PT_METER)
 
static meterrenderer metervs (PT_METERVS)
 
static const vec rotcoeffs [32][4]
 
partrendererparts []
 
static int addedparticles = 0
 

Macro Definition Documentation

#define ROTCOEFFS (   n)
Value:
{ \
vec(-1, 1, 0).rotate_around_z(n*2*M_PI/32.0f), \
vec( 1, 1, 0).rotate_around_z(n*2*M_PI/32.0f), \
vec( 1, -1, 0).rotate_around_z(n*2*M_PI/32.0f), \
vec(-1, -1, 0).rotate_around_z(n*2*M_PI/32.0f) \
}
ICOMMAND * f(float *a, float *b), floatret(*a **b)
#define SETCOLOR (   r,
  g,
  b,
 
)
Value:
do { \
bvec4 col(r, g, b, a); \
loopi(4) vs[i].color = col; \
} while(0)
else loopi(numargs)
Definition: command.cpp:3019
static void color(const bvec &v, uchar alpha=255)
Definition: glemu.hpp:71

Referenced by varenderer< T >::genverts().

#define SETMODCOLOR   SETCOLOR((p->color.r*blend)>>8, (p->color.g*blend)>>8, (p->color.b*blend)>>8, 255)
#define SETTEXCOORDS (   u1c,
  u2c,
  v1c,
  v2c,
  body 
)
Value:
{ \
float u1 = u1c, u2 = u2c, v1 = v1c, v2 = v2c; \
body; \
vs[0].tc = vec2(u1, v1); \
vs[1].tc = vec2(u2, v1); \
vs[2].tc = vec2(u2, v2); \
vs[3].tc = vec2(u1, v2); \
}
2-dimensional float vectors
Definition: geom.hpp:38

Referenced by varenderer< T >::genverts().

Typedef Documentation

Function Documentation

void addparticleemitters ( )
bool canaddparticles ( )
static bool canemitparticles ( )
static
void cleanupparticles ( )

References partrenderer::cleanup(), loopi(), and parts.

Referenced by resetgl().

void clearparticleemitters ( )

References emitters, and regenemitters.

Referenced by clearparticles(), and modifyoctaent().

void clearparticles ( )
static int colorfromattr ( int  attr)
inlinestatic

Referenced by makeparticles().

void debugparticles ( )
FVAR ( lnjitterscale  ,
,
0.  5f,
10   
)
FVAR ( lnscrollscale  ,
,
0.  125f,
10   
)
FVAR ( lnblendpower  ,
,
0.  25f,
1000   
)
template<int T>
static void genpos ( const vec o,
const vec d,
float  size,
int  grav,
int  ts,
partvert vs 
)
inlinestatic
template<>
void genpos< PT_TAPE > ( const vec o,
const vec d,
float  size,
int  ts,
int  grav,
partvert vs 
)
inline
template<>
void genpos< PT_TRAIL > ( const vec o,
const vec d,
float  size,
int  ts,
int  grav,
partvert vs 
)
inline
template<int T>
static void genrotpos ( const vec o,
const vec d,
float  size,
int  grav,
int  ts,
partvert vs,
int  rot 
)
inlinestatic

References hmap::d.

template<>
void genrotpos< PT_PART > ( const vec o,
const vec d,
float  size,
int  grav,
int  ts,
partvert vs,
int  rot 
)
inline

References camright, camup, vec::mul(), and rotcoeffs.

static void makeparticles ( entity e)
static
template<int T>
static void modifyblend ( const vec o,
int &  blend 
)
inlinestatic

References inexor::rpc::min().

template<>
void modifyblend< PT_TAPE > ( const vec o,
int &  blend 
)
inline
static particle* newparticle ( const vec o,
const vec d,
int  fade,
int  type,
int  color,
float  size,
int  gravity = 0 
)
inlinestatic
static vec offsetvec ( vec  o,
int  dir,
int  dist 
)
inlinestatic

References dir.

Referenced by makeparticles().

void particle_fireball ( const vec dest,
float  maxsize,
int  type,
int  fade,
int  color,
float  size 
)
void particle_flare ( const vec p,
const vec dest,
int  fade,
int  type,
int  color,
float  size,
physent owner 
)
void particle_icon ( const vec s,
int  ix,
int  iy,
int  type,
int  fade,
int  color,
float  size,
int  gravity 
)
void particle_meter ( const vec s,
float  val,
int  type,
int  fade,
int  color,
int  color2,
float  size 
)
void particle_splash ( int  type,
int  num,
int  fade,
const vec p,
int  color,
float  size,
int  radius,
int  gravity 
)
void particle_text ( const vec s,
const char *  t,
int  type,
int  fade,
int  color,
float  size,
int  gravity 
)
void particle_textcopy ( const vec s,
const char *  t,
int  type,
int  fade,
int  color,
float  size,
int  gravity 
)
void particle_trail ( int  type,
int  fade,
const vec s,
const vec e,
int  color,
float  size,
int  gravity 
)
void particleinit ( )
bool printparticles ( extentity e,
char *  buf,
int  len 
)
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 
)
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 regularflame ( 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 
)
static
void regularshape ( int  type,
int  radius,
int  color,
int  dir,
int  num,
int  fade,
const vec p,
float  size,
int  gravity,
int  vel,
const vec modfrom,
const vec modto 
)
static void regularsplash ( int  type,
int  color,
int  radius,
int  num,
int  fade,
const vec p,
float  size,
int  gravity,
int  delay = 0 
)
static
void removetrackedparticles ( physent owner)
void renderparticles ( bool  mainpass)
void seedparticles ( )
template<int T>
static void seedpos ( particleemitter pe,
const vec o,
const vec d,
int  fade,
float  size,
int  grav 
)
inlinestatic
template<>
void seedpos< PT_TAPE > ( particleemitter pe,
const vec o,
const vec d,
int  fade,
float  size,
int  grav 
)
inline

References hmap::d.

template<>
void seedpos< PT_TRAIL > ( particleemitter pe,
const vec o,
const vec d,
int  fade,
float  size,
int  grav 
)
inline

References vec::add(), hmap::d, vec::div(), and f().

static void splash ( int  type,
int  color,
int  radius,
int  num,
int  fade,
const vec p,
float  size,
int  gravity 
)
static
static textrenderer texts ( PT_TEXT PT_LERP)
static
void updateparticles ( )
VAR ( cullparticles  ,
,
,
 
)
VAR ( replayparticles  ,
,
,
 
)
VAR ( dbgpcull  ,
,
,
 
)
VAR ( dbgpseed  ,
,
,
 
)
VAR ( flarelights  ,
,
,
 
)
VAR ( lnjittermillis  ,
,
100  ,
1000   
)
VAR ( lnjitterradius  ,
,
,
100   
)
VAR ( lnscrollmillis  ,
,
300  ,
5000   
)
VARFP ( maxparticles  ,
10  ,
4000  ,
40000  ,
particleinit()   
)
VARFP ( fewparticles  ,
10  ,
100  ,
40000  ,
particleinit()   
)
VARN ( seedparticles  ,
seedmillis  ,
,
3000  ,
10000   
)
VARN ( debugparticles  ,
dbgparts  ,
,
,
 
)
VARP ( particlesize  ,
20  ,
100  ,
500   
)
VARP ( emitmillis  ,
,
17  ,
1000   
)
VARP ( showparticles  ,
,
,
 
)
VARP ( outlinemeters  ,
,
,
 
)
VARP ( flarecutoff  ,
,
1000  ,
10000   
)
VARP ( flaresize  ,
20  ,
100  ,
500   
)
VARP ( particleglare  ,
,
,
100   
)
VARP ( maxparticledistance  ,
256  ,
1024  ,
4096   
)
VARP ( maxtrail  ,
,
500  ,
10000   
)
VARP ( particletext  ,
,
,
 
)
VARP ( maxparticletextdistance  ,
,
128  ,
10000   
)

Variable Documentation

int addedparticles = 0
static

Referenced by newparticle(), and updateparticles().

bool canemit = false
static
bool canstep = false
static
int emitoffset = 0
static
vector<particleemitter> emitters
static
int lastemitframe = 0
static

Referenced by updateparticles().

meterrenderer meters(PT_METER)
static
Shader * particlenotextureshader = nullptr

Referenced by particleinit(), and renderparticles().

Shader* particleshader = nullptr

Referenced by particleinit(), and renderparticles().

const char* partnames[] = { "part", "tape", "trail", "text", "textup", "meter", "metervs", "fireball", "lightning", "flare" }
static

Referenced by partrenderer::debuginfo().

partrenderer* parts[]
Initial value:
=
{
new quadrenderer("<grey>particle/blood.png", PT_PART|PT_FLIP|PT_MOD|PT_RND4, DECAL_BLOOD),
new trailrenderer("particle/base.png", PT_TRAIL|PT_LERP),
new quadrenderer("<grey>particle/smoke.png", PT_PART|PT_FLIP|PT_LERP),
new quadrenderer("<grey>particle/steam.png", PT_PART|PT_FLIP),
new quadrenderer("<grey>particle/flames.png", PT_PART|PT_HFLIP|PT_RND4|PT_GLARE),
new quadrenderer("particle/ball1.png", PT_PART|PT_FEW|PT_GLARE),
new quadrenderer("particle/ball2.png", PT_PART|PT_FEW|PT_GLARE),
new quadrenderer("particle/ball3.png", PT_PART|PT_FEW|PT_GLARE),
new taperenderer("particle/flare.jpg", PT_TAPE|PT_GLARE),
new quadrenderer("particle/spark.png", PT_PART|PT_FLIP|PT_GLARE),
new quadrenderer("particle/base.png", PT_PART|PT_FLIP|PT_GLARE),
new quadrenderer("<grey>particle/snow.png", PT_PART|PT_FLIP|PT_RND4, -1),
new quadrenderer("particle/muzzleflash1.jpg", PT_PART|PT_FEW|PT_FLIP|PT_GLARE|PT_TRACK),
new quadrenderer("particle/muzzleflash2.jpg", PT_PART|PT_FEW|PT_FLIP|PT_GLARE|PT_TRACK),
new quadrenderer("particle/muzzleflash3.jpg", PT_PART|PT_FEW|PT_FLIP|PT_GLARE|PT_TRACK),
new quadrenderer("interface/hud/items.png", PT_PART|PT_FEW|PT_ICON),
new quadrenderer("<colorify:1/1/1>interface/hud/items.png", PT_PART|PT_FEW|PT_ICON),
&texts,
&meters,
}
static flarerenderer flares("<grey>particle/lensflares.png", 64)
Definition: particles.hpp:45
Definition: particles.hpp:32
varenderer< PT_TRAIL > trailrenderer
Definition: renderparticles.cpp:718
Definition: particles.hpp:42
Definition: particles.hpp:47
static meterrenderer metervs(PT_METERVS)
static meterrenderer meters(PT_METER)
fireballrenderer fireballs("particle/explosion.png")
Definition: particles.hpp:52
Definition: particles.hpp:55
Definition: particles.hpp:41
varenderer< PT_PART > quadrenderer
Definition: renderparticles.cpp:716
Definition: decal.hpp:16
Definition: particles.hpp:30
varenderer< PT_TAPE > taperenderer
Definition: renderparticles.cpp:717
static lightningrenderer lightnings
Definition: lightning.hpp:117
Definition: particles.hpp:51
fireballrenderer bluefireballs("particle/plasma.png")
static textrenderer texts(PT_TEXT|PT_LERP)
Definition: particles.hpp:31
Definition: particles.hpp:43
Definition: particles.hpp:44

Referenced by varenderer< T >::addpart(), cleanupparticles(), clearparticles(), compileglslshader(), debugparticles(), finddepthfxranges(), varenderer< T >::genverts(), varenderer< T >::init(), newparticle(), particleinit(), regularshape(), removetrackedparticles(), renderparticles(), varenderer< T >::resettracked(), skelcommands< MDL >::setadjust(), skelcommands< MDL >::setanim(), skelcommands< MDL >::setanimpart(), modelcommands< MDL, struct MDL::vertmesh >::setlink(), skelcommands< MDL >::setpitch(), skelcommands< MDL >::setpitchcorrect(), skelcommands< MDL >::setpitchtarget(), skelcommands< MDL >::settag(), showglslinfo(), and splash().

bool regenemitters = false
static
const vec rotcoeffs[32][4]
static
Initial value:
=
{
ROTCOEFFS(24), ROTCOEFFS(25), ROTCOEFFS(26), ROTCOEFFS(27), ROTCOEFFS(28), ROTCOEFFS(29), ROTCOEFFS(30), ROTCOEFFS(31),
}
#define ROTCOEFFS(n)
Definition: renderparticles.cpp:451

Referenced by genrotpos< PT_PART >().

particleemitter* seedemitter = nullptr
static