Physics Engine

The idea is that the engine offers a number of different simulations, that can be turned on or off depending on the container type and the settings on the server. Different containers or areas in the game will have different requirements for the level of realism needed in physics simulation

For example, when under the water the pressure will vary significantly with the depth, but when above the water at around sea level the air pressure can be treated as constant.

Or a planet surface container could just use a constant gravitation, directed downwards, while a solar system container would have to calculate the gravitation force vector for each body depending on nearby planets, moons, or stars.

Sometimes realistic and lightweight versions of some similar simulation could be given, and in that case it would be up to the admin to select which one to use (for example accuracy of collision detection). The simulations could also be configured with parameters (how often to recalculate gravitation forces acting on an object in space, etc).

Goals

Here's a list of different situations that the physics engine should be able to handle more or less satisfactory. The picture also illustrates different physical phenomena that could be simulated.

Features

This is a list of the main functionality areas that the physics engine will have, and what they contain.

Bodies

The engine will operate on a few different types of physical bodies.

Entity

An entity is a more or less solid object, possibly consisting of many attached component objects.

Rope

A rope is an one-dimensional object, with a length and thickness, and some constant describing how bendable and elastic it is. These constants can depend on the material it is made of, but also depend in it's shape, for example an iron chain is bendable even if iron isn't.

Rope can be simulated as a number of connected line segments or springs. The rope may be attached to other bodies at any point, or a sliding attachment can be used.

Liquid body

How exactly to simulate bodies of liquid is still open. In the landscape, they can be terrain layers. But flooding a house built from entity blocks is a bit more tricky. The concept of a container, and openings in a container, might be practical here.

Fluid cloud

A fluid cloud can either be a cloud of gas, or a 'cloud' formed by releasing some liquid into a body of another liquid. A cloud will normally eventually expand and thin out, until it is either so diluted that it can be ignored, or has filled up the whole container that it was in, in which case the atmosphere or liquid in the container is updated to include the contents of the cloud.

Ground

A ground is made up of layers of different types of matter, some of which can be liquid too. The ground is always completely spanning a given container, varying in height in the y direction. The ground can also contain caves or overhanging terrain. A planet surface can be simulated by a number of triangular containers, arranged suitably.

Stellar or planetary body

This is used in space to represent large bodies that will decompose into containers with ground terrain on close range.

Mechanics

Movement

A body will accelerate and move as a result of forces acting on it.

Gravitation

This can be either constant, or depend on large bodies in the current container and possibly a constant outside gravitation. The former is used on planet surfaces, and the latter in space.

Artificial or magical force fields can also affect the local gravitation / forces acting on different bodies in a container.

Collision

Detect collision between bodies, and simulate the result.

Attachments

Attachments are different types of connections between physical bodies. If two bodies are attached, possibly with some degrees of freedom, they can in some cases be treated as one body, and there is also no need to perform collision checks between them.

Solid attachment

This is an unbending, unmoving attachment of some strength. For example, two wall blocks nailed together, or a spear head of stone tied to a wooden spear.

Rotating attachment

The attachment is free to rotate in some directions and ways. It can also be steered with some force by either body if the body is active in some way (a machine part, a body part, etc).

Sliding attachment

A body that is attached to some track or rope, that allows it to slide along the track. Again, the sliding body or the track could actively apply some force to move the sliding body. There can also be branchings in the track. The attachment can either be hindered by these, or be able to switch to one of them depending on in what direction it is pushed, or on how the track allows it to move. There is also some friction between the track and the body moving on it. The moving body could also be able to rotate in different ways.

Moving attachment

Two bodies can be pushed together as a result of various forces. They are free to move along the contact surface, but friction will affect that movement.

There's many different cases of this; an entity moving over a terrain, an entity moving over a water surface, and an entity moving along the surface of another entity. In most cases there's some force that is needed to separate the two attached objects.

Examples are humans pressed towards the terrain surface by gravitation, an alien in magnet shoes walking on a metallic space ship hull, or a duck floating on the surface of a pond.

Freely floating attachment

This might be used to simulate the effect of an object being immersed in a fluid or liquid, and moving when the body of liquid is moved.

For example, a goldfish in a fishbowl, or a passenger in some sci-fi gravitation suspension field.

I'm not sure if this should be modeled as an attachment.

Pressure

Buoyancy

Floating on a fluid/liquid surface

Movement of fluids

Includes both wind outdoors, and approximation of turbulent flow of fluids in pipes.

Flow of fluid between containers

Simulation of fluid movements in containers with portals to other containers. The container could be a living room with doors to a few other rooms and to outside, or a pressurized vat connected through pipes with vents to two other vats.

Addresses problems such as simulating a room filling up with water.

Flow of liquids over terrain

Water and other liquid layers, storing only flow information of rivers etc without simulating them in detail, and so on.

Thermodynamics

Temperature of physical bodies

Each material type has some heat conductivity.

Radiation

Spreading of heat through infra red radiation

Convection

Spreading of heat through a fluid medium, such as air or water.

Materials

material properties and reactions of materials on temperature, stress, and chemical reactions with other materials.

Material state

Solid, powder, liquid, gas.

Mixing materials

Properties of mixed materials, etc.

Stress

Reactions of materials on stress.

Temperature

Reactions of materials on temperature

Material Reactions

There's also complicated reactions such as: These reactions can be lumped together. They are all potentially complicated reactions that could depend on a lot of different factors. They should be described in some expressive, yet efficiently executable form.

The exact way this should be implemented needs more thought. There could also be different implementations with different degrees of flexibility and computational weight.

Light

I'm not sure, but we might also have to address light levels and sources in the physics engine. The general light level and sources in a container will be needed, and light radiation can also be converted to other energy forms.

Sound

We'll eventually have to simulate the movement of sound somewhere.

Electricity

Not sure if we need to address this very much. The energy transported in the mechanical system is of unspecified form. It seems only lightning strikes etc would be cases where electricity will have to be directly simulated in the game, and even there a fairly simply approximation will be enough.

Radiation

Well, not needed that much in fantasy games, and in sci-fi etc we can assume that engines etc have built in protection. The only case might be explosions that release a lot of radiation, and those are short enough to be easy to deal with.