Skip to content

Commit

Permalink
Improved cinecam mouse rotation
Browse files Browse the repository at this point in the history
The rotation speed no longer depends on rendering resolution.
The rotation is faster overall, horizontal rotation is a little faster than vertical rotation.
  • Loading branch information
ohlidalp committed Mar 8, 2024
1 parent 060ae94 commit 847476a
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions source/main/gfx/camera/CameraManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -940,12 +940,24 @@ void CameraManager::CameraBehaviorOrbitUpdate()

bool CameraManager::CameraBehaviorOrbitMouseMoved(const OIS::MouseEvent& _arg)
{
const OIS::MouseState ms = _arg.state;
const Ogre::Vector2 ROT_SPEED(550.f, 330.f);

if (ms.buttonDown(OIS::MB_Right))
if (_arg.state.buttonDown(OIS::MB_Right))
{
App::GetGuiManager()->SetMouseCursorVisibility(GUIManager::MouseCursorVisibility::HIDDEN);
// Recalculate mouse motion relative to screen size
const Ogre::Vector2 mouse_nrel(
static_cast<float>(_arg.state.X.rel) / static_cast<float>(_arg.state.width),
static_cast<float>(_arg.state.Y.rel) / static_cast<float>(_arg.state.height));

// Calculate camera rotation
m_cam_rot_x += Degree(mouse_nrel.x * ROT_SPEED.x);
m_cam_rot_y += Degree(-mouse_nrel.y * ROT_SPEED.y);

// Calculate camera zoom
float scale = RoR::App::GetInputEngine()->isKeyDown(OIS::KC_LMENU) ? 0.002f : 0.02f;
m_cam_dist += -_arg.state.Z.rel * scale;

if (App::io_invert_orbitcam->getBool() && this->GetCurrentBehavior() != CameraManager::CAMERA_BEHAVIOR_VEHICLE_CINECAM)
{
m_cam_rot_x += Degree(ms.X.rel * -0.13f);
Expand All @@ -956,7 +968,6 @@ bool CameraManager::CameraBehaviorOrbitMouseMoved(const OIS::MouseEvent& _arg)
m_cam_rot_x += Degree(ms.X.rel * 0.13f);
m_cam_rot_y += Degree(-ms.Y.rel * 0.13f);
}
m_cam_dist += -ms.Z.rel * scale;
return true;
}

Expand Down

0 comments on commit 847476a

Please sign in to comment.