Node definition manager refactor (#7016)
[oweals/minetest.git] / src / camera.h
index 8d213ede7dbe238e90368063eaf56146868542a4..88de3570ae25779ccf65ff6e8dbec570e19f554f 100644 (file)
@@ -17,20 +17,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
 
-#ifndef CAMERA_HEADER
-#define CAMERA_HEADER
+#pragma once
 
 #include "irrlichttypes_extrabloated.h"
 #include "inventory.h"
-#include "mesh.h"
 #include "client/tile.h"
-#include "util/numeric.h"
 #include <ICameraSceneNode.h>
 #include <ISceneNode.h>
 #include <list>
 
-#include "client.h"
-
 class LocalPlayer;
 struct MapDrawControl;
 class Client;
@@ -39,15 +34,18 @@ class WieldMeshSceneNode;
 struct Nametag {
        Nametag(scene::ISceneNode *a_parent_node,
                        const std::string &a_nametag_text,
-                       const video::SColor &a_nametag_color):
+                       const video::SColor &a_nametag_color,
+                       const v3f &a_nametag_pos):
                parent_node(a_parent_node),
                nametag_text(a_nametag_text),
-               nametag_color(a_nametag_color)
+               nametag_color(a_nametag_color),
+               nametag_pos(a_nametag_pos)
        {
        }
        scene::ISceneNode *parent_node;
        std::string nametag_text;
        video::SColor nametag_color;
+       v3f nametag_pos;
 };
 
 enum CameraMode {CAMERA_MODE_FIRST, CAMERA_MODE_THIRD, CAMERA_MODE_THIRD_FRONT};
@@ -60,8 +58,7 @@ enum CameraMode {CAMERA_MODE_FIRST, CAMERA_MODE_THIRD, CAMERA_MODE_THIRD_FRONT};
 class Camera
 {
 public:
-       Camera(scene::ISceneManager* smgr, MapDrawControl& draw_control,
-                       Client *client);
+       Camera(MapDrawControl &draw_control, Client *client);
        ~Camera();
 
        // Get camera scene node.
@@ -118,7 +115,7 @@ public:
        // Update the camera from the local player's position.
        // busytime is used to adjust the viewing range.
        void update(LocalPlayer* player, f32 frametime, f32 busytime,
-                       f32 tool_reload_ratio, ClientEnvironment &c_env);
+                       f32 tool_reload_ratio);
 
        // Update render distance
        void updateViewingRange();
@@ -158,7 +155,8 @@ public:
        }
 
        Nametag *addNametag(scene::ISceneNode *parent_node,
-               std::string nametag_text, video::SColor nametag_color);
+               const std::string &nametag_text, video::SColor nametag_color,
+               const v3f &pos);
 
        void removeNametag(Nametag *nametag);
 
@@ -166,6 +164,8 @@ public:
 
        void drawNametags();
 
+       inline void addArmInertia(f32 player_yaw);
+
 private:
        // Nodes
        scene::ISceneNode *m_playernode = nullptr;
@@ -179,7 +179,6 @@ private:
        MapDrawControl& m_draw_control;
 
        Client *m_client;
-       video::IVideoDriver *m_driver;
 
        // Absolute camera position
        v3f m_camera_position;
@@ -188,6 +187,12 @@ private:
        // Camera offset
        v3s16 m_camera_offset;
 
+       v2f m_wieldmesh_offset = v2f(55.0f, -35.0f);
+       v2f m_arm_dir;
+       v2f m_cam_vel;
+       v2f m_cam_vel_old;
+       v2f m_last_cam_pos;
+
        // Field of view and aspect ratio stuff
        f32 m_aspect = 1.0f;
        f32 m_fov_x = 1.0f;
@@ -220,9 +225,7 @@ private:
        f32 m_cache_fall_bobbing_amount;
        f32 m_cache_view_bobbing_amount;
        f32 m_cache_fov;
-       f32 m_cache_zoom_fov;
+       bool m_arm_inertia;
 
        std::list<Nametag *> m_nametags;
 };
-
-#endif