Interpolation of particle spawning point when emitter has moved

I noticed that the particle emission point is not interpolated when the emitter move. The drawing become unnatural when emitting high number of small particles along the emitter trajectory, ie. the contrail at a plane’s wingtip.

See the related post in the troubleshooting section :

As it worked for me, I propose to commit this little modification :

private Vector3f lastPos;
private void updateParticleState(float tpf) {


    // Spawns particles within the tpf timeslot with proper age

float originalTPF = tpf;
float interval = 1f / particlesPerSec;
tpf += timeDifference;
while (tpf > interval){
tpf -= interval;
Particle p = emitParticle(min, max);
if (p != null){ -= tpf;
p.position.interpolate(lastPos, 1-tpf/originalTPF);
if ( <= 0){
updateParticle(p, tpf, min, max);
timeDifference = tpf;
lastPos = new Vector3f(getWorldTranslation());



I’m not sure where is the best to initialize the lastPos, though. In preload(…) maybe, or in the update after a null check?

Hope you will find it usefull.

Sorry for the <strong/> in the code, I tried to hightlight modified lines :slight_smile:

Hint: if you post in a unified diff format ( it’s easier to understand the changes :slight_smile: