2001-02-19 21:15:25 +00:00
|
|
|
/*
|
2001-05-09 05:41:34 +00:00
|
|
|
sw_rpart.c
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2003-10-22 06:00:36 +00:00
|
|
|
Software renderer particle effects code.
|
2001-02-19 21:15:25 +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
|
|
|
|
|
2001-05-09 05:41:34 +00:00
|
|
|
#include <stdlib.h>
|
2010-08-24 07:20:07 +00:00
|
|
|
#ifdef HAVE_STRING_H
|
|
|
|
# include <string.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_STRINGS_H
|
|
|
|
# include <strings.h>
|
|
|
|
#endif
|
2001-05-09 05:41:34 +00:00
|
|
|
|
2001-05-31 03:41:35 +00:00
|
|
|
#include "QF/cvar.h"
|
2013-01-21 11:06:54 +00:00
|
|
|
#include "QF/mersenne.h"
|
2001-05-09 05:41:34 +00:00
|
|
|
#include "QF/qargs.h"
|
2002-08-27 07:16:28 +00:00
|
|
|
#include "QF/quakefs.h"
|
2001-05-29 19:43:15 +00:00
|
|
|
#include "QF/render.h"
|
2007-11-06 10:17:14 +00:00
|
|
|
#include "QF/sys.h"
|
2010-08-24 07:20:07 +00:00
|
|
|
#include "QF/va.h"
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2021-07-24 05:19:52 +00:00
|
|
|
#include "QF/scene/entity.h"
|
|
|
|
|
2001-08-16 23:14:46 +00:00
|
|
|
#include "compat.h"
|
2012-02-14 08:28:09 +00:00
|
|
|
#include "r_internal.h"
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2022-03-11 04:10:20 +00:00
|
|
|
vec3_t r_pright, r_pup, r_ppn, r_porigin;
|
|
|
|
|
2001-05-09 05:41:34 +00:00
|
|
|
void
|
2022-03-17 08:50:38 +00:00
|
|
|
R_DrawParticles (psystem_t *psystem)
|
2001-05-09 05:41:34 +00:00
|
|
|
{
|
2022-03-17 08:50:38 +00:00
|
|
|
if (!psystem->numparticles) {
|
|
|
|
return;
|
|
|
|
}
|
2001-05-09 05:41:34 +00:00
|
|
|
VectorScale (vright, xscaleshrink, r_pright);
|
|
|
|
VectorScale (vup, yscaleshrink, r_pup);
|
[renderer] Clean up use of vup/vright/vpn
This moves the common camera setup code out of the individual drivers,
and completely removes vup/vright/vpn from the non-software renderers.
This has highlighted the craziness around AngleVectors with it putting
+X forward, -Y right and +Z up. The main issue with this is it requires
a 90 degree pre-rotation about the Z axis to get the camera pointing in
the right direction, and that's for the native sw renderer (vulkan needs
a 90 degree pre-rotation about X, and gl and glsl need to invert an
axis, too), though at least it's just a matrix swizzle and vector
negation. However, it does mean the camera matrices can't be used
directly.
Also rename vpn to vfwd (still abbreviated, but fwd is much clearer in
meaning (to me, at least) than pn (plane normal, I guess, but which
way?)).
2022-03-14 00:34:24 +00:00
|
|
|
VectorCopy (vfwd, r_ppn);
|
|
|
|
VectorCopy (r_refdef.frame.position, r_porigin);
|
2001-05-09 05:41:34 +00:00
|
|
|
|
2022-03-17 08:50:38 +00:00
|
|
|
for (unsigned i = 0; i < psystem->numparticles; i++) {
|
|
|
|
particle_t *p = &psystem->particles[i];
|
2022-03-09 11:19:14 +00:00
|
|
|
D_DrawParticle (p);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
2001-12-11 22:37:30 +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);
|
|
|
|
}
|
|
|
|
|
2001-12-11 22:37:30 +00:00
|
|
|
void
|
|
|
|
R_Particles_Init_Cvars (void)
|
|
|
|
{
|
2012-04-11 13:45:23 +00:00
|
|
|
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.");
|
2001-12-11 22:37:30 +00:00
|
|
|
}
|
2021-12-19 05:47:25 +00:00
|
|
|
|
|
|
|
psystem_t * __attribute__((const))//FIXME
|
|
|
|
sw_ParticleSystem (void)
|
|
|
|
{
|
|
|
|
return &r_psystem;
|
|
|
|
}
|