Compare commits

...

2 commits

Author SHA1 Message Date
Mars 769dd30fdd Merge pull request 'fix: camera movement' (#1) from avery/vulkan-test:vk-hpp into vk-hpp
Reviewed-on: #1
2024-11-06 22:28:07 -05:00
avery 9b468e5c8a
fix camera movement 2024-11-07 02:11:30 +00:00
3 changed files with 10 additions and 10 deletions

View file

@ -244,24 +244,24 @@ class VulkanApp {
struct Camera { struct Camera {
glm::dvec3 position; glm::dvec3 position;
glm::dvec3 front;
glm::dvec3 up; glm::dvec3 up;
f64 speed {}; glm::dvec3 look_at;
f64 speed {1.0};
Camera() : position(2.0, 2.0, 2.0), front(0.0, 0.0, 0.0), up(0.0, 0.0, 1.0) {} Camera() : position(2.0, 2.0, 2.0), up(0.0, 0.0, 1.0), look_at(0.0) {}
[[nodiscard]] fn getViewMatrix() const -> glm::mat4 { return glm::lookAt(position, front, up); } [[nodiscard]] fn getViewMatrix() const -> glm::mat4 { return glm::lookAt(position, look_at, up); }
fn moveForward(f64 deltaTime) -> void { position += speed * front * deltaTime; } fn moveForward(f64 deltaTime) -> void { position += (look_at - position) * speed * deltaTime; }
fn moveBackward(f64 deltaTime) -> void { position -= speed * front * deltaTime; } fn moveBackward(f64 deltaTime) -> void { position -= (look_at - position) * speed * deltaTime; }
fn moveLeft(f64 deltaTime) -> void { fn moveLeft(f64 deltaTime) -> void {
position -= glm::normalize(glm::cross(front, up)) * speed * deltaTime; position -= glm::normalize(glm::cross((look_at - position), up)) * speed * deltaTime;
} }
fn moveRight(f64 deltaTime) -> void { fn moveRight(f64 deltaTime) -> void {
position += glm::normalize(glm::cross(front, up)) * speed * deltaTime; position += glm::normalize(glm::cross((look_at - position), up)) * speed * deltaTime;
} }
}; };

View file

@ -50,7 +50,7 @@ class ShaderCompiler {
throw runtime_error("Shader compilation failed for: " + shaderName); throw runtime_error("Shader compilation failed for: " + shaderName);
// Cache the compiled SPIR-V binary // Cache the compiled SPIR-V binary
saveCompiledShader(spirvCode, cacheFile); saveCompiledShader(spirvCode, cacheFile.string());
return spirvCode; return spirvCode;
} }

View file

@ -19,7 +19,7 @@ namespace stb {
* *
* @param path The filesystem path to the image file to load. * @param path The filesystem path to the image file to load.
*/ */
UniqueImage(const std::filesystem::path& path) { load(path.c_str()); } UniqueImage(const std::filesystem::path& path) { load(path.string().c_str()); }
// Deleted copy constructor to prevent copying. // Deleted copy constructor to prevent copying.
UniqueImage(const UniqueImage&) = delete; UniqueImage(const UniqueImage&) = delete;