Slime-Simulation
Slime-Simulation copied to clipboard
fix possible concurrency bug
Instead of Update both reading and writing from TrailMap, it now reads from DiffusedTrailMap and writes to TrailMap. This seems to avoid concurrency issues because it fixes https://github.com/SebLague/Slime-Simulation/issues/2 (at least for me).
Two things worth noting:
- Executions of
TrailMap[int2(newPos)] = min(1, oldTrail + agent.speciesMask * trailWeight * deltaTime);inUpdatecommute, so we don't have to worry about race conditions there. -
Diffusedoes exactly one write toDiffusedTrailMapper pixel, so we don't have to do any other clears/copies.