From 695e3db5f9b24ad46d236a28f9896dc9e5a619f6 Mon Sep 17 00:00:00 2001 From: LaG1924 <12997935+LaG1924@users.noreply.github.com> Date: Tue, 6 Feb 2018 16:47:21 +0500 Subject: Simplified raycast --- src/GameState.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/GameState.cpp') 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; } } -- cgit v1.2.3