Erde Physics

While developing the engine it was becoming more and more apparent that I could not put off working on the physics engine. Seeing as many of the physics engines out there work for primitive objects and meshes rather than distance fields this was a little tricky to figure out.

The Solution

After experimenting with several solutions I had a facepalm moment. I realised that as long object is in a distance field I know how far an object is from a surface. To find the point on the distance field I did a Point vs AABB check with the centre of the object vs the bounds of the distance field (Note that the distance field is broken up into chunks to drastically improve loading times). If that succeeded I would then transform the object into the distance fields local space and sample the point at that location. Once I had the point on the distance field I would treat it as a sphere and do the actual collision check.

The next part it was a bit of a problem because a distance field has no inherent shape and I needed to get a normal for collision resolution. To keep this simple for explanation purposes I will keep this to 2D and skip all optimizations. The easiest way I found was to use a kernel and sample all the points around the central point. From there I multiply the Final Griddistances by the direction they are from the centre and it should give me a kernel that looks like this. After that, all I have to do is add them all together and normalize them to get the normal of the point in the distance field.

The Next Steps

Although the current solution works it still has a few kinks in it. These kinks come from a few main issues

  1. The distances in the field are not perfect
  2. The density of the distance field is quite low
  3. The collision resolution is not 100% complete

To get around these I will likely have to do interpolation between multiple of the points and/or increase the density on the distance field to get smoother travel along the surface. In addition, I will have to swap out the procedural generation for something more accurate to get better accuracy (Sorry simplex noise I think this is the final hack job). My laptop is also starting to feel the strain of having no spatial partitioning at all in the engine. I think I am at the limit of brute force calculations.

Here is a preview of the changes to Erde

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s