X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=cl_particles.c;h=7d24c80e336de3debf5d1fe1f4b83391ad52285a;hb=ca913e8190a32d6e96dededdb0a6f8d5ce72bf63;hp=e03b0e36371610ae58bca0900a5705c8e65eff77;hpb=d3b158411b1d81181e05f750d9a7b0b2268438e2;p=xonotic%2Fdarkplaces.git diff --git a/cl_particles.c b/cl_particles.c index e03b0e36..7d24c80e 100644 --- a/cl_particles.c +++ b/cl_particles.c @@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. siextern float r_avertexnormals[NUMVERTEXNORMALS][3]; #define m_bytenormals r_avertexnormals #define VectorNormalizeFast VectorNormalize -#define CL_PointContents(v) (Mod_PointInLeaf(v,cl.worldmodel)->contents) +#define CL_PointQ1Contents(v) (Mod_PointInLeaf(v,cl.worldmodel)->contents) typedef unsigned char qbyte; #define cl_stainmaps.integer 0 void R_Stain (vec3_t origin, float radius, int cr1, int cg1, int cb1, int ca1, int cr2, int cg2, int cb2, int ca2) @@ -49,12 +49,12 @@ void R_CalcBeam_Vertex3f (float *vert, vec3_t org1, vec3_t org2, float width) VectorNormalizeFast (normal); // calculate 'right' vector for start - VectorSubtract (r_origin, org1, diff); + VectorSubtract (r_vieworigin, org1, diff); VectorNormalizeFast (diff); CrossProduct (normal, diff, right1); // calculate 'right' vector for end - VectorSubtract (r_origin, org2, diff); + VectorSubtract (r_vieworigin, org2, diff); VectorNormalizeFast (diff); CrossProduct (normal, diff, right2); @@ -152,7 +152,7 @@ void VectorVectors(const vec3_t forward, vec3_t right, vec3_t up) #include "pmove.h" extern qboolean PM_RecursiveHullCheck (hull_t *hull, int num, float p1f, float p2f, vec3_t p1, vec3_t p2, pmtrace_t *trace); #endif -float CL_TraceLine (vec3_t start, vec3_t end, vec3_t impact, vec3_t normal, int contents, int hitbmodels, void **hitent) +float CL_TraceLine (vec3_t start, vec3_t end, vec3_t impact, vec3_t normal, int hitbmodels, void **hitent, int hitsupercontentsmask) { #if QW pmtrace_t trace; @@ -431,18 +431,17 @@ void CL_SpawnDecalParticleForPoint(const vec3_t org, float maxdist, float size, int i; float bestfrac, bestorg[3], bestnormal[3]; float frac, v[3], normal[3], org2[3]; - void *besthitent; #ifdef WORKINGLQUAKE - void *hitent; + void *besthitent = NULL, *hitent; #else - entity_render_t *hitent; + entity_render_t *besthitent = NULL, *hitent; #endif bestfrac = 10; for (i = 0;i < 32;i++) { VectorRandom(org2); VectorMA(org, maxdist, org2, org2); - frac = CL_TraceLine(org, org2, v, normal, 0, true, &hitent); + frac = CL_TraceLine(org, org2, v, normal, true, &hitent, SUPERCONTENTS_SOLID); if (bestfrac > frac) { bestfrac = frac; @@ -510,8 +509,8 @@ void CL_ReadPointFile_f (void) if (!cl.worldmodel) return; - FS_StripExtension(cl.worldmodel->name, name); - strcat(name, ".pts"); + FS_StripExtension (cl.worldmodel->name, name, sizeof (name)); + strlcat (name, ".pts", sizeof (name)); #if WORKINGLQUAKE pointfile = COM_LoadTempFile (name); #else @@ -606,7 +605,7 @@ void CL_ParticleExplosion (vec3_t org) R_Stain(org, 96, 80, 80, 80, 64, 176, 176, 176, 64); CL_SpawnDecalParticleForPoint(org, 40, 48, 255, tex_bulletdecal[rand()&7], 0xFFFFFF, 0xFFFFFF); - i = CL_PointContents(org); + i = CL_PointQ1Contents(org); if ((i == CONTENTS_SLIME || i == CONTENTS_WATER) && cl_particles.integer && cl_particles_bubbles.integer) { for (i = 0;i < 128 * cl_particles_quality.value;i++) @@ -631,7 +630,7 @@ void CL_ParticleExplosion (vec3_t org) v[0] = org[0] + lhrandom(-64, 64); v[1] = org[1] + lhrandom(-64, 64); v[2] = org[2] + lhrandom(-8, 24); - if (CL_TraceLine(org, v, v2, NULL, 0, true, NULL) >= 0.1) + if (CL_TraceLine(org, v, v2, NULL, true, NULL, SUPERCONTENTS_SOLID) >= 0.1) break; } VectorSubtract(v2, org, v2); @@ -746,7 +745,7 @@ void CL_SparkShower (vec3_t org, vec3_t dir, int count) org2[0] = org[0] + 0.125f * lhrandom(-count, count); org2[1] = org[1] + 0.125f * lhrandom(-count, count); org2[2] = org[2] + 0.125f * lhrandom(-count, count); - CL_TraceLine(org, org2, org3, NULL, 0, true, NULL); + CL_TraceLine(org, org2, org3, NULL, true, NULL, SUPERCONTENTS_SOLID); particle(pt_grow, PARTICLE_BILLBOARD, 0x101010, 0x202020, tex_smoke[rand()&7], true, PBLEND_ADD, 3, 3, (1.0f / cl_particles_quality.value) * 255, (1.0f / cl_particles_quality.value) * 1024, 9999, -0.2, 0, org3[0], org3[1], org3[2], lhrandom(-8, 8), lhrandom(-8, 8), lhrandom(0, 16), 15, 0, 0, 0, 0, 0); } } @@ -790,7 +789,7 @@ void CL_BloodPuff (vec3_t org, vec3_t vel, int count) org2[0] = org[0] + 0.125f * lhrandom(-bloodcount, bloodcount); org2[1] = org[1] + 0.125f * lhrandom(-bloodcount, bloodcount); org2[2] = org[2] + 0.125f * lhrandom(-bloodcount, bloodcount); - CL_TraceLine(org, org2, org3, NULL, 0, true, NULL); + CL_TraceLine(org, org2, org3, NULL, true, NULL, SUPERCONTENTS_SOLID); particle(pt_blood, PARTICLE_BILLBOARD, 0xFFFFFF, 0xFFFFFF, tex_bloodparticle[rand()&7], true, PBLEND_MOD, 8, 8, cl_particles_blood_alpha.value * 768 / cl_particles_quality.value, cl_particles_blood_alpha.value * 384 / cl_particles_quality.value, 9999, 0, -1, org3[0], org3[1], org3[2], vel[0] + lhrandom(-s, s), vel[1] + lhrandom(-s, s), vel[2] + lhrandom(-s, s), 0, 0, 0, 0, 1, 0); bloodcount -= 16 / cl_particles_quality.value; } @@ -1072,7 +1071,7 @@ void CL_RocketTrail (vec3_t start, vec3_t end, int type, entity_t *ent) VectorMA(start, dec, vec, pos); len -= dec; - contents = CL_PointContents(pos); + contents = CL_PointQ1Contents(pos); if (contents == CONTENTS_SKY || contents == CONTENTS_LAVA) return; @@ -1265,7 +1264,7 @@ void CL_MoveParticles (void) VectorCopy(p->org, org); if (p->bounce) { - if (CL_TraceLine(p->oldorg, p->org, v, normal, 0, true, &hitent) < 1) + if (CL_TraceLine(p->oldorg, p->org, v, normal, true, &hitent, SUPERCONTENTS_SOLID) < 1) { VectorCopy(v, p->org); if (p->bounce < 0) @@ -1322,7 +1321,7 @@ void CL_MoveParticles (void) { f = p->friction * frametime; if (!content) - content = CL_PointContents(p->org); + content = CL_PointQ1Contents(p->org); if (content != CONTENTS_EMPTY) f *= 4; f = 1.0f - f; @@ -1335,7 +1334,7 @@ void CL_MoveParticles (void) { case pt_blood: if (!content) - content = CL_PointContents(p->org); + content = CL_PointQ1Contents(p->org); a = content; if (a != CONTENTS_EMPTY) { @@ -1353,7 +1352,7 @@ void CL_MoveParticles (void) break; case pt_bubble: if (!content) - content = CL_PointContents(p->org); + content = CL_PointQ1Contents(p->org); if (content != CONTENTS_WATER && content != CONTENTS_SLIME) { p->die = -1; @@ -1370,7 +1369,7 @@ void CL_MoveParticles (void) p->vel[2] = /*lhrandom(-32, 32) +*/ p->vel2[2]; } if (!content) - content = CL_PointContents(p->org); + content = CL_PointQ1Contents(p->org); a = content; if (a != CONTENTS_EMPTY && a != CONTENTS_SKY) p->die = -1; @@ -1820,7 +1819,7 @@ void R_DrawParticleCallback(const void *calldata1, int calldata2) #ifndef WORKINGLQUAKE if (fogenabled && p->blendmode != PBLEND_MOD) { - VectorSubtract(org, r_origin, fogvec); + VectorSubtract(org, r_vieworigin, fogvec); fog = exp(fogdensity/DotProduct(fogvec,fogvec)); ifog = 1 - fog; cr = cr * ifog; @@ -1833,9 +1832,6 @@ void R_DrawParticleCallback(const void *calldata1, int calldata2) cb += fogcolor[2] * fog; } } - cr *= r_colorscale; - cg *= r_colorscale; - cb *= r_colorscale; GL_Color(cr, cg, cb, ca); @@ -1861,7 +1857,7 @@ void R_DrawParticleCallback(const void *calldata1, int calldata2) if (p->orientation == PARTICLE_ORIENTED_DOUBLESIDED) { // double-sided - if (DotProduct(p->vel2, r_origin) > DotProduct(p->vel2, org)) + if (DotProduct(p->vel2, r_vieworigin) > DotProduct(p->vel2, org)) { VectorNegate(p->vel2, v); VectorVectors(v, right, up); @@ -1873,8 +1869,8 @@ void R_DrawParticleCallback(const void *calldata1, int calldata2) } else { - VectorScale(vright, p->scalex, right); - VectorScale(vup, p->scaley, up); + VectorScale(r_viewleft, -p->scalex, right); + VectorScale(r_viewup, p->scaley, up); } particle_vertex3f[ 0] = org[0] - right[0] - up[0]; particle_vertex3f[ 1] = org[1] - right[1] - up[1]; @@ -1951,7 +1947,7 @@ void R_DrawParticles (void) if ((!cl_numparticles) || (!r_drawparticles.integer)) return; - minparticledist = DotProduct(r_origin, vpn) + 4.0f; + minparticledist = DotProduct(r_vieworigin, r_viewforward) + 4.0f; #ifdef WORKINGLQUAKE glBindTexture(GL_TEXTURE_2D, particlefonttexture); @@ -1960,7 +1956,7 @@ void R_DrawParticles (void) glDepthMask(0); // LordHavoc: only render if not too close for (i = 0, p = particles;i < cl_numparticles;i++, p++) - if (DotProduct(p->org, vpn) >= minparticledist) + if (DotProduct(p->org, r_viewforward) >= minparticledist) R_DrawParticle(p); glDepthMask(1); glDisable(GL_BLEND); @@ -1969,7 +1965,7 @@ void R_DrawParticles (void) // LordHavoc: only render if not too close c_particles += cl_numparticles; for (i = 0, p = particles;i < cl_numparticles;i++, p++) - if (DotProduct(p->org, vpn) >= minparticledist || p->orientation == PARTICLE_BEAM) + if (DotProduct(p->org, r_viewforward) >= minparticledist || p->orientation == PARTICLE_BEAM) R_MeshQueue_AddTransparent(p->org, R_DrawParticleCallback, p, 0); #endif }