pathfinding_demo/cpp/src/camera.hpp
2025-10-12 16:19:38 +02:00

36 lines
826 B
C++

#pragma once
#include "math.hpp"
class Camera
{
public:
void Pan(const WorldPos& delta);
void Zoom(float delta);
WorldPos GetPan() const { return m_Pan; }
float GetZoom() const { return m_Zoom; }
WindowPos WorldToWindow(WorldPos) const;
WorldPos WindowToWorld(WindowPos) const;
WindowSize WorldToWindowSize(WorldSize) const;
WorldSize WindowToWorldSize(WindowSize) const;
template <typename T>
requires std::floating_point<T>
T WindowToWorldSize(T window_size) const {
return window_size / static_cast<T>(m_Zoom);
}
template <typename T>
requires std::floating_point<T>
T WorldToWindowSize(T world_size) const {
return world_size * static_cast<T>(m_Zoom);
}
private:
// TODO this should be replaced with a matrix
float m_Zoom = 1.0f;
WorldPos m_Pan;
};