Added cg_atmospheric to the Linux Makefile and added a CVS header to

cg_atmospheric and indented it like the other files.
This commit is contained in:
Richard Allen 2002-08-25 19:19:49 +00:00
parent 2cea4d3acc
commit 50d562f7f9
2 changed files with 283 additions and 295 deletions

View file

@ -74,6 +74,7 @@ CGOBJ = \
$(CGDIRNAME)/cg_servercmds.o \
$(CGDIRNAME)/cg_snapshot.o \
$(CGDIRNAME)/cg_view.o \
$(CGDIRNAME)/cg_atmospheric.o \
$(CGDIRNAME)/cg_weapons.o
UIOBJ = \

View file

@ -1,3 +1,16 @@
//-----------------------------------------------------------------------------
//
// $Id$
//
//-----------------------------------------------------------------------------
//
// $Log$
// Revision 1.2 2002/08/25 19:19:49 jbravo
// Added cg_atmospheric to the Linux Makefile and added a CVS header to
// cg_atmospheric and indented it like the other files.
//
//
//-----------------------------------------------------------------------------
/*
** Copyright (C) 2000, 2001 by the Q3F Development team
** All rights reserved.
@ -18,11 +31,8 @@
#define MAX_ATMOSPHERIC_EFFECTSHADERS 6 // maximum different effectshaders for an atmospheric effect
#define ATMOSPHERIC_DROPDELAY 1000
#define ATMOSPHERIC_CUTHEIGHT 800
#define ATMOSPHERIC_RAIN_SPEED 1.1f * DEFAULT_GRAVITY
#define ATMOSPHERIC_RAIN_HEIGHT 150
#define ATMOSPHERIC_SNOW_SPEED 0.1f * DEFAULT_GRAVITY
#define ATMOSPHERIC_SNOW_HEIGHT 10
@ -38,18 +48,13 @@ typedef struct cg_atmosphericEffect_s {
cg_atmosphericParticle_t particles[MAX_ATMOSPHERIC_PARTICLES];
qhandle_t effectshaders[MAX_ATMOSPHERIC_EFFECTSHADERS];
qhandle_t effectwatershader, effectlandshader;
int lastRainTime, numDrops;
int gustStartTime, gustEndTime;
int baseStartTime, baseEndTime;
int gustMinTime, gustMaxTime;
int changeMinTime, changeMaxTime;
int baseMinTime, baseMaxTime;
int lastRainTime, numDrops, gustStartTime, gustEndTime;
int baseStartTime, baseEndTime, gustMinTime, gustMaxTime;
int changeMinTime, changeMaxTime, baseMinTime, baseMaxTime;
float baseWeight, gustWeight;
int baseDrops, gustDrops;
int numEffectShaders;
int baseDrops, gustDrops, numEffectShaders;
qboolean waterSplash, landSplash;
vec3_t baseVec, gustVec;
qboolean(*ParticleCheckVisible) (cg_atmosphericParticle_t * particle);
qboolean(*ParticleGenerate) (cg_atmosphericParticle_t * particle, vec3_t currvec, float currweight);
void (*ParticleRender) (cg_atmosphericParticle_t * particle);
@ -61,16 +66,15 @@ static cg_atmosphericEffect_t cg_atmFx;
** Render utility functions
*/
void CG_EffectMark( qhandle_t markShader, const vec3_t origin, const vec3_t dir, float alpha, float radius ) {
void CG_EffectMark(qhandle_t markShader, const vec3_t origin, const vec3_t dir, float alpha, float radius)
{
// 'quick' version of the CG_ImpactMark function
vec3_t axis[3];
vec3_t axis[3], originalPoints[4];
float texCoordScale;
vec3_t originalPoints[4];
byte colors[4];
int i;
polyVert_t *v;
polyVert_t verts[4];
polyVert_t *v, verts[4];
if (!cg_addMarks.integer) {
return;
@ -79,7 +83,6 @@ void CG_EffectMark( qhandle_t markShader, const vec3_t origin, const vec3_t di
if (radius <= 0) {
CG_Error("CG_EffectMark called with <= 0 radius");
}
// create the texture axis
VectorNormalize2(dir, axis[0]);
PerpendicularVector(axis[1], axis[0]);
@ -105,7 +108,6 @@ void CG_EffectMark( qhandle_t markShader, const vec3_t origin, const vec3_t di
vec3_t delta;
VectorCopy(originalPoints[i], v->xyz);
VectorSubtract(v->xyz, origin, delta);
v->st[0] = 0.5 + DotProduct(delta, axis[1]) * texCoordScale;
v->st[1] = 0.5 + DotProduct(delta, axis[2]) * texCoordScale;
@ -157,8 +159,7 @@ static qboolean CG_RainParticleGenerate( cg_atmosphericParticle_t *particle, vec
testpoint[2] = origz = cg.refdef.vieworg[2];
testend[2] = testpoint[2] + MAX_ATMOSPHERIC_HEIGHT;
while( 1 )
{
while (1) {
if (testpoint[2] >= MAX_ATMOSPHERIC_HEIGHT)
return (qfalse);
if (testend[2] >= MAX_ATMOSPHERIC_HEIGHT)
@ -168,12 +169,12 @@ static qboolean CG_RainParticleGenerate( cg_atmosphericParticle_t *particle, vec
{
testpoint[2] += 64;
testend[2] = testpoint[2] + MAX_ATMOSPHERIC_HEIGHT;
}
else if( tr.fraction == 1 ) // Didn't hit anything, we're (probably) outside the world
} else if (tr.fraction == 1) // Didn't hit anything, we're (probably) outside the world
return (qfalse);
else if (tr.surfaceFlags & SURF_SKY) // Hit sky, this is where we start.
break;
else return( qfalse );
else
return (qfalse);
}
particle->active = qtrue;
@ -216,28 +217,27 @@ static void CG_RainParticleRender( cg_atmosphericParticle_t *particle )
VectorCopy(particle->pos, start);
len = particle->height;
if( start[2] <= particle->minz )
{
if (start[2] <= particle->minz) {
// Stop rain going through surfaces.
len = particle->height - particle->minz + start[2];
frac = start[2];
VectorMA(start, len - particle->height, particle->deltaNormalized, start);
if( !cg_lowEffects.integer )
{
if (!cg_lowEffects.integer) {
frac = (ATMOSPHERIC_CUTHEIGHT - particle->minz + frac) / (float) ATMOSPHERIC_CUTHEIGHT;
// Splash effects on different surfaces
if( particle->contents & (CONTENTS_WATER|CONTENTS_SLIME) )
{
if (particle->contents & (CONTENTS_WATER | CONTENTS_SLIME)) {
// Water splash
if (cg_atmFx.effectwatershader && frac > 0 && frac < 1)
CG_EffectMark( cg_atmFx.effectwatershader, start, particle->surfacenormal, frac * 0.5, 8 - frac * 8 );
}
else if( !(particle->contents & CONTENTS_LAVA) && !(particle->surface & (SURF_NODAMAGE|SURF_NOIMPACT|SURF_NOMARKS|SURF_SKY)) )
{
CG_EffectMark(cg_atmFx.effectwatershader, start, particle->surfacenormal,
frac * 0.5, 8 - frac * 8);
} else if (!(particle->contents & CONTENTS_LAVA)
&& !(particle->
surface & (SURF_NODAMAGE | SURF_NOIMPACT | SURF_NOMARKS | SURF_SKY))) {
// Solid splash
if (cg_atmFx.effectlandshader && frac > 0 && frac < 1)
CG_ImpactMark( cg_atmFx.effectlandshader, start, particle->surfacenormal, 0, 1, 1, 1, frac * 0.5, qfalse, 3 - frac * 2, qtrue );
CG_ImpactMark(cg_atmFx.effectlandshader, start, particle->surfacenormal, 0, 1,
1, 1, frac * 0.5, qfalse, 3 - frac * 2, qtrue);
}
}
}
@ -309,8 +309,7 @@ static qboolean CG_SnowParticleGenerate( cg_atmosphericParticle_t *particle, vec
testpoint[2] = origz = cg.refdef.vieworg[2];
testend[2] = testpoint[2] + MAX_ATMOSPHERIC_HEIGHT;
while( 1 )
{
while (1) {
if (testpoint[2] >= MAX_ATMOSPHERIC_HEIGHT)
return (qfalse);
if (testend[2] >= MAX_ATMOSPHERIC_HEIGHT)
@ -320,12 +319,12 @@ static qboolean CG_SnowParticleGenerate( cg_atmosphericParticle_t *particle, vec
{
testpoint[2] += 64;
testend[2] = testpoint[2] + MAX_ATMOSPHERIC_HEIGHT;
}
else if( tr.fraction == 1 ) // Didn't hit anything, we're (probably) outside the world
} else if (tr.fraction == 1) // Didn't hit anything, we're (probably) outside the world
return (qfalse);
else if (tr.surfaceFlags & SURF_SKY) // Hit sky, this is where we start.
break;
else return( qfalse );
else
return (qfalse);
}
particle->active = qtrue;
@ -374,8 +373,7 @@ static void CG_SnowParticleRender( cg_atmosphericParticle_t *particle )
start[1] += 24 * (1 - particle->deltaNormalized[2]) * cosTumbling;
len = particle->height;
if( start[2] <= particle->minz )
{
if (start[2] <= particle->minz) {
// Stop snow going through surfaces.
len = particle->height - particle->minz + start[2];
frac = start[2];
@ -441,7 +439,8 @@ static void CG_EffectGust()
int diff;
cg_atmFx.baseEndTime = cg.time + cg_atmFx.baseMinTime + (rand() % (cg_atmFx.baseMaxTime - cg_atmFx.baseMinTime));
cg_atmFx.baseEndTime =
cg.time + cg_atmFx.baseMinTime + (rand() % (cg_atmFx.baseMaxTime - cg_atmFx.baseMinTime));
diff = cg_atmFx.changeMaxTime - cg_atmFx.changeMinTime;
cg_atmFx.gustStartTime = cg_atmFx.baseEndTime + cg_atmFx.changeMinTime + (diff ? (rand() % diff) : 0);
diff = cg_atmFx.gustMaxTime - cg_atmFx.gustMinTime;
@ -457,30 +456,28 @@ static qboolean CG_EffectGustCurrent( vec3_t curr, float *weight, int *num )
vec3_t temp;
float frac;
if( cg.time < cg_atmFx.baseEndTime )
{
if (cg.time < cg_atmFx.baseEndTime) {
VectorCopy(cg_atmFx.baseVec, curr);
*weight = cg_atmFx.baseWeight;
*num = cg_atmFx.baseDrops;
}
else {
} else {
VectorSubtract(cg_atmFx.gustVec, cg_atmFx.baseVec, temp);
if( cg.time < cg_atmFx.gustStartTime )
{
frac = ((float)(cg.time - cg_atmFx.baseEndTime))/((float)(cg_atmFx.gustStartTime - cg_atmFx.baseEndTime));
if (cg.time < cg_atmFx.gustStartTime) {
frac =
((float) (cg.time - cg_atmFx.baseEndTime)) /
((float) (cg_atmFx.gustStartTime - cg_atmFx.baseEndTime));
VectorMA(cg_atmFx.baseVec, frac, temp, curr);
*weight = cg_atmFx.baseWeight + (cg_atmFx.gustWeight - cg_atmFx.baseWeight) * frac;
*num = cg_atmFx.baseDrops + ((float) (cg_atmFx.gustDrops - cg_atmFx.baseDrops)) * frac;
}
else if( cg.time < cg_atmFx.gustEndTime )
{
} else if (cg.time < cg_atmFx.gustEndTime) {
VectorCopy(cg_atmFx.gustVec, curr);
*weight = cg_atmFx.gustWeight;
*num = cg_atmFx.gustDrops;
}
else
{
frac = 1.0 - ((float)(cg.time - cg_atmFx.gustEndTime))/((float)(cg_atmFx.baseStartTime - cg_atmFx.gustEndTime));
} else {
frac =
1.0 -
((float) (cg.time - cg_atmFx.gustEndTime)) /
((float) (cg_atmFx.baseStartTime - cg_atmFx.gustEndTime));
VectorMA(cg_atmFx.baseVec, frac, temp, curr);
*weight = cg_atmFx.baseWeight + (cg_atmFx.gustWeight - cg_atmFx.baseWeight) * frac;
*num = cg_atmFx.baseDrops + ((float) (cg_atmFx.gustDrops - cg_atmFx.baseDrops)) * frac;
@ -500,13 +497,11 @@ static void CG_EP_ParseFloats( char *floatstr, float *f1, float *f2 )
Q_strncpyz(buff, floatstr, sizeof(buff));
for (middleptr = buff; *middleptr && *middleptr != ' '; middleptr++);
if( *middleptr )
{
if (*middleptr) {
*middleptr++ = 0;
*f1 = atof(floatstr);
*f2 = atof(middleptr);
}
else {
} else {
*f1 = *f2 = atof(floatstr);
}
}
@ -540,13 +535,11 @@ void CG_EffectParse( const char *effectstr )
// Parse the parameter string
Q_strncpyz(workbuff, effectstr, sizeof(workbuff));
for( startptr = workbuff; *startptr; )
{
for (startptr = workbuff; *startptr;) {
for (eqptr = startptr; *eqptr && *eqptr != '=' && *eqptr != ','; eqptr++);
if (!*eqptr)
break; // No more string
if( *eqptr == ',' )
{
if (*eqptr == ',') {
startptr = eqptr + 1; // Bad argument, continue
continue;
}
@ -555,8 +548,7 @@ void CG_EffectParse( const char *effectstr )
if (*endptr)
*endptr++ = 0;
if( !type )
{
if (!type) {
if (Q_stricmp(startptr, "T")) {
cg_atmFx.numDrops = 0;
CG_Printf("Atmospheric effect must start with a type.\n");
@ -581,8 +573,7 @@ void CG_EffectParse( const char *effectstr )
CG_Printf("Only effect type 'rain' and 'snow' are supported.\n");
return;
}
}
else {
} else {
if (!Q_stricmp(startptr, "B"))
CG_EP_ParseFloats(eqptr, &bmin, &bmax);
else if (!Q_stricmp(startptr, "C"))
@ -599,13 +590,13 @@ void CG_EffectParse( const char *effectstr )
CG_EP_ParseFloats(eqptr, &wsplash, &lsplash);
else if (!Q_stricmp(startptr, "D"))
CG_EP_ParseFloats(eqptr, &bdrop, &gdrop);
else CG_Printf( "Unknown effect key '%s'.\n", startptr );
else
CG_Printf("Unknown effect key '%s'.\n", startptr);
}
startptr = endptr;
}
if( !type )
{
if (!type) {
// No effects
cg_atmFx.numDrops = -1;
@ -642,7 +633,9 @@ void CG_EffectParse( const char *effectstr )
// Snow
} else if (!Q_stricmp(type, "snow")) {
for (cg_atmFx.numEffectShaders = 0; cg_atmFx.numEffectShaders < 6; cg_atmFx.numEffectShaders++) {
if( !( cg_atmFx.effectshaders[cg_atmFx.numEffectShaders] = trap_R_RegisterShader( va("gfx/atmosphere/snowflake0%i", cg_atmFx.numEffectShaders ) ) ) )
if (!
(cg_atmFx.effectshaders[cg_atmFx.numEffectShaders] =
trap_R_RegisterShader(va("gfx/atmosphere/snowflake0%i", cg_atmFx.numEffectShaders))))
cg_atmFx.effectshaders[cg_atmFx.numEffectShaders] = -1; // we had some kind of a problem
}
cg_atmFx.waterSplash = 0;
@ -678,22 +671,17 @@ void CG_AddAtmosphericEffects()
max = cg_lowEffects.integer ? (cg_atmFx.numDrops >> 1) : cg_atmFx.numDrops;
if (CG_EffectGustCurrent(currvec, &currweight, &currnum))
CG_EffectGust(); // Recalculate gust parameters
for( curr = 0; curr < max; curr++ )
{
for (curr = 0; curr < max; curr++) {
particle = &cg_atmFx.particles[curr];
if( !cg_atmFx.ParticleCheckVisible( particle ) )
{
if (!cg_atmFx.ParticleCheckVisible(particle)) {
// Effect has terminated / fallen from screen view
if( !particle->nextDropTime )
{
if (!particle->nextDropTime) {
// Stop rain being synchronized
particle->nextDropTime = rand() % ATMOSPHERIC_DROPDELAY;
}
else if( currnum < curr || particle->nextDropTime > cg.time )
} else if (currnum < curr || particle->nextDropTime > cg.time)
continue;
if( !cg_atmFx.ParticleGenerate( particle, currvec, currweight ) )
{
if (!cg_atmFx.ParticleGenerate(particle, currvec, currweight)) {
// Ensure it doesn't attempt to generate every frame, to prevent
// 'clumping' when there's only a small sky area available.
particle->nextDropTime = cg.time + ATMOSPHERIC_DROPDELAY;
@ -707,7 +695,6 @@ void CG_AddAtmosphericEffects()
cg_atmFx.lastRainTime = cg.time;
}
/*
** G_AtmosphericKludge
*/