mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-07 01:23:52 +00:00
fix(stamp): scrub NaN samples at save time
Symmetric with the load-side scrub. Without this, a stamp captured on terrain that had a NaN mid-edit would throw on serialize and abort the whole save.
This commit is contained in:
parent
ebb7e0f831
commit
4babaebf86
1 changed files with 4 additions and 1 deletions
|
|
@ -1528,9 +1528,12 @@ bool TerrainEditor::saveStamp(const std::string& path) const {
|
|||
nlohmann::json j;
|
||||
j["format"] = "wowee-stamp-1.0";
|
||||
j["vertexCount"] = stampData_.size();
|
||||
// Scrub NaN samples on save — nlohmann::json throws on non-finite
|
||||
// serialization, which would abort the entire save.
|
||||
auto san = [](float x) { return std::isfinite(x) ? x : 0.0f; };
|
||||
nlohmann::json verts = nlohmann::json::array();
|
||||
for (const auto& sv : stampData_)
|
||||
verts.push_back({sv.dx, sv.dy, sv.height});
|
||||
verts.push_back({san(sv.dx), san(sv.dy), san(sv.height)});
|
||||
j["vertices"] = verts;
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue