diff --git a/DataSpec/DNACommon/CMDL.hpp b/DataSpec/DNACommon/CMDL.hpp index 6f63facdd..094412191 100644 --- a/DataSpec/DNACommon/CMDL.hpp +++ b/DataSpec/DNACommon/CMDL.hpp @@ -1228,6 +1228,13 @@ bool WriteCMDL(const HECL::ProjectPath& outPath, const HECL::ProjectPath& inPath ++padIt; /* Surfaces */ + GX::Primitive prim; + if (mesh.outputMode == Mesh::OutputTriangles) + prim = GX::TRIANGLES; + else if (mesh.outputMode == Mesh::OutputTriStrips) + prim = GX::TRIANGLESTRIP; + else + LogDNACommon.report(LogVisor::FatalError, "unrecognized mesh output mode"); for (const Mesh::Surface& surf : mesh.surfaces) { const typename MaterialSet::Material::VAFlags& vaFlags = @@ -1241,7 +1248,7 @@ bool WriteCMDL(const HECL::ProjectPath& outPath, const HECL::ProjectPath& inPath header.reflectionNormal = surf.reflectionNormal; header.write(writer); - writer.writeUByte(GX::TRIANGLESTRIP); + writer.writeUByte(prim); writer.writeUint16Big(surf.verts.size()); for (const Mesh::Surface::Vert& vert : surf.verts) diff --git a/DataSpec/DNAMP1/CMDL.hpp b/DataSpec/DNAMP1/CMDL.hpp index d4c18e6ca..a87e01a6b 100644 --- a/DataSpec/DNAMP1/CMDL.hpp +++ b/DataSpec/DNAMP1/CMDL.hpp @@ -53,7 +53,7 @@ struct CMDL /* Cook and re-extract test */ HECL::ProjectPath tempOut = outPath.getWithExtension(_S(".recook"), true); HECL::BlenderConnection::DataStream ds = conn.beginData(); - HECL::BlenderConnection::DataStream::Mesh mesh = ds.compileMesh(-1); + DNACMDL::Mesh mesh = ds.compileMesh(DNACMDL::Mesh::OutputTriStrips, -1); ds.close(); DNACMDL::WriteCMDL(tempOut, outPath, mesh); @@ -71,7 +71,33 @@ struct CMDL const DNACMDL::Mesh& mesh) { HECL::ProjectPath tempOut = outPath.getWithExtension(_S(".recook")); - return DNACMDL::WriteCMDL(tempOut, inPath, mesh); + if (mesh.skins.size()) + { + DNACMDL::Mesh skinMesh = mesh.getContiguousSkinningVersion(); + if (!DNACMDL::WriteCMDL(tempOut, inPath, skinMesh)) + return false; + + /* Output skinning intermediate */ + auto vertCountIt = skinMesh.contiguousSkinVertCounts.cbegin(); + Athena::io::FileWriter writer(outPath.getWithExtension(_S(".skin")).getAbsolutePath()); + writer.writeUint32Big(skinMesh.skins.size()); + for (const std::vector skin : skinMesh.skins) + { + writer.writeUint32Big(skin.size()); + for (const DNACMDL::Mesh::SkinBind& bind : skin) + { + writer.writeUint32Big(bind.boneIdx); + writer.writeFloatBig(bind.weight); + } + writer.writeUint32Big(*vertCountIt++); + } + writer.writeUint32Big(skinMesh.boneNames.size()); + for (const std::string& boneName : skinMesh.boneNames) + writer.writeString(boneName); + } + else if (!DNACMDL::WriteCMDL(tempOut, inPath, mesh)) + return false; + return true; } }; diff --git a/DataSpec/DNAMP1/CMDLMaterials.cpp b/DataSpec/DNAMP1/CMDLMaterials.cpp index 4b930449f..749287874 100644 --- a/DataSpec/DNAMP1/CMDLMaterials.cpp +++ b/DataSpec/DNAMP1/CMDLMaterials.cpp @@ -581,6 +581,20 @@ static void AddTEVStage(Stream& out, const MaterialSet::Material::TEVStage& stag AddColorCombiner(out, COMB_ADD, cd, ca, nullptr); ++c_combiner_idx; } + else if (stage.colorInA() != GX::CC_ZERO && + stage.colorInB() == GX::CC_ZERO && + stage.colorInC() == GX::CC_ZERO && + stage.colorInD() == GX::CC_ZERO) + { + c_tev_opts |= 0xf; + } + else if (stage.colorInA() == GX::CC_ZERO && + stage.colorInB() == GX::CC_ZERO && + stage.colorInC() == GX::CC_ZERO && + stage.colorInD() != GX::CC_ZERO) + { + c_tev_opts |= 0xf; + } if (!(c_tev_opts & 1)) { @@ -655,6 +669,20 @@ static void AddTEVStage(Stream& out, const MaterialSet::Material::TEVStage& stag AddAlphaCombiner(out, COMB_ADD, ad, aa, nullptr); ++a_combiner_idx; } + else if (stage.alphaInA() != GX::CA_ZERO && + stage.alphaInB() == GX::CA_ZERO && + stage.alphaInC() == GX::CA_ZERO && + stage.alphaInD() == GX::CA_ZERO) + { + a_tev_opts |= 0xf; + } + else if (stage.alphaInA() == GX::CA_ZERO && + stage.alphaInB() == GX::CA_ZERO && + stage.alphaInC() == GX::CA_ZERO && + stage.alphaInD() != GX::CA_ZERO) + { + a_tev_opts |= 0xf; + } if (!(a_tev_opts & 1)) { @@ -713,6 +741,8 @@ static void AddTEVStage(Stream& out, const MaterialSet::Material::TEVStage& stag { if (stage.colorInD() != GX::CC_ZERO) strncpy(c_regs[stage.colorOpOutReg()], cd, 64); + else if (stage.colorInA() != GX::CC_ZERO) + strncpy(c_regs[stage.colorOpOutReg()], ca, 64); } else snprintf(c_regs[stage.colorOpOutReg()], 64, "color_combiner_sockets[%u]", c_combiner_idx - 1); @@ -720,6 +750,8 @@ static void AddTEVStage(Stream& out, const MaterialSet::Material::TEVStage& stag { if (stage.alphaInD() != GX::CA_ZERO) strncpy(a_regs[stage.alphaOpOutReg()], ad, 64); + else if (stage.alphaInA() != GX::CA_ZERO) + strncpy(a_regs[stage.alphaOpOutReg()], aa, 64); } else snprintf(a_regs[stage.alphaOpOutReg()], 64, "alpha_combiner_sockets[%u]", a_combiner_idx - 1); diff --git a/DataSpec/SpecBase.cpp b/DataSpec/SpecBase.cpp index acf11890e..a9b9573c0 100644 --- a/DataSpec/SpecBase.cpp +++ b/DataSpec/SpecBase.cpp @@ -112,7 +112,8 @@ bool SpecBase::canCook(const HECL::ProjectPath& path) return false; } -void SpecBase::doCook(const HECL::ProjectPath& path, const HECL::ProjectPath& cookedPath) +void SpecBase::doCook(const HECL::ProjectPath& path, const HECL::ProjectPath& cookedPath, + bool fast, FCookProgress progress) { if (HECL::IsPathBlend(path)) { @@ -124,19 +125,19 @@ void SpecBase::doCook(const HECL::ProjectPath& path, const HECL::ProjectPath& co case HECL::BlenderConnection::TypeMesh: { HECL::BlenderConnection::DataStream ds = conn.beginData(); - cookMesh(cookedPath, path, ds); + cookMesh(cookedPath, path, ds, fast, progress); break; } case HECL::BlenderConnection::TypeActor: { HECL::BlenderConnection::DataStream ds = conn.beginData(); - cookActor(cookedPath, path, ds); + cookActor(cookedPath, path, ds, fast, progress); break; } case HECL::BlenderConnection::TypeArea: { HECL::BlenderConnection::DataStream ds = conn.beginData(); - cookArea(cookedPath, path, ds); + cookArea(cookedPath, path, ds, fast, progress); break; } default: break; @@ -145,7 +146,7 @@ void SpecBase::doCook(const HECL::ProjectPath& path, const HECL::ProjectPath& co else if (HECL::IsPathYAML(path)) { FILE* fp = HECL::Fopen(path.getAbsolutePath().c_str(), _S("r")); - cookYAML(cookedPath, path, fp); + cookYAML(cookedPath, path, fp, progress); } } diff --git a/DataSpec/SpecBase.hpp b/DataSpec/SpecBase.hpp index ae09231ce..2ef5b8816 100644 --- a/DataSpec/SpecBase.hpp +++ b/DataSpec/SpecBase.hpp @@ -17,7 +17,7 @@ struct SpecBase : HECL::Database::IDataSpec void doExtract(const ExtractPassInfo& info, FProgress progress); bool canCook(const HECL::ProjectPath& path); - void doCook(const HECL::ProjectPath& path, const HECL::ProjectPath& cookedPath); + void doCook(const HECL::ProjectPath& path, const HECL::ProjectPath& cookedPath, bool fast, FCookProgress progress); bool canPackage(const PackagePassInfo& info); void gatherDependencies(const PackagePassInfo& info, @@ -47,10 +47,10 @@ struct SpecBase : HECL::Database::IDataSpec using BlendStream = HECL::BlenderConnection::DataStream; using Mesh = BlendStream::Mesh; - virtual void cookMesh(const HECL::ProjectPath& out, const HECL::ProjectPath& in, BlendStream& ds) const=0; - virtual void cookActor(const HECL::ProjectPath& out, const HECL::ProjectPath& in, BlendStream& ds) const=0; - virtual void cookArea(const HECL::ProjectPath& out, const HECL::ProjectPath& in, BlendStream& ds) const=0; - virtual void cookYAML(const HECL::ProjectPath& out, const HECL::ProjectPath& in, FILE* fin) const=0; + virtual void cookMesh(const HECL::ProjectPath& out, const HECL::ProjectPath& in, BlendStream& ds, bool fast, FCookProgress progress) const=0; + virtual void cookActor(const HECL::ProjectPath& out, const HECL::ProjectPath& in, BlendStream& ds, bool fast, FCookProgress progress) const=0; + virtual void cookArea(const HECL::ProjectPath& out, const HECL::ProjectPath& in, BlendStream& ds, bool fast, FCookProgress progress) const=0; + virtual void cookYAML(const HECL::ProjectPath& out, const HECL::ProjectPath& in, FILE* fin, FCookProgress progress) const=0; const HECL::ProjectPath& getMasterShaderPath() const {return m_masterShader;} diff --git a/DataSpec/SpecMP1.cpp b/DataSpec/SpecMP1.cpp index c9418a18a..f97815167 100644 --- a/DataSpec/SpecMP1.cpp +++ b/DataSpec/SpecMP1.cpp @@ -280,21 +280,29 @@ struct SpecMP1 : SpecBase return false; } - void cookMesh(const HECL::ProjectPath& out, const HECL::ProjectPath& in, BlendStream& ds) const + void cookMesh(const HECL::ProjectPath& out, const HECL::ProjectPath& in, + BlendStream& ds, bool fast, FCookProgress progress) const { - Mesh mesh = ds.compileMesh(-1); + Mesh mesh = ds.compileMesh(fast ? Mesh::OutputTriangles : Mesh::OutputTriStrips, -1, + [&progress](int surfCount) + { + progress(HECL::SysFormat(_S("%d"), surfCount).c_str()); + }); DNAMP1::CMDL::Cook(out, in, mesh); } - void cookActor(const HECL::ProjectPath& out, const HECL::ProjectPath& in, BlendStream& ds) const + void cookActor(const HECL::ProjectPath& out, const HECL::ProjectPath& in, + BlendStream& ds, bool fast, FCookProgress progress) const { } - void cookArea(const HECL::ProjectPath& out, const HECL::ProjectPath& in, BlendStream& ds) const + void cookArea(const HECL::ProjectPath& out, const HECL::ProjectPath& in, + BlendStream& ds, bool fast, FCookProgress progress) const { } - void cookYAML(const HECL::ProjectPath& out, const HECL::ProjectPath& in, FILE* fin) const + void cookYAML(const HECL::ProjectPath& out, const HECL::ProjectPath& in, + FILE* fin, FCookProgress progress) const { } }; diff --git a/DataSpec/SpecMP2.cpp b/DataSpec/SpecMP2.cpp index 2cca8ff36..1c6db32a9 100644 --- a/DataSpec/SpecMP2.cpp +++ b/DataSpec/SpecMP2.cpp @@ -271,19 +271,23 @@ struct SpecMP2 : SpecBase return false; } - void cookMesh(const HECL::ProjectPath& out, const HECL::ProjectPath& in, BlendStream& ds) const + void cookMesh(const HECL::ProjectPath& out, const HECL::ProjectPath& in, + BlendStream& ds, bool fast, FCookProgress progress) const { } - void cookActor(const HECL::ProjectPath& out, const HECL::ProjectPath& in, BlendStream& ds) const + void cookActor(const HECL::ProjectPath& out, const HECL::ProjectPath& in, + BlendStream& ds, bool fast, FCookProgress progress) const { } - void cookArea(const HECL::ProjectPath& out, const HECL::ProjectPath& in, BlendStream& ds) const + void cookArea(const HECL::ProjectPath& out, const HECL::ProjectPath& in, + BlendStream& ds, bool fast, FCookProgress progress) const { } - void cookYAML(const HECL::ProjectPath& out, const HECL::ProjectPath& in, FILE* fin) const + void cookYAML(const HECL::ProjectPath& out, const HECL::ProjectPath& in, + FILE* fin, FCookProgress progress) const { } }; diff --git a/DataSpec/SpecMP3.cpp b/DataSpec/SpecMP3.cpp index 75c16eac1..2352b5764 100644 --- a/DataSpec/SpecMP3.cpp +++ b/DataSpec/SpecMP3.cpp @@ -453,19 +453,23 @@ struct SpecMP3 : SpecBase return false; } - void cookMesh(const HECL::ProjectPath& out, const HECL::ProjectPath& in, BlendStream& ds) const + void cookMesh(const HECL::ProjectPath& out, const HECL::ProjectPath& in, + BlendStream& ds, bool fast, FCookProgress progress) const { } - void cookActor(const HECL::ProjectPath& out, const HECL::ProjectPath& in, BlendStream& ds) const + void cookActor(const HECL::ProjectPath& out, const HECL::ProjectPath& in, + BlendStream& ds, bool fast, FCookProgress progress) const { } - void cookArea(const HECL::ProjectPath& out, const HECL::ProjectPath& in, BlendStream& ds) const + void cookArea(const HECL::ProjectPath& out, const HECL::ProjectPath& in, + BlendStream& ds, bool fast, FCookProgress progress) const { } - void cookYAML(const HECL::ProjectPath& out, const HECL::ProjectPath& in, FILE* fin) const + void cookYAML(const HECL::ProjectPath& out, const HECL::ProjectPath& in, + FILE* fin, FCookProgress progress) const { } }; diff --git a/hecl b/hecl index 43498db9f..8d513577c 160000 --- a/hecl +++ b/hecl @@ -1 +1 @@ -Subproject commit 43498db9f7a56f46ba8844c83113c5d8e2fb7adc +Subproject commit 8d513577cb199a8e567119fe45356b75ab3700ed