diff --git a/DataSpec/SpecBase.cpp b/DataSpec/SpecBase.cpp index 17054dead..cb6145873 100644 --- a/DataSpec/SpecBase.cpp +++ b/DataSpec/SpecBase.cpp @@ -33,8 +33,8 @@ static const hecl::SystemChar* MomErr[] = }; constexpr uint32_t MomErrCount = std::extent::value; -SpecBase::SpecBase(hecl::Database::Project& project, bool pc) -: m_project(project), m_pc(pc), +SpecBase::SpecBase(const hecl::Database::DataSpecEntry* specEntry, hecl::Database::Project& project, bool pc) +: hecl::Database::IDataSpec(specEntry), m_project(project), m_pc(pc), m_masterShader(project.getProjectWorkingPath(), ".hecl/RetroMasterShader.blend") {} bool SpecBase::canExtract(const ExtractPassInfo& info, std::vector& reps) @@ -114,13 +114,13 @@ void SpecBase::doExtract(const ExtractPassInfo& info, FProgress progress) extractFromDisc(*m_disc, info.force, progress); } -bool SpecBase::canCook(const hecl::ProjectPath& path) +bool SpecBase::canCook(const hecl::ProjectPath& path, hecl::BlenderToken& btok) { if (!checkPathPrefix(path)) return false; if (hecl::IsPathBlend(path)) { - hecl::BlenderConnection& conn = hecl::BlenderConnection::SharedConnection(); + hecl::BlenderConnection& conn = btok.getBlenderConnection(); if (!conn.openBlend(path)) return false; if (conn.getBlendType() != hecl::BlenderConnection::BlendType::None) @@ -141,13 +141,14 @@ bool SpecBase::canCook(const hecl::ProjectPath& path) } const hecl::Database::DataSpecEntry* SpecBase::overrideDataSpec(const hecl::ProjectPath& path, - const hecl::Database::DataSpecEntry* oldEntry) + const hecl::Database::DataSpecEntry* oldEntry, + hecl::BlenderToken& btok) { if (!checkPathPrefix(path)) return nullptr; if (hecl::IsPathBlend(path)) { - hecl::BlenderConnection& conn = hecl::BlenderConnection::SharedConnection(); + hecl::BlenderConnection& conn = btok.getBlenderConnection(); if (!conn.openBlend(path)) { Log.report(logvisor::Error, _S("unable to cook '%s'"), @@ -167,12 +168,12 @@ const hecl::Database::DataSpecEntry* SpecBase::overrideDataSpec(const hecl::Proj } void SpecBase::doCook(const hecl::ProjectPath& path, const hecl::ProjectPath& cookedPath, - bool fast, FCookProgress progress) + bool fast, hecl::BlenderToken& btok, FCookProgress progress) { DataSpec::g_curSpec = this; if (hecl::IsPathBlend(path)) { - hecl::BlenderConnection& conn = hecl::BlenderConnection::SharedConnection(); + hecl::BlenderConnection& conn = btok.getBlenderConnection(); if (!conn.openBlend(path)) return; switch (conn.getBlendType()) diff --git a/DataSpec/SpecBase.hpp b/DataSpec/SpecBase.hpp index 11cb8e5c1..52136c254 100644 --- a/DataSpec/SpecBase.hpp +++ b/DataSpec/SpecBase.hpp @@ -16,11 +16,12 @@ struct SpecBase : hecl::Database::IDataSpec bool canExtract(const ExtractPassInfo& info, std::vector& reps); void doExtract(const ExtractPassInfo& info, FProgress progress); - bool canCook(const hecl::ProjectPath& path); + bool canCook(const hecl::ProjectPath& path, hecl::BlenderToken& btok); const hecl::Database::DataSpecEntry* overrideDataSpec(const hecl::ProjectPath& path, - const hecl::Database::DataSpecEntry* oldEntry); + const hecl::Database::DataSpecEntry* oldEntry, + hecl::BlenderToken& btok); void doCook(const hecl::ProjectPath& path, const hecl::ProjectPath& cookedPath, - bool fast, FCookProgress progress); + bool fast, hecl::BlenderToken& btok, FCookProgress progress); bool canPackage(const PackagePassInfo& info); void gatherDependencies(const PackagePassInfo& info, @@ -72,7 +73,7 @@ struct SpecBase : hecl::Database::IDataSpec /* Project accessor */ hecl::Database::Project& getProject() const {return m_project;} - SpecBase(hecl::Database::Project& project, bool pc); + SpecBase(const hecl::Database::DataSpecEntry* specEntry, hecl::Database::Project& project, bool pc); protected: hecl::Database::Project& m_project; bool m_pc; diff --git a/DataSpec/SpecMP1.cpp b/DataSpec/SpecMP1.cpp index 8d07f39ea..a1d787ad3 100644 --- a/DataSpec/SpecMP1.cpp +++ b/DataSpec/SpecMP1.cpp @@ -34,8 +34,8 @@ struct SpecMP1 : SpecBase hecl::ProjectPath m_cookPath; PAKRouter m_pakRouter; - SpecMP1(hecl::Database::Project& project, bool pc) - : SpecBase(project, pc), + SpecMP1(const hecl::Database::DataSpecEntry* specEntry, hecl::Database::Project& project, bool pc) + : SpecBase(specEntry, project, pc), m_workPath(project.getProjectWorkingPath(), _S("MP1")), m_cookPath(project.getProjectCookedPath(SpecEntMP1), _S("MP1")), m_pakRouter(*this, m_workPath, m_cookPath) {} @@ -356,7 +356,7 @@ hecl::Database::DataSpecEntry SpecEntMP1 = _S("MP1"), _S("Data specification for original Metroid Prime engine"), [](hecl::Database::Project& project, hecl::Database::DataSpecTool) - -> hecl::Database::IDataSpec* {return new struct SpecMP1(project, false);} + -> hecl::Database::IDataSpec* {return new struct SpecMP1(&SpecEntMP1, project, false);} }; hecl::Database::DataSpecEntry SpecEntMP1PC = @@ -367,7 +367,7 @@ hecl::Database::DataSpecEntry SpecEntMP1PC = -> hecl::Database::IDataSpec* { if (tool != hecl::Database::DataSpecTool::Extract) - return new struct SpecMP1(project, true); + return new struct SpecMP1(&SpecEntMP1PC, project, true); return nullptr; } }; diff --git a/DataSpec/SpecMP2.cpp b/DataSpec/SpecMP2.cpp index 0c28220aa..9b3836ff5 100644 --- a/DataSpec/SpecMP2.cpp +++ b/DataSpec/SpecMP2.cpp @@ -29,8 +29,8 @@ struct SpecMP2 : SpecBase hecl::ProjectPath m_cookPath; PAKRouter m_pakRouter; - SpecMP2(hecl::Database::Project& project, bool pc) - : SpecBase(project, pc), + SpecMP2(const hecl::Database::DataSpecEntry* specEntry, hecl::Database::Project& project, bool pc) + : SpecBase(specEntry, project, pc), m_workPath(project.getProjectWorkingPath(), _S("MP2")), m_cookPath(project.getProjectCookedPath(SpecEntMP2), _S("MP2")), m_pakRouter(*this, m_workPath, m_cookPath) {} @@ -307,7 +307,7 @@ hecl::Database::DataSpecEntry SpecEntMP2 _S("MP2"), _S("Data specification for original Metroid Prime 2 engine"), [](hecl::Database::Project& project, hecl::Database::DataSpecTool) - -> hecl::Database::IDataSpec* {return new struct SpecMP2(project, false);} + -> hecl::Database::IDataSpec* {return new struct SpecMP2(&SpecEntMP2, project, false);} ); hecl::Database::DataSpecEntry SpecEntMP2PC = @@ -318,7 +318,7 @@ hecl::Database::DataSpecEntry SpecEntMP2PC = -> hecl::Database::IDataSpec* { if (tool != hecl::Database::DataSpecTool::Extract) - return new struct SpecMP2(project, true); + return new struct SpecMP2(&SpecEntMP2PC, project, true); return nullptr; } }; diff --git a/DataSpec/SpecMP3.cpp b/DataSpec/SpecMP3.cpp index 02f318d17..c2c5b4a48 100644 --- a/DataSpec/SpecMP3.cpp +++ b/DataSpec/SpecMP3.cpp @@ -42,8 +42,8 @@ struct SpecMP3 : SpecBase hecl::ProjectPath m_feCookPath; PAKRouter m_fePakRouter; - SpecMP3(hecl::Database::Project& project, bool pc) - : SpecBase(project, pc), + SpecMP3(const hecl::Database::DataSpecEntry* specEntry, hecl::Database::Project& project, bool pc) + : SpecBase(specEntry, project, pc), m_workPath(project.getProjectWorkingPath(), _S("MP3")), m_cookPath(project.getProjectCookedPath(SpecEntMP3), _S("MP3")), m_pakRouter(*this, m_workPath, m_cookPath), @@ -491,7 +491,7 @@ hecl::Database::DataSpecEntry SpecEntMP3 _S("MP3"), _S("Data specification for original Metroid Prime 3 engine"), [](hecl::Database::Project& project, hecl::Database::DataSpecTool) - -> hecl::Database::IDataSpec* {return new struct SpecMP3(project, false);} + -> hecl::Database::IDataSpec* {return new struct SpecMP3(&SpecEntMP3, project, false);} ); hecl::Database::DataSpecEntry SpecEntMP3PC = @@ -502,7 +502,7 @@ hecl::Database::DataSpecEntry SpecEntMP3PC = -> hecl::Database::IDataSpec* { if (tool != hecl::Database::DataSpecTool::Extract) - return new struct SpecMP3(project, true); + return new struct SpecMP3(&SpecEntMP3PC, project, true); return nullptr; } }; diff --git a/Editor/ProjectResourceFactoryBase.cpp b/Editor/ProjectResourceFactoryBase.cpp index 381d64663..5fc6988b9 100644 --- a/Editor/ProjectResourceFactoryBase.cpp +++ b/Editor/ProjectResourceFactoryBase.cpp @@ -244,12 +244,9 @@ void ProjectResourceFactoryBase::BackgroundIndexProc() void ProjectResourceFactoryBase::CancelBackgroundIndex() { - if (m_backgroundRunning) - { - m_backgroundRunning = false; - if (m_backgroundIndexTh.joinable()) - m_backgroundIndexTh.join(); - } + m_backgroundRunning = false; + if (m_backgroundIndexTh.joinable()) + m_backgroundIndexTh.join(); } void ProjectResourceFactoryBase::BeginBackgroundIndex @@ -273,7 +270,7 @@ hecl::ProjectPath ProjectResourceFactoryBase::GetCookedPath(const hecl::ProjectP { const hecl::Database::DataSpecEntry* spec = m_origSpec; if (pcTarget) - spec = m_cookSpec->overrideDataSpec(working, m_pcSpec); + spec = m_cookSpec->overrideDataSpec(working, m_pcSpec, hecl::SharedBlenderToken); if (!spec) return {}; return working.getCookedPath(*spec); @@ -281,7 +278,7 @@ hecl::ProjectPath ProjectResourceFactoryBase::GetCookedPath(const hecl::ProjectP bool ProjectResourceFactoryBase::SyncCook(const hecl::ProjectPath& working) { - return m_clientProc.syncCook(working) == 0; + return m_clientProc.syncCook(working, m_cookSpec.get(), hecl::SharedBlenderToken); } CFactoryFnReturn ProjectResourceFactoryBase::SyncMakeObject(const SObjectTag& tag, @@ -348,7 +345,7 @@ void ProjectResourceFactoryBase::AsyncTask::EnsurePath(const hecl::ProjectPath& m_cookedPath.getModtime() < path.getModtime()) { /* Start a background cook here */ - m_cookTransaction = m_parent.m_clientProc.addCookTransaction(path); + m_cookTransaction = m_parent.m_clientProc.addCookTransaction(path, m_parent.m_cookSpec.get()); return; } diff --git a/Editor/ProjectResourceFactoryBase.hpp b/Editor/ProjectResourceFactoryBase.hpp index 033750f79..a18a748ac 100644 --- a/Editor/ProjectResourceFactoryBase.hpp +++ b/Editor/ProjectResourceFactoryBase.hpp @@ -95,6 +95,8 @@ public: void AsyncIdle(); void Shutdown() {CancelBackgroundIndex();} + + ~ProjectResourceFactoryBase() {Shutdown();} }; } diff --git a/Runtime/IFactory.hpp b/Runtime/IFactory.hpp index 10006a064..bf667a154 100644 --- a/Runtime/IFactory.hpp +++ b/Runtime/IFactory.hpp @@ -12,7 +12,7 @@ class IObj; class IFactory { public: - virtual ~IFactory() {} + virtual ~IFactory() = default; virtual std::unique_ptr Build(const SObjectTag&, const CVParamTransfer&)=0; virtual void BuildAsync(const SObjectTag&, const CVParamTransfer&, IObj**)=0; virtual void CancelBuild(const SObjectTag&)=0; diff --git a/hecl b/hecl index 1a1b41c6c..fe207bf42 160000 --- a/hecl +++ b/hecl @@ -1 +1 @@ -Subproject commit 1a1b41c6c491322427927939beb69a45d56b8bac +Subproject commit fe207bf42c08164a83420e8ed82ad7f009972307