X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fui%2Fui.cpp;h=02f372e5c66c57d7a827362814dc61c97aa66bc1;hb=38a4cffc0b6aa58e49d24c06aad7bee14cb6515d;hp=2ec4d883d3e6f963dc047e85694a5bfb9bcec00d;hpb=4e3d9c23940c4511623b5bf328cbbe42641c4b30;p=blank.git diff --git a/src/ui/ui.cpp b/src/ui/ui.cpp index 2ec4d88..02f372e 100644 --- a/src/ui/ui.cpp +++ b/src/ui/ui.cpp @@ -103,11 +103,11 @@ Interface::Interface( const Config &config, Environment &env, World &world, - Entity &player) + const Player &player) : env(env) , world(world) -// let's assume this succeeds and hope for the best for now -, ctrl(player) +, player(player) +, ctrl(*player.entity) , hud(world.BlockTypes(), env.assets.small_ui_font) , aim{{ 0, 0, 0 }, { 0, 0, -1 }} , aim_world() @@ -396,9 +396,9 @@ void Interface::PickBlock() { void Interface::PlaceBlock() { if (!aim_world) return; - glm::vec3 next_pos = aim_world.BlockCoords() + aim_world.normal; - BlockLookup next_block(&aim_world.GetChunk(), next_pos); - if (next_block) { + BlockLookup next_block(aim_world.chunk, aim_world.BlockPos(), Block::NormalFace(aim_world.normal)); + if (!next_block) { + return; } next_block.SetBlock(selection); @@ -406,7 +406,7 @@ void Interface::PlaceBlock() { const Entity &player = ctrl.Controlled(); env.audio.Play( place_sound, - aim_world.GetChunk().ToSceneCoords(player.ChunkCoords(), next_pos) + next_block.GetChunk().ToSceneCoords(player.ChunkCoords(), next_block.GetBlockCoords()) ); } @@ -526,7 +526,7 @@ void Interface::UpdateOutline() { outl_buf.Clear(); aim_world.GetType().FillOutlineModel(outl_buf); outline.Update(outl_buf); - outline_transform = aim_world.GetChunk().Transform(Player().ChunkCoords()); + outline_transform = aim_world.GetChunk().Transform(player.entity->ChunkCoords()); outline_transform *= aim_world.BlockTransform(); outline_transform *= glm::scale(glm::vec3(1.005f)); }