Merge pull request #173 from teamfisk/ExplosionEffectV2

Explosion effect v2
This commit is contained in:
2016-03-12 15:25:12 +01:00
7 changed files with 138 additions and 141 deletions
+10 -1
View File
@@ -1333,7 +1333,12 @@ void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr<E
glUniform3fv(glGetUniformLocation(shaderHandle, "ExplosionOrigin"), 1, glm::value_ptr(job->ExplosionOrigin));
GLERROR("Bind 6 uniform");
glUniform1f(glGetUniformLocation(shaderHandle, "TimeSinceDeath"), job->TimeSinceDeath);
if (job->Reverse == false) {
glUniform1f(glGetUniformLocation(shaderHandle, "TimeSinceDeath"), job->TimeSinceDeath);
}
else {
glUniform1f(glGetUniformLocation(shaderHandle, "TimeSinceDeath"), (job->ExplosionDuration - job->TimeSinceDeath));
}
GLERROR("Bind 7 uniform");
glUniform1f(glGetUniformLocation(shaderHandle, "ExplosionDuration"), job->ExplosionDuration);
GLERROR("Bind 8 uniform");
@@ -1351,6 +1356,10 @@ void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr<E
GLERROR("Bind 14 uniform");
glUniform1i(glGetUniformLocation(shaderHandle, "ExponentialAccelaration"), job->ExponentialAccelaration);
GLERROR("Bind 15 uniform");
glUniform1i(glGetUniformLocation(shaderHandle, "Reverse"), job->Reverse);
GLERROR("Bind 15-2 uniform");
glUniform1f(glGetUniformLocation(shaderHandle, "ColorDistanceScalar"), job->ColorDistanceScalar);
GLERROR("Bind 15-3 uniform");
glUniform4fv(glGetUniformLocation(shaderHandle, "Color"), 1, glm::value_ptr(job->Color));
GLERROR("Bind 16 uniform");
+10 -7
View File
@@ -7,12 +7,15 @@ void ExplosionEffectSystem::UpdateComponent(EntityWrapper& entity, ComponentWrap
delay = std::max(0.0, delay - dt);
}
if (delay <= 0) {
double& timeSinceDeath = component["TimeSinceDeath"];
timeSinceDeath += (double)component["Speed"] * dt;
if (timeSinceDeath < 0 || timeSinceDeath > (double)component["ExplosionDuration"]) {
timeSinceDeath = 0.0;
}
}
if (delay <= 0) {
double& timeSinceDeath = component["TimeSinceDeath"];
timeSinceDeath += (double)component["Speed"] * dt;
if (timeSinceDeath < 0) {
timeSinceDeath = 0.0;
}
else if (timeSinceDeath >(double)component["ExplosionDuration"]) {
timeSinceDeath = (double)component["ExplosionDuration"];
}
}
}