From f43e69eda5052eb1dac327b6dc490c970269a8fd Mon Sep 17 00:00:00 2001 From: darkrose Date: Fri, 20 Nov 2015 18:32:27 +1000 Subject: [PATCH] add camera offsetting to selection meshes --- src/game.cpp | 2 +- src/selection_mesh.cpp | 17 +++++++++++++++-- src/selection_mesh.h | 2 +- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/game.cpp b/src/game.cpp index 2eb9dff..9c25af0 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -2183,7 +2183,7 @@ void the_game( } if (selected_nodes.size() > 0) - selection_draw(driver,client,selected_nodes); + selection_draw(driver,client,camera.getOffset(),selected_nodes); /* draw old-style selection boxes */ if (hilightboxes.size()) { diff --git a/src/selection_mesh.cpp b/src/selection_mesh.cpp index b3de513..c503512 100644 --- a/src/selection_mesh.cpp +++ b/src/selection_mesh.cpp @@ -28,6 +28,7 @@ static std::map selected; static std::vector meshes; +static v3s16 o_camera_offset(0,0,0); static void selection_clear() { @@ -71,7 +72,7 @@ static void selection_generate(Client &client) } } -void selection_draw(video::IVideoDriver* driver, Client &client, std::vector &select) +void selection_draw(video::IVideoDriver* driver, Client &client, v3s16 camera_offset, std::vector &select) { if (!select.size()) { if (selected.size()) @@ -98,12 +99,22 @@ void selection_draw(video::IVideoDriver* driver, Client &client, std::vectorgetBool("trilinear_filter"); bool render_bilinear = g_settings->getBool("bilinear_filter"); bool render_anisotropic = g_settings->getBool("anisotropic_filter"); @@ -115,6 +126,8 @@ void selection_draw(video::IVideoDriver* driver, Client &client, std::vectorgetMesh(); if (!m) continue; + if (cos_changed) + translateMesh(m, cos_diff); u32 c = m->getMeshBufferCount(); for (u32 i=0; iappend(d.vertices.data(), d.vertices.size(), d.indices.data(), d.indices.size()); } - translateMesh(mesh, intToFloat(data->m_blockpos_nodes, BS)); + translateMesh(mesh, intToFloat(data->m_blockpos_nodes - o_camera_offset, BS)); if (m_mesh) m_mesh->drop(); diff --git a/src/selection_mesh.h b/src/selection_mesh.h index 37f762a..8d4a230 100644 --- a/src/selection_mesh.h +++ b/src/selection_mesh.h @@ -26,7 +26,7 @@ class Client; -void selection_draw(video::IVideoDriver* driver, Client &client, std::vector &select); +void selection_draw(video::IVideoDriver* driver, Client &client, v3s16 camera_offset, std::vector &select); class SelectionMesh {