Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm making a voxel engine, and I'm trying to figure out the right way to make efficient collisions with a slide response (making the player slide against the wall).

Currently my collisions are pretty simple : if, after update, the player bounding box collides with the voxel world, then we just cancel the collision.

I have seen this answer on SO, but I don't understand what the answerer means here. Since a voxel is a single unit, how can I compute its normal ? Should I map the 3x3x3 block surrounding the voxel to a precomputed normal ?

  • Take the unit surface normal of the colliding voxel (pointing outward).
share|improve this question
add comment

1 Answer

You're drawing faces for the the terrain right? Just like you're computing faces for a voxel, you can compute the normal. The normal pointing outward of the voxel is the same normal pointing outward for the face you're drawing. If you have access to the vertices, you can compute the normal formed by the surface triangle you collided with.

Or more simply the normal is just the voxel pointing to the next voxel that's empty. For example:

enter image description here

The red lines point from the solid voxels towards the empty voxels. The black lines represent the faces being drawn. The red lines are the surface normals for the solid voxels.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.