apply velocity over the frames until hitting box inner walls

This commit is contained in:
ethan merchant 2024-11-24 13:19:30 -05:00
parent 7de0458ef4
commit e1d72e8f3d

View file

@ -29,6 +29,28 @@ static class VFX
}
}
public static void Frame()
{
for (int i = 0; i < particles.Length; i++)
{
Particle particle = particles[i];
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, Mono.SD_X - 0.5f - scl_rad),
Maths.s_clamp(particle.pos.y, Mono.SD_Y - 0.5f - scl_rad),
Maths.s_clamp(particle.pos.z, Mono.SD_Z - 0.5f - 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;
}
}
}
}
}
public class Particle