Skip to content

Commit

Permalink
Merge pull request #368 from carboncopies/364-fix-metalic-maps-not-im…
Browse files Browse the repository at this point in the history
…porting

364 fix metalic maps not importing
  • Loading branch information
datacrystals authored Sep 12, 2022
2 parents 7c0c4de + 4ba0e63 commit ae5e02f
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 27 deletions.
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

0 comments on commit ae5e02f

Please sign in to comment.