Slime-Simulation icon indicating copy to clipboard operation
Slime-Simulation copied to clipboard

fix possible concurrency bug

Open asvarga opened this issue 4 years ago • 1 comments

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).

asvarga avatar Apr 13 '21 23:04 asvarga

Two things worth noting:

  • Executions of TrailMap[int2(newPos)] = min(1, oldTrail + agent.speciesMask * trailWeight * deltaTime); in Update commute, so we don't have to worry about race conditions there.
  • Diffuse does exactly one write to DiffusedTrailMap per pixel, so we don't have to do any other clears/copies.

asvarga avatar Apr 14 '21 00:04 asvarga