summaryrefslogtreecommitdiffstats
path: root/src/GameState.cpp
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2018-02-06 12:47:21 +0100
committerLaG1924 <12997935+LaG1924@users.noreply.github.com>2018-02-06 17:35:33 +0100
commit695e3db5f9b24ad46d236a28f9896dc9e5a619f6 (patch)
tree40061610b81a88c17ae812f23967d00cf9b78a26 /src/GameState.cpp
parentAdded visualisation of selected block (diff)
downloadAltCraft-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.cpp4
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;
}
}