2001-05-24 19:19:32 +00:00
|
|
|
/*
|
|
|
|
r_part.c
|
|
|
|
|
2003-10-22 06:00:36 +00:00
|
|
|
Interface for particles
|
2001-05-24 19:19:32 +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-09-22 02:37:45 +00:00
|
|
|
#include "QF/cvar.h"
|
2001-08-27 01:00:03 +00:00
|
|
|
#include "QF/qargs.h"
|
2001-05-29 19:43:15 +00:00
|
|
|
#include "QF/render.h"
|
2012-01-15 11:14:36 +00:00
|
|
|
#include "QF/sys.h"
|
2001-05-24 19:19:32 +00:00
|
|
|
|
2001-08-26 16:54:33 +00:00
|
|
|
#include "compat.h"
|
2012-02-14 08:28:09 +00:00
|
|
|
#include "r_internal.h"
|
2001-05-24 19:19:32 +00:00
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
unsigned int r_maxparticles, numparticles;
|
|
|
|
particle_t *particles;
|
|
|
|
partparm_t *partparams;
|
|
|
|
const int **partramps;
|
|
|
|
vec3_t r_pright, r_pup, r_ppn;
|
2001-09-22 02:37:45 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
R_MaxParticlesCheck
|
|
|
|
|
|
|
|
Misty-chan: Dynamically change the maximum amount of particles on the fly.
|
|
|
|
Thanks to a LOT of help from Taniwha, Deek, Mercury, Lordhavoc, and lots of
|
|
|
|
others.
|
|
|
|
*/
|
|
|
|
void
|
2001-12-03 08:55:46 +00:00
|
|
|
R_MaxParticlesCheck (cvar_t *r_particles, cvar_t *r_particles_max)
|
2001-09-22 02:37:45 +00:00
|
|
|
{
|
2021-12-18 16:21:39 +00:00
|
|
|
unsigned maxparticles = 0;
|
|
|
|
if (r_particles && r_particles->int_val) {
|
|
|
|
maxparticles = r_particles_max ? r_particles_max->int_val : 0;
|
|
|
|
}
|
2001-09-22 02:37:45 +00:00
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
if (r_maxparticles == maxparticles) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t size = sizeof (particle_t) + sizeof (partparm_t)
|
|
|
|
+ sizeof (int *);
|
2001-10-27 08:31:45 +00:00
|
|
|
|
2021-12-18 16:21:39 +00:00
|
|
|
if (particles) {
|
|
|
|
Sys_Free (particles, r_maxparticles * size);
|
|
|
|
particles = 0;
|
|
|
|
partparams = 0;
|
|
|
|
partramps = 0;
|
|
|
|
}
|
|
|
|
r_maxparticles = maxparticles;
|
2001-10-27 08:31:45 +00:00
|
|
|
|
|
|
|
if (r_maxparticles) {
|
2021-12-18 16:21:39 +00:00
|
|
|
particles = Sys_Alloc (r_maxparticles * size);
|
|
|
|
partparams = (partparm_t *) &particles[r_maxparticles];
|
|
|
|
partramps = (const int **) &partparams[r_maxparticles];
|
2001-10-27 08:31:45 +00:00
|
|
|
}
|
2021-12-19 04:08:39 +00:00
|
|
|
R_ClearParticles ();
|
2012-01-15 11:14:36 +00:00
|
|
|
}
|
|
|
|
|
2021-12-19 04:08:39 +00:00
|
|
|
void
|
|
|
|
R_ClearParticles (void)
|
2012-01-15 11:14:36 +00:00
|
|
|
{
|
2021-12-19 04:08:39 +00:00
|
|
|
numparticles = 0;
|
2012-01-15 11:14:36 +00:00
|
|
|
}
|