diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2023-09-01 21:54:09 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2023-09-02 09:45:15 -0700 |
commit | d73df8d9b10490b2e09623972cf4d8d5f7b84162 (patch) | |
tree | d1bfdd3813d698eca4c64577134ebbeb5f324a90 /src/modules/swarm/swarm.c | |
parent | c1118d5daed415f49cc4bb9bfba07801fa9a1481 (diff) |
flow: implement a 3D flow field module
This is kind of a particle system, where the particles are pushed
around through a 3D vector space treated as a flow field.
No physics are being simulated here, it's just treating the flow
field as direction vectors that are trilinearly interpolated when
sampled to produce a single direction vector. That direction
vector gets applied to particles near it.
To keep things interesting the flow field evolves by having two
distinct flow fields which the simulation progressively
alternates sampling from. For every frame, both flow fields are
sampled for every particle, but how much weight is given to the
influence of one vs. the other varies by a triangle wave over
time. When the weight is biased enough to one of the flow fields
near a peak/valley in the triangle wave, the other gets
re-populated while its influence is negligible, also
interpolating its new values with 25% influence from the active
field.
The current flow field population routine is completely random.
Yet there's a surprising amount of emergent order despite being
totally randomized direction vectors.
Currently supported settings include:
size= the width of the 3D flow field cube in direction vectors
(the number of vectors is size*size*size)
count= the number of particles/elements
speed= how far a particle is moved along the current sample's
direction vector
This was first implemented in 2017, but sat unfinished in a topic
branch for myriad reasons. Now that rototiller has much more
robust settings infrastructure, among other things, it seemed
worth finishing this up and merging.
Diffstat (limited to 'src/modules/swarm/swarm.c')
0 files changed, 0 insertions, 0 deletions