From 17ca42b70b1666b9b74fe49d5ca5312e3ffec1cc Mon Sep 17 00:00:00 2001 From: Kelsi Date: Wed, 6 May 2026 10:12:45 -0700 Subject: [PATCH] fix(camera): validate setSpeed input against wheel-clamp range 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. --- tools/editor/editor_camera.hpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/editor/editor_camera.hpp b/tools/editor/editor_camera.hpp index 11c8b066..0911fafb 100644 --- a/tools/editor/editor_camera.hpp +++ b/tools/editor/editor_camera.hpp @@ -3,6 +3,7 @@ #include "rendering/camera.hpp" #include #include +#include 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);