Voxel Engine Collision Response

I just wanted to start off by saying that I’m pretty sure there is something out there on this topic, but I don’t really understand them. Please don’t scream at me to Google it.

So, anyways, ahead with the question. I’ve started working on a Voxel game(just a Minecraft clone to work on programming), and I’ve got some rendering done. This rendering isn’t very complicated, but I want collision done before the other stuff. I’ve gotten AABB’s setup and collision detection down, but I couldn’t get the collision detection working. Also, this collision doesn’t work if the player is travelling extraordinarily fast, so I was also wondering if there was a better method.

I’m using this to determine collision:

if (boundingBox.maxX + boundingBox.x > aabb.minX + aabb.x &&
                    boundingBox.minX + boundingBox.x < aabb.maxX + aabb.x &&
                    boundingBox.maxY + boundingBox.y > aabb.minY + aabb.y &&
                    boundingBox.minY + boundingBox.y < aabb.maxY + aabb.y &&
                    boundingBox.maxZ + boundingBox.z > aabb.minZ + aabb.z &&
                    boundingBox.minZ + boundingBox.z < aabb.maxZ + aabb.z) {
                return true;
 }

boundingBox is the player AABB and aabb is the AABB that we are checking collision for.
I’m adding the maxX to the x position, because the maxX is not absolute.

The problem you are describing is referred to as tunneling. call your delta movements for the next frame as dx, dy, dz. After you check your collisions in one frame and if you know the object is moving really fast then do this if statement.


boolean collisionNextFrame = true;

if(dx > 0)
{
      if(boundingBox.maxX + boundingBox.x + dx < aabb.minX + aabb.x ||
                    boundingBox.minX + boundingBox.x > aabb.maxX + aabb.x)
       {
               collisionNextFrame = false;
       }
}
else if(dx < 0)
{
           if(boundingBox.maxX + boundingBox.x < aabb.minX + aabb.x ||
                    boundingBox.minX + boundingBox.x + dx> aabb.maxX + aabb.x)
       {
               collisionNextFrame = false;
       }
}

//same thing for y and z
//if collisionNextFrame is still true then it will collide

Thanks but I really need the collision response. Thanks though!

i’m pretty sure minecraft doesn’t use collision like this.
minecraft probably stores tiles as arrays which you can access.
when you want to check for collision, you add speed values to moving object’s coordinates and divide them by tile/cube size. now you got tile’s/cubes’ coordinates on which the object will be once once you move it. all that is left to do is to get the tile/cube with coordinates you calculated and check if you can move in that tile/cube.