mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-07 01:23:52 +00:00
fix(editor): NaN guards on flattenAroundSelected and createHill
Same NaN-comparison short-circuit pattern: dist >= radius is false when dist is NaN, so the loop body would run for every vertex and write garbage heights / bend the terrain unbounded.
This commit is contained in:
parent
12bcd0ef8c
commit
f484b742db
2 changed files with 6 additions and 0 deletions
|
|
@ -1703,6 +1703,9 @@ void EditorApp::snapSelectedToGround() {
|
|||
void EditorApp::flattenAroundSelected(float radius) {
|
||||
auto* sel = objectPlacer_.getSelected();
|
||||
if (!sel || !terrain_.isLoaded()) return;
|
||||
if (!std::isfinite(radius) || radius <= 0.0f ||
|
||||
!std::isfinite(sel->position.x) || !std::isfinite(sel->position.y) ||
|
||||
!std::isfinite(sel->position.z)) return;
|
||||
|
||||
terrainEditor_.beginGeneratorUndo();
|
||||
float targetHeight = sel->position.z;
|
||||
|
|
|
|||
|
|
@ -905,6 +905,9 @@ void TerrainEditor::createMesa(const glm::vec3& center, float radius, float heig
|
|||
|
||||
void TerrainEditor::createHill(const glm::vec3& center, float radius, float height) {
|
||||
if (!terrain_) return;
|
||||
if (!std::isfinite(center.x) || !std::isfinite(center.y) ||
|
||||
!std::isfinite(radius) || radius <= 0.0f ||
|
||||
!std::isfinite(height)) return;
|
||||
recordGeneratorUndo();
|
||||
for (int ci = 0; ci < 256; ci++) {
|
||||
auto& chunk = terrain_->chunks[ci];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue