Add various improvements to models importing code
This commit is contained in:
@@ -151,9 +151,7 @@ public:
|
||||
{
|
||||
int32 result = 0;
|
||||
for (int32 i = 0; i < Channels.Count(); i++)
|
||||
{
|
||||
result += Channels[i].GetKeyframesCount();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,11 +8,6 @@
|
||||
|
||||
#include "Engine/Tools/ModelTool/ModelTool.h"
|
||||
|
||||
/// <summary>
|
||||
/// Enable/disable caching model import options
|
||||
/// </summary>
|
||||
#define IMPORT_MODEL_CACHE_OPTIONS 1
|
||||
|
||||
/// <summary>
|
||||
/// Importing models utility
|
||||
/// </summary>
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
bool ImportModelFile::TryGetImportOptions(const StringView& path, Options& options)
|
||||
{
|
||||
#if IMPORT_MODEL_CACHE_OPTIONS
|
||||
if (FileSystem::FileExists(path))
|
||||
{
|
||||
// Try to load asset file and asset info
|
||||
@@ -44,7 +43,6 @@ bool ImportModelFile::TryGetImportOptions(const StringView& path, Options& optio
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -158,7 +156,6 @@ CreateAssetResult ImportModelFile::Import(CreateAssetContext& context)
|
||||
if (result != CreateAssetResult::Ok)
|
||||
return result;
|
||||
|
||||
#if IMPORT_MODEL_CACHE_OPTIONS
|
||||
// Create json with import context
|
||||
rapidjson_flax::StringBuffer importOptionsMetaBuffer;
|
||||
importOptionsMetaBuffer.Reserve(256);
|
||||
@@ -171,7 +168,6 @@ CreateAssetResult ImportModelFile::Import(CreateAssetContext& context)
|
||||
}
|
||||
importOptionsMeta.EndObject();
|
||||
context.Data.Metadata.Copy((const byte*)importOptionsMetaBuffer.GetString(), (uint32)importOptionsMetaBuffer.GetSize());
|
||||
#endif
|
||||
|
||||
return CreateAssetResult::Ok;
|
||||
}
|
||||
|
||||
@@ -452,7 +452,6 @@ public:
|
||||
/// <summary>
|
||||
/// Gets the valid level of details count.
|
||||
/// </summary>
|
||||
/// <returns>The LOD count.</returns>
|
||||
FORCE_INLINE int32 GetLODsCount() const
|
||||
{
|
||||
return LODs.Count();
|
||||
@@ -461,7 +460,6 @@ public:
|
||||
/// <summary>
|
||||
/// Determines whether this instance has valid skeleton structure.
|
||||
/// </summary>
|
||||
/// <returns>True if has skeleton, otherwise false.</returns>
|
||||
FORCE_INLINE bool HasSkeleton() const
|
||||
{
|
||||
return Skeleton.Bones.HasItems();
|
||||
|
||||
@@ -1117,11 +1117,15 @@ bool ModelTool::ImportDataOpenFBX(const char* path, ImportedModelData& data, Opt
|
||||
}
|
||||
ofbx::u64 loadFlags = 0;
|
||||
if (EnumHasAnyFlags(data.Types, ImportDataTypes::Geometry))
|
||||
{
|
||||
loadFlags |= (ofbx::u64)ofbx::LoadFlags::TRIANGULATE;
|
||||
if (!options.ImportBlendShapes)
|
||||
loadFlags |= (ofbx::u64)ofbx::LoadFlags::IGNORE_BLEND_SHAPES;
|
||||
}
|
||||
else
|
||||
loadFlags |= (ofbx::u64)ofbx::LoadFlags::IGNORE_GEOMETRY;
|
||||
if (!options.ImportBlendShapes)
|
||||
loadFlags |= (ofbx::u64)ofbx::LoadFlags::IGNORE_BLEND_SHAPES;
|
||||
{
|
||||
loadFlags |= (ofbx::u64)ofbx::LoadFlags::IGNORE_GEOMETRY | (ofbx::u64)ofbx::LoadFlags::IGNORE_BLEND_SHAPES;
|
||||
}
|
||||
ofbx::IScene* scene = ofbx::load(fileData.Get(), fileData.Count(), loadFlags);
|
||||
if (!scene)
|
||||
{
|
||||
|
||||
@@ -787,7 +787,7 @@ bool ModelTool::ImportModel(const String& path, ModelData& meshData, Options& op
|
||||
switch (options.Type)
|
||||
{
|
||||
case ModelType::Model:
|
||||
importDataTypes = ImportDataTypes::Geometry | ImportDataTypes::Nodes | ImportDataTypes::Textures;
|
||||
importDataTypes = ImportDataTypes::Geometry | ImportDataTypes::Nodes;
|
||||
if (options.ImportMaterials)
|
||||
importDataTypes |= ImportDataTypes::Materials;
|
||||
if (options.ImportTextures)
|
||||
@@ -1036,7 +1036,7 @@ bool ModelTool::ImportModel(const String& path, ModelData& meshData, Options& op
|
||||
// When splitting imported meshes allow only the first mesh to import assets (mesh[0] is imported after all following ones so import assets during mesh[1])
|
||||
if (!options.SplitObjects && options.ObjectIndex != 1 && options.ObjectIndex != -1)
|
||||
{
|
||||
// Find that asset create previously
|
||||
// Find that asset created previously
|
||||
AssetInfo info;
|
||||
if (Content::GetAssetInfo(assetPath, info))
|
||||
material.AssetID = info.ID;
|
||||
|
||||
@@ -24,7 +24,7 @@ enum class ImportDataTypes : int32
|
||||
None = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Imports materials and meshes.
|
||||
/// Imports meshes (and LODs).
|
||||
/// </summary>
|
||||
Geometry = 1 << 0,
|
||||
|
||||
@@ -104,7 +104,7 @@ public:
|
||||
Array<MaterialSlotEntry> Materials;
|
||||
|
||||
/// <summary>
|
||||
/// The level of details data.
|
||||
/// The level of details data with meshes.
|
||||
/// </summary>
|
||||
Array<LOD> LODs;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user