Skip to content

Commit

Permalink
Use MaxSpeed when calculating speedGain (#921)
Browse files Browse the repository at this point in the history
This calculation was never implemented from the Mercury Particle Engine port
  • Loading branch information
AristurtleDev authored Jul 12, 2024
1 parent 3314226 commit f56dc7b
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using Microsoft.Xna.Framework;

namespace MonoGame.Extended.Particles.Modifiers
Expand All @@ -20,11 +21,12 @@ public override void Update(float elapsedSeconds, ParticleBuffer.ParticleIterato

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;
}
}
}
}
}

0 comments on commit f56dc7b

Please sign in to comment.