Paged Geometry Collision
I'm looking for any way to do collision detection with paged geometry. Example, I have a forest of rather large trees that I would like collision detection on (walking through them is kind of silly). Does anyone have any ideas? I know setting a query flag on the entity doesn't work as it's batch geometry, not just a entity with a scene node. I'm using the simple MOC library from artifexterra3d to do basic collision at the moment. I found a post with someone modifying it to check collision on static geometry, but when I added that, it still didn't catch the paged geometry collisions. Any ideas?
This is currently a partial limitation of PagedGeometry in that collision isn't the easiest to implement. The current best method is to write a custom GeometryPage type that rather than adding entities to the scene, adds them to your physics system. Then you can add this page type to your PagedGeometry object and configure it to a certain near/far range.
Alright. I'm starting to look into OgreODE as one possible way of doing this. I think I need to head this direction anyway to get the physics I wanted. The only issue I'm thinking of is performance. I'm using the Myrddin landscape plugin, which utilizes paged terrain, so my worlds can get very big. With paged geometry, I'd be adding all of the trees for example still at level load. This could end up being a lot of objects for OgreODE to handle collisions on. Do you still think your approach you outlined is the best still? Currently using MOC, it using RaySceneQueries to test for collisions using query masks, which seems like it'd be better performance given the large terrain with lots of trees. But maybe your way is the only option. Curious of your thoughts on that JohnJ, or if anyone else has ideas. Thanks!
Currently in PagedGeometry the only options are either to load everything into the collision system, load nearby entities through a GeometryPage implementation, or implement your own custom collision paging system that loads trees on demand based on broadphase bounding boxes. I can't help much with ODE because I'm more familiar with Bullet, but I doubt Ogre's raytracing capability if any would be faster than ODE or Bullet.
The current best method is to write a custom GeometryPage type that rather than adding entities to the scene, adds them to your physics system. Then you can add this page type to your PagedGeometry object and configure it to a certain near/far range.
The down-side to this approach is if you have dynamic RigidBodies that are moving around outside the far range there is a chance that the moving objects could become stuck in a tree when the static tree RigidBody suddenly pops into existence or the dynamic RigidBody could be thrown a great distance once the collision is detected. I'm not aware of an easy way to solve this problem but one possible approach is to use a collision callback that automatically warps the dynamic RidgidBody out of the tree. However, in my experience, having hundreds of thousands of static rigid bodies (btScaledBvhTriangleMeshShape to be precise) in the physics system does not cause a noticeable reduction in frame rate. So it may not be an issue. My recommendation to Herb is to try initializing all of the static tree bodies in the physics engine and measure the results. Different physics engines may handle static meshes in different ways, so your results may vary from engine to engine.
Thanks JohnJ and Fish for your replies. This gives me some things to think about and try out!