Skip to main content
1 of 3
House
  • 73.3k
  • 17
  • 185
  • 273

While I appreciate Kevin Reid's answer, it was at a level that was higher than what my question was asking. Understandably with out knowledge of Bullet Physics, it'd be hard to answer this question. I got this working and have an answer that is specific to Bullet Physics.

Along with extending the RigidBody class like I mentioned in my question. I also needed to extend the CollisionAlgorithm class. This is mostly to override the processCollision() function. Inside the processCollision() function (which takes the two colliding bodies as arguments), I was able to create a cube shape and appropriate Transform for the cube that my entity was currently colliding with. Then just let the default collision happen based on the entity and the specific cube/cubes it's colliding with. In order to use the newly extended CollisionAlgorithm, I needed to register the algorithm to deal with the shapes I want it to handle. In this case that's pretty much the terrain type against everything else. For that I used registerCollisionCreateFunc() with my CollisionDispatcher.

So for those following along in the future:

  1. Extend RigidBody to have a basic collision check with your terrain.
  2. Create a instance of your RigidBody class and add it to your DynamicsWorld or whatever PhysicsProccesor you're using.
  3. Extend CollisionAlgorithm, specifically processCollision() to create Bullet Physics shapes and Transforms that match with your collision location.
  4. Register your version of CollisionAlgorithm with your CollisionDispatcher using registerCollisionCreateFunc(). (This registration is done multiple times, once for each pair of shapes you want to collide.)
House
  • 73.3k
  • 17
  • 185
  • 273