fix camera move

This commit is contained in:
quagsirus 2024-11-07 02:04:12 +00:00
parent 450c92ec55
commit 6ccfa18df8
No known key found for this signature in database
3 changed files with 9 additions and 9 deletions

View file

@ -244,24 +244,24 @@ class VulkanApp {
struct Camera {
glm::dvec3 position;
glm::dvec3 front;
glm::dvec3 up;
glm::dvec3 look_at;
f64 speed {};
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) * deltaTime; }
fn moveBackward(f64 deltaTime) -> void { position -= speed * front * deltaTime; }
fn moveBackward(f64 deltaTime) -> void { position -= (look_at - position) * deltaTime; }
fn moveLeft(f64 deltaTime) -> void {
position -= glm::normalize(glm::cross(front, up)) * speed * deltaTime;
position -= glm::normalize(glm::cross((look_at - position), up)) * deltaTime;
}
fn moveRight(f64 deltaTime) -> void {
position += glm::normalize(glm::cross(front, up)) * speed * deltaTime;
position += glm::normalize(glm::cross((look_at - position), up)) * deltaTime;
}
};

View file

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

View file

@ -19,7 +19,7 @@ namespace stb {
*
* @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.
UniqueImage(const UniqueImage&) = delete;