Skip to content

Commit

Permalink
Quake4: add effect color's alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
glKarin committed Sep 10, 2024
1 parent e648507 commit 2698f1a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 68 deletions.
23 changes: 13 additions & 10 deletions Q3E/src/main/jni/doom3/neo/raven/bse/BSE_Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -527,18 +527,19 @@ idVec3 rvDeclEffectParser::ParseTint(rvBSEParticleStage *stage, int n)
stage->color[0] = p[0];
stage->color[1] = p[1];
stage->color[2] = p[2];
stage->color[3] = 1.0;
//stage->entityColor = false; // comment it, for line lighting

stage->fadeColor[0] = p[0];
stage->fadeColor[1] = p[1];
stage->fadeColor[2] = p[2];
}
#if 0
else
{
stage->fadeColor[0] = p[0];
stage->fadeColor[1] = p[1];
stage->fadeColor[2] = p[2];
stage->fadeColor[3] = 1.0;
stage->fade = true;
}
#endif
return p;
}

Expand All @@ -560,21 +561,21 @@ void rvDeclEffectParser::ParseFade(rvBSEParticleStage *stage, int n)
idVec3 p(0.0f, 0.0f, 0.0f);
ParsePoint(p);
if(n == STAGE_START)
stage->fadeInFraction = p[0];
stage->color[3] = p[0];
else
stage->fadeOutFraction = p[0];
stage->fadeOutFraction = p[0]; // TODO: always fade out
stage->fade = true;
stage->fadeColor[3] = p[0];
}
else if(!idStr::Icmp(token, "line"))
{
idBounds b;
b.Zero();
ParseLine(b);
if(n == STAGE_START)
stage->fadeInFraction = b[0][0];
stage->color[3] = b[0][0];
else
stage->fadeOutFraction = b[0][0];
stage->fadeOutFraction = b[0][0]; // TODO: always fade out
stage->fade = true;
stage->fadeColor[3] = b[0][0];
}
else
{
Expand Down Expand Up @@ -1348,6 +1349,8 @@ rvBSEParticleStage * rvDeclEffectParser::Alloc_rvBSEParticleStage(void)
stage->speed.from = 0;
stage->speed.to = 0;
stage->deadTime = 0;

stage->fade = false;
return stage;
}

Expand Down
67 changes: 9 additions & 58 deletions Q3E/src/main/jni/doom3/neo/raven/bse/BSE_Particle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,25 +182,7 @@ void rvBSEParticle::ParseParametric(idLexer &src, rvBSEParticleParm *parm)
return;
}

#ifdef _HUMANHEAD
#define NEG_NUMBER_TOKEN(token) \
if(!idStr::Cmp(token, "-")) { \
if(!src.ReadToken(&token)) { \
src.Error("`-` missing number"); \
return; \
} \
}
#endif

#ifdef _HUMANHEAD
if (token.IsNumeric() || !idStr::Cmp(token, "-"))
#else
if (token.IsNumeric())
#endif
{
#ifdef _HUMANHEAD
NEG_NUMBER_TOKEN(token);
#endif
if (token.IsNumeric()) {
// can have a to + 2nd parm
parm->from = parm->to = atof(token);

Expand All @@ -211,31 +193,11 @@ void rvBSEParticle::ParseParametric(idLexer &src, rvBSEParticleParm *parm)
return;
}

#ifdef _HUMANHEAD
NEG_NUMBER_TOKEN(token);
#endif
parm->to = atof(token);
} else {
src.UnreadToken(&token);
}
}
#ifdef _HUMANHEAD
if(src.ReadToken(&token)) // a to b with c
{
if(!idStr::Icmp(token, "with"))
{
NEG_NUMBER_TOKEN(token);
src.ReadToken(&token); // a number
}
else
src.UnreadToken(&token);
}
else
src.UnreadToken(&token);
#endif
#ifdef _HUMANHEAD
#undef NEG_NUMBER_TOKEN
#endif
} else {
// table
parm->table = static_cast<const idDeclTable *>(declManager->FindType(DECL_TABLE, token, false));
Expand Down Expand Up @@ -477,13 +439,6 @@ rvBSEParticleStage *rvBSEParticle::ParseParticleStage(idLexer &src)
continue;
}

#ifdef _HUMANHEAD
if (!token.Icmp("lowSkippable")) {
src.ReadToken(&token);
continue;
}
#endif

src.Error("unknown token %s\n", token.c_str());
}

Expand Down Expand Up @@ -536,17 +491,6 @@ bool rvBSEParticle::Parse(const char *text, const int textLength, bool noCaching
continue;
}

#ifdef _HUMANHEAD
if (!token.Icmp("bounds")) {
src.ParseFloat();
src.ParseFloat();
src.ParseFloat();
src.ParseFloat();
src.ParseFloat();
src.ParseFloat();
continue;
}
#endif

src.Warning("bad token %s", token.c_str());
MakeDefault();
Expand Down Expand Up @@ -921,13 +865,20 @@ void rvBSEParticleStage::Default()
fadeColor.y = 0.0f;
fadeColor.z = 0.0f;
fadeColor.w = 0.0f;
#if 1
fadeInFraction = 0.0f;
fadeOutFraction = 0.0f;
#else
fadeInFraction = 0.1f;
fadeOutFraction = 0.25f;
#endif
fadeIndexFraction = 0.0f;
boundsExpansion = 0.0f;
randomDistribution = true;
entityColor = false;
cycleMsec = (particleLife + deadTime) * 1000;

fade = false;
}

/*
Expand Down Expand Up @@ -1479,7 +1430,7 @@ rvBSEParticleStage::ParticleColors
*/
void rvBSEParticleStage::ParticleColors(rvBSE_particleGen_t *g, idDrawVert *verts) const
{
float fadeFraction = 1.0f;
float fadeFraction = fade ? g->frac : 1.0f;

// most particles fade in at the beginning and fade out at the end
if (g->frac < fadeInFraction) {
Expand Down
1 change: 1 addition & 0 deletions Q3E/src/main/jni/doom3/neo/raven/bse/BSE_Particle.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ class rvBSEParticleStage

idBounds bounds; // derived

bool fade;
int rvptype;
idRenderModel *model;
};
Expand Down

0 comments on commit 2698f1a

Please sign in to comment.