From 2ce1b6047df57919f9cf1be44708fc93e1e6080a Mon Sep 17 00:00:00 2001 From: Luke Street Date: Tue, 14 Apr 2020 00:15:17 -0400 Subject: [PATCH] DNA/ANCS: Ensure CINFs extracted --- DataSpec/DNACommon/ANCS.cpp | 33 ++++++++++++++++++++++++++------- DataSpec/DNACommon/ANCS.hpp | 2 +- DataSpec/DNAMP1/ANCS.cpp | 3 +-- DataSpec/DNAMP2/ANCS.hpp | 3 +-- DataSpec/DNAMP3/CHAR.hpp | 3 +-- 5 files changed, 30 insertions(+), 14 deletions(-) diff --git a/DataSpec/DNACommon/ANCS.cpp b/DataSpec/DNACommon/ANCS.cpp index 0ee44741d..03f89f3a9 100644 --- a/DataSpec/DNACommon/ANCS.cpp +++ b/DataSpec/DNACommon/ANCS.cpp @@ -15,10 +15,11 @@ namespace DataSpec::DNAANCS { template -bool ReadANCSToBlender(hecl::blender::Connection& conn, const ANCSDNA& ancs, const hecl::ProjectPath& outPath, +bool ReadANCSToBlender(hecl::blender::Token& btok, const ANCSDNA& ancs, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, const typename PAKRouter::EntryType& entry, const SpecBase& dataspec, std::function fileChanged, bool force) { - /* Extract character CMDL/CSKR first */ + auto& conn = btok.getBlenderConnection(); + /* Extract character CMDL/CSKR/CINF first */ std::vector> chResInfo; ancs.getCharacterResInfo(chResInfo); for (const auto& info : chResInfo) { @@ -49,11 +50,19 @@ bool ReadANCSToBlender(hecl::blender::Connection& conn, const ANCSDNA& ancs, con conn.saveBlend(); } } + if (const typename PAKRouter::EntryType* cinfE = pakRouter.lookupEntry(info.cinf, &node, true, false)) { + hecl::ProjectPath cinfPath = pakRouter.getWorking(cinfE); + if (cinfPath.getPathType() == hecl::ProjectPath::Type::None) { + PAKEntryReadStream rs = cinfE->beginReadStream(*node); + ANCSDNA::CINFType::Extract(dataspec, rs, cinfPath, pakRouter, *cinfE, false, btok, fileChanged); + } + } } - /* Extract attachment CMDL/CSKRs first */ + /* Extract attachment CMDL/CSKR/CINFs first */ auto attRange = pakRouter.lookupCharacterAttachmentRigs(entry.id); for (auto it = attRange.first; it != attRange.second; ++it) { + auto cinfid = it->second.first.cinf; auto cmdlid = it->second.first.cmdl; const nod::Node* node; @@ -61,8 +70,9 @@ bool ReadANCSToBlender(hecl::blender::Connection& conn, const ANCSDNA& ancs, con hecl::ProjectPath cmdlPath = pakRouter.getWorking(cmdlE); if (force || cmdlPath.isNone()) { cmdlPath.makeDirChain(false); - if (!conn.createBlend(cmdlPath, hecl::blender::BlendType::Mesh)) + if (!conn.createBlend(cmdlPath, hecl::blender::BlendType::Mesh)) { return false; + } std::string bestName = pakRouter.getBestEntryName(*cmdlE); hecl::SystemStringConv bestNameView(bestName); @@ -84,6 +94,15 @@ bool ReadANCSToBlender(hecl::blender::Connection& conn, const ANCSDNA& ancs, con conn.saveBlend(); } } + if (cinfid.isValid()) { + if (const typename PAKRouter::EntryType* cinfE = pakRouter.lookupEntry(cinfid, &node, true, false)) { + hecl::ProjectPath cinfPath = pakRouter.getWorking(cinfE); + if (cinfPath.getPathType() == hecl::ProjectPath::Type::None) { + PAKEntryReadStream rs = cinfE->beginReadStream(*node); + ANCSDNA::CINFType::Extract(dataspec, rs, cinfPath, pakRouter, *cinfE, false, btok, fileChanged); + } + } + } } std::string bestName = pakRouter.getBestEntryName(entry); @@ -253,17 +272,17 @@ bool ReadANCSToBlender(hecl::blender::Connection& conn, const ANCSDNA& ancs, con template bool ReadANCSToBlender, DNAMP1::ANCS, DNAMP1::MaterialSet, DNACMDL::SurfaceHeader_1, 2>( - hecl::blender::Connection& conn, const DNAMP1::ANCS& ancs, const hecl::ProjectPath& outPath, + hecl::blender::Token& btok, const DNAMP1::ANCS& ancs, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, const typename PAKRouter::EntryType& entry, const SpecBase& dataspec, std::function fileChanged, bool force); template bool ReadANCSToBlender, DNAMP2::ANCS, DNAMP2::MaterialSet, DNACMDL::SurfaceHeader_2, 4>( - hecl::blender::Connection& conn, const DNAMP2::ANCS& ancs, const hecl::ProjectPath& outPath, + hecl::blender::Token& btok, const DNAMP2::ANCS& ancs, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, const typename PAKRouter::EntryType& entry, const SpecBase& dataspec, std::function fileChanged, bool force); template bool ReadANCSToBlender, DNAMP3::CHAR, DNAMP3::MaterialSet, DNACMDL::SurfaceHeader_3, 4>( - hecl::blender::Connection& conn, const DNAMP3::CHAR& ancs, const hecl::ProjectPath& outPath, + hecl::blender::Token& btok, const DNAMP3::CHAR& ancs, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, const typename PAKRouter::EntryType& entry, const SpecBase& dataspec, std::function fileChanged, bool force); diff --git a/DataSpec/DNACommon/ANCS.hpp b/DataSpec/DNACommon/ANCS.hpp index 6064fa6bd..2cf7ef811 100644 --- a/DataSpec/DNACommon/ANCS.hpp +++ b/DataSpec/DNACommon/ANCS.hpp @@ -41,7 +41,7 @@ struct AnimationResInfo { }; template -bool ReadANCSToBlender(hecl::blender::Connection& conn, const ANCSDNA& ancs, const hecl::ProjectPath& outPath, +bool ReadANCSToBlender(hecl::blender::Token& btok, const ANCSDNA& ancs, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, const typename PAKRouter::EntryType& entry, const SpecBase& dataspec, std::function fileChanged, bool force = false); diff --git a/DataSpec/DNAMP1/ANCS.cpp b/DataSpec/DNAMP1/ANCS.cpp index e3c67b451..642da411f 100644 --- a/DataSpec/DNAMP1/ANCS.cpp +++ b/DataSpec/DNAMP1/ANCS.cpp @@ -975,9 +975,8 @@ bool ANCS::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl: } if (force || blendType == hecl::ProjectPath::Type::None) { - hecl::blender::Connection& conn = btok.getBlenderConnection(); DNAANCS::ReadANCSToBlender, ANCS, MaterialSet, DNACMDL::SurfaceHeader_1, 2>( - conn, ancs, blendPath, pakRouter, entry, dataSpec, fileChanged, force); + btok, ancs, blendPath, pakRouter, entry, dataSpec, fileChanged, force); } } diff --git a/DataSpec/DNAMP2/ANCS.hpp b/DataSpec/DNAMP2/ANCS.hpp index e78d4a558..7a2e48ef1 100644 --- a/DataSpec/DNAMP2/ANCS.hpp +++ b/DataSpec/DNAMP2/ANCS.hpp @@ -215,9 +215,8 @@ struct ANCS : BigDNA { } if (force || blendType == hecl::ProjectPath::Type::None) { - hecl::blender::Connection& conn = btok.getBlenderConnection(); DNAANCS::ReadANCSToBlender, ANCS, MaterialSet, DNACMDL::SurfaceHeader_2, 4>( - conn, ancs, blendPath, pakRouter, entry, dataSpec, fileChanged, force); + btok, ancs, blendPath, pakRouter, entry, dataSpec, fileChanged, force); } } diff --git a/DataSpec/DNAMP3/CHAR.hpp b/DataSpec/DNAMP3/CHAR.hpp index 0ee8b495b..af6e71b75 100644 --- a/DataSpec/DNAMP3/CHAR.hpp +++ b/DataSpec/DNAMP3/CHAR.hpp @@ -283,9 +283,8 @@ struct CHAR : BigDNA { } if (force || blendType == hecl::ProjectPath::Type::None) { - hecl::blender::Connection& conn = btok.getBlenderConnection(); DNAANCS::ReadANCSToBlender, CHAR, MaterialSet, DNACMDL::SurfaceHeader_3, 4>( - conn, aChar, blendPath, pakRouter, entry, dataSpec, fileChanged, force); + btok, aChar, blendPath, pakRouter, entry, dataSpec, fileChanged, force); } }