Wednesday, September 21, 2011

Bears with bounding volumes

I recently started to add some primitive collision detection to be able to place objects to scene without them overlapping each other. I calculate bounding volumes during parsing of the object data. Whenever a new vertex comes in I test it for current min and max for x, y and z. Then in the end I calculate midpoint for the mesh as well. I added a debug mode to see the bounding volumes during rendering and this is the result. This is all simple and makes development and debugging much easier. Highly recommended step to do at the very beginning.



I've also rewritten the scenegraph part of the engine so that all CPU work (like the matrix calculation) happens before any GPU work. This meant a lot of refactoring but now I can enjoy much higher FPS rates even with a lot of complex geometry like exploding the buddha mesh and so on.

As next step I will experiment more with the explosion stuff, I want to add more physics. I already did some trials to rotate triangles while they fly but it did not really look that good, I probably will try to add per triangle velocity vertex attribute and apply gravity so that the pieces fall down. One problem also is that when I do the explosion in vertex shader my bounding volumes are not reflected to this change as shown below.