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

Method TryGetImportOptions

Source/Engine/ContentImporters/ImportModel.cpp:33–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31#include "AssetsImportingManager.h"
32
33bool ImportModel::TryGetImportOptions(const StringView& path, Options& options)
34{
35 if (FileSystem::FileExists(path))
36 {
37 // Try to load asset file and asset info
38 auto tmpFile = ContentStorageManager::GetStorage(path);
39 AssetInitData data;
40 if (tmpFile
41 && tmpFile->GetEntriesCount() == 1
42 && (
43 (tmpFile->GetEntry(0).TypeName == Model::TypeName && !tmpFile->LoadAssetHeader(0, data) && data.SerializedVersion >= 4)
44 ||
45 (tmpFile->GetEntry(0).TypeName == SkinnedModel::TypeName && !tmpFile->LoadAssetHeader(0, data) && data.SerializedVersion >= 1)
46 ||
47 (tmpFile->GetEntry(0).TypeName == Animation::TypeName && !tmpFile->LoadAssetHeader(0, data) && data.SerializedVersion >= 1)
48 ))
49 {
50 // Check import meta
51 rapidjson_flax::Document metadata;
52 metadata.Parse((const char*)data.Metadata.Get(), data.Metadata.Length());
53 if (metadata.HasParseError() == false)
54 {
55 options.Deserialize(metadata, nullptr);
56 return true;
57 }
58 }
59 }
60 else
61 {
62 // Try model prefab
63 String pathPrefab = String(StringUtils::GetPathWithoutExtension(path)) + DEFAULT_PREFAB_EXTENSION_DOT;
64 if (FileSystem::FileExists(pathPrefab))
65 {
66 auto prefab = Content::Load<Prefab>(pathPrefab);
67 if (prefab)
68 {
69 for (const auto& e : prefab->ObjectsDataCache)
70 {
71 auto importOptionsMember = e.Value->FindMember("ImportOptions");
72 if (importOptionsMember != e.Value->MemberEnd() && importOptionsMember->value.IsObject())
73 {
74 options.Deserialize(*(ISerializable::DeserializeStream*)&importOptionsMember->value, nullptr);
75 return true;
76 }
77 }
78 }
79 }
80 }
81 return false;
82}
83
84struct PrefabObject
85{

Callers

nothing calls this directly

Calls 11

GetEntriesCountMethod · 0.80
LoadAssetHeaderMethod · 0.80
FindMemberMethod · 0.80
MemberEndMethod · 0.80
StringClass · 0.50
GetEntryMethod · 0.45
ParseMethod · 0.45
GetMethod · 0.45
LengthMethod · 0.45
HasParseErrorMethod · 0.45
DeserializeMethod · 0.45

Tested by

no test coverage detected