float lightcolor[3];
qboolean lightshadow;
int lightcubemapnum;
+ float lightcorona[2];
unsigned int staincolor[2]; // note: 0x808080 = neutral (particle's own color), these are modding factors for the particle's original color!
int staintex[2];
float stainalpha[2];
{1.0f, 1.0f, 1.0f}, //float lightcolor[3];
true, //qboolean lightshadow;
0, //int lightcubemapnum;
+ {1.0f, 0.25f}, //float lightcorona[2];
{(unsigned int)-1, (unsigned int)-1}, //unsigned int staincolor[2]; // note: 0x808080 = neutral (particle's own color), these are modding factors for the particle's original color!
{-1, -1}, //int staintex[2];
{1.0f, 1.0f}, //float stainalpha[2];
else if (!strcmp(argv[0], "lightcolor")) {readfloats(info->lightcolor, 3);}
else if (!strcmp(argv[0], "lightshadow")) {readbool(info->lightshadow);}
else if (!strcmp(argv[0], "lightcubemapnum")) {readint(info->lightcubemapnum);}
+ else if (!strcmp(argv[0], "lightcorona")) {readints(info->lightcorona, 2);}
else if (!strcmp(argv[0], "underwater")) {checkparms(1);info->flags |= PARTICLEEFFECT_UNDERWATER;}
else if (!strcmp(argv[0], "notunderwater")) {checkparms(1);info->flags |= PARTICLEEFFECT_NOTUNDERWATER;}
else if (!strcmp(argv[0], "trailspacing")) {readfloat(info->trailspacing);if (info->trailspacing > 0) info->countmultiplier = 1.0f / info->trailspacing;}
"SVC_PARTICLE"
};
-static void CL_Particles_LoadEffectInfo(void)
+static void CL_Particles_LoadEffectInfo(const char *customfile)
{
int i;
int filepass;
for (filepass = 0;;filepass++)
{
if (filepass == 0)
- dpsnprintf(filename, sizeof(filename), "effectinfo.txt");
+ {
+ if (customfile)
+ strlcpy(filename, customfile, sizeof(filename));
+ else
+ strlcpy(filename, "effectinfo.txt", sizeof(filename));
+ }
else if (filepass == 1)
{
- if (!cl.worldbasename[0])
+ if (!cl.worldbasename[0] || customfile)
continue;
dpsnprintf(filename, sizeof(filename), "%s_effectinfo.txt", cl.worldnamenoextension);
}
}
}
+static void CL_Particles_LoadEffectInfo_f(void)
+{
+ CL_Particles_LoadEffectInfo(Cmd_Argc() > 1 ? Cmd_Argv(1) : NULL);
+}
+
/*
===============
CL_InitParticles
void CL_Particles_Init (void)
{
Cmd_AddCommand ("pointfile", CL_ReadPointFile_f, "display point file produced by qbsp when a leak was detected in the map (a line leading through the leak hole, to an entity inside the level)");
- Cmd_AddCommand ("cl_particles_reloadeffects", CL_Particles_LoadEffectInfo, "reloads effectinfo.txt and maps/levelname_effectinfo.txt (where levelname is the current map)");
+ Cmd_AddCommand ("cl_particles_reloadeffects", CL_Particles_LoadEffectInfo_f, "reloads effectinfo.txt and maps/levelname_effectinfo.txt (where levelname is the current map) if parameter is given, loads from custom file (no levelname_effectinfo are loaded in this case)");
Cvar_RegisterVariable (&cl_particles);
Cvar_RegisterVariable (&cl_particles_quality);
void CL_SpawnDecalParticleForPoint(const vec3_t org, float maxdist, float size, float alpha, int texnum, int color1, int color2)
{
int i;
- float bestfrac, bestorg[3], bestnormal[3];
- float org2[3];
+ vec_t bestfrac;
+ vec3_t bestorg;
+ vec3_t bestnormal;
+ vec3_t org2;
int besthitent = 0, hitent;
trace_t trace;
bestfrac = 10;
{
// light flash (explosion, etc)
// called when effect starts
- CL_AllocLightFlash(NULL, &tempmatrix, info->lightradiusstart, info->lightcolor[0]*avgtint[0]*avgtint[3], info->lightcolor[1]*avgtint[1]*avgtint[3], info->lightcolor[2]*avgtint[2]*avgtint[3], info->lightradiusfade, info->lighttime, info->lightcubemapnum, -1, info->lightshadow, 1, 0.25, 0, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
+ CL_AllocLightFlash(NULL, &tempmatrix, info->lightradiusstart, info->lightcolor[0]*avgtint[0]*avgtint[3], info->lightcolor[1]*avgtint[1]*avgtint[3], info->lightcolor[2]*avgtint[2]*avgtint[3], info->lightradiusfade, info->lighttime, info->lightcubemapnum, -1, info->lightshadow, info->lightcorona[0], info->lightcorona[1], 0, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
}
else if (r_refdef.scene.numlights < MAX_DLIGHTS)
{
rvec[0] = info->lightcolor[0]*avgtint[0]*avgtint[3];
rvec[1] = info->lightcolor[1]*avgtint[1]*avgtint[3];
rvec[2] = info->lightcolor[2]*avgtint[2]*avgtint[3];
- R_RTLight_Update(&r_refdef.scene.templights[r_refdef.scene.numlights], false, &tempmatrix, rvec, -1, info->lightcubemapnum > 0 ? va(vabuf, sizeof(vabuf), "cubemaps/%i", info->lightcubemapnum) : NULL, info->lightshadow, 1, 0.25, 0, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
+ R_RTLight_Update(&r_refdef.scene.templights[r_refdef.scene.numlights], false, &tempmatrix, rvec, -1, info->lightcubemapnum > 0 ? va(vabuf, sizeof(vabuf), "cubemaps/%i", info->lightcubemapnum) : NULL, info->lightshadow, info->lightcorona[0], info->lightcorona[1], 0, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
r_refdef.scene.lights[r_refdef.scene.numlights] = &r_refdef.scene.templights[r_refdef.scene.numlights];r_refdef.scene.numlights++;
}
}
void CL_EntityParticles (const entity_t *ent)
{
int i;
- float pitch, yaw, dist = 64, beamlength = 16, org[3], v[3];
+ vec_t pitch, yaw, dist = 64, beamlength = 16;
+ vec3_t org, v;
static vec3_t avelocities[NUMVERTEXNORMALS];
if (!cl_particles.integer) return;
if (cl.time <= cl.oldtime) return; // don't spawn new entity particles while paused
void CL_ReadPointFile_f (void)
{
- vec3_t org, leakorg;
+ double org[3], leakorg[3];
+ vec3_t vecorg;
int r, c, s;
char *pointfile = NULL, *pointfilepos, *t, tchar;
char name[MAX_QPATH];
#if _MSC_VER >= 1400
#define sscanf sscanf_s
#endif
- r = sscanf (pointfilepos,"%f %f %f", &org[0], &org[1], &org[2]);
+ r = sscanf (pointfilepos,"%lf %lf %lf", &org[0], &org[1], &org[2]);
+ VectorCopy(org, vecorg);
*t = tchar;
pointfilepos = t;
if (r != 3)
if (cl.num_particles < cl.max_particles - 3)
{
s++;
- CL_NewParticle(org, pt_alphastatic, particlepalette[(-c)&15], particlepalette[(-c)&15], tex_particle, 2, 0, 255, 0, 0, 0, org[0], org[1], org[2], 0, 0, 0, 0, 0, 0, 0, true, 1<<30, 1, PBLEND_ALPHA, PARTICLE_BILLBOARD, -1, -1, -1, 1, 1, 0, 0, NULL);
+ CL_NewParticle(vecorg, pt_alphastatic, particlepalette[(-c)&15], particlepalette[(-c)&15], tex_particle, 2, 0, 255, 0, 0, 0, org[0], org[1], org[2], 0, 0, 0, 0, 0, 0, 0, true, 1<<30, 1, PBLEND_ALPHA, PARTICLE_BILLBOARD, -1, -1, -1, 1, 1, 0, 0, NULL);
}
}
Mem_Free(pointfile);
- VectorCopy(leakorg, org);
- Con_Printf("%i points read (%i particles spawned)\nLeak at %f %f %f\n", c, s, org[0], org[1], org[2]);
+ VectorCopy(leakorg, vecorg);
+ Con_Printf("%i points read (%i particles spawned)\nLeak at %f %f %f\n", c, s, leakorg[0], leakorg[1], leakorg[2]);
- CL_NewParticle(org, pt_beam, 0xFF0000, 0xFF0000, tex_beam, 64, 0, 255, 0, 0, 0, org[0] - 4096, org[1], org[2], org[0] + 4096, org[1], org[2], 0, 0, 0, 0, false, 1<<30, 1, PBLEND_ADD, PARTICLE_HBEAM, -1, -1, -1, 1, 1, 0, 0, NULL);
- CL_NewParticle(org, pt_beam, 0x00FF00, 0x00FF00, tex_beam, 64, 0, 255, 0, 0, 0, org[0], org[1] - 4096, org[2], org[0], org[1] + 4096, org[2], 0, 0, 0, 0, false, 1<<30, 1, PBLEND_ADD, PARTICLE_HBEAM, -1, -1, -1, 1, 1, 0, 0, NULL);
- CL_NewParticle(org, pt_beam, 0x0000FF, 0x0000FF, tex_beam, 64, 0, 255, 0, 0, 0, org[0], org[1], org[2] - 4096, org[0], org[1], org[2] + 4096, 0, 0, 0, 0, false, 1<<30, 1, PBLEND_ADD, PARTICLE_HBEAM, -1, -1, -1, 1, 1, 0, 0, NULL);
+ CL_NewParticle(vecorg, pt_beam, 0xFF0000, 0xFF0000, tex_beam, 64, 0, 255, 0, 0, 0, org[0] - 4096, org[1], org[2], org[0] + 4096, org[1], org[2], 0, 0, 0, 0, false, 1<<30, 1, PBLEND_ADD, PARTICLE_HBEAM, -1, -1, -1, 1, 1, 0, 0, NULL);
+ CL_NewParticle(vecorg, pt_beam, 0x00FF00, 0x00FF00, tex_beam, 64, 0, 255, 0, 0, 0, org[0], org[1] - 4096, org[2], org[0], org[1] + 4096, org[2], 0, 0, 0, 0, false, 1<<30, 1, PBLEND_ADD, PARTICLE_HBEAM, -1, -1, -1, 1, 1, 0, 0, NULL);
+ CL_NewParticle(vecorg, pt_beam, 0x0000FF, 0x0000FF, tex_beam, 64, 0, 255, 0, 0, 0, org[0], org[1], org[2] - 4096, org[0], org[1], org[2] + 4096, 0, 0, 0, 0, false, 1<<30, 1, PBLEND_ADD, PARTICLE_HBEAM, -1, -1, -1, 1, 1, 0, 0, NULL);
}
/*
particlepalette[i] = palette_rgb[i][0] * 65536 + palette_rgb[i][1] * 256 + palette_rgb[i][2];
particletexturepool = R_AllocTexturePool();
R_InitParticleTexture ();
- CL_Particles_LoadEffectInfo();
+ CL_Particles_LoadEffectInfo(NULL);
}
static void r_part_shutdown(void)
{
if (decalskinframe)
R_SkinFrame_MarkUsed(decalskinframe);
- CL_Particles_LoadEffectInfo();
+ CL_Particles_LoadEffectInfo(NULL);
}
unsigned short particle_elements[MESHQUEUE_TRANSPARENT_BATCHSIZE*6];
const decal_t *d;
float *v3f, *t2f, *c4f;
particletexture_t *tex;
- float right[3], up[3], size, ca;
+ vec_t right[3], up[3], size, ca;
float alphascale = (1.0f / 65536.0f) * cl_particles_alpha.value;
RSurf_ActiveWorldEntity();
continue;
if (DotProduct(r_refdef.view.origin, decal->normal) > DotProduct(decal->org, decal->normal) && VectorDistance2(decal->org, r_refdef.view.origin) < drawdist2 * (decal->size * decal->size))
- R_MeshQueue_AddTransparent(MESHQUEUE_SORT_DISTANCE, decal->org, R_DrawDecal_TransparentCallback, NULL, i, NULL);
+ R_MeshQueue_AddTransparent(TRANSPARENTSORT_DISTANCE, decal->org, R_DrawDecal_TransparentCallback, NULL, i, NULL);
continue;
killdecal:
decal->typeindex = 0;
static void R_DrawParticle_TransparentCallback(const entity_render_t *ent, const rtlight_t *rtlight, int numsurfaces, int *surfacelist)
{
+ vec3_t vecorg, vecvel, baseright, baseup;
int surfacelistindex;
int batchstart, batchcount;
const particle_t *p;
particletexture_t *tex;
float up2[3], v[3], right[3], up[3], fog, ifog, size, len, lenfactor, alpha;
// float ambient[3], diffuse[3], diffusenormal[3];
- float palpha, spintime, spinrad, spincos, spinsin, spinm1, spinm2, spinm3, spinm4, baseright[3], baseup[3];
+ float palpha, spintime, spinrad, spincos, spinsin, spinm1, spinm2, spinm3, spinm4;
vec4_t colormultiplier;
float minparticledist_start, minparticledist_end;
qboolean dofade;
c4f[3] = alpha;
// note: lighting is not cheap!
if (particletype[p->typeindex].lighting)
- R_LightPoint(c4f, p->org, LP_LIGHTMAP | LP_RTWORLD | LP_DYNLIGHT);
+ {
+ vecorg[0] = p->org[0];
+ vecorg[1] = p->org[1];
+ vecorg[2] = p->org[2];
+ R_LightPoint(c4f, vecorg, LP_LIGHTMAP | LP_RTWORLD | LP_DYNLIGHT);
+ }
// mix in the fog color
if (r_refdef.fogenabled)
{
t2f[6] = tex->s2;t2f[7] = tex->t2;
break;
case PARTICLE_ORIENTED_DOUBLESIDED:
- VectorVectors(p->vel, baseright, baseup);
+ vecvel[0] = p->vel[0];
+ vecvel[1] = p->vel[1];
+ vecvel[2] = p->vel[2];
+ VectorVectors(vecvel, baseright, baseup);
if (p->angle + p->spin)
{
spinrad = (p->angle + p->spin * (spintime - p->delayedspawn)) * (float)(M_PI / 180.0f);
{
case pt_beam:
// beams have no culling
- R_MeshQueue_AddTransparent(MESHQUEUE_SORT_DISTANCE, p->sortorigin, R_DrawParticle_TransparentCallback, NULL, i, NULL);
+ R_MeshQueue_AddTransparent(TRANSPARENTSORT_DISTANCE, p->sortorigin, R_DrawParticle_TransparentCallback, NULL, i, NULL);
break;
default:
if(cl_particles_visculling.integer)
}
// anything else just has to be in front of the viewer and visible at this distance
if (DotProduct(p->org, r_refdef.view.forward) >= minparticledist_start && VectorDistance2(p->org, r_refdef.view.origin) < drawdist2 * (p->size * p->size))
- R_MeshQueue_AddTransparent(MESHQUEUE_SORT_DISTANCE, p->sortorigin, R_DrawParticle_TransparentCallback, NULL, i, NULL);
+ R_MeshQueue_AddTransparent(TRANSPARENTSORT_DISTANCE, p->sortorigin, R_DrawParticle_TransparentCallback, NULL, i, NULL);
break;
}