Collision Physics with Terrain
Posted: Mon Mar 10, 2014 5:38 am
I am currently working on working with collision detection in terrain. The terrain that I am using is coming from a .scene format. I am using Bullet for a physics library, but do not wish to use OgreBullet, as it seems to be dead. My current approach is to do the following:
First, get the location of the entity with entity->getPosition(). This vector is then used to get the height of the terrain at the position with terrain->getHeightAtWorldPosition(position). The terrain is coming from when I am loading the .scene file and getting the terrain at the position from the TerrainGroup that comes with loading the .scene file. I then plan to create a plane or something similar in bullet and then proceed with the normal way of doing physics with the physics engine.
However, this seems overly complicated, as it would be just as easy to do all the collisions with a RaySceneQuery at this point. It also seems like this technique would have some issues with uneven terrain. I also plan to manage collision detection for .bsp maps as well at some point, meaning I would have to redesign this for that type of map, which isn't managed by the whole terrain system as far as I know.
Anyone have any suggestions or alternate ways I could do this? I would like to integrate bullet as it seems to be a fairly reliable physics engine, although I plan to rewrite parts of it or write my own physics engine at some point. I also plan to allow different map types in my final game, so I would like to make the technique as flexible as possible for the map type.
EDIT: I have now thought of somehow processing the entire terrain into an object in bullet during the loading of the scene, and hopefully the broadphase in bullet will stop unnecessary computation. Does anyone have any comments on this technique or suggestions of how to do it (I know how to get the height at a specific point, but not much else)?
First, get the location of the entity with entity->getPosition(). This vector is then used to get the height of the terrain at the position with terrain->getHeightAtWorldPosition(position). The terrain is coming from when I am loading the .scene file and getting the terrain at the position from the TerrainGroup that comes with loading the .scene file. I then plan to create a plane or something similar in bullet and then proceed with the normal way of doing physics with the physics engine.
However, this seems overly complicated, as it would be just as easy to do all the collisions with a RaySceneQuery at this point. It also seems like this technique would have some issues with uneven terrain. I also plan to manage collision detection for .bsp maps as well at some point, meaning I would have to redesign this for that type of map, which isn't managed by the whole terrain system as far as I know.
Anyone have any suggestions or alternate ways I could do this? I would like to integrate bullet as it seems to be a fairly reliable physics engine, although I plan to rewrite parts of it or write my own physics engine at some point. I also plan to allow different map types in my final game, so I would like to make the technique as flexible as possible for the map type.
EDIT: I have now thought of somehow processing the entire terrain into an object in bullet during the loading of the scene, and hopefully the broadphase in bullet will stop unnecessary computation. Does anyone have any comments on this technique or suggestions of how to do it (I know how to get the height at a specific point, but not much else)?