#include "actions.h" //GET A CUBE DEFINED BY ITS POS //cubeChunk is a "cubemap" array //x,y,z are coordinates //warning ! the coordinates are in the chunk, NOT in the world. So 0,0,0 is player's feet pos. //basically, 0,0,0 is the cube where the player stands on. int getCubeIndex(float x,float y,float z) { int index=0,temp=0; x+=CUBE_CHUNK_X; y+=CUBE_CHUNK_Y; z+=CUBE_CHUNK_Z-2.0; if(x>0 && y>0 && z>0 && x/2.0=0 && index0) { if(chunk[chunkIndex]>0) { collision=1; if(lastCube!=NULL) *lastCube=getCubeIndex(xPos-xcoef/20,yPos-ycoef/20,zPos-zcoef/20+4); } } } //now, let's get worldIndex with chunkIndex... if(collision==1) { worldIndex=getWorldIndexFromChunk(chunkIndex,playerPos); if(lastCube!=NULL) *lastCube=getWorldIndexFromChunk(*lastCube,playerPos); } return worldIndex; } //REMOVE A BLOCK void removeBlock(uint8_t *world,uint8_t *chunk,float angleX,float angleZ,pos playerPos) { int index=rayCast(chunk,angleX,angleZ,playerPos,NULL); if(index>=0) { if(world[index]!=1)//bedrock world[index]=0; } } //ADD A BLOCK void addBlock(uint8_t *world,uint8_t *chunk,float angleX,float angleZ,pos playerPos,int block) { int newCubeIndex=-1; rayCast(chunk,angleX,angleZ,playerPos,&newCubeIndex); if(newCubeIndex>0 && newCubeIndex