changed return type

This commit is contained in:
2024-09-03 22:19:17 +03:00
parent 05addefd63
commit 7bb8dcbb8c
2 changed files with 3 additions and 3 deletions

View File

@@ -30,7 +30,7 @@ namespace omath::projection
[[nodiscard]] Matrix GetViewMatrix() const; [[nodiscard]] Matrix GetViewMatrix() const;
[[nodiscard]] std::expected<Vector3, Error> WorldToScreen(const Vector3& worldPosition) const; [[nodiscard]] std::expected<Vector2, Error> WorldToScreen(const Vector3& worldPosition) const;
ViewPort m_viewPort{}; ViewPort m_viewPort{};
float m_fieldOfView; float m_fieldOfView;

View File

@@ -30,7 +30,7 @@ namespace omath::projection
return Matrix::TranslationMatrix(-m_origin) * Matrix::OrientationMatrix(forward, right, up); return Matrix::TranslationMatrix(-m_origin) * Matrix::OrientationMatrix(forward, right, up);
} }
std::expected<Vector3, Error> Camera::WorldToScreen(const Vector3 &worldPosition) const std::expected<Vector2, Error> Camera::WorldToScreen(const Vector3 &worldPosition) const
{ {
const auto posVecAsMatrix = Matrix({{worldPosition.x, worldPosition.y, worldPosition.z, 1.f}}); const auto posVecAsMatrix = Matrix({{worldPosition.x, worldPosition.y, worldPosition.z, 1.f}});
@@ -51,6 +51,6 @@ namespace omath::projection
projected *= Matrix::ToScreenMatrix(m_viewPort.m_width, m_viewPort.m_height); projected *= Matrix::ToScreenMatrix(m_viewPort.m_width, m_viewPort.m_height);
return Vector3{projected.At(0, 0), projected.At(0, 1), projected.At(0, 2)}; return Vector2{projected.At(0, 0), projected.At(0, 1)};
} }
} }