diff options
author | CoderForTheBetter <marcumjp@gmail.com> | 2018-11-28 03:38:50 -0500 |
---|---|---|
committer | Loïc Blot <nerzhul@users.noreply.github.com> | 2018-11-28 09:38:50 +0100 |
commit | faa358e797128ab07bb5644ce305a832d59e5596 (patch) | |
tree | dcf05ef0611b839503c4845fd89ad9519ee1c4bb /src/content_sao.h | |
parent | 9519d57017cfa28eb4f2fbf3c780f826017bbb00 (diff) | |
download | minetest-faa358e797128ab07bb5644ce305a832d59e5596.tar.gz minetest-faa358e797128ab07bb5644ce305a832d59e5596.tar.bz2 minetest-faa358e797128ab07bb5644ce305a832d59e5596.zip |
Add Lua methods 'set_rotation()' and 'get_rotation()' (#7395)
* Adds Lua methods 'set_rotation()' and 'get_rotation'. Also changed some method names to be more clear. Instead of an f32 being sent over network for yaw, now a v3f is sent for rotation on xyz axes. Perserved Lua method set_yaw/setyaw so that old mods still work, other wise to set yaw they would need to switch to set_rotation(0, yaw, 0).
Diffstat (limited to 'src/content_sao.h')
-rw-r--r-- | src/content_sao.h | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/src/content_sao.h b/src/content_sao.h index e45a4028e..6d2f55b70 100644 --- a/src/content_sao.h +++ b/src/content_sao.h @@ -32,11 +32,12 @@ public: UnitSAO(ServerEnvironment *env, v3f pos); virtual ~UnitSAO() = default; - virtual void setYaw(const float yaw) { m_yaw = yaw; } - float getYaw() const { return m_yaw; }; - f32 getRadYaw() const { return m_yaw * core::DEGTORAD; } + void setRotation(v3f rotation) { m_rotation = rotation; } + const v3f &getRotation() const { return m_rotation; } + v3f getRadRotation() { return m_rotation * core::DEGTORAD; } + // Deprecated - f32 getRadYawDep() const { return (m_yaw + 90.) * core::DEGTORAD; } + f32 getRadYawDep() const { return (m_rotation.Y + 90.) * core::DEGTORAD; } s16 getHP() const { return m_hp; } // Use a function, if isDead can be defined by other conditions @@ -64,7 +65,8 @@ public: void notifyObjectPropertiesModified(); protected: s16 m_hp = -1; - float m_yaw = 0.0f; + + v3f m_rotation; bool m_properties_sent = true; ObjectProperties m_prop; @@ -156,9 +158,9 @@ private: v3f m_velocity; v3f m_acceleration; - float m_last_sent_yaw = 0.0f; v3f m_last_sent_position; v3f m_last_sent_velocity; + v3f m_last_sent_rotation; float m_last_sent_position_timer = 0.0f; float m_last_sent_move_precision = 0.0f; std::string m_current_texture_modifier = ""; @@ -232,16 +234,16 @@ public: void setBasePosition(const v3f &position); void setPos(const v3f &pos); void moveTo(v3f pos, bool continuous); - void setYaw(const float yaw); + void setPlayerYaw(const float yaw); // Data should not be sent at player initialization - void setYawAndSend(const float yaw); - void setPitch(const float pitch); + void setPlayerYawAndSend(const float yaw); + void setLookPitch(const float pitch); // Data should not be sent at player initialization - void setPitchAndSend(const float pitch); - f32 getPitch() const { return m_pitch; } - f32 getRadPitch() const { return m_pitch * core::DEGTORAD; } + void setLookPitchAndSend(const float pitch); + f32 getLookPitch() const { return m_pitch; } + f32 getRadLookPitch() const { return m_pitch * core::DEGTORAD; } // Deprecated - f32 getRadPitchDep() const { return -1.0 * m_pitch * core::DEGTORAD; } + f32 getRadLookPitchDep() const { return -1.0 * m_pitch * core::DEGTORAD; } void setFov(const float pitch); f32 getFov() const { return m_fov; } void setWantedRange(const s16 range); |