From the Lab
Spacing Control for Coordinated Particle System (2): Change Gradually
Chujia Wei — July 16, 2013 - 6:03pm
Check the previous blog post for more information: Spacing Control for Coordinated Particle System (1)
We have managed changing the spacing for each pair of particles, now we try to make it change slowly and smoothly.
Instead of making each pair of particles adjust to the new spacing immediately when particles enter a new area with different spacing, we give these particles an "adjusting" time.
Each particle will remember the old spacing that they were on. When particle A enters a new area with spacing 30 from the old area which has a spacing as 10, it will first compare its own old record with the current spacing, if the record is smaller, make it somewhat larger, and vice versa. In this case, A's old record will be added by 0.001. When it comes to compare the distance of A and its neighbor B with the spacing, to determine if there is a need of birth or death, it will compare the distance AB with the average of A and B's records.
In this case, if AB > BIRTH_OFFSET * (A_record + B_record) / 2, then generates a new particle between A and B; if AB < DEATH_OFFSET * (A_record + B_record) / 2, then kill B;
By this way, AB will not just compare with the new current spacing, so that when the old spacing and the new one are too different, particles will not have a burst of birth or death suddently .
See the images below showing the effect of this feature.
(Before adding the feature. Particles suddently give birth when enter the right half of screen.)
(After adding the feature, though particles enter the right half, they change their spacing gradually.)