Fix issues with camera

This commit is contained in:
Georg Hagen
2024-06-30 13:58:11 +02:00
parent 475c72e505
commit beeea386aa
2 changed files with 5 additions and 4 deletions

View File

@@ -245,7 +245,7 @@ namespace OpenVulkano::Scene
return 2.0f * atanf(tanf(m_fov * 0.5f) * m_aspect);
}
void UpdateProjectionMatrix()
void UpdateProjectionMatrix() override
{
m_projection = Math::Utils::perspectiveRH_ZO(m_fov, m_aspect, m_nearPlane, m_farPlane);
UpdateViewProjectionMatrix();
@@ -255,7 +255,7 @@ namespace OpenVulkano::Scene
class OrthographicCamera : public Camera
{
public:
void UpdateProjectionMatrix() final
void UpdateProjectionMatrix() override
{
const float scale = 0.5f * m_contentScaleFactor * m_zoom;
const float widthHalf = m_width * scale, heightHalf = m_height * scale;

View File

@@ -17,7 +17,7 @@ namespace OpenVulkano::Scene
, m_animationDuration(1.0f)
, m_currentTime(0.0f)
, m_isMorphing(false)
, m_targetMorphStatePerspective(false)
, m_targetMorphStatePerspective(true)
{
auto input = OpenVulkano::Input::InputManager::GetInstance();
m_actionMorph = input->GetAction("morph");
@@ -52,13 +52,14 @@ namespace OpenVulkano::Scene
t = 1.0f;
m_isMorphing = false;
}
float newState = m_targetMorphStatePerspective ? t : (1.0f - t);
float newState = m_targetMorphStatePerspective ? (1.0f - t) : t;
static_cast<MorphableCamera*>(GetCamera())->SetMorphState(newState);
}
}
void MorphableCameraController::SetTargetState(bool toPerspective)
{
if (toPerspective == m_targetMorphStatePerspective) return;
m_targetMorphStatePerspective = toPerspective;
m_isMorphing = true;
}