GRAVITY WELLS


[WATCH VIDEO] - rigid bodies, single peer
[WATCH VIDEO] -deformable bodies, single peer
[WATCH VIDEO] - 4 peers

The application has 2 parts: the physical simmulation for movement of the balls (single peer) and the peer-to-peer part.


1. Physics


A large number of balls is placed on a plane, the world being closed by a circular wall. A peer has a region of influence (the circle from the photo), in which he can apply forces to move the spheres. He can apply a positive force, attracting all the balls in the centre of the region, or a negative force, repelling the balls from the centre of his region. The balls can be light, medium or heavy, and can be rigid or deformable. Different modes of collisions, rotations and integration have been implemented (collision with friction, collision with angular effects, physically based rotation, arbitrary rotation, RK4, euler with drag etc).



The deformable sphere has been implemented using the exoskeleton model. It is basically a mesh of springs which are "hooked" on an exoskeleton. There are additional springs connecting the exoskeleton with the original mesh, that make the sphere regain its shape after deformation.

2. Networking


The application supports 4 peers that will share the balls from the world. The peers do not have all the knowledge of the world, they know only what is contained in their region of influence. If a peer changes position, or if spheres are perturbed by an applied force, the peers have to communicate to keep the regions of influence consistent. However, complications occur when the regions of influence are intersecting. It may happen that multiple peers apply forces on the same spheres. So each peer has a list of "owned spheres", and each is the only one responsible for updating the physics for them. All the other peers recognize the spheres owned by someone else as contended, and have to display them, but not update the physics. However, if the network refresh rate is slow, the peers will interpolate the movement of the contended balls using the knowledge from the previous frame.

At the beginning, the application starts with one peer that has the full knowledge of the world. When the second peer arrives, the first one will start migrating the spheres from the world, until they reach an equilibrium state. The same thing happens when there are multiple peers, the database being distributed among them. When a peer closes (gracefully), it will send his knowledge of the world to the existing peers.


4 peers in the same time of the simmulation. The balls owned by a peer have a coloured circle around them (the circle has the colour of the peer who ownes the ball). It can be noticed in the photo that each peer can see the balls from its own region of influence.