Performance improvements to ParticleSystem.
This commit is contained in:
@@ -165,23 +165,21 @@ public class ParticleEmitter : IUpdatableSystem
|
||||
Emit();
|
||||
}
|
||||
|
||||
var deltaTimeVector = new Vector2((float)deltaTime);
|
||||
var lifeTimeInv = 1.0f / Settings.LifeTime;
|
||||
var gravityVector = Settings.Gravity * (float)deltaTime;
|
||||
var dampingFactor = Settings.Damping * (float)deltaTime;
|
||||
|
||||
for (int i = 0; i < _maxParticles; i++)
|
||||
{
|
||||
// var particle = _particles[i];
|
||||
|
||||
_lifetimes[i] = Math.Max(0.0f, _lifetimes[i] - (float)deltaTime);
|
||||
|
||||
var t = _lifetimes[i] / Settings.LifeTime;
|
||||
var t = _lifetimes[i] * lifeTimeInv;
|
||||
|
||||
_velocities[i] += Settings.Gravity * (float)deltaTime;
|
||||
_positions[i] += _velocities[i] * (float)deltaTime;
|
||||
// particle.Rotation += particle.AngularVelocity * (float)deltaTime;
|
||||
// particle.Scale = MathUtils.Lerp(Settings.ScaleEnd, Settings.ScaleBegin, t);
|
||||
_velocities[i] += gravityVector;
|
||||
_positions[i] += _velocities[i] * deltaTimeVector;
|
||||
|
||||
var color = MathUtils.LerpColor(Settings.ColorEnd, Settings.ColorBegin, t);
|
||||
// particle.ColorArgb = color.Argb;
|
||||
|
||||
_velocities[i] -= _velocities[i] * Settings.Damping * (float)deltaTime;
|
||||
_velocities[i] -= _velocities[i] * dampingFactor;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user