WIP Rewrite flow from compiling to loading to recognising assets

This commit is contained in:
Xiao Qi 2022-11-01 20:54:51 +08:00
parent 2a31ea6798
commit e2778da955
7 changed files with 40 additions and 34 deletions

View File

@ -7,7 +7,7 @@ echo "SHADE DEPENDENCIES (Default - All in 10 Seconds)"
echo "A - All" echo "A - All"
echo "B - VMA" echo "B - VMA"
echo "C - msdf" echo "C - msdf"
echo "D - assimp" echo "D - ModelCompiler"
echo "E - spdlog" echo "E - spdlog"
echo "F - reactphysics3d" echo "F - reactphysics3d"
echo "G - imgui" echo "G - imgui"
@ -29,7 +29,7 @@ set _e=%ERRORLEVEL%
if %_e%==1 goto VMA if %_e%==1 goto VMA
if %_e%==2 goto VMA if %_e%==2 goto VMA
if %_e%==3 goto MSDF if %_e%==3 goto MSDF
if %_e%==4 goto assimp if %_e%==4 goto ModelCompiler
if %_e%==5 goto spdlog if %_e%==5 goto spdlog
if %_e%==6 goto reactphysics3d if %_e%==6 goto reactphysics3d
if %_e%==7 goto imgui if %_e%==7 goto imgui
@ -53,12 +53,13 @@ if %_e%==2 (goto :done) else (goto :MSDF)
echo -----------------------MSDF---------------------------- echo -----------------------MSDF----------------------------
rmdir "Dependencies/msdf" /S /Q rmdir "Dependencies/msdf" /S /Q
git clone --recurse-submodules https://github.com/SHADE-DP/msdf-atlas-gen.git "Dependencies/msdf" git clone --recurse-submodules https://github.com/SHADE-DP/msdf-atlas-gen.git "Dependencies/msdf"
if %_e%==3 (goto :done) else (goto :assimp) if %_e%==3 (goto :done) else (goto :ModelCompiler)
:assimp :ModelCompiler
echo -----------------------assimp---------------------------- echo -----------------------ModelCompiler----------------------------
rmdir "Dependencies/assimp" /S /Q rmdir "Dependencies/ModelCompiler" /S /Q
git clone https://github.com/SHADE-DP/assimp.git "Dependencies/assimp" git clone https://github.com/SHADE-DP/ModelCompiler.git "Dependencies/ModelCompiler"
Dependencies/ModelCompiler/Dependencies.bat
if %_e%==4 (goto :done) else (goto :spdlog) if %_e%==4 (goto :done) else (goto :spdlog)
@REM :ktx @REM :ktx

View File

@ -1,5 +1,5 @@
IncludeDir = {} IncludeDir = {}
IncludeDir["assimp"] = "%{wks.location}\\Dependencies\\assimp" IncludeDir["ModelCompiler"] = "%{wks.location}\\Dependencies\\ModelCompiler"
IncludeDir["imgui"] = "%{wks.location}\\Dependencies\\imgui" IncludeDir["imgui"] = "%{wks.location}\\Dependencies\\imgui"
IncludeDir["imguizmo"] = "%{wks.location}\\Dependencies\\imguizmo" IncludeDir["imguizmo"] = "%{wks.location}\\Dependencies\\imguizmo"
IncludeDir["imnodes"] = "%{wks.location}\\Dependencies\\imnodes" IncludeDir["imnodes"] = "%{wks.location}\\Dependencies\\imnodes"

View File

@ -26,7 +26,6 @@ project "SHADE_Engine"
externalincludedirs externalincludedirs
{ {
"%{IncludeDir.assimp}\\include",
"%{IncludeDir.imgui}", "%{IncludeDir.imgui}",
"%{IncludeDir.imguizmo}", "%{IncludeDir.imguizmo}",
"%{IncludeDir.imnodes}", "%{IncludeDir.imnodes}",
@ -52,8 +51,6 @@ project "SHADE_Engine"
{ {
"%{prj.location}/libs", "%{prj.location}/libs",
"%{IncludeDir.VULKAN}/Lib", "%{IncludeDir.VULKAN}/Lib",
"%{IncludeDir.assimp}/lib/Debug",
"%{IncludeDir.assimp}/lib/Release",
"%{IncludeDir.RTTR}/lib", "%{IncludeDir.RTTR}/lib",
"%{IncludeDir.SDL}/lib", "%{IncludeDir.SDL}/lib",
"%{IncludeDir.spdlog}/lib", "%{IncludeDir.spdlog}/lib",
@ -119,7 +116,7 @@ project "SHADE_Engine"
filter "configurations:Debug" filter "configurations:Debug"
postbuildcommands postbuildcommands
{ {
"xcopy /r /y /q \"%{IncludeDir.assimp}\\bin\\Debug\\assimp-vc142-mtd.dll\" \"$(OutDir)\"", --"xcopy /r /y /q \"%{IncludeDir.assimp}\\bin\\Debug\\assimp-vc142-mtd.dll\" \"$(OutDir)\"",
"xcopy /r /y /q \"%{IncludeDir.fmod}\\lib\\fmodL.dll\" \"$(OutDir)\"", "xcopy /r /y /q \"%{IncludeDir.fmod}\\lib\\fmodL.dll\" \"$(OutDir)\"",
"xcopy /r /y /q \"%{IncludeDir.fmod}\\lib\\fmodstudioL.dll\" \"$(OutDir)\"" "xcopy /r /y /q \"%{IncludeDir.fmod}\\lib\\fmodstudioL.dll\" \"$(OutDir)\""
} }
@ -127,7 +124,7 @@ project "SHADE_Engine"
filter "configurations:Release" filter "configurations:Release"
postbuildcommands postbuildcommands
{ {
"xcopy /r /y /q \"%{IncludeDir.assimp}\\bin\\Release\\assimp-vc142-mt.dll\" \"$(OutDir)\"", --"xcopy /r /y /q \"%{IncludeDir.assimp}\\bin\\Release\\assimp-vc142-mt.dll\" \"$(OutDir)\"",
"xcopy /r /y /q \"%{IncludeDir.fmod}\\lib\\fmod.dll\" \"$(OutDir)\"", "xcopy /r /y /q \"%{IncludeDir.fmod}\\lib\\fmod.dll\" \"$(OutDir)\"",
"xcopy /r /y /q \"%{IncludeDir.fmod}\\lib\\fmodstudio.dll\" \"$(OutDir)\"" "xcopy /r /y /q \"%{IncludeDir.fmod}\\lib\\fmodstudio.dll\" \"$(OutDir)\""
} }
@ -135,32 +132,35 @@ project "SHADE_Engine"
filter "configurations:Publish" filter "configurations:Publish"
postbuildcommands postbuildcommands
{ {
"xcopy /r /y /q \"%{IncludeDir.assimp}\\bin\\Release\\assimp-vc142-mt.dll\" \"$(OutDir)\"", --"xcopy /r /y /q \"%{IncludeDir.assimp}\\bin\\Release\\assimp-vc142-mt.dll\" \"$(OutDir)\"",
"xcopy /r /y /q \"%{IncludeDir.fmod}\\lib\\fmod.dll\" \"$(OutDir)\"", "xcopy /r /y /q \"%{IncludeDir.fmod}\\lib\\fmod.dll\" \"$(OutDir)\"",
"xcopy /r /y /q \"%{IncludeDir.fmod}\\lib\\fmodstudio.dll\" \"$(OutDir)\"" "xcopy /r /y /q \"%{IncludeDir.fmod}\\lib\\fmodstudio.dll\" \"$(OutDir)\""
} }
filter "configurations:Publish" filter "configurations:Publish"
postbuildcommands {"xcopy /r /y /q \"%{IncludeDir.assimp}\\bin\\Release\\assimp-vc142-mt.dll\" \"$(OutDir)\""} postbuildcommands
{
--"xcopy /r /y /q \"%{IncludeDir.assimp}\\bin\\Release\\assimp-vc142-mt.dll\" \"$(OutDir)\""
}
warnings 'Extra' warnings 'Extra'
filter "configurations:Debug" filter "configurations:Debug"
symbols "On" symbols "On"
defines {"_DEBUG", "SHEDITOR"} defines {"_DEBUG", "SHEDITOR"}
links{"assimp-vc142-mtd.lib", "librttr_core_d.lib", "spdlogd.lib"} links{"librttr_core_d.lib", "spdlogd.lib"}
links{"fmodstudioL_vc.lib", "fmodL_vc.lib"} links{"fmodstudioL_vc.lib", "fmodL_vc.lib"}
filter "configurations:Release" filter "configurations:Release"
optimize "On" optimize "On"
defines{"_RELEASE", "SHEDITOR"} defines{"_RELEASE", "SHEDITOR"}
links{"assimp-vc142-mt.lib", "librttr_core.lib", "spdlog.lib"} links{"librttr_core.lib", "spdlog.lib"}
links{"fmodstudio_vc.lib", "fmod_vc.lib"} links{"fmodstudio_vc.lib", "fmod_vc.lib"}
filter "configurations:Publish" filter "configurations:Publish"
optimize "On" optimize "On"
defines{"_RELEASE", "_PUBLISH"} defines{"_RELEASE", "_PUBLISH"}
links{"assimp-vc142-mt.lib", "librttr_core.lib", "spdlog.lib"} links{"librttr_core.lib", "spdlog.lib"}
excludes excludes
{ {
-- "%{prj.location}/src/Editor/**.cpp", -- "%{prj.location}/src/Editor/**.cpp",

View File

@ -63,6 +63,9 @@ constexpr std::string_view ASSET_ROOT {"../../Assets"};
constexpr std::string_view BUILT_IN_ASSET_ROOT{ "../../Built_In" }; constexpr std::string_view BUILT_IN_ASSET_ROOT{ "../../Built_In" };
#endif #endif
// COMPILER PATHS
constexpr std::string_view MODEL_COMPILER_EXE{ "ModelCompiler.exe" };
// INTERNAL ASSET PATHS // INTERNAL ASSET PATHS
constexpr std::string_view SCENE_FOLDER{ "/Scenes/" }; constexpr std::string_view SCENE_FOLDER{ "/Scenes/" };
constexpr std::string_view PREFAB_FOLDER{ "/Prefabs/" }; constexpr std::string_view PREFAB_FOLDER{ "/Prefabs/" };

View File

@ -11,6 +11,8 @@
#include <random> #include <random>
#include <chrono> #include <chrono>
#include <ranges> #include <ranges>
#include <cstdlib>
#include "SHAssetManager.h" #include "SHAssetManager.h"
#include "SHAssetMetaHandler.h" #include "SHAssetMetaHandler.h"
@ -19,7 +21,7 @@
#include "Libraries/Loaders/SHShaderSourceLoader.h" #include "Libraries/Loaders/SHShaderSourceLoader.h"
#include "Libraries/Loaders/SHTextBasedLoader.h" #include "Libraries/Loaders/SHTextBasedLoader.h"
#include "Libraries/Compilers/SHMeshCompiler.h" //#include "Libraries/Compilers/SHMeshCompiler.h"
#include "Libraries/Compilers/SHTextureCompiler.h" #include "Libraries/Compilers/SHTextureCompiler.h"
#include "Libraries/Compilers/SHShaderSourceCompiler.h" #include "Libraries/Compilers/SHShaderSourceCompiler.h"
@ -413,22 +415,15 @@ namespace SHADE
} }
else if (ext == GLTF_EXTENSION.data() || ext == FBX_EXTENSION.data()) else if (ext == GLTF_EXTENSION.data() || ext == FBX_EXTENSION.data())
{ {
std::vector<SHMeshAsset*> meshes; std::string command = MODEL_COMPILER_EXE.data();
std::vector<SHAnimationAsset*> anims; command += " " + path.string();
SHMeshCompiler::LoadFromFile(path, meshes, anims); std::system(command.c_str());
for (auto const& mesh : meshes) std::string newPath = path.string().substr(0, path.string().find_last_of('.'));
{ newPath += MESH_EXTENSION;
SHAsset meshAsset{ newAsset.path = newPath;
.name = mesh->header.name newAsset.id = GenerateAssetID(AssetType::MESH);
}; newAsset.type = AssetType::MESH;
meshAsset.path = SHMeshCompiler::CompileMeshBinary(*mesh, path).value();
meshAsset.id = GenerateAssetID(AssetType::MESH);
meshAsset.type = AssetType::MESH;
assetCollection.insert({ meshAsset.id, meshAsset });
SHAssetMetaHandler::WriteMetaData(meshAsset);
}
continue;
} }
assetCollection.insert({ newAsset.id, newAsset }); assetCollection.insert({ newAsset.id, newAsset });
@ -492,6 +487,11 @@ namespace SHADE
return data; return data;
} }
void SHAssetManager::LoadDataFromScratch(AssetPath path) noexcept
{
}
void SHAssetManager::BuildAssetCollection() noexcept void SHAssetManager::BuildAssetCollection() noexcept
{ {
SHFileSystem::BuildDirectory(ASSET_ROOT.data(), folderRoot, assetCollection); SHFileSystem::BuildDirectory(ASSET_ROOT.data(), folderRoot, assetCollection);

View File

@ -96,6 +96,7 @@ namespace SHADE
static void InitLoaders() noexcept; static void InitLoaders() noexcept;
static void LoadAllData() noexcept; static void LoadAllData() noexcept;
static SHAssetData* LoadData(SHAsset const& asset) noexcept; static SHAssetData* LoadData(SHAsset const& asset) noexcept;
static void LoadDataFromScratch(AssetPath path) noexcept;
inline static void BuildAssetCollection() noexcept; inline static void BuildAssetCollection() noexcept;
static bool IsRecognised(char const*) noexcept; static bool IsRecognised(char const*) noexcept;

View File

@ -30,4 +30,5 @@ workspace "SHADE"
--include "Dependencies/tracy" --include "Dependencies/tracy"
include "Dependencies/yamlcpp" include "Dependencies/yamlcpp"
include "Dependencies/reactphysics3d" include "Dependencies/reactphysics3d"
include "Dependencies/ModelCompiler"
group "" group ""