Collision Detection Progress
Am Currently in phase 1 of implementing Collision Detection in my game engine – JustAnotherGameEngine.
marked have been done –
- Design Collision Manager that will be handling all collision related stuff.
- CD (Collision Detection) of AABB with Polygons (triangles making up objects in current scene , yes there are no simple primitives).
- Sphere & Ellipsoid with Polygons.
- Registration & CD of Static Objects
- Registration & CD of Dynamic Objects (Moving objects like bullet etc)
- Registration & CD of Height map Terrains (avoiding registration of whole terrain mesh if possible because that’s going to take allot of memory and unnecessary CPU time )
Update Player FPS Controller and Implement Response phase.
- Registration of Static Hierarchal meshes loaded from 3ds Max as Static Objects.
- Registration & CD of Models with animation loaded from 3ds Max (e.g. Walking character , etc).
- Map Editor with collision detection support for making simple levels.
- Or Implement the support for Loading Levels from 3ds Max and register it with Collision detection System and also make a provision to place some simple entities in 3ds Max and recognize it in engine while loading.
- Make the whole Collision Detection System and Response phase of Player Independent of Default Co-ordinate Axes. (I will explain it later but it’s like using OABB instead of AABB. But thing am trying to do is beyond that and I can’t explain it without screenshots etc)
Here’s the way things work now, During Scene Initialization all the objects are registered with Collision Detection as static or dynamic objects passing the mesh data to build polygons in Collision Manager Database. Later on when we need to move a dynamic object say the player object it will call just one function passing in its current position and new position, Collision Manager then uses its Triangle database created at loading time to check player object against all the objects / triangles in the scene (remember there’s no high level optimization technique planned in phase 1).
For Terrains there’s separate system to register and check collision detection. If we use the same system like static Objects and pass terrain meshes to Collision Manager then allot of memory will be wasted and also number of triangles to be processed will increase. To avoid this we will only generate terrain mesh around player position and check collision against it. This mesh will be generated every frame using height map.
Here’s a screen shot of player object with terrain (having > 2 Million polygons). As you can see am getting 108 fps. If i have registered this terrain as static mesh to the collision system it would have processed all 2M triangles which would have taken ages and obviously not practical for any purpose. Instead what am doing here is am generating a part of terrain mesh surrounding the players position inside the collision system every frame with the help of height map data. Blur Colored Triangles are the ones generated inside collision system for detection in this frame. And player object collides with the triangle shown red.
(Terrain size 1025 x 1025)
(Note – terrain is being rendered without any optimization technique e.g. frustum culling, occlusion culling etc. So all vertices and triangles are being passed to draw call)
(Same terrain with Frustum Culling on. Notice the Number of Vertices and Triangles being passed to Draw Call)