Cope with degenerate node T/R/S.
It's technically valid for e.g. scale to have a zero dimension, which in turn wreaks havoc on the rotation quaternion we get from the FBX SDK. The simplest solution is to just leave any T/R/S vector out of the glTF if it has any NaN component.
This commit is contained in:
parent
a3989249f3
commit
54c3b04fce
|
@ -52,12 +52,18 @@ void NodeData::SetCamera(uint32_t cameraIndex)
|
||||||
|
|
||||||
json NodeData::serialize() const
|
json NodeData::serialize() const
|
||||||
{
|
{
|
||||||
json result = {
|
json result = { { "name", name } };
|
||||||
{ "name", name },
|
|
||||||
{ "translation", toStdVec(translation) },
|
// if any of the T/R/S have NaN components, just leave them out of the glTF
|
||||||
{ "rotation", toStdVec(rotation) },
|
auto maybeAdd = [&](std::string key, std::vector<float> vec) {
|
||||||
{ "scale", toStdVec(scale) }
|
if (std::none_of(vec.begin(), vec.end(), [&](float n) { return isnan(n); })) {
|
||||||
|
result[key] = vec;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
maybeAdd("translation", toStdVec(translation));
|
||||||
|
maybeAdd("rotation", toStdVec(rotation));
|
||||||
|
maybeAdd("scale", toStdVec(scale));
|
||||||
|
|
||||||
if (!children.empty()) {
|
if (!children.empty()) {
|
||||||
result["children"] = children;
|
result["children"] = children;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue