r/howdidtheycodeit • u/Mysterious-Insect858 • Jun 19 '23
Question This particle ripple effect. How did that do it?
3
Upvotes
r/howdidtheycodeit • u/Mysterious-Insect858 • Jun 19 '23
23
u/HungryProton Jun 19 '23
Now move your mouse and notice how it gives the illusion of a ripple even though each point actually moves on a straight line!
0
u/MattOpara Jun 20 '23
I’d say that each “line” of dots that’s radially around the cursor is a linked list in which each node is a dot and each dot holds a reference to the one immediately after it and the cursor is the head of all the lists. Each dot also holds a small first in first out queue (the longer it is the more delay there is, in the video it might only be 2 long) that stores 2D position data and each dot also has 2 variables that store it’s current 2D position and it’s last 2D position. Now each dot follows the same basic procedure, wait for movement update, subtract it’s current position from its last position and then push that info to the queue, pop a value out of the queue and add it to the dots position stored in the reference, update last to be equal to current, and then wait until the next frame. This basically means that however much a dot translates on a given frame, that info will eventually be passed onto the next dot to do after a given number of frames have passed (where the number of frames is equal to the size of the queue). Hope this helps!