diff --git a/src/scene.cpp b/src/scene.cpp index 3ff2303..5adba6e 100644 --- a/src/scene.cpp +++ b/src/scene.cpp @@ -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() diff --git a/src/scene.h b/src/scene.h index d7bc4d0..57a8805 100644 --- a/src/scene.h +++ b/src/scene.h @@ -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();