MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / Serialize

Method Serialize

Source/Engine/Foliage/Foliage.cpp:1356–1400  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1354static_assert(InstanceEncoded::Base64Size == GetInstanceBase64Size(sizeof(InstanceEncoded)), "Please update base64 buffer size to match the encoded instance buffer.");
1355
1356void Foliage::Serialize(SerializeStream& stream, const void* otherObj)
1357{
1358 // Base
1359 Actor::Serialize(stream, otherObj);
1360
1361 SERIALIZE_GET_OTHER_OBJ(Foliage);
1362
1363 if (FoliageTypes.IsEmpty())
1364 return;
1365
1366 PROFILE_CPU();
1367
1368 stream.JKEY("Foliage");
1369 stream.StartArray();
1370 for (auto& type : FoliageTypes)
1371 {
1372 stream.StartObject();
1373 type.Serialize(stream, nullptr);
1374 stream.EndObject();
1375 }
1376 stream.EndArray();
1377
1378 stream.JKEY("Instances");
1379 stream.StartArray();
1380 InstanceEncoded enc;
1381 char base64[InstanceEncoded::Base64Size + 2];
1382 base64[0] = '\"';
1383 base64[InstanceEncoded::Base64Size + 1] = '\"';
1384 for (auto i = Instances.Begin(); i.IsNotEnd(); ++i)
1385 {
1386 auto& instance = *i;
1387
1388 enc.Type = instance.Type;
1389 enc.Random = instance.Random;
1390 enc.Translation = instance.Transform.Translation;
1391 enc.Orientation = instance.Transform.Orientation;
1392 enc.Scale = instance.Transform.Scale;
1393 enc.Lightmap = instance.Lightmap;
1394
1395 Encryption::Base64Encode((const byte*)&enc, sizeof(enc), base64 + 1);
1396
1397 stream.RawValue(base64, InstanceEncoded::Base64Size + 2);
1398 }
1399 stream.EndArray();
1400}
1401
1402void Foliage::Deserialize(DeserializeStream& stream, ISerializeModifier* modifier)
1403{

Callers

nothing calls this directly

Calls 9

SerializeFunction · 0.50
IsEmptyMethod · 0.45
StartArrayMethod · 0.45
StartObjectMethod · 0.45
EndObjectMethod · 0.45
EndArrayMethod · 0.45
BeginMethod · 0.45
IsNotEndMethod · 0.45
RawValueMethod · 0.45

Tested by

no test coverage detected