blob: f2d6d091fee6eb0630351a115390b8a9524e47ba (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
using Microsoft.Xna.Framework;
namespace MonoGame.Extended.Particles.Modifiers
{
public class DragModifier : Modifier
{
public float DragCoefficient { get; set; } = 0.47f;
public float Density { get; set; } = .5f;
public override unsafe void Update(float elapsedSeconds, ParticleBuffer.ParticleIterator iterator)
{
while (iterator.HasNext)
{
var particle = iterator.Next();
var drag = -DragCoefficient*Density*particle->Mass*elapsedSeconds;
particle->Velocity = new Vector2(
particle->Velocity.X + particle->Velocity.X*drag,
particle->Velocity.Y + particle->Velocity.Y*drag);
}
}
}
}
|