fix(painter): reject NaN brush center / non-positive radius

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.
This commit is contained in:
Kelsi 2026-05-06 07:37:11 -07:00
parent 891bb711a0
commit 9207d54f20

View file

@ -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];