diff options
author | RunitaiLinden <davep@lindenlab.com> | 2024-05-30 13:42:27 -0500 |
---|---|---|
committer | RunitaiLinden <davep@lindenlab.com> | 2024-05-30 13:42:27 -0500 |
commit | e279aae51a0f43cba0e284da4c0ea7c168316ca1 (patch) | |
tree | 27ec179553565e3f452c9dc45b49c4ad7fa91fe3 /indra | |
parent | 15fd13f83036ff781160957a21bb2d59771044bc (diff) |
#1597 Fix for some GLTF transforms not loading properly.
Also incidental fix for unreachable code error.
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/gltf/accessor.cpp | 6 | ||||
-rw-r--r-- | indra/newview/gltf/asset.cpp | 5 | ||||
-rw-r--r-- | indra/newview/gltf/buffer_util.h | 78 | ||||
-rw-r--r-- | indra/newview/llsidepaneltaskinfo.cpp | 1 |
4 files changed, 42 insertions, 48 deletions
diff --git a/indra/newview/gltf/accessor.cpp b/indra/newview/gltf/accessor.cpp index 5f4e3ca3a8..9f1cb0c1cd 100644 --- a/indra/newview/gltf/accessor.cpp +++ b/indra/newview/gltf/accessor.cpp @@ -124,8 +124,10 @@ void Buffer::erase(Asset& asset, S32 offset, S32 length) bool Buffer::prep(Asset& asset) { - // PRECONDITION: mByteLength must not be 0 - llassert(mByteLength != 0); + if (mByteLength == 0) + { + return false; + } LLUUID id; if (mUri.size() == UUID_STR_SIZE && LLUUID::parseUUID(mUri, &id) && id.notNull()) diff --git a/indra/newview/gltf/asset.cpp b/indra/newview/gltf/asset.cpp index 7870eb28b0..7d379c2528 100644 --- a/indra/newview/gltf/asset.cpp +++ b/indra/newview/gltf/asset.cpp @@ -300,8 +300,8 @@ void Node::serialize(object& dst) const { write(mName, "name", dst); write(mMatrix, "matrix", dst, glm::identity<mat4>()); - write(mRotation, "rotation", dst); - write(mTranslation, "translation", dst); + write(mRotation, "rotation", dst, glm::identity<quat>()); + write(mTranslation, "translation", dst, glm::vec3(0.f, 0.f, 0.f)); write(mScale, "scale", dst, vec3(1.f,1.f,1.f)); write(mChildren, "children", dst); write(mMesh, "mesh", dst, INVALID_INDEX); @@ -312,7 +312,6 @@ const Node& Node::operator=(const Value& src) { copy(src, "name", mName); mMatrixValid = copy(src, "matrix", mMatrix); - copy(src, "rotation", mRotation); copy(src, "translation", mTranslation); copy(src, "scale", mScale); diff --git a/indra/newview/gltf/buffer_util.h b/indra/newview/gltf/buffer_util.h index 72e69c9599..548d4ec5d6 100644 --- a/indra/newview/gltf/buffer_util.h +++ b/indra/newview/gltf/buffer_util.h @@ -610,14 +610,17 @@ namespace LL const boost::json::array& arr = src.as_array(); if (arr.size() == 4) { - if (arr[0].is_double() && - arr[1].is_double() && - arr[2].is_double() && - arr[3].is_double()) - { - dst = vec4(arr[0].get_double(), arr[1].get_double(), arr[2].get_double(), arr[3].get_double()); - return true; - } + vec4 v; + std::error_code ec; + + v.x = arr[0].to_number<F32>(ec); if (ec) return false; + v.y = arr[1].to_number<F32>(ec); if (ec) return false; + v.z = arr[2].to_number<F32>(ec); if (ec) return false; + v.w = arr[3].to_number<F32>(ec); if (ec) return false; + + dst = v; + + return true; } } return false; @@ -645,17 +648,13 @@ namespace LL const boost::json::array& arr = src.as_array(); if (arr.size() == 4) { - if (arr[0].is_double() && - arr[1].is_double() && - arr[2].is_double() && - arr[3].is_double()) - { - dst.x = arr[0].get_double(); - dst.y = arr[1].get_double(); - dst.z = arr[2].get_double(); - dst.w = arr[3].get_double(); - return true; - } + std::error_code ec; + dst.x = arr[0].to_number<F32>(ec); if (ec) return false; + dst.y = arr[1].to_number<F32>(ec); if (ec) return false; + dst.z = arr[2].to_number<F32>(ec); if (ec) return false; + dst.w = arr[3].to_number<F32>(ec); if (ec) return false; + + return true; } } return false; @@ -684,12 +683,13 @@ namespace LL const boost::json::array& arr = src.as_array(); if (arr.size() == 3) { - if (arr[0].is_double() && - arr[1].is_double() && - arr[2].is_double()) - { - dst = vec3(arr[0].get_double(), arr[1].get_double(), arr[2].get_double()); - } + std::error_code ec; + vec3 t; + t.x = arr[0].to_number<F32>(ec); if (ec) return false; + t.y = arr[1].to_number<F32>(ec); if (ec) return false; + t.z = arr[2].to_number<F32>(ec); if (ec) return false; + + dst = t; return true; } } @@ -731,12 +731,10 @@ namespace LL template<> inline bool copy(const Value& src, F32& dst) { - if (src.is_double()) - { - dst = src.get_double(); - return true; - } - return false; + std::error_code ec; + F32 t = src.to_number<F32>(ec); if (ec) return false; + dst = t; + return true; } template<> @@ -770,12 +768,10 @@ namespace LL template<> inline bool copy(const Value& src, F64& dst) { - if (src.is_double()) - { - dst = src.get_double(); - return true; - } - return false; + std::error_code ec; + F64 t = src.to_number<F64>(ec); if (ec) return false; + dst = t; + return true; } template<> @@ -860,11 +856,9 @@ namespace LL for (U32 i = 0; i < arr.size(); ++i) { - if (arr[i].is_double()) - { - p[i] = arr[i].get_double(); - } - else + std::error_code ec; + p[i] = arr[i].to_number<F32>(ec); + if (ec) { return false; } diff --git a/indra/newview/llsidepaneltaskinfo.cpp b/indra/newview/llsidepaneltaskinfo.cpp index 4ce45608df..c619b63ef5 100644 --- a/indra/newview/llsidepaneltaskinfo.cpp +++ b/indra/newview/llsidepaneltaskinfo.cpp @@ -97,7 +97,6 @@ static std::string click_action_to_string_value(U8 click_action) default: return "Touch"; } - return "Touch"; } // Default constructor |