From 077627181ee2eac3c0dacc3d8dc49825837e474c Mon Sep 17 00:00:00 2001 From: Lars Müller <34514239+appgurueu@users.noreply.github.com> Date: Sun, 30 Oct 2022 16:53:14 +0100 Subject: Allow rotating entity selectionboxes (#12379) --- src/server/unit_sao.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/server/unit_sao.h') diff --git a/src/server/unit_sao.h b/src/server/unit_sao.h index a21e055c5..dedb1874e 100644 --- a/src/server/unit_sao.h +++ b/src/server/unit_sao.h @@ -22,6 +22,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "object_properties.h" #include "serveractiveobject.h" +#include +#include "util/numeric.h" class UnitSAO : public ServerActiveObject { @@ -36,6 +38,17 @@ public: // Rotation void setRotation(v3f rotation) { m_rotation = rotation; } const v3f &getRotation() const { return m_rotation; } + const v3f getTotalRotation() const { + // This replicates what happens clientside serverside + core::matrix4 rot; + setPitchYawRoll(rot, -m_rotation); + v3f res; + // First rotate by m_rotation, then rotate by the automatic rotate yaw + (core::quaternion(v3f(0, -m_rotation_add_yaw * core::DEGTORAD, 0)) + * core::quaternion(rot.getRotationDegrees() * core::DEGTORAD)) + .toEuler(res); + return res * core::RADTODEG; + } v3f getRadRotation() { return m_rotation * core::DEGTORAD; } // Deprecated @@ -95,6 +108,7 @@ protected: u16 m_hp = 1; v3f m_rotation; + f32 m_rotation_add_yaw = 0; ItemGroupList m_armor_groups; -- cgit v1.2.3