mirror of https://github.com/AxioDL/metaforce.git
Specialize PATH by PAKBridge
This commit is contained in:
parent
df229671c4
commit
73f245ee27
|
@ -1,6 +1,9 @@
|
|||
#include "AROTBuilder.hpp"
|
||||
#include "hecl/Blender/Connection.hpp"
|
||||
#include "../DNAMP1/PATH.hpp"
|
||||
#include "PATH.hpp"
|
||||
#include "DataSpec/DNAMP1/DNAMP1.hpp"
|
||||
#include "DataSpec/DNAMP2/DNAMP2.hpp"
|
||||
#include "DataSpec/DNAMP3/DNAMP3.hpp"
|
||||
|
||||
namespace DataSpec {
|
||||
logvisor::Module Log("AROTBuilder");
|
||||
|
@ -272,8 +275,8 @@ void AROTBuilder::Node::pathCountNodesAndLookups(size_t& nodeCount, size_t& look
|
|||
}
|
||||
}
|
||||
|
||||
template <uint32_t PathVer>
|
||||
void AROTBuilder::Node::pathWrite(DNAPATH::PATH<PathVer>& path, const zeus::CAABox& curAABB) {
|
||||
template <class PAKBridge>
|
||||
void AROTBuilder::Node::pathWrite(DNAPATH::PATH<PAKBridge>& path, const zeus::CAABox& curAABB) {
|
||||
if (childNodes.empty()) {
|
||||
auto& n = path.octree.emplace_back();
|
||||
n.isLeaf = 1;
|
||||
|
@ -306,9 +309,9 @@ void AROTBuilder::Node::pathWrite(DNAPATH::PATH<PathVer>& path, const zeus::CAAB
|
|||
}
|
||||
}
|
||||
|
||||
template void AROTBuilder::Node::pathWrite<4>(DNAPATH::PATH<4>& path, const zeus::CAABox& curAABB);
|
||||
template void AROTBuilder::Node::pathWrite<6>(DNAPATH::PATH<6>& path, const zeus::CAABox& curAABB);
|
||||
template void AROTBuilder::Node::pathWrite<7>(DNAPATH::PATH<7>& path, const zeus::CAABox& curAABB);
|
||||
template void AROTBuilder::Node::pathWrite(DNAPATH::PATH<DNAMP1::PAKBridge>& path, const zeus::CAABox& curAABB);
|
||||
template void AROTBuilder::Node::pathWrite(DNAPATH::PATH<DNAMP2::PAKBridge>& path, const zeus::CAABox& curAABB);
|
||||
template void AROTBuilder::Node::pathWrite(DNAPATH::PATH<DNAMP3::PAKBridge>& path, const zeus::CAABox& curAABB);
|
||||
|
||||
void AROTBuilder::build(std::vector<std::vector<uint8_t>>& secs, const zeus::CAABox& fullAabb,
|
||||
const std::vector<zeus::CAABox>& meshAabbs, const std::vector<DNACMDL::Mesh>& meshes) {
|
||||
|
@ -403,8 +406,8 @@ std::pair<std::unique_ptr<uint8_t[]>, uint32_t> AROTBuilder::buildCol(const ColM
|
|||
return {std::move(ret), totalSize};
|
||||
}
|
||||
|
||||
template <uint32_t PathVer>
|
||||
void AROTBuilder::buildPath(DNAPATH::PATH<PathVer>& path) {
|
||||
template <class PAKBridge>
|
||||
void AROTBuilder::buildPath(DNAPATH::PATH<PAKBridge>& path) {
|
||||
/* Accumulate total AABB and gather region boxes */
|
||||
std::vector<zeus::CAABox> regionBoxes;
|
||||
regionBoxes.reserve(path.regions.size());
|
||||
|
@ -427,8 +430,8 @@ void AROTBuilder::buildPath(DNAPATH::PATH<PathVer>& path) {
|
|||
rootNode.pathWrite(path, fullAABB);
|
||||
}
|
||||
|
||||
template void AROTBuilder::buildPath<4>(DNAPATH::PATH<4>& path);
|
||||
template void AROTBuilder::buildPath<6>(DNAPATH::PATH<6>& path);
|
||||
template void AROTBuilder::buildPath<7>(DNAPATH::PATH<7>& path);
|
||||
template void AROTBuilder::buildPath(DNAPATH::PATH<DNAMP1::PAKBridge>& path);
|
||||
template void AROTBuilder::buildPath(DNAPATH::PATH<DNAMP2::PAKBridge>& path);
|
||||
template void AROTBuilder::buildPath(DNAPATH::PATH<DNAMP3::PAKBridge>& path);
|
||||
|
||||
} // namespace DataSpec
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
namespace DataSpec {
|
||||
namespace DNAPATH {
|
||||
template <atUint32 PathVer>
|
||||
template <class PAKBridge>
|
||||
struct PATH;
|
||||
}
|
||||
|
||||
|
@ -44,15 +44,15 @@ struct AROTBuilder {
|
|||
void writeColNodes(uint8_t*& ptr, const zeus::CAABox& curAABB);
|
||||
|
||||
void pathCountNodesAndLookups(size_t& nodeCount, size_t& lookupCount);
|
||||
template <uint32_t PathVer>
|
||||
void pathWrite(DNAPATH::PATH<PathVer>& path, const zeus::CAABox& curAABB);
|
||||
template <class PAKBridge>
|
||||
void pathWrite(DNAPATH::PATH<PAKBridge>& path, const zeus::CAABox& curAABB);
|
||||
} rootNode;
|
||||
|
||||
void build(std::vector<std::vector<uint8_t>>& secs, const zeus::CAABox& fullAabb,
|
||||
const std::vector<zeus::CAABox>& meshAabbs, const std::vector<DNACMDL::Mesh>& meshes);
|
||||
std::pair<std::unique_ptr<uint8_t[]>, uint32_t> buildCol(const ColMesh& mesh, BspNodeType& rootOut);
|
||||
template <uint32_t PathVer>
|
||||
void buildPath(DNAPATH::PATH<PathVer>& path);
|
||||
template <class PAKBridge>
|
||||
void buildPath(DNAPATH::PATH<PAKBridge>& path);
|
||||
};
|
||||
|
||||
} // namespace DataSpec
|
||||
|
|
|
@ -24,9 +24,9 @@ static void OutputOctreeNode(hecl::blender::PyOutStream& os, int idx, const zeus
|
|||
}
|
||||
#endif
|
||||
|
||||
template <atUint32 Ver>
|
||||
void PATH<Ver>::sendToBlender(hecl::blender::Connection& conn, std::string_view entryName, const zeus::CMatrix4f* xf,
|
||||
const std::string& areaPath) {
|
||||
template <class PAKBridge>
|
||||
void PATH<PAKBridge>::sendToBlender(hecl::blender::Connection& conn, std::string_view entryName,
|
||||
const zeus::CMatrix4f* xf, const std::string& areaPath) {
|
||||
/* Open Py Stream and read sections */
|
||||
hecl::blender::PyOutStream os = conn.beginPythonOut(true);
|
||||
os << "import bpy\n"
|
||||
|
@ -176,9 +176,33 @@ void PATH<Ver>::sendToBlender(hecl::blender::Connection& conn, std::string_view
|
|||
os.close();
|
||||
}
|
||||
|
||||
template <atUint32 Ver>
|
||||
bool PATH<Ver>::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPath, const PathMesh& mesh,
|
||||
hecl::blender::Token& btok) {
|
||||
template <class PAKBridge>
|
||||
bool PATH<PAKBridge>::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl::ProjectPath& outPath,
|
||||
PAKRouter<PAKBridge>& pakRouter, const typename PAKBridge::PAKType::Entry& entry,
|
||||
bool force, hecl::blender::Token& btok,
|
||||
std::function<void(const hecl::SystemChar*)> fileChanged) {
|
||||
PATH path;
|
||||
path.read(rs);
|
||||
hecl::blender::Connection& conn = btok.getBlenderConnection();
|
||||
if (!conn.createBlend(outPath, hecl::blender::BlendType::PathMesh))
|
||||
return false;
|
||||
|
||||
std::string areaPath;
|
||||
for (const auto& ent : hecl::DirectoryEnumerator(outPath.getParentPath().getAbsolutePath())) {
|
||||
if (hecl::StringUtils::BeginsWith(ent.m_name, _SYS_STR("!area_"))) {
|
||||
areaPath = hecl::SystemUTF8Conv(ent.m_name).str();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const zeus::CMatrix4f* xf = pakRouter.lookupMAPATransform(entry.id);
|
||||
path.sendToBlender(conn, pakRouter.getBestEntryName(entry, false), xf, areaPath);
|
||||
return conn.saveBlend();
|
||||
}
|
||||
|
||||
template <class PAKBridge>
|
||||
bool PATH<PAKBridge>::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPath, const PathMesh& mesh,
|
||||
hecl::blender::Token& btok) {
|
||||
athena::io::MemoryReader r(mesh.data.data(), mesh.data.size());
|
||||
PATH path;
|
||||
path.read(r);
|
||||
|
@ -217,8 +241,8 @@ bool PATH<Ver>::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath&
|
|||
return true;
|
||||
}
|
||||
|
||||
template struct PATH<4>;
|
||||
template struct PATH<6>;
|
||||
template struct PATH<7>;
|
||||
template struct PATH<DataSpec::DNAMP1::PAKBridge>;
|
||||
template struct PATH<DataSpec::DNAMP2::PAKBridge>;
|
||||
template struct PATH<DataSpec::DNAMP3::PAKBridge>;
|
||||
|
||||
} // namespace DataSpec::DNAPATH
|
|
@ -2,17 +2,20 @@
|
|||
|
||||
#include "DataSpec/DNACommon/DNACommon.hpp"
|
||||
#include "DataSpec/DNACommon/PAK.hpp"
|
||||
#include "DataSpec/DNAMP1/DNAMP1.hpp"
|
||||
#include "DataSpec/DNAMP2/DNAMP2.hpp"
|
||||
#include "DataSpec/DNAMP3/DNAMP3.hpp"
|
||||
|
||||
namespace DataSpec::DNAPATH {
|
||||
template <atUint32 Ver>
|
||||
template <class PAKBridge>
|
||||
struct RegionPointers {};
|
||||
template <>
|
||||
struct RegionPointers<4> : BigDNA {
|
||||
struct RegionPointers<DataSpec::DNAMP1::PAKBridge> : BigDNA {
|
||||
AT_DECL_DNA
|
||||
Value<atUint32> regionIdxPtr;
|
||||
};
|
||||
template <>
|
||||
struct RegionPointers<6> : BigDNA {
|
||||
struct RegionPointers<DataSpec::DNAMP2::PAKBridge> : BigDNA {
|
||||
AT_DECL_DNA
|
||||
Value<atUint32> unk0;
|
||||
Value<atUint32> unk1;
|
||||
|
@ -20,7 +23,7 @@ struct RegionPointers<6> : BigDNA {
|
|||
Value<atUint32> regionIdxPtr;
|
||||
};
|
||||
template <>
|
||||
struct RegionPointers<7> : BigDNA {
|
||||
struct RegionPointers<DataSpec::DNAMP3::PAKBridge> : BigDNA {
|
||||
AT_DECL_DNA
|
||||
Value<atUint32> unk0;
|
||||
Value<atUint32> unk1;
|
||||
|
@ -28,8 +31,9 @@ struct RegionPointers<7> : BigDNA {
|
|||
Value<atUint32> regionIdxPtr;
|
||||
};
|
||||
|
||||
template <atUint32 Ver>
|
||||
struct AT_SPECIALIZE_PARMS(4, 6, 7) PATH : BigDNA {
|
||||
template <class PAKBridge>
|
||||
struct AT_SPECIALIZE_PARMS(DataSpec::DNAMP1::PAKBridge, DataSpec::DNAMP2::PAKBridge, DataSpec::DNAMP3::PAKBridge) PATH
|
||||
: BigDNA {
|
||||
using PathMesh = hecl::blender::PathMesh;
|
||||
|
||||
AT_DECL_DNA
|
||||
|
@ -66,7 +70,7 @@ struct AT_SPECIALIZE_PARMS(4, 6, 7) PATH : BigDNA {
|
|||
Value<atUint32> regionIdx;
|
||||
Value<atVec3f> centroid;
|
||||
Value<atVec3f> aabb[2];
|
||||
Value<RegionPointers<Ver>> pointers;
|
||||
Value<RegionPointers<PAKBridge>> pointers;
|
||||
};
|
||||
Value<atUint32> regionCount;
|
||||
Vector<Region, AT_DNA_COUNT(regionCount)> regions;
|
||||
|
@ -93,7 +97,11 @@ struct AT_SPECIALIZE_PARMS(4, 6, 7) PATH : BigDNA {
|
|||
void sendToBlender(hecl::blender::Connection& conn, std::string_view entryName, const zeus::CMatrix4f* xf,
|
||||
const std::string& areaPath);
|
||||
|
||||
static bool Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPath,
|
||||
const PathMesh& mesh, hecl::blender::Token& btok);
|
||||
static bool Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl::ProjectPath& outPath,
|
||||
PAKRouter<PAKBridge>& pakRouter, const typename PAKBridge::PAKType::Entry& entry, bool force,
|
||||
hecl::blender::Token& btok, std::function<void(const hecl::SystemChar*)> fileChanged);
|
||||
|
||||
static bool Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPath, const PathMesh& mesh,
|
||||
hecl::blender::Token& btok);
|
||||
};
|
||||
} // namespace DataSpec::DNAMP1
|
||||
} // namespace DataSpec::DNAPATH
|
||||
|
|
|
@ -49,7 +49,7 @@ set(DNAMP1_SOURCES
|
|||
ANIM.cpp
|
||||
CINF.cpp
|
||||
EVNT.cpp
|
||||
PATH.cpp
|
||||
PATH.hpp
|
||||
CMDL.hpp CMDL.cpp
|
||||
CMDLMaterials.cpp
|
||||
DCLN.cpp
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
#include "DataSpec/DNAMP1/PATH.hpp"
|
||||
#include "DataSpec/DNACommon/AROTBuilder.hpp"
|
||||
#include "hecl/Blender/Connection.hpp"
|
||||
|
||||
namespace DataSpec::DNAMP1 {
|
||||
bool PATH::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl::ProjectPath& outPath,
|
||||
PAKRouter<PAKBridge>& pakRouter, const PAK::Entry& entry, bool force, hecl::blender::Token& btok,
|
||||
std::function<void(const hecl::SystemChar*)> fileChanged) {
|
||||
PATH path;
|
||||
path.read(rs);
|
||||
hecl::blender::Connection& conn = btok.getBlenderConnection();
|
||||
if (!conn.createBlend(outPath, hecl::blender::BlendType::PathMesh))
|
||||
return false;
|
||||
|
||||
std::string areaPath;
|
||||
for (const auto& ent : hecl::DirectoryEnumerator(outPath.getParentPath().getAbsolutePath())) {
|
||||
if (hecl::StringUtils::BeginsWith(ent.m_name, _SYS_STR("!area_"))) {
|
||||
areaPath = hecl::SystemUTF8Conv(ent.m_name).str();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const zeus::CMatrix4f* xf = pakRouter.lookupMAPATransform(entry.id);
|
||||
path.sendToBlender(conn, pakRouter.getBestEntryName(entry, false), xf, areaPath);
|
||||
return conn.saveBlend();
|
||||
}
|
||||
}
|
|
@ -1,11 +1,6 @@
|
|||
#pragma once
|
||||
#include "DataSpec/DNACommon/PATH.hpp"
|
||||
#include "DataSpec/DNAMP1/DNAMP1.hpp"
|
||||
|
||||
namespace DataSpec::DNAMP1 {
|
||||
struct PATH : DNAPATH::PATH<4> {
|
||||
static bool Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl::ProjectPath& outPath,
|
||||
PAKRouter<PAKBridge>& pakRouter, const PAK::Entry& entry, bool force, hecl::blender::Token& btok,
|
||||
std::function<void(const hecl::SystemChar*)> fileChanged);
|
||||
};
|
||||
} // namespace DataSpec::DNAMP1
|
||||
using PATH = DNAPATH::PATH<PAKBridge>;
|
||||
} // namespace DataSpec::DNAMP1
|
||||
|
|
|
@ -23,7 +23,7 @@ set(DNAMP2_SOURCES
|
|||
MREA.cpp
|
||||
MAPA.hpp
|
||||
MAPU.hpp
|
||||
PATH.hpp PATH.cpp
|
||||
PATH.hpp
|
||||
AFSM.hpp
|
||||
STRG.hpp STRG.cpp)
|
||||
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
#include "DataSpec/DNAMP2/PATH.hpp"
|
||||
#include "hecl/Blender/Connection.hpp"
|
||||
|
||||
namespace DataSpec::DNAMP2 {
|
||||
bool PATH::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl::ProjectPath& outPath,
|
||||
PAKRouter<PAKBridge>& pakRouter, const PAK::Entry& entry, bool force, hecl::blender::Token& btok,
|
||||
std::function<void(const hecl::SystemChar*)> fileChanged) {
|
||||
PATH path;
|
||||
path.read(rs);
|
||||
hecl::blender::Connection& conn = btok.getBlenderConnection();
|
||||
if (!conn.createBlend(outPath, hecl::blender::BlendType::PathMesh))
|
||||
return false;
|
||||
|
||||
std::string areaPath;
|
||||
for (const auto& ent : hecl::DirectoryEnumerator(outPath.getParentPath().getAbsolutePath())) {
|
||||
if (hecl::StringUtils::BeginsWith(ent.m_name, _SYS_STR("!area_"))) {
|
||||
areaPath = hecl::SystemUTF8Conv(ent.m_name).str();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const zeus::CMatrix4f* xf = pakRouter.lookupMAPATransform(entry.id);
|
||||
path.sendToBlender(conn, pakRouter.getBestEntryName(entry, false), xf, areaPath);
|
||||
return conn.saveBlend();
|
||||
}
|
||||
}
|
|
@ -1,14 +1,6 @@
|
|||
#pragma once
|
||||
#include "DataSpec/DNACommon/PATH.hpp"
|
||||
#include "DataSpec/DNAMP2/DNAMP2.hpp"
|
||||
|
||||
namespace DataSpec::DNAMP2 {
|
||||
struct PATH : DNAPATH::PATH<6> {
|
||||
static bool Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl::ProjectPath& outPath,
|
||||
PAKRouter<PAKBridge>& pakRouter, const PAK::Entry& entry, bool force, hecl::blender::Token& btok,
|
||||
std::function<void(const hecl::SystemChar*)> fileChanged);
|
||||
|
||||
static bool Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPath,
|
||||
const PathMesh& mesh, hecl::blender::Token& btok);
|
||||
};
|
||||
}
|
||||
using PATH = DNAPATH::PATH<PAKBridge>;
|
||||
} // namespace DataSpec::DNAMP2
|
||||
|
|
|
@ -661,7 +661,7 @@ struct SpecMP1 : SpecBase {
|
|||
hecl::blender::Token& btok, FCookProgress progress) override {
|
||||
PathMesh mesh = ds.compilePathMesh();
|
||||
ds.close();
|
||||
DNAPATH::PATH<4>::Cook(out, in, mesh, btok);
|
||||
DNAMP1::PATH::Cook(out, in, mesh, btok);
|
||||
}
|
||||
|
||||
void cookActor(const hecl::ProjectPath& out, const hecl::ProjectPath& in, BlendStream& ds, bool fast,
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "DNAMP2/MLVL.hpp"
|
||||
#include "DNAMP2/STRG.hpp"
|
||||
#include "DNAMP2/AGSC.hpp"
|
||||
#include "DNAMP2/PATH.hpp"
|
||||
#include "DNAMP2/MAPA.hpp"
|
||||
#include "DNAMP1/CSNG.hpp"
|
||||
#include "DNACommon/MAPU.hpp"
|
||||
|
@ -291,7 +292,7 @@ struct SpecMP2 : SpecBase {
|
|||
hecl::blender::Token& btok, FCookProgress progress) override {
|
||||
PathMesh mesh = ds.compilePathMesh();
|
||||
ds.close();
|
||||
DNAPATH::PATH<6>::Cook(out, in, mesh, btok);
|
||||
DNAMP2::PATH::Cook(out, in, mesh, btok);
|
||||
}
|
||||
|
||||
void cookActor(const hecl::ProjectPath& out, const hecl::ProjectPath& in, BlendStream& ds, bool fast,
|
||||
|
|
Loading…
Reference in New Issue