World cooking bug fixes

This commit is contained in:
Jack Andersen 2016-12-24 15:36:42 -10:00
parent 5e2f2e3af8
commit e192fb77a4
13 changed files with 34 additions and 27 deletions

View File

@ -8,6 +8,7 @@ namespace DataSpec
logvisor::Module LogDNACommon("urde::DNACommon");
ThreadLocalPtr<SpecBase> g_curSpec;
ThreadLocalPtr<PAKRouterBase> g_PakRouter;
ThreadLocalPtr<hecl::BlenderToken> g_ThreadBlenderToken;
ThreadLocalPtr<hecl::Database::Project> UniqueIDBridge::s_Project;
UniqueID32 UniqueID32::kInvalidId;
@ -29,7 +30,7 @@ hecl::ProjectPath UniqueIDBridge::TranslatePakIdToPath(const IDType& id, bool si
{
if (pakRouter)
{
if (!silenceWarnings)
if (!silenceWarnings && id)
LogDNACommon.report(logvisor::Warning,
"unable to translate %s to path", id.toString().c_str());
return {};
@ -42,7 +43,7 @@ hecl::ProjectPath UniqueIDBridge::TranslatePakIdToPath(const IDType& id, bool si
const hecl::ProjectPath* search = project->lookupBridgePath(id.toUint64());
if (!search)
{
if (!silenceWarnings)
if (!silenceWarnings && id)
LogDNACommon.report(logvisor::Warning,
"unable to translate %s to path", id.toString().c_str());
return {};

View File

@ -18,6 +18,7 @@ namespace DataSpec
extern logvisor::Module LogDNACommon;
extern ThreadLocalPtr<SpecBase> g_curSpec;
extern ThreadLocalPtr<class PAKRouterBase> g_PakRouter;
extern ThreadLocalPtr<hecl::BlenderToken> g_ThreadBlenderToken;
/* This comes up a great deal */
typedef athena::io::DNA<athena::BigEndian> BigDNA;

View File

@ -473,14 +473,14 @@ hecl::SystemString PAKRouter<BRIDGETYPE>::getResourceRelativePath(const EntryTyp
}
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;
for (const BRIDGETYPE& bridge : *m_bridges)
{
const typename BRIDGETYPE::PAKType& pak = bridge.getPAK();
if (isShared())
if (stdOverride && isShared())
{
if (entry.type == FOURCC('MLVL'))
return "!world";
@ -499,7 +499,7 @@ std::string PAKRouter<BRIDGETYPE>::getBestEntryName(const EntryType& entry) cons
}
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;
for (const BRIDGETYPE& bridge : *m_bridges)
@ -509,7 +509,7 @@ std::string PAKRouter<BRIDGETYPE>::getBestEntryName(const IDType& entry) const
if (!e)
continue;
if (isShared())
if (stdOverride && isShared())
{
if (e->type == FOURCC('MLVL'))
return "!world";
@ -543,7 +543,7 @@ bool PAKRouter<BRIDGETYPE>::extractResources(const BRIDGETYPE& pakBridge, bool f
if (extractor.weight != w)
continue;
std::string bestName = getBestEntryName(*item);
std::string bestName = getBestEntryName(*item, false);
hecl::SystemStringView bestNameView(bestName);
float thisFac = ++count / fsz;
progress(bestNameView.c_str(), thisFac);

View File

@ -200,8 +200,8 @@ public:
hecl::SystemString getResourceRelativePath(const EntryType& a, const IDType& b) const;
std::string getBestEntryName(const EntryType& entry) const;
std::string getBestEntryName(const IDType& entry) const;
std::string getBestEntryName(const EntryType& entry, bool stdOverride=true) const;
std::string getBestEntryName(const IDType& entry, bool stdOverride=true) const;
bool extractResources(const BRIDGETYPE& pakBridge, bool force, hecl::BlenderToken& btok,
std::function<void(const hecl::SystemChar*, float)> progress);

View File

@ -40,7 +40,8 @@ bool MLVL::Extract(const SpecBase& dataSpec,
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 = {};
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 */
hecl::ProjectPath mapPath(area.path, _S("/!map.blend"));
if (mapPath.isFile())
mapaTags.push_back(g_curSpec->BuildTagFromPath(mapPath, hecl::SharedBlenderToken));
mapaTags.push_back(g_curSpec->BuildTagFromPath(mapPath, btok));
/* Populate area record */
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 */
{
g_ThreadBlenderToken.reset(&btok);
std::vector<hecl::ProjectPath> depPaths;
std::vector<Scan> scans;
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)
{
SpecialFunction& specialFunc = static_cast<SpecialFunction&>(*obj);
if (specialFunc.type == ESpecialFunctionType::CinematicSkip)
if (specialFunc.function == ESpecialFunctionType::CinematicSkip)
savw.skippableCutscenes.push_back(specialFunc.id);
else if (specialFunc.type == ESpecialFunctionType::ScriptLayerController)
else if (specialFunc.function == ESpecialFunctionType::ScriptLayerController)
{
savw.layers.emplace_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())
{
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);
}
}
@ -300,12 +302,12 @@ bool MLVL::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat
if (addedPaths.find(path.hash()) == addedPaths.cend())
{
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);
}
}
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);
}
@ -330,7 +332,7 @@ bool MLVL::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat
/* Write out MAPW */
{
hecl::ProjectPath mapwCooked =
mapwPath.getCookedPath(*g_curSpec->overrideDataSpec(mapwPath, nullptr, hecl::SharedBlenderToken));
mapwPath.getCookedPath(*g_curSpec->overrideDataSpec(mapwPath, nullptr, btok));
mapwCooked.makeDirChain(false);
athena::io::FileWriter fo(mapwCooked.getAbsolutePath());
fo.writeUint32Big(0xDEADF00D);
@ -350,7 +352,7 @@ bool MLVL::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat
savw.scanCount = savw.scans.size();
hecl::ProjectPath savwCooked =
savwPath.getCookedPath(*g_curSpec->overrideDataSpec(savwPath, nullptr, hecl::SharedBlenderToken));
savwPath.getCookedPath(*g_curSpec->overrideDataSpec(savwPath, nullptr, btok));
savwCooked.makeDirChain(false);
athena::io::FileWriter fo(savwCooked.getAbsolutePath());
savw.write(fo);

View File

@ -153,7 +153,8 @@ struct MLVL : BigYAML
static bool Cook(const hecl::ProjectPath& outPath,
const hecl::ProjectPath& inPath,
const World& wld);
const World& wld,
hecl::BlenderToken& btok);
};
}

View File

@ -84,7 +84,7 @@ bool MREA::Extract(const SpecBase& dataSpec,
"from mathutils import Vector\n"
"\n"
"bpy.context.scene.name = '%s'\n",
pakRouter.getBestEntryName(entry).c_str());
pakRouter.getBestEntryName(entry, false).c_str());
DNACMDL::InitGeomBlenderContext(os, dataSpec.getMasterShaderPath(), true);
MaterialSet::RegisterMaterialProps(os);
os << "# Clear Scene\n"

View File

@ -15,7 +15,7 @@ struct SpecialFunction : IScriptObject
String<-1> name;
Value<atVec3f> location;
Value<atVec3f> orientation;
Value<ESpecialFunctionType> type;
Value<ESpecialFunctionType> function;
String<-1> unknown1;
Value<float> unknown2;
Value<float> unknown3;

View File

@ -214,7 +214,7 @@ bool MREA::Extract(const SpecBase& dataSpec,
"from mathutils import Vector\n"
"\n"
"bpy.context.scene.name = '%s'\n",
pakRouter.getBestEntryName(entry).c_str());
pakRouter.getBestEntryName(entry, false).c_str());
DNACMDL::InitGeomBlenderContext(os, dataSpec.getMasterShaderPath(), true);
MaterialSet::RegisterMaterialProps(os);
os << "# Clear Scene\n"

View File

@ -113,7 +113,7 @@ bool MREA::Extract(const SpecBase& dataSpec,
"from mathutils import Vector\n"
"\n"
"bpy.context.scene.name = '%s'\n",
pakRouter.getBestEntryName(entry).c_str());
pakRouter.getBestEntryName(entry, false).c_str());
DNACMDL::InitGeomBlenderContext(os, dataSpec.getMasterShaderPath(), true);
MaterialSet::RegisterMaterialProps(os);
os << "# Clear Scene\n"

View File

@ -224,6 +224,7 @@ const hecl::Database::DataSpecEntry* SpecBase::overrideDataSpec(const hecl::Proj
void SpecBase::doCook(const hecl::ProjectPath& path, const hecl::ProjectPath& cookedPath,
bool fast, hecl::BlenderToken& btok, FCookProgress progress)
{
cookedPath.makeDirChain(false);
DataSpec::g_curSpec.reset(this);
hecl::ProjectPath asBlend;
@ -364,14 +365,14 @@ void SpecBase::flattenDependencies(const UniqueID32& id, std::vector<hecl::Proje
{
hecl::ProjectPath path = UniqueIDBridge::TranslatePakIdToPath(id);
if (path)
flattenDependencies(path, pathsOut, hecl::SharedBlenderToken);
flattenDependencies(path, pathsOut, *g_ThreadBlenderToken.get());
}
void SpecBase::flattenDependencies(const UniqueID64& id, std::vector<hecl::ProjectPath>& pathsOut)
{
hecl::ProjectPath path = UniqueIDBridge::TranslatePakIdToPath(id);
if (path)
flattenDependencies(path, pathsOut, hecl::SharedBlenderToken);
flattenDependencies(path, pathsOut, *g_ThreadBlenderToken.get());
}
bool SpecBase::canPackage(const PackagePassInfo& info)

View File

@ -601,7 +601,8 @@ struct SpecMP1 : SpecBase
FCookProgress progress)
{
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,

2
hecl

@ -1 +1 @@
Subproject commit c75c8c0a28c8bbe994c56047371414e5b8f394af
Subproject commit 2beeb0cec6bf4b02e8eb494a778682d571dc7c32