Final Project- My Role – Collision System

Summary

This is where I spent the majority of my hours the second month! It has been challenging and fun!

The book “Real-Time Collision Detection”  by Christer Ericson and the lab activities of our collision course (Engine Development 3) were my main resource.

Remarks:

  • Layer System: 

    To reduce pair-wise tests, we are organizing entities in layers. This way, we do not need to check collisions between groups of objects that are not supposed to collide. For example: There is no need to check collisions between a static wall and the terrain, since they are both part of the level

  • Proxy Collision Geometry:

    Entities have an outer bounding volume which is computed based on the model. For now we support AABBs and Spheres. If it is an animated model, it may also have numerous inner bounding volumes (Spheres) which are sized manually using our own in-engine tool. Their positions are based on the joints of the model. Entities can have up to one bounding volume per joint.

  • Precise Collision Resolution:

    Outer bounding volumes are used to detect bound overlap between objects. If there is a collision and the entity has no inner bounding volumes, tests are over and collision is resolved. In the other hand, another set of checks will need to be done against all the inner bounding volumes. If there is a collision with any of them, then resolution and separation are applied.

  • Raycasting

    Uses a layer mask to reduce the number of pair-wise test. It is being used to handle shooting and ground clamping.

  • Ground Clamping.

    We are changing the position of entities so they are always in top of the terrain. This is done by finding the collision point between the bottom of the entity and the ground. To get this, we are performing a ray to mesh collision test. The ray starts at the top of the entity and points to the opposite of the world’s up direction. Instead of testing the ray against ALL the triangles of the terrain’s mesh, we are using a Bounding Volume Hierarchy (BVH) as a spatial partitioning technique to only test against those triangles that are near the ray. Now, we only need to test against 2 to 3 triangles instead of  20k !

  • Render Frustum Culling

    We wanted to have a lot of things being drawn on the screen at once. Rendering takes time and can slowdown the game. To speed things up, we are culling (not drawing) everything that is not inside the view frustum. To get this working, we are testing all the objects in the scene and checking if they are inside of the 6 planes of the frustum. Results are impressive.

Wrap-up

You will find a video in this post explaining and showing each of the features explained above.

There are other features that we are thinking of doing if there is a need for it:

  • Implement a kd-tree as spatial partitioning to reduce the number of pair-wise tests between entities
  • Using capsules instead of spheres for the inner bounding volumes for more accurate collision.

My  linear algebra, data structures and research skills have improved a lot while working on this system.

Leave a Reply

Your email address will not be published. Required fields are marked *