Jump to content


Photo

Air pressure


  • Please log in to reply
3 replies to this topic

#1 chaz13

chaz13

    GMC Member

  • GMC Member
  • 4144 posts
  • Version:Unknown

Posted 26 February 2012 - 11:50 PM

Hey.

I'm working with a platformer game with a grid based system, all tiles and such lie on a 16x16 grid (and are destructible, terraria style). The idea is it's based on an alien planet and the player has to be careful about creating bases that have a solid air supply and such. Each cell in the grid is going to have an "air level" stored in a seperate ds_grid from the terrain one. There'll be objects that pump out air, and I want it to travel semi-realistically so it'll build up pressure in sealed off areas.

The player will need a basic pressure or air value in a grid cell to be able to breath, so by creating a sealed off base and creating objects to make air they'll be able to breath in their environment.

The problem is, how should I go about making these objects fill up the grid spaces around them with air? I was first considering looping through objects that do this and having loop propogating out in a flood fill fashion, but I'm not sure if that'd work so well. My other idea is to loop through each grid cell, and if it's got a higher pressure than surrounding cells move air into them. The issue with this is the speed, and also the fact that it'd travel too far from a source- I'd only want it to be able to pressurize say, 10 cells radius or whatever, but this system would have cells with tiny pressures all over, which is not really a huge problem but isn't a very neat solution.

Any thoughts?
  • 0

#2 YellowAfterlife

YellowAfterlife

    GMC Member

  • Global Moderators
  • 3772 posts
  • Version:GM:Studio

Posted 27 February 2012 - 12:27 AM

Simple solution is to iterate through all grid cells, 'sending' 1 air to adjacent cells if they have less air. So yes, basically second solution. To achieve good performance this would also require using a data structure or a mini-dll to do time-consuming parts of operations.

Advanced solutions would mean to store maximum distance which air can travel... but hey, even real air doesn't work like that.

Edited by YellowAfterlife, 27 February 2012 - 12:28 AM.

  • 0

#3 Gamer3D

Gamer3D

    Human* me = this;

  • GMC Member
  • 1815 posts
  • Version:GM:Studio

Posted 27 February 2012 - 03:41 AM

I think the key to doing this quickly will be detecting when an equilibrium is reached (or is close to being reached) in some area. Perhaps a quadtree storing minimum and maximum pressures in an area, and not updating it and its branches if the difference is small enough?
  • 0

#4 xot

xot

    GMC Dismember

  • Retired Staff
  • 4772 posts
  • Version:GM:Studio

Posted 27 February 2012 - 07:36 PM

This article by Mick West might stimulate your brain.

http://cowboyprogram...luid-mechanics/

Not sure GM by itself is up to the challenge, even with the trickiest code, but I haven't really looked into it since this article first appeared in Game Developer Magazine in 2007. Perhaps if your needs are modest a solution might be practical.

Ron Fedkiw (cited above) has done some cutting edge work with high speed CFD that you might find interesting.

http://physbam.stanford.edu/~fedkiw/

This paper is a good place to start.

http://physbam.stanf...ford2010-02.pdf [PDF]
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users