2011-12-25 22:50:05 +00:00
|
|
|
/*
|
2012-01-19 01:38:05 +00:00
|
|
|
gl_dyn_part.c
|
2011-12-25 22:50:05 +00:00
|
|
|
|
2012-01-19 01:38:05 +00:00
|
|
|
OpenGL particle system.
|
2011-12-25 22:50:05 +00:00
|
|
|
|
|
|
|
Copyright (C) 1996-1997 Id Software, Inc.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2012-02-22 07:32:34 +00:00
|
|
|
#define NH_DEFINE
|
|
|
|
#include "namehack.h"
|
|
|
|
|
2011-12-25 22:50:05 +00:00
|
|
|
#ifdef HAVE_STRING_H
|
2012-01-19 01:38:05 +00:00
|
|
|
# include <string.h>
|
2011-12-25 22:50:05 +00:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_STRINGS_H
|
2012-01-19 01:38:05 +00:00
|
|
|
# include <strings.h>
|
2011-12-25 22:50:05 +00:00
|
|
|
#endif
|
|
|
|
|
2012-01-19 01:38:05 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "QF/cmd.h"
|
2011-12-25 22:50:05 +00:00
|
|
|
#include "QF/cvar.h"
|
2012-01-21 10:51:18 +00:00
|
|
|
#include "QF/image.h"
|
2013-01-21 11:06:54 +00:00
|
|
|
#include "QF/mersenne.h"
|
2012-01-19 01:38:05 +00:00
|
|
|
#include "QF/qargs.h"
|
|
|
|
#include "QF/quakefs.h"
|
2011-12-25 22:50:05 +00:00
|
|
|
#include "QF/render.h"
|
2012-01-19 01:38:05 +00:00
|
|
|
#include "QF/sys.h"
|
|
|
|
#include "QF/va.h"
|
2021-07-24 05:19:52 +00:00
|
|
|
|
|
|
|
#include "QF/scene/entity.h"
|
|
|
|
|
2011-12-26 07:08:55 +00:00
|
|
|
#include "QF/GLSL/defines.h"
|
|
|
|
#include "QF/GLSL/funcs.h"
|
2012-01-19 01:38:05 +00:00
|
|
|
//#include "QF/GL/qf_explosions.h"
|
|
|
|
#include "QF/GLSL/qf_particles.h"
|
|
|
|
#include "QF/GLSL/qf_textures.h"
|
|
|
|
#include "QF/GLSL/qf_vid.h"
|
2011-12-25 22:50:05 +00:00
|
|
|
|
2012-02-14 08:28:09 +00:00
|
|
|
#include "r_internal.h"
|
2011-12-25 22:50:05 +00:00
|
|
|
|
2012-01-21 12:54:36 +00:00
|
|
|
//FIXME not part of GLES, but needed for GL
|
|
|
|
#ifndef GL_VERTEX_PROGRAM_POINT_SIZE
|
|
|
|
# define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642
|
|
|
|
#endif
|
|
|
|
|
2012-01-19 01:38:05 +00:00
|
|
|
static GLushort *pVAindices;
|
|
|
|
static partvert_t *particleVertexArray;
|
|
|
|
|
2012-01-21 10:51:18 +00:00
|
|
|
static GLuint part_tex;
|
2012-01-19 01:38:05 +00:00
|
|
|
|
2014-01-28 03:08:53 +00:00
|
|
|
static const char *particle_point_vert_effects[] =
|
|
|
|
{
|
|
|
|
"QuakeForge.Vertex.particle.point",
|
|
|
|
0
|
|
|
|
};
|
2012-01-19 01:38:05 +00:00
|
|
|
|
2014-01-28 03:08:53 +00:00
|
|
|
static const char *particle_point_frag_effects[] =
|
|
|
|
{
|
2014-01-28 04:00:28 +00:00
|
|
|
"QuakeForge.Fragment.fog",
|
|
|
|
"QuakeForge.Fragment.palette",
|
2014-01-28 03:08:53 +00:00
|
|
|
"QuakeForge.Fragment.particle.point",
|
|
|
|
0
|
|
|
|
};
|
2012-01-19 01:38:05 +00:00
|
|
|
|
2014-01-28 03:16:52 +00:00
|
|
|
static const char *particle_textured_vert_effects[] =
|
|
|
|
{
|
|
|
|
"QuakeForge.Vertex.particle.textured",
|
|
|
|
0
|
|
|
|
};
|
2012-01-21 10:51:18 +00:00
|
|
|
|
2014-01-28 03:16:52 +00:00
|
|
|
static const char *particle_textured_frag_effects[] =
|
|
|
|
{
|
2014-01-28 04:00:28 +00:00
|
|
|
"QuakeForge.Fragment.fog",
|
|
|
|
"QuakeForge.Fragment.palette",
|
2014-01-28 03:16:52 +00:00
|
|
|
"QuakeForge.Fragment.particle.textured",
|
|
|
|
0
|
|
|
|
};
|
2012-01-21 10:51:18 +00:00
|
|
|
|
2012-01-19 01:38:05 +00:00
|
|
|
static struct {
|
|
|
|
int program;
|
|
|
|
shaderparam_t mvp_matrix;
|
|
|
|
shaderparam_t vertex;
|
|
|
|
shaderparam_t palette;
|
|
|
|
shaderparam_t color;
|
2012-01-29 01:27:28 +00:00
|
|
|
shaderparam_t fog;
|
2012-01-19 01:38:05 +00:00
|
|
|
} quake_point = {
|
|
|
|
0,
|
|
|
|
{"mvp_mat", 1},
|
|
|
|
{"vertex", 0},
|
|
|
|
{"palette", 1},
|
|
|
|
{"vcolor", 0},
|
2012-01-29 01:35:23 +00:00
|
|
|
{"fog", 1},
|
2012-01-19 01:38:05 +00:00
|
|
|
};
|
|
|
|
|
2012-01-21 10:51:18 +00:00
|
|
|
static struct {
|
|
|
|
int program;
|
|
|
|
shaderparam_t mvp_matrix;
|
|
|
|
shaderparam_t st;
|
|
|
|
shaderparam_t vertex;
|
|
|
|
shaderparam_t color;
|
|
|
|
shaderparam_t texture;
|
2012-01-29 01:27:28 +00:00
|
|
|
shaderparam_t fog;
|
2012-01-21 10:51:18 +00:00
|
|
|
} quake_part = {
|
|
|
|
0,
|
|
|
|
{"mvp_mat", 1},
|
|
|
|
{"vst", 0},
|
|
|
|
{"vertex", 0},
|
|
|
|
{"vcolor", 0},
|
|
|
|
{"texture", 1},
|
2012-01-29 01:35:23 +00:00
|
|
|
{"fog", 1},
|
2012-01-21 10:51:18 +00:00
|
|
|
};
|
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
static mtstate_t mt; // private PRNG state
|
|
|
|
|
2012-01-19 01:38:05 +00:00
|
|
|
inline static void
|
2021-12-18 16:21:39 +00:00
|
|
|
particle_new (ptype_t type, int texnum, vec4f_t pos, float scale,
|
|
|
|
vec4f_t vel, float live, int color, float alpha, float ramp)
|
2012-01-19 01:38:05 +00:00
|
|
|
{
|
2021-12-18 16:21:39 +00:00
|
|
|
if (numparticles >= r_maxparticles)
|
|
|
|
return;
|
|
|
|
particle_t *p = &particles[numparticles];
|
|
|
|
partparm_t *parm = &partparams[numparticles];
|
|
|
|
const int **rampptr = &partramps[numparticles];
|
|
|
|
numparticles += 1;
|
|
|
|
|
|
|
|
p->pos = pos;
|
|
|
|
p->vel = vel;
|
|
|
|
p->icolor = color;
|
|
|
|
p->alpha = alpha;
|
|
|
|
p->tex = texnum;
|
|
|
|
p->ramp = ramp;
|
|
|
|
p->scale = scale;
|
|
|
|
p->live = live;
|
|
|
|
|
|
|
|
*parm = R_ParticlePhysics (type);
|
|
|
|
*rampptr = R_ParticleRamp (type);
|
|
|
|
if (*rampptr) {
|
|
|
|
p->icolor = (*rampptr) [(int) p->ramp];
|
2012-01-19 01:38:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
particle_new_random
|
|
|
|
|
|
|
|
note that org_fuzz & vel_fuzz should be ints greater than 0 if you are
|
|
|
|
going to bother using this function.
|
|
|
|
*/
|
|
|
|
inline static void
|
2021-12-18 16:21:39 +00:00
|
|
|
particle_new_random (ptype_t type, int texnum, vec4f_t org, int org_fuzz,
|
|
|
|
float scale, int vel_fuzz, float live, int color,
|
2012-01-19 01:38:05 +00:00
|
|
|
float alpha, float ramp)
|
|
|
|
{
|
|
|
|
float o_fuzz = org_fuzz, v_fuzz = vel_fuzz;
|
|
|
|
int rnd;
|
2021-12-18 16:21:39 +00:00
|
|
|
vec4f_t porg, pvel;
|
2012-01-19 01:38:05 +00:00
|
|
|
|
2013-01-21 11:06:54 +00:00
|
|
|
rnd = mtwist_rand (&mt);
|
2012-01-19 01:38:05 +00:00
|
|
|
porg[0] = o_fuzz * ((rnd & 63) - 31.5) / 63.0 + org[0];
|
2013-01-21 11:06:54 +00:00
|
|
|
porg[1] = o_fuzz * (((rnd >> 6) & 63) - 31.5) / 63.0 + org[1];
|
|
|
|
porg[2] = o_fuzz * (((rnd >> 10) & 63) - 31.5) / 63.0 + org[2];
|
2021-12-18 16:21:39 +00:00
|
|
|
porg[3] = 1;
|
2013-01-21 11:06:54 +00:00
|
|
|
rnd = mtwist_rand (&mt);
|
2012-01-19 01:38:05 +00:00
|
|
|
pvel[0] = v_fuzz * ((rnd & 63) - 31.5) / 63.0;
|
2013-01-21 11:06:54 +00:00
|
|
|
pvel[1] = v_fuzz * (((rnd >> 6) & 63) - 31.5) / 63.0;
|
|
|
|
pvel[2] = v_fuzz * (((rnd >> 10) & 63) - 31.5) / 63.0;
|
2021-12-18 16:21:39 +00:00
|
|
|
pvel[3] = 0;
|
2012-01-19 01:38:05 +00:00
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
particle_new (type, texnum, porg, scale, pvel, live, color, alpha, ramp);
|
2012-01-19 01:38:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
inline static void
|
2021-12-18 16:21:39 +00:00
|
|
|
particle_new_veryrandom (ptype_t type, int texnum, vec4f_t org,
|
|
|
|
int org_fuzz, float scale, int vel_fuzz, float live,
|
2012-01-19 01:38:05 +00:00
|
|
|
int color, float alpha, float ramp)
|
|
|
|
{
|
|
|
|
vec3_t porg, pvel;
|
|
|
|
|
|
|
|
porg[0] = qfrandom (org_fuzz * 2) - org_fuzz + org[0];
|
|
|
|
porg[1] = qfrandom (org_fuzz * 2) - org_fuzz + org[1];
|
|
|
|
porg[2] = qfrandom (org_fuzz * 2) - org_fuzz + org[2];
|
|
|
|
pvel[0] = qfrandom (vel_fuzz * 2) - vel_fuzz;
|
|
|
|
pvel[1] = qfrandom (vel_fuzz * 2) - vel_fuzz;
|
|
|
|
pvel[2] = qfrandom (vel_fuzz * 2) - vel_fuzz;
|
2021-12-18 16:21:39 +00:00
|
|
|
particle_new (type, texnum, porg, scale, pvel, live, color, alpha, ramp);
|
2012-01-19 01:38:05 +00:00
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
static vec4f_t
|
|
|
|
roffs (int mod)
|
|
|
|
{
|
|
|
|
vec4f_t offs = {
|
|
|
|
(mtwist_rand (&mt) % mod) - 0.5 * (mod - 1),
|
|
|
|
(mtwist_rand (&mt) % mod) - 0.5 * (mod - 1),
|
|
|
|
(mtwist_rand (&mt) % mod) - 0.5 * (mod - 1),
|
|
|
|
0
|
|
|
|
};
|
|
|
|
return offs;
|
|
|
|
}
|
|
|
|
|
|
|
|
static vec4f_t
|
|
|
|
tracer_vel (int tracercount, vec4f_t vec)
|
|
|
|
{
|
|
|
|
if (tracercount & 1) {
|
|
|
|
return (vec4f_t) { vec[1], -vec[0], 0, 0 };
|
|
|
|
} else {
|
|
|
|
return (vec4f_t) { -vec[1], vec[0], 0, 0 };
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
add_particle (ptype_t type, vec4f_t pos, vec4f_t vel, float live, int color,
|
|
|
|
float ramp)
|
|
|
|
{
|
|
|
|
particle_new (type, part_tex_dot, pos, 1, vel, live, color, 1, ramp);
|
|
|
|
}
|
|
|
|
|
2012-02-18 13:28:42 +00:00
|
|
|
void
|
2012-02-22 07:32:34 +00:00
|
|
|
glsl_R_ClearParticles (void)
|
2012-01-19 01:38:05 +00:00
|
|
|
{
|
|
|
|
numparticles = 0;
|
|
|
|
}
|
|
|
|
|
2011-12-25 22:50:05 +00:00
|
|
|
void
|
2012-02-22 07:32:34 +00:00
|
|
|
glsl_R_InitParticles (void)
|
2011-12-25 22:50:05 +00:00
|
|
|
{
|
2014-01-28 03:08:53 +00:00
|
|
|
shader_t *vert_shader, *frag_shader;
|
2012-01-19 01:38:05 +00:00
|
|
|
unsigned i;
|
|
|
|
int vert;
|
|
|
|
int frag;
|
2012-01-21 06:48:21 +00:00
|
|
|
float v[2] = {0, 0};
|
2012-01-21 10:51:18 +00:00
|
|
|
byte data[64][64][2];
|
|
|
|
tex_t *tex;
|
2012-01-21 06:48:21 +00:00
|
|
|
|
2013-01-21 11:06:54 +00:00
|
|
|
mtwist_seed (&mt, 0xdeadbeef);
|
|
|
|
|
2012-02-22 07:48:57 +00:00
|
|
|
qfeglEnable (GL_VERTEX_PROGRAM_POINT_SIZE);
|
|
|
|
qfeglGetFloatv (GL_ALIASED_POINT_SIZE_RANGE, v);
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_glsl, "point size: %g - %g\n", v[0], v[1]);
|
2012-01-19 01:38:05 +00:00
|
|
|
|
2014-01-28 03:08:53 +00:00
|
|
|
vert_shader = GLSL_BuildShader (particle_point_vert_effects);
|
|
|
|
frag_shader = GLSL_BuildShader (particle_point_frag_effects);
|
|
|
|
vert = GLSL_CompileShader ("quakepnt.vert", vert_shader,
|
2012-02-17 09:57:13 +00:00
|
|
|
GL_VERTEX_SHADER);
|
2014-01-28 03:08:53 +00:00
|
|
|
frag = GLSL_CompileShader ("quakepnt.frag", frag_shader,
|
2012-02-17 09:57:13 +00:00
|
|
|
GL_FRAGMENT_SHADER);
|
|
|
|
quake_point.program = GLSL_LinkProgram ("quakepoint", vert, frag);
|
|
|
|
GLSL_ResolveShaderParam (quake_point.program, &quake_point.mvp_matrix);
|
|
|
|
GLSL_ResolveShaderParam (quake_point.program, &quake_point.vertex);
|
|
|
|
GLSL_ResolveShaderParam (quake_point.program, &quake_point.palette);
|
|
|
|
GLSL_ResolveShaderParam (quake_point.program, &quake_point.color);
|
|
|
|
GLSL_ResolveShaderParam (quake_point.program, &quake_point.fog);
|
2014-01-28 03:08:53 +00:00
|
|
|
GLSL_FreeShader (vert_shader);
|
|
|
|
GLSL_FreeShader (frag_shader);
|
2012-02-17 09:57:13 +00:00
|
|
|
|
2014-01-28 03:16:52 +00:00
|
|
|
vert_shader = GLSL_BuildShader (particle_textured_vert_effects);
|
|
|
|
frag_shader = GLSL_BuildShader (particle_textured_frag_effects);
|
|
|
|
vert = GLSL_CompileShader ("quakepar.vert", vert_shader,
|
2012-02-17 09:57:13 +00:00
|
|
|
GL_VERTEX_SHADER);
|
2014-01-28 03:16:52 +00:00
|
|
|
frag = GLSL_CompileShader ("quakepar.frag", frag_shader,
|
2012-02-17 09:57:13 +00:00
|
|
|
GL_FRAGMENT_SHADER);
|
|
|
|
quake_part.program = GLSL_LinkProgram ("quakepart", vert, frag);
|
|
|
|
GLSL_ResolveShaderParam (quake_part.program, &quake_part.mvp_matrix);
|
|
|
|
GLSL_ResolveShaderParam (quake_part.program, &quake_part.st);
|
|
|
|
GLSL_ResolveShaderParam (quake_part.program, &quake_part.vertex);
|
|
|
|
GLSL_ResolveShaderParam (quake_part.program, &quake_part.color);
|
|
|
|
GLSL_ResolveShaderParam (quake_part.program, &quake_part.texture);
|
|
|
|
GLSL_ResolveShaderParam (quake_part.program, &quake_part.fog);
|
2014-01-28 03:16:52 +00:00
|
|
|
GLSL_FreeShader (vert_shader);
|
|
|
|
GLSL_FreeShader (frag_shader);
|
2012-01-21 10:51:18 +00:00
|
|
|
|
|
|
|
memset (data, 0, sizeof (data));
|
2012-02-22 07:48:57 +00:00
|
|
|
qfeglGenTextures (1, &part_tex);
|
|
|
|
qfeglBindTexture (GL_TEXTURE_2D, part_tex);
|
|
|
|
qfeglTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
|
|
|
qfeglTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
|
|
|
qfeglTexImage2D (GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA, 64, 64, 0,
|
2012-01-21 10:51:18 +00:00
|
|
|
GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, data);
|
|
|
|
tex = R_DotParticleTexture ();
|
2012-02-22 07:48:57 +00:00
|
|
|
qfeglTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, 32, 32, GL_LUMINANCE_ALPHA,
|
2012-01-21 10:51:18 +00:00
|
|
|
GL_UNSIGNED_BYTE, tex->data);
|
|
|
|
free (tex);
|
|
|
|
tex = R_SparkParticleTexture ();
|
2012-02-22 07:48:57 +00:00
|
|
|
qfeglTexSubImage2D (GL_TEXTURE_2D, 0, 32, 0, 32, 32, GL_LUMINANCE_ALPHA,
|
2012-01-21 10:51:18 +00:00
|
|
|
GL_UNSIGNED_BYTE, tex->data);
|
|
|
|
free (tex);
|
|
|
|
tex = R_SmokeParticleTexture ();
|
2012-02-22 07:48:57 +00:00
|
|
|
qfeglTexSubImage2D (GL_TEXTURE_2D, 0, 0, 32, 32, 32, GL_LUMINANCE_ALPHA,
|
2012-01-21 10:51:18 +00:00
|
|
|
GL_UNSIGNED_BYTE, tex->data);
|
|
|
|
free (tex);
|
|
|
|
|
2012-01-19 01:38:05 +00:00
|
|
|
if (particleVertexArray)
|
|
|
|
free (particleVertexArray);
|
|
|
|
particleVertexArray = calloc (r_maxparticles * 4, sizeof (partvert_t));
|
|
|
|
|
|
|
|
if (pVAindices)
|
|
|
|
free (pVAindices);
|
|
|
|
pVAindices = calloc (r_maxparticles * 6, sizeof (GLushort));
|
|
|
|
for (i = 0; i < r_maxparticles; i++) {
|
|
|
|
pVAindices[i * 6 + 0] = i * 4 + 0;
|
|
|
|
pVAindices[i * 6 + 1] = i * 4 + 1;
|
|
|
|
pVAindices[i * 6 + 2] = i * 4 + 2;
|
|
|
|
pVAindices[i * 6 + 3] = i * 4 + 0;
|
|
|
|
pVAindices[i * 6 + 4] = i * 4 + 2;
|
|
|
|
pVAindices[i * 6 + 5] = i * 4 + 3;
|
|
|
|
}
|
2011-12-25 22:50:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-02-22 07:32:34 +00:00
|
|
|
glsl_R_ReadPointFile_f (void)
|
2012-01-19 01:38:05 +00:00
|
|
|
{
|
|
|
|
const char *name;
|
|
|
|
char *mapname;
|
2021-12-18 16:21:39 +00:00
|
|
|
int c;
|
2012-01-19 01:38:05 +00:00
|
|
|
QFile *f;
|
|
|
|
|
2021-03-09 14:52:40 +00:00
|
|
|
mapname = strdup (r_worldentity.renderer.model->path);
|
2012-01-19 01:38:05 +00:00
|
|
|
if (!mapname)
|
|
|
|
Sys_Error ("Can't duplicate mapname!");
|
|
|
|
QFS_StripExtension (mapname, mapname);
|
|
|
|
|
2021-01-31 07:01:20 +00:00
|
|
|
name = va (0, "%s.pts", mapname);
|
2012-01-19 01:38:05 +00:00
|
|
|
free (mapname);
|
|
|
|
|
2014-01-23 02:57:57 +00:00
|
|
|
f = QFS_FOpenFile (name);
|
2012-01-19 01:38:05 +00:00
|
|
|
if (!f) {
|
|
|
|
Sys_Printf ("couldn't open %s\n", name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_dev, "Reading %s...\n", name);
|
2012-01-19 01:38:05 +00:00
|
|
|
c = 0;
|
2021-12-18 16:21:39 +00:00
|
|
|
vec4f_t zero = {};
|
2012-01-19 01:38:05 +00:00
|
|
|
for (;;) {
|
|
|
|
char buf[64];
|
2021-12-18 16:21:39 +00:00
|
|
|
vec4f_t org = { 0, 0, 0, 1 };
|
2012-01-19 01:38:05 +00:00
|
|
|
|
|
|
|
Qgets (f, buf, sizeof (buf));
|
2021-12-18 16:21:39 +00:00
|
|
|
int r = sscanf (buf, "%f %f %f\n", &org[0], &org[1], &org[2]);
|
2012-01-19 01:38:05 +00:00
|
|
|
if (r != 3)
|
|
|
|
break;
|
|
|
|
c++;
|
|
|
|
|
|
|
|
if (numparticles >= r_maxparticles) {
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_dev, "Not enough free particles\n");
|
2012-01-19 01:38:05 +00:00
|
|
|
break;
|
|
|
|
} else {
|
2021-12-18 16:21:39 +00:00
|
|
|
particle_new (pt_static, part_tex_dot, org, 1.5, zero,
|
2012-01-19 01:38:05 +00:00
|
|
|
99999, (-c) & 15, 1.0, 0.0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Qclose (f);
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_dev, "%i points read\n", c);
|
2012-01-19 01:38:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-12-18 16:21:39 +00:00
|
|
|
R_ParticleExplosion_QF (vec4f_t org)
|
2011-12-25 22:50:05 +00:00
|
|
|
{
|
2012-01-19 01:38:05 +00:00
|
|
|
// R_NewExplosion (org);
|
|
|
|
if (numparticles >= r_maxparticles)
|
|
|
|
return;
|
|
|
|
particle_new_random (pt_smokecloud, part_tex_smoke, org, 4, 30, 8,
|
2021-12-18 16:21:39 +00:00
|
|
|
5.0, (mtwist_rand (&mt) & 7) + 8,
|
2012-01-19 01:38:05 +00:00
|
|
|
0.5 + qfrandom (0.25), 0.0);
|
2011-12-25 22:50:05 +00:00
|
|
|
}
|
|
|
|
|
2012-01-19 01:38:05 +00:00
|
|
|
static void
|
2021-12-18 16:21:39 +00:00
|
|
|
R_ParticleExplosion2_QF (vec4f_t org, int colorStart, int colorLength)
|
2011-12-25 22:50:05 +00:00
|
|
|
{
|
2012-01-19 01:38:05 +00:00
|
|
|
unsigned int i, j = 512;
|
|
|
|
|
|
|
|
if (numparticles >= r_maxparticles)
|
|
|
|
return;
|
|
|
|
else if (numparticles + j >= r_maxparticles)
|
|
|
|
j = r_maxparticles - numparticles;
|
|
|
|
|
|
|
|
for (i = 0; i < j; i++) {
|
2012-05-21 23:23:22 +00:00
|
|
|
particle_new_random (pt_blob, part_tex_dot, org, 16, 2, 256,
|
2021-12-18 16:21:39 +00:00
|
|
|
0.3,
|
2012-02-22 12:53:17 +00:00
|
|
|
colorStart + (i % colorLength), 1.0, 0.0);
|
2012-01-19 01:38:05 +00:00
|
|
|
}
|
2011-12-25 22:50:05 +00:00
|
|
|
}
|
|
|
|
|
2012-01-19 01:38:05 +00:00
|
|
|
static void
|
2021-12-18 16:21:39 +00:00
|
|
|
R_BlobExplosion_QF (vec4f_t org)
|
2011-12-25 22:50:05 +00:00
|
|
|
{
|
2012-01-19 01:38:05 +00:00
|
|
|
unsigned int i;
|
|
|
|
unsigned int j = 1024;
|
|
|
|
|
|
|
|
if (numparticles >= r_maxparticles)
|
|
|
|
return;
|
|
|
|
else if (numparticles + j >= r_maxparticles)
|
|
|
|
j = r_maxparticles - numparticles;
|
|
|
|
|
|
|
|
for (i = 0; i < j >> 1; i++) {
|
|
|
|
particle_new_random (pt_blob, part_tex_dot, org, 12, 2, 256,
|
2021-12-18 16:21:39 +00:00
|
|
|
1.0 + (mtwist_rand (&mt) & 7) * 0.05,
|
2012-01-19 01:38:05 +00:00
|
|
|
66 + i % 6, 1.0, 0.0);
|
|
|
|
}
|
|
|
|
for (i = 0; i < j / 2; i++) {
|
|
|
|
particle_new_random (pt_blob2, part_tex_dot, org, 12, 2, 256,
|
2021-12-18 16:21:39 +00:00
|
|
|
1.0 + (mtwist_rand (&mt) & 7) * 0.05,
|
2012-01-19 01:38:05 +00:00
|
|
|
150 + i % 6, 1.0, 0.0);
|
|
|
|
}
|
2011-12-25 22:50:05 +00:00
|
|
|
}
|
|
|
|
|
2012-01-19 01:38:05 +00:00
|
|
|
static inline void
|
2021-12-18 16:21:39 +00:00
|
|
|
R_RunSparkEffect_QF (vec4f_t org, int count, int ofuzz)
|
2011-12-25 22:50:05 +00:00
|
|
|
{
|
2021-12-18 16:21:39 +00:00
|
|
|
if (!r_particles->int_val)
|
2012-01-19 01:38:05 +00:00
|
|
|
return;
|
2021-12-18 16:21:39 +00:00
|
|
|
|
|
|
|
vec4f_t zero = {};
|
2012-01-19 01:38:05 +00:00
|
|
|
particle_new (pt_smokecloud, part_tex_smoke, org, ofuzz * 0.08,
|
2021-12-18 16:21:39 +00:00
|
|
|
zero, 9, 12 + (mtwist_rand (&mt) & 3),
|
2012-01-19 01:38:05 +00:00
|
|
|
0.25 + qfrandom (0.125), 0.0);
|
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
if (count > 0) {
|
2012-01-19 01:38:05 +00:00
|
|
|
int orgfuzz = ofuzz * 3 / 4;
|
|
|
|
if (orgfuzz < 1)
|
|
|
|
orgfuzz = 1;
|
|
|
|
|
|
|
|
while (count--) {
|
2013-01-21 11:06:54 +00:00
|
|
|
int color = mtwist_rand (&mt) & 7;
|
2012-01-19 01:38:05 +00:00
|
|
|
|
|
|
|
particle_new_random (pt_fallfadespark, part_tex_dot, org, orgfuzz,
|
2021-12-18 16:21:39 +00:00
|
|
|
0.7, 96, 5.0, 0, 1.0, color);
|
2012-01-19 01:38:05 +00:00
|
|
|
}
|
|
|
|
}
|
2011-12-25 22:50:05 +00:00
|
|
|
}
|
|
|
|
|
2012-01-19 01:38:05 +00:00
|
|
|
static inline void
|
2021-12-18 16:21:39 +00:00
|
|
|
R_BloodPuff_QF (vec4f_t org, int count)
|
2011-12-25 22:50:05 +00:00
|
|
|
{
|
2021-12-18 16:21:39 +00:00
|
|
|
if (!r_particles->int_val)
|
2012-01-19 01:38:05 +00:00
|
|
|
return;
|
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
vec4f_t zero = {};
|
|
|
|
particle_new (pt_bloodcloud, part_tex_smoke, org, count / 5, zero,
|
|
|
|
99.0, 70 + (mtwist_rand (&mt) & 3), 0.5, 0.0);
|
2011-12-25 22:50:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-12-18 16:21:39 +00:00
|
|
|
R_BloodPuffEffect_QF (vec4f_t org, int count)
|
2011-12-25 22:50:05 +00:00
|
|
|
{
|
2012-01-19 01:38:05 +00:00
|
|
|
R_BloodPuff_QF (org, count);
|
2011-12-25 22:50:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-12-18 16:21:39 +00:00
|
|
|
R_GunshotEffect_QF (vec4f_t org, int count)
|
2011-12-25 22:50:05 +00:00
|
|
|
{
|
2012-01-19 01:38:05 +00:00
|
|
|
int scale = 16;
|
|
|
|
|
|
|
|
scale += count / 15;
|
|
|
|
R_RunSparkEffect_QF (org, count >> 1, scale);
|
2011-12-25 22:50:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-12-18 16:21:39 +00:00
|
|
|
R_LightningBloodEffect_QF (vec4f_t org)
|
2011-12-25 22:50:05 +00:00
|
|
|
{
|
2021-12-18 16:21:39 +00:00
|
|
|
if (!r_particles->int_val)
|
|
|
|
return;
|
2012-01-19 01:38:05 +00:00
|
|
|
|
|
|
|
R_BloodPuff_QF (org, 50);
|
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
vec4f_t zero = {};
|
|
|
|
particle_new (pt_smokecloud, part_tex_smoke, org, 3.0, zero,
|
|
|
|
9.0, 12 + (mtwist_rand (&mt) & 3),
|
2012-01-19 01:38:05 +00:00
|
|
|
0.25 + qfrandom (0.125), 0.0);
|
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
for (int count = 7; count-- > 0; ) {
|
2012-01-19 01:38:05 +00:00
|
|
|
particle_new_random (pt_fallfade, part_tex_spark, org, 12, 2.0, 128,
|
2021-12-18 16:21:39 +00:00
|
|
|
5.0, 244 + (count % 3), 1.0, 0.0);
|
|
|
|
}
|
2011-12-25 22:50:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-12-18 16:21:39 +00:00
|
|
|
R_RunParticleEffect_QF (vec4f_t org, vec4f_t dir, int color,
|
2012-01-19 01:38:05 +00:00
|
|
|
int count)
|
2011-12-25 22:50:05 +00:00
|
|
|
{
|
2021-12-18 16:21:39 +00:00
|
|
|
if (!r_particles->int_val)
|
2012-01-19 01:38:05 +00:00
|
|
|
return;
|
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
float scale = pow (count, 0.23);
|
2012-01-19 01:38:05 +00:00
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
for (int i = 0; i < count; i++) {
|
2013-01-21 11:06:54 +00:00
|
|
|
int rnd = mtwist_rand (&mt);
|
2012-01-19 01:38:05 +00:00
|
|
|
|
|
|
|
// Note that ParseParticleEffect handles (dir * 15)
|
2021-12-18 16:21:39 +00:00
|
|
|
particle_new (pt_grav, part_tex_dot, org + scale * roffs (16), 1.5,
|
|
|
|
dir, 0.1 * (i % 5),
|
2012-01-19 01:38:05 +00:00
|
|
|
(color & ~7) + (rnd & 7), 1.0, 0.0);
|
|
|
|
}
|
2011-12-25 22:50:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-12-18 16:21:39 +00:00
|
|
|
R_SpikeEffect_QF (vec4f_t org)
|
2011-12-25 22:50:05 +00:00
|
|
|
{
|
2012-01-19 01:38:05 +00:00
|
|
|
R_RunSparkEffect_QF (org, 5, 8);
|
2011-12-25 22:50:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-12-18 16:21:39 +00:00
|
|
|
R_SuperSpikeEffect_QF (vec4f_t org)
|
2011-12-25 22:50:05 +00:00
|
|
|
{
|
2012-01-19 01:38:05 +00:00
|
|
|
R_RunSparkEffect_QF (org, 10, 8);
|
2011-12-25 22:50:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-12-18 16:21:39 +00:00
|
|
|
R_KnightSpikeEffect_QF (vec4f_t org)
|
2011-12-25 22:50:05 +00:00
|
|
|
{
|
2021-12-18 16:21:39 +00:00
|
|
|
if (!r_particles->int_val)
|
2012-01-19 01:38:05 +00:00
|
|
|
return;
|
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
vec4f_t zero = {};
|
|
|
|
particle_new (pt_smokecloud, part_tex_smoke, org, 1.0, zero,
|
|
|
|
9.0, 234, 0.25 + qfrandom (0.125), 0.0);
|
|
|
|
|
|
|
|
for (int count = 10; count-- > 0; ) {
|
2012-01-19 01:38:05 +00:00
|
|
|
particle_new_random (pt_fallfade, part_tex_dot, org, 6, 0.7, 96,
|
2021-12-18 16:21:39 +00:00
|
|
|
5.0, 234, 1.0, 0.0);
|
|
|
|
}
|
2011-12-25 22:50:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-12-18 16:21:39 +00:00
|
|
|
R_WizSpikeEffect_QF (vec4f_t org)
|
2011-12-25 22:50:05 +00:00
|
|
|
{
|
2021-12-18 16:21:39 +00:00
|
|
|
if (!r_particles->int_val)
|
2012-01-19 01:38:05 +00:00
|
|
|
return;
|
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
vec4f_t zero = {};
|
|
|
|
particle_new (pt_smokecloud, part_tex_smoke, org, 2.0, zero,
|
|
|
|
9.0, 63, 0.25 + qfrandom (0.125), 0.0);
|
|
|
|
|
|
|
|
for (int count = 15; count-- > 0; ) {
|
2012-01-19 01:38:05 +00:00
|
|
|
particle_new_random (pt_fallfade, part_tex_dot, org, 12, 0.7, 96,
|
2021-12-18 16:21:39 +00:00
|
|
|
5.0, 63, 1.0, 0.0);
|
|
|
|
}
|
2011-12-25 22:50:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-12-18 16:21:39 +00:00
|
|
|
R_LavaSplash_QF (vec4f_t org)
|
2011-12-25 22:50:05 +00:00
|
|
|
{
|
2021-12-18 16:21:39 +00:00
|
|
|
if (!r_particles->int_val)
|
2012-01-19 01:38:05 +00:00
|
|
|
return;
|
2021-12-18 16:21:39 +00:00
|
|
|
|
|
|
|
for (int i = -16; i < 16; i++) {
|
|
|
|
for (int j = -16; j < 16; j++) {
|
|
|
|
uint32_t rnd = mtwist_rand (&mt);
|
|
|
|
float vel = 50.0 + 0.5 * (mtwist_rand (&mt) & 127);
|
|
|
|
vec4f_t dir = {
|
|
|
|
j * 8 + (rnd & 7),
|
|
|
|
i * 8 + ((rnd >> 6) & 7),
|
|
|
|
256,
|
|
|
|
0
|
|
|
|
};
|
|
|
|
vec4f_t offs = { dir[0], dir[1], ((rnd >> 9) & 63), 0 };
|
|
|
|
dir = normalf (dir);
|
|
|
|
particle_new (pt_grav, part_tex_dot, org + offs, 3, vel * dir,
|
|
|
|
2.0 + ((rnd >> 7) & 31) * 0.02,
|
2012-01-19 01:38:05 +00:00
|
|
|
224 + ((rnd >> 12) & 7), 0.75, 0.0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-12-18 16:21:39 +00:00
|
|
|
R_TeleportSplash_QF (vec4f_t org)
|
2012-01-19 01:38:05 +00:00
|
|
|
{
|
2021-12-18 16:21:39 +00:00
|
|
|
if (!r_particles->int_val)
|
2012-01-19 01:38:05 +00:00
|
|
|
return;
|
2021-12-18 16:21:39 +00:00
|
|
|
|
|
|
|
for (int k = -24; k < 32; k += 4) {
|
|
|
|
for (int i = -16; i < 16; i += 4) {
|
|
|
|
for (int j = -16; j < 16; j += 4) {
|
|
|
|
uint32_t rnd = mtwist_rand (&mt);
|
|
|
|
float vel = 50 + ((rnd >> 6) & 63);
|
|
|
|
vec4f_t dir = normalf ((vec4f_t) { j, i, k, 0 } * 8);
|
|
|
|
vec4f_t offs = {
|
|
|
|
i + (rnd & 3),
|
|
|
|
j + ((rnd >> 2) & 3),
|
|
|
|
k + ((rnd >> 4) & 3),
|
|
|
|
0
|
|
|
|
};
|
|
|
|
particle_new (pt_grav, part_tex_spark, org + offs, 0.6,
|
|
|
|
vel * dir,
|
|
|
|
(0.2 + (mtwist_rand (&mt) & 15) * 0.01),
|
2012-01-19 01:38:05 +00:00
|
|
|
(7 + ((rnd >> 12) & 7)), 1.0, 0.0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-12-18 16:21:39 +00:00
|
|
|
R_RocketTrail_QF (vec4f_t start, vec4f_t end)
|
2012-01-19 01:38:05 +00:00
|
|
|
{
|
|
|
|
if (numparticles >= r_maxparticles)
|
|
|
|
return;
|
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
vec4f_t vec = end - start;
|
|
|
|
float maxlen = magnitudef (vec)[0];
|
|
|
|
vec = normalf (vec);
|
|
|
|
|
|
|
|
float origlen = vr_data.frametime / maxlen;
|
|
|
|
vec4f_t step = (maxlen - 3) * vec;
|
|
|
|
|
|
|
|
float len = 0;
|
|
|
|
vec4f_t zero = {};
|
|
|
|
vec4f_t pos = start;
|
|
|
|
float pscale = 1.5 + qfrandom (1.5);
|
2012-01-19 01:38:05 +00:00
|
|
|
|
|
|
|
while (len < maxlen) {
|
2021-12-18 16:21:39 +00:00
|
|
|
float pscalenext = 1.5 + qfrandom (1.5);
|
|
|
|
float dist = (pscale + pscalenext) * 3.0;
|
|
|
|
float percent = len * origlen;
|
2012-01-19 01:38:05 +00:00
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
particle_new (pt_smoke, part_tex_smoke, pos,
|
|
|
|
pscale + percent * 4.0, zero,
|
|
|
|
2.0 - percent * 2.0,
|
2013-01-21 11:06:54 +00:00
|
|
|
12 + (mtwist_rand (&mt) & 3),
|
2012-01-19 01:38:05 +00:00
|
|
|
0.5 + qfrandom (0.125) - percent * 0.40, 0.0);
|
|
|
|
if (numparticles >= r_maxparticles)
|
|
|
|
break;
|
|
|
|
len += dist;
|
2021-12-18 16:21:39 +00:00
|
|
|
pos += step;
|
2012-01-19 01:38:05 +00:00
|
|
|
pscale = pscalenext;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-12-18 16:21:39 +00:00
|
|
|
R_GrenadeTrail_QF (vec4f_t start, vec4f_t end)
|
2012-01-19 01:38:05 +00:00
|
|
|
{
|
|
|
|
if (numparticles >= r_maxparticles)
|
|
|
|
return;
|
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
vec4f_t vec = end - start;
|
|
|
|
float maxlen = magnitudef (vec)[0];
|
|
|
|
vec = normalf (vec);
|
|
|
|
|
|
|
|
float origlen = vr_data.frametime / maxlen;
|
|
|
|
vec4f_t step = (maxlen - 3) * vec;
|
|
|
|
|
|
|
|
float len = 0;
|
|
|
|
vec4f_t zero = {};
|
|
|
|
vec4f_t pos = start;
|
|
|
|
float pscale = 6.0 + qfrandom (7.0);
|
2012-01-19 01:38:05 +00:00
|
|
|
|
|
|
|
while (len < maxlen) {
|
2021-12-18 16:21:39 +00:00
|
|
|
float pscalenext = 6.0 + qfrandom (7.0);
|
|
|
|
float dist = (pscale + pscalenext) * 2.0;
|
|
|
|
float percent = len * origlen;
|
2012-01-19 01:38:05 +00:00
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
particle_new (pt_smoke, part_tex_smoke, pos,
|
|
|
|
pscale + percent * 4.0, zero,
|
|
|
|
2.0 - percent * 2.0,
|
2013-01-21 11:06:54 +00:00
|
|
|
1 + (mtwist_rand (&mt) & 3),
|
2012-01-19 01:38:05 +00:00
|
|
|
0.625 + qfrandom (0.125) - percent * 0.40, 0.0);
|
|
|
|
if (numparticles >= r_maxparticles)
|
|
|
|
break;
|
|
|
|
len += dist;
|
2021-12-18 16:21:39 +00:00
|
|
|
pos += step;
|
2012-01-19 01:38:05 +00:00
|
|
|
pscale = pscalenext;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-12-18 16:21:39 +00:00
|
|
|
R_BloodTrail_QF (vec4f_t start, vec4f_t end)
|
2012-01-19 01:38:05 +00:00
|
|
|
{
|
|
|
|
if (numparticles >= r_maxparticles)
|
|
|
|
return;
|
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
vec4f_t vec = end - start;
|
|
|
|
float maxlen = magnitudef (vec)[0];
|
|
|
|
vec = normalf (vec);
|
2012-01-19 01:38:05 +00:00
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
float origlen = vr_data.frametime / maxlen;
|
|
|
|
vec4f_t step = (maxlen - 3) * vec;
|
2012-01-19 01:38:05 +00:00
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
float len = 0;
|
|
|
|
vec4f_t pos = start;
|
|
|
|
float pscale = 5.0 + qfrandom (10.0);
|
2012-01-19 01:38:05 +00:00
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
while (len < maxlen) {
|
|
|
|
float pscalenext = 5.0 + qfrandom (10.0);
|
|
|
|
float dist = (pscale + pscalenext) * 1.5;
|
|
|
|
float percent = len * origlen;
|
|
|
|
vec4f_t vel = roffs (24);
|
|
|
|
vel[2] -= percent * 40;
|
|
|
|
|
|
|
|
particle_new (pt_grav, part_tex_smoke, pos + roffs (4), pscale, vel,
|
|
|
|
2.0 - percent * 2.0,
|
2013-01-21 11:06:54 +00:00
|
|
|
68 + (mtwist_rand (&mt) & 3), 1.0, 0.0);
|
2012-01-19 01:38:05 +00:00
|
|
|
if (numparticles >= r_maxparticles)
|
|
|
|
break;
|
|
|
|
len += dist;
|
2021-12-18 16:21:39 +00:00
|
|
|
pos += step;
|
2012-01-19 01:38:05 +00:00
|
|
|
pscale = pscalenext;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-12-18 16:21:39 +00:00
|
|
|
R_SlightBloodTrail_QF (vec4f_t start, vec4f_t end)
|
2012-01-19 01:38:05 +00:00
|
|
|
{
|
|
|
|
if (numparticles >= r_maxparticles)
|
|
|
|
return;
|
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
vec4f_t vec = end - start;
|
|
|
|
float maxlen = magnitudef (vec)[0];
|
|
|
|
vec = normalf (vec);
|
2012-01-19 01:38:05 +00:00
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
float origlen = vr_data.frametime / maxlen;
|
|
|
|
vec4f_t step = (maxlen - 3) * vec;
|
2012-01-19 01:38:05 +00:00
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
float len = 0;
|
|
|
|
vec4f_t pos = start;
|
|
|
|
float pscale = 1.5 + qfrandom (7.5);
|
|
|
|
while (len < maxlen) {
|
|
|
|
float pscalenext = 1.5 + qfrandom (7.5);
|
|
|
|
float dist = (pscale + pscalenext) * 1.5;
|
|
|
|
float percent = len * origlen;
|
|
|
|
vec4f_t vel = roffs (12);
|
|
|
|
vel[2] -= percent * 40;
|
|
|
|
|
|
|
|
particle_new (pt_grav, part_tex_smoke, pos + roffs (4), pscale, vel,
|
|
|
|
1.5 - percent * 1.5,
|
2013-01-21 11:06:54 +00:00
|
|
|
68 + (mtwist_rand (&mt) & 3), 0.75, 0.0);
|
2012-01-19 01:38:05 +00:00
|
|
|
if (numparticles >= r_maxparticles)
|
|
|
|
break;
|
|
|
|
len += dist;
|
2021-12-18 16:21:39 +00:00
|
|
|
pos += step;
|
2012-01-19 01:38:05 +00:00
|
|
|
pscale = pscalenext;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-12-18 16:21:39 +00:00
|
|
|
R_WizTrail_QF (vec4f_t start, vec4f_t end)
|
2012-01-19 01:38:05 +00:00
|
|
|
{
|
2021-12-18 16:21:39 +00:00
|
|
|
float dist = 3.0;
|
2012-01-19 01:38:05 +00:00
|
|
|
|
|
|
|
if (numparticles >= r_maxparticles)
|
|
|
|
return;
|
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
vec4f_t vec = end - start;
|
|
|
|
float maxlen = magnitudef (vec)[0];
|
|
|
|
vec = normalf (vec);
|
2012-01-19 01:38:05 +00:00
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
float origlen = vr_data.frametime / maxlen;
|
|
|
|
vec4f_t step = (maxlen - dist) * vec;
|
2012-01-19 01:38:05 +00:00
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
float len = 0;
|
|
|
|
vec4f_t pos = start;
|
|
|
|
while (len < maxlen) {
|
|
|
|
static int tracercount;
|
|
|
|
float percent = len * origlen;
|
2012-01-19 01:38:05 +00:00
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
particle_new (pt_flame, part_tex_smoke, pos,
|
|
|
|
2.0 + qfrandom (1.0) - percent * 2.0,
|
|
|
|
30 * tracer_vel (tracercount++, vec),
|
|
|
|
0.5 - percent * 0.5,
|
2013-01-21 11:06:54 +00:00
|
|
|
52 + (mtwist_rand (&mt) & 4), 1.0 - percent * 0.125, 0.0);
|
2012-01-19 01:38:05 +00:00
|
|
|
if (numparticles >= r_maxparticles)
|
|
|
|
break;
|
|
|
|
len += dist;
|
2021-12-18 16:21:39 +00:00
|
|
|
pos += step;
|
2012-01-19 01:38:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-12-18 16:21:39 +00:00
|
|
|
R_FlameTrail_QF (vec4f_t start, vec4f_t end)
|
2012-01-19 01:38:05 +00:00
|
|
|
{
|
2021-12-18 16:21:39 +00:00
|
|
|
float dist = 3.0;
|
2012-01-19 01:38:05 +00:00
|
|
|
|
|
|
|
if (numparticles >= r_maxparticles)
|
|
|
|
return;
|
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
vec4f_t vec = end - start;
|
|
|
|
float maxlen = magnitudef (vec)[0];
|
|
|
|
vec = normalf (vec);
|
2012-01-19 01:38:05 +00:00
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
float origlen = vr_data.frametime / maxlen;
|
|
|
|
vec4f_t step = (maxlen - dist) * vec;
|
2012-01-19 01:38:05 +00:00
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
float len = 0;
|
|
|
|
vec4f_t pos = start;
|
|
|
|
while (len < maxlen) {
|
|
|
|
static int tracercount;
|
|
|
|
float percent = len * origlen;
|
2012-01-19 01:38:05 +00:00
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
particle_new (pt_flame, part_tex_smoke, pos,
|
|
|
|
2.0 + qfrandom (1.0) - percent * 2.0,
|
|
|
|
30 * tracer_vel (tracercount++, vec),
|
|
|
|
0.5 - percent * 0.5, 234,
|
2012-01-19 01:38:05 +00:00
|
|
|
1.0 - percent * 0.125, 0.0);
|
|
|
|
len += dist;
|
2021-12-18 16:21:39 +00:00
|
|
|
pos += step;
|
2012-01-19 01:38:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-12-18 16:21:39 +00:00
|
|
|
R_VoorTrail_QF (vec4f_t start, vec4f_t end)
|
2012-01-19 01:38:05 +00:00
|
|
|
{
|
2021-12-18 16:21:39 +00:00
|
|
|
float dist = 3.0;
|
2012-01-19 01:38:05 +00:00
|
|
|
|
|
|
|
if (numparticles >= r_maxparticles)
|
|
|
|
return;
|
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
vec4f_t vec = end - start;
|
|
|
|
float maxlen = magnitudef (vec)[0];
|
|
|
|
vec = normalf (vec);
|
2012-01-19 01:38:05 +00:00
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
float origlen = vr_data.frametime / maxlen;
|
|
|
|
vec4f_t step = (maxlen - dist) * vec;
|
2012-01-19 01:38:05 +00:00
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
float len = 0;
|
|
|
|
vec4f_t zero = {};
|
|
|
|
vec4f_t pos = start;
|
|
|
|
while (len < maxlen) {
|
|
|
|
float percent = len * origlen;
|
2012-01-19 01:38:05 +00:00
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
particle_new (pt_static, part_tex_dot, pos + roffs (16),
|
|
|
|
1.0 + qfrandom (1.0),
|
|
|
|
zero, 0.3 - percent * 0.3,
|
2013-01-21 11:06:54 +00:00
|
|
|
9 * 16 + 8 + (mtwist_rand (&mt) & 3), 1.0, 0.0);
|
2012-01-19 01:38:05 +00:00
|
|
|
len += dist;
|
2021-12-18 16:21:39 +00:00
|
|
|
pos += step;
|
2012-01-19 01:38:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-12-18 16:21:39 +00:00
|
|
|
R_GlowTrail_QF (vec4f_t start, vec4f_t end, int glow_color)
|
2012-01-19 01:38:05 +00:00
|
|
|
{
|
2021-12-18 16:21:39 +00:00
|
|
|
float dist = 3.0;
|
2012-01-19 01:38:05 +00:00
|
|
|
|
|
|
|
if (numparticles >= r_maxparticles)
|
|
|
|
return;
|
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
vec4f_t vec = end - start;
|
|
|
|
float maxlen = magnitudef (vec)[0];
|
|
|
|
vec = normalf (vec);
|
2012-01-19 01:38:05 +00:00
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
float origlen = vr_data.frametime / maxlen;
|
|
|
|
vec4f_t step = (maxlen - dist) * vec;
|
2012-01-19 01:38:05 +00:00
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
float len = 0;
|
|
|
|
vec4f_t zero = {};
|
|
|
|
vec4f_t pos = start;
|
|
|
|
while (len < maxlen) {
|
|
|
|
float percent = len * origlen;
|
2012-01-19 01:38:05 +00:00
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
particle_new (pt_smoke, part_tex_dot, pos + roffs (5), 1.0, zero,
|
|
|
|
2.0 - percent * 0.2, glow_color, 1.0, 0.0);
|
2012-01-19 01:38:05 +00:00
|
|
|
if (numparticles >= r_maxparticles)
|
|
|
|
break;
|
|
|
|
len += dist;
|
2021-12-18 16:21:39 +00:00
|
|
|
pos += step;
|
2012-01-19 01:38:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-12-18 16:21:39 +00:00
|
|
|
R_ParticleExplosion_EE (vec4f_t org)
|
2012-01-19 01:38:05 +00:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
R_NewExplosion (org);
|
|
|
|
*/
|
|
|
|
if (numparticles >= r_maxparticles)
|
|
|
|
return;
|
|
|
|
particle_new_random (pt_smokecloud, part_tex_smoke, org, 4, 30, 8,
|
2021-12-18 16:21:39 +00:00
|
|
|
5.0, mtwist_rand (&mt) & 255,
|
2012-01-19 01:38:05 +00:00
|
|
|
0.5 + qfrandom (0.25), 0.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-12-18 16:21:39 +00:00
|
|
|
R_TeleportSplash_EE (vec4f_t org)
|
2012-01-19 01:38:05 +00:00
|
|
|
{
|
2021-12-18 16:21:39 +00:00
|
|
|
if (!r_particles->int_val)
|
2012-01-19 01:38:05 +00:00
|
|
|
return;
|
2021-12-18 16:21:39 +00:00
|
|
|
|
|
|
|
for (int k = -24; k < 32; k += 4) {
|
|
|
|
for (int i = -16; i < 16; i += 4) {
|
|
|
|
for (int j = -16; j < 16; j += 4) {
|
|
|
|
uint32_t rnd = mtwist_rand (&mt);
|
|
|
|
float vel = 50 + ((rnd >> 6) & 63);
|
|
|
|
vec4f_t dir = normalf ((vec4f_t) { j, i, k, 0 } * 8);
|
|
|
|
vec4f_t offs = {
|
|
|
|
i + (rnd & 3),
|
|
|
|
j + ((rnd >> 2) & 3),
|
|
|
|
k + ((rnd >> 4) & 3),
|
|
|
|
0
|
|
|
|
};
|
|
|
|
particle_new (pt_grav, part_tex_spark, org + offs, 0.6,
|
|
|
|
vel * dir,
|
|
|
|
(0.2 + (mtwist_rand (&mt) & 15) * 0.01),
|
2012-01-19 01:38:05 +00:00
|
|
|
qfrandom (1.0), 1.0, 0.0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-12-18 16:21:39 +00:00
|
|
|
R_RocketTrail_EE (vec4f_t start, vec4f_t end)
|
2012-01-19 01:38:05 +00:00
|
|
|
{
|
|
|
|
if (numparticles >= r_maxparticles)
|
|
|
|
return;
|
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
vec4f_t vec = end - start;
|
|
|
|
float maxlen = magnitudef (vec)[0];
|
|
|
|
vec = normalf (vec);
|
|
|
|
|
|
|
|
float origlen = vr_data.frametime / maxlen;
|
|
|
|
float pscale = 1.5 + qfrandom (1.5);
|
2012-01-19 01:38:05 +00:00
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
float len = 0;
|
|
|
|
vec4f_t zero = {};
|
|
|
|
vec4f_t pos = start;
|
2012-01-19 01:38:05 +00:00
|
|
|
while (len < maxlen) {
|
2021-12-18 16:21:39 +00:00
|
|
|
float pscalenext = 1.5 + qfrandom (1.5);
|
|
|
|
float dist = (pscale + pscalenext) * 3.0;
|
|
|
|
float percent = len * origlen;
|
2012-01-19 01:38:05 +00:00
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
particle_new (pt_smoke, part_tex_smoke, pos,
|
|
|
|
pscale + percent * 4.0, zero,
|
|
|
|
2.0 - percent * 2.0,
|
2013-01-21 11:06:54 +00:00
|
|
|
mtwist_rand (&mt) & 255,
|
2012-01-19 01:38:05 +00:00
|
|
|
0.5 + qfrandom (0.125) - percent * 0.40, 0.0);
|
|
|
|
if (numparticles >= r_maxparticles)
|
|
|
|
break;
|
|
|
|
len += dist;
|
2021-12-18 16:21:39 +00:00
|
|
|
pos += len * vec;
|
2012-01-19 01:38:05 +00:00
|
|
|
pscale = pscalenext;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-12-18 16:21:39 +00:00
|
|
|
R_GrenadeTrail_EE (vec4f_t start, vec4f_t end)
|
2012-01-19 01:38:05 +00:00
|
|
|
{
|
2021-12-18 16:21:39 +00:00
|
|
|
if (!r_particles->int_val)
|
2012-01-19 01:38:05 +00:00
|
|
|
return;
|
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
vec4f_t vec = end - start;
|
|
|
|
float maxlen = magnitudef (vec)[0];
|
|
|
|
vec = normalf (vec);
|
|
|
|
|
|
|
|
float origlen = vr_data.frametime / maxlen;
|
|
|
|
float pscale = 6.0 + qfrandom (7.0);
|
2012-01-19 01:38:05 +00:00
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
float len = 0;
|
|
|
|
vec4f_t zero = {};
|
|
|
|
vec4f_t pos = start;
|
2012-01-19 01:38:05 +00:00
|
|
|
while (len < maxlen) {
|
2021-12-18 16:21:39 +00:00
|
|
|
float pscalenext = 6.0 + qfrandom (7.0);
|
|
|
|
float dist = (pscale + pscalenext) * 2.0;
|
|
|
|
float percent = len * origlen;
|
2012-01-19 01:38:05 +00:00
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
particle_new (pt_smoke, part_tex_smoke, pos,
|
|
|
|
pscale + percent * 4.0, zero,
|
|
|
|
2.0 - percent * 2.0,
|
2013-01-21 11:06:54 +00:00
|
|
|
mtwist_rand (&mt) & 255,
|
2012-01-19 01:38:05 +00:00
|
|
|
0.625 + qfrandom (0.125) - percent * 0.40, 0.0);
|
|
|
|
len += dist;
|
2021-12-18 16:21:39 +00:00
|
|
|
pos += len * vec;
|
2012-01-19 01:38:05 +00:00
|
|
|
pscale = pscalenext;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-12-18 16:21:39 +00:00
|
|
|
R_ParticleExplosion_ID (vec4f_t org)
|
2012-01-19 01:38:05 +00:00
|
|
|
{
|
2021-12-18 16:21:39 +00:00
|
|
|
if (!r_particles->int_val)
|
2012-01-19 01:38:05 +00:00
|
|
|
return;
|
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
for (int i = 0; i < 1024; i++) {
|
|
|
|
ptype_t type = i & 1 ? pt_explode2 : pt_explode;
|
|
|
|
add_particle (type, org + roffs (32), roffs (512), 5,
|
|
|
|
0, mtwist_rand (&mt) & 3);
|
2012-01-19 01:38:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-12-18 16:21:39 +00:00
|
|
|
R_BlobExplosion_ID (vec4f_t org)
|
2012-01-19 01:38:05 +00:00
|
|
|
{
|
2021-12-18 16:21:39 +00:00
|
|
|
if (!r_particles->int_val)
|
2012-01-19 01:38:05 +00:00
|
|
|
return;
|
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
for (int i = 0; i < 1024; i++) {
|
|
|
|
ptype_t type = i & 1 ? pt_blob : pt_blob2;
|
|
|
|
int color = i & 1 ? 66 : 150;
|
|
|
|
add_particle (type, org + roffs (32), roffs (512),
|
|
|
|
color + mtwist_rand (&mt) % 6,
|
|
|
|
(color & ~7) + (mtwist_rand (&mt) & 7), 0);
|
2012-01-19 01:38:05 +00:00
|
|
|
}
|
2011-12-25 22:50:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void // FIXME: inline?
|
2021-12-18 16:21:39 +00:00
|
|
|
R_RunParticleEffect_ID (vec4f_t org, vec4f_t dir, int color,
|
2012-01-19 01:38:05 +00:00
|
|
|
int count)
|
|
|
|
{
|
2021-12-18 16:21:39 +00:00
|
|
|
if (!r_particles->int_val)
|
2012-01-19 01:38:05 +00:00
|
|
|
return;
|
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
for (int i = 0; i < count; i++) {
|
|
|
|
add_particle (pt_slowgrav, org + roffs (16),
|
|
|
|
dir/* + roffs (300)*/,
|
|
|
|
0.1 * (mtwist_rand (&mt) % 5),
|
|
|
|
(color & ~7) + (mtwist_rand (&mt) & 7), 0);
|
2012-01-19 01:38:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-12-18 16:21:39 +00:00
|
|
|
R_BloodPuffEffect_ID (vec4f_t org, int count)
|
2011-12-25 22:50:05 +00:00
|
|
|
{
|
2021-12-18 16:21:39 +00:00
|
|
|
vec4f_t zero = {};
|
|
|
|
R_RunParticleEffect_ID (org, zero, 73, count);
|
2011-12-25 22:50:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-12-18 16:21:39 +00:00
|
|
|
R_GunshotEffect_ID (vec4f_t org, int count)
|
2011-12-25 22:50:05 +00:00
|
|
|
{
|
2021-12-18 16:21:39 +00:00
|
|
|
vec4f_t zero = {};
|
|
|
|
R_RunParticleEffect_ID (org, zero, 0, count);
|
2011-12-25 22:50:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-12-18 16:21:39 +00:00
|
|
|
R_LightningBloodEffect_ID (vec4f_t org)
|
2011-12-25 22:50:05 +00:00
|
|
|
{
|
2021-12-18 16:21:39 +00:00
|
|
|
vec4f_t zero = {};
|
|
|
|
R_RunParticleEffect_ID (org, zero, 225, 50);
|
2011-12-25 22:50:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-12-18 16:21:39 +00:00
|
|
|
R_SpikeEffect_ID (vec4f_t org)
|
2011-12-25 22:50:05 +00:00
|
|
|
{
|
2021-12-18 16:21:39 +00:00
|
|
|
vec4f_t zero = {};
|
|
|
|
R_RunParticleEffect_ID (org, zero, 0, 10);
|
2012-01-19 01:38:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-12-18 16:21:39 +00:00
|
|
|
R_SuperSpikeEffect_ID (vec4f_t org)
|
2012-01-19 01:38:05 +00:00
|
|
|
{
|
2021-12-18 16:21:39 +00:00
|
|
|
vec4f_t zero = {};
|
|
|
|
R_RunParticleEffect_ID (org, zero, 0, 20);
|
2012-01-19 01:38:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-12-18 16:21:39 +00:00
|
|
|
R_KnightSpikeEffect_ID (vec4f_t org)
|
2012-01-19 01:38:05 +00:00
|
|
|
{
|
2021-12-18 16:21:39 +00:00
|
|
|
vec4f_t zero = {};
|
|
|
|
R_RunParticleEffect_ID (org, zero, 226, 20);
|
2012-01-19 01:38:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-12-18 16:21:39 +00:00
|
|
|
R_WizSpikeEffect_ID (vec4f_t org)
|
2012-01-19 01:38:05 +00:00
|
|
|
{
|
2021-12-18 16:21:39 +00:00
|
|
|
vec4f_t zero = {};
|
|
|
|
R_RunParticleEffect_ID (org, zero, 20, 30);
|
2012-01-19 01:38:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-12-18 16:21:39 +00:00
|
|
|
R_LavaSplash_ID (vec4f_t org)
|
2012-01-19 01:38:05 +00:00
|
|
|
{
|
2021-12-18 16:21:39 +00:00
|
|
|
if (!r_particles->int_val)
|
2012-01-19 01:38:05 +00:00
|
|
|
return;
|
2021-12-18 16:21:39 +00:00
|
|
|
|
|
|
|
for (int i = -16; i < 16; i++) {
|
|
|
|
for (int j = -16; j < 16; j++) {
|
|
|
|
for (int k = 0; k < 1; k++) {
|
|
|
|
float vel = 50 + (mtwist_rand (&mt) & 63);
|
|
|
|
vec4f_t dir = {
|
|
|
|
j * 8 + (mtwist_rand (&mt) & 7),
|
|
|
|
i * 8 + (mtwist_rand (&mt) & 7),
|
|
|
|
256,
|
|
|
|
0
|
|
|
|
};
|
|
|
|
vec4f_t offs = {
|
|
|
|
dir[0],
|
|
|
|
dir[1],
|
|
|
|
(mtwist_rand (&mt) & 63),
|
|
|
|
0
|
|
|
|
};
|
|
|
|
dir = normalf (dir);
|
|
|
|
add_particle (pt_grav, org + offs, vel * dir,
|
|
|
|
2 + (mtwist_rand (&mt) & 31) * 0.02,
|
|
|
|
224 + (mtwist_rand (&mt) & 7), 0);
|
|
|
|
}
|
2012-01-19 01:38:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-12-18 16:21:39 +00:00
|
|
|
R_TeleportSplash_ID (vec4f_t org)
|
2012-01-19 01:38:05 +00:00
|
|
|
{
|
2021-12-18 16:21:39 +00:00
|
|
|
if (!r_particles->int_val)
|
2012-01-19 01:38:05 +00:00
|
|
|
return;
|
2021-12-18 16:21:39 +00:00
|
|
|
|
|
|
|
for (int i = -16; i < 16; i += 4) {
|
|
|
|
for (int j = -16; j < 16; j += 4) {
|
|
|
|
for (int k = -24; k < 32; k += 4) {
|
|
|
|
float vel = 50 + (mtwist_rand (&mt) & 63);
|
|
|
|
vec4f_t dir = normalf ((vec4f_t) { j, i, k, 0 } * 8);
|
|
|
|
vec4f_t offs = {
|
|
|
|
i + (mtwist_rand (&mt) & 3),
|
|
|
|
j + (mtwist_rand (&mt) & 3),
|
|
|
|
k + (mtwist_rand (&mt) & 3),
|
|
|
|
0
|
|
|
|
};
|
|
|
|
add_particle (pt_grav, org + offs, vel * dir,
|
|
|
|
0.2 + (mtwist_rand (&mt) & 7) * 0.02,
|
|
|
|
7 + (mtwist_rand (&mt) & 7), 0);
|
2012-01-19 01:38:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-12-18 16:21:39 +00:00
|
|
|
R_DarkFieldParticles_ID (vec4f_t org)
|
2012-01-19 01:38:05 +00:00
|
|
|
{
|
2021-12-18 16:21:39 +00:00
|
|
|
if (!r_particles->int_val)
|
2012-01-19 01:38:05 +00:00
|
|
|
return;
|
2021-12-18 16:21:39 +00:00
|
|
|
|
|
|
|
for (int i = -16; i < 16; i += 8) {
|
|
|
|
for (int j = -16; j < 16; j += 8) {
|
|
|
|
for (int k = 0; k < 32; k += 8) {
|
|
|
|
uint32_t rnd = mtwist_rand (&mt);
|
|
|
|
float vel = 50 + ((rnd >> 9) & 63);
|
|
|
|
vec4f_t dir = normalf ((vec4f_t) { j, i, k, 0 } * 8);
|
|
|
|
vec4f_t offs = {
|
|
|
|
i + ((rnd >> 3) & 3),
|
|
|
|
j + ((rnd >> 5) & 3),
|
|
|
|
k + ((rnd >> 7) & 3),
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
|
|
|
add_particle (pt_slowgrav, org + offs, vel * dir,
|
|
|
|
0.2 + (rnd & 7) * 0.02,
|
|
|
|
150 + mtwist_rand (&mt) % 6, 0);
|
|
|
|
}
|
2012-01-19 01:38:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
static vec4f_t velocities[NUMVERTEXNORMALS];
|
|
|
|
static vec4f_t normals[NUMVERTEXNORMALS] = {
|
|
|
|
#include "anorms.h"
|
|
|
|
};
|
2012-01-19 01:38:05 +00:00
|
|
|
|
|
|
|
static void
|
2021-12-18 16:21:39 +00:00
|
|
|
R_EntityParticles_ID (vec4f_t org)
|
2012-01-19 01:38:05 +00:00
|
|
|
{
|
2021-12-18 16:21:39 +00:00
|
|
|
int i;
|
|
|
|
float angle, sp, sy, cp, cy; // cr, sr
|
|
|
|
float beamlength = 16.0, dist = 64.0;
|
2012-01-19 01:38:05 +00:00
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
if (!r_particles->int_val)
|
2012-01-19 01:38:05 +00:00
|
|
|
return;
|
2021-03-19 11:18:45 +00:00
|
|
|
|
2013-09-27 14:08:33 +00:00
|
|
|
for (i = 0; i < NUMVERTEXNORMALS; i++) {
|
|
|
|
int k;
|
|
|
|
for (k = 0; k < 3; k++) {
|
2021-12-18 16:21:39 +00:00
|
|
|
velocities[i][k] = (mtwist_rand (&mt) & 255) * 0.01;
|
2013-09-27 14:08:33 +00:00
|
|
|
}
|
2012-01-19 01:38:05 +00:00
|
|
|
}
|
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
vec4f_t zero = {};
|
|
|
|
for (i = 0; i < NUMVERTEXNORMALS; i++) {
|
|
|
|
angle = vr_data.realtime * velocities[i][0];
|
2012-01-19 01:38:05 +00:00
|
|
|
cy = cos (angle);
|
|
|
|
sy = sin (angle);
|
2021-12-18 16:21:39 +00:00
|
|
|
angle = vr_data.realtime * velocities[i][1];
|
2012-01-19 01:38:05 +00:00
|
|
|
cp = cos (angle);
|
|
|
|
sp = sin (angle);
|
|
|
|
// Next 3 lines results aren't currently used, may be in future. --Despair
|
2012-02-14 08:28:09 +00:00
|
|
|
// angle = vr_data.realtime * avelocities[i][2];
|
2012-01-19 01:38:05 +00:00
|
|
|
// sr = sin (angle);
|
|
|
|
// cr = cos (angle);
|
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
vec4f_t forward = { cp * cy, cp * sy, -sp, 0 };
|
|
|
|
vec4f_t pos = org + normals[i] * dist + forward * beamlength;
|
|
|
|
//FIXME 0 velocity?
|
|
|
|
add_particle (pt_explode, pos, zero, 0.01, 0x6f, 0);
|
2012-01-19 01:38:05 +00:00
|
|
|
}
|
2011-12-25 22:50:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-12-18 16:21:39 +00:00
|
|
|
R_RocketTrail_ID (vec4f_t start, vec4f_t end)
|
2011-12-25 22:50:05 +00:00
|
|
|
{
|
2021-12-18 16:21:39 +00:00
|
|
|
if (!r_particles->int_val)
|
2012-01-19 01:38:05 +00:00
|
|
|
return;
|
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
vec4f_t vec = end - start;
|
|
|
|
float len = magnitudef (vec)[0];
|
|
|
|
vec = normalf (vec);
|
|
|
|
|
|
|
|
vec4f_t zero = {};
|
|
|
|
vec4f_t pos = start;
|
|
|
|
while (len > 0) {
|
|
|
|
len -= 3;
|
|
|
|
add_particle (pt_fire, pos + roffs (6), zero, 2,
|
|
|
|
0, (mtwist_rand (&mt) & 3));
|
|
|
|
pos += vec;
|
2012-01-19 01:38:05 +00:00
|
|
|
}
|
2011-12-25 22:50:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-12-18 16:21:39 +00:00
|
|
|
R_GrenadeTrail_ID (vec4f_t start, vec4f_t end)
|
2011-12-25 22:50:05 +00:00
|
|
|
{
|
2021-12-18 16:21:39 +00:00
|
|
|
if (!r_particles->int_val)
|
2012-01-19 01:38:05 +00:00
|
|
|
return;
|
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
vec4f_t vec = end - start;
|
|
|
|
float len = magnitudef (vec)[0];
|
|
|
|
vec = normalf (vec);
|
|
|
|
|
|
|
|
vec4f_t zero = {};
|
|
|
|
vec4f_t pos = start;
|
|
|
|
while (len > 0) {
|
|
|
|
len -= 3;
|
|
|
|
add_particle (pt_fire, pos + roffs (6), zero, 2,
|
|
|
|
0, (mtwist_rand (&mt) & 3) + 2);
|
|
|
|
pos += vec;
|
2012-01-19 01:38:05 +00:00
|
|
|
}
|
2011-12-25 22:50:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-12-18 16:21:39 +00:00
|
|
|
R_BloodTrail_ID (vec4f_t start, vec4f_t end)
|
2011-12-25 22:50:05 +00:00
|
|
|
{
|
2021-12-18 16:21:39 +00:00
|
|
|
if (!r_particles->int_val)
|
2012-01-19 01:38:05 +00:00
|
|
|
return;
|
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
vec4f_t vec = end - start;
|
|
|
|
float len = magnitudef (vec)[0];
|
|
|
|
vec = normalf (vec);
|
|
|
|
|
|
|
|
vec4f_t zero = {};
|
|
|
|
vec4f_t pos = start;
|
|
|
|
while (len > 0) {
|
|
|
|
len -= 3;
|
|
|
|
add_particle (pt_slowgrav, pos + roffs (6), zero, 2,
|
|
|
|
67 + (mtwist_rand (&mt) & 3), 0);
|
|
|
|
pos += vec;
|
2012-01-19 01:38:05 +00:00
|
|
|
}
|
2011-12-25 22:50:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-12-18 16:21:39 +00:00
|
|
|
R_SlightBloodTrail_ID (vec4f_t start, vec4f_t end)
|
2011-12-25 22:50:05 +00:00
|
|
|
{
|
2021-12-18 16:21:39 +00:00
|
|
|
if (!r_particles->int_val)
|
2012-01-19 01:38:05 +00:00
|
|
|
return;
|
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
vec4f_t vec = end - start;
|
|
|
|
float len = magnitudef (vec)[0];
|
|
|
|
vec = normalf (vec);
|
|
|
|
|
|
|
|
vec4f_t zero = {};
|
|
|
|
vec4f_t pos = start;
|
|
|
|
while (len > 0) {
|
|
|
|
len -= 6;
|
|
|
|
add_particle (pt_slowgrav, pos + roffs (6), zero, 2,
|
|
|
|
67 + (mtwist_rand (&mt) & 3), 0);
|
|
|
|
pos += vec;
|
2012-01-19 01:38:05 +00:00
|
|
|
}
|
2011-12-25 22:50:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-12-18 16:21:39 +00:00
|
|
|
R_WizTrail_ID (vec4f_t start, vec4f_t end)
|
2011-12-25 22:50:05 +00:00
|
|
|
{
|
2021-12-18 16:21:39 +00:00
|
|
|
if (!r_particles->int_val)
|
2012-01-19 01:38:05 +00:00
|
|
|
return;
|
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
vec4f_t vec = end - start;
|
|
|
|
float len = magnitudef (vec)[0];
|
|
|
|
vec = normalf (vec);
|
2012-01-19 01:38:05 +00:00
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
vec4f_t pos = start;
|
|
|
|
while (len > 0) {
|
|
|
|
static int tracercount;
|
|
|
|
len -= 3;
|
|
|
|
add_particle (pt_static, pos, 30 * tracer_vel (tracercount, vec), 0.5,
|
|
|
|
52 + ((tracercount & 4) << 1), 0);
|
2012-01-19 01:38:05 +00:00
|
|
|
tracercount++;
|
2021-12-18 16:21:39 +00:00
|
|
|
pos += vec;
|
2012-01-19 01:38:05 +00:00
|
|
|
}
|
2011-12-25 22:50:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-12-18 16:21:39 +00:00
|
|
|
R_FlameTrail_ID (vec4f_t start, vec4f_t end)
|
2011-12-25 22:50:05 +00:00
|
|
|
{
|
2021-12-18 16:21:39 +00:00
|
|
|
if (!r_particles->int_val)
|
2012-01-19 01:38:05 +00:00
|
|
|
return;
|
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
vec4f_t vec = end - start;
|
|
|
|
float len = magnitudef (vec)[0];
|
|
|
|
vec = normalf (vec);
|
2012-01-19 01:38:05 +00:00
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
vec4f_t pos = start;
|
|
|
|
while (len > 0) {
|
|
|
|
static int tracercount;
|
|
|
|
len -= 3;
|
|
|
|
add_particle (pt_static, pos, 30 * tracer_vel (tracercount, vec), 0.5,
|
|
|
|
230 + ((tracercount & 4) << 1), 0);
|
2012-01-19 01:38:05 +00:00
|
|
|
tracercount++;
|
2021-12-18 16:21:39 +00:00
|
|
|
pos += vec;
|
2012-01-19 01:38:05 +00:00
|
|
|
}
|
2011-12-25 22:50:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-12-18 16:21:39 +00:00
|
|
|
R_VoorTrail_ID (vec4f_t start, vec4f_t end)
|
2011-12-25 22:50:05 +00:00
|
|
|
{
|
2021-12-18 16:21:39 +00:00
|
|
|
if (!r_particles->int_val)
|
2012-01-19 01:38:05 +00:00
|
|
|
return;
|
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
vec4f_t vec = end - start;
|
|
|
|
float len = magnitudef (vec)[0];
|
|
|
|
vec = normalf (vec);
|
|
|
|
|
|
|
|
vec4f_t zero = {};
|
|
|
|
vec4f_t pos = start;
|
|
|
|
while (len > 0) {
|
|
|
|
len -= 3;
|
|
|
|
add_particle (pt_static, pos + roffs (16), zero, 0.3,
|
|
|
|
9 * 16 + 8 + (mtwist_rand (&mt) & 3), 0);
|
|
|
|
pos += vec;
|
2012-01-19 01:38:05 +00:00
|
|
|
}
|
2011-12-25 22:50:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-01-19 01:38:05 +00:00
|
|
|
draw_qf_particles (void)
|
2011-12-25 22:50:05 +00:00
|
|
|
{
|
2012-01-19 01:38:05 +00:00
|
|
|
byte *at;
|
2021-12-18 16:21:39 +00:00
|
|
|
int vacount;
|
2012-01-19 01:38:05 +00:00
|
|
|
float minparticledist, scale;
|
|
|
|
vec3_t up_scale, right_scale, up_right_scale, down_right_scale;
|
|
|
|
partvert_t *VA;
|
2021-03-09 14:52:40 +00:00
|
|
|
mat4f_t vp_mat;
|
2012-01-29 01:27:28 +00:00
|
|
|
quat_t fog;
|
2012-01-21 10:51:18 +00:00
|
|
|
|
2021-03-09 14:52:40 +00:00
|
|
|
mmulf (vp_mat, glsl_projection, glsl_view);
|
2012-01-21 10:51:18 +00:00
|
|
|
|
2012-02-22 07:48:57 +00:00
|
|
|
qfeglDepthMask (GL_FALSE);
|
|
|
|
qfeglUseProgram (quake_part.program);
|
|
|
|
qfeglEnableVertexAttribArray (quake_part.vertex.location);
|
|
|
|
qfeglEnableVertexAttribArray (quake_part.color.location);
|
|
|
|
qfeglEnableVertexAttribArray (quake_part.st.location);
|
2012-01-21 10:51:18 +00:00
|
|
|
|
2020-12-24 07:39:05 +00:00
|
|
|
glsl_Fog_GetColor (fog);
|
2012-02-22 07:32:34 +00:00
|
|
|
fog[3] = glsl_Fog_GetDensity () / 64.0;
|
2012-02-22 07:48:57 +00:00
|
|
|
qfeglUniform4fv (quake_part.fog.location, 1, fog);
|
2012-01-29 01:27:28 +00:00
|
|
|
|
2021-03-09 14:52:40 +00:00
|
|
|
qfeglUniformMatrix4fv (quake_part.mvp_matrix.location, 1, false,
|
|
|
|
&vp_mat[0][0]);
|
2012-01-21 10:51:18 +00:00
|
|
|
|
2012-02-22 07:48:57 +00:00
|
|
|
qfeglUniform1i (quake_part.texture.location, 0);
|
|
|
|
qfeglActiveTexture (GL_TEXTURE0 + 0);
|
|
|
|
qfeglEnable (GL_TEXTURE_2D);
|
|
|
|
qfeglBindTexture (GL_TEXTURE_2D, part_tex);
|
2012-01-19 01:38:05 +00:00
|
|
|
|
|
|
|
// LordHavoc: particles should not affect zbuffer
|
2012-02-22 07:48:57 +00:00
|
|
|
qfeglDepthMask (GL_FALSE);
|
2012-01-19 01:38:05 +00:00
|
|
|
|
2021-03-19 11:18:45 +00:00
|
|
|
minparticledist = DotProduct (r_refdef.viewposition, vpn) +
|
2012-01-19 01:38:05 +00:00
|
|
|
r_particles_nearclip->value;
|
|
|
|
|
|
|
|
vacount = 0;
|
|
|
|
VA = particleVertexArray;
|
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
vec4f_t gravity = {0, 0, -vr_data.gravity, 0};
|
|
|
|
|
|
|
|
unsigned j = 0;
|
|
|
|
for (unsigned i = 0; i < numparticles; i++) {
|
|
|
|
particle_t *p = &particles[i];
|
|
|
|
partparm_t *parm = &partparams[i];
|
|
|
|
|
|
|
|
if (p->live <= 0 || p->ramp >= parm->ramp_max
|
|
|
|
|| p->alpha <= 0 || p->scale <= 0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
const int *ramp = partramps[j];
|
|
|
|
if (i > j) {
|
|
|
|
particles[j] = *p;
|
|
|
|
partparams[j] = *parm;
|
|
|
|
partramps[j] = ramp;
|
|
|
|
}
|
|
|
|
p = &particles[j];
|
|
|
|
parm = &partparams[j];
|
|
|
|
j += 1;
|
|
|
|
|
2012-01-19 01:38:05 +00:00
|
|
|
// Don't render particles too close to us.
|
|
|
|
// Note, we must still do physics and such on them.
|
2021-12-18 16:21:39 +00:00
|
|
|
if (!(DotProduct (p->pos, vpn) < minparticledist)) {
|
|
|
|
at = (byte *) &d_8to24table[(byte) p->icolor];
|
2012-01-19 01:38:05 +00:00
|
|
|
VA[0].color[0] = at[0];
|
|
|
|
VA[0].color[1] = at[1];
|
|
|
|
VA[0].color[2] = at[2];
|
2021-12-18 16:21:39 +00:00
|
|
|
VA[0].color[3] = p->alpha * 255;
|
2012-01-19 01:38:05 +00:00
|
|
|
memcpy (VA[1].color, VA[0].color, sizeof (VA[0].color));
|
|
|
|
memcpy (VA[2].color, VA[0].color, sizeof (VA[0].color));
|
|
|
|
memcpy (VA[3].color, VA[0].color, sizeof (VA[0].color));
|
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
switch (p->tex) {
|
2012-01-19 01:38:05 +00:00
|
|
|
case part_tex_dot:
|
|
|
|
VA[0].texcoord[0] = 0.0;
|
|
|
|
VA[0].texcoord[1] = 0.0;
|
|
|
|
VA[1].texcoord[0] = 0.5;
|
|
|
|
VA[1].texcoord[1] = 0.0;
|
|
|
|
VA[2].texcoord[0] = 0.5;
|
|
|
|
VA[2].texcoord[1] = 0.5;
|
|
|
|
VA[3].texcoord[0] = 0.0;
|
|
|
|
VA[3].texcoord[1] = 0.5;
|
|
|
|
break;
|
|
|
|
case part_tex_spark:
|
|
|
|
VA[0].texcoord[0] = 0.5;
|
|
|
|
VA[0].texcoord[1] = 0.0;
|
|
|
|
VA[1].texcoord[0] = 1.0;
|
|
|
|
VA[1].texcoord[1] = 0.0;
|
|
|
|
VA[2].texcoord[0] = 1.0;
|
|
|
|
VA[2].texcoord[1] = 0.5;
|
|
|
|
VA[3].texcoord[0] = 0.5;
|
|
|
|
VA[3].texcoord[1] = 0.5;
|
|
|
|
break;
|
|
|
|
case part_tex_smoke:
|
|
|
|
VA[0].texcoord[0] = 0.0;
|
|
|
|
VA[0].texcoord[1] = 0.5;
|
|
|
|
VA[1].texcoord[0] = 0.5;
|
|
|
|
VA[1].texcoord[1] = 0.5;
|
|
|
|
VA[2].texcoord[0] = 0.5;
|
|
|
|
VA[2].texcoord[1] = 1.0;
|
|
|
|
VA[3].texcoord[0] = 0.0;
|
|
|
|
VA[3].texcoord[1] = 1.0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
scale = p->scale;
|
2012-01-19 01:38:05 +00:00
|
|
|
|
|
|
|
VectorScale (vup, scale, up_scale);
|
|
|
|
VectorScale (vright, scale, right_scale);
|
|
|
|
|
|
|
|
VectorAdd (right_scale, up_scale, up_right_scale);
|
|
|
|
VectorSubtract (right_scale, up_scale, down_right_scale);
|
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
VectorAdd (p->pos, down_right_scale, VA[0].vertex);
|
|
|
|
VectorSubtract (p->pos, up_right_scale, VA[1].vertex);
|
|
|
|
VectorSubtract (p->pos, down_right_scale, VA[2].vertex);
|
|
|
|
VectorAdd (p->pos, up_right_scale, VA[3].vertex);
|
2012-01-19 01:38:05 +00:00
|
|
|
|
|
|
|
VA += 4;
|
2012-01-21 11:16:18 +00:00
|
|
|
vacount += 6;
|
2012-01-19 01:38:05 +00:00
|
|
|
}
|
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
float dT = vr_data.frametime;
|
|
|
|
p->pos += dT * p->vel;
|
|
|
|
p->vel += dT * (p->vel * parm->drag + gravity * parm->drag[3]);
|
|
|
|
p->ramp += dT * parm->ramp;
|
|
|
|
p->live -= dT;
|
|
|
|
p->alpha -= dT * parm->alpha_rate;
|
|
|
|
p->scale += dT * parm->scale_rate;
|
|
|
|
if (ramp) {
|
|
|
|
p->icolor = ramp[(int)p->ramp];
|
2012-01-19 01:38:05 +00:00
|
|
|
}
|
|
|
|
}
|
2021-12-18 16:21:39 +00:00
|
|
|
numparticles = j;
|
|
|
|
|
2012-02-22 07:48:57 +00:00
|
|
|
qfeglVertexAttribPointer (quake_part.vertex.location, 3, GL_FLOAT,
|
2012-01-21 10:51:18 +00:00
|
|
|
0, sizeof (partvert_t),
|
|
|
|
&particleVertexArray[0].vertex);
|
2012-02-22 07:48:57 +00:00
|
|
|
qfeglVertexAttribPointer (quake_part.color.location, 4, GL_UNSIGNED_BYTE,
|
2012-01-21 10:51:18 +00:00
|
|
|
1, sizeof (partvert_t),
|
|
|
|
&particleVertexArray[0].color);
|
2012-02-22 07:48:57 +00:00
|
|
|
qfeglVertexAttribPointer (quake_part.st.location, 2, GL_FLOAT,
|
2012-01-21 10:51:18 +00:00
|
|
|
0, sizeof (partvert_t),
|
|
|
|
&particleVertexArray[0].texcoord);
|
2012-02-22 07:48:57 +00:00
|
|
|
qfeglDrawElements (GL_TRIANGLES, vacount, GL_UNSIGNED_SHORT, pVAindices);
|
2012-01-19 01:38:05 +00:00
|
|
|
|
2012-02-22 07:48:57 +00:00
|
|
|
qfeglDepthMask (GL_TRUE);
|
|
|
|
qfeglDisableVertexAttribArray (quake_part.vertex.location);
|
|
|
|
qfeglDisableVertexAttribArray (quake_part.color.location);
|
|
|
|
qfeglDisableVertexAttribArray (quake_part.st.location);
|
|
|
|
qfeglActiveTexture (GL_TEXTURE0 + 0);
|
|
|
|
qfeglDisable (GL_TEXTURE_2D);
|
2011-12-25 22:50:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-01-19 01:38:05 +00:00
|
|
|
draw_id_particles (void)
|
2011-12-25 22:50:05 +00:00
|
|
|
{
|
2021-12-18 16:21:39 +00:00
|
|
|
int vacount;
|
2012-01-19 01:38:05 +00:00
|
|
|
float minparticledist;
|
|
|
|
partvert_t *VA;
|
2021-03-09 14:52:40 +00:00
|
|
|
mat4f_t vp_mat;
|
2012-01-29 01:27:28 +00:00
|
|
|
quat_t fog;
|
2012-01-19 01:38:05 +00:00
|
|
|
|
2021-03-09 14:52:40 +00:00
|
|
|
mmulf (vp_mat, glsl_projection, glsl_view);
|
2012-01-19 01:38:05 +00:00
|
|
|
|
|
|
|
// LordHavoc: particles should not affect zbuffer
|
2012-02-22 07:48:57 +00:00
|
|
|
qfeglDepthMask (GL_FALSE);
|
|
|
|
qfeglUseProgram (quake_point.program);
|
|
|
|
qfeglEnableVertexAttribArray (quake_point.vertex.location);
|
|
|
|
qfeglEnableVertexAttribArray (quake_point.color.location);
|
2012-01-19 01:38:05 +00:00
|
|
|
|
2021-03-09 14:52:40 +00:00
|
|
|
qfeglUniformMatrix4fv (quake_point.mvp_matrix.location, 1, false,
|
|
|
|
&vp_mat[0][0]);
|
2012-01-19 01:38:05 +00:00
|
|
|
|
2020-12-24 07:39:05 +00:00
|
|
|
glsl_Fog_GetColor (fog);
|
2012-02-22 07:32:34 +00:00
|
|
|
fog[3] = glsl_Fog_GetDensity () / 64.0;
|
2012-02-22 07:48:57 +00:00
|
|
|
qfeglUniform4fv (quake_point.fog.location, 1, fog);
|
2012-01-29 01:27:28 +00:00
|
|
|
|
2012-02-22 07:48:57 +00:00
|
|
|
qfeglUniform1i (quake_point.palette.location, 0);
|
|
|
|
qfeglActiveTexture (GL_TEXTURE0 + 0);
|
|
|
|
qfeglEnable (GL_TEXTURE_2D);
|
|
|
|
qfeglBindTexture (GL_TEXTURE_2D, glsl_palette);
|
2012-01-19 01:38:05 +00:00
|
|
|
|
2021-03-19 11:18:45 +00:00
|
|
|
minparticledist = DotProduct (r_refdef.viewposition, vpn) +
|
2012-01-19 01:38:05 +00:00
|
|
|
r_particles_nearclip->value;
|
|
|
|
|
|
|
|
vacount = 0;
|
|
|
|
VA = particleVertexArray;
|
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
vec4f_t gravity = {0, 0, -vr_data.gravity, 0};
|
|
|
|
|
|
|
|
unsigned j = 0;
|
|
|
|
for (unsigned i = 0; i < numparticles; i++) {
|
|
|
|
particle_t *p = &particles[i];
|
|
|
|
partparm_t *parm = &partparams[i];
|
|
|
|
|
|
|
|
if (p->live <= 0 || p->ramp >= parm->ramp_max
|
|
|
|
|| p->alpha <= 0 || p->scale <= 0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
const int *ramp = partramps[j];
|
|
|
|
if (i > j) {
|
|
|
|
particles[j] = *p;
|
|
|
|
partparams[j] = *parm;
|
|
|
|
partramps[j] = ramp;
|
|
|
|
}
|
|
|
|
p = &particles[j];
|
|
|
|
parm = &partparams[j];
|
|
|
|
j += 1;
|
|
|
|
|
2012-01-19 01:38:05 +00:00
|
|
|
// Don't render particles too close to us.
|
|
|
|
// Note, we must still do physics and such on them.
|
2021-12-18 16:21:39 +00:00
|
|
|
if (!(DotProduct (p->pos, vpn) < minparticledist)) {
|
|
|
|
VA[0].color[0] = (byte) p->icolor;
|
|
|
|
VectorCopy (p->pos, VA[0].vertex);
|
2012-01-19 01:38:05 +00:00
|
|
|
VA++;
|
|
|
|
vacount++;
|
|
|
|
}
|
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
float dT = vr_data.frametime;
|
|
|
|
p->pos += dT * p->vel;
|
|
|
|
p->vel += dT * (p->vel * parm->drag + gravity * parm->drag[3]);
|
|
|
|
p->ramp += dT * parm->ramp;
|
|
|
|
p->live -= dT;
|
|
|
|
p->alpha -= dT * parm->alpha_rate;
|
|
|
|
p->scale += dT * parm->scale_rate;
|
|
|
|
if (ramp) {
|
|
|
|
p->icolor = ramp[(int)p->ramp];
|
2012-01-19 01:38:05 +00:00
|
|
|
}
|
|
|
|
}
|
2021-12-18 16:21:39 +00:00
|
|
|
numparticles = j;
|
|
|
|
|
2012-02-22 07:48:57 +00:00
|
|
|
qfeglVertexAttribPointer (quake_point.vertex.location, 3, GL_FLOAT,
|
2012-01-19 01:38:05 +00:00
|
|
|
0, sizeof (partvert_t),
|
|
|
|
&particleVertexArray[0].vertex);
|
2012-02-22 07:48:57 +00:00
|
|
|
qfeglVertexAttribPointer (quake_point.color.location, 1, GL_UNSIGNED_BYTE,
|
2012-01-21 07:16:48 +00:00
|
|
|
1, sizeof (partvert_t),
|
2012-01-19 01:38:05 +00:00
|
|
|
&particleVertexArray[0].color);
|
2012-02-22 07:48:57 +00:00
|
|
|
qfeglDrawArrays (GL_POINTS, 0, vacount);
|
2012-01-19 01:38:05 +00:00
|
|
|
|
2012-02-22 07:48:57 +00:00
|
|
|
qfeglDepthMask (GL_TRUE);
|
|
|
|
qfeglDisableVertexAttribArray (quake_point.vertex.location);
|
|
|
|
qfeglDisableVertexAttribArray (quake_point.color.location);
|
|
|
|
qfeglActiveTexture (GL_TEXTURE0 + 0);
|
|
|
|
qfeglDisable (GL_TEXTURE_2D);
|
2012-01-19 01:38:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-02-22 07:32:34 +00:00
|
|
|
glsl_R_DrawParticles (void)
|
2012-01-19 01:38:05 +00:00
|
|
|
{
|
2012-07-03 09:20:32 +00:00
|
|
|
if (!r_particles->int_val || !numparticles)
|
2012-01-19 01:38:05 +00:00
|
|
|
return;
|
2012-01-21 10:51:18 +00:00
|
|
|
if (r_particles_style->int_val) {
|
2012-01-19 01:38:05 +00:00
|
|
|
draw_qf_particles ();
|
|
|
|
} else {
|
|
|
|
draw_id_particles ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-18 03:46:06 +00:00
|
|
|
static void
|
2021-12-18 16:21:39 +00:00
|
|
|
glsl_R_Particle_New (ptype_t type, int texnum, vec4f_t org, float scale,
|
|
|
|
vec4f_t vel, float live, int color, float alpha,
|
2021-01-18 03:46:06 +00:00
|
|
|
float ramp)
|
|
|
|
{
|
|
|
|
if (numparticles >= r_maxparticles)
|
|
|
|
return;
|
2021-12-18 16:21:39 +00:00
|
|
|
particle_new (type, texnum, org, scale, vel, live, color, alpha, ramp);
|
2021-01-18 03:46:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-12-18 16:21:39 +00:00
|
|
|
glsl_R_Particle_NewRandom (ptype_t type, int texnum, vec4f_t org,
|
|
|
|
int org_fuzz, float scale, int vel_fuzz, float live,
|
2021-01-18 03:46:06 +00:00
|
|
|
int color, float alpha, float ramp)
|
|
|
|
{
|
|
|
|
if (numparticles >= r_maxparticles)
|
|
|
|
return;
|
2021-12-18 16:21:39 +00:00
|
|
|
particle_new_random (type, texnum, org, org_fuzz, scale, vel_fuzz, live,
|
2021-01-18 03:46:06 +00:00
|
|
|
color, alpha, ramp);
|
|
|
|
}
|
|
|
|
|
2012-02-14 08:28:09 +00:00
|
|
|
static vid_particle_funcs_t particles_QF = {
|
|
|
|
R_RocketTrail_QF,
|
|
|
|
R_GrenadeTrail_QF,
|
|
|
|
R_BloodTrail_QF,
|
|
|
|
R_SlightBloodTrail_QF,
|
|
|
|
R_WizTrail_QF,
|
|
|
|
R_FlameTrail_QF,
|
|
|
|
R_VoorTrail_QF,
|
|
|
|
R_GlowTrail_QF,
|
|
|
|
R_RunParticleEffect_QF,
|
|
|
|
R_BloodPuffEffect_QF,
|
|
|
|
R_GunshotEffect_QF,
|
|
|
|
R_LightningBloodEffect_QF,
|
|
|
|
R_SpikeEffect_QF,
|
|
|
|
R_KnightSpikeEffect_QF,
|
|
|
|
R_SuperSpikeEffect_QF,
|
|
|
|
R_WizSpikeEffect_QF,
|
|
|
|
R_BlobExplosion_QF,
|
|
|
|
R_ParticleExplosion_QF,
|
|
|
|
R_ParticleExplosion2_QF,
|
|
|
|
R_LavaSplash_QF,
|
|
|
|
R_TeleportSplash_QF,
|
|
|
|
R_DarkFieldParticles_ID,
|
|
|
|
R_EntityParticles_ID,
|
2012-07-06 01:18:05 +00:00
|
|
|
R_Particle_New,
|
|
|
|
R_Particle_NewRandom,
|
2012-02-14 08:28:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static vid_particle_funcs_t particles_ID = {
|
|
|
|
R_RocketTrail_ID,
|
|
|
|
R_GrenadeTrail_ID,
|
|
|
|
R_BloodTrail_ID,
|
|
|
|
R_SlightBloodTrail_ID,
|
|
|
|
R_WizTrail_ID,
|
|
|
|
R_FlameTrail_ID,
|
|
|
|
R_VoorTrail_ID,
|
|
|
|
R_GlowTrail_QF,
|
|
|
|
R_RunParticleEffect_ID,
|
|
|
|
R_BloodPuffEffect_ID,
|
|
|
|
R_GunshotEffect_ID,
|
|
|
|
R_LightningBloodEffect_ID,
|
|
|
|
R_SpikeEffect_ID,
|
|
|
|
R_KnightSpikeEffect_ID,
|
|
|
|
R_SuperSpikeEffect_ID,
|
|
|
|
R_WizSpikeEffect_ID,
|
|
|
|
R_BlobExplosion_ID,
|
|
|
|
R_ParticleExplosion_ID,
|
|
|
|
R_ParticleExplosion2_QF,
|
|
|
|
R_LavaSplash_ID,
|
|
|
|
R_TeleportSplash_ID,
|
|
|
|
R_DarkFieldParticles_ID,
|
|
|
|
R_EntityParticles_ID,
|
2012-07-06 01:18:05 +00:00
|
|
|
R_Particle_New,
|
|
|
|
R_Particle_NewRandom,
|
2012-02-14 08:28:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static vid_particle_funcs_t particles_QF_egg = {
|
|
|
|
R_RocketTrail_EE,
|
|
|
|
R_GrenadeTrail_EE,
|
|
|
|
R_BloodTrail_QF,
|
|
|
|
R_SlightBloodTrail_QF,
|
|
|
|
R_WizTrail_QF,
|
|
|
|
R_FlameTrail_QF,
|
|
|
|
R_VoorTrail_QF,
|
|
|
|
R_GlowTrail_QF,
|
|
|
|
R_RunParticleEffect_QF,
|
|
|
|
R_BloodPuffEffect_QF,
|
|
|
|
R_GunshotEffect_QF,
|
|
|
|
R_LightningBloodEffect_QF,
|
|
|
|
R_SpikeEffect_QF,
|
|
|
|
R_KnightSpikeEffect_QF,
|
|
|
|
R_SuperSpikeEffect_QF,
|
|
|
|
R_WizSpikeEffect_QF,
|
|
|
|
R_BlobExplosion_QF,
|
|
|
|
R_ParticleExplosion_EE,
|
|
|
|
R_ParticleExplosion2_QF,
|
|
|
|
R_LavaSplash_QF,
|
|
|
|
R_TeleportSplash_EE,
|
|
|
|
R_DarkFieldParticles_ID,
|
|
|
|
R_EntityParticles_ID,
|
2012-07-06 01:18:05 +00:00
|
|
|
R_Particle_New,
|
|
|
|
R_Particle_NewRandom,
|
2012-02-14 08:28:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static vid_particle_funcs_t particles_ID_egg = {
|
|
|
|
R_RocketTrail_EE,
|
|
|
|
R_GrenadeTrail_EE,
|
|
|
|
R_BloodTrail_ID,
|
|
|
|
R_SlightBloodTrail_ID,
|
|
|
|
R_WizTrail_ID,
|
|
|
|
R_FlameTrail_ID,
|
|
|
|
R_VoorTrail_ID,
|
|
|
|
R_GlowTrail_QF,
|
|
|
|
R_RunParticleEffect_ID,
|
|
|
|
R_BloodPuffEffect_ID,
|
|
|
|
R_GunshotEffect_ID,
|
|
|
|
R_LightningBloodEffect_ID,
|
|
|
|
R_SpikeEffect_ID,
|
|
|
|
R_KnightSpikeEffect_ID,
|
|
|
|
R_SuperSpikeEffect_ID,
|
|
|
|
R_WizSpikeEffect_ID,
|
|
|
|
R_BlobExplosion_ID,
|
|
|
|
R_ParticleExplosion_EE,
|
|
|
|
R_ParticleExplosion2_QF,
|
|
|
|
R_LavaSplash_ID,
|
|
|
|
R_TeleportSplash_EE,
|
|
|
|
R_DarkFieldParticles_ID,
|
|
|
|
R_EntityParticles_ID,
|
2012-07-06 01:18:05 +00:00
|
|
|
R_Particle_New,
|
|
|
|
R_Particle_NewRandom,
|
2012-02-14 08:28:09 +00:00
|
|
|
};
|
|
|
|
|
2012-01-19 01:38:05 +00:00
|
|
|
void
|
2012-02-22 07:32:34 +00:00
|
|
|
glsl_r_easter_eggs_f (cvar_t *var)
|
2012-01-19 01:38:05 +00:00
|
|
|
{
|
|
|
|
if (easter_eggs) {
|
|
|
|
if (easter_eggs->int_val) {
|
2012-02-14 08:28:09 +00:00
|
|
|
if (r_particles_style->int_val) {
|
2012-02-22 12:53:17 +00:00
|
|
|
glsl_vid_render_funcs.particles = &particles_QF_egg;
|
2012-02-14 08:28:09 +00:00
|
|
|
} else {
|
2012-02-22 12:53:17 +00:00
|
|
|
glsl_vid_render_funcs.particles = &particles_ID_egg;
|
2012-02-14 08:28:09 +00:00
|
|
|
}
|
2012-01-19 01:38:05 +00:00
|
|
|
} else if (r_particles_style) {
|
|
|
|
if (r_particles_style->int_val) {
|
2012-02-22 12:53:17 +00:00
|
|
|
glsl_vid_render_funcs.particles = &particles_QF;
|
2012-01-19 01:38:05 +00:00
|
|
|
} else {
|
2012-02-22 12:53:17 +00:00
|
|
|
glsl_vid_render_funcs.particles = &particles_ID;
|
2012-01-19 01:38:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-02-22 07:32:34 +00:00
|
|
|
glsl_r_particles_style_f (cvar_t *var)
|
2012-01-19 01:38:05 +00:00
|
|
|
{
|
2012-02-22 07:32:34 +00:00
|
|
|
glsl_r_easter_eggs_f (easter_eggs);
|
2011-12-25 22:50:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-01-19 01:38:05 +00:00
|
|
|
R_ParticleFunctionInit (void)
|
2011-12-25 22:50:05 +00:00
|
|
|
{
|
2012-02-22 07:32:34 +00:00
|
|
|
glsl_r_particles_style_f (r_particles_style);
|
|
|
|
glsl_r_easter_eggs_f (easter_eggs);
|
2011-12-25 22:50:05 +00:00
|
|
|
}
|
|
|
|
|
2012-04-11 13:45:23 +00:00
|
|
|
static void
|
|
|
|
r_particles_nearclip_f (cvar_t *var)
|
|
|
|
{
|
|
|
|
Cvar_SetValue (r_particles_nearclip, bound (r_nearclip->value, var->value,
|
|
|
|
r_farclip->value));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
r_particles_f (cvar_t *var)
|
|
|
|
{
|
|
|
|
R_MaxParticlesCheck (var, r_particles_max);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
r_particles_max_f (cvar_t *var)
|
|
|
|
{
|
|
|
|
R_MaxParticlesCheck (r_particles, var);
|
|
|
|
}
|
|
|
|
|
2012-02-18 13:28:42 +00:00
|
|
|
void
|
2012-02-22 07:32:34 +00:00
|
|
|
glsl_R_Particles_Init_Cvars (void)
|
2012-01-19 01:38:05 +00:00
|
|
|
{
|
2012-04-11 13:45:23 +00:00
|
|
|
easter_eggs = Cvar_Get ("easter_eggs", "0", CVAR_NONE, r_easter_eggs_f,
|
|
|
|
"Enables easter eggs.");
|
|
|
|
r_particles = Cvar_Get ("r_particles", "1", CVAR_ARCHIVE, r_particles_f,
|
|
|
|
"Toggles drawing of particles.");
|
|
|
|
r_particles_max = Cvar_Get ("r_particles_max", "2048", CVAR_ARCHIVE,
|
|
|
|
r_particles_max_f, "Maximum amount of "
|
|
|
|
"particles to display. No maximum, minimum "
|
|
|
|
"is 0.");
|
|
|
|
r_particles_nearclip = Cvar_Get ("r_particles_nearclip", "32",
|
|
|
|
CVAR_ARCHIVE, r_particles_nearclip_f,
|
|
|
|
"Distance of the particle near clipping "
|
|
|
|
"plane from the player.");
|
|
|
|
r_particles_style = Cvar_Get ("r_particles_style", "1", CVAR_ARCHIVE,
|
|
|
|
r_particles_style_f, "Sets particle style. "
|
|
|
|
"0 for Id, 1 for QF.");
|
2012-01-19 01:38:05 +00:00
|
|
|
R_ParticleFunctionInit ();
|
|
|
|
}
|