| 1989 | } |
| 1990 | |
| 1991 | void VisualScriptingBinaryModule::SerializeObject(JsonWriter& stream, ScriptingObject* object, const ScriptingObject* otherObj) |
| 1992 | { |
| 1993 | char idName[33]; |
| 1994 | stream.StartObject(); |
| 1995 | Locker.Lock(); |
| 1996 | const auto asset = Scripts[object->GetTypeHandle().TypeIndex].Get(); |
| 1997 | Locker.Unlock(); |
| 1998 | if (asset) |
| 1999 | { |
| 2000 | ScopeLock lock(asset->Locker); |
| 2001 | const auto instanceParams = asset->_instances.Find(object->GetID()); |
| 2002 | if (instanceParams) |
| 2003 | { |
| 2004 | auto& params = instanceParams->Value.Params; |
| 2005 | if (otherObj) |
| 2006 | { |
| 2007 | // Serialize parameters diff |
| 2008 | const auto otherParams = asset->_instances.Find(otherObj->GetID()); |
| 2009 | if (otherParams) |
| 2010 | { |
| 2011 | for (int32 paramIndex = 0; paramIndex < params.Count(); paramIndex++) |
| 2012 | { |
| 2013 | auto& param = asset->Graph.Parameters[paramIndex]; |
| 2014 | auto& value = params[paramIndex]; |
| 2015 | auto& otherValue = otherParams->Value.Params[paramIndex]; |
| 2016 | if (SerializeValue(value, otherValue)) |
| 2017 | { |
| 2018 | param.Identifier.ToString(idName, Guid::FormatType::N); |
| 2019 | stream.Key(idName, 32); |
| 2020 | Serialization::Serialize(stream, params[paramIndex], &otherValue); |
| 2021 | } |
| 2022 | } |
| 2023 | } |
| 2024 | else |
| 2025 | { |
| 2026 | for (int32 paramIndex = 0; paramIndex < params.Count(); paramIndex++) |
| 2027 | { |
| 2028 | auto& param = asset->Graph.Parameters[paramIndex]; |
| 2029 | auto& value = params[paramIndex]; |
| 2030 | auto& otherValue = param.Value; |
| 2031 | if (SerializeValue(value, otherValue)) |
| 2032 | { |
| 2033 | param.Identifier.ToString(idName, Guid::FormatType::N); |
| 2034 | stream.Key(idName, 32); |
| 2035 | Serialization::Serialize(stream, params[paramIndex], &otherValue); |
| 2036 | } |
| 2037 | } |
| 2038 | } |
| 2039 | } |
| 2040 | else |
| 2041 | { |
| 2042 | // Serialize all parameters |
| 2043 | for (int32 paramIndex = 0; paramIndex < params.Count(); paramIndex++) |
| 2044 | { |
| 2045 | auto& param = asset->Graph.Parameters[paramIndex]; |
| 2046 | auto& value = params[paramIndex]; |
| 2047 | param.Identifier.ToString(idName, Guid::FormatType::N); |
| 2048 | stream.Key(idName, 32); |
no test coverage detected