mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-07 01:23:52 +00:00
Some checks are pending
Build / Build (arm64) (push) Waiting to run
Build / Build (x86-64) (push) Waiting to run
Build / Build (macOS arm64) (push) Waiting to run
Build / Build (windows-arm64) (push) Waiting to run
Build / Build (windows-x86-64) (push) Waiting to run
Security / CodeQL (C/C++) (push) Waiting to run
Security / Semgrep (push) Waiting to run
Security / Sanitizer Build (ASan/UBSan) (push) Waiting to run
EditorCamera::setSpeed accepted any float, including NaN/inf and values outside the wheel-zoom clamp range [10, 2000]. NaN speed would propagate into the per-tick position update (NaN * dt = NaN) and corrupt the camera view matrix. Match the wheel clamp so external setters can't bypass the UI's bounds.
47 lines
1.4 KiB
C++
47 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include "rendering/camera.hpp"
|
|
#include <SDL2/SDL.h>
|
|
#include <glm/glm.hpp>
|
|
#include <cmath>
|
|
|
|
namespace wowee {
|
|
namespace editor {
|
|
|
|
class EditorCamera {
|
|
public:
|
|
EditorCamera();
|
|
|
|
void update(float deltaTime);
|
|
void processMouseMotion(int dx, int dy);
|
|
void processMouseWheel(float delta, bool shiftHeld);
|
|
void processKeyEvent(const SDL_KeyboardEvent& event);
|
|
void processMouseButton(const SDL_MouseButtonEvent& event);
|
|
void processMiddleMouseMotion(int dx, int dy, const glm::vec3& pivotPoint);
|
|
|
|
rendering::Camera& getCamera() { return camera_; }
|
|
const rendering::Camera& getCamera() const { return camera_; }
|
|
|
|
float getSpeed() const { return speed_; }
|
|
void setSpeed(float s) {
|
|
// Match the wheel-zoom clamp range. NaN/inf would propagate
|
|
// into camera position via update(); the cap also matches what
|
|
// the user can set via the wheel UI.
|
|
if (std::isfinite(s) && s >= 10.0f && s <= 2000.0f) speed_ = s;
|
|
}
|
|
void setPosition(const glm::vec3& pos);
|
|
void setYawPitch(float yaw, float pitch);
|
|
|
|
private:
|
|
rendering::Camera camera_;
|
|
float speed_ = 100.0f;
|
|
float yaw_ = 0.0f;
|
|
float pitch_ = 0.0f;
|
|
bool keyW_ = false, keyA_ = false, keyS_ = false, keyD_ = false;
|
|
bool keyQ_ = false, keyE_ = false, keyShift_ = false;
|
|
bool rightMouseDown_ = false;
|
|
bool middleMouseDown_ = false;
|
|
};
|
|
|
|
} // namespace editor
|
|
} // namespace wowee
|