MP2 PATH support

This commit is contained in:
Jack Andersen 2020-04-08 19:19:50 -10:00
parent 5b0a4b5f60
commit df229671c4
12 changed files with 181 additions and 115 deletions

View File

@ -272,10 +272,10 @@ void AROTBuilder::Node::pathCountNodesAndLookups(size_t& nodeCount, size_t& look
} }
} }
void AROTBuilder::Node::pathWrite(DNAPATH::PATH& path, const zeus::CAABox& curAABB) { template <uint32_t PathVer>
void AROTBuilder::Node::pathWrite(DNAPATH::PATH<PathVer>& path, const zeus::CAABox& curAABB) {
if (childNodes.empty()) { if (childNodes.empty()) {
path.octree.emplace_back(); auto& n = path.octree.emplace_back();
DNAPATH::PATH::OctreeNode& n = path.octree.back();
n.isLeaf = 1; n.isLeaf = 1;
n.aabb[0] = curAABB.min; n.aabb[0] = curAABB.min;
n.aabb[1] = curAABB.max; n.aabb[1] = curAABB.max;
@ -294,8 +294,7 @@ void AROTBuilder::Node::pathWrite(DNAPATH::PATH& path, const zeus::CAABox& curAA
children[i] = path.octree.size() - 1; children[i] = path.octree.size() - 1;
} }
path.octree.emplace_back(); auto& n = path.octree.emplace_back();
DNAMP1::PATH::OctreeNode& n = path.octree.back();
n.isLeaf = 0; n.isLeaf = 0;
n.aabb[0] = curAABB.min; n.aabb[0] = curAABB.min;
n.aabb[1] = curAABB.max; n.aabb[1] = curAABB.max;
@ -307,6 +306,10 @@ void AROTBuilder::Node::pathWrite(DNAPATH::PATH& path, const zeus::CAABox& curAA
} }
} }
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);
void AROTBuilder::build(std::vector<std::vector<uint8_t>>& secs, const zeus::CAABox& fullAabb, 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) { const std::vector<zeus::CAABox>& meshAabbs, const std::vector<DNACMDL::Mesh>& meshes) {
/* Recursively split */ /* Recursively split */
@ -377,8 +380,7 @@ std::pair<std::unique_ptr<uint8_t[]>, uint32_t> AROTBuilder::buildCol(const ColM
std::vector<zeus::CAABox> triBoxes; std::vector<zeus::CAABox> triBoxes;
triBoxes.reserve(mesh.trianges.size()); triBoxes.reserve(mesh.trianges.size());
for (const ColMesh::Triangle& tri : mesh.trianges) { for (const ColMesh::Triangle& tri : mesh.trianges) {
triBoxes.emplace_back(); zeus::CAABox& aabb = triBoxes.emplace_back();
zeus::CAABox& aabb = triBoxes.back();
for (int e = 0; e < 3; ++e) { for (int e = 0; e < 3; ++e) {
const ColMesh::Edge& edge = mesh.edges[tri.edges[e]]; const ColMesh::Edge& edge = mesh.edges[tri.edges[e]];
for (int v = 0; v < 2; ++v) { for (int v = 0; v < 2; ++v) {
@ -401,15 +403,14 @@ std::pair<std::unique_ptr<uint8_t[]>, uint32_t> AROTBuilder::buildCol(const ColM
return {std::move(ret), totalSize}; return {std::move(ret), totalSize};
} }
void AROTBuilder::buildPath(DNAPATH::PATH& path) { template <uint32_t PathVer>
void AROTBuilder::buildPath(DNAPATH::PATH<PathVer>& path) {
/* Accumulate total AABB and gather region boxes */ /* Accumulate total AABB and gather region boxes */
std::vector<zeus::CAABox> regionBoxes; std::vector<zeus::CAABox> regionBoxes;
regionBoxes.reserve(path.regions.size()); regionBoxes.reserve(path.regions.size());
zeus::CAABox fullAABB; zeus::CAABox fullAABB;
for (const DNAPATH::PATH::Region& r : path.regions) { for (const auto& r : path.regions)
regionBoxes.emplace_back(r.aabb[0], r.aabb[1]); fullAABB.accumulateBounds(regionBoxes.emplace_back(r.aabb[0], r.aabb[1]));
fullAABB.accumulateBounds(regionBoxes.back());
}
/* Recursively split */ /* Recursively split */
BspNodeType dontCare; BspNodeType dontCare;
@ -426,4 +427,8 @@ void AROTBuilder::buildPath(DNAPATH::PATH& path) {
rootNode.pathWrite(path, fullAABB); 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);
} // namespace DataSpec } // namespace DataSpec

View File

@ -8,6 +8,7 @@
namespace DataSpec { namespace DataSpec {
namespace DNAPATH { namespace DNAPATH {
template <atUint32 PathVer>
struct PATH; struct PATH;
} }
@ -43,13 +44,15 @@ struct AROTBuilder {
void writeColNodes(uint8_t*& ptr, const zeus::CAABox& curAABB); void writeColNodes(uint8_t*& ptr, const zeus::CAABox& curAABB);
void pathCountNodesAndLookups(size_t& nodeCount, size_t& lookupCount); void pathCountNodesAndLookups(size_t& nodeCount, size_t& lookupCount);
void pathWrite(DNAPATH::PATH& path, const zeus::CAABox& curAABB); template <uint32_t PathVer>
void pathWrite(DNAPATH::PATH<PathVer>& path, const zeus::CAABox& curAABB);
} rootNode; } rootNode;
void build(std::vector<std::vector<uint8_t>>& secs, const zeus::CAABox& fullAabb, 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); 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); std::pair<std::unique_ptr<uint8_t[]>, uint32_t> buildCol(const ColMesh& mesh, BspNodeType& rootOut);
void buildPath(DNAPATH::PATH& path); template <uint32_t PathVer>
void buildPath(DNAPATH::PATH<PathVer>& path);
}; };
} // namespace DataSpec } // namespace DataSpec

View File

@ -13,71 +13,70 @@ static void OutputOctreeNode(hecl::blender::PyOutStream& os, int idx, const zeus
const zeus::CVector3f pos = aabb.center(); const zeus::CVector3f pos = aabb.center();
const zeus::CVector3f extent = aabb.extents(); const zeus::CVector3f extent = aabb.extents();
os.format( os.format(
"obj = bpy.data.objects.new('Leaf_%d', None)\n" "obj = bpy.data.objects.new('Leaf_%d', None)\n"
"bpy.context.scene.collection.objects.link(obj)\n" "bpy.context.scene.collection.objects.link(obj)\n"
"obj.location = (%f,%f,%f)\n" "obj.location = (%f,%f,%f)\n"
"obj.scale = (%f,%f,%f)\n" "obj.scale = (%f,%f,%f)\n"
"obj.empty_display_type = 'CUBE'\n" "obj.empty_display_type = 'CUBE'\n"
"obj.layers[1] = True\n" "obj.layers[1] = True\n"
"obj.layers[0] = False\n", idx, "obj.layers[0] = False\n",
pos.x(), pos.y(), pos.z(), extent.x(), extent.y(), extent.z()); idx, pos.x(), pos.y(), pos.z(), extent.x(), extent.y(), extent.z());
} }
#endif #endif
void PATH::sendToBlender(hecl::blender::Connection& conn, std::string_view entryName, const zeus::CMatrix4f* xf, template <atUint32 Ver>
const std::string& areaPath) { void PATH<Ver>::sendToBlender(hecl::blender::Connection& conn, std::string_view entryName, const zeus::CMatrix4f* xf,
const std::string& areaPath) {
/* Open Py Stream and read sections */ /* Open Py Stream and read sections */
hecl::blender::PyOutStream os = conn.beginPythonOut(true); hecl::blender::PyOutStream os = conn.beginPythonOut(true);
os << os << "import bpy\n"
"import bpy\n" "import bmesh\n"
"import bmesh\n" "from mathutils import Vector, Matrix\n"
"from mathutils import Vector, Matrix\n" "\n"
"\n" "bpy.types.Material.retro_path_idx_mask = bpy.props.IntProperty(name='Retro: Path Index Mask')\n"
"bpy.types.Material.retro_path_idx_mask = bpy.props.IntProperty(name='Retro: Path Index Mask')\n" "bpy.types.Material.retro_path_type_mask = bpy.props.IntProperty(name='Retro: Path Type Mask')\n"
"bpy.types.Material.retro_path_type_mask = bpy.props.IntProperty(name='Retro: Path Type Mask')\n" "\n"
"\n" "material_dict = {}\n"
"material_dict = {}\n" "material_index = []\n"
"material_index = []\n" "def make_ground_material(idxMask):\n"
"def make_ground_material(idxMask):\n" " mat = bpy.data.materials.new('Ground %X' % idxMask)\n"
" mat = bpy.data.materials.new('Ground %X' % idxMask)\n" " mat.diffuse_color = (0.8, 0.460, 0.194, 1.0)\n"
" mat.diffuse_color = (0.8, 0.460, 0.194, 1.0)\n" " return mat\n"
" return mat\n" "def make_flyer_material(idxMask):\n"
"def make_flyer_material(idxMask):\n" " mat = bpy.data.materials.new('Flyer %X' % idxMask)\n"
" mat = bpy.data.materials.new('Flyer %X' % idxMask)\n" " mat.diffuse_color = (0.016, 0.8, 0.8, 1.0)\n"
" mat.diffuse_color = (0.016, 0.8, 0.8, 1.0)\n" " return mat\n"
" return mat\n" "def make_swimmer_material(idxMask):\n"
"def make_swimmer_material(idxMask):\n" " mat = bpy.data.materials.new('Swimmer %X' % idxMask)\n"
" mat = bpy.data.materials.new('Swimmer %X' % idxMask)\n" " mat.diffuse_color = (0.074, 0.293, 0.8, 1.0)\n"
" mat.diffuse_color = (0.074, 0.293, 0.8, 1.0)\n" " return mat\n"
" return mat\n" "def select_material(meshIdxMask, meshTypeMask):\n"
"def select_material(meshIdxMask, meshTypeMask):\n" " key = (meshIdxMask, meshTypeMask)\n"
" key = (meshIdxMask, meshTypeMask)\n" " if key in material_index:\n"
" if key in material_index:\n" " return material_index.index(key)\n"
" return material_index.index(key)\n" " elif key in material_dict:\n"
" elif key in material_dict:\n" " material_index.append(key)\n"
" material_index.append(key)\n" " return len(material_index)-1\n"
" return len(material_index)-1\n" " else:\n"
" else:\n" " if meshTypeMask == 0x2:\n"
" if meshTypeMask == 0x2:\n" " mat = make_flyer_material(meshIdxMask)\n"
" mat = make_flyer_material(meshIdxMask)\n" " elif meshTypeMask == 0x4:\n"
" elif meshTypeMask == 0x4:\n" " mat = make_swimmer_material(meshIdxMask)\n"
" mat = make_swimmer_material(meshIdxMask)\n" " else:\n"
" else:\n" " mat = make_ground_material(meshIdxMask)\n"
" mat = make_ground_material(meshIdxMask)\n" " mat.retro_path_idx_mask = meshIdxMask\n"
" mat.retro_path_idx_mask = meshIdxMask\n" " mat.retro_path_type_mask = meshTypeMask\n"
" mat.retro_path_type_mask = meshTypeMask\n" " material_dict[key] = mat\n"
" material_dict[key] = mat\n" " material_index.append(key)\n"
" material_index.append(key)\n" " return len(material_index)-1\n"
" return len(material_index)-1\n" "\n";
"\n";
os.format(fmt("bpy.context.scene.name = '{}'\n"), entryName); os.format(fmt("bpy.context.scene.name = '{}'\n"), entryName);
os << os << "# Clear Scene\n"
"# Clear Scene\n" "if len(bpy.data.collections):\n"
"if len(bpy.data.collections):\n" " bpy.data.collections.remove(bpy.data.collections[0])\n"
" bpy.data.collections.remove(bpy.data.collections[0])\n" "\n"
"\n" "bm = bmesh.new()\n"
"bm = bmesh.new()\n" "height_lay = bm.faces.layers.float.new('Height')\n";
"height_lay = bm.faces.layers.float.new('Height')\n";
for (const Node& n : nodes) { for (const Node& n : nodes) {
zeus::simd_floats f(n.position.simd); zeus::simd_floats f(n.position.simd);
@ -91,16 +90,15 @@ void PATH::sendToBlender(hecl::blender::Connection& conn, std::string_view entry
for (atUint32 i = 0; i < r.nodeCount; ++i) for (atUint32 i = 0; i < r.nodeCount; ++i)
os.format(fmt("tri_verts.append(bm.verts[{}])\n"), r.nodeStart + i); os.format(fmt("tri_verts.append(bm.verts[{}])\n"), r.nodeStart + i);
os.format(fmt( os.format(fmt("face = bm.faces.get(tri_verts)\n"
"face = bm.faces.get(tri_verts)\n" "if face is None:\n"
"if face is None:\n" " face = bm.faces.new(tri_verts)\n"
" face = bm.faces.new(tri_verts)\n" " face.normal_flip()\n"
" face.normal_flip()\n" "face.material_index = select_material(0x{:04X}, 0x{:04X})\n"
"face.material_index = select_material(0x{:04X}, 0x{:04X})\n" "face.smooth = False\n"
"face.smooth = False\n" "face[height_lay] = {}\n"
"face[height_lay] = {}\n" "\n"),
"\n"), r.meshIndexMask, r.meshTypeMask, r.height);
r.meshIndexMask, r.meshTypeMask, r.height);
#if 0 #if 0
const zeus::CVector3f center = xf->multiplyOneOverW(r.centroid); const zeus::CVector3f center = xf->multiplyOneOverW(r.centroid);
@ -152,15 +150,14 @@ void PATH::sendToBlender(hecl::blender::Connection& conn, std::string_view entry
zeus::simd_floats xfMtxF[4]; zeus::simd_floats xfMtxF[4];
for (int i = 0; i < 4; ++i) for (int i = 0; i < 4; ++i)
w.m[i].mSimd.copy_to(xfMtxF[i]); w.m[i].mSimd.copy_to(xfMtxF[i]);
os.format(fmt( os.format(fmt("mtx = Matrix((({},{},{},{}),({},{},{},{}),({},{},{},{}),(0.0,0.0,0.0,1.0)))\n"
"mtx = Matrix((({},{},{},{}),({},{},{},{}),({},{},{},{}),(0.0,0.0,0.0,1.0)))\n" "mtxd = mtx.decompose()\n"
"mtxd = mtx.decompose()\n" "path_mesh_obj.rotation_mode = 'QUATERNION'\n"
"path_mesh_obj.rotation_mode = 'QUATERNION'\n" "path_mesh_obj.location = mtxd[0]\n"
"path_mesh_obj.location = mtxd[0]\n" "path_mesh_obj.rotation_quaternion = mtxd[1]\n"
"path_mesh_obj.rotation_quaternion = mtxd[1]\n" "path_mesh_obj.scale = mtxd[2]\n"),
"path_mesh_obj.scale = mtxd[2]\n"), xfMtxF[0][0], xfMtxF[1][0], xfMtxF[2][0], xfMtxF[3][0], xfMtxF[0][1], xfMtxF[1][1], xfMtxF[2][1],
xfMtxF[0][0], xfMtxF[1][0], xfMtxF[2][0], xfMtxF[3][0], xfMtxF[0][1], xfMtxF[1][1], xfMtxF[2][1], xfMtxF[3][1], xfMtxF[3][1], xfMtxF[0][2], xfMtxF[1][2], xfMtxF[2][2], xfMtxF[3][2]);
xfMtxF[0][2], xfMtxF[1][2], xfMtxF[2][2], xfMtxF[3][2]);
} }
#if DUMP_OCTREE #if DUMP_OCTREE
@ -179,8 +176,9 @@ void PATH::sendToBlender(hecl::blender::Connection& conn, std::string_view entry
os.close(); os.close();
} }
bool PATH::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPath, template <atUint32 Ver>
const PathMesh& mesh, hecl::blender::Token& btok) { bool PATH<Ver>::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()); athena::io::MemoryReader r(mesh.data.data(), mesh.data.size());
PATH path; PATH path;
path.read(r); path.read(r);
@ -219,4 +217,8 @@ bool PATH::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat
return true; return true;
} }
} // namespace DataSpec::DNAMP1 template struct PATH<4>;
template struct PATH<6>;
template struct PATH<7>;
} // namespace DataSpec::DNAPATH

View File

@ -4,7 +4,32 @@
#include "DataSpec/DNACommon/PAK.hpp" #include "DataSpec/DNACommon/PAK.hpp"
namespace DataSpec::DNAPATH { namespace DataSpec::DNAPATH {
struct PATH : BigDNA { template <atUint32 Ver>
struct RegionPointers {};
template <>
struct RegionPointers<4> : BigDNA {
AT_DECL_DNA
Value<atUint32> regionIdxPtr;
};
template <>
struct RegionPointers<6> : BigDNA {
AT_DECL_DNA
Value<atUint32> unk0;
Value<atUint32> unk1;
Value<atUint32> unk2;
Value<atUint32> regionIdxPtr;
};
template <>
struct RegionPointers<7> : BigDNA {
AT_DECL_DNA
Value<atUint32> unk0;
Value<atUint32> unk1;
Value<atUint32> unk2;
Value<atUint32> regionIdxPtr;
};
template <atUint32 Ver>
struct AT_SPECIALIZE_PARMS(4, 6, 7) PATH : BigDNA {
using PathMesh = hecl::blender::PathMesh; using PathMesh = hecl::blender::PathMesh;
AT_DECL_DNA AT_DECL_DNA
@ -41,7 +66,7 @@ struct PATH : BigDNA {
Value<atUint32> regionIdx; Value<atUint32> regionIdx;
Value<atVec3f> centroid; Value<atVec3f> centroid;
Value<atVec3f> aabb[2]; Value<atVec3f> aabb[2];
Value<atUint32> regionIdxPtr; Value<RegionPointers<Ver>> pointers;
}; };
Value<atUint32> regionCount; Value<atUint32> regionCount;
Vector<Region, AT_DNA_COUNT(regionCount)> regions; Vector<Region, AT_DNA_COUNT(regionCount)> regions;

View File

@ -3,7 +3,7 @@
#include "DataSpec/DNAMP1/DNAMP1.hpp" #include "DataSpec/DNAMP1/DNAMP1.hpp"
namespace DataSpec::DNAMP1 { namespace DataSpec::DNAMP1 {
struct PATH : DNAPATH::PATH { struct PATH : DNAPATH::PATH<4> {
static bool Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl::ProjectPath& outPath, 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, PAKRouter<PAKBridge>& pakRouter, const PAK::Entry& entry, bool force, hecl::blender::Token& btok,
std::function<void(const hecl::SystemChar*)> fileChanged); std::function<void(const hecl::SystemChar*)> fileChanged);

View File

@ -203,7 +203,6 @@ void PAKBridge::addMAPATransforms(PAKRouter<PAKBridge>& pakRouter,
fmt::format(fmt(_SYS_STR("!name_{}.yaml")), mlvl.worldNameId)); fmt::format(fmt(_SYS_STR("!name_{}.yaml")), mlvl.worldNameId));
for (const MLVL::Area& area : mlvl.areas) { for (const MLVL::Area& area : mlvl.areas) {
#if 0
{ {
/* Get PATH transform */ /* Get PATH transform */
const nod::Node* areaNode; const nod::Node* areaNode;
@ -214,7 +213,6 @@ void PAKBridge::addMAPATransforms(PAKRouter<PAKBridge>& pakRouter,
addTo[pathId] = zeus::CMatrix4f(area.transformMtx[0], area.transformMtx[1], area.transformMtx[2], BottomRow) addTo[pathId] = zeus::CMatrix4f(area.transformMtx[0], area.transformMtx[1], area.transformMtx[2], BottomRow)
.transposed(); .transposed();
} }
#endif
hecl::ProjectPath areaDirPath = pakRouter.getWorking(area.areaMREAId).getParentPath(); hecl::ProjectPath areaDirPath = pakRouter.getWorking(area.areaMREAId).getParentPath();
if (area.areaNameId.isValid()) if (area.areaNameId.isValid())
pathOverrides[area.areaNameId] = hecl::ProjectPath(areaDirPath, pathOverrides[area.areaNameId] = hecl::ProjectPath(areaDirPath,
@ -272,8 +270,8 @@ ResExtractor<PAKBridge> PAKBridge::LookupExtractor(const nod::Node& pakNode, con
return {MAPA::Extract, {_SYS_STR(".blend")}, 4}; return {MAPA::Extract, {_SYS_STR(".blend")}, 4};
case SBIG('MAPU'): case SBIG('MAPU'):
return {MAPU::Extract, {_SYS_STR(".blend")}, 5}; return {MAPU::Extract, {_SYS_STR(".blend")}, 5};
// case SBIG('PATH'): case SBIG('PATH'):
// return {PATH::Extract, {_SYS_STR(".blend")}, 5}; return {PATH::Extract, {_SYS_STR(".blend")}, 5};
case SBIG('FSM2'): case SBIG('FSM2'):
return {DNAFSM2::ExtractFSM2<UniqueID32>, {_SYS_STR(".yaml")}}; return {DNAFSM2::ExtractFSM2<UniqueID32>, {_SYS_STR(".yaml")}};
case SBIG('FONT'): case SBIG('FONT'):

View File

@ -98,11 +98,11 @@ void MREA::StreamReader::seek(atInt64 diff, athena::SeekOrigin whence) {
if (newAccum > target) if (newAccum > target)
break; break;
dAccum = newAccum; dAccum = newAccum;
++bIdx;
if (info.compSize) if (info.compSize)
cAccum += ROUND_UP_32(info.compSize); cAccum += ROUND_UP_32(info.compSize);
else else
cAccum += info.decompSize; cAccum += info.decompSize;
++bIdx;
} }
/* Seek source if needed */ /* Seek source if needed */
@ -116,6 +116,41 @@ void MREA::StreamReader::seek(atInt64 diff, athena::SeekOrigin whence) {
m_posInBlk = target - dAccum; m_posInBlk = target - dAccum;
} }
void MREA::StreamReader::seekToSection(atUint32 sec, const std::vector<atUint32>& secSizes) {
/* Determine which block contains section */
atUint32 sAccum = 0;
atUint32 dAccum = 0;
atUint32 cAccum = 0;
atUint32 bIdx = 0;
for (BlockInfo& info : m_blockInfos) {
atUint32 newSAccum = sAccum + info.secCount;
if (newSAccum > sec)
break;
sAccum = newSAccum;
dAccum += info.decompSize;
if (info.compSize)
cAccum += ROUND_UP_32(info.compSize);
else
cAccum += info.decompSize;
++bIdx;
}
/* Seek source if needed */
if (bIdx != m_nextBlk - 1) {
m_source.seek(m_blkBase + cAccum, athena::SeekOrigin::Begin);
m_nextBlk = bIdx;
nextBlock();
}
/* Seek within block */
atUint32 target = dAccum;
while (sAccum != sec)
target += secSizes[sAccum++];
m_pos = target;
m_posInBlk = target - dAccum;
}
atUint64 MREA::StreamReader::readUBytesToBuf(void* buf, atUint64 len) { atUint64 MREA::StreamReader::readUBytesToBuf(void* buf, atUint64 len) {
atUint8* bufCur = reinterpret_cast<atUint8*>(buf); atUint8* bufCur = reinterpret_cast<atUint8*>(buf);
atUint64 rem = len; atUint64 rem = len;
@ -302,15 +337,12 @@ UniqueID32 MREA::GetPATHId(PAKEntryReadStream& rs) {
head.read(rs); head.read(rs);
rs.seekAlign32(); rs.seekAlign32();
/* MREA decompression stream */
StreamReader drs(rs, head.compressedBlockCount);
/* Skip to PATH */ /* Skip to PATH */
atUint32 curSec = 0; drs.seekToSection(head.pathSecIdx, head.secSizes);
atUint64 secStart = rs.position(); return {drs};
while (curSec != head.pathSecIdx)
secStart += head.secSizes[curSec++];
if (!head.secSizes[curSec])
return {};
rs.seek(secStart, athena::SeekOrigin::Begin);
return {rs};
} }
} // namespace DNAMP2 } // namespace DNAMP2

View File

@ -43,6 +43,7 @@ struct MREA {
public: public:
StreamReader(athena::io::IStreamReader& source, atUint32 blkCount); StreamReader(athena::io::IStreamReader& source, atUint32 blkCount);
void seek(atInt64 diff, athena::SeekOrigin whence) override; void seek(atInt64 diff, athena::SeekOrigin whence) override;
void seekToSection(atUint32 sec, const std::vector<atUint32>& secSizes);
atUint64 position() const override { return m_pos; } atUint64 position() const override { return m_pos; }
atUint64 length() const override { return m_totalDecompLen; } atUint64 length() const override { return m_totalDecompLen; }
atUint64 readUBytesToBuf(void* buf, atUint64 len) override; atUint64 readUBytesToBuf(void* buf, atUint64 len) override;

View File

@ -3,7 +3,7 @@
#include "DataSpec/DNAMP2/DNAMP2.hpp" #include "DataSpec/DNAMP2/DNAMP2.hpp"
namespace DataSpec::DNAMP2 { namespace DataSpec::DNAMP2 {
struct PATH : DNAPATH::PATH { struct PATH : DNAPATH::PATH<6> {
static bool Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl::ProjectPath& outPath, 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, PAKRouter<PAKBridge>& pakRouter, const PAK::Entry& entry, bool force, hecl::blender::Token& btok,
std::function<void(const hecl::SystemChar*)> fileChanged); std::function<void(const hecl::SystemChar*)> fileChanged);

View File

@ -661,7 +661,7 @@ struct SpecMP1 : SpecBase {
hecl::blender::Token& btok, FCookProgress progress) override { hecl::blender::Token& btok, FCookProgress progress) override {
PathMesh mesh = ds.compilePathMesh(); PathMesh mesh = ds.compilePathMesh();
ds.close(); ds.close();
DNAPATH::PATH::Cook(out, in, mesh, btok); DNAPATH::PATH<4>::Cook(out, in, mesh, btok);
} }
void cookActor(const hecl::ProjectPath& out, const hecl::ProjectPath& in, BlendStream& ds, bool fast, void cookActor(const hecl::ProjectPath& out, const hecl::ProjectPath& in, BlendStream& ds, bool fast,

View File

@ -291,7 +291,7 @@ struct SpecMP2 : SpecBase {
hecl::blender::Token& btok, FCookProgress progress) override { hecl::blender::Token& btok, FCookProgress progress) override {
PathMesh mesh = ds.compilePathMesh(); PathMesh mesh = ds.compilePathMesh();
ds.close(); ds.close();
DNAPATH::PATH::Cook(out, in, mesh, btok); DNAPATH::PATH<6>::Cook(out, in, mesh, btok);
} }
void cookActor(const hecl::ProjectPath& out, const hecl::ProjectPath& in, BlendStream& ds, bool fast, void cookActor(const hecl::ProjectPath& out, const hecl::ProjectPath& in, BlendStream& ds, bool fast,

2
hecl

@ -1 +1 @@
Subproject commit 138328b8f617071cbe9457f04e9cbb31cef1975e Subproject commit 191ffdc8e06c20e8831e383be5431789d9d4b8fb