From 45fb8db38834423c477c2a5a6c1bee68523164be Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Sun, 21 Oct 2018 23:29:44 -1000 Subject: [PATCH] Integrate SDNA parser for checking .blend types --- DataSpec/DNACommon/DNACommon.hpp | 23 +---------------------- DataSpec/SpecBase.cpp | 11 ++++------- DataSpec/SpecMP1.cpp | 7 ++----- hecl | 2 +- 4 files changed, 8 insertions(+), 35 deletions(-) diff --git a/DataSpec/DNACommon/DNACommon.hpp b/DataSpec/DNACommon/DNACommon.hpp index d1ef07004..437b13125 100644 --- a/DataSpec/DNACommon/DNACommon.hpp +++ b/DataSpec/DNACommon/DNACommon.hpp @@ -23,28 +23,7 @@ typedef athena::io::DNAV BigDNAV; typedef athena::io::DNAVYaml BigDNAVYaml; /** FourCC with DNA read/write */ -class DNAFourCC final : public BigDNA, public hecl::FourCC -{ -public: - DNAFourCC() : hecl::FourCC() {} - DNAFourCC(const hecl::FourCC& other) - : hecl::FourCC() {num = other.toUint32();} - DNAFourCC(const char* name) - : hecl::FourCC(name) {} - DNAFourCC(uint32_t n) - : hecl::FourCC(n) {} - AT_DECL_EXPLICIT_DNA_YAML -}; -template <> inline void DNAFourCC::Enumerate(typename Read::StreamT& r) -{ r.readUBytesToBuf(fcc, 4); } -template <> inline void DNAFourCC::Enumerate(typename Write::StreamT& w) -{ w.writeUBytes((atUint8*)fcc, 4); } -template <> inline void DNAFourCC::Enumerate(typename ReadYaml::StreamT& r) -{ std::string rs = r.readString(nullptr); strncpy(fcc, rs.c_str(), 4); } -template <> inline void DNAFourCC::Enumerate(typename WriteYaml::StreamT& w) -{ w.writeString(nullptr, std::string(fcc, 4)); } -template <> inline void DNAFourCC::Enumerate(typename BinarySize::StreamT& s) -{ s += 4; } +using DNAFourCC = hecl::DNAFourCC; class DNAColor final : public BigDNA, public zeus::CColor { diff --git a/DataSpec/SpecBase.cpp b/DataSpec/SpecBase.cpp index 3d3a8ff5a..3a0f602fa 100644 --- a/DataSpec/SpecBase.cpp +++ b/DataSpec/SpecBase.cpp @@ -11,6 +11,7 @@ #include "hecl/ClientProcess.hpp" #include "nod/nod.hpp" #include "hecl/Blender/Connection.hpp" +#include "hecl/Blender/SDNARead.hpp" #include "hecl/MultiProgressPrinter.hpp" #include @@ -233,10 +234,7 @@ bool SpecBase::canCook(const hecl::ProjectPath& path, hecl::blender::Token& btok if (hecl::IsPathBlend(asBlend)) { - hecl::blender::Connection& conn = btok.getBlenderConnection(); - if (!conn.openBlend(asBlend)) - return false; - hecl::blender::BlendType type = conn.getBlendType(); + hecl::blender::BlendType type = hecl::blender::GetBlendType(asBlend.getAbsolutePath()); if (type != hecl::blender::BlendType::None) return cookPass < 0 || (cookPass == 0 && type == hecl::blender::BlendType::Mesh) || // CMDL only @@ -288,14 +286,13 @@ const hecl::Database::DataSpecEntry* SpecBase::overrideDataSpec(const hecl::Proj hecl::StringUtils::EndsWith(path.getAuxInfo(), _SYS_STR(".ANIM"))) return oldEntry; - hecl::blender::Connection& conn = btok.getBlenderConnection(); - if (!conn.openBlend(asBlend)) + hecl::blender::BlendType type = hecl::blender::GetBlendType(asBlend.getAbsolutePath()); + if (type == hecl::blender::BlendType::None) { Log.report(logvisor::Error, _SYS_STR("unable to cook '%s'"), path.getAbsolutePath().data()); return nullptr; } - hecl::blender::BlendType type = conn.getBlendType(); if (type == hecl::blender::BlendType::Mesh || type == hecl::blender::BlendType::Area) return oldEntry; diff --git a/DataSpec/SpecMP1.cpp b/DataSpec/SpecMP1.cpp index 6c3cad1d7..d28c808c3 100644 --- a/DataSpec/SpecMP1.cpp +++ b/DataSpec/SpecMP1.cpp @@ -50,6 +50,7 @@ #include "hecl/ClientProcess.hpp" #include "hecl/MultiProgressPrinter.hpp" #include "hecl/Blender/Connection.hpp" +#include "hecl/Blender/SDNARead.hpp" #include "nod/nod.hpp" namespace DataSpec @@ -574,11 +575,7 @@ struct SpecMP1 : SpecBase if (hecl::IsPathBlend(asBlend)) { - hecl::blender::Connection& conn = btok.getBlenderConnection(); - if (!conn.openBlend(asBlend)) - return {}; - - switch (conn.getBlendType()) + switch (hecl::blender::GetBlendType(asBlend.getAbsolutePath())) { case hecl::blender::BlendType::Mesh: return {SBIG('CMDL'), path.hash().val32()}; diff --git a/hecl b/hecl index e83f40f5c..7561dd66e 160000 --- a/hecl +++ b/hecl @@ -1 +1 @@ -Subproject commit e83f40f5ca9c5f0bc7664bbda19c43574172f42e +Subproject commit 7561dd66e6ab5f5b7d4f94fc7bf732653ce104fb