Logic Optimization Suggestion

  • plypencil
    5th Dec 2012 Member 0 Permalink

    Currently TPT stores all particles in a single array and processes every particle per tick.

     

    I suggest splitting the array to active and asleep. Sleeping a particle stops it from being processed by the logic, thus reducing the logic time. A particle will be set to the asleep state under the following condition(s).

     

    There is no possible move or other property change, excluding temperature.

     

    A particle will reactivate under the following conditions:

     

    The particle is forced to update by another (example: temperature difference is found to be > 10 degrees)

    A new particle is now colliding (Other particle checks the collision and calls the activation)

    A heat/cool or prop tool is used on that particle

     


    Particles when active check the temperature difference with surrounding 'asleep' particles, and will activate the particles if the criteria is met.

     

    I hope this has made sense.

     

    What do you think?

  • mniip
    5th Dec 2012 Developer 0 Permalink
    no, some particles have life-based events
    and the parts that dont have any update functions nor any special interaction, eg DMND, already skip most parts of simulation code
  • plypencil
    5th Dec 2012 Member 0 Permalink

    But things like water even though its doing nothing will still hog the CPU.

     

    'There is no possible move or other property change, excluding temperature.'


    This covers particles with life based events. Life is a property.

  • mniip
    5th Dec 2012 Developer 0 Permalink
    water will not... why would it
  • plypencil
    5th Dec 2012 Member 0 Permalink

    Because it takes processing time to cycle through 10000 particles of water, check its type, check if there are particles nearby, calculate the direction to move (in this example none), transmit heat to surrounding particles, and whatever else a particle does in the background.

     

    By marking it as 'asleep' it reduces the amount of wasted time during the simulation. The particle can do nothing, therefore shouldnt be part of the frame logic.

  • Pilihp64
    5th Dec 2012 Developer 0 Permalink

    @plypencil (View Post)

    There is already a 'stagnant' flag which skips movement checks for everything.  The problem is there are just so many things that can break being 'asleep' that checking all of them is probably worse than just checking movement.

    It already checks neighbors for every single particle no matter what (not all need that, true) , and being asleep doesn't avoid any normal element update time (things have to be checked no matter what), there are also many many elements more time consuming than liquids.

    There just isn't that much wasted time anymore, many things have already been fixed, and I'm sure more can be, but this is kind of already added (for movement).

  • plypencil
    5th Dec 2012 Member 0 Permalink

    Okay fair enough