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