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

Method TryGetImportOptions

Source/Engine/ContentImporters/ImportTexture.cpp:25–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23}
24
25bool ImportTexture::TryGetImportOptions(const StringView& path, Options& options)
26{
27#if IMPORT_TEXTURE_CACHE_OPTIONS
28 if (FileSystem::FileExists(path))
29 {
30 auto tmpFile = ContentStorageManager::GetStorage(path);
31 AssetInitData data;
32 if (tmpFile
33 && tmpFile->GetEntriesCount() == 1
34 && IsSpriteAtlasOrTexture(tmpFile->GetEntry(0).TypeName)
35 && !tmpFile->LoadAssetHeader(0, data)
36 && data.SerializedVersion >= 4)
37 {
38 // For sprite atlas try to get sprites from the last chunk
39 if (tmpFile->GetEntry(0).TypeName == SpriteAtlas::TypeName)
40 {
41 auto chunk15 = data.Header.Chunks[15];
42 if (chunk15 != nullptr && !tmpFile->LoadAssetChunk(chunk15) && chunk15->Data.IsValid())
43 {
44 MemoryReadStream stream(chunk15->Data.Get(), chunk15->Data.Length());
45 int32 tilesVersion, tilesCount;
46 stream.Read(tilesVersion);
47 if (tilesVersion == 1)
48 {
49 options.Sprites.Clear();
50 stream.Read(tilesCount);
51 for (int32 i = 0; i < tilesCount; i++)
52 {
53 // Load sprite
54 Sprite t;
55 stream.Read(t.Area);
56 stream.Read(t.Name, 49);
57 options.Sprites.Add(t);
58 }
59 }
60 }
61 }
62
63 // Check import meta
64 rapidjson_flax::Document metadata;
65 metadata.Parse((const char*)data.Metadata.Get(), data.Metadata.Length());
66 if (metadata.HasParseError() == false)
67 {
68 options.Deserialize(metadata, nullptr);
69 return true;
70 }
71 }
72 }
73#endif
74 return false;
75}
76
77void ImportTexture::InitOptions(CreateAssetContext& context, Options& options)
78{

Callers

nothing calls this directly

Calls 14

IsSpriteAtlasOrTextureFunction · 0.85
GetEntriesCountMethod · 0.80
LoadAssetHeaderMethod · 0.80
LoadAssetChunkMethod · 0.80
GetEntryMethod · 0.45
IsValidMethod · 0.45
GetMethod · 0.45
LengthMethod · 0.45
ReadMethod · 0.45
ClearMethod · 0.45
AddMethod · 0.45
ParseMethod · 0.45

Tested by

no test coverage detected