mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-07 01:23:52 +00:00
fix(wob): fromWMO sanitizes vertex floats during conversion
Sanitize at conversion time too, not just on WoB load. Avoids the case where a corrupt source WMO (extracted from a partially-decoded MPQ) silently poisons the WOB the editor exports — and the WOB load-time guard from the previous commit only catches it on later reload, not during the first conversion. Also catches the boundRadius calculation which would otherwise inherit a NaN from one bad vertex.
This commit is contained in:
parent
2b5f69187e
commit
7acde76025
1 changed files with 14 additions and 2 deletions
|
|
@ -374,10 +374,22 @@ WoweeBuilding WoweeBuildingLoader::fromWMO(const WMOModel& wmo, const std::strin
|
|||
wv.normal = v.normal;
|
||||
wv.texCoord = v.texCoord;
|
||||
wv.color = v.color;
|
||||
// Sanitize on conversion so a corrupt source WMO doesn't poison
|
||||
// the WOB and then surprise us on later reload.
|
||||
if (!std::isfinite(wv.position.x)) wv.position.x = 0.0f;
|
||||
if (!std::isfinite(wv.position.y)) wv.position.y = 0.0f;
|
||||
if (!std::isfinite(wv.position.z)) wv.position.z = 0.0f;
|
||||
if (!std::isfinite(wv.normal.x)) wv.normal.x = 0.0f;
|
||||
if (!std::isfinite(wv.normal.y)) wv.normal.y = 0.0f;
|
||||
if (!std::isfinite(wv.normal.z)) wv.normal.z = 1.0f;
|
||||
if (!std::isfinite(wv.texCoord.x)) wv.texCoord.x = 0.0f;
|
||||
if (!std::isfinite(wv.texCoord.y)) wv.texCoord.y = 0.0f;
|
||||
for (int c = 0; c < 4; c++)
|
||||
if (!std::isfinite(wv.color[c])) wv.color[c] = 1.0f;
|
||||
wobGroup.vertices.push_back(wv);
|
||||
|
||||
float d = glm::length(v.position);
|
||||
if (d > maxDist) maxDist = d;
|
||||
float d = glm::length(wv.position);
|
||||
if (std::isfinite(d) && d > maxDist) maxDist = d;
|
||||
}
|
||||
|
||||
wobGroup.indices.reserve(grp.indices.size());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue