mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-07 01:23:52 +00:00
fix(brush): reject NaN/non-positive brush settings before sculpt apply
Same NaN-comparison short-circuit bug as the texture painter — a brush with a NaN cursor position would mark every vertex in every 'affected' chunk as full influence and silently rewrite huge swaths of terrain. Reject upfront in applyBrush.
This commit is contained in:
parent
9207d54f20
commit
bd6e5fe3de
1 changed files with 10 additions and 1 deletions
|
|
@ -289,8 +289,17 @@ void TerrainEditor::commitGeneratorUndo() {
|
|||
|
||||
void TerrainEditor::applyBrush(float deltaTime) {
|
||||
if (!terrain_ || !brush_.isActive()) return;
|
||||
// Reject NaN brush position / non-positive radius / NaN strength.
|
||||
// dist = length(pos - center) goes NaN if center has NaN, and
|
||||
// brush_.getInfluence(NaN) returns full strength on every vertex
|
||||
// because NaN comparisons always return false.
|
||||
const auto& bs = brush_.settings();
|
||||
auto bp = brush_.getPosition();
|
||||
if (!std::isfinite(bp.x) || !std::isfinite(bp.y) || !std::isfinite(bp.z) ||
|
||||
!std::isfinite(bs.radius) || bs.radius <= 0.0f ||
|
||||
!std::isfinite(bs.strength)) return;
|
||||
|
||||
switch (brush_.settings().mode) {
|
||||
switch (bs.mode) {
|
||||
case BrushMode::Raise: applyRaise(deltaTime); break;
|
||||
case BrushMode::Lower: applyRaise(deltaTime); break;
|
||||
case BrushMode::Smooth: applySmooth(deltaTime); break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue