Hi,
I’ve implemented testing voxel at player position, this is what I’ve already done and it isn’t very accurate, you can still pass through blocks - hence the reason I was asking over using AABB.
Or are you saying which maybe you are - use each corner of the player as position for voxel, thus you could test 8 positions?
@Argo - so, once I’ve got the block I then use sphere test with the blocks AABB?
I think doing a sphere (player) to AABB (voxel) test would prove best method. I’ve modified some AABB/Circle/CollisionLibrary class code to support Z:
public class AABB {
	public Vector center;
	public float r[];
	public AABB(final float width, final float height, final float depth) {
		center = new Vector();
		r = new float[3];
		r[0] = width * 0.5f;
		r[1] = height * 0.5f;
		r[2] = depth * 0.5f;
	}
	public void update(final Vector position) {
		center.x = position.x;
		center.y = position.y;
		center.z = position.z;
	}
}
public class Circle {
	public Vector center;
	public float radius;
	public Circle(final float radius) {
		center = new Vector();
		this.radius = radius;
	}
	public void update(final Vector position) {
		center.x = position.x;
		center.y = position.y;
		center.z = position.z;
	}
}
public class CollisionLibrary {
	public static boolean testAABBAABB(final AABB box1, final AABB box2) {
		   if (Math.abs(box1.center.x - box2.center.x) > (box1.r[0] + box2.r[0])) return false;
		   if (Math.abs(box1.center.y - box2.center.y) > (box1.r[1] + box2.r[1])) return false;
		   if (Math.abs(box1.center.z - box2.center.z) > (box1.r[2] + box2.r[2])) return false;
		   return true;
		}
	
	public static float sqDistPointAABB(final Vector p, final AABB aabb) {
		   float sqDist = 0.0f;
		   float v;
		   float minX, minY, minZ, maxX, maxY, maxZ;
		      
		   // get the minX, maxX, minY, maxY and minZ, maxZ points of the AABB
		   minX = aabb.center.x - aabb.r[0];
		   maxX = aabb.center.x + aabb.r[0];
		      
		   minY = aabb.center.y - aabb.r[1];
		   maxY = aabb.center.y + aabb.r[1];
		      
		   minZ = aabb.center.z - aabb.r[2];
		   maxZ = aabb.center.z + aabb.r[2];
		      
		   // test the bounds against the points X axis
		   v = p.x;
		      
		   if (v < minX) sqDist += (minX - v) * (minX - v);
		   if (v > maxX) sqDist += (v - maxX) * (v - maxX);
		      
		   // test the bounds against the points Y axis
		   v = p.y;
		      
		   if (v < minY) sqDist += (minY - v) * (minY - v);
		   if (v > maxY) sqDist += (v - maxY) * (v - maxY);
		      
		   // test the bounds against the points Z axis
		   v = p.z;
		      
		   if (v < minZ) sqDist += (minZ - v) * (minZ - v);
		   if (v > maxZ) sqDist += (v - maxZ) * (v - maxZ);
		      
		   return sqDist;
		}
	
		public static boolean testCircleAABB(final Circle circle, final AABB box) {
		   // get the squared distance between circle center and the AABB
		   float sqDist = sqDistPointAABB(circle.center, box);
		   float r = circle.radius;
		      
		   return sqDist <= r * r;
		}
	
}
Thanks
      
    

