From 3b7f7f2f3a56fe0f4df040ce87c51b555a875a67 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Tue, 6 Oct 2015 15:17:17 -1000 Subject: [PATCH] CMDL cooking updates --- DataSpec/Blender/BlenderSupport.cpp | 2 +- DataSpec/DNACommon/ANCS.hpp | 4 ++-- DataSpec/DNACommon/CMDL.hpp | 2 ++ DataSpec/DNACommon/PAK.hpp | 20 +++++++++-------- DataSpec/DNAMP1/CMDL.hpp | 8 ++++++- DataSpec/DNAMP1/DeafBabe.hpp | 4 ++-- DataSpec/DNAMP1/MREA.cpp | 2 +- DataSpec/DNAMP2/CMDL.hpp | 2 +- DataSpec/DNAMP2/DeafBabe.hpp | 4 ++-- DataSpec/DNAMP2/MREA.cpp | 2 +- DataSpec/DNAMP3/CMDL.hpp | 2 +- DataSpec/DNAMP3/MREA.cpp | 2 +- DataSpec/SpecBase.cpp | 33 +++++++++++++++++++++++------ DataSpec/SpecBase.hpp | 1 + DataSpec/SpecMP1.cpp | 3 +++ hecl | 2 +- 16 files changed, 63 insertions(+), 30 deletions(-) diff --git a/DataSpec/Blender/BlenderSupport.cpp b/DataSpec/Blender/BlenderSupport.cpp index 4f489ed8b..54ffe7ce2 100644 --- a/DataSpec/Blender/BlenderSupport.cpp +++ b/DataSpec/Blender/BlenderSupport.cpp @@ -13,7 +13,7 @@ namespace Blender bool BuildMasterShader(const HECL::ProjectPath& path) { HECL::BlenderConnection& conn = HECL::BlenderConnection::SharedConnection(); - if (!conn.createBlend(path.getAbsolutePath(), HECL::BlenderConnection::TypeNone)) + if (!conn.createBlend(path, HECL::BlenderConnection::TypeNone)) return false; { HECL::BlenderConnection::PyOutStream os = conn.beginPythonOut(true); diff --git a/DataSpec/DNACommon/ANCS.hpp b/DataSpec/DNACommon/ANCS.hpp index 37e16eb80..f1b429ed1 100644 --- a/DataSpec/DNACommon/ANCS.hpp +++ b/DataSpec/DNACommon/ANCS.hpp @@ -51,7 +51,7 @@ bool ReadANCSToBlender(HECL::BlenderConnection& conn, HECL::ProjectPath cmdlPath = pakRouter.getWorking(cmdlE); if (force || cmdlPath.getPathType() == HECL::ProjectPath::PT_NONE) { - if (!conn.createBlend(cmdlPath.getAbsolutePath(), HECL::BlenderConnection::TypeMesh)) + if (!conn.createBlend(cmdlPath, HECL::BlenderConnection::TypeMesh)) return false; HECL::SystemStringView bestNameView(pakRouter.getBestEntryName(*cmdlE)); @@ -77,7 +77,7 @@ bool ReadANCSToBlender(HECL::BlenderConnection& conn, fileChanged(bestNameView.sys_str().c_str()); /* Establish ANCS blend */ - if (!conn.createBlend(outPath.getAbsolutePath(), HECL::BlenderConnection::TypeActor)) + if (!conn.createBlend(outPath, HECL::BlenderConnection::TypeActor)) return false; HECL::BlenderConnection::PyOutStream os = conn.beginPythonOut(true); diff --git a/DataSpec/DNACommon/CMDL.hpp b/DataSpec/DNACommon/CMDL.hpp index 9d00e536a..2812fd686 100644 --- a/DataSpec/DNACommon/CMDL.hpp +++ b/DataSpec/DNACommon/CMDL.hpp @@ -11,6 +11,8 @@ namespace Retro namespace DNACMDL { +using Mesh = HECL::BlenderConnection::DataStream::Mesh; + struct Header : BigDNA { DECL_DNA diff --git a/DataSpec/DNACommon/PAK.hpp b/DataSpec/DNACommon/PAK.hpp index 0f58cecc4..bf4d928c7 100644 --- a/DataSpec/DNACommon/PAK.hpp +++ b/DataSpec/DNACommon/PAK.hpp @@ -512,15 +512,6 @@ public: float thisFac = ++count / fsz; progress(bestNameView.sys_str().c_str(), thisFac); - HECL::ProjectPath cooked = getCooked(item.second); - if (force || cooked.getPathType() == HECL::ProjectPath::PT_NONE) - { - PAKEntryReadStream s = item.second->beginReadStream(*m_node); - FILE* fout = HECL::Fopen(cooked.getAbsolutePath().c_str(), _S("wb")); - fwrite(s.data(), 1, s.length(), fout); - fclose(fout); - } - HECL::ProjectPath working = getWorking(item.second, extractor); if (extractor.func_a) /* Doesn't need PAKRouter access */ { @@ -542,6 +533,17 @@ public: }); } } + + /* Extract original cooked copy AFTER working so timestamps make + * the original a valid cached item */ + HECL::ProjectPath cooked = getCooked(item.second); + if (force || cooked.getPathType() == HECL::ProjectPath::PT_NONE) + { + PAKEntryReadStream s = item.second->beginReadStream(*m_node); + FILE* fout = HECL::Fopen(cooked.getAbsolutePath().c_str(), _S("wb")); + fwrite(s.data(), 1, s.length(), fout); + fclose(fout); + } } } diff --git a/DataSpec/DNAMP1/CMDL.hpp b/DataSpec/DNAMP1/CMDL.hpp index d0189486b..d2053f1e0 100644 --- a/DataSpec/DNAMP1/CMDL.hpp +++ b/DataSpec/DNAMP1/CMDL.hpp @@ -38,12 +38,18 @@ struct CMDL /* Do extract */ HECL::BlenderConnection& conn = HECL::BlenderConnection::SharedConnection(); - if (!conn.createBlend(outPath.getAbsolutePath(), HECL::BlenderConnection::TypeMesh)) + if (!conn.createBlend(outPath, HECL::BlenderConnection::TypeMesh)) return false; DNACMDL::ReadCMDLToBlender, MaterialSet, std::pair, DNACMDL::SurfaceHeader_1_2, 2> (conn, rs, pakRouter, entry, dataSpec, loadRp); return conn.saveBlend(); } + + static bool Cook(const DNACMDL::Mesh& mesh, + const HECL::ProjectPath& outPath) + { + return true; + } }; } diff --git a/DataSpec/DNAMP1/DeafBabe.hpp b/DataSpec/DNAMP1/DeafBabe.hpp index 1576d5263..1f664ba54 100644 --- a/DataSpec/DNAMP1/DeafBabe.hpp +++ b/DataSpec/DNAMP1/DeafBabe.hpp @@ -23,7 +23,7 @@ struct DeafBabe : BigDNA DECL_DNA Value material; bool fireThrough() const {return material >> 18 & 0x1;} - void setFireThrough(bool v) {material &= 0x40000; material |= v << 18;} + void setFireThrough(bool v) {material &= ~0x40000; material |= v << 18;} enum Type { @@ -39,7 +39,7 @@ struct DeafBabe : BigDNA MatLeaves }; Type type() const {return Type(material & 0xff);} - void setType(Type t) {material &= 0xff; material |= t;} + void setType(Type t) {material &= ~0xff; material |= t;} }; struct Edge : BigDNA diff --git a/DataSpec/DNAMP1/MREA.cpp b/DataSpec/DNAMP1/MREA.cpp index 5ba4c1699..8077dc5c5 100644 --- a/DataSpec/DNAMP1/MREA.cpp +++ b/DataSpec/DNAMP1/MREA.cpp @@ -50,7 +50,7 @@ bool MREA::Extract(const SpecBase& dataSpec, rs.seekAlign32(); HECL::BlenderConnection& conn = HECL::BlenderConnection::SharedConnection(); - if (!conn.createBlend(outPath.getAbsolutePath(), HECL::BlenderConnection::TypeArea)) + if (!conn.createBlend(outPath, HECL::BlenderConnection::TypeArea)) return false; /* Open Py Stream and read sections */ diff --git a/DataSpec/DNAMP2/CMDL.hpp b/DataSpec/DNAMP2/CMDL.hpp index 39f6d1aad..87383e37a 100644 --- a/DataSpec/DNAMP2/CMDL.hpp +++ b/DataSpec/DNAMP2/CMDL.hpp @@ -38,7 +38,7 @@ struct CMDL /* Do extract */ HECL::BlenderConnection& conn = HECL::BlenderConnection::SharedConnection(); - if (!conn.createBlend(outPath.getAbsolutePath(), HECL::BlenderConnection::TypeMesh)) + if (!conn.createBlend(outPath, HECL::BlenderConnection::TypeMesh)) return false; DNACMDL::ReadCMDLToBlender, MaterialSet, std::pair, DNACMDL::SurfaceHeader_1_2, 4> (conn, rs, pakRouter, entry, dataSpec, loadRp); diff --git a/DataSpec/DNAMP2/DeafBabe.hpp b/DataSpec/DNAMP2/DeafBabe.hpp index fa94df8a1..cf48dc450 100644 --- a/DataSpec/DNAMP2/DeafBabe.hpp +++ b/DataSpec/DNAMP2/DeafBabe.hpp @@ -18,7 +18,7 @@ struct DeafBabe : BigDNA DECL_DNA Value material; bool fireThrough() const {return material >> 18 & 0x1;} - void setFireThrough(bool v) {material &= 0x40000; material |= v << 18;} + void setFireThrough(bool v) {material &= ~0x40000; material |= v << 18;} enum Type { @@ -34,7 +34,7 @@ struct DeafBabe : BigDNA MatLeaves }; Type type() const {return Type(material & 0xff);} - void setType(Type t) {material &= 0xff; material |= t;} + void setType(Type t) {material &= ~0xff; material |= t;} }; using Edge = DNAMP1::DeafBabe::Edge; diff --git a/DataSpec/DNAMP2/MREA.cpp b/DataSpec/DNAMP2/MREA.cpp index be97454cb..3b35600df 100644 --- a/DataSpec/DNAMP2/MREA.cpp +++ b/DataSpec/DNAMP2/MREA.cpp @@ -186,7 +186,7 @@ bool MREA::Extract(const SpecBase& dataSpec, /* Start up blender connection */ HECL::BlenderConnection& conn = HECL::BlenderConnection::SharedConnection(); - if (!conn.createBlend(outPath.getAbsolutePath(), HECL::BlenderConnection::TypeArea)) + if (!conn.createBlend(outPath, HECL::BlenderConnection::TypeArea)) return false; /* Open Py Stream and read sections */ diff --git a/DataSpec/DNAMP3/CMDL.hpp b/DataSpec/DNAMP3/CMDL.hpp index 0203d7eeb..404380c37 100644 --- a/DataSpec/DNAMP3/CMDL.hpp +++ b/DataSpec/DNAMP3/CMDL.hpp @@ -38,7 +38,7 @@ struct CMDL /* Do extract */ HECL::BlenderConnection& conn = HECL::BlenderConnection::SharedConnection(); - if (!conn.createBlend(outPath.getAbsolutePath(), HECL::BlenderConnection::TypeMesh)) + if (!conn.createBlend(outPath, HECL::BlenderConnection::TypeMesh)) return false; DNACMDL::ReadCMDLToBlender, MaterialSet, std::pair, DNACMDL::SurfaceHeader_3, 5> (conn, rs, pakRouter, entry, dataSpec, loadRp); diff --git a/DataSpec/DNAMP3/MREA.cpp b/DataSpec/DNAMP3/MREA.cpp index 41fb1bf24..9a4b91163 100644 --- a/DataSpec/DNAMP3/MREA.cpp +++ b/DataSpec/DNAMP3/MREA.cpp @@ -99,7 +99,7 @@ bool MREA::Extract(const SpecBase& dataSpec, /* Start up blender connection */ HECL::BlenderConnection& conn = HECL::BlenderConnection::SharedConnection(); - if (!conn.createBlend(outPath.getAbsolutePath(), HECL::BlenderConnection::TypeArea)) + if (!conn.createBlend(outPath, HECL::BlenderConnection::TypeArea)) return false; /* Open Py Stream and read sections */ diff --git a/DataSpec/SpecBase.cpp b/DataSpec/SpecBase.cpp index 3cb69c85a..0a18ee2f0 100644 --- a/DataSpec/SpecBase.cpp +++ b/DataSpec/SpecBase.cpp @@ -93,7 +93,7 @@ bool SpecBase::canCook(const HECL::ProjectPath& path) if (HECL::IsPathBlend(path)) { HECL::BlenderConnection& conn = HECL::BlenderConnection::SharedConnection(); - if (!conn.openBlend(path.getAbsolutePath())) + if (!conn.openBlend(path)) return false; if (conn.getBlendType() != HECL::BlenderConnection::TypeNone) return true; @@ -112,21 +112,40 @@ bool SpecBase::canCook(const HECL::ProjectPath& path) return false; } -using Mesh = HECL::BlenderConnection::DataStream::Mesh; - void SpecBase::doCook(const HECL::ProjectPath& path, const HECL::ProjectPath& cookedPath) { if (HECL::IsPathBlend(path)) { HECL::BlenderConnection& conn = HECL::BlenderConnection::SharedConnection(); - if (!conn.openBlend(path.getAbsolutePath())) + if (!conn.openBlend(path)) return; - if (conn.getBlendType() == HECL::BlenderConnection::TypeMesh) + switch (conn.getBlendType()) + { + case HECL::BlenderConnection::TypeMesh: { HECL::BlenderConnection::DataStream ds = conn.beginData(); - Mesh mesh = ds.compileMesh(); - ds.close(); + cookMesh(path, ds, cookedPath); + break; } + case HECL::BlenderConnection::TypeActor: + { + HECL::BlenderConnection::DataStream ds = conn.beginData(); + cookActor(path, ds, cookedPath); + break; + } + case HECL::BlenderConnection::TypeArea: + { + HECL::BlenderConnection::DataStream ds = conn.beginData(); + cookArea(path, ds, cookedPath); + break; + } + default: break; + } + } + else if (HECL::IsPathYAML(path)) + { + FILE* fp = HECL::Fopen(path.getAbsolutePath().c_str(), _S("r")); + cookYAML(fp, cookedPath); } } diff --git a/DataSpec/SpecBase.hpp b/DataSpec/SpecBase.hpp index b3776bf79..11f0217cf 100644 --- a/DataSpec/SpecBase.hpp +++ b/DataSpec/SpecBase.hpp @@ -45,6 +45,7 @@ struct SpecBase : HECL::Database::IDataSpec /* Cook handlers */ using BlendStream = HECL::BlenderConnection::DataStream; + using Mesh = BlendStream::Mesh; virtual void cookMesh(const HECL::ProjectPath& in, BlendStream& ds, const HECL::ProjectPath& out) const=0; virtual void cookActor(const HECL::ProjectPath& in, BlendStream& ds, const HECL::ProjectPath& out) const=0; virtual void cookArea(const HECL::ProjectPath& in, BlendStream& ds, const HECL::ProjectPath& out) const=0; diff --git a/DataSpec/SpecMP1.cpp b/DataSpec/SpecMP1.cpp index 883f6dd7e..c5615ea32 100644 --- a/DataSpec/SpecMP1.cpp +++ b/DataSpec/SpecMP1.cpp @@ -7,6 +7,7 @@ #include "DNAMP1/MLVL.hpp" #include "DNAMP1/STRG.hpp" +#include "DNAMP1/CMDL.hpp" namespace Retro { @@ -281,6 +282,8 @@ struct SpecMP1 : SpecBase void cookMesh(const HECL::ProjectPath& in, BlendStream& ds, const HECL::ProjectPath& out) const { + Mesh mesh = ds.compileMesh(); + DNAMP1::CMDL::Cook(mesh, out); } void cookActor(const HECL::ProjectPath& in, BlendStream& ds, const HECL::ProjectPath& out) const diff --git a/hecl b/hecl index dd557bb7c..120d22fd5 160000 --- a/hecl +++ b/hecl @@ -1 +1 @@ -Subproject commit dd557bb7c5a3a409988d1b24d81ddd1f66791701 +Subproject commit 120d22fd527452be9cc49dd601fd908cd5693555