mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Allow rotating entity selectionboxes (#12379)
This commit is contained in:
parent
b829231992
commit
077627181e
18 changed files with 271 additions and 58 deletions
|
@ -197,6 +197,11 @@ void LuaEntitySAO::step(float dtime, bool send_recommended)
|
|||
}
|
||||
}
|
||||
|
||||
if (fabs(m_prop.automatic_rotate) > 0.001f) {
|
||||
m_rotation_add_yaw = modulo360f(m_rotation_add_yaw + dtime * core::RADTODEG *
|
||||
m_prop.automatic_rotate);
|
||||
}
|
||||
|
||||
if(m_registered) {
|
||||
m_env->getScriptIface()->luaentity_Step(m_id, dtime, moveresult_p);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue