fix mouse picking

This commit is contained in:
2023-06-03 20:43:40 +02:00
parent cb5f5a4cf8
commit 193e4db651
6 changed files with 67 additions and 65 deletions

View File

@@ -9,6 +9,15 @@
namespace td {
namespace render {
struct Camera {
Mat4f viewMatrix;
Mat4f projectionMatrix;
Mat4f InvViewMatrix;
Mat4f InvProjectionMatrix;
Vec3f CamPos;
};
class Renderer {
public:
static constexpr float m_AnimationSpeed = 2.0f;
@@ -24,9 +33,7 @@ private:
Vec3f m_BackgroundColor;
bool m_IsometricView = true;
float m_IsometricShade = m_IsometricView;
Vec2f m_CamPos{};
Camera m_Camera {};
public:
Renderer();
~Renderer();
@@ -41,15 +48,12 @@ public:
void SetZoom(float zoom);
void SetCamMovement(const Vec2f& mov);
void SetCamPos(const Vec2f& newPos);
void SetIsometricView(bool isometric); // false = 2D true = Isometric
void SetCamPos(const Vec3f& newPos);
void SetBackgroundColor(const Vec3f& color) { m_BackgroundColor = color; }
Vec2f GetCursorWorldPos(const Vec2f& cursorPos, float aspectRatio, float zoom, float windowWidth, float windowHeight);
Vec2f GetCursorWorldPos(const Vec2f& cursorPos, float windowWidth, float windowHeight);
private:
void UpdateIsometricView();
void UpdateIsometricFade();
void InitShaders();
};