Bugfix: make waypoints respect camera offset
authorRealBadAngel <maciej.kasatkin@yahoo.com>
Mon, 5 May 2014 05:45:20 +0000 (07:45 +0200)
committerRealBadAngel <maciej.kasatkin@o2.pl>
Mon, 5 May 2014 07:03:37 +0000 (09:03 +0200)
src/game.cpp
src/hud.cpp
src/hud.h

index 51e97d61b415957912dd5e7eb85c5d413c151272..a9ca38d1d10df511b7af36bf532ca2a4d7efe50b 100644 (file)
@@ -3594,7 +3594,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
                        Draw lua hud items
                */
                if (show_hud)
-                       hud.drawLuaElements();
+                       hud.drawLuaElements(camera.getOffset());
 
                /*
                        Draw gui
index bbec4489ead7203043c9ec5d30752a7387ca80d4..c385211f24ffe60c84dae2debbb6d01084c93f0f 100644 (file)
@@ -46,7 +46,7 @@ Hud::Hud(video::IVideoDriver *driver, scene::ISceneManager* smgr,
        this->gamedef     = gamedef;
        this->player      = player;
        this->inventory   = inventory;
-       
+
        m_screensize       = v2u32(0, 0);
        m_displaycenter    = v2s32(0, 0);
        m_hotbar_imagesize = floor(HOTBAR_IMAGE_SIZE * porting::getDisplayDensity() + 0.5);
@@ -222,7 +222,7 @@ void Hud::drawItems(v2s32 upperleftpos, s32 itemcount, s32 offset,
 }
 
 
-void Hud::drawLuaElements() {
+void Hud::drawLuaElements(v3s16 camera_offset) {
        for (size_t i = 0; i != player->hud.size(); i++) {
                HudElement *e = player->hud[i];
                if (!e)
@@ -277,6 +277,7 @@ void Hud::drawLuaElements() {
                                v3f w_pos = e->world_pos * BS;
                                float distance = floor(10 * p_pos.getDistanceFrom(e->world_pos)) / 10;
                                scene::ICameraSceneNode* camera = smgr->getActiveCamera();
+                               w_pos -= intToFloat(camera_offset, BS);
                                core::matrix4 trans = camera->getProjectionMatrix();
                                trans *= camera->getViewMatrix();
                                f32 transformed_pos[4] = { w_pos.X, w_pos.Y, w_pos.Z, 1.0f };
index 3897a850c332fba79a005e82d0558a4117e67202..1ace6646fd91f99aa0dceef30dd01e7e4d4dd8a1 100644 (file)
--- a/src/hud.h
+++ b/src/hud.h
@@ -115,6 +115,7 @@ public:
        bool use_hotbar_image;
        std::string hotbar_selected_image;
        bool use_hotbar_selected_image;
+       v3s16 camera_offset;
        
        Hud(video::IVideoDriver *driver,scene::ISceneManager* smgr,
                gui::IGUIEnvironment* guienv, gui::IGUIFont *font,
@@ -125,7 +126,7 @@ public:
        void resizeHotbar();
        void drawCrosshair();
        void drawSelectionBoxes(std::vector<aabb3f> &hilightboxes);
-       void drawLuaElements();
+       void drawLuaElements(v3s16 camera_offset);
 private:
        void drawStatbar(v2s32 pos, u16 corner, u16 drawdir,
                                         std::string texture, s32 count, v2s32 offset);