Move source projects into source directory

This commit is contained in:
Christopher Whitley
2024-05-18 19:59:41 -04:00
parent 9c5f7cd3b4
commit a4d72eaf6c
423 changed files with 123 additions and 105 deletions
@@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using MonoGame.Extended.Particles.Modifiers.Interpolators;
namespace MonoGame.Extended.Particles.Modifiers
{
public class VelocityModifier : Modifier
{
public List<Interpolator> Interpolators { get; set; } = new List<Interpolator>();
public float VelocityThreshold { get; set; }
public override unsafe void Update(float elapsedSeconds, ParticleBuffer.ParticleIterator iterator)
{
var velocityThreshold2 = VelocityThreshold*VelocityThreshold;
var n = Interpolators.Count;
while (iterator.HasNext)
{
var particle = iterator.Next();
var velocity2 = particle->Velocity.LengthSquared();
if (velocity2 >= velocityThreshold2)
{
for (var i = 0; i < n; i++)
{
var interpolator = Interpolators[i];
interpolator.Update(1, particle);
}
}
else
{
var t = (float) Math.Sqrt(velocity2)/VelocityThreshold;
for (var i = 0; i < n; i++)
{
var interpolator = Interpolators[i];
interpolator.Update(t, particle);
}
}
}
}
}
}