From 130aa34d735289e411d13e4d5011fed98abbab8e Mon Sep 17 00:00:00 2001 From: Kelsi Date: Wed, 6 May 2026 07:53:07 -0700 Subject: [PATCH] fix(viewport): hide path preview on zero-length input start == end would call glm::normalize on a zero vector, producing NaN dir/perp and NaN ribbon vertex positions. Vulkan would either drop the draw silently or trip a validation error. Hide the preview when the segment is degenerate. --- tools/editor/editor_viewport.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/editor/editor_viewport.cpp b/tools/editor/editor_viewport.cpp index 931b4c4c..8bac465c 100644 --- a/tools/editor/editor_viewport.cpp +++ b/tools/editor/editor_viewport.cpp @@ -436,7 +436,13 @@ void EditorViewport::setPathPreview(const glm::vec3& start, const glm::vec3& end struct BV { float pos[3]; float color[4]; }; std::vector verts; - glm::vec2 dir = glm::normalize(glm::vec2(end.x - start.x, end.y - start.y)); + glm::vec2 delta(end.x - start.x, end.y - start.y); + float dlen = glm::length(delta); + // start == end would produce NaN dir/perp from glm::normalize and then + // NaN positions in the path ribbon — Vulkan would either drop the draw + // or crash on validation. Hide the preview instead. + if (dlen < 1e-4f) { pathVisible_ = false; return; } + glm::vec2 dir = delta / dlen; glm::vec2 perp(-dir.y, dir.x); float z0 = start.z + 2.0f; float z1 = end.z + 2.0f;