1
0
Fork 0
forked from fte/fteqw

fix high fps particles on classic r_particlesystem, don't pass trailstate to fallback system, fix trail names in particle sets

git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3823 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
TimeServ 2011-06-18 13:05:14 +00:00
parent 9d4586b532
commit 9d87fd127c
5 changed files with 81 additions and 48 deletions

View file

@ -231,10 +231,30 @@ static void PClassic_ShutdownParticles(void)
particles = NULL;
}
// a classic trailstate is really just a float stored in a pointer variable...
// assuming float alignment/size is more strict than pointer
static float Classic_GetLeftover(trailstate_t **tsk)
{
float *f = (float *)tsk;
if (!f)
return 0;
return *f;
}
static void Classic_SetLeftover(trailstate_t **tsk, float leftover)
{
float *f = (float *)tsk;
if (f)
*f = leftover;
}
//called when an entity is removed from the world, taking its trailstate with it.
static void PClassic_DelinkTrailstate(trailstate_t **tsk)
{
//classic has no concept of trail states.
*tsk = NULL;
}
//wipes all the particles ready for the next map.
@ -599,10 +619,10 @@ static void Classic_TeleportSplash (vec3_t org)
}
}
static void Classic_ParticleTrail (vec3_t start, vec3_t end, vec3_t *trail_origin, effect_type_t type)
static float Classic_ParticleTrail (vec3_t start, vec3_t end, float leftover, effect_type_t type)
{
vec3_t point, delta, dir;
float len;
float len, rlen, scale;
int i, j, num_particles;
cparticle_t *p;
static int tracercount;
@ -613,16 +633,22 @@ static void Classic_ParticleTrail (vec3_t start, vec3_t end, vec3_t *trail_origi
goto done;
VectorScale(delta, 1 / len, dir); //unit vector in direction of trail
len += leftover;
rlen = len;
switch (type)
{
case ALT_ROCKET_TRAIL:
len /= 1.5; break;
scale = 1.5; break;
case BLOOD_TRAIL:
len /= 6; break;
scale = 6; break;
default:
len /= 3; break;
scale = 3; break;
}
len /= scale;
leftover = rlen - ((int)(len) * scale);
if (!(num_particles = (int) len))
goto done;
@ -708,8 +734,7 @@ static void Classic_ParticleTrail (vec3_t start, vec3_t end, vec3_t *trail_origi
VectorAdd (point, delta, point);
}
done:
if (trail_origin)
VectorCopy(point, *trail_origin);
return leftover;
}
@ -717,10 +742,13 @@ done:
//builds a trail from here to there. The trail state can be used to remember how far you got last frame.
static int PClassic_ParticleTrail (vec3_t startpos, vec3_t end, int type, trailstate_t **tsk)
{
float leftover;
if (type == P_INVALID)
return 1;
Classic_ParticleTrail(startpos, end, NULL, type);
leftover = Classic_ParticleTrail(startpos, end, Classic_GetLeftover(tsk), type);
Classic_SetLeftover(tsk, leftover);
return 0;
}

View file

@ -40,7 +40,10 @@ static void PNULL_ShutdownParticles(void)
{
}
static void PNULL_DelinkTrailstate(trailstate_t **tsk){}
static void PNULL_DelinkTrailstate(trailstate_t **tsk)
{
*tsk = NULL;
}
static void PNULL_ClearParticles (void){}
static void PNULL_DrawParticles(void)
{

View file

@ -2328,7 +2328,7 @@ static int PScript_RunParticleEffectState (vec3_t org, vec3_t dir, float count,
trailstate_t *ts;
if (typenum >= FALLBACKBIAS && fallback)
return fallback->RunParticleEffectState(org, dir, count, typenum-FALLBACKBIAS, tsk);
return fallback->RunParticleEffectState(org, dir, count, typenum-FALLBACKBIAS, NULL);
if (typenum < 0 || typenum >= numparticletypes)
return 1;
@ -3613,8 +3613,10 @@ static int PScript_ParticleTrail (vec3_t startpos, vec3_t end, int type, trailst
{
part_type_t *ptype = &part_type[type];
// TODO: fallback particle system won't have a decent trailstate which will mess up
// high fps trails
if (type >= FALLBACKBIAS && fallback)
return fallback->ParticleTrail(startpos, end, type-FALLBACKBIAS, tsk);
return fallback->ParticleTrail(startpos, end, type-FALLBACKBIAS, NULL);
if (type < 0 || type >= numparticletypes)
return 1; //bad value

View file

@ -346,7 +346,7 @@ void P_SelectableTrail(model_t *model, cvar_t *selection, int mdleffect, int mdl
model->traildefaultindex = 154;
break;
case 9: // rail trail
model->particletrail = P_FindParticleType("TR_RAILTRAIL");
model->particletrail = P_FindParticleType("TE_RAILTRAIL");
model->traildefaultindex = 15;
break;
}
@ -393,57 +393,57 @@ void P_DefaultTrail (model_t *model)
}
else if (model->flags & EFH2_BLOODSHOT) //these are the hexen2 ones.
{
model->particletrail = P_FindParticleType("t_bloodshot");
model->particletrail = P_FindParticleType("tr_bloodshot");
model->traildefaultindex = 136;
}
else if (model->flags & EFH2_FIREBALL)
{
model->particletrail = P_FindParticleType("t_fireball");
model->particletrail = P_FindParticleType("tr_fireball");
model->traildefaultindex = 424;
}
else if (model->flags & EFH2_ACIDBALL)
{
model->particletrail = P_FindParticleType("t_acidball");
model->particletrail = P_FindParticleType("tr_acidball");
model->traildefaultindex = 440;
}
else if (model->flags & EFH2_ICE)
{
model->particletrail = P_FindParticleType("t_ice");
model->particletrail = P_FindParticleType("tr_ice");
model->traildefaultindex = 408;
}
else if (model->flags & EFH2_SPIT)
{
model->particletrail = P_FindParticleType("t_spit");
model->particletrail = P_FindParticleType("tr_spit");
model->traildefaultindex = 260;
}
else if (model->flags & EFH2_SPELL)
{
model->particletrail = P_FindParticleType("t_spell");
model->particletrail = P_FindParticleType("tr_spell");
model->traildefaultindex = 260;
}
else if (model->flags & EFH2_VORP_MISSILE)
{
model->particletrail = P_FindParticleType("t_vorpmissile");
model->particletrail = P_FindParticleType("tr_vorpmissile");
model->traildefaultindex = 302;
}
else if (model->flags & EFH2_SET_STAFF)
{
model->particletrail = P_FindParticleType("t_setstaff");
model->particletrail = P_FindParticleType("tr_setstaff");
model->traildefaultindex = 424;
}
else if (model->flags & EFH2_MAGICMISSILE)
{
model->particletrail = P_FindParticleType("t_magicmissile");
model->particletrail = P_FindParticleType("tr_magicmissile");
model->traildefaultindex = 149;
}
else if (model->flags & EFH2_BONESHARD)
{
model->particletrail = P_FindParticleType("t_boneshard");
model->particletrail = P_FindParticleType("tr_boneshard");
model->traildefaultindex = 384;
}
else if (model->flags & EFH2_SCARAB)
{
model->particletrail = P_FindParticleType("t_scarab");
model->particletrail = P_FindParticleType("tr_scarab");
model->traildefaultindex = 254;
}
else

View file

@ -47,7 +47,7 @@ char *particle_set_spikeset =
"spawnvel 10\n"
"}\n"
"r_part t_rocket\n"
"r_part tr_rocket\n"
"{\n"
"texture \"particles/fteparticlefont.tga\"\n"
"tcoords 97 97 191 191 256\n"
@ -78,7 +78,7 @@ char *particle_set_spikeset =
"cliptype rockettail\n"
"}\n"
"r_part t_altrocket\n"
"r_part tr_altrocket\n"
"{\n"
"texture \"particles/fteparticlefont.tga\"\n"
"tcoords 97 97 191 191 256\n"
@ -188,7 +188,7 @@ char *particle_set_spikeset =
"rgb 150 150 150\n"
"}\n"
"r_part t_grenade\n"
"r_part tr_grenade\n"
"{\n"
"texture \"particles/fteparticlefont.tga\"\n"
"tcoords 97 97 191 191 256\n"
@ -207,7 +207,7 @@ char *particle_set_spikeset =
"}\n"
//cool's blood trails (cos they're cooler)
"r_part t_gib\n"
"r_part tr_gib\n"
"{\n"
"texture \"particles/fteparticlefont.tga\"\n"
"tcoords 1 1 63 63 256 2 64\n"
@ -226,7 +226,7 @@ char *particle_set_spikeset =
"stains 5\n"
"}\n"
"r_part t_zomgib\n"
"r_part tr_slightblood\n"
"{\n"
"texture \"particles/fteparticlefont.tga\"\n"
"tcoords 1 1 63 63 256 2 64\n"
@ -245,7 +245,7 @@ char *particle_set_spikeset =
"stains 5\n"
"}\n"
"r_part t_tracer\n"
"r_part tr_wizspike\n"
"{\n"
"texture \"particles/fteparticlefont.tga\"\n"
"tcoords 1 97 95 191 256\n"
@ -260,7 +260,7 @@ char *particle_set_spikeset =
"scalefactor 0.825\n"
"}\n"
"r_part t_tracer2\n"
"r_part tr_knightspike\n"
"{\n"
"texture \"particles/fteparticlefont.tga\"\n"
"tcoords 1 97 95 191 256\n"
@ -275,7 +275,7 @@ char *particle_set_spikeset =
"scalefactor 0.825\n"
"}\n"
"r_part t_tracer3\n"
"r_part tr_vorespike\n"
"{\n"
"texture \"particles/fteparticlefont.tga\"\n"
"tcoords 1 97 95 191 256\n"
@ -727,7 +727,7 @@ char *particle_set_spikeset =
char *particle_set_faithful =
// faithful, by TimeServ
"r_part t_gib\n"
"r_part tr_gib\n"
"{\n"
"texture \"particles/quake\"\n"
"step 3\n"
@ -742,7 +742,7 @@ char *particle_set_faithful =
"stains 1\n"
"}\n"
"r_part t_zomgib\n"
"r_part tr_slightblood\n"
"{\n"
"texture \"particles/quake\"\n"
"step 6\n"
@ -757,7 +757,7 @@ char *particle_set_faithful =
"stains 1\n"
"}\n"
"r_part t_tracer3\n"
"r_part tr_vorespike\n"
"{\n"
"texture \"particles/quake\"\n"
"step 3\n"
@ -768,7 +768,7 @@ char *particle_set_faithful =
"spawnorg 8\n"
"}\n"
"r_part t_tracer\n"
"r_part tr_wizspike\n"
"{\n"
"texture \"particles/quake\"\n"
"step 3\n"
@ -781,7 +781,7 @@ char *particle_set_faithful =
"spawnmode tracer\n"
"}\n"
"r_part t_tracer2\n"
"r_part tr_knightspike\n"
"{\n"
"texture \"particles/quake\"\n"
"step 3\n"
@ -794,7 +794,7 @@ char *particle_set_faithful =
"spawnmode tracer\n"
"}\n"
"r_part t_rocket\n"
"r_part tr_rocket\n"
"{\n"
"texture \"particles/quake\"\n"
"step 3\n"
@ -812,7 +812,7 @@ char *particle_set_faithful =
"gravity -40\n"
"}\n"
"r_part t_altrocket\n"
"r_part tr_altrocket\n"
"{\n"
"texture \"particles/quake\"\n"
"step 3\n"
@ -825,7 +825,7 @@ char *particle_set_faithful =
"gravity -40\n"
"}\n"
"r_part t_grenade\n"
"r_part tr_grenade\n"
"{\n"
"texture \"particles/quake\"\n"
"step 3\n"
@ -1031,7 +1031,7 @@ char *particle_set_faithful =
char *particle_set_highfps =
// highfps, originally submitted by 'ShadowWalker'
// rehashed by TimeServ
"r_part t_gib\n"
"r_part tr_gib\n"
"{\n"
"texture \"particles/bloodtrail\"\n"
"step 12\n"
@ -1042,7 +1042,7 @@ char *particle_set_highfps =
"rgb 64 0 0\n"
"rgbdelta -128 0 0\n"
"}\n"
"r_part t_zomgib\n"
"r_part tr_slightblood\n"
"{\n"
"texture \"particles/bloodtrail\"\n"
"step 16\n"
@ -1054,7 +1054,7 @@ char *particle_set_highfps =
"rgbdelta -128 0 0\n"
"}\n"
"r_part t_tracer\n"
"r_part tr_wizspike\n"
"{\n"
"texture \"particles/tracer\"\n"
"scale 23\n"
@ -1063,7 +1063,7 @@ char *particle_set_highfps =
"die 0.5\n"
"}\n"
"r_part t_tracer2\n"
"r_part tr_knightspike\n"
"{\n"
"texture \"particles/tracer\"\n"
"scale 23\n"
@ -1072,7 +1072,7 @@ char *particle_set_highfps =
"rgb 192 96 0\n"
"}\n"
"r_part t_tracer3\n"
"r_part tr_vorespike\n"
"{\n"
"texture \"particles/tracer\"\n"
"scale 23\n"
@ -1212,7 +1212,7 @@ char *particle_set_highfps =
"spawnvel 25 4\n"
"}\n"
"r_part t_grenade\n"
"r_part tr_grenade\n"
"{\n"
"texture \"particles/smoke\"\n"
"step 20\n"
@ -1222,7 +1222,7 @@ char *particle_set_highfps =
"rgb 128 128 128\n"
"}\n"
"r_part t_rocket\n"
"r_part tr_rocket\n"
"{\n"
"texture \"particles/rocket\"\n"
"step 15\n"
@ -1233,7 +1233,7 @@ char *particle_set_highfps =
"assoc t_grenade\n"
"}\n"
"r_part t_altrocket\n"
"r_part tr_altrocket\n"
"{\n"
"texture \"particles/rocket\"\n"
"step 15\n"