Add various improvements to models importing code

This commit is contained in:
Wojtek Figat
2023-11-30 11:31:58 +01:00
parent 712c400e43
commit c5df7ad689
7 changed files with 11 additions and 20 deletions

View File

@@ -151,9 +151,7 @@ public:
{
int32 result = 0;
for (int32 i = 0; i < Channels.Count(); i++)
{
result += Channels[i].GetKeyframesCount();
}
return result;
}

View File

@@ -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>

View File

@@ -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;
}

View File

@@ -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();

View File

@@ -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)
{

View File

@@ -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;

View File

@@ -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;