mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-07 01:23:52 +00:00
fix(viewport): defensive NaN checks in patrol path ribbon
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.
This commit is contained in:
parent
ba017193db
commit
493cb68ddc
1 changed files with 5 additions and 1 deletions
|
|
@ -500,9 +500,13 @@ void EditorViewport::setPatrolPath(const std::vector<glm::vec3>& 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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue