aboutsummaryrefslogtreecommitdiff
path: root/src/server/unit_sao.h
diff options
context:
space:
mode:
authorLars Müller <34514239+appgurueu@users.noreply.github.com>2022-10-30 16:53:14 +0100
committerGitHub <noreply@github.com>2022-10-30 16:53:14 +0100
commit077627181ee2eac3c0dacc3d8dc49825837e474c (patch)
treea8a6298198738f2edb30bd7e733a7a0d2005affa /src/server/unit_sao.h
parentb8292319924994352d56d6111faa73fe315d149a (diff)
downloadminetest-077627181ee2eac3c0dacc3d8dc49825837e474c.tar.xz
Allow rotating entity selectionboxes (#12379)
Diffstat (limited to 'src/server/unit_sao.h')
-rw-r--r--src/server/unit_sao.h14
1 files changed, 14 insertions, 0 deletions
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 <quaternion.h>
+#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;