@@ -16,6 +16,7 @@
|
||||
#include "Engine/Core/Collections/CollectionPoolCache.h"
|
||||
#include "Engine/Debug/Exceptions/JsonParseException.h"
|
||||
#include "Engine/Graphics/RenderView.h"
|
||||
#include "Engine/Profiler/ProfilerCPU.h"
|
||||
#include "Engine/Scripting/Scripting.h"
|
||||
#include "Engine/Serialization/ISerializeModifier.h"
|
||||
#include "Engine/Serialization/Serialization.h"
|
||||
@@ -1494,6 +1495,7 @@ void WriteObjectToBytes(SceneObject* obj, rapidjson_flax::StringBuffer& buffer,
|
||||
|
||||
bool Actor::ToBytes(const Array<Actor*>& actors, MemoryWriteStream& output)
|
||||
{
|
||||
PROFILE_CPU();
|
||||
if (actors.IsEmpty())
|
||||
{
|
||||
// Cannot serialize empty list
|
||||
@@ -1553,6 +1555,7 @@ Array<byte> Actor::ToBytes(const Array<Actor*>& actors)
|
||||
|
||||
bool Actor::FromBytes(const Span<byte>& data, Array<Actor*>& output, ISerializeModifier* modifier)
|
||||
{
|
||||
PROFILE_CPU();
|
||||
output.Clear();
|
||||
|
||||
ASSERT(modifier);
|
||||
@@ -1654,17 +1657,19 @@ bool Actor::FromBytes(const Span<byte>& data, Array<Actor*>& output, ISerializeM
|
||||
Scripting::ObjectsLookupIdMapping.Set(nullptr);
|
||||
|
||||
// Link objects
|
||||
for (int32 i = 0; i < objectsCount; i++)
|
||||
//for (int32 i = 0; i < objectsCount; i++)
|
||||
{
|
||||
SceneObject* obj = sceneObjects->At(i);
|
||||
obj->PostLoad();
|
||||
//SceneObject* obj = sceneObjects->At(i);
|
||||
// TODO: post load or post spawn?
|
||||
//obj->PostLoad();
|
||||
}
|
||||
|
||||
// Update objects order
|
||||
for (int32 i = 0; i < objectsCount; i++)
|
||||
//for (int32 i = 0; i < objectsCount; i++)
|
||||
{
|
||||
SceneObject* obj = sceneObjects->At(i);
|
||||
obj->SetOrderInParent(order[i]);
|
||||
//SceneObject* obj = sceneObjects->At(i);
|
||||
// TODO: remove order from saved data?
|
||||
//obj->SetOrderInParent(order[i]);
|
||||
}
|
||||
|
||||
// Call events (only for parents because they will propagate events down the tree)
|
||||
@@ -1681,6 +1686,10 @@ bool Actor::FromBytes(const Span<byte>& data, Array<Actor*>& output, ISerializeM
|
||||
}
|
||||
}
|
||||
for (int32 i = 0; i < parents->Count(); i++)
|
||||
{
|
||||
parents->At(i)->PostSpawn();
|
||||
}
|
||||
for (int32 i = 0; i < parents->Count(); i++)
|
||||
{
|
||||
Actor* actor = parents->At(i);
|
||||
actor->OnTransformChanged();
|
||||
@@ -1722,6 +1731,7 @@ Array<Actor*> Actor::FromBytes(const Span<byte>& data, const Dictionary<Guid, Gu
|
||||
|
||||
Array<Guid> Actor::TryGetSerializedObjectsIds(const Span<byte>& data)
|
||||
{
|
||||
PROFILE_CPU();
|
||||
Array<Guid> result;
|
||||
if (data.Length() > 0)
|
||||
{
|
||||
@@ -1742,6 +1752,7 @@ Array<Guid> Actor::TryGetSerializedObjectsIds(const Span<byte>& data)
|
||||
|
||||
String Actor::ToJson()
|
||||
{
|
||||
PROFILE_CPU();
|
||||
rapidjson_flax::StringBuffer buffer;
|
||||
CompactJsonWriter writer(buffer);
|
||||
writer.SceneObject(this);
|
||||
@@ -1753,6 +1764,8 @@ String Actor::ToJson()
|
||||
|
||||
void Actor::FromJson(const StringAnsiView& json)
|
||||
{
|
||||
PROFILE_CPU();
|
||||
|
||||
// Load JSON
|
||||
rapidjson_flax::Document document;
|
||||
document.Parse(json.Get(), json.Length());
|
||||
|
||||
Reference in New Issue
Block a user