- Get character's AABB.
- Set's character's AABB position to current character's position.
- Add velocity vector to character's AABB position.
- Pass the character's AABB and an empty std::set
to the octree.
- Collide the character's AABB with the octree nodes, when in a leaf, collide the meshes's AABB there with the character's AABB again and get those that overlap.
- Iterate the std::set
we got from the octree and collide the character's ellipsoid with each mesh geometry.
This added quite a lot of complexity to per-frame processing but framerate increased notoriously because the data to be processed (mesh geometry) got reduced A LOT.
Now I need to do the same for drawing only what's visible which will increase framerate quite a bit as well.
The following video shows a level composed of 54 meshes with 54 faces each. At all time, I'm colliding only with +-1.6 meshes per frame. At the top right you can see the number of tiles that are subject to collision. The wireframe represents the octree's nodes.
Got it. I made the octree class and I'm able to push the meshes geometry into it. The algorithm for character collision against the world is something like this: