I have an idea to include 2 or more layers in the TPT window. These layers can be switched between and each layer would be like a separate TPT window. electricity can travel between layers usin a new material LAYR that transmits electricity between two adjacent layers.
for example, if a LAYR is placed in layer 3 and there are 4 layers, then any electronics in layers 2 & 4 which are in the same pixel as the LAYR will recieve electricity if the LAYR on layer 3 is sparked .
in effect, it gives a sort of 3D element to TPT, and would really give a lot of room for some really neat ideas. imagine a dual layer PCB made in TPT!
ofcourse, i realise this would cause lag like anything (I forgot to put this down) , but this discussion was very informative.
That doesn't work reliably, particularly with particle interactions, and it's therefore not a good idea to rely on it.
Also, 'layers' in that sense are not isolated from each other and are difficult to use, so it's not really a suitable answer for this suggestion.
most graphical design programs have layering within one open application. I have thought it would be nice if TPT had 5 layer tabs and one "show all" tab on the right side tool bar which would simplify constructiong multilayerd saves. layer 1 would be the bottom most layer and 5 the top. the highest number layer for any pixel would get view priority if you click the show all tab. when you click on a layer(1-5) tab it would show only what is drawn on that layer. this method would allow you to draw on a specific layer. The program already keeps track of what pixels are on what layer, it just needs a way to view and manipulate specific layers.
Sandwichlizard:
The program already keeps track of what pixels are on what layer
If you're talking about TPT rather than a graphical design program, then no it doesn't. It only keeps track of the location of particles in the topmost 'layer'. That's why stacked particles don't work reliably.
The only practical way to implement layers in TPT (as suggested in the first post) is not with stacked particles, it's basically with several separate simulations running at once, as described by minecraft-physics. The big problem with this is speed (though it would be easy to make the separate simulations run on different CPU cores if they're only linked by a particle that transmits sparks between them, but not everyone has huge numbers of cores, so this isn't a full solution to the speed problem if you want much more than two layers).
Well im certainly not going to argue with a developer, but let me ask, why does the stack order stay the same when you reload and delete them one layer at a time? something keeps track of the layer order. even if it did not make layer work better than they do now it would still be easier to build layered stuff.
The reason the stack order stays the same when you reload and delete one layer at a time is that the particle with the highest ID is displayed on top, the particle with the second highest ID underneath that and so on. TPT could actually figure out wich layer a particle is in by finding all the particle on that pixel then putting them in the order of their ID.
The order is to do with particle ID. When particles are saved, they are stored in order of y coordinate, then x coordinate, then particle ID. When they are loaded, particle IDs are allocated in the same order in which the particles were stored (y, then x, then particle ID before saving). So within each coordinate, particle order is preserved.
To quickly find which particle is in a given position, TPT has a thing called a particle map (or 'pmap'). This is used for pretty much all reactions and movement checks, so if a particle isn't linked to in the particle map then most other particles can't see it and won't react with it or conduct heat to it or be blocked from moving by it, and it won't be visible in the HUD or deletable with the brush.
pmap can store a link to only one particle for each coordinate. Since multiple particles can be in the same position, this means that pmap has to be recalculated each frame to make sure it is correct. When it is recalculated, TPT goes through all the particles in order of their ID and sets the relevant pmap entry for them. This means that particles with higher IDs overwrite lower IDs, so the one that ends up in the pmap for a given coordinate after the recalculation is finished is the particle at that coordinate with the highest ID. The particle in the pmap after recalculation is finished is the 'topmost' one, which will be shown in the HUD, be seen by other particles, or deleted by the brush on that frame.
The appearance of layer order is purely due to the recalculation of pmap being affected by particle IDs. There is currently no tracking of which 'layer' each particle is in, no quick way to find out which layer a particle is in, and no quick way of finding which particles are in a particular position other than the topmost one (so pretty much all reactions have to involve at least one particle that is topmost, and deleting things with the brush only deletes the topmost particle each frame).
If any particles move, then they may switch 'layer'. The 'layer' does not stay the same for any particular particle. If a particle is in layer 2 in one position, it could move to a different position and suddenly be in layer 5. Or if one particle in a particular position is deleted due to a reaction, then it changes the layer numbers of other particles in that position.
Even particles just changing type can also affect which particle is considered topmost. For example: create a particle of WOOD, then a particle of DMND (order is important). Stack them. If you mouse over them, TPT will say it is DMND. Lower the fps cap (tpt.setfpscap(2)) to make the next bit easier to see. Pause the game, then set the temperature of the wood to 9999. Move your mouse over the WOOD+DMND particles, and keep it there while you unpause. You should see the HUD briefly flicker when the WOOD starts burning to say that the FIRE+DMND particles are FIRE instead of DMND - so FIRE is briefly considered the topmost particle. (WOOD/FIRE remains particle 0, DMND remains particle 1, but changing type updates pmap so changes the topmost particle).
As you might have guessed, stacked particles are not something I approve of, and I don't wish to make it easier to build stuff with them. Stacked particles currently behave in horribly broken ways, and in most cases there are better ways of making saves do what you want.
If layers ever happen, they will be more like the description in the first post, rather than a way of making stacked particles.
thankyou very much for such a detailed explaination.