Created
December 8, 2019 15:20
-
-
Save matyklug18/bd37c21a138844baf24fad655cf43335 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Vector3i end = new Vector3i((int) floor(rayPos.x), (int) floor(rayPos.y), (int) floor(rayPos.z)); | |
float dToPX = (float) (end.x-floor(end.x)); | |
float dToPY = (float) (end.y-floor(end.y)); | |
float dToPZ = (float) (end.z-floor(end.z)); | |
float dToNX = abs(1-dToPX); | |
float dToNY = abs(1-dToPY); | |
float dToNZ = abs(1-dToPZ); | |
BlockSide side; | |
float smallestValue = 0; | |
smallestValue = dToPX; | |
side = BlockSide.RIGHT; | |
if(smallestValue > dToPY) { | |
smallestValue = dToPY; | |
side = BlockSide.TOP; | |
} | |
if(smallestValue > dToPZ) { | |
smallestValue = dToPZ; | |
side = BlockSide.BACK; | |
} | |
if(smallestValue > dToPY) { | |
smallestValue = dToPY; | |
side = BlockSide.TOP; | |
} | |
if(smallestValue > dToNX) { | |
smallestValue = dToNX; | |
side = BlockSide.LEFT; | |
} | |
if(smallestValue > dToNY) { | |
smallestValue = dToNY; | |
side = BlockSide.BOTTOM; | |
} | |
if(smallestValue > dToNZ) { | |
smallestValue = dToNZ; | |
side = BlockSide.FRONT; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment