float stretchfactor;
// stretch velocity factor (used for sparks)
float originoffset[3];
+ float relativeoriginoffset[3];
float velocityoffset[3];
+ float relativevelocityoffset[3];
float originjitter[3];
float velocityjitter[3];
float velocitymultiplier;
1.0f, //float stretchfactor;
// stretch velocity factor (used for sparks)
{0.0f, 0.0f, 0.0f}, //float originoffset[3];
+ {0.0f, 0.0f, 0.0f}, //float relativeoriginoffset[3];
{0.0f, 0.0f, 0.0f}, //float velocityoffset[3];
+ {0.0f, 0.0f, 0.0f}, //float relativevelocityoffset[3];
{0.0f, 0.0f, 0.0f}, //float originjitter[3];
{0.0f, 0.0f, 0.0f}, //float velocityjitter[3];
- 1.0f, //float velocitymultiplier;
+ 0.0f, //float velocitymultiplier;
// an effect can also spawn a dlight
0.0f, //float lightradiusstart;
0.0f, //float lightradiusfade;
cvar_t cl_decals_max = {CVAR_SAVE, "cl_decals_max", "4096", "maximum number of decals allowed to exist in the world at once"};
-void CL_Particles_ParseEffectInfo(const char *textstart, const char *textend, const char *filename)
+static void CL_Particles_ParseEffectInfo(const char *textstart, const char *textend, const char *filename)
{
int arrayindex;
int argc;
argv[arrayindex][0] = 0;
for (;;)
{
- if (!COM_ParseToken_Simple(&text, true, false))
+ if (!COM_ParseToken_Simple(&text, true, false, true))
return;
if (!strcmp(com_token, "\n"))
break;
// copy entire info from baseline, then fix up the nameindex
*info = baselineparticleeffectinfo;
info->effectnameindex = effectnameindex;
- // Nexuiz had some busted effects that didn't specify this...
- if (gamemode == GAME_NEXUIZ)
- info->velocitymultiplier = 0.0f;
}
else if (info == NULL)
{
else if (!strcmp(argv[0], "airfriction")) {readfloat(info->airfriction);}
else if (!strcmp(argv[0], "liquidfriction")) {readfloat(info->liquidfriction);}
else if (!strcmp(argv[0], "originoffset")) {readfloats(info->originoffset, 3);}
+ else if (!strcmp(argv[0], "relativeoriginoffset")) {readfloats(info->relativeoriginoffset, 3);}
else if (!strcmp(argv[0], "velocityoffset")) {readfloats(info->velocityoffset, 3);}
+ else if (!strcmp(argv[0], "relativevelocityoffset")) {readfloats(info->relativevelocityoffset, 3);}
else if (!strcmp(argv[0], "originjitter")) {readfloats(info->originjitter, 3);}
else if (!strcmp(argv[0], "velocityjitter")) {readfloats(info->velocityjitter, 3);}
else if (!strcmp(argv[0], "velocitymultiplier")) {readfloat(info->velocitymultiplier);}
"SVC_PARTICLE"
};
-void CL_Particles_LoadEffectInfo(void)
+static void CL_Particles_LoadEffectInfo(void)
{
int i;
int filepass;
part->color[2] = ((((pcolor1 >> 0) & 0xFF) * l1 + ((pcolor2 >> 0) & 0xFF) * l2) >> 8) & 0xFF;
if (vid.sRGB3D)
{
- part->color[0] = (unsigned char)(Image_LinearFloatFromsRGB(part->color[0]) * 256.0f);
- part->color[1] = (unsigned char)(Image_LinearFloatFromsRGB(part->color[1]) * 256.0f);
- part->color[2] = (unsigned char)(Image_LinearFloatFromsRGB(part->color[2]) * 256.0f);
+ part->color[0] = (unsigned char)floor(Image_LinearFloatFromsRGB(part->color[0]) * 255.0f + 0.5f);
+ part->color[1] = (unsigned char)floor(Image_LinearFloatFromsRGB(part->color[1]) * 255.0f + 0.5f);
+ part->color[2] = (unsigned char)floor(Image_LinearFloatFromsRGB(part->color[2]) * 255.0f + 0.5f);
}
part->alpha = palpha;
part->alphafade = palphafade;
static void CL_Sparks(const vec3_t originmins, const vec3_t originmaxs, const vec3_t velocitymins, const vec3_t velocitymaxs, float sparkcount);
static void CL_Smoke(const vec3_t originmins, const vec3_t originmaxs, const vec3_t velocitymins, const vec3_t velocitymaxs, float smokecount);
-void CL_ParticleEffect_Fallback(int effectnameindex, float count, const vec3_t originmins, const vec3_t originmaxs, const vec3_t velocitymins, const vec3_t velocitymaxs, entity_t *ent, int palettecolor, qboolean spawndlight, qboolean spawnparticles)
+static void CL_ParticleEffect_Fallback(int effectnameindex, float count, const vec3_t originmins, const vec3_t originmaxs, const vec3_t velocitymins, const vec3_t velocitymaxs, entity_t *ent, int palettecolor, qboolean spawndlight, qboolean spawnparticles)
{
vec3_t center;
matrix4x4_t tempmatrix;
void CL_ParticleTrail(int effectnameindex, float pcount, const vec3_t originmins, const vec3_t originmaxs, const vec3_t velocitymins, const vec3_t velocitymaxs, entity_t *ent, int palettecolor, qboolean spawndlight, qboolean spawnparticles, float tintmins[4], float tintmaxs[4])
{
qboolean found = false;
+ char vabuf[1024];
if (effectnameindex < 1 || effectnameindex >= MAX_PARTICLEEFFECTNAME || !particleeffectname[effectnameindex][0])
{
Con_DPrintf("Unknown effect number %i received from server\n", effectnameindex);
vec3_t traildir;
vec3_t trailpos;
vec3_t rvec;
+ vec3_t angles;
+ vec3_t velocity;
+ vec3_t forward;
+ vec3_t right;
+ vec3_t up;
vec_t traillen;
vec_t trailstep;
qboolean underwater;
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("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, 1, 0.25, 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++;
}
}
staintex = min(staintex, info->staintex[1] - 1);
}
if (info->particletype == pt_decal)
- CL_SpawnDecalParticleForPoint(center, info->originjitter[0], lhrandom(info->size[0], info->size[1]), lhrandom(info->alpha[0], info->alpha[1])*avgtint[3], tex, info->color[0], info->color[1]);
+ {
+ VectorMAM(0.5f, velocitymins, 0.5f, velocitymaxs, velocity);
+ AnglesFromVectors(angles, velocity, NULL, false);
+ AngleVectors(angles, forward, right, up);
+ VectorMAMAMAM(1.0f, center, info->relativeoriginoffset[0], forward, info->relativeoriginoffset[1], right, info->relativeoriginoffset[2], up, trailpos);
+
+ CL_SpawnDecalParticleForPoint(trailpos, info->originjitter[0], lhrandom(info->size[0], info->size[1]), lhrandom(info->alpha[0], info->alpha[1])*avgtint[3], tex, info->color[0], info->color[1]);
+ }
else if (info->orientation == PARTICLE_HBEAM)
- CL_NewParticle(center, info->particletype, info->color[0], info->color[1], tex, lhrandom(info->size[0], info->size[1]), info->size[2], lhrandom(info->alpha[0], info->alpha[1]), info->alpha[2], 0, 0, originmins[0], originmins[1], originmins[2], originmaxs[0], originmaxs[1], originmaxs[2], 0, 0, 0, 0, false, lhrandom(info->time[0], info->time[1]), info->stretchfactor, info->blendmode, info->orientation, info->staincolor[0], info->staincolor[1], staintex, lhrandom(info->stainalpha[0], info->stainalpha[1]), lhrandom(info->stainsize[0], info->stainsize[1]), 0, 0, tintmins ? avgtint : NULL);
+ {
+ AnglesFromVectors(angles, traildir, NULL, false);
+ AngleVectors(angles, forward, right, up);
+ VectorMAMAM(info->relativeoriginoffset[0], forward, info->relativeoriginoffset[1], right, info->relativeoriginoffset[2], up, trailpos);
+
+ CL_NewParticle(center, info->particletype, info->color[0], info->color[1], tex, lhrandom(info->size[0], info->size[1]), info->size[2], lhrandom(info->alpha[0], info->alpha[1]), info->alpha[2], 0, 0, originmins[0] + trailpos[0], originmins[1] + trailpos[1], originmins[2] + trailpos[2], originmaxs[0], originmaxs[1], originmaxs[2], 0, 0, 0, 0, false, lhrandom(info->time[0], info->time[1]), info->stretchfactor, info->blendmode, info->orientation, info->staincolor[0], info->staincolor[1], staintex, lhrandom(info->stainalpha[0], info->stainalpha[1]), lhrandom(info->stainsize[0], info->stainsize[1]), 0, 0, tintmins ? avgtint : NULL);
+ }
else
{
if (!cl_particles.integer)
info->particleaccumulator += traillen / info->trailspacing * cl_particles_quality.value * pcount;
trailstep = info->trailspacing / cl_particles_quality.value / max(0.001, pcount);
immediatebloodstain = false;
+
+ AnglesFromVectors(angles, traildir, NULL, false);
+ AngleVectors(angles, forward, right, up);
+ VectorMAMAMAM(1.0f, trailpos, info->relativeoriginoffset[0], forward, info->relativeoriginoffset[1], right, info->relativeoriginoffset[2], up, trailpos);
+ VectorMAMAM(info->relativevelocityoffset[0], forward, info->relativevelocityoffset[1], right, info->relativevelocityoffset[2], up, velocity);
}
else
{
((cl_decals_newsystem_immediatebloodstain.integer >= 1) && (info->particletype == pt_blood))
||
((cl_decals_newsystem_immediatebloodstain.integer >= 2) && staintex);
+
+ VectorMAM(0.5f, velocitymins, 0.5f, velocitymaxs, velocity);
+ AnglesFromVectors(angles, velocity, NULL, false);
+ AngleVectors(angles, forward, right, up);
+ VectorMAMAMAM(1.0f, trailpos, info->relativeoriginoffset[0], traildir, info->relativeoriginoffset[1], right, info->relativeoriginoffset[2], up, trailpos);
+ VectorMAMAM(info->relativevelocityoffset[0], traildir, info->relativevelocityoffset[1], right, info->relativevelocityoffset[2], up, velocity);
}
info->particleaccumulator = bound(0, info->particleaccumulator, 16384);
for (;info->particleaccumulator >= 1;info->particleaccumulator--)
Vector4Lerp(tintmins, tintlerp, tintmaxs, tint);
}
VectorRandom(rvec);
- part = CL_NewParticle(center, info->particletype, info->color[0], info->color[1], tex, lhrandom(info->size[0], info->size[1]), info->size[2], lhrandom(info->alpha[0], info->alpha[1]), info->alpha[2], info->gravity, info->bounce, trailpos[0] + info->originoffset[0] + info->originjitter[0] * rvec[0], trailpos[1] + info->originoffset[1] + info->originjitter[1] * rvec[1], trailpos[2] + info->originoffset[2] + info->originjitter[2] * rvec[2], lhrandom(velocitymins[0], velocitymaxs[0]) * info->velocitymultiplier + info->velocityoffset[0] + info->velocityjitter[0] * rvec[0], lhrandom(velocitymins[1], velocitymaxs[1]) * info->velocitymultiplier + info->velocityoffset[1] + info->velocityjitter[1] * rvec[1], lhrandom(velocitymins[2], velocitymaxs[2]) * info->velocitymultiplier + info->velocityoffset[2] + info->velocityjitter[2] * rvec[2], info->airfriction, info->liquidfriction, 0, 0, info->countabsolute <= 0, lhrandom(info->time[0], info->time[1]), info->stretchfactor, info->blendmode, info->orientation, info->staincolor[0], info->staincolor[1], staintex, lhrandom(info->stainalpha[0], info->stainalpha[1]), lhrandom(info->stainsize[0], info->stainsize[1]), lhrandom(info->rotate[0], info->rotate[1]), lhrandom(info->rotate[2], info->rotate[3]), tintmins ? tint : NULL);
+ part = CL_NewParticle(center, info->particletype, info->color[0], info->color[1], tex, lhrandom(info->size[0], info->size[1]), info->size[2], lhrandom(info->alpha[0], info->alpha[1]), info->alpha[2], info->gravity, info->bounce, trailpos[0] + info->originoffset[0] + info->originjitter[0] * rvec[0], trailpos[1] + info->originoffset[1] + info->originjitter[1] * rvec[1], trailpos[2] + info->originoffset[2] + info->originjitter[2] * rvec[2], lhrandom(velocitymins[0], velocitymaxs[0]) * info->velocitymultiplier + info->velocityoffset[0] + info->velocityjitter[0] * rvec[0] + velocity[0], lhrandom(velocitymins[1], velocitymaxs[1]) * info->velocitymultiplier + info->velocityoffset[1] + info->velocityjitter[1] * rvec[1] + velocity[1], lhrandom(velocitymins[2], velocitymaxs[2]) * info->velocitymultiplier + info->velocityoffset[2] + info->velocityjitter[2] * rvec[2] + velocity[2], info->airfriction, info->liquidfriction, 0, 0, info->countabsolute <= 0, lhrandom(info->time[0], info->time[1]), info->stretchfactor, info->blendmode, info->orientation, info->staincolor[0], info->staincolor[1], staintex, lhrandom(info->stainalpha[0], info->stainalpha[1]), lhrandom(info->stainsize[0], info->stainsize[1]), lhrandom(info->rotate[0], info->rotate[1]), lhrandom(info->rotate[2], info->rotate[3]), tintmins ? tint : NULL);
if (immediatebloodstain && part)
{
immediatebloodstain = false;
vec3_t org, dir;
int i, count, msgcount, color;
- MSG_ReadVector(org, cls.protocol);
+ MSG_ReadVector(&cl_message, org, cls.protocol);
for (i=0 ; i<3 ; i++)
- dir[i] = MSG_ReadChar () * (1.0 / 16.0);
- msgcount = MSG_ReadByte ();
- color = MSG_ReadByte ();
+ dir[i] = MSG_ReadChar(&cl_message) * (1.0 / 16.0);
+ msgcount = MSG_ReadByte(&cl_message);
+ color = MSG_ReadByte(&cl_message);
if (msgcount == 255)
count = 1024;
}
int particlefontwidth, particlefontheight, particlefontcellwidth, particlefontcellheight, particlefontrows, particlefontcols;
-void CL_Particle_PixelCoordsForTexnum(int texnum, int *basex, int *basey, int *width, int *height)
+static void CL_Particle_PixelCoordsForTexnum(int texnum, int *basex, int *basey, int *width, int *height)
{
*basex = (texnum % particlefontcols) * particlefontcellwidth;
*basey = ((texnum / particlefontcols) % particlefontrows) * particlefontcellheight;
memcpy(particletexturedata + ((basey + y) * PARTICLEFONTSIZE + basex) * 4, data + y * PARTICLETEXTURESIZE * 4, PARTICLETEXTURESIZE * 4);
}
-void particletextureblotch(unsigned char *data, float radius, float red, float green, float blue, float alpha)
+static void particletextureblotch(unsigned char *data, float radius, float red, float green, float blue, float alpha)
{
int x, y;
float cx, cy, dx, dy, f, iradius;
}
}
-void particletextureclamp(unsigned char *data, int minr, int ming, int minb, int maxr, int maxg, int maxb)
+#if 0
+static void particletextureclamp(unsigned char *data, int minr, int ming, int minb, int maxr, int maxg, int maxb)
{
int i;
for (i = 0;i < PARTICLETEXTURESIZE*PARTICLETEXTURESIZE;i++, data += 4)
data[2] = bound(minr, data[2], maxr);
}
}
+#endif
-void particletextureinvert(unsigned char *data)
+static void particletextureinvert(unsigned char *data)
{
int i;
for (i = 0;i < PARTICLETEXTURESIZE*PARTICLETEXTURESIZE;i++, data += 4)
bufptr = buf;
for(;;)
{
- if(!COM_ParseToken_Simple(&bufptr, true, false))
+ if(!COM_ParseToken_Simple(&bufptr, true, false, true))
break;
if(!strcmp(com_token, "\n"))
continue; // empty line
s2 = 1;
t2 = 1;
- if (COM_ParseToken_Simple(&bufptr, true, false) && strcmp(com_token, "\n"))
+ if (COM_ParseToken_Simple(&bufptr, true, false, true) && strcmp(com_token, "\n"))
{
strlcpy(texturename, com_token, sizeof(texturename));
s1 = atof(com_token);
- if (COM_ParseToken_Simple(&bufptr, true, false) && strcmp(com_token, "\n"))
+ if (COM_ParseToken_Simple(&bufptr, true, false, true) && strcmp(com_token, "\n"))
{
texturename[0] = 0;
t1 = atof(com_token);
- if (COM_ParseToken_Simple(&bufptr, true, false) && strcmp(com_token, "\n"))
+ if (COM_ParseToken_Simple(&bufptr, true, false, true) && strcmp(com_token, "\n"))
{
s2 = atof(com_token);
- if (COM_ParseToken_Simple(&bufptr, true, false) && strcmp(com_token, "\n"))
+ if (COM_ParseToken_Simple(&bufptr, true, false, true) && strcmp(com_token, "\n"))
{
t2 = atof(com_token);
strlcpy(texturename, "particles/particlefont.tga", sizeof(texturename));
- if (COM_ParseToken_Simple(&bufptr, true, false) && strcmp(com_token, "\n"))
+ if (COM_ParseToken_Simple(&bufptr, true, false, true) && strcmp(com_token, "\n"))
strlcpy(texturename, com_token, sizeof(texturename));
}
}
Con_Printf("particles/particlefont.txt: texnum %i outside valid range (0 to %i)\n", i, MAX_PARTICLETEXTURES);
continue;
}
- sf = R_SkinFrame_LoadExternal(texturename, TEXF_ALPHA | TEXF_FORCELINEAR | TEXF_RGBMULTIPLYBYALPHA, true);
+ sf = R_SkinFrame_LoadExternal(texturename, TEXF_ALPHA | TEXF_FORCELINEAR | TEXF_RGBMULTIPLYBYALPHA, true); // note: this loads as sRGB if sRGB is active!
if(!sf)
{
// R_SkinFrame_LoadExternal already complained
R_RegisterModule("R_Particles", r_part_start, r_part_shutdown, r_part_newmap, NULL, NULL);
}
-void R_DrawDecal_TransparentCallback(const entity_render_t *ent, const rtlight_t *rtlight, int numsurfaces, int *surfacelist)
+static void R_DrawDecal_TransparentCallback(const entity_render_t *ent, const rtlight_t *rtlight, int numsurfaces, int *surfacelist)
{
int surfacelistindex;
const decal_t *d;
// now render the decals all at once
// (this assumes they all use one particle font texture!)
GL_BlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_COLOR);
- R_SetupShader_Generic(particletexture[63].texture, NULL, GL_MODULATE, 1, false);
+ R_SetupShader_Generic(particletexture[63].texture, NULL, GL_MODULATE, 1, false, false, true);
R_Mesh_PrepareVertices_Generic_Arrays(numsurfaces * 4, particle_vertex3f, particle_color4f, particle_texcoord2f);
R_Mesh_Draw(0, numsurfaces * 4, 0, numsurfaces * 2, NULL, NULL, 0, particle_elements, NULL, 0);
}
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(decal->org, R_DrawDecal_TransparentCallback, NULL, i, NULL);
+ R_MeshQueue_AddTransparent(MESHQUEUE_SORT_DISTANCE, decal->org, R_DrawDecal_TransparentCallback, NULL, i, NULL);
continue;
killdecal:
decal->typeindex = 0;
r_refdef.stats.totaldecals = cl.num_decals;
}
-void R_DrawParticle_TransparentCallback(const entity_render_t *ent, const rtlight_t *rtlight, int numsurfaces, int *surfacelist)
+static void R_DrawParticle_TransparentCallback(const entity_render_t *ent, const rtlight_t *rtlight, int numsurfaces, int *surfacelist)
{
int surfacelistindex;
int batchstart, batchcount;
if (texture != particletexture[p->texnum].texture)
{
texture = particletexture[p->texnum].texture;
- R_SetupShader_Generic(texture, NULL, GL_MODULATE, 1, false);
+ R_SetupShader_Generic(texture, NULL, GL_MODULATE, 1, false, false, false);
}
if (p->blendmode == PBLEND_INVMOD)
{
case pt_beam:
// beams have no culling
- R_MeshQueue_AddTransparent(p->sortorigin, R_DrawParticle_TransparentCallback, NULL, i, NULL);
+ R_MeshQueue_AddTransparent(MESHQUEUE_SORT_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(p->sortorigin, R_DrawParticle_TransparentCallback, NULL, i, NULL);
+ R_MeshQueue_AddTransparent(MESHQUEUE_SORT_DISTANCE, p->sortorigin, R_DrawParticle_TransparentCallback, NULL, i, NULL);
break;
}