mirror of https://github.com/AxioDL/metaforce.git
World cooking bug fixes
This commit is contained in:
parent
5e2f2e3af8
commit
e192fb77a4
|
@ -8,6 +8,7 @@ namespace DataSpec
|
||||||
logvisor::Module LogDNACommon("urde::DNACommon");
|
logvisor::Module LogDNACommon("urde::DNACommon");
|
||||||
ThreadLocalPtr<SpecBase> g_curSpec;
|
ThreadLocalPtr<SpecBase> g_curSpec;
|
||||||
ThreadLocalPtr<PAKRouterBase> g_PakRouter;
|
ThreadLocalPtr<PAKRouterBase> g_PakRouter;
|
||||||
|
ThreadLocalPtr<hecl::BlenderToken> g_ThreadBlenderToken;
|
||||||
ThreadLocalPtr<hecl::Database::Project> UniqueIDBridge::s_Project;
|
ThreadLocalPtr<hecl::Database::Project> UniqueIDBridge::s_Project;
|
||||||
UniqueID32 UniqueID32::kInvalidId;
|
UniqueID32 UniqueID32::kInvalidId;
|
||||||
|
|
||||||
|
@ -29,7 +30,7 @@ hecl::ProjectPath UniqueIDBridge::TranslatePakIdToPath(const IDType& id, bool si
|
||||||
{
|
{
|
||||||
if (pakRouter)
|
if (pakRouter)
|
||||||
{
|
{
|
||||||
if (!silenceWarnings)
|
if (!silenceWarnings && id)
|
||||||
LogDNACommon.report(logvisor::Warning,
|
LogDNACommon.report(logvisor::Warning,
|
||||||
"unable to translate %s to path", id.toString().c_str());
|
"unable to translate %s to path", id.toString().c_str());
|
||||||
return {};
|
return {};
|
||||||
|
@ -42,7 +43,7 @@ hecl::ProjectPath UniqueIDBridge::TranslatePakIdToPath(const IDType& id, bool si
|
||||||
const hecl::ProjectPath* search = project->lookupBridgePath(id.toUint64());
|
const hecl::ProjectPath* search = project->lookupBridgePath(id.toUint64());
|
||||||
if (!search)
|
if (!search)
|
||||||
{
|
{
|
||||||
if (!silenceWarnings)
|
if (!silenceWarnings && id)
|
||||||
LogDNACommon.report(logvisor::Warning,
|
LogDNACommon.report(logvisor::Warning,
|
||||||
"unable to translate %s to path", id.toString().c_str());
|
"unable to translate %s to path", id.toString().c_str());
|
||||||
return {};
|
return {};
|
||||||
|
|
|
@ -18,6 +18,7 @@ namespace DataSpec
|
||||||
extern logvisor::Module LogDNACommon;
|
extern logvisor::Module LogDNACommon;
|
||||||
extern ThreadLocalPtr<SpecBase> g_curSpec;
|
extern ThreadLocalPtr<SpecBase> g_curSpec;
|
||||||
extern ThreadLocalPtr<class PAKRouterBase> g_PakRouter;
|
extern ThreadLocalPtr<class PAKRouterBase> g_PakRouter;
|
||||||
|
extern ThreadLocalPtr<hecl::BlenderToken> g_ThreadBlenderToken;
|
||||||
|
|
||||||
/* This comes up a great deal */
|
/* This comes up a great deal */
|
||||||
typedef athena::io::DNA<athena::BigEndian> BigDNA;
|
typedef athena::io::DNA<athena::BigEndian> BigDNA;
|
||||||
|
|
|
@ -473,14 +473,14 @@ hecl::SystemString PAKRouter<BRIDGETYPE>::getResourceRelativePath(const EntryTyp
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class BRIDGETYPE>
|
template <class BRIDGETYPE>
|
||||||
std::string PAKRouter<BRIDGETYPE>::getBestEntryName(const EntryType& entry) const
|
std::string PAKRouter<BRIDGETYPE>::getBestEntryName(const EntryType& entry, bool stdOverride) const
|
||||||
{
|
{
|
||||||
std::string name;
|
std::string name;
|
||||||
for (const BRIDGETYPE& bridge : *m_bridges)
|
for (const BRIDGETYPE& bridge : *m_bridges)
|
||||||
{
|
{
|
||||||
const typename BRIDGETYPE::PAKType& pak = bridge.getPAK();
|
const typename BRIDGETYPE::PAKType& pak = bridge.getPAK();
|
||||||
|
|
||||||
if (isShared())
|
if (stdOverride && isShared())
|
||||||
{
|
{
|
||||||
if (entry.type == FOURCC('MLVL'))
|
if (entry.type == FOURCC('MLVL'))
|
||||||
return "!world";
|
return "!world";
|
||||||
|
@ -499,7 +499,7 @@ std::string PAKRouter<BRIDGETYPE>::getBestEntryName(const EntryType& entry) cons
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class BRIDGETYPE>
|
template <class BRIDGETYPE>
|
||||||
std::string PAKRouter<BRIDGETYPE>::getBestEntryName(const IDType& entry) const
|
std::string PAKRouter<BRIDGETYPE>::getBestEntryName(const IDType& entry, bool stdOverride) const
|
||||||
{
|
{
|
||||||
std::string name;
|
std::string name;
|
||||||
for (const BRIDGETYPE& bridge : *m_bridges)
|
for (const BRIDGETYPE& bridge : *m_bridges)
|
||||||
|
@ -509,7 +509,7 @@ std::string PAKRouter<BRIDGETYPE>::getBestEntryName(const IDType& entry) const
|
||||||
if (!e)
|
if (!e)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (isShared())
|
if (stdOverride && isShared())
|
||||||
{
|
{
|
||||||
if (e->type == FOURCC('MLVL'))
|
if (e->type == FOURCC('MLVL'))
|
||||||
return "!world";
|
return "!world";
|
||||||
|
@ -543,7 +543,7 @@ bool PAKRouter<BRIDGETYPE>::extractResources(const BRIDGETYPE& pakBridge, bool f
|
||||||
if (extractor.weight != w)
|
if (extractor.weight != w)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
std::string bestName = getBestEntryName(*item);
|
std::string bestName = getBestEntryName(*item, false);
|
||||||
hecl::SystemStringView bestNameView(bestName);
|
hecl::SystemStringView bestNameView(bestName);
|
||||||
float thisFac = ++count / fsz;
|
float thisFac = ++count / fsz;
|
||||||
progress(bestNameView.c_str(), thisFac);
|
progress(bestNameView.c_str(), thisFac);
|
||||||
|
|
|
@ -200,8 +200,8 @@ public:
|
||||||
|
|
||||||
hecl::SystemString getResourceRelativePath(const EntryType& a, const IDType& b) const;
|
hecl::SystemString getResourceRelativePath(const EntryType& a, const IDType& b) const;
|
||||||
|
|
||||||
std::string getBestEntryName(const EntryType& entry) const;
|
std::string getBestEntryName(const EntryType& entry, bool stdOverride=true) const;
|
||||||
std::string getBestEntryName(const IDType& entry) const;
|
std::string getBestEntryName(const IDType& entry, bool stdOverride=true) const;
|
||||||
|
|
||||||
bool extractResources(const BRIDGETYPE& pakBridge, bool force, hecl::BlenderToken& btok,
|
bool extractResources(const BRIDGETYPE& pakBridge, bool force, hecl::BlenderToken& btok,
|
||||||
std::function<void(const hecl::SystemChar*, float)> progress);
|
std::function<void(const hecl::SystemChar*, float)> progress);
|
||||||
|
|
|
@ -40,7 +40,8 @@ bool MLVL::Extract(const SpecBase& dataSpec,
|
||||||
entry, force, fileChanged);
|
entry, force, fileChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MLVL::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPath, const World& wld)
|
bool MLVL::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPath,
|
||||||
|
const World& wld, hecl::BlenderToken& btok)
|
||||||
{
|
{
|
||||||
MLVL mlvl = {};
|
MLVL mlvl = {};
|
||||||
athena::io::FileReader reader(inPath.getWithExtension(_S(".yaml"), true).getAbsolutePath());
|
athena::io::FileReader reader(inPath.getWithExtension(_S(".yaml"), true).getAbsolutePath());
|
||||||
|
@ -120,7 +121,7 @@ bool MLVL::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat
|
||||||
/* Area map */
|
/* Area map */
|
||||||
hecl::ProjectPath mapPath(area.path, _S("/!map.blend"));
|
hecl::ProjectPath mapPath(area.path, _S("/!map.blend"));
|
||||||
if (mapPath.isFile())
|
if (mapPath.isFile())
|
||||||
mapaTags.push_back(g_curSpec->BuildTagFromPath(mapPath, hecl::SharedBlenderToken));
|
mapaTags.push_back(g_curSpec->BuildTagFromPath(mapPath, btok));
|
||||||
|
|
||||||
/* Populate area record */
|
/* Populate area record */
|
||||||
mlvl.areas.emplace_back();
|
mlvl.areas.emplace_back();
|
||||||
|
@ -200,6 +201,7 @@ bool MLVL::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat
|
||||||
|
|
||||||
/* Gather memory relays, scans, and dependencies */
|
/* Gather memory relays, scans, and dependencies */
|
||||||
{
|
{
|
||||||
|
g_ThreadBlenderToken.reset(&btok);
|
||||||
std::vector<hecl::ProjectPath> depPaths;
|
std::vector<hecl::ProjectPath> depPaths;
|
||||||
std::vector<Scan> scans;
|
std::vector<Scan> scans;
|
||||||
for (std::unique_ptr<IScriptObject>& obj : layer.objects)
|
for (std::unique_ptr<IScriptObject>& obj : layer.objects)
|
||||||
|
@ -221,9 +223,9 @@ bool MLVL::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat
|
||||||
else if (obj->type == 0x3A)
|
else if (obj->type == 0x3A)
|
||||||
{
|
{
|
||||||
SpecialFunction& specialFunc = static_cast<SpecialFunction&>(*obj);
|
SpecialFunction& specialFunc = static_cast<SpecialFunction&>(*obj);
|
||||||
if (specialFunc.type == ESpecialFunctionType::CinematicSkip)
|
if (specialFunc.function == ESpecialFunctionType::CinematicSkip)
|
||||||
savw.skippableCutscenes.push_back(specialFunc.id);
|
savw.skippableCutscenes.push_back(specialFunc.id);
|
||||||
else if (specialFunc.type == ESpecialFunctionType::ScriptLayerController)
|
else if (specialFunc.function == ESpecialFunctionType::ScriptLayerController)
|
||||||
{
|
{
|
||||||
savw.layers.emplace_back();
|
savw.layers.emplace_back();
|
||||||
SAVWCommon::Layer& layer = savw.layers.back();
|
SAVWCommon::Layer& layer = savw.layers.back();
|
||||||
|
@ -248,7 +250,7 @@ bool MLVL::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat
|
||||||
if (addedPaths.find(path.hash()) == addedPaths.cend())
|
if (addedPaths.find(path.hash()) == addedPaths.cend())
|
||||||
{
|
{
|
||||||
addedPaths.insert(path.hash());
|
addedPaths.insert(path.hash());
|
||||||
urde::SObjectTag tag = g_curSpec->BuildTagFromPath(path, hecl::SharedBlenderToken);
|
urde::SObjectTag tag = g_curSpec->BuildTagFromPath(path, btok);
|
||||||
areaOut.deps.emplace_back(tag.id, tag.type);
|
areaOut.deps.emplace_back(tag.id, tag.type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -300,12 +302,12 @@ bool MLVL::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat
|
||||||
if (addedPaths.find(path.hash()) == addedPaths.cend())
|
if (addedPaths.find(path.hash()) == addedPaths.cend())
|
||||||
{
|
{
|
||||||
addedPaths.insert(path.hash());
|
addedPaths.insert(path.hash());
|
||||||
urde::SObjectTag tag = g_curSpec->BuildTagFromPath(path, hecl::SharedBlenderToken);
|
urde::SObjectTag tag = g_curSpec->BuildTagFromPath(path, btok);
|
||||||
areaOut.deps.emplace_back(tag.id, tag.type);
|
areaOut.deps.emplace_back(tag.id, tag.type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
urde::SObjectTag tag = g_curSpec->BuildTagFromPath(areaPath, hecl::SharedBlenderToken);
|
urde::SObjectTag tag = g_curSpec->BuildTagFromPath(areaPath, btok);
|
||||||
areaOut.deps.emplace_back(tag.id, tag.type);
|
areaOut.deps.emplace_back(tag.id, tag.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -330,7 +332,7 @@ bool MLVL::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat
|
||||||
/* Write out MAPW */
|
/* Write out MAPW */
|
||||||
{
|
{
|
||||||
hecl::ProjectPath mapwCooked =
|
hecl::ProjectPath mapwCooked =
|
||||||
mapwPath.getCookedPath(*g_curSpec->overrideDataSpec(mapwPath, nullptr, hecl::SharedBlenderToken));
|
mapwPath.getCookedPath(*g_curSpec->overrideDataSpec(mapwPath, nullptr, btok));
|
||||||
mapwCooked.makeDirChain(false);
|
mapwCooked.makeDirChain(false);
|
||||||
athena::io::FileWriter fo(mapwCooked.getAbsolutePath());
|
athena::io::FileWriter fo(mapwCooked.getAbsolutePath());
|
||||||
fo.writeUint32Big(0xDEADF00D);
|
fo.writeUint32Big(0xDEADF00D);
|
||||||
|
@ -350,7 +352,7 @@ bool MLVL::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat
|
||||||
savw.scanCount = savw.scans.size();
|
savw.scanCount = savw.scans.size();
|
||||||
|
|
||||||
hecl::ProjectPath savwCooked =
|
hecl::ProjectPath savwCooked =
|
||||||
savwPath.getCookedPath(*g_curSpec->overrideDataSpec(savwPath, nullptr, hecl::SharedBlenderToken));
|
savwPath.getCookedPath(*g_curSpec->overrideDataSpec(savwPath, nullptr, btok));
|
||||||
savwCooked.makeDirChain(false);
|
savwCooked.makeDirChain(false);
|
||||||
athena::io::FileWriter fo(savwCooked.getAbsolutePath());
|
athena::io::FileWriter fo(savwCooked.getAbsolutePath());
|
||||||
savw.write(fo);
|
savw.write(fo);
|
||||||
|
|
|
@ -153,7 +153,8 @@ struct MLVL : BigYAML
|
||||||
|
|
||||||
static bool Cook(const hecl::ProjectPath& outPath,
|
static bool Cook(const hecl::ProjectPath& outPath,
|
||||||
const hecl::ProjectPath& inPath,
|
const hecl::ProjectPath& inPath,
|
||||||
const World& wld);
|
const World& wld,
|
||||||
|
hecl::BlenderToken& btok);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,7 @@ bool MREA::Extract(const SpecBase& dataSpec,
|
||||||
"from mathutils import Vector\n"
|
"from mathutils import Vector\n"
|
||||||
"\n"
|
"\n"
|
||||||
"bpy.context.scene.name = '%s'\n",
|
"bpy.context.scene.name = '%s'\n",
|
||||||
pakRouter.getBestEntryName(entry).c_str());
|
pakRouter.getBestEntryName(entry, false).c_str());
|
||||||
DNACMDL::InitGeomBlenderContext(os, dataSpec.getMasterShaderPath(), true);
|
DNACMDL::InitGeomBlenderContext(os, dataSpec.getMasterShaderPath(), true);
|
||||||
MaterialSet::RegisterMaterialProps(os);
|
MaterialSet::RegisterMaterialProps(os);
|
||||||
os << "# Clear Scene\n"
|
os << "# Clear Scene\n"
|
||||||
|
|
|
@ -15,7 +15,7 @@ struct SpecialFunction : IScriptObject
|
||||||
String<-1> name;
|
String<-1> name;
|
||||||
Value<atVec3f> location;
|
Value<atVec3f> location;
|
||||||
Value<atVec3f> orientation;
|
Value<atVec3f> orientation;
|
||||||
Value<ESpecialFunctionType> type;
|
Value<ESpecialFunctionType> function;
|
||||||
String<-1> unknown1;
|
String<-1> unknown1;
|
||||||
Value<float> unknown2;
|
Value<float> unknown2;
|
||||||
Value<float> unknown3;
|
Value<float> unknown3;
|
||||||
|
|
|
@ -214,7 +214,7 @@ bool MREA::Extract(const SpecBase& dataSpec,
|
||||||
"from mathutils import Vector\n"
|
"from mathutils import Vector\n"
|
||||||
"\n"
|
"\n"
|
||||||
"bpy.context.scene.name = '%s'\n",
|
"bpy.context.scene.name = '%s'\n",
|
||||||
pakRouter.getBestEntryName(entry).c_str());
|
pakRouter.getBestEntryName(entry, false).c_str());
|
||||||
DNACMDL::InitGeomBlenderContext(os, dataSpec.getMasterShaderPath(), true);
|
DNACMDL::InitGeomBlenderContext(os, dataSpec.getMasterShaderPath(), true);
|
||||||
MaterialSet::RegisterMaterialProps(os);
|
MaterialSet::RegisterMaterialProps(os);
|
||||||
os << "# Clear Scene\n"
|
os << "# Clear Scene\n"
|
||||||
|
|
|
@ -113,7 +113,7 @@ bool MREA::Extract(const SpecBase& dataSpec,
|
||||||
"from mathutils import Vector\n"
|
"from mathutils import Vector\n"
|
||||||
"\n"
|
"\n"
|
||||||
"bpy.context.scene.name = '%s'\n",
|
"bpy.context.scene.name = '%s'\n",
|
||||||
pakRouter.getBestEntryName(entry).c_str());
|
pakRouter.getBestEntryName(entry, false).c_str());
|
||||||
DNACMDL::InitGeomBlenderContext(os, dataSpec.getMasterShaderPath(), true);
|
DNACMDL::InitGeomBlenderContext(os, dataSpec.getMasterShaderPath(), true);
|
||||||
MaterialSet::RegisterMaterialProps(os);
|
MaterialSet::RegisterMaterialProps(os);
|
||||||
os << "# Clear Scene\n"
|
os << "# Clear Scene\n"
|
||||||
|
|
|
@ -224,6 +224,7 @@ const hecl::Database::DataSpecEntry* SpecBase::overrideDataSpec(const hecl::Proj
|
||||||
void SpecBase::doCook(const hecl::ProjectPath& path, const hecl::ProjectPath& cookedPath,
|
void SpecBase::doCook(const hecl::ProjectPath& path, const hecl::ProjectPath& cookedPath,
|
||||||
bool fast, hecl::BlenderToken& btok, FCookProgress progress)
|
bool fast, hecl::BlenderToken& btok, FCookProgress progress)
|
||||||
{
|
{
|
||||||
|
cookedPath.makeDirChain(false);
|
||||||
DataSpec::g_curSpec.reset(this);
|
DataSpec::g_curSpec.reset(this);
|
||||||
|
|
||||||
hecl::ProjectPath asBlend;
|
hecl::ProjectPath asBlend;
|
||||||
|
@ -364,14 +365,14 @@ void SpecBase::flattenDependencies(const UniqueID32& id, std::vector<hecl::Proje
|
||||||
{
|
{
|
||||||
hecl::ProjectPath path = UniqueIDBridge::TranslatePakIdToPath(id);
|
hecl::ProjectPath path = UniqueIDBridge::TranslatePakIdToPath(id);
|
||||||
if (path)
|
if (path)
|
||||||
flattenDependencies(path, pathsOut, hecl::SharedBlenderToken);
|
flattenDependencies(path, pathsOut, *g_ThreadBlenderToken.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpecBase::flattenDependencies(const UniqueID64& id, std::vector<hecl::ProjectPath>& pathsOut)
|
void SpecBase::flattenDependencies(const UniqueID64& id, std::vector<hecl::ProjectPath>& pathsOut)
|
||||||
{
|
{
|
||||||
hecl::ProjectPath path = UniqueIDBridge::TranslatePakIdToPath(id);
|
hecl::ProjectPath path = UniqueIDBridge::TranslatePakIdToPath(id);
|
||||||
if (path)
|
if (path)
|
||||||
flattenDependencies(path, pathsOut, hecl::SharedBlenderToken);
|
flattenDependencies(path, pathsOut, *g_ThreadBlenderToken.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SpecBase::canPackage(const PackagePassInfo& info)
|
bool SpecBase::canPackage(const PackagePassInfo& info)
|
||||||
|
|
|
@ -601,7 +601,8 @@ struct SpecMP1 : SpecBase
|
||||||
FCookProgress progress)
|
FCookProgress progress)
|
||||||
{
|
{
|
||||||
BlendStream::World world = ds.compileWorld();
|
BlendStream::World world = ds.compileWorld();
|
||||||
DNAMP1::MLVL::Cook(out, in, world);
|
ds.close();
|
||||||
|
DNAMP1::MLVL::Cook(out, in, world, btok);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cookYAML(const hecl::ProjectPath& out, const hecl::ProjectPath& in,
|
void cookYAML(const hecl::ProjectPath& out, const hecl::ProjectPath& in,
|
||||||
|
|
2
hecl
2
hecl
|
@ -1 +1 @@
|
||||||
Subproject commit c75c8c0a28c8bbe994c56047371414e5b8f394af
|
Subproject commit 2beeb0cec6bf4b02e8eb494a778682d571dc7c32
|
Loading…
Reference in New Issue