#1597 Fix for some GLTF transforms not loading properly.

Also incidental fix for unreachable code error.
master
RunitaiLinden 2024-05-30 13:42:27 -05:00
parent 15fd13f830
commit e279aae51a
4 changed files with 42 additions and 48 deletions

View File

@ -124,8 +124,10 @@ void Buffer::erase(Asset& asset, S32 offset, S32 length)
bool Buffer::prep(Asset& asset) bool Buffer::prep(Asset& asset)
{ {
// PRECONDITION: mByteLength must not be 0 if (mByteLength == 0)
llassert(mByteLength != 0); {
return false;
}
LLUUID id; LLUUID id;
if (mUri.size() == UUID_STR_SIZE && LLUUID::parseUUID(mUri, &id) && id.notNull()) if (mUri.size() == UUID_STR_SIZE && LLUUID::parseUUID(mUri, &id) && id.notNull())

View File

@ -300,8 +300,8 @@ void Node::serialize(object& dst) const
{ {
write(mName, "name", dst); write(mName, "name", dst);
write(mMatrix, "matrix", dst, glm::identity<mat4>()); write(mMatrix, "matrix", dst, glm::identity<mat4>());
write(mRotation, "rotation", dst); write(mRotation, "rotation", dst, glm::identity<quat>());
write(mTranslation, "translation", dst); write(mTranslation, "translation", dst, glm::vec3(0.f, 0.f, 0.f));
write(mScale, "scale", dst, vec3(1.f,1.f,1.f)); write(mScale, "scale", dst, vec3(1.f,1.f,1.f));
write(mChildren, "children", dst); write(mChildren, "children", dst);
write(mMesh, "mesh", dst, INVALID_INDEX); write(mMesh, "mesh", dst, INVALID_INDEX);
@ -312,7 +312,6 @@ const Node& Node::operator=(const Value& src)
{ {
copy(src, "name", mName); copy(src, "name", mName);
mMatrixValid = copy(src, "matrix", mMatrix); mMatrixValid = copy(src, "matrix", mMatrix);
copy(src, "rotation", mRotation); copy(src, "rotation", mRotation);
copy(src, "translation", mTranslation); copy(src, "translation", mTranslation);
copy(src, "scale", mScale); copy(src, "scale", mScale);

View File

@ -610,14 +610,17 @@ namespace LL
const boost::json::array& arr = src.as_array(); const boost::json::array& arr = src.as_array();
if (arr.size() == 4) if (arr.size() == 4)
{ {
if (arr[0].is_double() && vec4 v;
arr[1].is_double() && std::error_code ec;
arr[2].is_double() &&
arr[3].is_double()) v.x = arr[0].to_number<F32>(ec); if (ec) return false;
{ v.y = arr[1].to_number<F32>(ec); if (ec) return false;
dst = vec4(arr[0].get_double(), arr[1].get_double(), arr[2].get_double(), arr[3].get_double()); v.z = arr[2].to_number<F32>(ec); if (ec) return false;
return true; v.w = arr[3].to_number<F32>(ec); if (ec) return false;
}
dst = v;
return true;
} }
} }
return false; return false;
@ -645,17 +648,13 @@ namespace LL
const boost::json::array& arr = src.as_array(); const boost::json::array& arr = src.as_array();
if (arr.size() == 4) if (arr.size() == 4)
{ {
if (arr[0].is_double() && std::error_code ec;
arr[1].is_double() && dst.x = arr[0].to_number<F32>(ec); if (ec) return false;
arr[2].is_double() && dst.y = arr[1].to_number<F32>(ec); if (ec) return false;
arr[3].is_double()) dst.z = arr[2].to_number<F32>(ec); if (ec) return false;
{ dst.w = arr[3].to_number<F32>(ec); if (ec) return false;
dst.x = arr[0].get_double();
dst.y = arr[1].get_double(); return true;
dst.z = arr[2].get_double();
dst.w = arr[3].get_double();
return true;
}
} }
} }
return false; return false;
@ -684,12 +683,13 @@ namespace LL
const boost::json::array& arr = src.as_array(); const boost::json::array& arr = src.as_array();
if (arr.size() == 3) if (arr.size() == 3)
{ {
if (arr[0].is_double() && std::error_code ec;
arr[1].is_double() && vec3 t;
arr[2].is_double()) t.x = arr[0].to_number<F32>(ec); if (ec) return false;
{ t.y = arr[1].to_number<F32>(ec); if (ec) return false;
dst = vec3(arr[0].get_double(), arr[1].get_double(), arr[2].get_double()); t.z = arr[2].to_number<F32>(ec); if (ec) return false;
}
dst = t;
return true; return true;
} }
} }
@ -731,12 +731,10 @@ namespace LL
template<> template<>
inline bool copy(const Value& src, F32& dst) inline bool copy(const Value& src, F32& dst)
{ {
if (src.is_double()) std::error_code ec;
{ F32 t = src.to_number<F32>(ec); if (ec) return false;
dst = src.get_double(); dst = t;
return true; return true;
}
return false;
} }
template<> template<>
@ -770,12 +768,10 @@ namespace LL
template<> template<>
inline bool copy(const Value& src, F64& dst) inline bool copy(const Value& src, F64& dst)
{ {
if (src.is_double()) std::error_code ec;
{ F64 t = src.to_number<F64>(ec); if (ec) return false;
dst = src.get_double(); dst = t;
return true; return true;
}
return false;
} }
template<> template<>
@ -860,11 +856,9 @@ namespace LL
for (U32 i = 0; i < arr.size(); ++i) for (U32 i = 0; i < arr.size(); ++i)
{ {
if (arr[i].is_double()) std::error_code ec;
{ p[i] = arr[i].to_number<F32>(ec);
p[i] = arr[i].get_double(); if (ec)
}
else
{ {
return false; return false;
} }

View File

@ -97,7 +97,6 @@ static std::string click_action_to_string_value(U8 click_action)
default: default:
return "Touch"; return "Touch";
} }
return "Touch";
} }
// Default constructor // Default constructor