From 9207d54f2024754256bff090ba5899ba2ead3f51 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Wed, 6 May 2026 07:37:11 -0700 Subject: [PATCH] fix(painter): reject NaN brush center / non-positive radius MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit NaN comparisons return false, so the dist >= radius early-out would never fire and the falloff path would skip its inner check too — the brush would paint full strength on every texel in the chunk. Reject upfront. --- tools/editor/texture_painter.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/editor/texture_painter.cpp b/tools/editor/texture_painter.cpp index eb80f55d..5233623a 100644 --- a/tools/editor/texture_painter.cpp +++ b/tools/editor/texture_painter.cpp @@ -82,6 +82,12 @@ glm::vec2 TexturePainter::worldToChunkUV(int chunkIdx, const glm::vec3& worldPos void TexturePainter::modifyAlpha(int chunkIdx, int layerIdx, const glm::vec3& center, float radius, float strength, float falloff, bool erasing) { + // Reject NaN center / non-positive radius up front. Without this, every + // dist comparison below becomes NaN-vs-finite (which returns false), so + // the falloff path falls through and paints full strength on every + // texel in the chunk — the opposite of what was asked. + if (!std::isfinite(center.x) || !std::isfinite(center.y) || + !std::isfinite(radius) || radius <= 0.0f) return; auto& chunk = terrain_->chunks[chunkIdx]; auto& layer = chunk.layers[layerIdx];