diff options
author | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2018-02-06 12:47:21 +0100 |
---|---|---|
committer | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2018-02-06 17:35:33 +0100 |
commit | 695e3db5f9b24ad46d236a28f9896dc9e5a619f6 (patch) | |
tree | 40061610b81a88c17ae812f23967d00cf9b78a26 /src/GameState.cpp | |
parent | Added visualisation of selected block (diff) | |
download | AltCraft-695e3db5f9b24ad46d236a28f9896dc9e5a619f6.tar AltCraft-695e3db5f9b24ad46d236a28f9896dc9e5a619f6.tar.gz AltCraft-695e3db5f9b24ad46d236a28f9896dc9e5a619f6.tar.bz2 AltCraft-695e3db5f9b24ad46d236a28f9896dc9e5a619f6.tar.lz AltCraft-695e3db5f9b24ad46d236a28f9896dc9e5a619f6.tar.xz AltCraft-695e3db5f9b24ad46d236a28f9896dc9e5a619f6.tar.zst AltCraft-695e3db5f9b24ad46d236a28f9896dc9e5a619f6.zip |
Diffstat (limited to 'src/GameState.cpp')
-rw-r--r-- | src/GameState.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/GameState.cpp b/src/GameState.cpp index 650cd6f..180db98 100644 --- a/src/GameState.cpp +++ b/src/GameState.cpp @@ -36,7 +36,9 @@ void GameState::Update(float deltaTime) { direction.y = sin(glm::radians(playerPitch)); direction.z = sin(glm::radians(playerYaw)) * cos(glm::radians(playerPitch)); - selectedBlock = world.Raycast(player->pos + player->EyeOffset, direction, distanceToSelectedBlock); + RaycastResult raycast = world.Raycast(player->pos + player->EyeOffset, direction); + selectedBlock = raycast.isHit ? raycast.hitBlock : Vector(0,0,0); + distanceToSelectedBlock = raycast.isHit ? (player->pos - raycast.hitPos).GetLength() : 0.0f; } } |