From 211c69499dff9981f6aec912ce7584e2e13e904d Mon Sep 17 00:00:00 2001 From: fiplox Date: Mon, 21 Mar 2022 10:35:38 +0100 Subject: [PATCH 1/3] Linux fix paths --- TerraForge3D/include/Platform.h | 6 +- TerraForge3D/src/Base/Logging/Logger.cpp | 4 +- TerraForge3D/src/Data/ProjectData.cpp | 14 +-- TerraForge3D/src/Data/Serializer.cpp | 52 ++++++--- .../src/Filters/AdvancedErosionFilter.cpp | 8 +- TerraForge3D/src/Filters/GPUErosionFilter.cpp | 3 +- TerraForge3D/src/Foliage/FoliagePlacement.cpp | 13 ++- .../CPUNodeEditor/CPUNodeEditor.cpp | 5 +- .../CPUNodeEditor/Nodes/TextureNode.cpp | 7 +- .../src/Generators/MeshGeneratorManager.cpp | 3 +- TerraForge3D/src/Main.cpp | 104 +++++++++--------- TerraForge3D/src/Menu/MainMenu.cpp | 5 +- TerraForge3D/src/Misc/SupportersTribute.cpp | 44 +++++--- TerraForge3D/src/Modules/ModuleManager.cpp | 12 +- TerraForge3D/src/Sea/SeaManager.cpp | 14 +-- .../Shading/ShaderNodes/ShaderTextureNode.cpp | 6 +- TerraForge3D/src/Shading/ShadingManager.cpp | 6 +- TerraForge3D/src/Sky/CubeMap.cpp | 20 ++-- .../src/TextureStore/TextureStore.cpp | 66 ++++++----- TerraForge3D/src/Utils/Utils.cpp | 1 + 20 files changed, 221 insertions(+), 172 deletions(-) diff --git a/TerraForge3D/include/Platform.h b/TerraForge3D/include/Platform.h index 6d4fc19d70..686bf6e014 100644 --- a/TerraForge3D/include/Platform.h +++ b/TerraForge3D/include/Platform.h @@ -2,10 +2,10 @@ #ifdef TERR3D_WIN32 -#define PATH_SEPERATOR "\\" +#define PATH_SEPARATOR "\\" #else -#define PATH_SEPERATOR "/" +#define PATH_SEPARATOR "/" -#endif \ No newline at end of file +#endif diff --git a/TerraForge3D/src/Base/Logging/Logger.cpp b/TerraForge3D/src/Base/Logging/Logger.cpp index ac8ba0ef97..839e27e537 100644 --- a/TerraForge3D/src/Base/Logging/Logger.cpp +++ b/TerraForge3D/src/Base/Logging/Logger.cpp @@ -14,10 +14,10 @@ Logger::Logger(std::string logsDir) strftime(buffer, sizeof(buffer), "%A %d-%m-%Y %I-%M-%S %p", timeinfo); std::string str(buffer); str += ".txt"; - mLogHandler = new LoggingOutputStreambuf(std::cout, logsDir + PATH_SEPERATOR + str); + mLogHandler = new LoggingOutputStreambuf(std::cout, logsDir + PATH_SEPARATOR + str); } Logger::~Logger() { delete mLogHandler; -} \ No newline at end of file +} diff --git a/TerraForge3D/src/Data/ProjectData.cpp b/TerraForge3D/src/Data/ProjectData.cpp index a8cf03c125..c25d2f33ac 100644 --- a/TerraForge3D/src/Data/ProjectData.cpp +++ b/TerraForge3D/src/Data/ProjectData.cpp @@ -1,10 +1,10 @@ #include "Data/ProjectData.h" #include "Data/ApplicationState.h" #include "Utils/Utils.h" +#include "Platform.h" #include -#include "Platform.h" ProjectManager *ProjectManager::s_ProjectManager; @@ -81,12 +81,12 @@ void ProjectManager::SaveDatabase() MkDir(GetResourcePath()); } - SaveToFile(GetResourcePath() + PATH_SEPERATOR "project_database.terr3d", projectDatase.dump()); + SaveToFile(GetResourcePath() + PATH_SEPARATOR "project_database.terr3d", projectDatase.dump()); } std::string ProjectManager::GetResourcePath() { - return GetExecutableDir() + PATH_SEPERATOR "Data" PATH_SEPERATOR "cache" PATH_SEPERATOR "project_data" PATH_SEPERATOR "project_" + GetId(); + return GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "cache" PATH_SEPARATOR "project_data" PATH_SEPARATOR "project_" + GetId(); } std::string ProjectManager::SaveTexture(Texture2D *texture) @@ -102,10 +102,10 @@ std::string ProjectManager::SaveTexture(Texture2D *texture) if (GetAsset(hash).size() <= 0) { - MkDir(GetResourcePath() + PATH_SEPERATOR "textures"); - CopyFileData(path, GetResourcePath() + PATH_SEPERATOR "textures" PATH_SEPERATOR + hash); - RegisterAsset(hash, "textures" PATH_SEPERATOR + hash); + MkDir(GetResourcePath() + PATH_SEPARATOR "textures"); + CopyFileData(path, GetResourcePath() + PATH_SEPARATOR "textures" PATH_SEPARATOR + hash); + RegisterAsset(hash, "textures" PATH_SEPARATOR + hash); } return hash; -} \ No newline at end of file +} diff --git a/TerraForge3D/src/Data/Serializer.cpp b/TerraForge3D/src/Data/Serializer.cpp index f6773c3cd5..c06cf5901c 100644 --- a/TerraForge3D/src/Data/Serializer.cpp +++ b/TerraForge3D/src/Data/Serializer.cpp @@ -6,6 +6,7 @@ #include "Data/ApplicationState.h" #include "Misc/AppStyles.h" #include "Shading/ShadingManager.h" +#include "Platform.h" #ifdef TERR3D_WIN32 #include "dirent/dirent.h" @@ -46,7 +47,7 @@ static void zip_walk(struct zip_t *zip, const char *path, bool isFristLayer = tr if (S_ISDIR(s.st_mode)) { - zip_walk(zip, fullpath, false, prevPath + entry->d_name + "\\"); + zip_walk(zip, fullpath, false, prevPath + entry->d_name + PATH_SEPARATOR); } else @@ -116,9 +117,9 @@ nlohmann::json Serializer::Serialize() if (projectAsset == "") { - MkDir(appState->projectManager->GetResourcePath() + "\\models"); - CopyFileData(appState->globals.currentBaseModelPath, appState->projectManager->GetResourcePath() + "\\models\\" + baseHash + appState->globals.currentBaseModelPath.substr(appState->globals.currentBaseModelPath.find_last_of("."))); - appState->projectManager->RegisterAsset(baseHash, "models\\" + baseHash + appState->globals.currentBaseModelPath.substr(appState->globals.currentBaseModelPath.find_last_of("."))); + MkDir(appState->projectManager->GetResourcePath() + PATH_SEPARATOR "models"); + CopyFileData(appState->globals.currentBaseModelPath, appState->projectManager->GetResourcePath() + PATH_SEPARATOR "models" + PATH_SEPARATOR + baseHash + appState->globals.currentBaseModelPath.substr(appState->globals.currentBaseModelPath.find_last_of("."))); + appState->projectManager->RegisterAsset(baseHash, "models" + PATH_SEPARATOR + baseHash + appState->globals.currentBaseModelPath.substr(appState->globals.currentBaseModelPath.find_last_of("."))); } data["baseid"] = baseHash; @@ -137,12 +138,12 @@ void Serializer::PackProject(std::string path) Serialize(); std::ofstream outfile; - outfile.open(appState->projectManager->GetResourcePath() + "\\project.terr3d"); + outfile.open(appState->projectManager->GetResourcePath() + PATH_SEPARATOR "project.terr3d"); outfile << data.dump(4, ' ', false); outfile.close(); - MkDir(GetExecutableDir() + "\\Data\\temp"); + MkDir(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "temp"); std::string uid = GenerateId(64); - SaveFile(GetExecutableDir() + "\\Data\\temp\\" + uid); + SaveFile(GetExecutableDir() + "Data" + PATH_SEPARATOR "temp" + PATH_SEPARATOR + uid); zip_t *packed = zip_open(path.c_str(), 9, 'w'); zip_walk(packed, appState->projectManager->GetResourcePath().c_str()); zip_close(packed); @@ -156,16 +157,24 @@ void Serializer::LoadPackedProject(std::string path) } std::string uid = GenerateId(64); - MkDir(GetExecutableDir() + "\\Data\\temp\\pcache_" + uid); - zip_extract(path.c_str(), (GetExecutableDir() + "\\Data\\temp\\pcache_" + uid).c_str(), [](const char *filename, void *arg) + MkDir(GetExecutableDir() + PATH_SEPARATOR "Data" + PATH_SEPARATOR + + "temp" PATH_SEPARATOR "pcache_" + uid); + zip_extract(path.c_str(), (GetExecutableDir() + PATH_SEPARATOR "Data" + + PATH_SEPARATOR "temp" PATH_SEPARATOR "pcache_" + + uid).c_str(), [](const char *filename, void *arg) { return 1; }, (void *)0); - if (FileExists(GetExecutableDir() + "\\Data\\temp\\pcache_" + uid + "\\project.terr3d", true)) + if (FileExists(GetExecutableDir() + PATH_SEPARATOR "Data" + + PATH_SEPARATOR "temp" PATH_SEPARATOR "pcache_" + uid + + PATH_SEPARATOR "project.terr3d", true)) { bool tmp = false; - std::string sdata = ReadShaderSourceFile(GetExecutableDir() + "\\Data\\temp\\pcache_" + uid + "\\project.terr3d", &tmp); + std::string sdata = ReadShaderSourceFile(GetExecutableDir() + + PATH_SEPARATOR "Data" PATH_SEPARATOR "temp" + + PATH_SEPARATOR "pcache_" + uid + PATH_SEPARATOR + + "project.terr3d", &tmp); if (sdata.size() <= 0) { @@ -187,15 +196,22 @@ void Serializer::LoadPackedProject(std::string path) } std::string projId = data["projectID"]; - zip_extract(path.c_str(), (GetExecutableDir() + "\\Data\\cache\\project_data\\project_" + projId).c_str(), [](const char *filename, void *arg) + zip_extract(path.c_str(), (GetExecutableDir() + PATH_SEPARATOR "Data" + + PATH_SEPARATOR "cache" + PATH_SEPARATOR + + "project_data" PATH_SEPARATOR "project_" + + projId).c_str(), [](const char *filename, void *arg) { Log(std::string("Extracted ") + filename); return 1; }, (void *)0); - std::string oriDir = path.substr(0, path.rfind("\\")); - std::string oriName = path.substr(path.rfind("\\") + 1); - CopyFileData((GetExecutableDir() + "\\Data\\cache\\project_data\\project_" + projId + "\\project.terr3d").c_str(), oriDir + "\\" + oriName + ".terr3d"); - LoadFile(oriDir + "\\" + oriName + ".terr3d"); + std::string oriDir = path.substr(0, path.rfind(PATH_SEPARATOR)); + std::string oriName = path.substr(path.rfind(PATH_SEPARATOR) + 1); + CopyFileData((GetExecutableDir() + PATH_SEPARATOR "Data" + + PATH_SEPARATOR "cache" + PATH_SEPARATOR + + + "project_data" PATH_SEPARATOR "project_" + projId + + PATH_SEPARATOR "project.terr3d").c_str(), oriDir + + PATH_SEPARATOR + oriName + ".terr3d"); + LoadFile(oriDir + PATH_SEPARATOR + oriName + ".terr3d"); } else @@ -223,7 +239,7 @@ void Serializer::SaveFile(std::string path) Serialize(); std::ofstream outfile; - outfile.open(appState->projectManager->GetResourcePath() + "\\project.terr3d"); + outfile.open(appState->projectManager->GetResourcePath() + PATH_SEPARATOR "project.terr3d"); outfile << data.dump(4, ' ', false); outfile.close(); outfile.open(path); @@ -356,7 +372,7 @@ ApplicationState *Serializer::Deserialize(nlohmann::json d) delete appState->models.customBaseCopy; } - appState->globals.currentBaseModelPath = appState->projectManager->GetResourcePath() + "\\" + projectAsset; + appState->globals.currentBaseModelPath = appState->projectManager->GetResourcePath() + PATH_SEPARATOR + projectAsset; appState->models.customBase = LoadModel(appState->globals.currentBaseModelPath); appState->models.customBaseCopy = LoadModel(appState->globals.currentBaseModelPath); appState->states.usingBase = false; diff --git a/TerraForge3D/src/Filters/AdvancedErosionFilter.cpp b/TerraForge3D/src/Filters/AdvancedErosionFilter.cpp index 3d266b5750..f1de3bbc78 100644 --- a/TerraForge3D/src/Filters/AdvancedErosionFilter.cpp +++ b/TerraForge3D/src/Filters/AdvancedErosionFilter.cpp @@ -4,6 +4,7 @@ #include "Data/ApplicationState.h" #include "Utils/Utils.h" +#include "Platform.h" #include #include @@ -72,12 +73,15 @@ void AdvancedErosionFilter::Apply() localWorkSize = 1; } - std::string kernelSrc = ReadShaderSourceFile(GetExecutableDir() + "\\Data\\kernels\\advanced_erosion.cl", &tmp); + std::string kernelSrc = ReadShaderSourceFile(GetExecutableDir() + + PATH_SEPARATOR "Data" PATH_SEPARATOR "kernels" + + PATH_SEPARATOR "advanced_erosion.cl", &tmp); // Some constants kernelSrc = std::regex_replace(kernelSrc, std::regex("LOCAL_WORK_SIZE"), std::to_string(localWorkSize)); kernels.Clear(); kernels.AddSoruce(kernelSrc); - kernels.BuildProgram("-I\"" + GetExecutableDir() + "\\Data\\kernels" + "\""); + kernels.BuildProgram("-I\"" + GetExecutableDir() + PATH_SEPARATOR + + "Data" PATH_SEPARATOR "kernels" + "\""); kernels.AddKernel("erode"); kernels.CreateBuffer("mesh", CL_MEM_READ_WRITE, sizeof(Vert) * model->mesh->vertexCount); kernels.WriteBuffer("mesh", true, sizeof(Vert) * model->mesh->vertexCount, model->mesh->vert); diff --git a/TerraForge3D/src/Filters/GPUErosionFilter.cpp b/TerraForge3D/src/Filters/GPUErosionFilter.cpp index 19fe264bb8..e4b7556340 100644 --- a/TerraForge3D/src/Filters/GPUErosionFilter.cpp +++ b/TerraForge3D/src/Filters/GPUErosionFilter.cpp @@ -3,6 +3,7 @@ #include #include "Data/ApplicationState.h" +#include "Platform.h" #include #include @@ -80,7 +81,7 @@ void GPUErosionFilter::Apply() mapSize = model->mesh->res; mapSize = MAX(0, mapSize - 2 * erosionBrushRadius); bool tmp = false; - std::string shaderSrc = ReadShaderSourceFile(GetExecutableDir() + "\\Data\\compute\\erosion.glsl", &tmp); + std::string shaderSrc = ReadShaderSourceFile(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "compute" PATH_SEPARATOR "erosion.glsl", &tmp); shaderSrc = std::regex_replace(shaderSrc, std::regex("LAYOUT_SIZE_X"), std::to_string(1024)); //shaderSrc = std::regex_replace(shaderSrc, std::regex("LAYOUT_SIZE_X"), std::to_string(1)); shaderSrc = std::regex_replace(shaderSrc, std::regex("LAYOUT_SIZE_Y"), std::to_string(1)); diff --git a/TerraForge3D/src/Foliage/FoliagePlacement.cpp b/TerraForge3D/src/Foliage/FoliagePlacement.cpp index ceb8b3926f..1a86660b17 100644 --- a/TerraForge3D/src/Foliage/FoliagePlacement.cpp +++ b/TerraForge3D/src/Foliage/FoliagePlacement.cpp @@ -5,6 +5,7 @@ #include "Base/Texture2D.h" #include "Data/ProjectData.h" #include "Data/ApplicationState.h" +#include "Platform.h" #include #include @@ -139,8 +140,8 @@ void FoliageManager::ShowSettings(bool *pOpen) if(path.size() > 3) { - foliageItems.push_back(new FoliageItem(appState->constants.texturesDir + "\\white.png")); - foliageItems.back()->name = path.substr(path.find("\\") + 1); + foliageItems.push_back(new FoliageItem(appState->constants.texturesDir + PATH_SEPARATOR "white.png")); + foliageItems.back()->name = path.substr(path.find(PATH_SEPARATOR) + 1); foliageItems.back()->model = LoadModel(path); foliageItems.back()->model->SetupMeshOnGPU(); foliageItems.back()->model->UploadToGPU(); @@ -156,9 +157,9 @@ void FoliageManager::ShowSettings(bool *pOpen) { delete appState->shaders.foliage; bool res = false; - appState->shaders.foliage = new Shader(ReadShaderSourceFile(appState->constants.shadersDir + "\\foliage\\vert.glsl", &res), - ReadShaderSourceFile(appState->constants.shadersDir + "\\foliage\\frag.glsl", &res), - ReadShaderSourceFile(appState->constants.shadersDir + "\\foliage\\geom.glsl", &res)); + appState->shaders.foliage = new Shader(ReadShaderSourceFile(appState->constants.shadersDir + PATH_SEPARATOR "foliage" PATH_SEPARATOR "vert.glsl", &res), + ReadShaderSourceFile(appState->constants.shadersDir + PATH_SEPARATOR "foliage" PATH_SEPARATOR "frag.glsl", &res), + ReadShaderSourceFile(appState->constants.shadersDir + PATH_SEPARATOR "foliage" PATH_SEPARATOR "geom.glsl", &res)); } ImGui::End(); @@ -198,4 +199,4 @@ nlohmann::json FoliageManager::Save() void FoliageManager::Load(nlohmann::json data) { Log("Foliage Manager does not support Save/Load yet!"); -} \ No newline at end of file +} diff --git a/TerraForge3D/src/Generators/CPUNodeEditor/CPUNodeEditor.cpp b/TerraForge3D/src/Generators/CPUNodeEditor/CPUNodeEditor.cpp index 4284272ba4..230f8cda1e 100644 --- a/TerraForge3D/src/Generators/CPUNodeEditor/CPUNodeEditor.cpp +++ b/TerraForge3D/src/Generators/CPUNodeEditor/CPUNodeEditor.cpp @@ -3,6 +3,7 @@ #include "Data/ApplicationState.h" #include "Profiler.h" #include "Utils/Utils.h" +#include "Platform.h" #include "imgui.h" #include "Base/ImGuiShapes.h" @@ -134,7 +135,7 @@ CPUNodeEditor::CPUNodeEditor(ApplicationState *as) name.reserve(1024); name = "CPU Node Editor " + std::to_string(count++); NodeEditorConfig config; - config.saveFile = GetExecutableDir() + "\\Data\\configs\\CPUNodeEditorconfigs.terr3d"; + config.saveFile = GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "configs" PATH_SEPARATOR "CPUNodeEditorconfigs.terr3d"; config.makeNodeFunc = [&]() { ImGuiNodeEditor::Suspend(); @@ -413,4 +414,4 @@ void CPUNodeEditor::ShowSetting(int id) ImGui::Text("UID : %s", uid.data()); ImGui::Text("Time : %lf ms", time); -} \ No newline at end of file +} diff --git a/TerraForge3D/src/Generators/CPUNodeEditor/Nodes/TextureNode.cpp b/TerraForge3D/src/Generators/CPUNodeEditor/Nodes/TextureNode.cpp index 9490d18df6..6d1dd809c8 100644 --- a/TerraForge3D/src/Generators/CPUNodeEditor/Nodes/TextureNode.cpp +++ b/TerraForge3D/src/Generators/CPUNodeEditor/Nodes/TextureNode.cpp @@ -9,6 +9,7 @@ #include #include #include "Base/ImGuiCurveEditor.h" +#include "Platform.h" #define CLAMP01(x) x > 1 ? 1 : ( x < 0 ? 0 : x ) @@ -130,7 +131,7 @@ void TextureNode::Load(nlohmann::json data) if (isDefault) { delete texture; - texture = new Texture2D(GetExecutableDir() + "\\Data\\textures\\white.png", false, false); + texture = new Texture2D(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "textures" PATH_SEPARATOR "white.png", false, false); } else @@ -146,7 +147,7 @@ void TextureNode::Load(nlohmann::json data) else { delete texture; - texture = new Texture2D(ProjectManager::Get()->GetResourcePath() + "\\" + ProjectManager::Get()->GetAsset(hash)); + texture = new Texture2D(ProjectManager::Get()->GetResourcePath() + PATH_SEPARATOR + ProjectManager::Get()->GetAsset(hash)); Log("Loaded Cached Texture : " + hash); } } @@ -285,7 +286,7 @@ TextureNode::TextureNode() outputPins.push_back(new NodeEditorPin(NodeEditorPinType::Output)); outputPins.push_back(new NodeEditorPin(NodeEditorPinType::Output)); headerColor = ImColor(IMAGE_NODE_COLOR); - texture = new Texture2D(GetExecutableDir() + "\\Data\\textures\\white.png", false, false); + texture = new Texture2D(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "textures" PATH_SEPARATOR "white.png", false, false); isDefault = true; scale = 1.0f; inv = false; diff --git a/TerraForge3D/src/Generators/MeshGeneratorManager.cpp b/TerraForge3D/src/Generators/MeshGeneratorManager.cpp index f842d57fea..e27be1b838 100644 --- a/TerraForge3D/src/Generators/MeshGeneratorManager.cpp +++ b/TerraForge3D/src/Generators/MeshGeneratorManager.cpp @@ -12,6 +12,7 @@ #include "Base/UIFontManager.h" #include "Profiler.h" +#include "Platform.h" MeshGeneratorManager::MeshGeneratorManager(ApplicationState *as) :appState(as) @@ -436,7 +437,7 @@ void MeshGeneratorManager::ExecuteCPUGenerators() void MeshGeneratorManager::LoadKernels() { bool tmp = false; - std::string source = ReadShaderSourceFile(GetExecutableDir() + "\\Data\\kernels\\generators\\generators.cl", &tmp); + std::string source = ReadShaderSourceFile(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "kernels" PATH_SEPARATOR "generators" PATH_SEPARATOR "generators.cl", &tmp); kernels->AddSoruce(source); kernels->BuildProgram("-I" + appState->globals.kernelsIncludeDir + " -cl-fast-relaxed-math -cl-mad-enable"); kernels->AddKernel("clear_mesh_terrain"); diff --git a/TerraForge3D/src/Main.cpp b/TerraForge3D/src/Main.cpp index 3ffe31acbe..2507463ae6 100644 --- a/TerraForge3D/src/Main.cpp +++ b/TerraForge3D/src/Main.cpp @@ -102,22 +102,22 @@ static void ResetShader() if (!appState->shaders.wireframe) { - appState->shaders.wireframe = new Shader(ReadShaderSourceFile(appState->constants.shadersDir + PATH_SEPERATOR "default" PATH_SEPERATOR "vert.glsl", &res), - ReadShaderSourceFile(appState->constants.shadersDir + PATH_SEPERATOR "default" PATH_SEPERATOR "frag.glsl", &res), - ReadShaderSourceFile(appState->constants.shadersDir + PATH_SEPERATOR "default" PATH_SEPERATOR "geom.glsl", &res)); + appState->shaders.wireframe = new Shader(ReadShaderSourceFile(appState->constants.shadersDir + PATH_SEPARATOR "default" PATH_SEPARATOR "vert.glsl", &res), + ReadShaderSourceFile(appState->constants.shadersDir + PATH_SEPARATOR "default" PATH_SEPARATOR "frag.glsl", &res), + ReadShaderSourceFile(appState->constants.shadersDir + PATH_SEPARATOR "default" PATH_SEPARATOR "geom.glsl", &res)); } - // appState->shaders.textureBake = new Shader(ReadShaderSourceFile(appState->constants.shadersDir + PATH_SEPERATOR "texture_bake" PATH_SEPERATOR "vert.glsl", &res), - // ReadShaderSourceFile(appState->constants.shadersDir + PATH_SEPERATOR "texture_bake" PATH_SEPERATOR "frag.glsl", &res), - // ReadShaderSourceFile(appState->constants.shadersDir + PATH_SEPERATOR "texture_bake" PATH_SEPERATOR "geom.glsl", &res)); + // appState->shaders.textureBake = new Shader(ReadShaderSourceFile(appState->constants.shadersDir + PATH_SEPARATOR "texture_bake" PATH_SEPARATOR "vert.glsl", &res), + // ReadShaderSourceFile(appState->constants.shadersDir + PATH_SEPARATOR "texture_bake" PATH_SEPARATOR "frag.glsl", &res), + // ReadShaderSourceFile(appState->constants.shadersDir + PATH_SEPARATOR "texture_bake" PATH_SEPARATOR "geom.glsl", &res)); - // appState->shaders.terrain = new Shader(ReadShaderSourceFile(appState->constants.shadersDir + PATH_SEPERATOR "default" PATH_SEPERATOR "vert.glsl", &res), - // ReadShaderSourceFile(appState->constants.shadersDir + PATH_SEPERATOR "default" PATH_SEPERATOR "frag.glsl", &res), - // ReadShaderSourceFile(appState->constants.shadersDir + PATH_SEPERATOR "default" PATH_SEPERATOR "geom.glsl", &res)); + // appState->shaders.terrain = new Shader(ReadShaderSourceFile(appState->constants.shadersDir + PATH_SEPARATOR "default" PATH_SEPARATOR "vert.glsl", &res), + // ReadShaderSourceFile(appState->constants.shadersDir + PATH_SEPARATOR "default" PATH_SEPARATOR "frag.glsl", &res), + // ReadShaderSourceFile(appState->constants.shadersDir + PATH_SEPARATOR "default" PATH_SEPARATOR "geom.glsl", &res)); - appState->shaders.foliage = new Shader(ReadShaderSourceFile(appState->constants.shadersDir + PATH_SEPERATOR "foliage" PATH_SEPERATOR "vert.glsl", &res), - ReadShaderSourceFile(appState->constants.shadersDir + PATH_SEPERATOR "foliage" PATH_SEPERATOR "frag.glsl", &res), - ReadShaderSourceFile(appState->constants.shadersDir + PATH_SEPERATOR "foliage" PATH_SEPERATOR "geom.glsl", &res)); + appState->shaders.foliage = new Shader(ReadShaderSourceFile(appState->constants.shadersDir + PATH_SEPARATOR "foliage" PATH_SEPARATOR "vert.glsl", &res), + ReadShaderSourceFile(appState->constants.shadersDir + PATH_SEPARATOR "foliage" PATH_SEPARATOR "frag.glsl", &res), + ReadShaderSourceFile(appState->constants.shadersDir + PATH_SEPARATOR "foliage" PATH_SEPARATOR "geom.glsl", &res)); } static void RegenerateMesh() @@ -284,12 +284,12 @@ static void ChangeCustomModel(std::string mdstr = ShowOpenFileDialog("*.obj")) static void ShowChooseBaseModelPopup() { // TEMP - static std::shared_ptr plane = std::make_shared(appState->constants.texturesDir + PATH_SEPERATOR "ui_thumbs" PATH_SEPERATOR "plane.png", false, false); - static std::shared_ptr sphere = std::make_shared(appState->constants.texturesDir + PATH_SEPERATOR "ui_thumbs" PATH_SEPERATOR "sphere.png", false, false); - static std::shared_ptr cube = std::make_shared(appState->constants.texturesDir + PATH_SEPERATOR "ui_thumbs" PATH_SEPERATOR "cube.png", false, false); - static std::shared_ptr cone = std::make_shared(appState->constants.texturesDir + PATH_SEPERATOR "ui_thumbs" PATH_SEPERATOR "cone.png", false, false); - static std::shared_ptr cyllinder = std::make_shared(appState->constants.texturesDir + PATH_SEPERATOR "ui_thumbs" PATH_SEPERATOR "cylinder.png", false, false); - static std::shared_ptr torus = std::make_shared(appState->constants.texturesDir + PATH_SEPERATOR "ui_thumbs" PATH_SEPERATOR "torus.png", false, false); + static std::shared_ptr plane = std::make_shared(appState->constants.texturesDir + PATH_SEPARATOR "ui_thumbs" PATH_SEPARATOR "plane.png", false, false); + static std::shared_ptr sphere = std::make_shared(appState->constants.texturesDir + PATH_SEPARATOR "ui_thumbs" PATH_SEPARATOR "sphere.png", false, false); + static std::shared_ptr cube = std::make_shared(appState->constants.texturesDir + PATH_SEPARATOR "ui_thumbs" PATH_SEPARATOR "cube.png", false, false); + static std::shared_ptr cone = std::make_shared(appState->constants.texturesDir + PATH_SEPARATOR "ui_thumbs" PATH_SEPARATOR "cone.png", false, false); + static std::shared_ptr cyllinder = std::make_shared(appState->constants.texturesDir + PATH_SEPARATOR "ui_thumbs" PATH_SEPARATOR "cylinder.png", false, false); + static std::shared_ptr torus = std::make_shared(appState->constants.texturesDir + PATH_SEPARATOR "ui_thumbs" PATH_SEPARATOR "torus.png", false, false); // TEMP if (ImGui::BeginPopup("Choose Base Model")) @@ -322,7 +322,7 @@ static void ShowChooseBaseModelPopup() if (ImGui::ImageButton((ImTextureID)sphere->GetRendererID(), ImVec2(200, 200))) { - ChangeCustomModel(appState->constants.modelsDir + PATH_SEPERATOR "Sphere.obj"); + ChangeCustomModel(appState->constants.modelsDir + PATH_SEPARATOR "Sphere.obj"); ImGui::CloseCurrentPopup(); } @@ -330,13 +330,13 @@ static void ShowChooseBaseModelPopup() if (ImGui::ImageButton((ImTextureID)cube->GetRendererID(), ImVec2(200, 200))) { - ChangeCustomModel(appState->constants.modelsDir + PATH_SEPERATOR "cube.obj"); + ChangeCustomModel(appState->constants.modelsDir + PATH_SEPARATOR "cube.obj"); ImGui::CloseCurrentPopup(); } if (ImGui::ImageButton((ImTextureID)torus->GetRendererID(), ImVec2(200, 200))) { - ChangeCustomModel(appState->constants.modelsDir + PATH_SEPERATOR "Torus.obj"); + ChangeCustomModel(appState->constants.modelsDir + PATH_SEPARATOR "Torus.obj"); ImGui::CloseCurrentPopup(); } @@ -344,7 +344,7 @@ static void ShowChooseBaseModelPopup() if (ImGui::ImageButton((ImTextureID)cone->GetRendererID(), ImVec2(200, 200))) { - ChangeCustomModel(appState->constants.modelsDir + PATH_SEPERATOR "cone.obj"); + ChangeCustomModel(appState->constants.modelsDir + PATH_SEPARATOR "cone.obj"); ImGui::CloseCurrentPopup(); } @@ -352,7 +352,7 @@ static void ShowChooseBaseModelPopup() if (ImGui::ImageButton((ImTextureID)cyllinder->GetRendererID(), ImVec2(200, 200))) { - ChangeCustomModel(appState->constants.modelsDir + PATH_SEPERATOR "cylinder.obj"); + ChangeCustomModel(appState->constants.modelsDir + PATH_SEPARATOR "cylinder.obj"); ImGui::CloseCurrentPopup(); } @@ -680,11 +680,11 @@ class MyApp : public Application virtual void OnPreload() override { SetTitle("TerraForge3D - Jaysmito Mukherjee"); - MkDir(GetExecutableDir() + PATH_SEPERATOR "Data" PATH_SEPERATOR "logs"); - SetLogsDir(GetExecutableDir() + PATH_SEPERATOR "Data" PATH_SEPERATOR "logs"); - SetWindowConfigPath(GetExecutableDir() + PATH_SEPERATOR "Data" PATH_SEPERATOR "configs" PATH_SEPERATOR "windowconfigs.terr3d"); - MkDir(GetExecutableDir() + PATH_SEPERATOR "Data" PATH_SEPERATOR "cache" PATH_SEPERATOR "autosave\""); - MkDir(GetExecutableDir() + PATH_SEPERATOR "Data" PATH_SEPERATOR "temp\""); + MkDir(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "logs"); + SetLogsDir(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "logs"); + SetWindowConfigPath(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "configs" PATH_SEPARATOR "windowconfigs.terr3d"); + MkDir(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "cache" PATH_SEPARATOR "autosave\""); + MkDir(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "temp\""); } virtual void OnUpdate(float deltatime) override @@ -848,7 +848,7 @@ class MyApp : public Application { if (appState->states.autoSave) { - SaveFile(appState->constants.cacheDir + PATH_SEPERATOR "autosave" PATH_SEPERATOR "autosave.terr3d"); + SaveFile(appState->constants.cacheDir + PATH_SEPARATOR "autosave" PATH_SEPARATOR "autosave.terr3d"); if (appState->globals.currentOpenFilePath.size() > 3) { @@ -956,20 +956,20 @@ class MyApp : public Application appState = new ApplicationState(); appState->mainApp = mainApp; appState->constants.executableDir = GetExecutableDir(); - appState->constants.dataDir = appState->constants.executableDir + PATH_SEPERATOR "Data"; - appState->constants.cacheDir = appState->constants.dataDir + PATH_SEPERATOR "cache"; - appState->constants.texturesDir = appState->constants.dataDir + PATH_SEPERATOR "textures"; - appState->constants.projectsDir = appState->constants.cacheDir + PATH_SEPERATOR "project_data"; - appState->constants.tempDir = appState->constants.dataDir + PATH_SEPERATOR "temp"; - appState->constants.shadersDir = appState->constants.dataDir + PATH_SEPERATOR "shaders"; - appState->constants.kernelsDir = appState->constants.dataDir + PATH_SEPERATOR "kernels"; - appState->constants.fontsDir = appState->constants.dataDir + PATH_SEPERATOR "fonts"; - appState->constants.liscensesDir = appState->constants.dataDir + PATH_SEPERATOR "licenses"; - appState->constants.skyboxDir = appState->constants.dataDir + PATH_SEPERATOR "skybox"; - appState->constants.modulesDir = appState->constants.dataDir + PATH_SEPERATOR "modules"; - appState->constants.configsDir = appState->constants.dataDir + PATH_SEPERATOR "configs"; - appState->constants.logsDir = appState->constants.dataDir + PATH_SEPERATOR "logs"; - appState->constants.modelsDir = appState->constants.dataDir + PATH_SEPERATOR "models"; + appState->constants.dataDir = appState->constants.executableDir + PATH_SEPARATOR "Data"; + appState->constants.cacheDir = appState->constants.dataDir + PATH_SEPARATOR "cache"; + appState->constants.texturesDir = appState->constants.dataDir + PATH_SEPARATOR "textures"; + appState->constants.projectsDir = appState->constants.cacheDir + PATH_SEPARATOR "project_data"; + appState->constants.tempDir = appState->constants.dataDir + PATH_SEPARATOR "temp"; + appState->constants.shadersDir = appState->constants.dataDir + PATH_SEPARATOR "shaders"; + appState->constants.kernelsDir = appState->constants.dataDir + PATH_SEPARATOR "kernels"; + appState->constants.fontsDir = appState->constants.dataDir + PATH_SEPARATOR "fonts"; + appState->constants.liscensesDir = appState->constants.dataDir + PATH_SEPARATOR "licenses"; + appState->constants.skyboxDir = appState->constants.dataDir + PATH_SEPARATOR "skybox"; + appState->constants.modulesDir = appState->constants.dataDir + PATH_SEPARATOR "modules"; + appState->constants.configsDir = appState->constants.dataDir + PATH_SEPARATOR "configs"; + appState->constants.logsDir = appState->constants.dataDir + PATH_SEPARATOR "logs"; + appState->constants.modelsDir = appState->constants.dataDir + PATH_SEPARATOR "models"; appState->supportersTribute = new SupportersTribute(); SetupExplorerControls(); ImGui::GetStyle().WindowMenuButtonPosition = ImGuiDir_None; @@ -1034,9 +1034,9 @@ class MyApp : public Application appState->filtersManager = new FiltersManager(appState); float t = 1.0f; // Load Fonts - LoadUIFont("Open-Sans-Regular", 18, appState->constants.fontsDir + PATH_SEPERATOR "OpenSans-Regular.ttf"); - LoadUIFont("OpenSans-Bold", 25, appState->constants.fontsDir + PATH_SEPERATOR "OpenSans-Bold.ttf"); - LoadUIFont("OpenSans-Semi-Bold", 22, appState->constants.fontsDir + PATH_SEPERATOR "OpenSans-Bold.ttf"); + LoadUIFont("Open-Sans-Regular", 18, appState->constants.fontsDir + PATH_SEPARATOR "OpenSans-Regular.ttf"); + LoadUIFont("OpenSans-Bold", 25, appState->constants.fontsDir + PATH_SEPARATOR "OpenSans-Bold.ttf"); + LoadUIFont("OpenSans-Semi-Bold", 22, appState->constants.fontsDir + PATH_SEPARATOR "OpenSans-Bold.ttf"); // The framebuffer used for reflections in the sea appState->frameBuffers.reflection = new FrameBuffer(); // The main frame buffer @@ -1044,24 +1044,24 @@ class MyApp : public Application // The Framebuffer used for post processing appState->frameBuffers.postProcess = new FrameBuffer(1280, 720); bool tpp = false; - appState->shaders.postProcess = new Shader(ReadShaderSourceFile(appState->constants.shadersDir + PATH_SEPERATOR "post_processing" PATH_SEPERATOR "vert.glsl", &tpp), - ReadShaderSourceFile(appState->constants.shadersDir + PATH_SEPERATOR "post_processing" PATH_SEPERATOR "frag.glsl", &tpp)); + appState->shaders.postProcess = new Shader(ReadShaderSourceFile(appState->constants.shadersDir + PATH_SEPARATOR "post_processing" PATH_SEPARATOR "vert.glsl", &tpp), + ReadShaderSourceFile(appState->constants.shadersDir + PATH_SEPARATOR "post_processing" PATH_SEPARATOR "frag.glsl", &tpp)); appState->states.autoUpdate = true; if(IsNetWorkConnected()) { - if(FileExists(appState->constants.configsDir + PATH_SEPERATOR "server.terr3d")) + if(FileExists(appState->constants.configsDir + PATH_SEPARATOR "server.terr3d")) { bool ttmp = false; - std::string uid = ReadShaderSourceFile(appState->constants.configsDir + PATH_SEPERATOR "server.terr3d", &ttmp); + std::string uid = ReadShaderSourceFile(appState->constants.configsDir + PATH_SEPARATOR "server.terr3d", &ttmp); Log("Connection to Backend : " + FetchURL("https://terraforge3d.maxalpha.repl.co", "/startup/" + uid)); } else { - DownloadFile("https://terraforge3d.maxalpha.repl.co", "/register", appState->constants.configsDir + PATH_SEPERATOR "server.terr3d"); + DownloadFile("https://terraforge3d.maxalpha.repl.co", "/register", appState->constants.configsDir + PATH_SEPARATOR "server.terr3d"); bool ttmp = false; - std::string uid = ReadShaderSourceFile(appState->constants.configsDir + PATH_SEPERATOR "server.terr3d", &ttmp); + std::string uid = ReadShaderSourceFile(appState->constants.configsDir + PATH_SEPARATOR "server.terr3d", &ttmp); Log("Connection to Backend : " + FetchURL("https://terraforge3d.maxalpha.repl.co", "/startup/" + uid)); } } diff --git a/TerraForge3D/src/Menu/MainMenu.cpp b/TerraForge3D/src/Menu/MainMenu.cpp index 0d137c45fc..2adb001b8d 100644 --- a/TerraForge3D/src/Menu/MainMenu.cpp +++ b/TerraForge3D/src/Menu/MainMenu.cpp @@ -6,6 +6,7 @@ #include "Misc/AppStyles.h" #include "Misc/ExportManager.h" #include "Data/ApplicationState.h" +#include "Platform.h" static void ShowWindowMenuItem(const char *title, bool *val) { @@ -151,7 +152,7 @@ void MainMenu::ShowFileMenu() if (ImGui::MenuItem("Load Auto Saved Project")) { - appState->serailizer->LoadFile(GetExecutableDir() + "\\Data\\cache\\autosave\\autosave.terr3d"); + appState->serailizer->LoadFile(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "cache" PATH_SEPARATOR "autosave" PATH_SEPARATOR "autosave.terr3d"); } if (ImGui::MenuItem("Exit")) @@ -277,4 +278,4 @@ void MainMenu::ShowHelpMenu() { appState->windows.osLisc = !appState->windows.osLisc; } -} \ No newline at end of file +} diff --git a/TerraForge3D/src/Misc/SupportersTribute.cpp b/TerraForge3D/src/Misc/SupportersTribute.cpp index 5a6e160f38..2bb0c29de3 100644 --- a/TerraForge3D/src/Misc/SupportersTribute.cpp +++ b/TerraForge3D/src/Misc/SupportersTribute.cpp @@ -3,6 +3,7 @@ #include "Misc/SupportersTribute.h" #include "Base/Texture2D.h" +#include "Platform.h" #include #include @@ -20,20 +21,20 @@ void SupportersTribute::LoadstargazersData(nlohmann::json &data) GitHubData st; st.name = item["login"]; - if (!PathExist(GetExecutableDir() + "\\Data\\cache\\github_avatars")) + if (!PathExist(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "cache" PATH_SEPARATOR "github_avatars")) { - MkDir(GetExecutableDir() + "\\Data\\cache\\github_avatars"); + MkDir(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "cache" PATH_SEPARATOR "github_avatars"); } - if (!FileExists(GetExecutableDir() + "\\Data\\cache\\github_avatars\\" + st.name + "_" + std::string(item["node_id"])) && isNetWorkConnected) + if (!FileExists(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "cache" PATH_SEPARATOR "github_avatars" + PATH_SEPARATOR + st.name + "_" + std::string(item["node_id"])) && isNetWorkConnected) { std::string urlFull = item["avatar_url"]; std::string baseURL = urlFull.substr(0, 37); std::string pathURL = urlFull.substr(38); - DownloadFile(baseURL, pathURL, GetExecutableDir() + "\\Data\\cache\\github_avatars\\" + st.name + "_" + std::string(item["node_id"])); + DownloadFile(baseURL, pathURL, GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "cache" PATH_SEPARATOR "github_avatars" + PATH_SEPARATOR + st.name + "_" + std::string(item["node_id"])); } - st.avatar = new Texture2D(GetExecutableDir() + "\\Data\\cache\\github_avatars\\" + st.name + "_" + std::string(item["node_id"])); + st.avatar = new Texture2D(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "cache" PATH_SEPARATOR "github_avatars" + PATH_SEPARATOR + st.name + "_" + std::string(item["node_id"])); stargazers.push_back(st); } } @@ -47,20 +48,27 @@ void SupportersTribute::LoadcontributorsData(nlohmann::json &data) GitHubData st; st.name = item["login"]; - if (!PathExist(GetExecutableDir() + "\\Data\\cache\\github_avatars")) + if (!PathExist(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "cache" PATH_SEPARATOR "github_avatars")) { - MkDir(GetExecutableDir() + "\\Data\\cache\\github_avatars"); + MkDir(GetExecutableDir() + PATH_SEPARATOR "Data" + PATH_SEPARATOR + + "cache" PATH_SEPARATOR "github_avatars"); } - if (!FileExists(GetExecutableDir() + "\\Data\\cache\\github_avatars\\" + st.name + "_" + std::string(item["node_id"])) && isNetWorkConnected) + if (!FileExists(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "cache" PATH_SEPARATOR "github_avatars" + PATH_SEPARATOR + st.name + "_" + std::string(item["node_id"])) && isNetWorkConnected) { std::string urlFull = item["avatar_url"]; std::string baseURL = urlFull.substr(0, 37); std::string pathURL = urlFull.substr(38); - DownloadFile(baseURL, pathURL, GetExecutableDir() + "\\Data\\cache\\github_avatars\\" + st.name + "_" + std::string(item["node_id"])); + DownloadFile(baseURL, pathURL, GetExecutableDir() + PATH_SEPARATOR + + "Data" PATH_SEPARATOR "cache" + PATH_SEPARATOR + + "github_avatars" + PATH_SEPARATOR + st.name + "_" + + std::string(item["node_id"])); } - st.avatar = new Texture2D(GetExecutableDir() + "\\Data\\cache\\github_avatars\\" + st.name + "_" + std::string(item["node_id"])); + st.avatar = new Texture2D(GetExecutableDir() + PATH_SEPARATOR "Data" + + PATH_SEPARATOR "cache" PATH_SEPARATOR "github_avatars" + + PATH_SEPARATOR + st.name + "_" + + std::string(item["node_id"])); contributors.push_back(st); } } @@ -68,7 +76,7 @@ void SupportersTribute::LoadcontributorsData(nlohmann::json &data) SupportersTribute::SupportersTribute() { - if (IsNetWorkConnected() && (!FileExists(GetExecutableDir() + "\\Data\\cache\\stargazers.terr3dcache") || rand() % 5 == 0)) + if (IsNetWorkConnected() && (!FileExists(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "cache" PATH_SEPARATOR "stargazers.terr3dcache") || rand() % 5 == 0)) { Log("Internet Connection is Live!\nFetching Latest Supporters data."); { @@ -78,13 +86,13 @@ SupportersTribute::SupportersTribute() int perPage = 30; int lastPage = stargazerCount / perPage; std::string stargazersRawData = FetchURL("https://api.github.com", "/repos/Jaysmito101/TerraForge3D/stargazers?per_page=30&page=" + std::to_string(lastPage)); - SaveToFile(GetExecutableDir() + "\\Data\\cache\\stargazers.terr3dcache", stargazersRawData); + SaveToFile(GetExecutableDir() + PATH_SEPARATOR +"Data" PATH_SEPARATOR "cache" PATH_SEPARATOR "stargazers.terr3dcache", stargazersRawData); nlohmann::json stargazersData = nlohmann::json::parse(stargazersRawData); LoadstargazersData(stargazersData); } { std::string contributorsRawData = FetchURL("https://api.github.com", "/repos/Jaysmito101/TerraForge3D/contributors"); - SaveToFile(GetExecutableDir() + "\\Data\\cache\\contributors.terr3dcache", contributorsRawData); + SaveToFile(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "cache" PATH_SEPARATOR "contributors.terr3dcache", contributorsRawData); nlohmann::json contributorsData = nlohmann::json::parse(contributorsRawData); LoadcontributorsData(contributorsData); } @@ -95,10 +103,10 @@ SupportersTribute::SupportersTribute() bool tmp = false; Log("Trying to load cached data."); - if (FileExists(GetExecutableDir() + "\\Data\\cache\\stargazers.terr3dcache")) + if (FileExists(GetExecutableDir() + PATH_SEPARATOR "Data"+ PATH_SEPARATOR "cache" PATH_SEPARATOR "stargazers.terr3dcache")) { Log("Found Stargazers Cached Data!"); - std::string stargazersRawData = ReadShaderSourceFile(GetExecutableDir() + "\\Data\\cache\\stargazers.terr3dcache", &tmp); + std::string stargazersRawData = ReadShaderSourceFile(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "cache" PATH_SEPARATOR "stargazers.terr3dcache", &tmp); nlohmann::json stargazersData = nlohmann::json::parse(stargazersRawData); LoadstargazersData(stargazersData); } @@ -108,10 +116,10 @@ SupportersTribute::SupportersTribute() Log("Stargazers Cached Data not found!"); } - if (FileExists(GetExecutableDir() + "\\Data\\cache\\contributors.terr3dcache")) + if (FileExists(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "cache" PATH_SEPARATOR "contributors.terr3dcache")) { Log("Found Contributors Cached Data!"); - std::string contributorsRawData = ReadShaderSourceFile(GetExecutableDir() + "\\Data\\cache\\contributors.terr3dcache", &tmp); + std::string contributorsRawData = ReadShaderSourceFile(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "cache" PATH_SEPARATOR "contributors.terr3dcache", &tmp); nlohmann::json contributorsData = nlohmann::json::parse(contributorsRawData); LoadcontributorsData(contributorsData); } @@ -183,4 +191,4 @@ void SupportersTribute::ShowSettings(bool *pOpen) ImGui::Separator(); ImGui::End(); -} \ No newline at end of file +} diff --git a/TerraForge3D/src/Modules/ModuleManager.cpp b/TerraForge3D/src/Modules/ModuleManager.cpp index 70e95976f1..03ac464cd2 100644 --- a/TerraForge3D/src/Modules/ModuleManager.cpp +++ b/TerraForge3D/src/Modules/ModuleManager.cpp @@ -44,13 +44,13 @@ void ModuleManager::LoadModules() { UnloadModules(); // iterate through all directories in the modules folder - std::string modulesFolder = appState->constants.modulesDir + PATH_SEPERATOR; + std::string modulesFolder = appState->constants.modulesDir + PATH_SEPARATOR; for (auto &p : std::filesystem::directory_iterator(modulesFolder)) { std::string path = p.path().string(); - if (p.is_directory() && FileExists(path + PATH_SEPERATOR + "module" MODULE_EXT )) + if (p.is_directory() && FileExists(path + PATH_SEPARATOR "module" MODULE_EXT )) { - LoadModule(path + PATH_SEPERATOR + "module" MODULE_EXT); + LoadModule(path + PATH_SEPARATOR "module" MODULE_EXT); } } } @@ -113,9 +113,9 @@ ModuleManager::~ModuleManager() void ModuleManager::InstallModule(std::string path) { // extract zip file to modules folder - zip_extract(path.data(), (appState->constants.modulesDir + PATH_SEPERATOR + GenerateId(32)).data(), [](const char* f, void* arg){return 1;}, 0); + zip_extract(path.data(), (appState->constants.modulesDir + PATH_SEPARATOR + GenerateId(32)).data(), [](const char* f, void* arg){return 1;}, 0); // load module - LoadModule(appState->constants.modulesDir + PATH_SEPERATOR + GenerateId(32) + PATH_SEPERATOR + "module" MODULE_EXT); + LoadModule(appState->constants.modulesDir + PATH_SEPARATOR + GenerateId(32) + PATH_SEPARATOR "module" MODULE_EXT); } void ModuleManager::UninstallModule(std::string uid) @@ -176,4 +176,4 @@ void ModuleManager::UpdateModules() { module->Update(); } -} \ No newline at end of file +} diff --git a/TerraForge3D/src/Sea/SeaManager.cpp b/TerraForge3D/src/Sea/SeaManager.cpp index b2bebbfc87..df720ee56b 100644 --- a/TerraForge3D/src/Sea/SeaManager.cpp +++ b/TerraForge3D/src/Sea/SeaManager.cpp @@ -23,12 +23,12 @@ SeaManager::SeaManager(ApplicationState *as) color[2] = 0.7f; color[3] = 0; scale = 100; - std::string vertexShaderSource = ReadShaderSourceFile(GetExecutableDir() + "\\Data\\shaders\\water\\vert.glsl", &tmp); - std::string fragmentShaderSource = ReadShaderSourceFile(GetExecutableDir() + "\\Data\\shaders\\water\\frag.glsl", &tmp); - std::string geometryShaderSource = ReadShaderSourceFile(GetExecutableDir() + "\\Data\\shaders\\water\\geom.glsl", &tmp); + std::string vertexShaderSource = ReadShaderSourceFile(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "shaders" PATH_SEPARATOR "water" PATH_SEPARATOR "vert.glsl", &tmp); + std::string fragmentShaderSource = ReadShaderSourceFile(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "shaders" PATH_SEPARATOR "water" PATH_SEPARATOR "frag.glsl", &tmp); + std::string geometryShaderSource = ReadShaderSourceFile(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "shaders" PATH_SEPARATOR "water" PATH_SEPARATOR "geom.glsl", &tmp); shader = new Shader(vertexShaderSource, fragmentShaderSource, geometryShaderSource); - dudvMap = new Texture2D(GetExecutableDir() + PATH_SEPERATOR "Data" PATH_SEPERATOR "textures" PATH_SEPERATOR "water_dudv.png"); - normalMap = new Texture2D(GetExecutableDir() + PATH_SEPERATOR "Data" PATH_SEPERATOR "textures" PATH_SEPERATOR "water_normal.png"); + dudvMap = new Texture2D(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "textures" PATH_SEPARATOR "water_dudv.png"); + normalMap = new Texture2D(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "textures" PATH_SEPARATOR "water_normal.png"); } SeaManager::~SeaManager() @@ -72,14 +72,14 @@ void SeaManager::Load(nlohmann::json data) delete dudvMap; } - dudvMap = new Texture2D(appState->projectManager->GetResourcePath() + "\\" + appState->projectManager->GetAsset(data["dudvMap"])); + dudvMap = new Texture2D(appState->projectManager->GetResourcePath() + PATH_SEPARATOR + appState->projectManager->GetAsset(data["dudvMap"])); if (normalMap) { delete normalMap; } - normalMap = new Texture2D(appState->projectManager->GetResourcePath() + "\\" + appState->projectManager->GetAsset(data["normalMap"])); + normalMap = new Texture2D(appState->projectManager->GetResourcePath() + PATH_SEPARATOR + appState->projectManager->GetAsset(data["normalMap"])); } nlohmann::json SeaManager::Save() diff --git a/TerraForge3D/src/Shading/ShaderNodes/ShaderTextureNode.cpp b/TerraForge3D/src/Shading/ShaderNodes/ShaderTextureNode.cpp index e07b5df70a..3e01e61e17 100644 --- a/TerraForge3D/src/Shading/ShaderNodes/ShaderTextureNode.cpp +++ b/TerraForge3D/src/Shading/ShaderNodes/ShaderTextureNode.cpp @@ -48,7 +48,7 @@ void ShaderTextureNode::Load(nlohmann::json data) texture = nullptr; } - texture = new Texture2D(ProjectManager::Get()->GetResourcePath() + PATH_SEPERATOR + ProjectManager::Get()->GetAsset(data["texture"])); + texture = new Texture2D(ProjectManager::Get()->GetResourcePath() + PATH_SEPARATOR + ProjectManager::Get()->GetAsset(data["texture"])); scale = data["scale"]; offsetX = data["offsetX"]; offsetY = data["offsetY"]; @@ -156,7 +156,7 @@ ShaderTextureNode::ShaderTextureNode(GLSLHandler *handler, ShaderTextureManager name = "Texture"; headerColor = ImColor(SHADER_TEXTURE_NODE_COLOR); outputPins.push_back(new SNEPin(NodeEditorPinType::Output, SNEPinType::SNEPinType_Float3)); - texture = new Texture2D(GetExecutableDir() + PATH_SEPERATOR "Data" PATH_SEPERATOR "textures" PATH_SEPERATOR "white.png"); + texture = new Texture2D(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "textures" PATH_SEPARATOR "white.png"); textureManager->Register(this); } @@ -170,4 +170,4 @@ ShaderTextureNode::~ShaderTextureNode() delete texture; texture = nullptr; } -} \ No newline at end of file +} diff --git a/TerraForge3D/src/Shading/ShadingManager.cpp b/TerraForge3D/src/Shading/ShadingManager.cpp index aacab89fd0..db5e2648a1 100644 --- a/TerraForge3D/src/Shading/ShadingManager.cpp +++ b/TerraForge3D/src/Shading/ShadingManager.cpp @@ -172,7 +172,7 @@ ShadingManager::ShadingManager(ApplicationState *as) return node; }; - config.saveFile = GetExecutableDir() + PATH_SEPERATOR + "Data" + PATH_SEPERATOR + "configs" + PATH_SEPERATOR + "ShaderNodes.json"; + config.saveFile = GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "configs" PATH_SEPARATOR "ShaderNodes.json"; shaderNodeEditor = new NodeEditor(config); shaderNodeEditor->name = "Shader Nodes"; shaderNodeEditor->SetOutputNode(new ShaderOutputNode(fsh)); @@ -217,7 +217,7 @@ void ShadingManager::UpdateShaders() void ShadingManager::LoadDefaultCustomNodes() { - std::string nodesDir = GetExecutableDir() + PATH_SEPERATOR + "Data" + PATH_SEPERATOR + "shader_nodes"; + std::string nodesDir = GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "shader_nodes"; defaultCustomNodes.clear(); bool tmp = false; @@ -232,7 +232,7 @@ void ShadingManager::LoadDefaultCustomNodes() defaultCustomNodes.push_back(n); } - extraSource = ReadShaderSourceFile(nodesDir + PATH_SEPERATOR + "extras.glsl", &tmp); + extraSource = ReadShaderSourceFile(nodesDir + PATH_SEPARATOR "extras.glsl", &tmp); } diff --git a/TerraForge3D/src/Sky/CubeMap.cpp b/TerraForge3D/src/Sky/CubeMap.cpp index 96e28b76e5..c1476c7750 100644 --- a/TerraForge3D/src/Sky/CubeMap.cpp +++ b/TerraForge3D/src/Sky/CubeMap.cpp @@ -17,9 +17,9 @@ #include "Data/ApplicationState.h" static bool tmpb = false; -static std::string vertShader = ReadShaderSourceFile(GetExecutableDir() + PATH_SEPERATOR "Data" PATH_SEPERATOR "shaders" PATH_SEPERATOR "skybox" PATH_SEPERATOR "vert.glsl", &tmpb); -static std::string fragShader = ReadShaderSourceFile(GetExecutableDir() + PATH_SEPERATOR "Data" PATH_SEPERATOR "shaders" PATH_SEPERATOR "skybox" PATH_SEPERATOR "frag.glsl", &tmpb); -static std::string fragProShader = ReadShaderSourceFile(GetExecutableDir() + PATH_SEPERATOR "Data" PATH_SEPERATOR "shaders" PATH_SEPERATOR "skybox" PATH_SEPERATOR "procedural_clouds.glsl", &tmpb); +static std::string vertShader = ReadShaderSourceFile(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "shaders" PATH_SEPARATOR "skybox" PATH_SEPARATOR "vert.glsl", &tmpb); +static std::string fragShader = ReadShaderSourceFile(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "shaders" PATH_SEPARATOR "skybox" PATH_SEPARATOR "frag.glsl", &tmpb); +static std::string fragProShader = ReadShaderSourceFile(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "shaders" PATH_SEPARATOR "skybox" PATH_SEPARATOR "procedural_clouds.glsl", &tmpb); static float skyboxVertices[] = @@ -96,12 +96,12 @@ CubeMapManager::CubeMapManager(ApplicationState *as) appState = as; static std::vector faces = { - appState->constants.skyboxDir + PATH_SEPERATOR "px.jpg", - appState->constants.skyboxDir + PATH_SEPERATOR "nx.jpg", - appState->constants.skyboxDir + PATH_SEPERATOR "py.jpg", - appState->constants.skyboxDir + PATH_SEPERATOR "ny.jpg", - appState->constants.skyboxDir + PATH_SEPERATOR "pz.jpg", - appState->constants.skyboxDir + PATH_SEPERATOR "nz.jpg" + appState->constants.skyboxDir + PATH_SEPARATOR "px.jpg", + appState->constants.skyboxDir + PATH_SEPARATOR "nx.jpg", + appState->constants.skyboxDir + PATH_SEPARATOR "py.jpg", + appState->constants.skyboxDir + PATH_SEPARATOR "ny.jpg", + appState->constants.skyboxDir + PATH_SEPARATOR "pz.jpg", + appState->constants.skyboxDir + PATH_SEPARATOR "nz.jpg" }; cubemap = new TextureCubemap(); cubemap->SetUpOnGPU(); @@ -117,7 +117,7 @@ CubeMapManager::CubeMapManager(ApplicationState *as) glBufferData(GL_ARRAY_BUFFER, sizeof(skyboxVertices), skyboxVertices, GL_STATIC_DRAW); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), (void *)0); glEnableVertexAttribArray(0); - skySphere = LoadModel(GetExecutableDir() + PATH_SEPERATOR "Data" PATH_SEPERATOR "models" PATH_SEPERATOR "icosphere.obj"); + skySphere = LoadModel(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "models" PATH_SEPARATOR "icosphere.obj"); skySphere->SetupMeshOnGPU(); skySphere->UploadToGPU(); } diff --git a/TerraForge3D/src/TextureStore/TextureStore.cpp b/TerraForge3D/src/TextureStore/TextureStore.cpp index 891cf8aaf8..4c756cbc68 100644 --- a/TerraForge3D/src/TextureStore/TextureStore.cpp +++ b/TerraForge3D/src/TextureStore/TextureStore.cpp @@ -1,4 +1,5 @@ #include "TextureStore/TextureStore.h" +#include "Platform.h" #include "Data/ApplicationState.h" #include "Utils/Utils.h" @@ -64,7 +65,7 @@ nlohmann::json TextureStore::LoadTextureDatabaseJ() loadFromFile = false; } - if(!FileExists(GetExecutableDir() + "\\Data\\cache\\texture_database.terr3d")) + if(!FileExists(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "cache" PATH_SEPARATOR "texture_database.terr3d")) { loadFromFile = false; } @@ -73,7 +74,7 @@ nlohmann::json TextureStore::LoadTextureDatabaseJ() { Log("Loading texture database from file"); bool tmp = false; - std::string tmpStr = ReadShaderSourceFile(GetExecutableDir() + "\\Data\\cache\\texture_database.terr3d", &tmp); + std::string tmpStr = ReadShaderSourceFile(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "cache" PATH_SEPARATOR "texture_database.terr3d", &tmp); if(tmp == false) { @@ -104,35 +105,41 @@ nlohmann::json TextureStore::LoadTextureDatabaseJ() return nlohmann::json(); } - SaveToFile(GetExecutableDir() + "\\Data\\cache\\texture_database.terr3d", tmp); + SaveToFile(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "cache" PATH_SEPARATOR "texture_database.terr3d", tmp); return nlohmann::json::parse(tmp); } } void TextureStore::VerifyTextureThumbs() { - MkDir(GetExecutableDir() + "\\Data\\cache\\texture_thumbnails\\"); + MkDir(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "cache" PATH_SEPARATOR "texture_thumbnails" PATH_SEPARATOR); for(auto it = textureDatabaseJ.begin() ; it != textureDatabaseJ.end() ; it++) { - if(!FileExists(GetExecutableDir() + "\\Data\\cache\\texture_thumbnails\\" + it.key() + ".png")) + if(!FileExists(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "cache" PATH_SEPARATOR "texture_thumbnails" PATH_SEPARATOR + it.key() + ".png")) { Log("Downloading thumbnail for texture: " + it.key()); - DownloadFile("https://cdn.polyhaven.com", "/asset_img/thumbs/" + it.key() + ".png?width=100&height=100", GetExecutableDir() + "\\Data\\cache\\texture_thumbnails\\" + it.key() + ".png"); + DownloadFile("https://cdn.polyhaven.com", "/asset_img/thumbs/" + + it.key() + ".png?width=100&height=100", GetExecutableDir() + + PATH_SEPARATOR "Data" PATH_SEPARATOR "cache " + PATH_SEPARATOR "texture_thumbnails" PATH_SEPARATOR + + it.key() + ".png"); } } } nlohmann::json TextureStore::LoadDownloadedTextureDatabaseJ() { - if(!FileExists(GetExecutableDir() + "\\Data\\configs\\texture_database_downloaded.terr3d")) + if(!FileExists(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "configs" PATH_SEPARATOR "texture_database_downloaded.terr3d")) { Log("No Textures downloaded yet"); return nlohmann::json(); } bool tmp = false; - std::string tmpStr = ReadShaderSourceFile(GetExecutableDir() + "\\Data\\configs\\texture_database_downloaded.terr3d", &tmp); + std::string tmpStr = ReadShaderSourceFile(GetExecutableDir() + + PATH_SEPARATOR "Data" PATH_SEPARATOR "configs" PATH_SEPARATOR + "texture_database_downloaded.terr3d", &tmp); if(tmp == false) { @@ -168,7 +175,9 @@ void TextureStore::LoadTextureDatabase() { TextureStoreItem item; item.name = it.key(); - item.thumbnailPath = GetExecutableDir() + "\\Data\\cache\\texture_thumbnails\\" + item.name + ".png"; + item.thumbnailPath = GetExecutableDir() + PATH_SEPARATOR "Data" + PATH_SEPARATOR "cache" PATH_SEPARATOR "texture_thumbnails" + PATH_SEPARATOR + item.name + ".png"; item.download_count = it.value()["download_count"]; for(auto it2 = it.value()["authors"].begin() ; it2 != it.value()["authors"].end() ; it2++) @@ -202,10 +211,12 @@ void TextureStore::LoadTextureThumbs() { i++; - if(!FileExists(GetExecutableDir() + "\\Data\\cache\\texture_thumbnails\\" + it.name + ".png")) + if(!FileExists(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "cache" PATH_SEPARATOR "texture_thumbnails" PATH_SEPARATOR + it.name + ".png")) { Log("Thumbnail for texture: " + it.name + " not found."); - it.texThumbnail = new Texture2D(GetExecutableDir() + "\\Data\\textures\\white.png", false); + it.texThumbnail = new Texture2D(GetExecutableDir() + PATH_SEPARATOR + "Data" PATH_SEPARATOR "textures" PATH_SEPARATOR + "white.png", false); } else @@ -239,7 +250,9 @@ void TextureStore::SaveDownloadsDatabase() tmp2[textureStoreItems[id].name] = tmp; } - SaveToFile(GetExecutableDir() + "\\Data\\configs\\texture_database_downloaded.terr3d", tmp2.dump(4)); + SaveToFile(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR + "configs" PATH_SEPARATOR "texture_database_downloaded.terr3d", + tmp2.dump(4)); } void TextureStore::DeleteTexture(int id) @@ -251,7 +264,7 @@ void TextureStore::DeleteTexture(int id) DeleteFileT(textureStoreItems[id].metallic); DeleteFileT(textureStoreItems[id].roughness); DeleteFileT(textureStoreItems[id].arm); - DeleteFileT(textureStoreItems[id].baseDir + "\\displacement.png"); // TEMPORARY + DeleteFileT(textureStoreItems[id].baseDir + PATH_SEPARATOR "displacement.png"); // TEMPORARY textureStoreItems[id].downloaded = false; downloadedTextureStoreItems.erase(std::find(downloadedTextureStoreItems.begin(), downloadedTextureStoreItems.end(), id)); SaveDownloadsDatabase(); @@ -273,26 +286,27 @@ void TextureStore::DownloadTexture(int id, int res) return; } - std::string baseDir = GetExecutableDir() + "\\Data\\textures\\" + textureStoreItems[id].name; + std::string baseDir = GetExecutableDir() + PATH_SEPARATOR "Data" + PATH_SEPARATOR "textures" PATH_SEPARATOR + textureStoreItems[id].name; MkDir(baseDir); textureStoreItems[id].baseDir = baseDir; tmpStr = tmpJ["Diffuse"][std::to_string(res) + "k"]["png"]["url"]; - DownloadFile("https://dl.polyhaven.org", tmpStr.substr(24), baseDir + "\\albedo.png"); - textureStoreItems[id].abledo = baseDir + "\\albedo.png"; + DownloadFile("https://dl.polyhaven.org", tmpStr.substr(24), baseDir + PATH_SEPARATOR "albedo.png"); + textureStoreItems[id].abledo = baseDir + PATH_SEPARATOR "albedo.png"; tmpStr = tmpJ["nor_gl"][std::to_string(res) + "k"]["png"]["url"]; - DownloadFile("https://dl.polyhaven.org", tmpStr.substr(24), baseDir + "\\normal.png"); - textureStoreItems[id].normal = baseDir + "\\normal.png"; + DownloadFile("https://dl.polyhaven.org", tmpStr.substr(24), baseDir + PATH_SEPARATOR "normal.png"); + textureStoreItems[id].normal = baseDir + PATH_SEPARATOR + "normal.png"; tmpStr = tmpJ["Rough"][std::to_string(res) + "k"]["png"]["url"]; - DownloadFile("https://dl.polyhaven.org", tmpStr.substr(24), baseDir + "\\roughness.png"); - textureStoreItems[id].roughness = baseDir + "\\roughness.png"; + DownloadFile("https://dl.polyhaven.org", tmpStr.substr(24), baseDir + PATH_SEPARATOR "roughness.png"); + textureStoreItems[id].roughness = baseDir + PATH_SEPARATOR "roughness.png"; tmpStr = tmpJ["AO"][std::to_string(res) + "k"]["png"]["url"]; - DownloadFile("https://dl.polyhaven.org", tmpStr.substr(24), baseDir + "\\ao.png"); - textureStoreItems[id].ao = baseDir + "\\ao.png"; + DownloadFile("https://dl.polyhaven.org", tmpStr.substr(24), baseDir + PATH_SEPARATOR "ao.png"); + textureStoreItems[id].ao = baseDir + PATH_SEPARATOR "ao.png"; tmpStr = tmpJ["arm"][std::to_string(res) + "k"]["png"]["url"]; - DownloadFile("https://dl.polyhaven.org", tmpStr.substr(24), baseDir + "\\arm.png"); - textureStoreItems[id].arm = baseDir + "\\arm.png"; + DownloadFile("https://dl.polyhaven.org", tmpStr.substr(24), baseDir + PATH_SEPARATOR "arm.png"); + textureStoreItems[id].arm = baseDir + PATH_SEPARATOR "arm.png"; tmpStr = tmpJ["Displacement"][std::to_string(res) + "k"]["png"]["url"]; - DownloadFile("https://dl.polyhaven.org", tmpStr.substr(24), baseDir + "\\displacement.png"); + DownloadFile("https://dl.polyhaven.org", tmpStr.substr(24), baseDir + PATH_SEPARATOR "displacement.png"); textureStoreItems[id].downloaded = true; downloadedTextureStoreItems.push_back(id); SaveDownloadsDatabase(); @@ -494,4 +508,4 @@ TextureStore::~TextureStore() { delete it.texThumbnail; } -} \ No newline at end of file +} diff --git a/TerraForge3D/src/Utils/Utils.cpp b/TerraForge3D/src/Utils/Utils.cpp index 546badb56f..08134730f5 100644 --- a/TerraForge3D/src/Utils/Utils.cpp +++ b/TerraForge3D/src/Utils/Utils.cpp @@ -35,6 +35,7 @@ #include "GLFW/glfw3.h" #include "Application.h" #include "Data/ProjectData.h" +#include "Platform.h" #ifndef TERR3D_WIN32 #include // dirname From 8a4b5ad8729ec50bb11bdfbb5f129e1217445967 Mon Sep 17 00:00:00 2001 From: fiplox Date: Mon, 21 Mar 2022 10:42:45 +0100 Subject: [PATCH 2/3] not used --- TerraForge3D/src/Utils/Utils.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/TerraForge3D/src/Utils/Utils.cpp b/TerraForge3D/src/Utils/Utils.cpp index 08134730f5..546badb56f 100644 --- a/TerraForge3D/src/Utils/Utils.cpp +++ b/TerraForge3D/src/Utils/Utils.cpp @@ -35,7 +35,6 @@ #include "GLFW/glfw3.h" #include "Application.h" #include "Data/ProjectData.h" -#include "Platform.h" #ifndef TERR3D_WIN32 #include // dirname From 4181985349c920a89044a8f2c17dc19e3cc705d0 Mon Sep 17 00:00:00 2001 From: fiplox Date: Mon, 21 Mar 2022 10:54:20 +0100 Subject: [PATCH 3/3] remove useless pluses --- TerraForge3D/src/Data/Serializer.cpp | 41 +++++++++---------- .../src/Filters/AdvancedErosionFilter.cpp | 4 +- TerraForge3D/src/Misc/SupportersTribute.cpp | 21 +++++----- .../src/TextureStore/TextureStore.cpp | 2 +- 4 files changed, 32 insertions(+), 36 deletions(-) diff --git a/TerraForge3D/src/Data/Serializer.cpp b/TerraForge3D/src/Data/Serializer.cpp index c06cf5901c..7f2b1b6a5f 100644 --- a/TerraForge3D/src/Data/Serializer.cpp +++ b/TerraForge3D/src/Data/Serializer.cpp @@ -118,8 +118,8 @@ nlohmann::json Serializer::Serialize() if (projectAsset == "") { MkDir(appState->projectManager->GetResourcePath() + PATH_SEPARATOR "models"); - CopyFileData(appState->globals.currentBaseModelPath, appState->projectManager->GetResourcePath() + PATH_SEPARATOR "models" + PATH_SEPARATOR + baseHash + appState->globals.currentBaseModelPath.substr(appState->globals.currentBaseModelPath.find_last_of("."))); - appState->projectManager->RegisterAsset(baseHash, "models" + PATH_SEPARATOR + baseHash + appState->globals.currentBaseModelPath.substr(appState->globals.currentBaseModelPath.find_last_of("."))); + CopyFileData(appState->globals.currentBaseModelPath, appState->projectManager->GetResourcePath() + PATH_SEPARATOR "models" PATH_SEPARATOR + baseHash + appState->globals.currentBaseModelPath.substr(appState->globals.currentBaseModelPath.find_last_of("."))); + appState->projectManager->RegisterAsset(baseHash, "models" PATH_SEPARATOR + baseHash + appState->globals.currentBaseModelPath.substr(appState->globals.currentBaseModelPath.find_last_of("."))); } data["baseid"] = baseHash; @@ -143,7 +143,7 @@ void Serializer::PackProject(std::string path) outfile.close(); MkDir(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "temp"); std::string uid = GenerateId(64); - SaveFile(GetExecutableDir() + "Data" + PATH_SEPARATOR "temp" + PATH_SEPARATOR + uid); + SaveFile(GetExecutableDir() + "Data" + PATH_SEPARATOR "temp" PATH_SEPARATOR + uid); zip_t *packed = zip_open(path.c_str(), 9, 'w'); zip_walk(packed, appState->projectManager->GetResourcePath().c_str()); zip_close(packed); @@ -157,24 +157,21 @@ void Serializer::LoadPackedProject(std::string path) } std::string uid = GenerateId(64); - MkDir(GetExecutableDir() + PATH_SEPARATOR "Data" + PATH_SEPARATOR + - "temp" PATH_SEPARATOR "pcache_" + uid); - zip_extract(path.c_str(), (GetExecutableDir() + PATH_SEPARATOR "Data" + - PATH_SEPARATOR "temp" PATH_SEPARATOR "pcache_" + - uid).c_str(), [](const char *filename, void *arg) + MkDir(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "temp" + PATH_SEPARATOR "pcache_" + uid); + zip_extract(path.c_str(), (GetExecutableDir() + PATH_SEPARATOR "Data" + PATH_SEPARATOR "temp" PATH_SEPARATOR "pcache_" + uid).c_str(), + [](const char *filename, void *arg) { return 1; }, (void *)0); - if (FileExists(GetExecutableDir() + PATH_SEPARATOR "Data" + - PATH_SEPARATOR "temp" PATH_SEPARATOR "pcache_" + uid + - PATH_SEPARATOR "project.terr3d", true)) + if (FileExists(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "temp" PATH_SEPARATOR "pcache_" + uid + PATH_SEPARATOR "project.terr3d", true)) { bool tmp = false; std::string sdata = ReadShaderSourceFile(GetExecutableDir() + - PATH_SEPARATOR "Data" PATH_SEPARATOR "temp" + - PATH_SEPARATOR "pcache_" + uid + PATH_SEPARATOR + - "project.terr3d", &tmp); + PATH_SEPARATOR "Data" PATH_SEPARATOR "temp" PATH_SEPARATOR + "pcache_" + uid + PATH_SEPARATOR "project.terr3d", &tmp); if (sdata.size() <= 0) { @@ -197,20 +194,20 @@ void Serializer::LoadPackedProject(std::string path) std::string projId = data["projectID"]; zip_extract(path.c_str(), (GetExecutableDir() + PATH_SEPARATOR "Data" - + PATH_SEPARATOR "cache" + PATH_SEPARATOR + - "project_data" PATH_SEPARATOR "project_" + - projId).c_str(), [](const char *filename, void *arg) + PATH_SEPARATOR "cache" PATH_SEPARATOR "project_data" + PATH_SEPARATOR "project_" + projId).c_str(), [](const char + *filename, void *arg) { Log(std::string("Extracted ") + filename); return 1; }, (void *)0); std::string oriDir = path.substr(0, path.rfind(PATH_SEPARATOR)); std::string oriName = path.substr(path.rfind(PATH_SEPARATOR) + 1); - CopyFileData((GetExecutableDir() + PATH_SEPARATOR "Data" + - PATH_SEPARATOR "cache" + PATH_SEPARATOR + + - "project_data" PATH_SEPARATOR "project_" + projId + - PATH_SEPARATOR "project.terr3d").c_str(), oriDir + - PATH_SEPARATOR + oriName + ".terr3d"); + CopyFileData((GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR + "cache" PATH_SEPARATOR "project_data" PATH_SEPARATOR + "project_" + projId + PATH_SEPARATOR + "project.terr3d").c_str(), oriDir + PATH_SEPARATOR + + oriName + ".terr3d"); LoadFile(oriDir + PATH_SEPARATOR + oriName + ".terr3d"); } diff --git a/TerraForge3D/src/Filters/AdvancedErosionFilter.cpp b/TerraForge3D/src/Filters/AdvancedErosionFilter.cpp index f1de3bbc78..99dd426180 100644 --- a/TerraForge3D/src/Filters/AdvancedErosionFilter.cpp +++ b/TerraForge3D/src/Filters/AdvancedErosionFilter.cpp @@ -74,13 +74,13 @@ void AdvancedErosionFilter::Apply() } std::string kernelSrc = ReadShaderSourceFile(GetExecutableDir() + - PATH_SEPARATOR "Data" PATH_SEPARATOR "kernels" + + PATH_SEPARATOR "Data" PATH_SEPARATOR "kernels" PATH_SEPARATOR "advanced_erosion.cl", &tmp); // Some constants kernelSrc = std::regex_replace(kernelSrc, std::regex("LOCAL_WORK_SIZE"), std::to_string(localWorkSize)); kernels.Clear(); kernels.AddSoruce(kernelSrc); - kernels.BuildProgram("-I\"" + GetExecutableDir() + PATH_SEPARATOR + + kernels.BuildProgram("-I\"" + GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "kernels" + "\""); kernels.AddKernel("erode"); kernels.CreateBuffer("mesh", CL_MEM_READ_WRITE, sizeof(Vert) * model->mesh->vertexCount); diff --git a/TerraForge3D/src/Misc/SupportersTribute.cpp b/TerraForge3D/src/Misc/SupportersTribute.cpp index 2bb0c29de3..7e80aa87d5 100644 --- a/TerraForge3D/src/Misc/SupportersTribute.cpp +++ b/TerraForge3D/src/Misc/SupportersTribute.cpp @@ -26,15 +26,15 @@ void SupportersTribute::LoadstargazersData(nlohmann::json &data) MkDir(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "cache" PATH_SEPARATOR "github_avatars"); } - if (!FileExists(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "cache" PATH_SEPARATOR "github_avatars" + PATH_SEPARATOR + st.name + "_" + std::string(item["node_id"])) && isNetWorkConnected) + if (!FileExists(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "cache" PATH_SEPARATOR "github_avatars" PATH_SEPARATOR + st.name + "_" + std::string(item["node_id"])) && isNetWorkConnected) { std::string urlFull = item["avatar_url"]; std::string baseURL = urlFull.substr(0, 37); std::string pathURL = urlFull.substr(38); - DownloadFile(baseURL, pathURL, GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "cache" PATH_SEPARATOR "github_avatars" + PATH_SEPARATOR + st.name + "_" + std::string(item["node_id"])); + DownloadFile(baseURL, pathURL, GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "cache" PATH_SEPARATOR "github_avatars" PATH_SEPARATOR + st.name + "_" + std::string(item["node_id"])); } - st.avatar = new Texture2D(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "cache" PATH_SEPARATOR "github_avatars" + PATH_SEPARATOR + st.name + "_" + std::string(item["node_id"])); + st.avatar = new Texture2D(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "cache" PATH_SEPARATOR "github_avatars" PATH_SEPARATOR + st.name + "_" + std::string(item["node_id"])); stargazers.push_back(st); } } @@ -50,24 +50,23 @@ void SupportersTribute::LoadcontributorsData(nlohmann::json &data) if (!PathExist(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "cache" PATH_SEPARATOR "github_avatars")) { - MkDir(GetExecutableDir() + PATH_SEPARATOR "Data" + PATH_SEPARATOR - + "cache" PATH_SEPARATOR "github_avatars"); + MkDir(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "cache" PATH_SEPARATOR "github_avatars"); } - if (!FileExists(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "cache" PATH_SEPARATOR "github_avatars" + PATH_SEPARATOR + st.name + "_" + std::string(item["node_id"])) && isNetWorkConnected) + if (!FileExists(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "cache" PATH_SEPARATOR "github_avatars" PATH_SEPARATOR + st.name + "_" + std::string(item["node_id"])) && isNetWorkConnected) { std::string urlFull = item["avatar_url"]; std::string baseURL = urlFull.substr(0, 37); std::string pathURL = urlFull.substr(38); DownloadFile(baseURL, pathURL, GetExecutableDir() + PATH_SEPARATOR - + "Data" PATH_SEPARATOR "cache" + PATH_SEPARATOR + - "github_avatars" + PATH_SEPARATOR + st.name + "_" + + "Data" PATH_SEPARATOR "cache" PATH_SEPARATOR + "github_avatars" PATH_SEPARATOR + st.name + "_" + std::string(item["node_id"])); } st.avatar = new Texture2D(GetExecutableDir() + PATH_SEPARATOR "Data" - + PATH_SEPARATOR "cache" PATH_SEPARATOR "github_avatars" - + PATH_SEPARATOR + st.name + "_" + + PATH_SEPARATOR "cache" PATH_SEPARATOR "github_avatars" + PATH_SEPARATOR + st.name + "_" + std::string(item["node_id"])); contributors.push_back(st); } @@ -103,7 +102,7 @@ SupportersTribute::SupportersTribute() bool tmp = false; Log("Trying to load cached data."); - if (FileExists(GetExecutableDir() + PATH_SEPARATOR "Data"+ PATH_SEPARATOR "cache" PATH_SEPARATOR "stargazers.terr3dcache")) + if (FileExists(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "cache" PATH_SEPARATOR "stargazers.terr3dcache")) { Log("Found Stargazers Cached Data!"); std::string stargazersRawData = ReadShaderSourceFile(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "cache" PATH_SEPARATOR "stargazers.terr3dcache", &tmp); diff --git a/TerraForge3D/src/TextureStore/TextureStore.cpp b/TerraForge3D/src/TextureStore/TextureStore.cpp index 4c756cbc68..71672dd7a7 100644 --- a/TerraForge3D/src/TextureStore/TextureStore.cpp +++ b/TerraForge3D/src/TextureStore/TextureStore.cpp @@ -295,7 +295,7 @@ void TextureStore::DownloadTexture(int id, int res) textureStoreItems[id].abledo = baseDir + PATH_SEPARATOR "albedo.png"; tmpStr = tmpJ["nor_gl"][std::to_string(res) + "k"]["png"]["url"]; DownloadFile("https://dl.polyhaven.org", tmpStr.substr(24), baseDir + PATH_SEPARATOR "normal.png"); - textureStoreItems[id].normal = baseDir + PATH_SEPARATOR + "normal.png"; + textureStoreItems[id].normal = baseDir + PATH_SEPARATOR "normal.png"; tmpStr = tmpJ["Rough"][std::to_string(res) + "k"]["png"]["url"]; DownloadFile("https://dl.polyhaven.org", tmpStr.substr(24), baseDir + PATH_SEPARATOR "roughness.png"); textureStoreItems[id].roughness = baseDir + PATH_SEPARATOR "roughness.png";