mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-07 09:33:51 +00:00
fix(wob): scrub NaN/inf doodad transforms at save time
Same scrub now applied symmetrically on the save side so a corrupted in-memory doodad transform can't be persisted into a WOB and then have to be cleaned up on every subsequent load.
This commit is contained in:
parent
5d78cbb81d
commit
b8e2d08b17
1 changed files with 9 additions and 3 deletions
|
|
@ -267,9 +267,15 @@ bool WoweeBuildingLoader::save(const WoweeBuilding& bld, const std::string& base
|
|||
|
||||
for (const auto& dp : bld.doodads) {
|
||||
writeStr(dp.modelPath);
|
||||
f.write(reinterpret_cast<const char*>(&dp.position), 12);
|
||||
f.write(reinterpret_cast<const char*>(&dp.rotation), 12);
|
||||
f.write(reinterpret_cast<const char*>(&dp.scale), 4);
|
||||
glm::vec3 pos = dp.position, rot = dp.rotation;
|
||||
for (int k = 0; k < 3; k++) {
|
||||
if (!std::isfinite(pos[k])) pos[k] = 0.0f;
|
||||
if (!std::isfinite(rot[k])) rot[k] = 0.0f;
|
||||
}
|
||||
float scale = (std::isfinite(dp.scale) && dp.scale > 0.0001f) ? dp.scale : 1.0f;
|
||||
f.write(reinterpret_cast<const char*>(&pos), 12);
|
||||
f.write(reinterpret_cast<const char*>(&rot), 12);
|
||||
f.write(reinterpret_cast<const char*>(&scale), 4);
|
||||
}
|
||||
|
||||
LOG_INFO("WOB saved: ", basePath, ".wob (", gc, " groups)");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue