Tried just updating new position and not camera before checking collision, same result.
Code:
http://pastebin.java-gaming.org/3ebf334355c
Note, I’m still checking all the blocks in the chunk - dunno if this is causing the issue of when collision occurs when moving forwards for instance, I then turn around and move forwards, still collision - thus cannot move forwards. This still using AABB too. I’ve just put this in for a simple collision check with no AABB:
Vector3f v = camera.getCameraPosition();
int bx = (int)Math.abs(Math.floor(v.x));
int by = (int)Math.abs(Math.floor(v.y));
int bz = (int)Math.abs(Math.floor(v.z));
Block b = ChunkManager.getInstance().getBlockInChunk(0, bx, by, bz);
if(b.IsActive())
{
// A collision
}
Need to check other blocks too as @HeroesGraveDev suggests.
*EDIT
Added this:
outerloop:
for(int x=-1; x < 2; x++)
for(int y=0; y< 2; y++)
for(int z=-1; z< 2; z++)
{
int bx = (int)Math.abs(Math.floor(v.x))+x;
int by = (int)Math.abs(Math.floor(v.y))+y;
int bz = (int)Math.abs(Math.floor(v.z))+z;
Block b = null;
b = ChunkManager.getInstance().getBlockInChunk(0, bx, by, bz);
if(b!=null && b.IsActive())
{
loopblockCollision = "LOOP COLLISION FOUND";
break outerloop;
}
else
loopblockCollision = "LOOP NO COLLISION";
}
Video: https://www.youtube.com/watch?v=G1J4GlA0fMk
This gives more accurate collision, now, what to do when there is a collision??