#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)
{
// 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())

View File

@ -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);

View File

@ -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;
}

View File

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