]> git.lizzy.rs Git - dragonfireclient.git/commitdiff
Improved Tracers
authorElias Fleckenstein <eliasfleckenstein@web.de>
Sun, 4 Oct 2020 20:59:43 +0000 (22:59 +0200)
committerElias Fleckenstein <eliasfleckenstein@web.de>
Sun, 4 Oct 2020 20:59:43 +0000 (22:59 +0200)
clientmods/dragonfire/autosneak/settingtypes.txt
src/activeobjectmgr.h
src/client/client.cpp
src/client/clientenvironment.h
src/client/clientobject.h
src/client/content_cao.h
src/gui/tracers.cpp

index 6b588143ef4568c200979282458375d3e9517d05..787076970be41bfa2241a0bfc9bfa7f52c86d8a3 100644 (file)
@@ -1 +1 @@
-autosneak (AutoSneak) bool false 
+autosneak (AutoSneak) bool false
index 95e7d3344c8508969b3e2307dab4e172bbad2685..8c4630c795f096815176a689b60305cf112ff433 100644 (file)
@@ -41,7 +41,12 @@ template <typename T> class ActiveObjectMgr
                                m_active_objects.find(id);
                return (n != m_active_objects.end() ? n->second : nullptr);
        }
-
+       
+       std::unordered_map<u16, T *> getAllActiveObjects() const
+       {
+               return m_active_objects;
+       }
+       
 protected:
        u16 getFreeId() const
        {
index bbc32c6d45e67cb92b845ace69030a6897cac294..d3e7a278db63462b99b92ac0223b2438282b25fe 100644 (file)
@@ -1289,9 +1289,6 @@ void Client::sendReady()
 
 void Client::sendPlayerPos(v3f pos)
 {
-       if (g_settings->getBool("freecam"))
-               return;
-       
        LocalPlayer *player = m_env.getLocalPlayer();
        if (!player)
                return;
@@ -1309,7 +1306,7 @@ void Client::sendPlayerPos(v3f pos)
 
        if (
                        player->last_position     == pos &&
-                       player->last_speed        == player->getSpeed()    &&
+                       player->last_speed        == player->getLegitSpeed()    &&
                        player->last_pitch        == player->getPitch()    &&
                        player->last_yaw          == player->getYaw()      &&
                        player->last_keyPressed   == player->keyPressed    &&
@@ -1318,7 +1315,7 @@ void Client::sendPlayerPos(v3f pos)
                return;
 
        player->last_position     = pos;
-       player->last_speed        = player->getSpeed();
+       player->last_speed        = player->getLegitSpeed();
        player->last_pitch        = player->getPitch();
        player->last_yaw          = player->getYaw();
        player->last_keyPressed   = player->keyPressed;
@@ -1337,7 +1334,7 @@ void Client::sendPlayerPos()
        LocalPlayer *player = m_env.getLocalPlayer();
        if (!player)
                return;
-       sendPlayerPos(player->getPosition());
+       sendPlayerPos(player->getLegitPosition());
 }
 
 void Client::removeNode(v3s16 p)
@@ -1678,7 +1675,7 @@ void Client::updateAllMapBlocks()
                MapBlockVect blocks;
                sector->getBlocks(blocks);
                for (MapBlock *block : blocks) {
-                       addUpdateMeshTask(block->getPos(), false, true);
+                       addUpdateMeshTask(block->getPos(), false, false);
                }
        }
 }
index 864496a415bf58546717a59be640b0436a0866dc..52d999c9995fd83541dcfb88e313dcbaebd54273 100644 (file)
@@ -92,6 +92,11 @@ class ClientEnvironment : public Environment
        {
                return m_ao_manager.getActiveObject(id);
        }
+       
+       std::unordered_map<u16, ClientActiveObject*> getAllActiveObjects()
+       {
+               return m_ao_manager.getAllActiveObjects();
+       }
 
        /*
                Adds an active object to the environment.
index ecd8059ef758c2a556fd18ae2396acc7a5d9bd3d..19f8e3b724fe2fef315d929f08dac4dc3fac2eb2 100644 (file)
@@ -44,6 +44,7 @@ class ClientActiveObject : public ActiveObject
 
        virtual void updateLight(u32 day_night_ratio) {}
 
+       virtual bool isItem() const { return false; }
        virtual bool getCollisionBox(aabb3f *toset) const { return false; }
        virtual bool getSelectionBox(aabb3f *toset) const { return false; }
        virtual bool collideWithObjects() const { return false; }
index 88aa4870c008a527e9c4773dd0a5b0eeb05d0bef..51b58b0303a2690203a3149197bbe54d60b5f98e 100644 (file)
@@ -215,6 +215,8 @@ class GenericCAO : public ClientActiveObject
                m_is_visible = toset;
        }
 
+       bool isItem() const { return m_prop.visual == "wielditem" || m_prop.visual == "item"; }
+
        void setChildrenVisible(bool toset);
        void setAttachment(int parent_id, const std::string &bone, v3f position, v3f rotation);
        void getAttachment(int *parent_id, std::string *bone, v3f *position,
index b1f7b15c0954fc059992a2aebe8382803ff7f8cd..ee41d0fb0643a318b45a52c9889d7a3a263e845e 100644 (file)
@@ -26,16 +26,17 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 void Tracers::draw(video::IVideoDriver* driver, Client *client)
 {
        ClientEnvironment &env = client->getEnv();
-       LocalPlayer *player = env.getLocalPlayer();
        Camera *camera = client->getCamera();
-       v3f player_pos = player->getPosition();
        v3f head_pos = camera->getPosition() + camera->getDirection();
-       std::vector<DistanceSortedActiveObject> allObjects;
-       env.getActiveObjects(player_pos, 1000000, allObjects);
-       for (const auto &allObject : allObjects) {
-               ClientActiveObject *obj = allObject.obj;
-               if (obj->isLocalPlayer() || obj->getParent())
+       auto allObjects = env.getAllActiveObjects();
+       for (auto &it : allObjects) {
+               ClientActiveObject *obj = it.second;
+               if (obj->isLocalPlayer() || obj->getParent() || obj->isItem())
                        continue;
-               driver->draw3DLine(head_pos, obj->getPosition(), video::SColor(255, 255, 255, 255));
+               v3f pos = obj->getPosition();
+               aabb3f box;
+               if (obj->getSelectionBox(&box))
+                       pos += box.getCenter();
+               driver->draw3DLine(head_pos, pos, video::SColor(255, 255, 255, 255));
        }
 }