[particles] Merge particle spawning into client

After yesterday's crazy marathon editing all the particles files, and
starting to do another big change to them today, I realized that I
really do need to merge them down. All the actual spawning is now in the
client library (though particle insertion will need to be moved). GLSL
particle rendering is semi-broken in that it now does only points (until
I come up with a way to select between points and quads (probably a
context object, which I need anyway for Vulkan)).
This commit is contained in:
Bill Currie 2021-12-19 13:08:39 +09:00
parent 81a5e076ac
commit 8d2791752e
35 changed files with 1516 additions and 4175 deletions

View File

@ -60,10 +60,7 @@ typedef struct particlectx_s {
struct cvar_s;
struct vulkan_ctx_s;;
void Vulkan_ClearParticles (struct vulkan_ctx_s *ctx);
void Vulkan_InitParticles (struct vulkan_ctx_s *ctx);
void Vulkan_r_easter_eggs_f (struct cvar_s *var, struct vulkan_ctx_s *ctx);
void Vulkan_r_particles_style_f (struct cvar_s *var, struct vulkan_ctx_s *ctx);
struct r_particle_ctx_s *Vulkan_ParticleContext (struct vulkan_ctx_s *ctx);
void Vulkan_Particles_Init (struct vulkan_ctx_s *ctx);
void Vulkan_Particles_Shutdown (struct vulkan_ctx_s *ctx);
void Vulkan_DrawParticles (struct vulkan_ctx_s *ctx);

View File

@ -44,42 +44,6 @@ struct mod_sprite_ctx_s;
All video plugins must export these functions
*/
typedef struct vid_particle_funcs_s {
void (*R_RocketTrail) (vec4f_t start, vec4f_t end);
void (*R_GrenadeTrail) (vec4f_t start, vec4f_t end);
void (*R_BloodTrail) (vec4f_t start, vec4f_t end);
void (*R_SlightBloodTrail) (vec4f_t start, vec4f_t end);
void (*R_WizTrail) (vec4f_t start, vec4f_t end);
void (*R_FlameTrail) (vec4f_t start, vec4f_t end);
void (*R_VoorTrail) (vec4f_t start, vec4f_t end);
void (*R_GlowTrail) (vec4f_t start, vec4f_t end, int glow_color);
void (*R_RunParticleEffect) (vec4f_t org, vec4f_t dir, int color, int count);
void (*R_BloodPuffEffect) (vec4f_t org, int count);
void (*R_GunshotEffect) (vec4f_t org, int count);
void (*R_LightningBloodEffect) (vec4f_t org);
void (*R_SpikeEffect) (vec4f_t org);
void (*R_KnightSpikeEffect) (vec4f_t org);
void (*R_SuperSpikeEffect) (vec4f_t org);
void (*R_WizSpikeEffect) (vec4f_t org);
void (*R_BlobExplosion) (vec4f_t org);
void (*R_ParticleExplosion) (vec4f_t org);
void (*R_ParticleExplosion2) (vec4f_t org, int colorStart, int colorLength);
void (*R_LavaSplash) (vec4f_t org);
void (*R_TeleportSplash) (vec4f_t org);
void (*R_DarkFieldParticles) (vec4f_t org);
void (*R_EntityParticles) (vec4f_t org);
void (*R_Particle_New) (ptype_t type, int texnum, vec4f_t org,
float scale, vec4f_t vel, float die,
int color, float alpha, float ramp);
void (*R_Particle_NewRandom) (ptype_t type, int texnum, vec4f_t org,
int org_fuzz, float scale, int vel_fuzz,
float die, int color, float alpha,
float ramp);
} vid_particle_funcs_t;
typedef struct vid_model_funcs_s {
size_t texture_render_size;// size of renderer specific texture data
void (*Mod_LoadLighting) (model_t *mod, bsp_t *bsp);
@ -159,13 +123,8 @@ typedef struct vid_render_funcs_s {
void (*R_DecayLights) (double frametime);
void (*R_ViewChanged) (void);
void (*R_ClearParticles) (void);
void (*R_InitParticles) (void);
void (*SCR_ScreenShot_f) (void);
void (*r_easter_eggs_f) (struct cvar_s *var);
void (*r_particles_style_f) (struct cvar_s *var);
vid_particle_funcs_t *particles;
vid_model_funcs_t *model_funcs;
} vid_render_funcs_t;

View File

@ -54,6 +54,49 @@ typedef enum {
pt_flame
} ptype_t;
typedef enum {
part_tex_dot,
part_tex_spark,
part_tex_smoke,
} ptextype_t;
typedef struct particle_s particle_t;
// !!! if this is changed, it must be changed in d_ifacea.h too !!!
struct particle_s {
vec4f_t pos;
vec4f_t vel;
union {
struct {
int icolor;
int pad[2];
float alpha;
};
vec4f_t color;
};
ptextype_t tex;
float ramp;
float scale;
float live;
};
typedef struct partparm_s {
vec4f_t drag; // drag[3] is grav scale
float ramp;
float ramp_max;
float scale_rate;
float alpha_rate;
} partparm_t;
// FIXME these really shouldn't be global, but they speed up particle creation
extern unsigned int r_maxparticles;
extern unsigned int numparticles;
extern struct particle_s *particles;
extern struct partparm_s *partparams;
extern const int **partramps;
extern struct vid_render_funcs_s *r_funcs;
extern struct vid_render_data_s *r_data;

View File

@ -0,0 +1,74 @@
/*
particles.h
Client particles handling
Copyright (C) 2021 Bill Currie <bill@taniwha.org>
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
*/
#ifndef __client_particles_h_
#define __client_particles_h_
#include "QF/render.h"
typedef struct cl_particle_funcs_s {
void (*RocketTrail) (vec4f_t start, vec4f_t end);
void (*GrenadeTrail) (vec4f_t start, vec4f_t end);
void (*BloodTrail) (vec4f_t start, vec4f_t end);
void (*SlightBloodTrail) (vec4f_t start, vec4f_t end);
void (*WizTrail) (vec4f_t start, vec4f_t end);
void (*FlameTrail) (vec4f_t start, vec4f_t end);
void (*VoorTrail) (vec4f_t start, vec4f_t end);
void (*GlowTrail) (vec4f_t start, vec4f_t end, int glow_color);
void (*RunParticleEffect) (vec4f_t org, vec4f_t dir, int color, int count);
void (*BloodPuffEffect) (vec4f_t org, int count);
void (*GunshotEffect) (vec4f_t org, int count);
void (*LightningBloodEffect) (vec4f_t org);
void (*SpikeEffect) (vec4f_t org);
void (*KnightSpikeEffect) (vec4f_t org);
void (*SuperSpikeEffect) (vec4f_t org);
void (*WizSpikeEffect) (vec4f_t org);
void (*BlobExplosion) (vec4f_t org);
void (*ParticleExplosion) (vec4f_t org);
void (*ParticleExplosion2) (vec4f_t org, int colorStart, int colorLength);
void (*LavaSplash) (vec4f_t org);
void (*TeleportSplash) (vec4f_t org);
void (*DarkFieldParticles) (vec4f_t org);
void (*EntityParticles) (vec4f_t org);
void (*Particle_New) (ptype_t type, int texnum, vec4f_t org,
float scale, vec4f_t vel, float die,
int color, float alpha, float ramp);
void (*Particle_NewRandom) (ptype_t type, int texnum, vec4f_t org,
int org_fuzz, float scale, int vel_fuzz,
float die, int color, float alpha,
float ramp);
} cl_particle_funcs_t;
extern cl_particle_funcs_t *clp_funcs;
extern float cl_frametime;
extern float cl_realtime;
void CL_Particles_Init (void);
#endif // __client_particles_h_

View File

@ -56,45 +56,6 @@ typedef struct
float zi;
} emitpoint_t;
typedef enum {
part_tex_dot,
part_tex_spark,
part_tex_smoke,
} ptextype_t;
typedef struct particle_s particle_t;
// !!! if this is changed, it must be changed in d_ifacea.h too !!!
struct particle_s {
vec4f_t pos;
vec4f_t vel;
union {
struct {
int icolor;
int pad[2];
float alpha;
};
vec4f_t color;
};
ptextype_t tex;
float ramp;
float scale;
float live;
};
typedef struct partparm_s {
vec4f_t drag; // drag[3] is grav scale
float ramp;
float ramp_max;
float scale_rate;
float alpha_rate;
} partparm_t;
partparm_t R_ParticlePhysics (ptype_t type) __attribute__((pure));
const int *R_ParticleRamp (ptype_t type) __attribute__((pure));
#define PARTICLE_Z_CLIP 8.0
typedef struct polyvert_s {

View File

@ -1,9 +1,5 @@
#include "QF/mathlib.h"
extern struct cvar_s *easter_eggs;
extern void r_easter_eggs_f (struct cvar_s *var);
extern void r_particles_style_f (struct cvar_s *var);
extern void gl_overbright_f (struct cvar_s *cvar);
extern struct cvar_s *cl_crossx;
@ -80,7 +76,6 @@ extern struct cvar_s *r_numsurfs;
extern struct cvar_s *r_particles;
extern struct cvar_s *r_particles_max;
extern struct cvar_s *r_particles_nearclip;
extern struct cvar_s *r_particles_style;
extern struct cvar_s *r_reportedgeout;
extern struct cvar_s *r_reportsurfout;
extern struct cvar_s *r_shadows;

View File

@ -59,10 +59,4 @@ void R_MaxParticlesCheck (struct cvar_s *r_particles,
struct cvar_s *r_particles_max);
void R_InitSprites (void);
extern unsigned int r_maxparticles;
extern unsigned int numparticles;
extern struct particle_s *particles;
extern struct partparm_s *partparams;
extern const int **partramps;
#endif // _R_DYNAMIC_H

View File

@ -6,6 +6,7 @@ libs_client_libQFclient_la_SOURCES= \
libs/client/cl_effects.c \
libs/client/cl_entities.c \
libs/client/cl_input.c \
libs/client/cl_particles.c \
libs/client/cl_temp_entities.c \
libs/client/locs.c \
libs/client/old_keys.c

View File

@ -45,6 +45,7 @@
#include "client/entities.h"
#include "client/effects.h"
#include "client/particles.h"
void
CL_NewDlight (int key, vec4f_t org, int effects, byte glow_size,
@ -132,23 +133,21 @@ CL_ModelEffects (entity_t *ent, int num, int glow_color, double time)
VectorSet (0.9, 0.7, 0.0, dl->color);
dl->color[3] = 0.7;
}
r_funcs->particles->R_RocketTrail (old_origin, ent_origin);
clp_funcs->RocketTrail (old_origin, ent_origin);
} else if (model->flags & EF_GRENADE)
r_funcs->particles->R_GrenadeTrail (old_origin, ent_origin);
clp_funcs->GrenadeTrail (old_origin, ent_origin);
else if (model->flags & EF_GIB)
r_funcs->particles->R_BloodTrail (old_origin, ent_origin);
clp_funcs->BloodTrail (old_origin, ent_origin);
else if (model->flags & EF_ZOMGIB)
r_funcs->particles->R_SlightBloodTrail (old_origin, ent_origin);
clp_funcs->SlightBloodTrail (old_origin, ent_origin);
else if (model->flags & EF_TRACER)
r_funcs->particles->R_WizTrail (old_origin, ent_origin);
clp_funcs->WizTrail (old_origin, ent_origin);
else if (model->flags & EF_TRACER2)
r_funcs->particles->R_FlameTrail (old_origin, ent_origin);
clp_funcs->FlameTrail (old_origin, ent_origin);
else if (model->flags & EF_TRACER3)
r_funcs->particles->R_VoorTrail (old_origin, ent_origin);
clp_funcs->VoorTrail (old_origin, ent_origin);
else if (model->flags & EF_GLOWTRAIL)
if (r_funcs->particles->R_GlowTrail)
r_funcs->particles->R_GlowTrail (old_origin, ent_origin,
glow_color);
clp_funcs->GlowTrail (old_origin, ent_origin, glow_color);
}
void
@ -175,7 +174,7 @@ CL_EntityEffects (int num, entity_t *ent, entity_state_t *state, double time)
{
vec4f_t position = Transform_GetWorldPosition (ent->transform);
if (state->effects & EF_BRIGHTFIELD)
r_funcs->particles->R_EntityParticles (position);
clp_funcs->EntityParticles (position);
if (state->effects & EF_MUZZLEFLASH) {
vec4f_t fv = Transform_Forward (ent->transform);
CL_MuzzleFlash (position, fv, 16, num, time);

1347
libs/client/cl_particles.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -47,7 +47,9 @@
#include "QF/plugin/vid_render.h" //FIXME
#include "QF/scene/entity.h"
#include "client/effects.h"
#include "client/entities.h"
#include "client/particles.h"
#include "client/temp_entities.h"
typedef struct tent_s {
@ -337,13 +339,13 @@ parse_tent (qmsg_t *net_message, double time, TEntContext_t *ctx,
case TE_Blood:
count = MSG_ReadByte (net_message) * 20;
MSG_ReadCoordV (net_message, &position[0]);
r_funcs->particles->R_BloodPuffEffect (position, count);
clp_funcs->BloodPuffEffect (position, count);
break;
case TE_Explosion:
MSG_ReadCoordV (net_message, &position[0]);
// particles
r_funcs->particles->R_ParticleExplosion (position);
clp_funcs->ParticleExplosion (position);
// light
dl = r_funcs->R_AllocDlight (0);
@ -380,8 +382,7 @@ parse_tent (qmsg_t *net_message, double time, TEntContext_t *ctx,
colorStart = MSG_ReadByte (net_message);
colorLength = MSG_ReadByte (net_message);
S_StartSound (-1, 0, cl_sfx_r_exp3, &position[0], 1, 1);
r_funcs->particles->R_ParticleExplosion2 (position, colorStart,
colorLength);
clp_funcs->ParticleExplosion2 (position, colorStart, colorLength);
dl = r_funcs->R_AllocDlight (0);
if (!dl)
break;
@ -398,7 +399,7 @@ parse_tent (qmsg_t *net_message, double time, TEntContext_t *ctx,
MSG_ReadCoordV (net_message, &position[0]);
MSG_ReadCoordV (net_message, color); // OUCH!
color[3] = 0.7;
r_funcs->particles->R_ParticleExplosion (position);
clp_funcs->ParticleExplosion (position);
S_StartSound (-1, 0, cl_sfx_r_exp3, &position[0], 1, 1);
dl = r_funcs->R_AllocDlight (0);
if (dl) {
@ -411,21 +412,21 @@ parse_tent (qmsg_t *net_message, double time, TEntContext_t *ctx,
break;
case TE_Gunshot1:
MSG_ReadCoordV (net_message, &position[0]);
r_funcs->particles->R_GunshotEffect (position, 20);
clp_funcs->GunshotEffect (position, 20);
break;
case TE_Gunshot2:
count = MSG_ReadByte (net_message) * 20;
MSG_ReadCoordV (net_message, &position[0]);
r_funcs->particles->R_GunshotEffect (position, count);
clp_funcs->GunshotEffect (position, count);
break;
case TE_KnightSpike:
MSG_ReadCoordV (net_message, &position[0]);
r_funcs->particles->R_KnightSpikeEffect (position);
clp_funcs->KnightSpikeEffect (position);
S_StartSound (-1, 0, cl_sfx_knighthit, &position[0], 1, 1);
break;
case TE_LavaSplash:
MSG_ReadCoordV (net_message, &position[0]);
r_funcs->particles->R_LavaSplash (position);
clp_funcs->LavaSplash (position);
break;
case TE_Lightning1:
CL_ParseBeam (net_message, cl_mod_bolt, time, ctx);
@ -453,11 +454,11 @@ parse_tent (qmsg_t *net_message, double time, TEntContext_t *ctx,
QuatSet (0.25, 0.40, 0.65, 1, dl->color);
}
r_funcs->particles->R_LightningBloodEffect (position);
clp_funcs->LightningBloodEffect (position);
break;
case TE_Spike:
MSG_ReadCoordV (net_message, &position[0]);
r_funcs->particles->R_SpikeEffect (position);
clp_funcs->SpikeEffect (position);
{
int i;
sfx_t *sound;
@ -473,7 +474,7 @@ parse_tent (qmsg_t *net_message, double time, TEntContext_t *ctx,
break;
case TE_SuperSpike:
MSG_ReadCoordV (net_message, &position[0]);
r_funcs->particles->R_SuperSpikeEffect (position);
clp_funcs->SuperSpikeEffect (position);
{
int i;
sfx_t *sound;
@ -489,17 +490,17 @@ parse_tent (qmsg_t *net_message, double time, TEntContext_t *ctx,
break;
case TE_TarExplosion:
MSG_ReadCoordV (net_message, &position[0]);
r_funcs->particles->R_BlobExplosion (position);
clp_funcs->BlobExplosion (position);
S_StartSound (-1, 0, cl_sfx_r_exp3, &position[0], 1, 1);
break;
case TE_Teleport:
MSG_ReadCoordV (net_message, &position[0]);
r_funcs->particles->R_TeleportSplash (position);
clp_funcs->TeleportSplash (position);
break;
case TE_WizSpike:
MSG_ReadCoordV (net_message, &position[0]);
r_funcs->particles->R_WizSpikeEffect (position);
clp_funcs->WizSpikeEffect (position);
S_StartSound (-1, 0, cl_sfx_wizhit, &position[0], 1, 1);
break;
}
@ -659,9 +660,9 @@ CL_ParseParticleEffect (qmsg_t *net_message)
color = MSG_ReadByte (net_message);
if (count == 255)
r_funcs->particles->R_ParticleExplosion (org);
clp_funcs->ParticleExplosion (org);
else
r_funcs->particles->R_RunParticleEffect (org, dir, color, count);
clp_funcs->RunParticleEffect (org, dir, color, count);
}
void

View File

@ -55,7 +55,9 @@
#include "compat.h"
#include "d_iface.h" //FIXME part_tex_smoke and part_tex_dot
#include "client/effects.h"
#include "client/locs.h"
#include "client/particles.h"
#define LOCATION_BLOCK 128 // 128 locations per block.
@ -307,14 +309,12 @@ locs_draw (vec4f_t simorg)
dl->color[3] = 0.7;
}
trueloc = nearloc->loc;
r_funcs->particles->R_Particle_New (pt_smokecloud, part_tex_smoke,
trueloc, 2.0,
clp_funcs->Particle_New (pt_smokecloud, part_tex_smoke, trueloc, 2.0,
zero, r_data->realtime + 9.0, 254,
0.25 + qfrandom (0.125), 0.0);
for (i = 0; i < 15; i++)
r_funcs->particles->R_Particle_NewRandom (pt_fallfade,
part_tex_dot, trueloc, 12,
0.7, 96, r_data->realtime + 5.0,
clp_funcs->Particle_NewRandom (pt_fallfade, part_tex_dot, trueloc,
12, 0.7, 96, r_data->realtime + 5.0,
104 + (rand () & 7), 1.0, 0.0);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -895,5 +895,5 @@ gl_R_ClearState (void)
r_worldentity.renderer.model = 0;
R_ClearEfrags ();
R_ClearDlights ();
gl_R_ClearParticles ();
R_ClearParticles ();
}

View File

@ -146,8 +146,6 @@ gl_R_Init (void)
Cmd_AddCommand ("timerefresh", gl_R_TimeRefresh_f,
"Tests the current refresh rate for the current location");
Cmd_AddCommand ("envmap", R_Envmap_f, "No Description");
Cmd_AddCommand ("pointfile", gl_R_ReadPointFile_f,
"Load a pointfile to determine map leaks");
Cmd_AddCommand ("loadsky", gl_R_LoadSky_f, "Load a skybox");
gl_Draw_Init ();
@ -203,7 +201,7 @@ gl_R_NewMap (model_t *worldmodel, struct model_s **models, int num_models)
r_viewleaf = NULL;
R_MarkLeaves ();
gl_R_ClearParticles ();
R_ClearParticles ();
GL_BuildLightmaps (models, num_models);

View File

@ -34,7 +34,6 @@
#define R_AddTexture gl_R_AddTexture
#define R_BlendLightmaps gl_R_BlendLightmaps
#define R_CalcLightmaps gl_R_CalcLightmaps
#define R_ClearParticles gl_R_ClearParticles
#define R_ClearState gl_R_ClearState
#define R_ClearTextures gl_R_ClearTextures
#define R_DrawAliasModel gl_R_DrawAliasModel
@ -88,7 +87,6 @@
#undef R_AddTexture
#undef R_BlendLightmaps
#undef R_CalcLightmaps
#undef R_ClearParticles
#undef R_ClearState
#undef R_ClearTextures
#undef R_DrawAliasModel

View File

@ -229,8 +229,6 @@ glsl_R_RenderView (void)
void
glsl_R_Init (void)
{
Cmd_AddCommand ("pointfile", glsl_R_ReadPointFile_f,
"Load a pointfile to determine map leaks.");
Cmd_AddCommand ("timerefresh", glsl_R_TimeRefresh_f,
"Test the current refresh rate for the current location.");
R_Init_Cvars ();
@ -262,7 +260,7 @@ glsl_R_NewMap (model_t *worldmodel, struct model_s **models, int num_models)
R_MarkLeaves ();
R_FreeAllEntities ();
glsl_R_ClearParticles ();
R_ClearParticles ();
glsl_R_RegisterTextures (models, num_models);
glsl_R_BuildLightmaps (models, num_models);
glsl_R_BuildDisplayLists (models, num_models);
@ -279,7 +277,7 @@ glsl_R_ClearState (void)
r_worldentity.renderer.model = 0;
R_ClearEfrags ();
R_ClearDlights ();
glsl_R_ClearParticles ();
R_ClearParticles ();
}
void

File diff suppressed because it is too large Load Diff

View File

@ -35,7 +35,6 @@
#define R_BlendLightmaps glsl_R_BlendLightmaps
#define R_BuildLightMap glsl_R_BuildLightMap
#define R_CalcLightmaps glsl_R_CalcLightmaps
#define R_ClearParticles glsl_R_ClearParticles
#define R_ClearState glsl_R_ClearState
#define R_ClearTextures glsl_R_ClearTextures
#define R_DrawAliasModel glsl_R_DrawAliasModel
@ -91,7 +90,6 @@
#undef R_BlendLightmaps
#undef R_BuildLightMap
#undef R_CalcLightmaps
#undef R_ClearParticles
#undef R_ClearState
#undef R_ClearTextures
#undef R_DrawAliasModel

View File

@ -41,8 +41,6 @@
#include "compat.h"
#include "r_internal.h"
cvar_t *easter_eggs;
cvar_t *cl_crossx;
cvar_t *cl_crossy;
cvar_t *cl_verstring;
@ -80,7 +78,6 @@ cvar_t *r_novis;
cvar_t *r_numedges;
cvar_t *r_numsurfs;
cvar_t *r_particles;
cvar_t *r_particles_style;
cvar_t *r_particles_max;
cvar_t *r_particles_nearclip;
cvar_t *r_reportedgeout;

View File

@ -77,60 +77,11 @@ R_MaxParticlesCheck (cvar_t *r_particles, cvar_t *r_particles_max)
partparams = (partparm_t *) &particles[r_maxparticles];
partramps = (const int **) &partparams[r_maxparticles];
}
vr_funcs->R_ClearParticles ();
if (r_init)
vr_funcs->R_InitParticles ();
R_ClearParticles ();
}
static int ramp[] = {
/*ramp1*/ 0x6f, 0x6d, 0x6b, 0x69, 0x67, 0x65, 0x63, 0x61,
/*ramp2*/ 0x6f, 0x6e, 0x6d, 0x6c, 0x6b, 0x6a, 0x68, 0x66,
/*ramp3*/ 0x6d, 0x6b, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01,
};
static partparm_t part_params[] = {
[pt_static] = {{0, 0, 0, 0}, 0, 1, 0, 0},
[pt_grav] = {{0, 0, 0, 0.05}, 0, 1, 0, 0},
[pt_slowgrav] = {{0, 0, 0, 0.05}, 0, 1, 0, 0},
[pt_fire] = {{0, 0, 0, 0.05}, 5, 6, 0, 5./6},
[pt_explode] = {{4, 4, 4, 0.05}, 10, 8, 0, 0},
[pt_explode2] = {{1, 1, 1, 0.05}, 15, 8, 0, 0},
[pt_blob] = {{4, 4, 4, 0.05}, 0, 1, 0, 0},
[pt_blob2] = {{4, 4, 0, 0.05}, 0, 1, 0, 0},
[pt_smoke] = {{0, 0, 0, 0}, 0, 1, 4, 0.4},
[pt_smokecloud] = {{0, 0, 0, 0.0375}, 0, 1, 50, 0.55},
[pt_bloodcloud] = {{0, 0, 0, 0.05}, 0, 1, 4, 0.25},
[pt_fadespark] = {{0, 0, 0, 0}, 0, 1, 0, 0},
[pt_fadespark2] = {{0, 0, 0, 0}, 0, 1, 0, 0},
[pt_fallfade] = {{0, 0, 0, 1}, 0, 1, 0, 1},
[pt_fallfadespark] = {{0, 0, 0, 1}, 15, 8, 0, 1},
[pt_flame] = {{0, 0, 0, 0}, 0, 1, -2, 0.125},
};
static const int *part_ramps[] = {
[pt_fire] = ramp + 2 * 8, // ramp3
[pt_explode] = ramp + 0 * 8, // ramp1
[pt_explode2] = ramp + 1 * 8, // ramp2
[pt_fallfadespark] = ramp + 0 * 8, // ramp1
[pt_flame] = 0,
};
partparm_t
R_ParticlePhysics (ptype_t type)
void
R_ClearParticles (void)
{
if (type > pt_flame) {
Sys_Error ("R_ParticlePhysics: invalid particle type");
}
return part_params[type];
}
const int *
R_ParticleRamp (ptype_t type)
{
if (type > pt_flame) {
Sys_Error ("R_ParticleRamp: invalid particle type");
}
return part_ramps[type];
numparticles = 0;
}

View File

@ -131,12 +131,9 @@ sw_R_Init (void)
#endif
R_InitTurb ();
R_InitParticles ();
Cmd_AddCommand ("timerefresh", R_TimeRefresh_f, "Tests the current "
"refresh rate for the current location");
Cmd_AddCommand ("pointfile", R_ReadPointFile_f, "Load a pointfile to "
"determine map leaks");
Cmd_AddCommand ("loadsky", R_LoadSky_f, "Load a skybox");
Cvar_SetValue (r_maxedges, (float) NUMSTACKEDGES);

View File

@ -49,486 +49,6 @@
#include "compat.h"
#include "r_internal.h"
static mtstate_t mt; // private PRNG state
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)
{
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 = 1;
p->tex = 0;
p->ramp = ramp;
p->scale = 1;
p->live = live;
*parm = R_ParticlePhysics (type);
*rampptr = R_ParticleRamp (type);
if (*rampptr) {
p->icolor = (*rampptr) [(int) p->ramp];
}
}
void
R_InitParticles (void)
{
mtwist_seed (&mt, 0xdeadbeef);
}
void
R_ClearParticles (void)
{
if (r_maxparticles) {
memset (particles, 0, r_maxparticles * sizeof (*particles));
}
}
void
R_ReadPointFile_f (void)
{
QFile *f;
int c, r;
const char *name;
char *mapname;
vec4f_t zero = {};
mapname = strdup (r_worldentity.renderer.model->path);
if (!mapname)
Sys_Error ("Can't duplicate mapname!");
QFS_StripExtension (mapname, mapname);
name = va (0, "maps/%s.pts", mapname);
free (mapname);
f = QFS_FOpenFile (name);
if (!f) {
Sys_Printf ("couldn't open %s\n", name);
return;
}
Sys_Printf ("Reading %s...\n", name);
c = 0;
for (;;) {
char buf[64];
vec4f_t org = { 0, 0, 0, 1 };
Qgets (f, buf, sizeof (buf));
r = sscanf (buf, "%f %f %f\n", &org[0], &org[1], &org[2]);
if (r != 3)
break;
c++;
//if (!free_particles) {
// Sys_Printf ("Not enough free particles\n");
// break;
//}
add_particle (pt_static, org, zero, INFINITY, (-c) & 15, 0);
}
Qclose (f);
Sys_Printf ("%i points read\n", c);
}
static void
R_ParticleExplosion_QF (vec4f_t org)
{
if (!r_particles->int_val)
return;
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);
}
}
static void
R_ParticleExplosion2_QF (vec4f_t org, int colorStart, int colorLength)
{
int colorMod = 0;
for (int i=0; i<512; i++) {
add_particle (pt_blob, org + roffs (32), roffs (512), 0.3,
colorStart + (colorMod % colorLength), 0);
}
}
static void
R_BlobExplosion_QF (vec4f_t org)
{
if (!r_particles->int_val)
return;
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);
}
}
static void
R_RunParticleEffect_QF (vec4f_t org, vec4f_t dir, int color, int count)
{
if (!r_particles->int_val)
return;
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);
}
}
static void
R_SpikeEffect_QF (vec4f_t org)
{
vec4f_t zero = {};
R_RunParticleEffect_QF (org, zero, 0, 10);
}
static void
R_SuperSpikeEffect_QF (vec4f_t org)
{
vec4f_t zero = {};
R_RunParticleEffect_QF (org, zero, 0, 20);
}
static void
R_KnightSpikeEffect_QF (vec4f_t org)
{
vec4f_t zero = {};
R_RunParticleEffect_QF (org, zero, 226, 20);
}
static void
R_WizSpikeEffect_QF (vec4f_t org)
{
vec4f_t zero = {};
R_RunParticleEffect_QF (org, zero, 20, 30);
}
static void
R_BloodPuffEffect_QF (vec4f_t org, int count)
{
vec4f_t zero = {};
R_RunParticleEffect_QF (org, zero, 73, count);
}
static void
R_GunshotEffect_QF (vec4f_t org, int count)
{
vec4f_t zero = {};
R_RunParticleEffect_QF (org, zero, 0, count);
}
static void
R_LightningBloodEffect_QF (vec4f_t org)
{
vec4f_t zero = {};
R_RunParticleEffect_QF (org, zero, 225, 50);
}
static void
R_LavaSplash_QF (vec4f_t org)
{
if (!r_particles->int_val)
return;
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);
}
}
}
}
static void
R_TeleportSplash_QF (vec4f_t org)
{
if (!r_particles->int_val)
return;
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);
}
}
}
}
static void
R_DarkFieldParticles_ID (vec4f_t org)
{
if (!r_particles->int_val)
return;
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);
}
}
}
}
static vec4f_t velocities[NUMVERTEXNORMALS];
static vec4f_t normals[NUMVERTEXNORMALS] = {
#include "anorms.h"
};
static void
R_EntityParticles_ID (vec4f_t org)
{
int i;
float angle, sp, sy, cp, cy; // cr, sr
float beamlength = 16.0, dist = 64.0;
if (!r_particles->int_val)
return;
for (i = 0; i < NUMVERTEXNORMALS; i++) {
int k;
for (k = 0; k < 3; k++) {
velocities[i][k] = (mtwist_rand (&mt) & 255) * 0.01;
}
}
vec4f_t zero = {};
for (i = 0; i < NUMVERTEXNORMALS; i++) {
angle = vr_data.realtime * velocities[i][0];
cy = cos (angle);
sy = sin (angle);
angle = vr_data.realtime * velocities[i][1];
cp = cos (angle);
sp = sin (angle);
// Next 3 lines results aren't currently used, may be in future. --Despair
// angle = vr_data.realtime * avelocities[i][2];
// sr = sin (angle);
// cr = cos (angle);
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);
}
}
static void
R_RocketTrail_QF (vec4f_t start, vec4f_t end)
{
if (!r_particles->int_val)
return;
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;
}
}
static void
R_GrenadeTrail_QF (vec4f_t start, vec4f_t end)
{
if (!r_particles->int_val)
return;
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;
}
}
static void
R_BloodTrail_QF (vec4f_t start, vec4f_t end)
{
if (!r_particles->int_val)
return;
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;
}
}
static void
R_SlightBloodTrail_QF (vec4f_t start, vec4f_t end)
{
if (!r_particles->int_val)
return;
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;
}
}
static void
R_WizTrail_QF (vec4f_t start, vec4f_t end)
{
if (!r_particles->int_val)
return;
vec4f_t vec = end - start;
float len = magnitudef (vec)[0];
vec = normalf (vec);
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);
tracercount++;
pos += vec;
}
}
static void
R_FlameTrail_QF (vec4f_t start, vec4f_t end)
{
if (!r_particles->int_val)
return;
vec4f_t vec = end - start;
float len = magnitudef (vec)[0];
vec = normalf (vec);
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);
tracercount++;
pos += vec;
}
}
static void
R_VoorTrail_QF (vec4f_t start, vec4f_t end)
{
if (!r_particles->int_val)
return;
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;
}
}
void
R_DrawParticles (void)
{
@ -570,80 +90,6 @@ R_DrawParticles (void)
numparticles = j;
}
void
r_easter_eggs_f (cvar_t *var)
{
}
void
r_particles_style_f (cvar_t *var)
{
}
static void
R_Particle_New (ptype_t type, int texnum, vec4f_t pos, float scale,
vec4f_t vel, float live, int color, float alpha, float ramp)
{
add_particle (type, pos, vel, live, color, ramp);
}
static void
R_Particle_NewRandom (ptype_t type, int texnum, vec4f_t org, int org_fuzz,
float scale, int vel_fuzz, float live, int color,
float alpha, float ramp)
{
float o_fuzz = org_fuzz, v_fuzz = vel_fuzz;
int rnd;
vec4f_t pos, vel;
rnd = mtwist_rand (&mt);
pos[0] = o_fuzz * ((rnd & 63) - 31.5) / 63.0 + org[0];
pos[1] = o_fuzz * (((rnd >> 6) & 63) - 31.5) / 63.0 + org[1];
pos[2] = o_fuzz * (((rnd >> 10) & 63) - 31.5) / 63.0 + org[2];
pos[3] = 1;
rnd = mtwist_rand (&mt);
vel[0] = v_fuzz * ((rnd & 63) - 31.5) / 63.0;
vel[1] = v_fuzz * (((rnd >> 6) & 63) - 31.5) / 63.0;
vel[2] = v_fuzz * (((rnd >> 10) & 63) - 31.5) / 63.0;
vel[3] = 0;
add_particle (type, pos, vel, live, color, ramp);
}
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,
0,//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,
R_Particle_New,
R_Particle_NewRandom,
};
static void
R_ParticleFunctionInit (void)
{
sw_vid_render_funcs.particles = &particles_QF;
}
static void
r_particles_nearclip_f (cvar_t *var)
{
@ -666,8 +112,6 @@ r_particles_max_f (cvar_t *var)
void
R_Particles_Init_Cvars (void)
{
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,
@ -678,8 +122,4 @@ R_Particles_Init_Cvars (void)
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.");
R_ParticleFunctionInit ();
}

View File

@ -65,7 +65,6 @@
#define R_Alias_clip_top sw32_R_Alias_clip_top
#define R_IQMDrawModel sw32_R_IQMDrawModel
#define R_BeginEdgeFrame sw32_R_BeginEdgeFrame
#define R_ClearParticles sw32_R_ClearParticles
#define R_ClearState sw32_R_ClearState
#define R_ClipEdge sw32_R_ClipEdge
#define R_DrawParticles sw32_R_DrawParticles
@ -305,7 +304,6 @@ extern struct surf_s *sw32_surfaces;
#undef R_Alias_clip_top
#undef R_IQMDrawModel
#undef R_BeginEdgeFrame
#undef R_ClearParticles
#undef R_ClearState
#undef R_ClipEdge
#undef R_DrawParticles

View File

@ -151,12 +151,9 @@ sw32_R_Init (void)
sw32_Draw_Init ();
SCR_Init ();
sw32_R_InitTurb ();
sw32_R_InitParticles ();
Cmd_AddCommand ("timerefresh", sw32_R_TimeRefresh_f, "Tests the current "
"refresh rate for the current location");
Cmd_AddCommand ("pointfile", sw32_R_ReadPointFile_f, "Load a pointfile to "
"determine map leaks");
Cmd_AddCommand ("loadsky", sw32_R_LoadSky_f, "Load a skybox");
Cvar_SetValue (r_maxedges, (float) NUMSTACKEDGES);
@ -198,7 +195,7 @@ sw32_R_NewMap (model_t *worldmodel, struct model_s **models, int num_models)
r_viewleaf = NULL;
R_MarkLeaves ();
sw32_R_ClearParticles ();
R_ClearParticles ();
r_cnumsurfs = r_maxsurfs->int_val;
@ -875,5 +872,5 @@ sw32_R_ClearState (void)
r_worldentity.renderer.model = 0;
R_ClearEfrags ();
R_ClearDlights ();
sw32_R_ClearParticles ();
R_ClearParticles ();
}

View File

@ -52,486 +52,6 @@
#include "compat.h"
#include "r_internal.h"
static mtstate_t mt; // private PRNG state
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)
{
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 = 1;
p->tex = 0;
p->ramp = ramp;
p->scale = 1;
p->live = live;
*parm = R_ParticlePhysics (type);
*rampptr = R_ParticleRamp (type);
if (*rampptr) {
p->icolor = (*rampptr) [(int) p->ramp];
}
}
void
sw32_R_InitParticles (void)
{
mtwist_seed (&mt, 0xdeadbeef);
}
void
sw32_R_ClearParticles (void)
{
if (r_maxparticles) {
memset (particles, 0, r_maxparticles * sizeof (*particles));
}
}
void
sw32_R_ReadPointFile_f (void)
{
QFile *f;
int c, r;
const char *name;
char *mapname;
vec4f_t zero = {};
mapname = strdup (r_worldentity.renderer.model->path);
if (!mapname)
Sys_Error ("Can't duplicate mapname!");
QFS_StripExtension (mapname, mapname);
name = va (0, "maps/%s.pts", mapname);
free (mapname);
f = QFS_FOpenFile (name);
if (!f) {
Sys_Printf ("couldn't open %s\n", name);
return;
}
Sys_Printf ("Reading %s...\n", name);
c = 0;
for (;;) {
char buf[64];
vec4f_t org = { 0, 0, 0, 1 };
Qgets (f, buf, sizeof (buf));
r = sscanf (buf, "%f %f %f\n", &org[0], &org[1], &org[2]);
if (r != 3)
break;
c++;
//if (!free_particles) {
// Sys_Printf ("Not enough free particles\n");
// break;
//}
add_particle (pt_static, org, zero, INFINITY, (-c) & 15, 0);
}
Qclose (f);
Sys_Printf ("%i points read\n", c);
}
static void
R_ParticleExplosion_QF (vec4f_t org)
{
if (!r_particles->int_val)
return;
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);
}
}
static void
R_ParticleExplosion2_QF (vec4f_t org, int colorStart, int colorLength)
{
int colorMod = 0;
for (int i=0; i<512; i++) {
add_particle (pt_blob, org + roffs (32), roffs (512), 0.3,
colorStart + (colorMod % colorLength), 0);
}
}
static void
R_BlobExplosion_QF (vec4f_t org)
{
if (!r_particles->int_val)
return;
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);
}
}
static void
R_RunParticleEffect_QF (vec4f_t org, vec4f_t dir, int color, int count)
{
if (!r_particles->int_val)
return;
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);
}
}
static void
R_SpikeEffect_QF (vec4f_t org)
{
vec4f_t zero = {};
R_RunParticleEffect_QF (org, zero, 0, 10);
}
static void
R_SuperSpikeEffect_QF (vec4f_t org)
{
vec4f_t zero = {};
R_RunParticleEffect_QF (org, zero, 0, 20);
}
static void
R_KnightSpikeEffect_QF (vec4f_t org)
{
vec4f_t zero = {};
R_RunParticleEffect_QF (org, zero, 226, 20);
}
static void
R_WizSpikeEffect_QF (vec4f_t org)
{
vec4f_t zero = {};
R_RunParticleEffect_QF (org, zero, 20, 30);
}
static void
R_BloodPuffEffect_QF (vec4f_t org, int count)
{
vec4f_t zero = {};
R_RunParticleEffect_QF (org, zero, 73, count);
}
static void
R_GunshotEffect_QF (vec4f_t org, int count)
{
vec4f_t zero = {};
R_RunParticleEffect_QF (org, zero, 0, count);
}
static void
R_LightningBloodEffect_QF (vec4f_t org)
{
vec4f_t zero = {};
R_RunParticleEffect_QF (org, zero, 225, 50);
}
static void
R_LavaSplash_QF (vec4f_t org)
{
if (!r_particles->int_val)
return;
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);
}
}
}
}
static void
R_TeleportSplash_QF (vec4f_t org)
{
if (!r_particles->int_val)
return;
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);
}
}
}
}
static void
R_DarkFieldParticles_ID (vec4f_t org)
{
if (!r_particles->int_val)
return;
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);
}
}
}
}
static vec4f_t velocities[NUMVERTEXNORMALS];
static vec4f_t normals[NUMVERTEXNORMALS] = {
#include "anorms.h"
};
static void
R_EntityParticles_ID (vec4f_t org)
{
int i;
float angle, sp, sy, cp, cy; // cr, sr
float beamlength = 16.0, dist = 64.0;
if (!r_particles->int_val)
return;
for (i = 0; i < NUMVERTEXNORMALS; i++) {
int k;
for (k = 0; k < 3; k++) {
velocities[i][k] = (mtwist_rand (&mt) & 255) * 0.01;
}
}
vec4f_t zero = {};
for (i = 0; i < NUMVERTEXNORMALS; i++) {
angle = vr_data.realtime * velocities[i][0];
cy = cos (angle);
sy = sin (angle);
angle = vr_data.realtime * velocities[i][1];
cp = cos (angle);
sp = sin (angle);
// Next 3 lines results aren't currently used, may be in future. --Despair
// angle = vr_data.realtime * avelocities[i][2];
// sr = sin (angle);
// cr = cos (angle);
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);
}
}
static void
R_RocketTrail_QF (vec4f_t start, vec4f_t end)
{
if (!r_particles->int_val)
return;
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;
}
}
static void
R_GrenadeTrail_QF (vec4f_t start, vec4f_t end)
{
if (!r_particles->int_val)
return;
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;
}
}
static void
R_BloodTrail_QF (vec4f_t start, vec4f_t end)
{
if (!r_particles->int_val)
return;
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;
}
}
static void
R_SlightBloodTrail_QF (vec4f_t start, vec4f_t end)
{
if (!r_particles->int_val)
return;
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;
}
}
static void
R_WizTrail_QF (vec4f_t start, vec4f_t end)
{
if (!r_particles->int_val)
return;
vec4f_t vec = end - start;
float len = magnitudef (vec)[0];
vec = normalf (vec);
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);
tracercount++;
pos += vec;
}
}
static void
R_FlameTrail_QF (vec4f_t start, vec4f_t end)
{
if (!r_particles->int_val)
return;
vec4f_t vec = end - start;
float len = magnitudef (vec)[0];
vec = normalf (vec);
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);
tracercount++;
pos += vec;
}
}
static void
R_VoorTrail_QF (vec4f_t start, vec4f_t end)
{
if (!r_particles->int_val)
return;
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;
}
}
void
sw32_R_DrawParticles (void)
{
@ -573,81 +93,6 @@ sw32_R_DrawParticles (void)
numparticles = j;
}
void
sw32_r_easter_eggs_f (cvar_t *var)
{
}
void
sw32_r_particles_style_f (cvar_t *var)
{
}
static void
sw32_R_Particle_New (ptype_t type, int texnum, vec4f_t pos, float scale,
vec4f_t vel, float live, int color, float alpha,
float ramp)
{
add_particle (type, pos, vel, live, color, ramp);
}
static void
sw32_R_Particle_NewRandom (ptype_t type, int texnum, vec4f_t org,
int org_fuzz, float scale, int vel_fuzz, float live,
int color, float alpha, float ramp)
{
float o_fuzz = org_fuzz, v_fuzz = vel_fuzz;
int rnd;
vec4f_t pos, vel;
rnd = mtwist_rand (&mt);
pos[0] = o_fuzz * ((rnd & 63) - 31.5) / 63.0 + org[0];
pos[1] = o_fuzz * (((rnd >> 6) & 63) - 31.5) / 63.0 + org[1];
pos[2] = o_fuzz * (((rnd >> 12) & 63) - 31.5) / 63.0 + org[2];
pos[3] = 1;
rnd = mtwist_rand (&mt);
vel[0] = v_fuzz * ((rnd & 63) - 31.5) / 63.0;
vel[1] = v_fuzz * (((rnd >> 6) & 63) - 31.5) / 63.0;
vel[2] = v_fuzz * (((rnd >> 12) & 63) - 31.5) / 63.0;
vel[3] = 0;
add_particle (type, pos, vel, live, color, ramp);
}
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,
0,//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,
R_Particle_New,
R_Particle_NewRandom,
};
static void
R_ParticleFunctionInit (void)
{
sw32_vid_render_funcs.particles = &particles_QF;
}
static void
r_particles_nearclip_f (cvar_t *var)
{
@ -670,8 +115,6 @@ r_particles_max_f (cvar_t *var)
void
sw32_R_Particles_Init_Cvars (void)
{
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,
@ -682,8 +125,4 @@ sw32_R_Particles_Init_Cvars (void)
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.");
R_ParticleFunctionInit ();
}

View File

@ -155,12 +155,7 @@ vid_render_funcs_t gl_vid_render_funcs = {
R_MaxDlightsCheck,
R_DecayLights,
gl_R_ViewChanged,
gl_R_ClearParticles,
gl_R_InitParticles,
gl_SCR_ScreenShot_f,
gl_r_easter_eggs_f,
gl_r_particles_style_f,
0,
&model_funcs
};

View File

@ -154,12 +154,7 @@ vid_render_funcs_t glsl_vid_render_funcs = {
R_MaxDlightsCheck,
R_DecayLights,
glsl_R_ViewChanged,
glsl_R_ClearParticles,
glsl_R_InitParticles,
glsl_SCR_ScreenShot_f,
glsl_r_easter_eggs_f,
glsl_r_particles_style_f,
0,
&model_funcs
};

View File

@ -151,12 +151,7 @@ vid_render_funcs_t sw_vid_render_funcs = {
R_MaxDlightsCheck,
R_DecayLights,
R_ViewChanged,
R_ClearParticles,
R_InitParticles,
SCR_ScreenShot_f,
r_easter_eggs_f,
r_particles_style_f,
0,
&model_funcs
};

View File

@ -156,12 +156,7 @@ vid_render_funcs_t sw32_vid_render_funcs = {
R_MaxDlightsCheck,
R_DecayLights,
sw32_R_ViewChanged,
sw32_R_ClearParticles,
sw32_R_InitParticles,
sw32_SCR_ScreenShot_f,
sw32_r_easter_eggs_f,
sw32_r_particles_style_f,
0,
&model_funcs
};

View File

@ -246,7 +246,7 @@ vulkan_R_ClearState (void)
r_worldentity.renderer.model = 0;
R_ClearEfrags ();
R_ClearDlights ();
Vulkan_ClearParticles (vulkan_ctx);
R_ClearParticles ();
}
static void
@ -392,18 +392,6 @@ vulkan_R_ViewChanged (void)
Vulkan_CalcProjectionMatrices (vulkan_ctx);
}
static void
vulkan_R_ClearParticles (void)
{
Vulkan_ClearParticles (vulkan_ctx);
}
static void
vulkan_R_InitParticles (void)
{
Vulkan_InitParticles (vulkan_ctx);
}
static int
is_bgr (VkFormat format)
{
@ -455,18 +443,6 @@ vulkan_SCR_ScreenShot_f (void)
vulkan_ctx->capture_callback = capture_screenshot;
}
static void
vulkan_r_easter_eggs_f (struct cvar_s *var)
{
Vulkan_r_easter_eggs_f (var, vulkan_ctx);
}
static void
vulkan_r_particles_style_f (struct cvar_s *var)
{
Vulkan_r_particles_style_f (var, vulkan_ctx);
}
static void
vulkan_Mod_LoadLighting (model_t *mod, bsp_t *bsp)
{
@ -700,12 +676,7 @@ vid_render_funcs_t vulkan_vid_render_funcs = {
R_MaxDlightsCheck,
R_DecayLights,
vulkan_R_ViewChanged,
vulkan_R_ClearParticles,
vulkan_R_InitParticles,
vulkan_SCR_ScreenShot_f,
vulkan_r_easter_eggs_f,
vulkan_r_particles_style_f,
0,
&model_funcs
};

View File

@ -198,7 +198,7 @@ Vulkan_NewMap (model_t *worldmodel, struct model_s **models, int num_models,
R_MarkLeaves ();
R_FreeAllEntities ();
Vulkan_ClearParticles (ctx);
R_ClearParticles ();
Vulkan_RegisterTextures (models, num_models, ctx);
//Vulkan_BuildLightmaps (models, num_models, ctx);
Vulkan_BuildDisplayLists (models, num_models, ctx);

View File

@ -56,203 +56,6 @@ static const char * __attribute__((used)) particle_pass_names[] = {
"draw",
};
void
Vulkan_ClearParticles (vulkan_ctx_t *ctx)
{
}
void
Vulkan_InitParticles (vulkan_ctx_t *ctx)
{
}
static void
R_RocketTrail_QF (vec4f_t start, vec4f_t end)
{
}
static void
R_GrenadeTrail_QF (vec4f_t start, vec4f_t end)
{
}
static void
R_BloodTrail_QF (vec4f_t start, vec4f_t end)
{
}
static void
R_SlightBloodTrail_QF (vec4f_t start, vec4f_t end)
{
}
static void
R_WizTrail_QF (vec4f_t start, vec4f_t end)
{
}
static void
R_FlameTrail_QF (vec4f_t start, vec4f_t end)
{
}
static void
R_VoorTrail_QF (vec4f_t start, vec4f_t end)
{
}
static void
R_GlowTrail_QF (vec4f_t start, vec4f_t end, int glow_color)
{
}
static void
R_RunParticleEffect_QF (vec4f_t org, vec4f_t dir, int color,
int count)
{
}
static void
R_BloodPuffEffect_QF (vec4f_t org, int count)
{
}
static void
R_GunshotEffect_QF (vec4f_t org, int count)
{
}
static void
R_LightningBloodEffect_QF (vec4f_t org)
{
}
static void
R_SpikeEffect_QF (vec4f_t org)
{
}
static void
R_KnightSpikeEffect_QF (vec4f_t org)
{
}
static void
R_SuperSpikeEffect_QF (vec4f_t org)
{
}
static void
R_WizSpikeEffect_QF (vec4f_t org)
{
}
static void
R_BlobExplosion_QF (vec4f_t org)
{
}
static void
R_ParticleExplosion_QF (vec4f_t org)
{
}
static void
R_ParticleExplosion2_QF (vec4f_t org, int colorStart, int colorLength)
{
}
static void
R_LavaSplash_QF (vec4f_t org)
{
}
static void
R_TeleportSplash_QF (vec4f_t org)
{
}
static void
R_DarkFieldParticles_ID (vec4f_t org)
{
}
static void
R_EntityParticles_ID (vec4f_t org)
{
}
static void
R_Particle_New (ptype_t type, int texnum, vec4f_t org,
float scale, vec4f_t vel, float die,
int color, float alpha, float ramp)
{
}
static void
R_Particle_NewRandom (ptype_t type, int texnum, vec4f_t org,
int org_fuzz, float scale, int vel_fuzz,
float die, int color, float alpha,
float ramp)
{
}
static vid_particle_funcs_t vulkan_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,
R_Particle_New,
R_Particle_NewRandom,
};
void
Vulkan_r_easter_eggs_f (cvar_t *var, vulkan_ctx_t *ctx)
{
if (!easter_eggs || !r_particles_style) {
return;
}
if (easter_eggs->int_val) {
if (r_particles_style->int_val) {
//vulkan_vid_render_funcs.particles = &vulkan_particles_QF_egg;
} else {
//vulkan_vid_render_funcs.particles = &vulkan_particles_ID_egg;
}
} else {
if (r_particles_style->int_val) {
//vulkan_vid_render_funcs.particles = &vulkan_particles_QF;
} else {
//vulkan_vid_render_funcs.particles = &vulkan_particles_ID;
}
}
vulkan_vid_render_funcs.particles = &vulkan_particles_QF;
}
void
Vulkan_r_particles_style_f (cvar_t *var, vulkan_ctx_t *ctx)
{
Vulkan_r_easter_eggs_f (var, ctx);
}
void
Vulkan_DrawParticles (vulkan_ctx_t *ctx)
{
@ -261,8 +64,6 @@ Vulkan_DrawParticles (vulkan_ctx_t *ctx)
void
Vulkan_Particles_Init (vulkan_ctx_t *ctx)
{
vulkan_vid_render_funcs.particles = &vulkan_particles_QF;
qfv_device_t *device = ctx->device;
qfvPushDebug (ctx, "particles init");

View File

@ -52,6 +52,7 @@
#include "compat.h"
#include "sbar.h"
#include "client/particles.h"
#include "client/temp_entities.h"
#include "nq/include/chase.h"
@ -597,6 +598,7 @@ CL_Init (cbuf_t *cbuf)
Sbar_Init ();
CL_Input_Init (cbuf);
CL_Particles_Init ();
CL_TEnts_Init ();
CL_ClearState ();

View File

@ -95,6 +95,7 @@
#include "compat.h"
#include "sbar.h"
#include "client/particles.h"
#include "client/temp_entities.h"
#include "client/view.h"
@ -1206,6 +1207,7 @@ CL_Init (void)
CL_Input_Init ();
CL_Ents_Init ();
CL_Particles_Init ();
CL_TEnts_Init ();
CL_ClearState ();
Pmove_Init ();