Refactor some ArCameraController code

This commit is contained in:
2021-08-26 19:50:56 +02:00
parent 2364c05055
commit 3d92bef231
3 changed files with 7 additions and 12 deletions

View File

@@ -61,7 +61,7 @@ namespace openVulkanoCpp
} }
m_updated = false; m_updated = false;
m_arSession->OnNewCameraViewMatrix += EventHandler(this, &ArCameraController::UpdateCameraTransformation); m_arSession->OnNewCameraViewMatrix += EventHandler(this, &ArCameraController::UpdateCameraViewMatrix);
} }
void ArCameraController::Init(Scene::Camera* camera, const std::shared_ptr<AR::ArSession>& session, const Math::Matrix4f& registration) void ArCameraController::Init(Scene::Camera* camera, const std::shared_ptr<AR::ArSession>& session, const Math::Matrix4f& registration)
@@ -78,7 +78,7 @@ namespace openVulkanoCpp
if (!GetCamera() || !m_updated) return; if (!GetCamera() || !m_updated) return;
std::unique_lock lock(m_mutex); std::unique_lock lock(m_mutex);
Math::Matrix4f mat = m_registration * Math::Utils::inverse(m_matrixToUpdate); Math::Matrix4f mat = m_registration * Math::Utils::inverse(m_viewMatrixToUpdate);
GetCamera()->SetMatrix(mat); GetCamera()->SetMatrix(mat);
m_updated = false; m_updated = false;
} }
@@ -86,15 +86,15 @@ namespace openVulkanoCpp
void ArCameraController::Close() void ArCameraController::Close()
{ {
if (!GetCamera()) return; if (!GetCamera()) return;
m_arSession->OnNewCameraViewMatrix -= EventHandler(this, &ArCameraController::UpdateCameraTransformation); m_arSession->OnNewCameraViewMatrix -= EventHandler(this, &ArCameraController::UpdateCameraViewMatrix);
SetCamera(nullptr); SetCamera(nullptr);
m_arSession = nullptr; m_arSession = nullptr;
} }
void ArCameraController::UpdateCameraTransformation(const Math::Matrix4f& transform) void ArCameraController::UpdateCameraViewMatrix(const Math::Matrix4f& transform)
{ {
std::unique_lock lock(m_mutex); std::unique_lock lock(m_mutex);
m_matrixToUpdate = transform; m_viewMatrixToUpdate = transform;
m_updated = true; m_updated = true;
} }
} }

View File

@@ -23,7 +23,7 @@ namespace openVulkanoCpp
{ {
std::shared_ptr<AR::ArSession> m_arSession; std::shared_ptr<AR::ArSession> m_arSession;
Math::Matrix4f m_registration; Math::Matrix4f m_registration;
Math::Matrix4f m_matrixToUpdate; Math::Matrix4f m_viewMatrixToUpdate;
std::mutex m_mutex; std::mutex m_mutex;
std::atomic<bool> m_updated; std::atomic<bool> m_updated;
@@ -45,6 +45,6 @@ namespace openVulkanoCpp
private: private:
void Init(); void Init();
void UpdateCameraTransformation(const Math::Matrix4f& transform); void UpdateCameraViewMatrix(const Math::Matrix4f& transform);
}; };
} }

View File

@@ -11,11 +11,6 @@
namespace openVulkanoCpp namespace openVulkanoCpp
{ {
namespace Scene
{
class Camera;
}
namespace Input namespace Input
{ {
class InputAction; class InputAction;