fading particles

This commit is contained in:
ethan merchant 2024-12-04 18:19:43 -05:00
parent 76fbe75242
commit 2c56f6fe52

View file

@ -23,7 +23,7 @@ static class VFX
index = (index + 1) % particles.Length;
Particle particle = particles[index];
particle.pos = pos;
particle.vel = Quat.FromAngles(Random.Shared.NextSingle() * 360, 0, 0) * Quat.FromAngles(0, Random.Shared.NextSingle() * 360, 0) * Vec3.Forward * 1.0f;
particle.vel = Quat.FromAngles(Random.Shared.NextSingle() * 360, 0, 0) * Quat.FromAngles(0, Random.Shared.NextSingle() * 360, 0) * Vec3.Forward * 6.0f;
particle.ori = Quat.Identity;
particle.scl = (1.0f / 3) * Maths.smooth_start(Random.Shared.NextSingle());
}
@ -37,17 +37,19 @@ static class VFX
if (particle.vel.MagnitudeSq > float.Epsilon)
{
particle.pos += particle.vel * Time.Stepf;
float scl_rad = particle.scl * 0.5f * 0.333f;
Vec3 next_pos = V.XYZ(
Maths.s_clamp(particle.pos.x, 2 - scl_rad),
Maths.s_clamp(particle.pos.y, 2 - scl_rad),
Maths.s_clamp(particle.pos.z, 2 - scl_rad)
);
if (next_pos.x != particle.pos.x || next_pos.y != particle.pos.y || next_pos.z != particle.pos.z)
{
particle.pos = next_pos;
particle.vel = Vec3.Zero;
}
particle.vel *= 1 - (3 * Time.Stepf);
particle.scl *= 1 - (3 * Time.Stepf);
// float scl_rad = particle.scl * 0.5f * 0.333f;
// Vec3 next_pos = V.XYZ(
// Maths.s_clamp(particle.pos.x, 2 - scl_rad),
// Maths.s_clamp(particle.pos.y, 2 - scl_rad),
// Maths.s_clamp(particle.pos.z, 2 - scl_rad)
// );
// if (next_pos.x != particle.pos.x || next_pos.y != particle.pos.y || next_pos.z != particle.pos.z)
// {
// particle.pos = next_pos;
// particle.vel = Vec3.Zero;
// }
}
}
}