diff --git a/src/common/fileManager/fileWatcher.cpp b/src/common/fileManager/fileWatcher.cpp index a4b781de..7239595b 100644 --- a/src/common/fileManager/fileWatcher.cpp +++ b/src/common/fileManager/fileWatcher.cpp @@ -41,10 +41,12 @@ void FileWatcher::scanForChanges(bool callbacks) void FileWatcher::loadCache(std::filesystem::path changeCache) { - SerializedData cacheData; _changeCache = std::move(changeCache); - if(!FileManager::readFile(_changeCache, cacheData.vector())) + + SerializedData cacheData; + if (!FileManager::readFile(_changeCache, cacheData.vector())) return; + InputSerializer s(cacheData); uint32_t count = 0; s >> count; @@ -53,8 +55,10 @@ void FileWatcher::loadCache(std::filesystem::path changeCache) std::string path; std::filesystem::file_time_type lastUpdate; s >> path >> lastUpdate; + if(!std::filesystem::exists(path)) continue; + _lastUpdate.insert({path, lastUpdate}); } } @@ -63,10 +67,13 @@ void FileWatcher::saveCache() { if(_changeCache.empty()) return; + SerializedData cacheData; OutputSerializer s(cacheData); + uint32_t count = _lastUpdate.size(); s << count; + for(auto& u : _lastUpdate) s << u.first << u.second; FileManager::writeFile(_changeCache, cacheData.vector()); diff --git a/src/common/utility/threadPool.h b/src/common/utility/threadPool.h index 3b1b0de4..afe412a0 100644 --- a/src/common/utility/threadPool.h +++ b/src/common/utility/threadPool.h @@ -2,6 +2,7 @@ #include #include +#include #include #include #include diff --git a/src/editor/CMakeLists.txt b/src/editor/CMakeLists.txt index b0c3f825..e02e17ae 100644 --- a/src/editor/CMakeLists.txt +++ b/src/editor/CMakeLists.txt @@ -38,6 +38,9 @@ install(TARGETS BraneEditor if(MSVC) install(FILES $ DESTINATION . OPTIONAL COMPONENT Editor) endif() + +install(TARGETS BraneEditor + DESTINATION .) install(FILES config.json ${PROJECT_SOURCE_DIR}/media/branelogo.png DESTINATION . COMPONENT Editor) diff --git a/src/editor/assets/CMakeLists.txt b/src/editor/assets/CMakeLists.txt index 7a9fa68e..0d588685 100644 --- a/src/editor/assets/CMakeLists.txt +++ b/src/editor/assets/CMakeLists.txt @@ -1,11 +1,15 @@ find_package(jsoncpp CONFIG REQUIRED) -set(CMAKE_FOLDER ${CMAKE_FOLDER}/Assets) add_library(editorAssets STATIC gltfLoader.cpp assemblyBuilder.cpp editorAsset.cpp types/editorShaderAsset.cpp types/editorAssemblyAsset.cpp - jsonVirtualType.cpp assetCache.cpp assetCache.h types/editorMaterialAsset.cpp types/editorMaterialAsset.h types/editorChunkAsset.cpp types/editorChunkAsset.h assemblyReloadManager.cpp assemblyReloadManager.h types/editorImageAsset.cpp types/editorImageAsset.h) + jsonVirtualType.cpp + assetCache.cpp + types/editorMaterialAsset.cpp + types/editorChunkAsset.cpp + assemblyReloadManager.cpp + types/editorImageAsset.cpp) target_link_libraries(editorAssets PUBLIC assets_client ecs JsonCpp::JsonCpp) diff --git a/src/editor/braneProject.cpp b/src/editor/braneProject.cpp index f5ea4fe9..af66b61a 100644 --- a/src/editor/braneProject.cpp +++ b/src/editor/braneProject.cpp @@ -110,12 +110,16 @@ void BraneProject::initLoaded() { refreshAssets(); - Json::Value& assets = _file.data()["assets"]; + // Create required project data directories. + const auto projectRootDirectory = projectDirectory(); + std::filesystem::create_directories(projectDirectory() / "assets"); + std::filesystem::create_directories(projectDirectory() / "cache"); + if(!_file.data().isMember("assetIdCounter")) _file.data()["assetIdCounter"] = 0; _fileWatcher = std::make_unique(); - _fileWatcher->loadCache(projectDirectory() / "cache" / "changeCache"); + _fileWatcher->loadCache(projectDirectory() / "cache" / "changeCache.bin"); _fileWatcher->watchDirectory(projectDirectory() / "assets"); _fileWatcher->addFileWatcher(".gltf", [this](const std::filesystem::path& path) { Runtime::log("loading gltf: " + path.string()); @@ -303,26 +307,31 @@ void BraneProject::refreshAssets() assets.removeMember(id); } - std::unordered_set assetTypes = {".shader", ".material", ".assembly", ".image"}; - for(auto& file : std::filesystem::recursive_directory_iterator{projectDirectory() / "assets"}) + if (assets.empty()) + return; + + const std::unordered_set assetFileTypes = {".shader", ".material", ".assembly", ".image"}; + + for (const auto& assetFile : std::filesystem::recursive_directory_iterator{projectDirectory() / "assets"}) { - if(!file.is_regular_file()) + if(!assetFile.is_regular_file()) continue; - if(!assetTypes.count(file.path().extension().string())) + if(!assetFileTypes.contains(assetFile.path().extension().string())) continue; + EditorAsset* asset = nullptr; try { - asset = EditorAsset::openUnknownAsset(file, *this); + asset = EditorAsset::openUnknownAsset(assetFile, *this); } catch(const std::exception& e) { - Runtime::error("Could not open asset " + file.path().string() + " error: " + e.what()); + Runtime::error("Could not open asset " + assetFile.path().string() + " error: " + e.what()); continue; } if(!asset) { - Runtime::error("Could not automatically open asset with extension " + file.path().extension().string()); + Runtime::error("Could not automatically open asset with extension " + assetFile.path().extension().string()); continue; } registerAssetLocation(asset); diff --git a/vcpkg.json b/vcpkg.json index 23750f72..2df89404 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -1,26 +1,27 @@ { - "dependencies": [ - "openssl", - "asio", - "cpp-httplib", - "gtest", - "jsoncpp", - "sqlite3", - "shaderc", - "spirv-cross", - "glm", - "vulkan", - "glfw3", - { - "name": "imgui", - "features": [ - "docking-experimental", - "glfw-binding", - "vulkan-binding" - ] - }, - "imguizmo", - "tinyfiledialogs", - "stb" - ] + "dependencies": [ + "openssl", + "asio", + "cpp-httplib", + "gtest", + "jsoncpp", + "sqlite3", + "shaderc", + "spirv-cross", + "glm", + "vulkan", + "glfw3", + { + "name": "imgui", + "features": [ + "docking-experimental", + "glfw-binding", + "vulkan-binding" + ] + }, + "imguizmo", + "tinyfiledialogs", + "stb" + ], + "builtin-baseline": "5a5662402382b1aa72f64440717b75258992eba0" }