mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-07 01:23:52 +00:00
fix(wob): clamp doodad scale to 1.0 when loaded value is 0/NaN/inf
Without this guard, a corrupted or partially-written WoB with scale=0 would render the doodad at zero size (invisible) and a NaN/inf would crash the renderer's matrix math. Now defaults to 1.0 for any non- finite or near-zero value.
This commit is contained in:
parent
70e48640d8
commit
199f18cdac
1 changed files with 5 additions and 0 deletions
|
|
@ -5,6 +5,7 @@
|
|||
#include <fstream>
|
||||
#include <filesystem>
|
||||
#include <cstring>
|
||||
#include <cmath>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace wowee {
|
||||
|
|
@ -105,6 +106,10 @@ WoweeBuilding WoweeBuildingLoader::load(const std::string& basePath) {
|
|||
f.read(reinterpret_cast<char*>(&dp.position), 12);
|
||||
f.read(reinterpret_cast<char*>(&dp.rotation), 12);
|
||||
f.read(reinterpret_cast<char*>(&dp.scale), 4);
|
||||
// Guard against corrupted scale (older WoBs that hadn't initialized
|
||||
// the field, or NaNs from a partial write). The renderer would
|
||||
// collapse the doodad to a point with scale 0.
|
||||
if (!std::isfinite(dp.scale) || dp.scale <= 0.0001f) dp.scale = 1.0f;
|
||||
bld.doodads.push_back(dp);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue