diff --git a/flake.lock b/flake.lock index 4d1396c..05beee3 100644 --- a/flake.lock +++ b/flake.lock @@ -53,11 +53,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1730853263, - "narHash": "sha256-Cnp2zjzaA4bYUOhM/xo9GxhgOgTHn+qNbSGu4su8RaQ=", + "lastModified": 1730949988, + "narHash": "sha256-7AcEfVr+td+fRqFWZzqn1XbzhEYvotOAfyWLgVSoY70=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "5d4d64e923ce570996c089d768710f61bde0b9d3", + "rev": "5ed245d62a75ca9fc939b6fffe72af0e22ab8260", "type": "github" }, "original": { diff --git a/src/main.cpp b/src/main.cpp index 50340ea..dea1277 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -41,6 +41,9 @@ VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE constexpr i32 WIDTH = 800; constexpr i32 HEIGHT = 600; +// CAMERA_SPEED of camera movement +constexpr f64 CAMERA_SPEED = 1.0; + // Maximum number of frames that can be processed concurrently constexpr i32 MAX_FRAMES_IN_FLIGHT = 2; @@ -246,22 +249,23 @@ class VulkanApp { glm::dvec3 position; glm::dvec3 up; glm::dvec3 look_at; - f64 speed {1.0}; Camera() : position(2.0, 2.0, 2.0), up(0.0, 0.0, 1.0), look_at(0.0) {} + [[nodiscard]] fn getPosition() const -> glm::dvec3 { return position; } + [[nodiscard]] fn getViewMatrix() const -> glm::mat4 { return glm::lookAt(position, look_at, up); } - fn moveForward(f64 deltaTime) -> void { position += (look_at - position) * speed * deltaTime; } + fn moveForward(f64 deltaTime) -> void { position += (look_at - position) * CAMERA_SPEED * deltaTime; } - fn moveBackward(f64 deltaTime) -> void { position -= (look_at - position) * speed * deltaTime; } + fn moveBackward(f64 deltaTime) -> void { position -= (look_at - position) * CAMERA_SPEED * deltaTime; } fn moveLeft(f64 deltaTime) -> void { - position -= glm::normalize(glm::cross((look_at - position), up)) * speed * deltaTime; + position -= glm::normalize(glm::cross((look_at - position), up)) * CAMERA_SPEED * deltaTime; } fn moveRight(f64 deltaTime) -> void { - position += glm::normalize(glm::cross((look_at - position), up)) * speed * deltaTime; + position += glm::normalize(glm::cross((look_at - position), up)) * CAMERA_SPEED * deltaTime; } }; @@ -274,6 +278,10 @@ class VulkanApp { camera.moveBackward(deltaTime); if (window.getKey(vkfw::Key::eD) == vkfw::eTrue) camera.moveRight(deltaTime); + + fmt::println( + "New position: {} {} {}", camera.getPosition()[0], camera.getPosition()[1], camera.getPosition()[2] + ); } /**