Refactored ProjectPath aux info usage to function correctly

This commit is contained in:
Jack Andersen 2016-08-30 15:13:58 -10:00
parent 0aaeed2aeb
commit 52c6ce10b7
5 changed files with 35 additions and 27 deletions

View File

@ -1108,7 +1108,7 @@ bool ANCS::Cook(const hecl::ProjectPath& outPath,
for (ANCS::CharacterSet::CharacterInfo& ch : ancs.characterSet.characters)
{
hecl::SystemStringView chSysName(ch.name);
ch.cskr = inPath.getWithExtension((_S('.') + chSysName.sys_str()).c_str(), true).ensureAuxInfo(_S("CSKR"));
ch.cskr = inPath.ensureAuxInfo(chSysName.sys_str() + _S(".CSKR"));
for (const DNAANCS::Actor::Subtype& sub : actor.subtypes)
{
@ -1118,20 +1118,20 @@ bool ANCS::Cook(const hecl::ProjectPath& outPath,
{
const DNAANCS::Actor::Armature& arm = actor.armatures[sub.armature];
hecl::SystemStringView armSysName(arm.name);
ch.cinf = inPath.getWithExtension((_S('.') + armSysName.sys_str()).c_str(), true).ensureAuxInfo(_S("CINF"));
ch.cinf = inPath.ensureAuxInfo(armSysName.sys_str() + _S(".CINF"));
break;
}
}
}
ch.cskrOverlay = inPath.getWithExtension((_S('.') + chSysName.sys_str() + _S(".over")).c_str(), true).ensureAuxInfo(_S("CSKR"));
ch.cskrOverlay = inPath.ensureAuxInfo(chSysName.sys_str() + _S(".over.CSKR"));
}
/* Set Animation Resource IDs */
ancs.enumeratePrimitives([&](AnimationSet::MetaAnimPrimitive& prim) -> bool
{
hecl::SystemStringView sysStr(prim.animName);
hecl::ProjectPath pathOut = inPath.getWithExtension((_S('.') + sysStr.sys_str()).c_str(), true).ensureAuxInfo(_S("ANIM"));
hecl::ProjectPath pathOut = inPath.ensureAuxInfo(sysStr.sys_str() + _S(".ANIM"));
prim.animId = pathOut;
return true;
});
@ -1143,8 +1143,7 @@ bool ANCS::Cook(const hecl::ProjectPath& outPath,
for (const DNAANCS::Actor::Armature& arm : actor.armatures)
{
hecl::SystemStringView sysStr(arm.name);
hecl::ProjectPath pathOut = inPath.getCookedPath(SpecEntMP1).getWithExtension((_S('.') +
sysStr.sys_str()).c_str(), true).ensureAuxInfo(_S("CINF"));
hecl::ProjectPath pathOut = inPath.getCookedPath(SpecEntMP1).ensureAuxInfo(sysStr.sys_str() + _S(".CINF"));
athena::io::FileWriter w(pathOut.getAbsolutePath(), true, false);
if (w.hasError())
Log.report(logvisor::Fatal, _S("unable to open '%s' for writing"),
@ -1215,8 +1214,7 @@ bool ANCS::Cook(const hecl::ProjectPath& outPath,
skinIO.close();
hecl::SystemStringView sysStr(ch.name);
hecl::ProjectPath skinPath = inPath.getCookedPath(SpecEntMP1PC).getWithExtension((_S('.') +
sysStr.sys_str()).c_str(), true).ensureAuxInfo(_S("CSKR"));
hecl::ProjectPath skinPath = inPath.getCookedPath(SpecEntMP1PC).ensureAuxInfo(sysStr.sys_str() + _S(".CSKR"));
athena::io::FileWriter skinOut(skinPath.getAbsolutePath(), true, false);
if (skinOut.hasError())
Log.report(logvisor::Fatal, _S("unable to open '%s' for writing"),
@ -1243,8 +1241,8 @@ bool ANCS::Cook(const hecl::ProjectPath& outPath,
for (const DNAANCS::Actor::Action& act : actor.actions)
{
hecl::SystemStringView sysStr(act.name);
hecl::ProjectPath pathOut = inPath.getWithExtension((_S('.') + sysStr.sys_str()).c_str(), true).ensureAuxInfo(_S("ANIM"));
hecl::ProjectPath cookedOut = inPath.getCookedPath(SpecEntMP1PC).getWithExtension((_S('.') + sysStr.sys_str()).c_str(), true);
hecl::ProjectPath pathOut = inPath.ensureAuxInfo(sysStr.sys_str() + _S(".ANIM"));
hecl::ProjectPath cookedOut = pathOut.getCookedPath(SpecEntMP1PC);
athena::io::FileWriter w(cookedOut.getAbsolutePath(), true, false);
if (w.hasError())
Log.report(logvisor::Fatal, _S("unable to open '%s' for writing"),

View File

@ -90,6 +90,8 @@ static void WriteTag(athena::io::YAMLDocWriter& cacheWriter,
cacheWriter.enterSubVector(idStr);
cacheWriter.writeString(nullptr, pathTag.type.toString().c_str());
cacheWriter.writeString(nullptr, path.getRelativePathUTF8().c_str());
if (path.getAuxInfo().size())
cacheWriter.writeString(nullptr, path.getAuxInfoUTF8().c_str());
cacheWriter.leaveSubVector();
}
@ -155,7 +157,7 @@ void ProjectResourceFactoryBase::BackgroundIndexRecursiveProc(const hecl::Projec
for (const std::string& arm : armatureNames)
{
hecl::SystemStringView sysStr(arm);
hecl::ProjectPath subPath = path.getWithExtension((_S('.') + sysStr.sys_str()).c_str(), true).ensureAuxInfo(_S("CINF"));
hecl::ProjectPath subPath = path.ensureAuxInfo(sysStr.sys_str() + _S(".CINF"));
SObjectTag pathTag = TagFromPath(subPath, m_backgroundBlender);
m_tagToPath[pathTag] = subPath;
WriteTag(cacheWriter, pathTag, subPath);
@ -167,7 +169,7 @@ void ProjectResourceFactoryBase::BackgroundIndexRecursiveProc(const hecl::Projec
for (const std::string& sub : subtypeNames)
{
hecl::SystemStringView sysStr(sub);
hecl::ProjectPath subPath = path.getWithExtension((_S('.') + sysStr.sys_str()).c_str(), true).ensureAuxInfo(_S("CSKR"));
hecl::ProjectPath subPath = path.ensureAuxInfo(sysStr.sys_str() + _S(".CSKR"));
SObjectTag pathTag = TagFromPath(subPath, m_backgroundBlender);
m_tagToPath[pathTag] = subPath;
WriteTag(cacheWriter, pathTag, subPath);
@ -179,7 +181,7 @@ void ProjectResourceFactoryBase::BackgroundIndexRecursiveProc(const hecl::Projec
for (const std::string& act : actionNames)
{
hecl::SystemStringView sysStr(act);
hecl::ProjectPath subPath = path.getWithExtension((_S('.') + sysStr.sys_str()).c_str(), true).ensureAuxInfo(_S("ANIM"));
hecl::ProjectPath subPath = path.ensureAuxInfo(sysStr.sys_str() + _S(".ANIM"));
SObjectTag pathTag = TagFromPath(subPath, m_backgroundBlender);
m_tagToPath[pathTag] = subPath;
WriteTag(cacheWriter, pathTag, subPath);
@ -218,12 +220,18 @@ void ProjectResourceFactoryBase::BackgroundIndexProc()
size_t loadIdx = 0;
for (const auto& child : cacheReader.getRootNode()->m_mapChildren)
{
const athena::io::YAMLNode& node = *child.second;
unsigned long id = strtoul(child.first.c_str(), nullptr, 16);
hecl::FourCC type(child.second->m_seqChildren.at(0)->m_scalarString.c_str());
hecl::FourCC type(node.m_seqChildren.at(0)->m_scalarString.c_str());
hecl::ProjectPath path(m_proj->getProjectWorkingPath(),
child.second->m_seqChildren.at(1)->m_scalarString);
node.m_seqChildren.at(1)->m_scalarString);
if (node.m_seqChildren.size() >= 3)
{
hecl::SystemStringView sys(node.m_seqChildren[2]->m_scalarString);
path = path.ensureAuxInfo(sys.sys_str());
}
m_tagToPath[SObjectTag(type, id)] = path;
fprintf(stderr, "\r %" PRISize " / %" PRISize, loadIdx++,
fprintf(stderr, "\r %" PRISize " / %" PRISize, ++loadIdx,
cacheReader.getRootNode()->m_mapChildren.size());
}
fprintf(stderr, "\n");
@ -317,10 +325,7 @@ hecl::ProjectPath ProjectResourceFactoryBase::GetCookedPath(const hecl::ProjectP
spec = m_cookSpec->overrideDataSpec(working, m_pcSpec, hecl::SharedBlenderToken);
if (!spec)
return {};
if (working.getAuxInfo().size())
return working.getCookedPath(*spec).getWithExtension((_S('.') + working.getAuxInfo()).c_str());
else
return working.getCookedPath(*spec);
return working.getCookedPath(*spec);
}
bool ProjectResourceFactoryBase::SyncCook(const hecl::ProjectPath& working)

View File

@ -55,11 +55,11 @@ void ProjectResourceFactoryMP1::IndexMP1Resources(hecl::Database::Project& proj)
SObjectTag ProjectResourceFactoryMP1::TagFromPath(const hecl::ProjectPath& path, hecl::BlenderToken& btok) const
{
if (!path.getAuxInfo().compare(_S("CINF")))
if (hecl::StringUtils::EndsWith(path.getAuxInfo(), _S(".CINF")))
return SObjectTag(SBIG('CINF'), path.hash().val32());
else if (!path.getAuxInfo().compare(_S("CSKR")))
else if (hecl::StringUtils::EndsWith(path.getAuxInfo(), _S(".CSKR")))
return SObjectTag(SBIG('CSKR'), path.hash().val32());
else if (!path.getAuxInfo().compare(_S("ANIM")))
else if (hecl::StringUtils::EndsWith(path.getAuxInfo(), _S(".ANIM")))
return SObjectTag(SBIG('ANIM'), path.hash().val32());
if (hecl::IsPathBlend(path))
@ -75,11 +75,11 @@ SObjectTag ProjectResourceFactoryMP1::TagFromPath(const hecl::ProjectPath& path,
case hecl::BlenderConnection::BlendType::Actor:
if (path.getAuxInfo().size())
{
if (!path.getAuxInfo().compare(_S("CINF")))
if (hecl::StringUtils::EndsWith(path.getAuxInfo(), _S(".CINF")))
return {SBIG('CINF'), path.hash().val32()};
else if (!path.getAuxInfo().compare(_S("CSKR")))
else if (hecl::StringUtils::EndsWith(path.getAuxInfo(), _S(".CSKR")))
return {SBIG('CSKR'), path.hash().val32()};
else if (!path.getAuxInfo().compare(_S("ANIM")))
else if (hecl::StringUtils::EndsWith(path.getAuxInfo(), _S(".ANIM")))
return {SBIG('ANIM'), path.hash().val32()};
}
return {SBIG('ANCS'), path.hash().val32()};

View File

@ -4,6 +4,7 @@
#include "CInt32POINode.hpp"
#include "CParticlePOINode.hpp"
#include "CSoundPOINode.hpp"
#include "IMetaAnim.hpp"
namespace urde
{
@ -30,7 +31,11 @@ CSequenceHelper::CSequenceHelper(const std::shared_ptr<CAnimTreeNode>& a,
CSequenceHelper::CSequenceHelper(const std::vector<std::shared_ptr<IMetaAnim>>& nodes,
const CAnimSysContext& animCtx)
: x0_transDB(animCtx.x0_transDB)
{
x10_treeNodes.reserve(nodes.size());
for (const std::shared_ptr<IMetaAnim>& meta : nodes)
x10_treeNodes.push_back(meta->GetAnimationTree(animCtx, CMetaAnimTreeBuildOrders::NoSpecialOrders()));
}
CSequenceFundamentals CSequenceHelper::ComputeSequenceFundamentals()

2
hecl

@ -1 +1 @@
Subproject commit f325c438d1aa629de2af004ebb595db362895dd1
Subproject commit ab1df60c348335f9e3637ef21ac5dc8c6f563ad9