From e1d72e8f3ddf8da23a51587f8a496c05790688c4 Mon Sep 17 00:00:00 2001 From: spatialfree Date: Sun, 24 Nov 2024 13:19:30 -0500 Subject: [PATCH] apply velocity over the frames until hitting box inner walls --- src/VFX.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/VFX.cs b/src/VFX.cs index 16efdfe..0942279 100644 --- a/src/VFX.cs +++ b/src/VFX.cs @@ -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