Fix incorrect prefab serialization to correctly handle diff on object references to prefab objects

#3136
This commit is contained in:
Wojtek Figat
2025-02-14 17:07:33 +01:00
parent 3394de0b93
commit 086ddc96bb
4 changed files with 82 additions and 4 deletions

View File

@@ -441,10 +441,12 @@ namespace Serialization
// Scripting Object
FLAXENGINE_API bool ShouldSerialize(const SceneObject* v, const SceneObject* other);
template<typename T>
inline typename TEnableIf<TIsBaseOf<ScriptingObject, T>::Value, bool>::Type ShouldSerialize(const T*& v, const void* otherObj)
{
return !otherObj || v != *(T**)otherObj;
return !otherObj || v != *(const T**)otherObj;
}
template<typename T>
inline typename TEnableIf<TIsBaseOf<ScriptingObject, T>::Value>::Type Serialize(ISerializable::SerializeStream& stream, const T*& v, const void* otherObj)
@@ -460,12 +462,18 @@ namespace Serialization
v = (T*)::FindObject(id, T::GetStaticClass());
}
template<typename T>
inline typename TEnableIf<TIsBaseOf<SceneObject, T>::Value, bool>::Type ShouldSerialize(const T*& v, const void* otherObj)
{
return !otherObj || ShouldSerialize((const SceneObject*)v, *(const SceneObject**)otherObj);
}
// Scripting Object Reference
template<typename T>
inline bool ShouldSerialize(const ScriptingObjectReference<T>& v, const void* otherObj)
{
return !otherObj || v.Get() != ((ScriptingObjectReference<T>*)otherObj)->Get();
return !otherObj || ShouldSerialize(v.Get(), ((ScriptingObjectReference<T>*)otherObj)->Get());
}
template<typename T>
inline void Serialize(ISerializable::SerializeStream& stream, const ScriptingObjectReference<T>& v, const void* otherObj)
@@ -486,7 +494,7 @@ namespace Serialization
template<typename T>
inline bool ShouldSerialize(const SoftObjectReference<T>& v, const void* otherObj)
{
return !otherObj || v.Get() != ((SoftObjectReference<T>*)otherObj)->Get();
return !otherObj || ShouldSerialize(v.Get(), ((SoftObjectReference<T>*)otherObj)->Get());
}
template<typename T>
inline void Serialize(ISerializable::SerializeStream& stream, const SoftObjectReference<T>& v, const void* otherObj)