forked from pupbrained/vulkan-test
fix camera movement
This commit is contained in:
parent
450c92ec55
commit
9b468e5c8a
16
src/main.cpp
16
src/main.cpp
|
@ -244,24 +244,24 @@ class VulkanApp {
|
|||
|
||||
struct Camera {
|
||||
glm::dvec3 position;
|
||||
glm::dvec3 front;
|
||||
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 {
|
||||
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 {
|
||||
position += glm::normalize(glm::cross(front, up)) * speed * deltaTime;
|
||||
position += glm::normalize(glm::cross((look_at - position), up)) * speed * deltaTime;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue