Page 2 of 4

Re: Air/Vacuum Simulation

Posted: Sun Jan 19, 2014 11:32 am
by Iv121
The difference is not in how you store them but how you access them. In liquid simulation method you basically say the following:

I am level 5 air block , All the blocks near me in all directions but the one I come from get air, repeat for new air blocks.

I am level 4 air block, all the blocks near me in all directions but the one I come from get air, repeat for new air blocks.
.
.
.

I am level 0 air block, I am not air block, function end. / I am a wall, I am not air block, function end.

That is basically meaning that we have 5 code sections for each new air block: 5*5*5*5*5 ... n times (5^n) in worst case scenario (we didn’t run into any walls), it is true that in real environment we will run much less code as we meet walls and make the function much more clever, but even after all of that you will still get a really high runtime function which means your CPU commits suicide.

Re: Air/Vacuum Simulation

Posted: Sun Jan 19, 2014 12:39 pm
by Error
So, Iv, you mean that we figure out how much air is in a ship/metaworld, and every time a change occurs to the metaworld, recalculate the air volume, and from the air volume, determine the effects on players?

Call me derp, but I'm not codesavvy enough to see how this is more CPU efficient than the liquid method.

Re: Air/Vacuum Simulation

Posted: Sun Jan 19, 2014 1:33 pm
by Iv121
No, recalculation is what you do, I do PRE-Calculation, just to let you know the algorithm I wrote there is similar to what you will end up if you calculate air like flowing water. Also it seems like in one way or another RE-calculation of the air volume will be required to determine if an area is sealed or not which is why I try to figure out the best way to do it.

Re: Air/Vacuum Simulation

Posted: Sun Jan 19, 2014 1:43 pm
by  ҉ 
Instead of making stuff actually flow, can we just make it so any air block touching a vacuum block is destroyed and replaced by vacuum after, say, a tenth of a second? That'll mean that if there's a hole in the hull, the air in that room will be destroyed very quickly, but it'll stop at airlocks or whatever.

Re: Air/Vacuum Simulation

Posted: Sun Jan 19, 2014 1:59 pm
by Iv121
The problem is not with draining the air but actually filling it back as I said, to check if an area is sealed.

Re: Air/Vacuum Simulation

Posted: Sun Jan 19, 2014 2:04 pm
by Error
Kdapt-Preacher wrote:Instead of making stuff actually flow, can we just make it so any air block touching a vacuum block is destroyed and replaced by vacuum after, say, a tenth of a second? That'll mean that if there's a hole in the hull, the air in that room will be destroyed very quickly, but it'll stop at airlocks or whatever.
That actually sounds good. Like how MC lava sets fire to flammables, which vanish after x time?

So any player in a zone with no air starts taking damage? Or do we have the underwater style air bubbles thing?

Re: Air/Vacuum Simulation

Posted: Sun Jan 19, 2014 2:06 pm
by  ҉ 
Commander Error wrote:
Kdapt-Preacher wrote:Instead of making stuff actually flow, can we just make it so any air block touching a vacuum block is destroyed and replaced by vacuum after, say, a tenth of a second? That'll mean that if there's a hole in the hull, the air in that room will be destroyed very quickly, but it'll stop at airlocks or whatever.
That actually sounds good. Like how MC lava sets fire to flammables, which vanish after x time?

So any player in a zone with no air starts taking damage? Or do we have the underwater style air bubbles thing?
If they're in hard vacuum, give them maybe a second before they start dying, and another two or three to actually die. If you end up in vacuum without a pressure suit you should be pretty screwed.

Re: Air/Vacuum Simulation

Posted: Sun Jan 19, 2014 2:06 pm
by Keon
I think I have a solution. I'll test it in 2d later today.

Re: Air/Vacuum Simulation

Posted: Sun Jan 19, 2014 2:15 pm
by Iv121
Oh someone is actually going to bring something new to the table here !

BTW as for air draining all you need to do is to detect once a block is removed that on one side of it there is vacuum and on the other side there is air, then set the direction of all entities in the enclosure from the direction of the air cube to the direction of the vacuum cube, draining a set amount of air from the enclosure as whole.

Re: Air/Vacuum Simulation

Posted: Sun Jan 19, 2014 3:09 pm
by Error
I feel Kdapt's solution is PROBABLY best, but I don't know sufficient java to say so for sure.

Re: Air/Vacuum Simulation

Posted: Sun Jan 19, 2014 3:44 pm
by Iv121
Its a solution, but not for the problem at hand. We talk about defining enclosure and if an area is sealed, not if it is depressurised.

Re: Air/Vacuum Simulation

Posted: Mon Jan 20, 2014 2:57 am
by cats
Can we have pressure levels? Can that be a thing?

Re: Air/Vacuum Simulation

Posted: Mon Jan 20, 2014 3:05 am
by Iv121
What do you mean by that, and more importantly why do you want that ?

Re: Air/Vacuum Simulation

Posted: Mon Jan 20, 2014 9:18 am
by Keon
If we do it on a block-by-block basis I'd prefer air-vacuum but if we precalculate it, it could work.

Re: Air/Vacuum Simulation

Posted: Mon Jan 20, 2014 12:52 pm
by Ivan2006
Iv121 wrote:What do you mean by that, and more importantly why do you want that ?
He means that the system could differentiate between different air pressures.
May not only be important for spaceships, but also for upper atmosphere stuff.