1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-10-10 19:32:10 +00:00

Use true pitch/yaw/roll rotations without loss of precision by pgimeno (#8019)

Store the rotation in the node as a 4x4 transformation matrix internally (through IDummyTransformationSceneNode), which allows more manipulations without losing precision or having gimbal lock issues.

Network rotation is still transmitted as Eulers, though, not as matrix. But it will stay this way in 5.0.
This commit is contained in:
Paul Ouellette 2019-02-07 16:26:06 -05:00 committed by Paramat
parent fc566e2e10
commit d5456da69d
8 changed files with 251 additions and 49 deletions

View file

@ -25,6 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "object_properties.h"
#include "itemgroup.h"
#include "constants.h"
#include <cassert>
class Camera;
class Client;
@ -81,6 +82,7 @@ private:
scene::IAnimatedMeshSceneNode *m_animated_meshnode = nullptr;
WieldMeshSceneNode *m_wield_meshnode = nullptr;
scene::IBillboardSceneNode *m_spritenode = nullptr;
scene::IDummyTransformationSceneNode *m_matrixnode = nullptr;
Nametag *m_nametag = nullptr;
v3f m_position = v3f(0.0f, 10.0f * BS, 0);
v3f m_velocity;
@ -163,6 +165,19 @@ public:
scene::IAnimatedMeshSceneNode *getAnimatedMeshSceneNode();
// m_matrixnode controls the position and rotation of the child node
// for all scene nodes, as a workaround for an Irrlicht problem with
// rotations. The child node's position can't be used because it's
// rotated, and must remain as 0.
// Note that m_matrixnode.setPosition() shouldn't be called. Use
// m_matrixnode->getRelativeTransformationMatrix().setTranslation()
// instead (aka getPosRotMatrix().setTranslation()).
inline core::matrix4 &getPosRotMatrix()
{
assert(m_matrixnode);
return m_matrixnode->getRelativeTransformationMatrix();
}
inline f32 getStepHeight() const
{
return m_prop.stepheight;