Fix model LOD index detection in importer
This commit is contained in:
@@ -16,7 +16,6 @@
|
|||||||
#include "Engine/ContentImporters/AssetsImportingManager.h"
|
#include "Engine/ContentImporters/AssetsImportingManager.h"
|
||||||
#include "Engine/ContentImporters/CreateMaterial.h"
|
#include "Engine/ContentImporters/CreateMaterial.h"
|
||||||
#include "ThirdParty/meshoptimizer/meshoptimizer.h"
|
#include "ThirdParty/meshoptimizer/meshoptimizer.h"
|
||||||
#include <regex>
|
|
||||||
|
|
||||||
void RemoveNamespace(String& name)
|
void RemoveNamespace(String& name)
|
||||||
{
|
{
|
||||||
@@ -1193,27 +1192,15 @@ bool ModelTool::ImportModel(const String& path, ModelData& meshData, Options opt
|
|||||||
|
|
||||||
int32 ModelTool::DetectLodIndex(const String& nodeName)
|
int32 ModelTool::DetectLodIndex(const String& nodeName)
|
||||||
{
|
{
|
||||||
// Try detect mesh lod index
|
const int32 index = nodeName.FindLast(TEXT("LOD"));
|
||||||
int32 index;
|
if (index != -1)
|
||||||
String result;
|
|
||||||
std::match_results<const Char*> match;
|
|
||||||
String reversed = nodeName;
|
|
||||||
reversed.Reverse();
|
|
||||||
|
|
||||||
// Find '<name>LOD<index>' case
|
|
||||||
const std::wregex regex2(TEXT("^(\\d+)DOL"));
|
|
||||||
if (regex_search(*reversed, match, regex2) && match.size() == 2)
|
|
||||||
{
|
{
|
||||||
// Get result
|
int32 num;
|
||||||
String num(match[1].str().c_str());
|
if (!StringUtils::Parse(nodeName.Get() + index + 3, &num))
|
||||||
num.Reverse();
|
|
||||||
|
|
||||||
// Parse value
|
|
||||||
if (!StringUtils::Parse(*num, num.Length(), &index))
|
|
||||||
{
|
{
|
||||||
if (index >= 0 && index < MODEL_MAX_LODS)
|
if (num >= 0 && num < MODEL_MAX_LODS)
|
||||||
{
|
{
|
||||||
return index;
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG(Warning, "Invalid mesh level of detail index at node \'{0}\'. Maximum supported amount of LODs is {1}.", nodeName, MODEL_MAX_LODS);
|
LOG(Warning, "Invalid mesh level of detail index at node \'{0}\'. Maximum supported amount of LODs is {1}.", nodeName, MODEL_MAX_LODS);
|
||||||
|
|||||||
Reference in New Issue
Block a user