Use MaxSpeed when calculating speedGain (#921)

This calculation was never implemented from the Mercury Particle Engine port
This commit is contained in:
Christopher Whitley
2024-07-11 21:35:32 -04:00
committed by GitHub
parent 3314226861
commit f56dc7b620
@@ -1,3 +1,4 @@
using System;
using Microsoft.Xna.Framework;
namespace MonoGame.Extended.Particles.Modifiers
@@ -20,11 +21,12 @@ namespace MonoGame.Extended.Particles.Modifiers
var distance2 = diff.LengthSquared();
var speedGain = _gravConst*Mass/distance2*elapsedSeconds;
var speedGain = _gravConst*Mass/distance2;
speedGain = Math.Max(Math.Min(speedGain, MaxSpeed), -MaxSpeed) * elapsedSeconds;
// normalize distances and multiply by speedGain
diff.Normalize();
particle->Velocity += diff*speedGain;
}
}
}
}
}