Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Idea for handling floating objects  (Read 502 times)

shadowform

  • Bay Watcher
    • View Profile
Idea for handling floating objects
« on: April 26, 2010, 02:29:40 pm »

1. First, conceptualize 'floating' not as a process of density vs. density, but as surface pressure vs. surface pressure.

2. The 'floating' levels for various fluids are established constants within a game world.  Once set, they cannot be altered.  This is probably not ideal, but necessary to simplify floating objects in the following fashion:

3. Any time an item is created or modified, the game calculates it's relative surface area vs. mass and determines what fluids it will float in.  As an example: a wood table has a wide area (the table itself) and a fairly low mass (especially lighter woods, like featherwood), and therefore floats.  If encrusted with iron, steel, lead, platinum, gold, and so forth, its mass increases and it stops floating.

4. Another thing to consider is floating vs. submersion.  Once submerged, an object will either sink, rise, or stay the same depending on its actual density to the fluid.  A buoyant object (a featherwood ring, perhaps) is lighter than the water, so it goes to the surface, but doesn't have sufficient surface to float, so it sinks - the result would be that it 'bobs'.  To prevent this from consuming excessive CPU, this sort of thing can be handled either by limiting how fast an object can sink/rise, or by simply setting objects with a lower density than the fluid to float regardless of surface area.
Submerged objects that sink, once they reach the bottom, would stop moving (unless there's a very strong current - but that's something else).  Submerged objects with equal density would move freely with current, but would neither sink or rise.

5. Things that float usually float at the surface.  So, it can just be assumed that the top of the table is even with the top of the 3/7 water layer - unless the table itself is taller than that.  Object height would need to be handled somehow for this to really make a large difference.
Logged
Q: What do you get when you take 100 clear glass windows, 1000 silver bars, 6700 gold bars, and 18,000 marble blocks?

A: A very large wall.

"Alright, here's Helltooth... Harborfence... Urist, come get GenericBlade... and you. Welcome to the Danger Room. First timers get good ol' Ballswallowed. Have fun and try not to take off your own toe."