mirror of
https://github.com/Poikilos/SAM-Viewer.git
synced 2023-10-03 07:58:48 -07:00
Fix gimbal-lock with keyboard rotations
This commit is contained in:
parent
608bbcc546
commit
77c31ce84a
@ -218,22 +218,24 @@ void Scene::setDebugInfo(const bool &is_visible)
|
||||
}
|
||||
}
|
||||
|
||||
void Scene::rotate(s32 axis, const s32 &step)
|
||||
void Scene::rotate(s32 axis, const f32 &step)
|
||||
{
|
||||
vector3df rot = getRotation();
|
||||
matrix4 m, n;
|
||||
m.setRotationDegrees(getRotation());
|
||||
switch (axis)
|
||||
{
|
||||
case E_SCENE_AXIS_X:
|
||||
rot.X = int(rot.X / step) * step + step;
|
||||
n.setRotationDegrees(vector3df(step,0,0));
|
||||
break;
|
||||
case E_SCENE_AXIS_Y:
|
||||
rot.Y = int(rot.Y / step) * step + step;
|
||||
n.setRotationDegrees(vector3df(0,step,0));
|
||||
break;
|
||||
case E_SCENE_AXIS_Z:
|
||||
rot.Z = int(rot.Z / step) * step + step;
|
||||
n.setRotationDegrees(vector3df(0,0,step));
|
||||
break;
|
||||
}
|
||||
setRotation(rot);
|
||||
m *= n;
|
||||
setRotation(m.getRotationDegrees());
|
||||
}
|
||||
|
||||
void Scene::refresh()
|
||||
|
@ -40,7 +40,7 @@ public:
|
||||
void setGridVisible(const bool &is_visible) { show_grid = is_visible; }
|
||||
void setAxesVisible(const bool &is_visible) { show_axes = is_visible; }
|
||||
void setDebugInfo(const bool &is_visible);
|
||||
void rotate(s32 axis, const s32 &step);
|
||||
void rotate(s32 axis, const f32 &step);
|
||||
void refresh();
|
||||
void jump();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user