Collision Detection between Player and Block (Swept AABB)
A voxel world makes collision detection unusually convenient: every block already has a simple, predictable shape. Instead of checking the player's full geometry against the world, the player can be represented by a box-shaped hitbox.
This is an Axis-Aligned Bounding Box (AABB). Since both the player and every solid voxel can be represented as axis-aligned boxes, collision checks only need to consider their extents along the three coordinate axes.
Why Basic AABB Wasn't Enough
Basic AABB intersection works well for determining whether two boxes are currently overlapping. For a voxel world, this is particularly efficient because blocks are static and already aligned to the world grid.
The problem appears when the player moves quickly.
If the player's position is checked only once per frame, the player can move from one side of a block to the other between two collision checks. Neither position is overlapping, so the collision is never detected. The player effectively passes through the block.
This is known as tunneling.
The issue became especially noticeable when the frame rate dropped: the longer the time between collision checks, the farther the player could travel without being tested against the world.
Improved Solution: Swept AABB
One solution is to treat movement as a continuous path rather than checking only the player's position at the beginning and end of a frame.
Swept AABB considers the entire movement of the player's hitbox over the frame and determines whether it intersects a block during that movement.
Instead of returning only whether a collision occurred, the calculation provides a collision time and a collision normal. The collision time identifies when during the movement the player reaches the block, while the normal indicates which surface was hit.
That information makes it possible to resolve the collision without simply stopping the player. The movement remaining after the collision can be projected along the surface, allowing the player to slide along walls and floors instead of getting stuck.
This also makes the collision system robust to lower frame rates: the player's movement is accounted for across the entire frame rather than relying on the collision check happening frequently enough to catch an overlap.
For reference, the underlying 2D swept AABB approach is described here.
Swept AABB Implementation in 3D Voxel Space
My voxel engine extends this approach into 3D and uses it to resolve the player's movement against solid blocks.
The result is a collision system that keeps the simplicity of box-based collision while avoiding one of the major weaknesses of discrete AABB checks: passing through geometry when movement exceeds the distance between collision checks.