• Register
Post news RSS DevBlog 13 - Large Scale Collision

Handling large scale collision for my carrier ships.

Posted by on



sa vid13 thumbnail

sa vid13 spatialhash

Adding hand-made collision to the large ships so that fighters cannot fly through them.
I tweaked the model editor so it can load in models to define collision shapes.
There now is an XRay mode that lets you see wireframe of the ship with colored rendering of collision shapes.

To debug collision in the editor, you can pilot a quaternion based camera that has a box collision shape attached to it; the camera can fly and collide with objects in the viewport.
Collision is done using Separating Axis Theorem (SAT).
The camera resolves collision by using the minimum translation vector returned from SAT to get the camera out of collision.

For the remainder of the video, I did incremental updates to show what dev on a from scratch project is really like.

First there was a bug with scaling, the ships were much smaller than their collision shapes suggested.
while fixing that, I got distracted with a color bug and fixed that, only to get hit by a shutdown crash. I decided to fix the shutdown crash later.

I then fixed the scaling bug, but still crashing every time I close the game.
The particles size were incorrect, so I would fix that before fixing the shutdown crash.
There were some performance issues, so I increased the spatial hash cell size so that the large ships take up fewer spatial hash grid cells.

Finally fixed shutdown crash, which was due to a special pointer I created called a lifetime pointer.
Essentially there was an edge case situation that didn't account for the global engine pointer being null during a shutdown.

I realized that only projectiles collide with the large ships, I still needed to do ship v ship collision.
I added that bug had many issues with the carrier ship trying to deflect off of the small ships.
I fixed that bug by making the large ship not be blocked by small ships.
I found it funny how the small fighter ships bounced along the faces of the large ship. This is because there was no AI mechanism in place that helped the ship avoid the large ship.

Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.