Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

364 fix metalic maps not importing #368

Merged
merged 3 commits into from
Sep 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -506,9 +506,12 @@ void ERS_CLASS_AsyncTextureUpdater::ProcessVRAMUpdate(int Index, ERS_STRUCT_Scen

if (PrioritizeQueueByVisualImpact_) {
int HighestTargetLevel = Scene->Models[Index]->TargetTextureLevelVRAM;
float Priority = HighestTargetLevel / Scene->Models[Index]->MaxTextureLevel_;
int InsertLocationIndex = PushWorkItems_.size() * Priority;
PushWorkItems_.insert(PushWorkItems_.end() - InsertLocationIndex, Scene->Models[Index]);

if (HighestTargetLevel != 0) {
float Priority = HighestTargetLevel / Scene->Models[Index]->MaxTextureLevel_;
int InsertLocationIndex = PushWorkItems_.size() * Priority;
PushWorkItems_.insert(PushWorkItems_.end() - InsertLocationIndex, Scene->Models[Index]);
}
} else {
PushWorkItems_.push_back(Scene->Models[Index]);
}
Expand Down Expand Up @@ -543,9 +546,13 @@ void ERS_CLASS_AsyncTextureUpdater::ProcessRAMUpdate(int Index, ERS_STRUCT_Scene

if (PrioritizeQueueByVisualImpact_) {
int HighestTargetLevel = Scene->Models[Index]->TargetTextureLevelVRAM;
float Priority = HighestTargetLevel / Scene->Models[Index]->MaxTextureLevel_;
int InsertLocationIndex = LoadWorkItems_.size() * Priority;
LoadWorkItems_.insert(LoadWorkItems_.end() - InsertLocationIndex, Scene->Models[Index]);

if (HighestTargetLevel != 0) {
float Priority = HighestTargetLevel / Scene->Models[Index]->MaxTextureLevel_;
int InsertLocationIndex = LoadWorkItems_.size() * Priority;
LoadWorkItems_.insert(LoadWorkItems_.end() - InsertLocationIndex, Scene->Models[Index]);
}

} else {
LoadWorkItems_.push_back(Scene->Models[Index]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,31 +510,39 @@ bool ERS_CLASS_ExternalModelLoader::LoadModel(std::string ModelPath, ERS_STRUCT_
std::string ModelFileName = ModelPath.substr(ModelPath.find_last_of("/") + 1, ModelPath.size() - 1);

// Load Via Assimp
const aiScene* Scene = Data.ModelImporter.ReadFile(ModelPath, aiProcess_Triangulate | aiProcess_GenSmoothNormals | aiProcess_FlipUVs | aiProcess_CalcTangentSpace | aiProcess_PreTransformVertices | aiProcess_JoinIdenticalVertices);
if (!Scene || Scene->mFlags & AI_SCENE_FLAGS_INCOMPLETE || !Scene->mRootNode) {
SystemUtils_->Logger_->Log(std::string(std::string("External Model Loading Error: ") + std::string(Data.ModelImporter.GetErrorString())).c_str(), 10);
Data.ModelScene = nullptr;
return false;
}
SystemUtils_->Logger_->Log("Finished Loading External Model, Processing Geometry/Textures", 3);
try {
const aiScene* Scene = Data.ModelImporter.ReadFile(ModelPath, aiProcess_Triangulate | aiProcess_GenSmoothNormals | aiProcess_FlipUVs | aiProcess_CalcTangentSpace | aiProcess_PreTransformVertices | aiProcess_JoinIdenticalVertices);

// Process Geometry, Identify Textures
ProcessNode(Data, Data.Model, Scene->mRootNode, Scene, ModelDirectory);
if (!PerformModelSanityChecks(*Data.Model)) {
return false;
}
DetectBoundingBox(Data.Model);
CalculateTotalVertsIndices(Data.Model);
if (!Scene || Scene->mFlags & AI_SCENE_FLAGS_INCOMPLETE || !Scene->mRootNode) {
SystemUtils_->Logger_->Log(std::string(std::string("External Model Loading Error: ") + std::string(Data.ModelImporter.GetErrorString())).c_str(), 10);
Data.ModelScene = nullptr;
return false;
}
SystemUtils_->Logger_->Log("Finished Loading External Model, Processing Geometry/Textures", 3);

// Process Geometry, Identify Textures
ProcessNode(Data, Data.Model, Scene->mRootNode, Scene, ModelDirectory);
if (!PerformModelSanityChecks(*Data.Model)) {
return false;
}
DetectBoundingBox(Data.Model);
CalculateTotalVertsIndices(Data.Model);

// Update Struct
Data.ModelOriginDirectoryPath = ModelPath;
Data.ModelScene = (aiScene*)Scene;
Data.ModelFileName = ModelFileName;
// Update Struct
Data.ModelOriginDirectoryPath = ModelPath;
Data.ModelScene = (aiScene*)Scene;
Data.ModelFileName = ModelFileName;

// Load Textures
ProcessModelTextures(Data);
// Load Textures
ProcessModelTextures(Data);

return true;

} catch (const DeadlyImportError& e) {
SystemUtils_->Logger_->Log("Assimp Threw DeadlyImportError, Aborting Load", 8);
return false;
}

return true;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
#include <assimp/Exceptional.h>

// Internal Libraries (BG convention: use <> instead of "")
#include <ERS_STRUCT_Mesh.h>
Expand Down