Fix Transform diff serialization to properly handle prefab changes to a single component of transform
#2085
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -747,9 +747,21 @@ bool Serialization::ShouldSerialize(const Transform& v, const void* otherObj)
|
||||
|
||||
void Serialization::Deserialize(ISerializable::DeserializeStream& stream, Transform& v, ISerializeModifier* modifier)
|
||||
{
|
||||
DESERIALIZE_HELPER(stream, "Translation", v.Translation, Vector3::Zero);
|
||||
DESERIALIZE_HELPER(stream, "Scale", v.Scale, Vector3::One);
|
||||
DESERIALIZE_HELPER(stream, "Orientation", v.Orientation, Quaternion::Identity);
|
||||
{
|
||||
const auto m = SERIALIZE_FIND_MEMBER(stream, "Translation");
|
||||
if (m != stream.MemberEnd())
|
||||
Deserialize(m->value, v.Translation, modifier);
|
||||
}
|
||||
{
|
||||
const auto m = SERIALIZE_FIND_MEMBER(stream, "Scale");
|
||||
if (m != stream.MemberEnd())
|
||||
Deserialize(m->value, v.Scale, modifier);
|
||||
}
|
||||
{
|
||||
const auto m = SERIALIZE_FIND_MEMBER(stream, "Orientation");
|
||||
if (m != stream.MemberEnd())
|
||||
Deserialize(m->value, v.Orientation, modifier);
|
||||
}
|
||||
}
|
||||
|
||||
bool Serialization::ShouldSerialize(const Matrix& v, const void* otherObj)
|
||||
|
||||
@@ -393,7 +393,7 @@ namespace Serialization
|
||||
FLAXENGINE_API bool ShouldSerialize(const Transform& v, const void* otherObj);
|
||||
inline void Serialize(ISerializable::SerializeStream& stream, const Transform& v, const void* otherObj)
|
||||
{
|
||||
stream.Transform(v);
|
||||
stream.Transform(v, (const Transform*)otherObj);
|
||||
}
|
||||
FLAXENGINE_API void Deserialize(ISerializable::DeserializeStream& stream, Transform& v, ISerializeModifier* modifier);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user