From 493cb68ddc26b0fb2c77a73be7f2eb0e1f73d9b8 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Wed, 6 May 2026 07:57:54 -0700 Subject: [PATCH] fix(viewport): defensive NaN checks in patrol path ribbon MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit len < 0.001f returns false for NaN — same short-circuit class of bug as elsewhere. Reject non-finite endpoints upfront and double- check the computed length before dividing. --- tools/editor/editor_viewport.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/editor/editor_viewport.cpp b/tools/editor/editor_viewport.cpp index c2d4be9d..f84c628f 100644 --- a/tools/editor/editor_viewport.cpp +++ b/tools/editor/editor_viewport.cpp @@ -500,9 +500,13 @@ void EditorViewport::setPatrolPath(const std::vector& points, float w verts.reserve(points.size() * 24); auto addRibbon = [&](const glm::vec3& a, const glm::vec3& b, float r, float g, float bl, float al) { + // NaN endpoints would short-circuit the len < 0.001f check (NaN + // comparisons return false) and propagate NaN through dir. + if (!std::isfinite(a.x) || !std::isfinite(a.y) || !std::isfinite(a.z) || + !std::isfinite(b.x) || !std::isfinite(b.y) || !std::isfinite(b.z)) return; glm::vec2 dir = glm::vec2(b.x - a.x, b.y - a.y); float len = glm::length(dir); - if (len < 0.001f) return; + if (!std::isfinite(len) || len < 0.001f) return; dir /= len; glm::vec2 perp(-dir.y, dir.x); float hw = width * 0.5f;