Skip to content

Commit

Permalink
Merge pull request #21 from KTStephano/v0.9.1
Browse files Browse the repository at this point in the history
V0.9.1 - Hotfix (old hotfix didn't actually fix it)
  • Loading branch information
KTStephano authored Mar 20, 2023
2 parents a3eb3f3 + 240b1aa commit 22bdb30
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 37 deletions.
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "assimp"]
path = assimp
url = https://github.com/assimp/assimp
[submodule "Catch2"]
path = Catch2
url = https://github.com/catchorg/Catch2.git
Expand All @@ -10,3 +7,6 @@
[submodule "meshoptimizer"]
path = meshoptimizer
url = https://github.com/zeux/meshoptimizer.git
[submodule "assimp"]
path = assimp
url = https://github.com/assimp/assimp.git
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ if (WIN32)
list(APPEND CMAKE_PREFIX_PATH
$ENV{SYSROOT}/cmake
$ENV{SYSROOT}/lib/cmake
$ENV{SYSROOT}/lib/cmake/assimp
$ENV{SYSROOT}/lib/cmake/assimp-5.0
$ENV{SYSROOT}/lib/cmake/Catch2
$ENV{SYSROOT}/lib/cmake/meshoptimizer
Expand Down
4 changes: 2 additions & 2 deletions Examples/ExampleEnv02/Sponza.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ class Sponza : public stratus::Application {

// Disable culling for this model since there are some weird parts that seem to be reversed
//stratus::Async<stratus::Entity> e = stratus::ResourceManager::Instance()->LoadModel("../Resources/glTF-Sample-Models/2.0/Sponza/glTF/Sponza.gltf", stratus::ColorSpace::SRGB, stratus::RenderFaceCulling::CULLING_CCW);
stratus::Async<stratus::Entity> e = stratus::ResourceManager::Instance()->LoadModel("../Resources/Sponza2022/scene.gltf", stratus::ColorSpace::SRGB, stratus::RenderFaceCulling::CULLING_CCW);
stratus::Async<stratus::Entity> e2 = stratus::ResourceManager::Instance()->LoadModel("../Resources/local/Sponza2022/NewSponza_Curtains_glTF.gltf", stratus::ColorSpace::SRGB, stratus::RenderFaceCulling::CULLING_CCW);
stratus::Async<stratus::Entity> e = stratus::ResourceManager::Instance()->LoadModel("../Resources/Sponza2022/scene.gltf", stratus::ColorSpace::SRGB, true, stratus::RenderFaceCulling::CULLING_CCW);
stratus::Async<stratus::Entity> e2 = stratus::ResourceManager::Instance()->LoadModel("../Resources/local/Sponza2022/NewSponza_Curtains_glTF.gltf", stratus::ColorSpace::SRGB, true, stratus::RenderFaceCulling::CULLING_CCW);
requested.push_back(e);
requested.push_back(e2);

Expand Down
2 changes: 1 addition & 1 deletion Examples/ExampleEnv03/Interrogation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class Interrogation : public stratus::Application {
//Input()->AddInputHandler(controller);

// Disable culling for this model since there are some weird parts that seem to be reversed
stratus::Async<stratus::Entity> e = stratus::ResourceManager::Instance()->LoadModel("../Resources/local/InterrogationRoom/scene.gltf", stratus::ColorSpace::SRGB, stratus::RenderFaceCulling::CULLING_NONE);
stratus::Async<stratus::Entity> e = stratus::ResourceManager::Instance()->LoadModel("../Resources/local/InterrogationRoom/scene.gltf", stratus::ColorSpace::SRGB, false, stratus::RenderFaceCulling::CULLING_NONE);
e.AddCallback([this](stratus::Async<stratus::Entity> e) {
interrogationRoom = e.GetPtr();
auto transform = stratus::GetComponent<stratus::LocalTransformComponent>(interrogationRoom);
Expand Down
2 changes: 1 addition & 1 deletion Examples/ExampleEnv04/SanMiguel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class SanMiguel : public stratus::Application {
//Input()->AddInputHandler(controller);

// Disable culling for this model since there are some weird parts that seem to be reversed
stratus::Async<stratus::Entity> e = stratus::ResourceManager::Instance()->LoadModel("../Resources/San_Miguel/san-miguel-low-poly.obj", stratus::ColorSpace::SRGB, stratus::RenderFaceCulling::CULLING_CCW);
stratus::Async<stratus::Entity> e = stratus::ResourceManager::Instance()->LoadModel("../Resources/San_Miguel/san-miguel-low-poly.obj", stratus::ColorSpace::SRGB, true, stratus::RenderFaceCulling::CULLING_CCW);
e.AddCallback([this](stratus::Async<stratus::Entity> e) {
sanMiguel = e.GetPtr();
auto transform = stratus::GetComponent<stratus::LocalTransformComponent>(sanMiguel);
Expand Down
2 changes: 1 addition & 1 deletion Examples/ExampleEnv05/Bistro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ class Bistro : public stratus::Application {

// Disable culling for this model since there are some weird parts that seem to be reversed
//stratus::Async<stratus::Entity> e = stratus::ResourceManager::Instance()->LoadModel("../Resources/Bistro_v5_2/BistroExterior.fbx", stratus::ColorSpace::SRGB, stratus::RenderFaceCulling::CULLING_CCW);
stratus::Async<stratus::Entity> e = stratus::ResourceManager::Instance()->LoadModel("../Resources/BistroGltf/Bistro.gltf", stratus::ColorSpace::SRGB, stratus::RenderFaceCulling::CULLING_CCW);
stratus::Async<stratus::Entity> e = stratus::ResourceManager::Instance()->LoadModel("../Resources/BistroGltf/Bistro.gltf", stratus::ColorSpace::SRGB, true, stratus::RenderFaceCulling::CULLING_CCW);
e.AddCallback([this](stratus::Async<stratus::Entity> e) {
bistro = e.GetPtr();
auto transform = stratus::GetComponent<stratus::LocalTransformComponent>(bistro);
Expand Down
2 changes: 1 addition & 1 deletion Examples/ExampleEnv06/Bathroom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class Bathroom : public stratus::Application {
//Input()->AddInputHandler(controller);

// Disable culling for this model since there are some weird parts that seem to be reversed
stratus::Async<stratus::Entity> e = stratus::ResourceManager::Instance()->LoadModel("../Resources/Bathroom/scene.gltf", stratus::ColorSpace::SRGB, stratus::RenderFaceCulling::CULLING_NONE);
stratus::Async<stratus::Entity> e = stratus::ResourceManager::Instance()->LoadModel("../Resources/Bathroom/scene.gltf", stratus::ColorSpace::SRGB, true, stratus::RenderFaceCulling::CULLING_NONE);
e.AddCallback([this](stratus::Async<stratus::Entity> e) {
bathroom = e.GetPtr();
auto transform = stratus::GetComponent<stratus::LocalTransformComponent>(bathroom);
Expand Down
2 changes: 1 addition & 1 deletion Examples/ExampleEnv07/Warehouse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class Warehouse : public stratus::Application {
//Input()->AddInputHandler(controller);

// Disable culling for this model since there are some weird parts that seem to be reversed
stratus::Async<stratus::Entity> e = stratus::ResourceManager::Instance()->LoadModel("../Resources/Warehouse/scene.gltf", stratus::ColorSpace::SRGB, stratus::RenderFaceCulling::CULLING_NONE);
stratus::Async<stratus::Entity> e = stratus::ResourceManager::Instance()->LoadModel("../Resources/Warehouse/scene.gltf", stratus::ColorSpace::SRGB, true, stratus::RenderFaceCulling::CULLING_NONE);
e.AddCallback([this](stratus::Async<stratus::Entity> e) {
warehouse = e.GetPtr();
auto transform = stratus::GetComponent<stratus::LocalTransformComponent>(warehouse);
Expand Down
50 changes: 27 additions & 23 deletions Source/Engine/StratusResourceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ namespace stratus {
}
}

Async<Entity> ResourceManager::LoadModel(const std::string& name, const ColorSpace& cspace, RenderFaceCulling defaultCullMode) {
Async<Entity> ResourceManager::LoadModel(const std::string& name, const ColorSpace& cspace, const bool optimizeGraph, RenderFaceCulling defaultCullMode) {
{
auto sl = _LockRead();
if (_loadedModels.find(name) != _loadedModels.end()) {
Expand All @@ -148,8 +148,8 @@ namespace stratus {

auto ul = _LockWrite();
TaskSystem * tasks = TaskSystem::Instance();
Async<Entity> e = tasks->ScheduleTask<Entity>([this, name, defaultCullMode, cspace]() {
return _LoadModel(name, cspace, defaultCullMode);
Async<Entity> e = tasks->ScheduleTask<Entity>([this, name, defaultCullMode, optimizeGraph, cspace]() {
return _LoadModel(name, cspace, optimizeGraph, defaultCullMode);
});

_loadedModels.insert(std::make_pair(name, e));
Expand Down Expand Up @@ -440,33 +440,37 @@ namespace stratus {
}
}

EntityPtr ResourceManager::_LoadModel(const std::string& name, const ColorSpace& cspace, RenderFaceCulling defaultCullMode) {
EntityPtr ResourceManager::_LoadModel(const std::string& name, const ColorSpace& cspace, const bool optimizeGraph, RenderFaceCulling defaultCullMode) {
STRATUS_LOG << "Attempting to load model: " << name << std::endl;

Assimp::Importer importer;
//importer.SetPropertyInteger(AI_CONFIG_PP_SLM_VERTEX_LIMIT, 16000);
importer.SetPropertyInteger(AI_CONFIG_PP_SLM_TRIANGLE_LIMIT, 4000);

unsigned int pflags = aiProcess_Triangulate |
aiProcess_JoinIdenticalVertices |
aiProcess_SortByPType |
aiProcess_GenNormals |
//aiProcess_GenSmoothNormals |
aiProcess_FlipUVs |
aiProcess_GenUVCoords |
aiProcess_CalcTangentSpace |
aiProcess_SplitLargeMeshes |
aiProcess_ImproveCacheLocality |
aiProcess_OptimizeMeshes |
//aiProcess_OptimizeGraph |
//aiProcess_FixInfacingNormals |
aiProcess_FindDegenerates |
aiProcess_FindInvalidData |
aiProcess_FindInstances;

if (optimizeGraph) {
pflags |= aiProcess_OptimizeGraph;
}

//const aiScene *scene = importer.ReadFile(filename, aiProcess_Triangulate | aiProcess_FlipUVs | aiProcess_CalcTangentSpace | aiProcess_GenNormals | aiProcess_GenUVCoords);
//const aiScene *scene = importer.ReadFile(filename, aiProcess_Triangulate | aiProcess_GenSmoothNormals | aiProcess_FlipUVs | aiProcess_CalcTangentSpace | aiProcess_OptimizeMeshes);
const aiScene *scene = importer.ReadFile(name, aiProcess_Triangulate |
aiProcess_JoinIdenticalVertices |
aiProcess_SortByPType |
aiProcess_GenNormals |
//aiProcess_GenSmoothNormals |
aiProcess_FlipUVs |
aiProcess_GenUVCoords |
aiProcess_CalcTangentSpace |
aiProcess_SplitLargeMeshes |
aiProcess_ImproveCacheLocality |
aiProcess_OptimizeMeshes |
//aiProcess_OptimizeGraph |
//aiProcess_FixInfacingNormals |
aiProcess_FindDegenerates |
aiProcess_FindInvalidData |
aiProcess_FindInstances
//aiProcess_PreTransformVertices
// aiProcess_FlipWindingOrder
);
const aiScene *scene = importer.ReadFile(name, pflags);

auto material = MaterialManager::Instance()->CreateMaterial(name);

Expand Down
4 changes: 2 additions & 2 deletions Source/Engine/StratusResourceManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace stratus {

virtual ~ResourceManager();

Async<Entity> LoadModel(const std::string&, const ColorSpace&, RenderFaceCulling defaultCullMode = RenderFaceCulling::CULLING_CCW);
Async<Entity> LoadModel(const std::string&, const ColorSpace&, const bool optimizeGraph, RenderFaceCulling defaultCullMode = RenderFaceCulling::CULLING_CCW);
TextureHandle LoadTexture(const std::string&, const ColorSpace&);
// prefix is used to select all faces with one string. It ends up expanding to:
// prefix + "right." + fileExt
Expand Down Expand Up @@ -68,7 +68,7 @@ namespace stratus {
private:
std::unique_lock<std::shared_mutex> _LockWrite() const { return std::unique_lock<std::shared_mutex>(_mutex); }
std::shared_lock<std::shared_mutex> _LockRead() const { return std::shared_lock<std::shared_mutex>(_mutex); }
EntityPtr _LoadModel(const std::string&, const ColorSpace&, RenderFaceCulling);
EntityPtr _LoadModel(const std::string&, const ColorSpace&, const bool optimizeGraph, RenderFaceCulling);
// Despite accepting multiple files, it assumes they all have the same format (e.g. for cube texture)
TextureHandle _LoadTextureImpl(const std::vector<std::string>&,
const ColorSpace&,
Expand Down
2 changes: 1 addition & 1 deletion assimp
Submodule assimp updated 1259 files

0 comments on commit 22bdb30

Please sign in to comment.