mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-08 16:24:55 +00:00
Initial PATH cooking support
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "AROTBuilder.hpp"
|
||||
#include "hecl/Blender/Connection.hpp"
|
||||
#include "../DNAMP1/PATH.hpp"
|
||||
|
||||
namespace DataSpec
|
||||
{
|
||||
@@ -287,6 +288,60 @@ void AROTBuilder::Node::writeColNodes(uint8_t*& ptr, const zeus::CAABox& curAABB
|
||||
}
|
||||
}
|
||||
|
||||
void AROTBuilder::Node::pathCountNodesAndLookups(size_t& nodeCount, size_t& lookupCount)
|
||||
{
|
||||
++nodeCount;
|
||||
if (childNodes.empty())
|
||||
{
|
||||
lookupCount += childIndices.size();
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i=0 ; i<8 ; ++i)
|
||||
childNodes[i].pathCountNodesAndLookups(nodeCount, lookupCount);
|
||||
}
|
||||
}
|
||||
|
||||
void AROTBuilder::Node::pathWrite(DNAMP1::PATH& path, const zeus::CAABox& curAABB)
|
||||
{
|
||||
if (childNodes.empty())
|
||||
{
|
||||
path.octree.emplace_back();
|
||||
DNAMP1::PATH::OctreeNode& n = path.octree.back();
|
||||
n.isLeaf = 1;
|
||||
n.aabb[0] = curAABB.min;
|
||||
n.aabb[1] = curAABB.max;
|
||||
n.centroid = curAABB.center();
|
||||
for (int i=0 ; i<8 ; ++i)
|
||||
n.children[i] = 0xffffffff;
|
||||
n.regionCount = childIndices.size();
|
||||
n.regionStart = path.octreeRegionLookup.size();
|
||||
for (int r : childIndices)
|
||||
path.octreeRegionLookup.push_back(r);
|
||||
}
|
||||
else
|
||||
{
|
||||
atUint32 children[8];
|
||||
for (int i=0 ; i<8 ; ++i)
|
||||
{
|
||||
/* Head recursion (first node will be a leaf) */
|
||||
children[i] = path.octree.size();
|
||||
childNodes[i].pathWrite(path, SplitAABB(curAABB, i));
|
||||
}
|
||||
|
||||
path.octree.emplace_back();
|
||||
DNAMP1::PATH::OctreeNode& n = path.octree.back();
|
||||
n.isLeaf = 0;
|
||||
n.aabb[0] = curAABB.min;
|
||||
n.aabb[1] = curAABB.max;
|
||||
n.centroid = curAABB.center();
|
||||
for (int i=0 ; i<8 ; ++i)
|
||||
n.children[i] = children[i];
|
||||
n.regionCount = 0;
|
||||
n.regionStart = 0;
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
@@ -391,4 +446,31 @@ std::pair<std::unique_ptr<uint8_t[]>, uint32_t> AROTBuilder::buildCol(const ColM
|
||||
return {std::move(ret), totalSize};
|
||||
}
|
||||
|
||||
void AROTBuilder::buildPath(DNAMP1::PATH& path)
|
||||
{
|
||||
/* Accumulate total AABB and gather region boxes */
|
||||
std::vector<zeus::CAABox> regionBoxes;
|
||||
regionBoxes.reserve(path.regions.size());
|
||||
zeus::CAABox fullAABB;
|
||||
for (const DNAMP1::PATH::Region& r : path.regions)
|
||||
{
|
||||
regionBoxes.emplace_back(r.aabb[0], r.aabb[1]);
|
||||
fullAABB.accumulateBounds(regionBoxes.back());
|
||||
}
|
||||
|
||||
/* Recursively split */
|
||||
BspNodeType dontCare;
|
||||
rootNode.addChild(0, 4, regionBoxes, fullAABB, dontCare);
|
||||
|
||||
/* Write out */
|
||||
size_t nodeCount = 0;
|
||||
size_t lookupCount = 0;
|
||||
rootNode.pathCountNodesAndLookups(nodeCount, lookupCount);
|
||||
path.octreeNodeCount = nodeCount;
|
||||
path.octree.reserve(nodeCount);
|
||||
path.octreeRegionLookupCount = lookupCount;
|
||||
path.octreeRegionLookup.reserve(lookupCount);
|
||||
rootNode.pathWrite(path, fullAABB);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,6 +9,10 @@
|
||||
|
||||
namespace DataSpec
|
||||
{
|
||||
namespace DNAMP1
|
||||
{
|
||||
struct PATH;
|
||||
}
|
||||
|
||||
struct AROTBuilder
|
||||
{
|
||||
@@ -40,11 +44,15 @@ struct AROTBuilder
|
||||
|
||||
void colSize(size_t& totalSz);
|
||||
void writeColNodes(uint8_t*& ptr, const zeus::CAABox& curAABB);
|
||||
|
||||
void pathCountNodesAndLookups(size_t& nodeCount, size_t& lookupCount);
|
||||
void pathWrite(DNAMP1::PATH& 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);
|
||||
void buildPath(DNAMP1::PATH& path);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ struct Header : BigDNA
|
||||
Value<atVec3f> aabbMax;
|
||||
Value<atUint32> secCount;
|
||||
Value<atUint32> matSetCount;
|
||||
Vector<atUint32, DNA_COUNT(secCount)> secSizes;
|
||||
Vector<atUint32, AT_DNA_COUNT(secCount)> secSizes;
|
||||
Align<32> align;
|
||||
};
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ struct AT_SPECIALIZE_PARMS(DataSpec::UniqueID32, DataSpec::UniqueID64) DGRP : Bi
|
||||
Value<IDType> id;
|
||||
};
|
||||
|
||||
Vector<ObjectTag, DNA_COUNT(dependCount)> depends;
|
||||
Vector<ObjectTag, AT_DNA_COUNT(dependCount)> depends;
|
||||
};
|
||||
|
||||
template <class IDType>
|
||||
|
||||
@@ -17,7 +17,7 @@ struct EGMC : public BigDNA
|
||||
Value<atUint32> instanceId;
|
||||
};
|
||||
|
||||
Vector<Object, DNA_COUNT(count)> objects;
|
||||
Vector<Object, AT_DNA_COUNT(count)> objects;
|
||||
};
|
||||
}
|
||||
#endif // _DNACOMMON_EGMC_HPP_
|
||||
|
||||
@@ -109,7 +109,7 @@ struct AT_SPECIALIZE_PARMS(DataSpec::UniqueID32, DataSpec::UniqueID64) FONT : Bi
|
||||
Value<atUint32> glyphCount;
|
||||
std::vector<std::unique_ptr<IGlyph>> glyphs;
|
||||
Value<atUint32> kerningInfoCount;
|
||||
Vector<KerningInfo, DNA_COUNT(kerningInfoCount)> kerningInfo;
|
||||
Vector<KerningInfo, AT_DNA_COUNT(kerningInfoCount)> kerningInfo;
|
||||
|
||||
void gatherDependencies(std::vector<hecl::ProjectPath>& pathsOut) const
|
||||
{
|
||||
|
||||
@@ -42,7 +42,7 @@ struct AT_SPECIALIZE_PARMS(DataSpec::UniqueID32, DataSpec::UniqueID64) FSM2 : Bi
|
||||
AT_DECL_DNA_YAML
|
||||
String<-1> name;
|
||||
Value<atUint32> unknownCount;
|
||||
Vector<CommonStruct, DNA_COUNT(unknownCount)> unknown;
|
||||
Vector<CommonStruct, AT_DNA_COUNT(unknownCount)> unknown;
|
||||
};
|
||||
|
||||
struct Unknown1 : BigDNA
|
||||
@@ -51,7 +51,7 @@ struct AT_SPECIALIZE_PARMS(DataSpec::UniqueID32, DataSpec::UniqueID64) FSM2 : Bi
|
||||
String<-1> name;
|
||||
Value<float> unknown1;
|
||||
Value<atUint32> unknown2Count;
|
||||
Vector<CommonStruct, DNA_COUNT(unknown2Count)> unknown2;
|
||||
Vector<CommonStruct, AT_DNA_COUNT(unknown2Count)> unknown2;
|
||||
Value<atUint8> unknown3;
|
||||
};
|
||||
|
||||
@@ -60,7 +60,7 @@ struct AT_SPECIALIZE_PARMS(DataSpec::UniqueID32, DataSpec::UniqueID64) FSM2 : Bi
|
||||
AT_DECL_DNA_YAML
|
||||
String<-1> name;
|
||||
Value<atUint32> unknownCount;
|
||||
Vector<CommonStruct, DNA_COUNT(unknownCount)> unknown;
|
||||
Vector<CommonStruct, AT_DNA_COUNT(unknownCount)> unknown;
|
||||
};
|
||||
|
||||
struct Unknown3 : BigDNA
|
||||
@@ -68,14 +68,14 @@ struct AT_SPECIALIZE_PARMS(DataSpec::UniqueID32, DataSpec::UniqueID64) FSM2 : Bi
|
||||
AT_DECL_DNA_YAML
|
||||
String<-1> name;
|
||||
Value<atUint32> unknownCount;
|
||||
Vector<CommonStruct, DNA_COUNT(unknownCount)> unknown;
|
||||
Vector<CommonStruct, AT_DNA_COUNT(unknownCount)> unknown;
|
||||
Value<IDType> fsmId;
|
||||
};
|
||||
|
||||
Vector<State, DNA_COUNT(stateCount)> states;
|
||||
Vector<Unknown1, DNA_COUNT(unknown1Count)> unknown1;
|
||||
Vector<Unknown2, DNA_COUNT(unknown2Count)> unknown2;
|
||||
Vector<Unknown3, DNA_COUNT(unknown3Count)> unknown3;
|
||||
Vector<State, AT_DNA_COUNT(stateCount)> states;
|
||||
Vector<Unknown1, AT_DNA_COUNT(unknown1Count)> unknown1;
|
||||
Vector<Unknown2, AT_DNA_COUNT(unknown2Count)> unknown2;
|
||||
Vector<Unknown3, AT_DNA_COUNT(unknown3Count)> unknown3;
|
||||
};
|
||||
|
||||
struct FSMV2 : IFSM
|
||||
@@ -95,7 +95,7 @@ struct AT_SPECIALIZE_PARMS(DataSpec::UniqueID32, DataSpec::UniqueID64) FSM2 : Bi
|
||||
Value<atUint32> unknown3;
|
||||
Value<atUint32> unknown4;
|
||||
Value<atUint32> unknown5Count;
|
||||
Vector<CommonStruct, DNA_COUNT(unknown5Count)> unknown5;
|
||||
Vector<CommonStruct, AT_DNA_COUNT(unknown5Count)> unknown5;
|
||||
};
|
||||
|
||||
struct Unknown1 : BigDNA
|
||||
@@ -108,7 +108,7 @@ struct AT_SPECIALIZE_PARMS(DataSpec::UniqueID32, DataSpec::UniqueID64) FSM2 : Bi
|
||||
Value<atUint32> unknown4;
|
||||
Value<float> unknown5;
|
||||
Value<atUint32> unknown6Count;
|
||||
Vector<CommonStruct, DNA_COUNT(unknown6Count)> unknown6;
|
||||
Vector<CommonStruct, AT_DNA_COUNT(unknown6Count)> unknown6;
|
||||
Value<atUint8> unknown7;
|
||||
};
|
||||
|
||||
@@ -121,7 +121,7 @@ struct AT_SPECIALIZE_PARMS(DataSpec::UniqueID32, DataSpec::UniqueID64) FSM2 : Bi
|
||||
Value<atUint32> unknown3;
|
||||
Value<atUint32> unknown4;
|
||||
Value<atUint32> unknown5Count;
|
||||
Vector<CommonStruct, DNA_COUNT(unknown5Count)> unknown5;
|
||||
Vector<CommonStruct, AT_DNA_COUNT(unknown5Count)> unknown5;
|
||||
};
|
||||
|
||||
struct Unknown3 : BigDNA
|
||||
@@ -133,14 +133,14 @@ struct AT_SPECIALIZE_PARMS(DataSpec::UniqueID32, DataSpec::UniqueID64) FSM2 : Bi
|
||||
Value<atUint32> unknown3;
|
||||
Value<atUint32> unknown4;
|
||||
Value<atUint32> unknown5Count;
|
||||
Vector<CommonStruct, DNA_COUNT(unknown5Count)> unknown5;
|
||||
Vector<CommonStruct, AT_DNA_COUNT(unknown5Count)> unknown5;
|
||||
Value<IDType> fsmId;
|
||||
};
|
||||
|
||||
Vector<State, DNA_COUNT(stateCount)> states;
|
||||
Vector<Unknown1, DNA_COUNT(unknown1Count)> unknown1;
|
||||
Vector<Unknown2, DNA_COUNT(unknown2Count)> unknown2;
|
||||
Vector<Unknown3, DNA_COUNT(unknown3Count)> unknown3;
|
||||
Vector<State, AT_DNA_COUNT(stateCount)> states;
|
||||
Vector<Unknown1, AT_DNA_COUNT(unknown1Count)> unknown1;
|
||||
Vector<Unknown2, AT_DNA_COUNT(unknown2Count)> unknown2;
|
||||
Vector<Unknown3, AT_DNA_COUNT(unknown3Count)> unknown3;
|
||||
};
|
||||
|
||||
std::unique_ptr<IFSM> detail;
|
||||
|
||||
@@ -72,7 +72,7 @@ struct MAPA : BigDNA
|
||||
Value<atUint32> surfCount = 0;
|
||||
Value<atUint32> internalNameLength = 0;
|
||||
Value<atUint32> unknown7 = 0;
|
||||
String<DNA_COUNT(internalNameLength)> internalName;
|
||||
String<AT_DNA_COUNT(internalNameLength)> internalName;
|
||||
atUint32 visMode() const { return mapVisMode; }
|
||||
atUint32 mappableObjectCount() const { return moCount;}
|
||||
atUint32 vertexCount() const { return vtxCount; }
|
||||
@@ -131,14 +131,14 @@ struct MAPA : BigDNA
|
||||
Value<Type> type;
|
||||
Value<atUint32> visMode;
|
||||
Value<atUint32> sclyId;
|
||||
Buffer<DNA_COUNT(0x10)> unknownHash;
|
||||
Buffer<AT_DNA_COUNT(0x10)> unknownHash;
|
||||
Value<atInt32> seek1 = -1;
|
||||
Value<atVec4f> transformMtx[3];
|
||||
Value<atInt32> seek2[4] = {-1, -1, -1, -1};
|
||||
};
|
||||
|
||||
std::vector<std::unique_ptr<IMappableObject>> mappableObjects;
|
||||
Vector<atVec3f, DNA_COUNT(header->vertexCount())> vertices;
|
||||
Vector<atVec3f, AT_DNA_COUNT(header->vertexCount())> vertices;
|
||||
|
||||
struct SurfaceHeader : BigDNA
|
||||
{
|
||||
@@ -149,7 +149,7 @@ struct MAPA : BigDNA
|
||||
Value<atUint32> edgeOff;
|
||||
};
|
||||
|
||||
Vector<SurfaceHeader, DNA_COUNT(header->surfaceCount())> surfaceHeaders;
|
||||
Vector<SurfaceHeader, AT_DNA_COUNT(header->surfaceCount())> surfaceHeaders;
|
||||
|
||||
struct Surface : BigDNA
|
||||
{
|
||||
@@ -160,22 +160,22 @@ struct MAPA : BigDNA
|
||||
AT_DECL_DNA
|
||||
Value<atUint32> type;
|
||||
Value<atUint32> indexCount;
|
||||
Vector<atUint8, DNA_COUNT(indexCount)> indices;
|
||||
Vector<atUint8, AT_DNA_COUNT(indexCount)> indices;
|
||||
Align<4> align;
|
||||
};
|
||||
Vector<Primitive, DNA_COUNT(primitiveCount)> primitives;
|
||||
Vector<Primitive, AT_DNA_COUNT(primitiveCount)> primitives;
|
||||
Value<atUint32> borderCount;
|
||||
struct Border : BigDNA
|
||||
{
|
||||
AT_DECL_DNA
|
||||
Value<atUint32> indexCount;
|
||||
Vector<atUint8, DNA_COUNT(indexCount)> indices;
|
||||
Vector<atUint8, AT_DNA_COUNT(indexCount)> indices;
|
||||
Align<4> align;
|
||||
};
|
||||
Vector<Border, DNA_COUNT(borderCount)> borders;
|
||||
Vector<Border, AT_DNA_COUNT(borderCount)> borders;
|
||||
};
|
||||
|
||||
Vector<Surface, DNA_COUNT(header->surfaceCount())> surfaces;
|
||||
Vector<Surface, AT_DNA_COUNT(header->surfaceCount())> surfaces;
|
||||
};
|
||||
|
||||
template <typename PAKRouter>
|
||||
|
||||
@@ -24,10 +24,10 @@ struct MAPU : BigDNA
|
||||
UniqueID32 mlvl;
|
||||
Transform transform;
|
||||
Value<uint32_t> hexCount;
|
||||
Vector<Transform, DNA_COUNT(hexCount)> hexTransforms;
|
||||
Vector<Transform, AT_DNA_COUNT(hexCount)> hexTransforms;
|
||||
DNAColor hexColor;
|
||||
};
|
||||
Vector<World, DNA_COUNT(worldCount)> worlds;
|
||||
Vector<World, AT_DNA_COUNT(worldCount)> worlds;
|
||||
|
||||
static bool Cook(const hecl::blender::MapUniverse& mapu, const hecl::ProjectPath& out);
|
||||
};
|
||||
|
||||
@@ -129,7 +129,7 @@ struct REKeyframeEmitter : IRealElement
|
||||
Value<atUint32> loopEnd;
|
||||
Value<atUint32> loopStart;
|
||||
Value<atUint32> count;
|
||||
Vector<float, DNA_COUNT(count)> keys;
|
||||
Vector<float, AT_DNA_COUNT(count)> keys;
|
||||
const char* ClassID() const {return percentageTween ? "KEYP" : "KEYE";}
|
||||
};
|
||||
|
||||
@@ -339,7 +339,7 @@ struct IEKeyframeEmitter : IIntElement
|
||||
Value<atUint32> loopEnd;
|
||||
Value<atUint32> loopStart;
|
||||
Value<atUint32> count;
|
||||
Vector<atUint32, DNA_COUNT(count)> keys;
|
||||
Vector<atUint32, AT_DNA_COUNT(count)> keys;
|
||||
const char* ClassID() const {return percentageTween ? "KEYP" : "KEYE";}
|
||||
};
|
||||
|
||||
@@ -544,7 +544,7 @@ struct VEKeyframeEmitter : IVectorElement
|
||||
Value<atUint32> loopEnd;
|
||||
Value<atUint32> loopStart;
|
||||
Value<atUint32> count;
|
||||
Vector<atVec3f, DNA_COUNT(count)> keys;
|
||||
Vector<atVec3f, AT_DNA_COUNT(count)> keys;
|
||||
const char* ClassID() const {return percentageTween ? "KEYP" : "KEYE";}
|
||||
};
|
||||
|
||||
@@ -620,7 +620,7 @@ struct CEKeyframeEmitter : IColorElement
|
||||
Value<atUint32> loopEnd;
|
||||
Value<atUint32> loopStart;
|
||||
Value<atUint32> count;
|
||||
Vector<atVec4f, DNA_COUNT(count)> keys;
|
||||
Vector<atVec4f, AT_DNA_COUNT(count)> keys;
|
||||
const char* ClassID() const {return percentageTween ? "KEYP" : "KEYE";}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user