aboutsummaryrefslogtreecommitdiff
path: root/src/server/unit_sao.h
diff options
context:
space:
mode:
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;