rework API

This commit is contained in:
ohyzha
2024-11-06 09:48:53 +02:00
parent e2df88ca22
commit 3521ddeb1d
21 changed files with 296 additions and 230 deletions

View File

@@ -9,10 +9,7 @@
#include "Node.hpp"
#include "Math/Math.hpp"
#include "Math/Frustum.hpp"
#include "Input/InputDeviceMouse.hpp"
#include "Input/Touch/InputDeviceTouch.hpp"
#include "Input/InputManager.hpp"
#include "Base/Logger.hpp"
#include "Scene/Ray.hpp"
#include <array>
namespace OpenVulkano::Scene
@@ -31,7 +28,6 @@ namespace OpenVulkano::Scene
float m_contentScaleFactor = 1, m_zoom = 1; // For use with ortho camera
float m_interfaceOrientation = 0;
float m_padding = 0; //Unused
bool m_canCastRay = true;
Camera() : m_nearPlane(0), m_farPlane(0), m_width(0), m_height(0) {}
@@ -50,20 +46,6 @@ namespace OpenVulkano::Scene
m_farPlane = farPlane;
Node::Init();
UpdateProjectionMatrix();
if (m_canCastRay)
{
Input::InputDeviceMouse* mouse = static_cast<Input::InputDeviceMouse*>(Input::InputManager::GetInstance()->GetDevice(Input::InputDeviceType::MOUSE));
Input::InputDeviceTouch* touch = static_cast<Input::InputDeviceTouch*>(Input::InputManager::GetInstance()->GetDevice(Input::InputDeviceType::TOUCH));
if (mouse)
{
mouse->onLeftButtonClick += EventHandler(this, &Camera::CastRay);
}
else if (touch)
{
touch->OnTap += EventHandler(this, &Camera::CastRay);
}
}
}
public:
@@ -85,8 +67,6 @@ namespace OpenVulkano::Scene
[[nodiscard]] float FarPlane() const { return m_farPlane; }
[[nodiscard]] bool CanCastRay() const { return m_canCastRay; }
void SetContentScaleFactor(float contentScale = 1)
{
m_contentScaleFactor = 1.0f / contentScale;
@@ -104,7 +84,7 @@ namespace OpenVulkano::Scene
virtual void UpdateProjectionMatrix() = 0;
virtual std::optional<DrawableRayHit> CastRay(const Math::Vector2i& xy) const = 0;
Ray CastRay(const Math::Vector2i& xy) const;
void UpdateViewProjectionMatrix()
{
@@ -264,8 +244,6 @@ namespace OpenVulkano::Scene
SetProjectionMatrix(Math::Utils::perspectiveRH_ZO(m_fov, m_aspect, m_nearPlane, m_farPlane));
}
std::optional<DrawableRayHit> CastRay(const Math::Vector2i& xy) const override;
[[nodiscard]] bool IsPerspective() const override { return true; }
};
@@ -279,11 +257,6 @@ namespace OpenVulkano::Scene
SetProjectionMatrix(Math::Utils::orthoRH_ZO(-widthHalf, widthHalf, -heightHalf, heightHalf, m_nearPlane, m_farPlane));
}
std::optional<DrawableRayHit> CastRay(const Math::Vector2i& xy) const override
{
throw std::runtime_error("Not implemented yet");
}
[[nodiscard]] bool IsOrtho() const override { return true; }
};
}