Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Fire spreading modelling

Discussion in 'Scripting' started by fabio1955, Dec 7, 2020.

  1. fabio1955

    fabio1955

    Joined:
    Nov 11, 2009
    Posts:
    72
    I am developing a wild fire spreading model based on a cellular automata paradigm (a grid of cells). I used to update the grid every second or so. Unfortunately, as the grid dimensions grows, the computation time starts to be too long… I already adopted some optimization such as limiting the computation to the rectangular area (+1 row/column) where the fire is developing. Now I am thinking to go forward with some multithreading approach. I know there is a new stuff in Unity as Jobs, Entities and such. But I do not know how to start. In particular it is not necessary to update every frame, maybe some time step like one or even 5 seconds would be enough. But how to pass all the data to the jobs? How reading the results (new updated grid). Any suggestion?
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,336
    I would just start with some tutorials on using the basic systems you contemplate for this: Jobs, ECS, DOTS, whatever the technology stack for async stuff is in Unity right now.

    Keep in mind this stuff (I think) is still i flux and not a lot of people (as a fraction of Unity users) have any need for this, so you'll probably have to experiment a lot on your own once you understand the basics from the tutorials.

    Until you are familiar with how it all goes together, what it can and cannot do, you won't really be able to reason about implementing your current problem space in a way that gets you a measurable benefit.
     
  3. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,697
    If you don't need the computation to complete within a single frame there are still steps you can try before jumping to a multithreaded solution. Have you tried doing partial computation during each frame? You can easily split the computation across multiple frames using Coroutines for example.
     
    Kurt-Dekker likes this.