Allow controlling free camera with arrows when no object is selected

master
krzys-h 2015-09-06 20:09:47 +02:00
parent 883348c6cf
commit f6fdec1479
2 changed files with 13 additions and 7 deletions

View File

@ -1226,6 +1226,12 @@ EngineMouseType CCamera::GetMouseDef(Math::Point pos)
bool CCamera::EventFrameFree(const Event &event)
{
Math::Vector cameraInput = event.cameraInput;
if (m_cameraObj == nullptr)
{
cameraInput = Math::Clamp(cameraInput + event.motionInput, Math::Vector(-1.0f, -1.0f, -1.0f), Math::Vector(1.0f, 1.0f, 1.0f));
}
float factor = m_heightEye * 0.5f + 30.0f;
if ( m_mouseDirH != 0.0f )
@ -1234,19 +1240,19 @@ bool CCamera::EventFrameFree(const Event &event)
m_eyePt = Math::LookatPoint(m_eyePt, m_directionH, m_directionV, m_mouseDirV * event.rTime * factor * m_speed);
// Up/Down
m_eyePt = Math::LookatPoint(m_eyePt, m_directionH, m_directionV, event.cameraInput.y * event.rTime * factor * m_speed);
m_eyePt = Math::LookatPoint(m_eyePt, m_directionH, m_directionV, cameraInput.y * event.rTime * factor * m_speed);
// Left/Right
if ( event.kmodState & KEY_MOD(CTRL) )
{
if ( event.cameraInput.x < 0.0f )
m_eyePt = Math::LookatPoint(m_eyePt, m_directionH + Math::PI / 2.0f, m_directionV, -event.cameraInput.x * event.rTime * factor * m_speed);
if ( event.cameraInput.x > 0.0f )
m_eyePt = Math::LookatPoint(m_eyePt, m_directionH - Math::PI / 2.0f, m_directionV, event.cameraInput.x * event.rTime * factor * m_speed);
if ( cameraInput.x < 0.0f )
m_eyePt = Math::LookatPoint(m_eyePt, m_directionH + Math::PI / 2.0f, m_directionV, -cameraInput.x * event.rTime * factor * m_speed);
if ( cameraInput.x > 0.0f )
m_eyePt = Math::LookatPoint(m_eyePt, m_directionH - Math::PI / 2.0f, m_directionV, cameraInput.x * event.rTime * factor * m_speed);
}
else
{
m_directionH -= event.cameraInput.x * event.rTime * 0.7f * m_speed;
m_directionH -= cameraInput.x * event.rTime * 0.7f * m_speed;
}
// PageUp/PageDown

View File

@ -1825,9 +1825,9 @@ bool CRobotMain::SelectObject(CObject* obj, bool displayError)
if (m_missionType == MISSION_CODE_BATTLE && m_codeBattleStarted)
{
// During code battles, only change camera
m_camera->SetControllingObject(obj);
if (obj != nullptr)
{
m_camera->SetControllingObject(obj);
m_camera->SetType(Gfx::CAM_TYPE_PLANE);
}
else