Fix Transform diff serialization to properly handle prefab changes to a single component of transform

#2085
This commit is contained in:
Wojtek Figat
2024-02-20 13:12:23 +01:00
parent e255778c07
commit 8e6bd07322
3 changed files with 35 additions and 11 deletions

View File

@@ -343,18 +343,30 @@ void JsonWriter::Transform(const ::Transform& value)
void JsonWriter::Transform(const ::Transform& value, const ::Transform* other)
{
StartObject();
if (!other || !Vector3::NearEqual(value.Translation, other->Translation))
if (other)
{
if (!Vector3::NearEqual(value.Translation, other->Translation))
{
JKEY("Translation");
Vector3(value.Translation);
}
if (!Quaternion::NearEqual(value.Orientation, other->Orientation))
{
JKEY("Orientation");
Quaternion(value.Orientation);
}
if (!Float3::NearEqual(value.Scale, other->Scale))
{
JKEY("Scale");
Float3(value.Scale);
}
}
else
{
JKEY("Translation");
Vector3(value.Translation);
}
if (!other || !Quaternion::NearEqual(value.Orientation, other->Orientation))
{
JKEY("Orientation");
Quaternion(value.Orientation);
}
if (!other || !Float3::NearEqual(value.Scale, other->Scale))
{
JKEY("Scale");
Float3(value.Scale);
}