Unify directory structure for cooked/raw assets
This commit is contained in:
parent
4dc11023df
commit
c6e6ccaa89
|
@ -71,8 +71,7 @@ bool CGameExporter::Export(nod::DiscBase *pDisc, const TString& rkOutputDir, CAs
|
||||||
|
|
||||||
mpProject->SetProjectName(mGameName);
|
mpProject->SetProjectName(mGameName);
|
||||||
mpStore = mpProject->ResourceStore();
|
mpStore = mpProject->ResourceStore();
|
||||||
mContentDir = mpStore->RawDir(false);
|
mResourcesDir = mpStore->ResourcesDir();
|
||||||
mCookedDir = mpStore->CookedDir(false);
|
|
||||||
|
|
||||||
CResourceStore *pOldStore = gpResourceStore;
|
CResourceStore *pOldStore = gpResourceStore;
|
||||||
gpResourceStore = mpStore;
|
gpResourceStore = mpStore;
|
||||||
|
@ -467,7 +466,7 @@ void CGameExporter::LoadResource(const SResourceInstance& rkResource, std::vecto
|
||||||
void CGameExporter::ExportCookedResources()
|
void CGameExporter::ExportCookedResources()
|
||||||
{
|
{
|
||||||
SCOPED_TIMER(ExportCookedResources);
|
SCOPED_TIMER(ExportCookedResources);
|
||||||
FileUtil::MakeDirectory(mCookedDir);
|
FileUtil::MakeDirectory(mResourcesDir);
|
||||||
|
|
||||||
mpProgress->SetTask(eES_ExportCooked, "Unpacking cooked assets");
|
mpProgress->SetTask(eES_ExportCooked, "Unpacking cooked assets");
|
||||||
int ResIndex = 0;
|
int ResIndex = 0;
|
||||||
|
@ -502,7 +501,7 @@ void CGameExporter::ExportResourceEditorData()
|
||||||
for (CResourceIterator It(mpStore); It && !mpProgress->ShouldCancel(); ++It, ++ResIndex)
|
for (CResourceIterator It(mpStore); It && !mpProgress->ShouldCancel(); ++It, ++ResIndex)
|
||||||
{
|
{
|
||||||
// Update progress
|
// Update progress
|
||||||
if ((ResIndex & 0x3) == 0)
|
if ((ResIndex & 0x3) == 0 || It->ResourceType() == eArea)
|
||||||
mpProgress->Report(ResIndex, mpStore->NumTotalResources(), TString::Format("Processing asset %d/%d: %s",
|
mpProgress->Report(ResIndex, mpStore->NumTotalResources(), TString::Format("Processing asset %d/%d: %s",
|
||||||
ResIndex, mpStore->NumTotalResources(), *It->CookedAssetPath(true).GetFileName()) );
|
ResIndex, mpStore->NumTotalResources(), *It->CookedAssetPath(true).GetFileName()) );
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,7 @@ class CGameExporter
|
||||||
// Directories
|
// Directories
|
||||||
TString mExportDir;
|
TString mExportDir;
|
||||||
TString mDiscDir;
|
TString mDiscDir;
|
||||||
TString mContentDir;
|
TString mResourcesDir;
|
||||||
TString mCookedDir;
|
|
||||||
|
|
||||||
TString mWorldsDirName;
|
TString mWorldsDirName;
|
||||||
|
|
||||||
|
|
|
@ -211,7 +211,7 @@ CGameProject* CGameProject::CreateProjectForExport(
|
||||||
|
|
||||||
pProj->mProjectRoot = rkProjRootDir;
|
pProj->mProjectRoot = rkProjRootDir;
|
||||||
pProj->mProjectRoot.Replace("\\", "/");
|
pProj->mProjectRoot.Replace("\\", "/");
|
||||||
pProj->mpResourceStore = new CResourceStore(pProj, "Content/", "Cooked/", Game);
|
pProj->mpResourceStore = new CResourceStore(pProj);
|
||||||
pProj->mpGameInfo->LoadGameInfo(Game);
|
pProj->mpGameInfo->LoadGameInfo(Game);
|
||||||
pProj->mLoadSuccess = true;
|
pProj->mLoadSuccess = true;
|
||||||
return pProj;
|
return pProj;
|
||||||
|
|
|
@ -90,8 +90,8 @@ public:
|
||||||
inline TString ProjectRoot() const { return mProjectRoot; }
|
inline TString ProjectRoot() const { return mProjectRoot; }
|
||||||
inline TString ResourceDBPath(bool Relative) const { return Relative ? mResourceDBPath : mProjectRoot + mResourceDBPath; }
|
inline TString ResourceDBPath(bool Relative) const { return Relative ? mResourceDBPath : mProjectRoot + mResourceDBPath; }
|
||||||
inline TString DiscDir(bool Relative) const { return Relative ? "Disc/" : mProjectRoot + "Disc/"; }
|
inline TString DiscDir(bool Relative) const { return Relative ? "Disc/" : mProjectRoot + "Disc/"; }
|
||||||
inline TString CacheDir(bool Relative) const { return Relative ? "Cache/" : mProjectRoot + "Cache/"; }
|
|
||||||
inline TString PackagesDir(bool Relative) const { return Relative ? "Packages/" : mProjectRoot + "Packages/"; }
|
inline TString PackagesDir(bool Relative) const { return Relative ? "Packages/" : mProjectRoot + "Packages/"; }
|
||||||
|
inline TString ResourcesDir(bool Relative) const { return Relative ? "Resources/" : mProjectRoot + "Resources/"; }
|
||||||
inline TString ProjectPath() const { return mProjectRoot + FileUtil::SanitizeName(mProjectName, false) + ".prj"; }
|
inline TString ProjectPath() const { return mProjectRoot + FileUtil::SanitizeName(mProjectName, false) + ".prj"; }
|
||||||
inline TString ResourceCachePath(bool Relative) const { return ResourceDBPath(Relative).GetFileDirectory() + "ResourceCacheData.rcd"; }
|
inline TString ResourceCachePath(bool Relative) const { return ResourceDBPath(Relative).GetFileDirectory() + "ResourceCacheData.rcd"; }
|
||||||
|
|
||||||
|
|
|
@ -92,15 +92,12 @@ bool CResourceEntry::HasCookedVersion() const
|
||||||
|
|
||||||
TString CResourceEntry::RawAssetPath(bool Relative) const
|
TString CResourceEntry::RawAssetPath(bool Relative) const
|
||||||
{
|
{
|
||||||
TString Ext = RawExtension();
|
return CookedAssetPath(Relative) + ".raw";
|
||||||
TString Path = mpDirectory ? mpDirectory->FullPath() : "";
|
|
||||||
TString Name = mName + "." + Ext;
|
|
||||||
return Relative ? Path + Name : mpStore->RawDir(false) + Path + Name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TString CResourceEntry::RawExtension() const
|
TString CResourceEntry::RawExtension() const
|
||||||
{
|
{
|
||||||
return mpTypeInfo->RawExtension();
|
return CookedExtension().ToString() + ".raw";
|
||||||
}
|
}
|
||||||
|
|
||||||
TString CResourceEntry::CookedAssetPath(bool Relative) const
|
TString CResourceEntry::CookedAssetPath(bool Relative) const
|
||||||
|
@ -108,7 +105,7 @@ TString CResourceEntry::CookedAssetPath(bool Relative) const
|
||||||
TString Ext = CookedExtension().ToString();
|
TString Ext = CookedExtension().ToString();
|
||||||
TString Path = mpDirectory ? mpDirectory->FullPath() : "";
|
TString Path = mpDirectory ? mpDirectory->FullPath() : "";
|
||||||
TString Name = mName + "." + Ext;
|
TString Name = mName + "." + Ext;
|
||||||
return Relative ? Path + Name : mpStore->CookedDir(false) + Path + Name;
|
return Relative ? Path + Name : mpStore->ResourcesDir() + Path + Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
CFourCC CResourceEntry::CookedExtension() const
|
CFourCC CResourceEntry::CookedExtension() const
|
||||||
|
@ -383,7 +380,7 @@ bool CResourceEntry::Move(const TString& rkDir, const TString& rkName)
|
||||||
TString NewCookedPath = CookedAssetPath();
|
TString NewCookedPath = CookedAssetPath();
|
||||||
TString NewRawPath = RawAssetPath();
|
TString NewRawPath = RawAssetPath();
|
||||||
|
|
||||||
Log::Write("MOVING RESOURCE: " + FileUtil::MakeRelative(OldCookedPath, mpStore->CookedDir(false)) + " --> " + FileUtil::MakeRelative(NewCookedPath, mpStore->CookedDir(false)));
|
Log::Write("MOVING RESOURCE: " + FileUtil::MakeRelative(OldCookedPath, mpStore->ResourcesDir()) + " --> " + FileUtil::MakeRelative(NewCookedPath, mpStore->ResourcesDir()));
|
||||||
|
|
||||||
// If the old/new paths are the same then we should have already exited as CanMoveTo() should have returned false
|
// If the old/new paths are the same then we should have already exited as CanMoveTo() should have returned false
|
||||||
ASSERT(OldCookedPath != NewCookedPath && OldRawPath != NewRawPath);
|
ASSERT(OldCookedPath != NewCookedPath && OldRawPath != NewRawPath);
|
||||||
|
@ -432,7 +429,6 @@ bool CResourceEntry::Move(const TString& rkDir, const TString& rkName)
|
||||||
FSMoveSuccess = pOldDir->RemoveChildResource(this);
|
FSMoveSuccess = pOldDir->RemoveChildResource(this);
|
||||||
ASSERT(FSMoveSuccess == true); // this shouldn't be able to fail
|
ASSERT(FSMoveSuccess == true); // this shouldn't be able to fail
|
||||||
mpDirectory->AddChild("", this);
|
mpDirectory->AddChild("", this);
|
||||||
mpStore->ConditionalDeleteDirectory(pOldDir);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mpStore->SetDatabaseDirty();
|
mpStore->SetDatabaseDirty();
|
||||||
|
|
|
@ -26,19 +26,7 @@ CResourceStore::CResourceStore(const TString& rkDatabasePath)
|
||||||
mDatabaseName = rkDatabasePath.GetFileName();
|
mDatabaseName = rkDatabasePath.GetFileName();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Constructor for game exporter
|
// Main constructor for game projects and game exporter
|
||||||
CResourceStore::CResourceStore(CGameProject *pProject, const TString& rkRawDir, const TString& rkCookedDir, EGame Game)
|
|
||||||
: mpProj(nullptr)
|
|
||||||
, mGame(Game)
|
|
||||||
, mRawDir(rkRawDir)
|
|
||||||
, mCookedDir(rkCookedDir)
|
|
||||||
, mDatabaseDirty(false)
|
|
||||||
, mCacheFileDirty(false)
|
|
||||||
{
|
|
||||||
SetProject(pProject);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Main constructor for game projects
|
|
||||||
CResourceStore::CResourceStore(CGameProject *pProject)
|
CResourceStore::CResourceStore(CGameProject *pProject)
|
||||||
: mpProj(nullptr)
|
: mpProj(nullptr)
|
||||||
, mGame(eUnknownGame)
|
, mGame(eUnknownGame)
|
||||||
|
@ -84,9 +72,7 @@ void CResourceStore::SerializeResourceDatabase(IArchive& rArc)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Serialize
|
// Serialize
|
||||||
rArc << SERIAL("RawDir", mRawDir)
|
rArc << SERIAL_CONTAINER_AUTO(Resources, "Resource");
|
||||||
<< SERIAL("CookedDir", mCookedDir)
|
|
||||||
<< SERIAL_CONTAINER_AUTO(Resources, "Resource");
|
|
||||||
|
|
||||||
// Register resources
|
// Register resources
|
||||||
if (rArc.IsReader())
|
if (rArc.IsReader())
|
||||||
|
@ -310,10 +296,9 @@ void CResourceStore::ConditionalDeleteDirectory(CVirtualDirectory *pDir)
|
||||||
if (pDir->IsEmpty())
|
if (pDir->IsEmpty())
|
||||||
{
|
{
|
||||||
// If this directory is part of the project, then we should delete the corresponding filesystem directories
|
// If this directory is part of the project, then we should delete the corresponding filesystem directories
|
||||||
if (pDir->GetRoot() == mpDatabaseRoot)
|
if (pDir->GetRoot() == mpDatabaseRoot && !pDir->IsRoot())
|
||||||
{
|
{
|
||||||
FileUtil::DeleteDirectory(RawDir(false) + pDir->FullPath(), true);
|
FileUtil::DeleteDirectory(ResourcesDir() + pDir->FullPath(), true);
|
||||||
FileUtil::DeleteDirectory(CookedDir(false) + pDir->FullPath(), true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CVirtualDirectory *pParent = pDir->Parent();
|
CVirtualDirectory *pParent = pDir->Parent();
|
||||||
|
@ -423,7 +408,7 @@ CResource* CResourceStore::LoadResource(const TString& rkPath)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ASSERT(Ext.CaseInsensitiveCompare(pEntry->RawExtension()));
|
ASSERT( rkPath.EndsWith(pEntry->RawExtension()) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,6 @@ class CResourceStore
|
||||||
// Directory paths
|
// Directory paths
|
||||||
TString mDatabasePath;
|
TString mDatabasePath;
|
||||||
TString mDatabaseName;
|
TString mDatabaseName;
|
||||||
TString mRawDir;
|
|
||||||
TString mCookedDir;
|
|
||||||
|
|
||||||
enum EDatabaseVersion
|
enum EDatabaseVersion
|
||||||
{
|
{
|
||||||
|
@ -43,7 +41,6 @@ class CResourceStore
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CResourceStore(const TString& rkDatabasePath);
|
CResourceStore(const TString& rkDatabasePath);
|
||||||
CResourceStore(CGameProject *pProject, const TString& rkRawDir, const TString& rkCookedDir, EGame Game);
|
|
||||||
CResourceStore(CGameProject *pProject);
|
CResourceStore(CGameProject *pProject);
|
||||||
~CResourceStore();
|
~CResourceStore();
|
||||||
void SerializeResourceDatabase(IArchive& rArc);
|
void SerializeResourceDatabase(IArchive& rArc);
|
||||||
|
@ -78,10 +75,9 @@ public:
|
||||||
inline CGameProject* Project() const { return mpProj; }
|
inline CGameProject* Project() const { return mpProj; }
|
||||||
inline EGame Game() const { return mGame; }
|
inline EGame Game() const { return mGame; }
|
||||||
inline TString DatabaseRootPath() const { return mDatabasePath; }
|
inline TString DatabaseRootPath() const { return mDatabasePath; }
|
||||||
inline TString RawDir(bool Relative) const { return Relative ? mRawDir : mDatabasePath + mRawDir; }
|
inline TString ResourcesDir() const { return IsEditorStore() ? DatabaseRootPath() : DatabaseRootPath() + "Resources/"; }
|
||||||
inline TString CookedDir(bool Relative) const { return Relative ? mCookedDir : mDatabasePath + mCookedDir; }
|
inline TString DatabasePath() const { return DatabaseRootPath() + "ResourceDatabase.xml"; }
|
||||||
inline TString DatabasePath() const { return DatabaseRootPath() + mDatabaseName; }
|
inline TString CacheDataPath() const { return DatabaseRootPath() + "ResourceCacheData.bin"; }
|
||||||
inline TString CacheDataPath() const { return DatabaseRootPath() + "ResourceCacheData.rcd"; }
|
|
||||||
inline CVirtualDirectory* RootDirectory() const { return mpDatabaseRoot; }
|
inline CVirtualDirectory* RootDirectory() const { return mpDatabaseRoot; }
|
||||||
inline u32 NumTotalResources() const { return mResourceEntries.size(); }
|
inline u32 NumTotalResources() const { return mResourceEntries.size(); }
|
||||||
inline u32 NumLoadedResources() const { return mLoadedResources.size(); }
|
inline u32 NumLoadedResources() const { return mLoadedResources.size(); }
|
||||||
|
@ -89,6 +85,7 @@ public:
|
||||||
|
|
||||||
inline void SetDatabaseDirty() { mDatabaseDirty = true; }
|
inline void SetDatabaseDirty() { mDatabaseDirty = true; }
|
||||||
inline void SetCacheDataDirty() { mCacheFileDirty = true; }
|
inline void SetCacheDataDirty() { mCacheFileDirty = true; }
|
||||||
|
inline bool IsEditorStore() const { return mpProj == nullptr; }
|
||||||
};
|
};
|
||||||
|
|
||||||
extern CResourceStore *gpResourceStore;
|
extern CResourceStore *gpResourceStore;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "Core/GameProject/DependencyListBuilders.h"
|
#include "Core/GameProject/DependencyListBuilders.h"
|
||||||
#include <Common/Log.h>
|
#include <Common/Log.h>
|
||||||
|
|
||||||
const bool gkForceDisableCompression = true;
|
const bool gkForceDisableCompression = false;
|
||||||
|
|
||||||
CAreaCooker::CAreaCooker()
|
CAreaCooker::CAreaCooker()
|
||||||
: mGeometrySecNum(-1)
|
: mGeometrySecNum(-1)
|
||||||
|
|
|
@ -614,6 +614,8 @@ void CAreaLoader::SetUpObjects(CScriptLayer *pGenLayer)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Merge objects from the generated layer back into the regular script layers
|
// Merge objects from the generated layer back into the regular script layers
|
||||||
|
if (pGenLayer)
|
||||||
|
{
|
||||||
while (pGenLayer->NumInstances() != 0)
|
while (pGenLayer->NumInstances() != 0)
|
||||||
{
|
{
|
||||||
CScriptObject *pInst = pGenLayer->InstanceByIndex(0);
|
CScriptObject *pInst = pGenLayer->InstanceByIndex(0);
|
||||||
|
@ -634,6 +636,7 @@ void CAreaLoader::SetUpObjects(CScriptLayer *pGenLayer)
|
||||||
mpArea->mObjectMap[InstanceID] = pInst;
|
mpArea->mObjectMap[InstanceID] = pInst;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Iterate over all objects
|
// Iterate over all objects
|
||||||
for (auto Iter = mpArea->mObjectMap.begin(); Iter != mpArea->mObjectMap.end(); Iter++)
|
for (auto Iter = mpArea->mObjectMap.begin(); Iter != mpArea->mObjectMap.end(); Iter++)
|
||||||
|
|
|
@ -101,7 +101,9 @@ public:
|
||||||
|
|
||||||
case eStateMachine:
|
case eStateMachine:
|
||||||
// AFSM currently unsupported
|
// AFSM currently unsupported
|
||||||
if (pEntry->Game() == eCorruptionProto || pEntry->Game() == eCorruption)
|
if (pEntry->Game() <= eEchoes)
|
||||||
|
pRes = new CDependencyGroup(pEntry);
|
||||||
|
else if (pEntry->Game() <= eCorruption)
|
||||||
pRes = CUnsupportedFormatLoader::LoadFSM2(rInput, pEntry);
|
pRes = CUnsupportedFormatLoader::LoadFSM2(rInput, pEntry);
|
||||||
else if (pEntry->Game() == eReturns)
|
else if (pEntry->Game() == eReturns)
|
||||||
pRes = CUnsupportedFormatLoader::LoadFSMC(rInput, pEntry);
|
pRes = CUnsupportedFormatLoader::LoadFSMC(rInput, pEntry);
|
||||||
|
|
Loading…
Reference in New Issue