fix(camera): validate setSpeed input against wheel-clamp range
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.
This commit is contained in:
Kelsi 2026-05-06 10:12:45 -07:00
parent e02f2baf9d
commit 17ca42b70b

View file

@ -3,6 +3,7 @@
#include "rendering/camera.hpp"
#include <SDL2/SDL.h>
#include <glm/glm.hpp>
#include <cmath>
namespace wowee {
namespace editor {
@ -22,7 +23,12 @@ public:
const rendering::Camera& getCamera() const { return camera_; }
float getSpeed() const { return speed_; }
void setSpeed(float s) { speed_ = s; }
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);