2018-10-07 03:42:33 +00:00
|
|
|
#pragma once
|
2017-05-22 11:24:24 +00:00
|
|
|
|
2018-10-14 20:16:21 +00:00
|
|
|
#include "athena/Types.hpp"
|
2018-06-29 20:21:36 +00:00
|
|
|
#include "DataSpec/DNACommon/DeafBabe.hpp"
|
|
|
|
#include "DataSpec/DNACommon/PAK.hpp"
|
|
|
|
#include "DataSpec/DNACommon/OBBTreeBuilder.hpp"
|
2017-05-22 11:24:24 +00:00
|
|
|
#include "DNAMP1.hpp"
|
|
|
|
#include "DeafBabe.hpp"
|
|
|
|
|
2017-10-17 06:05:23 +00:00
|
|
|
#define DCLN_DUMP_OBB 0
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
namespace DataSpec::DNAMP1 {
|
2017-05-22 11:24:24 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
struct DCLN : BigDNA {
|
|
|
|
using Mesh = hecl::blender::ColMesh;
|
2017-10-17 05:51:53 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
AT_DECL_DNA
|
|
|
|
Value<atUint32> colCount;
|
|
|
|
struct Collision : BigDNA {
|
|
|
|
using Material = DeafBabe::Material;
|
|
|
|
using Edge = DeafBabe::Edge;
|
|
|
|
using Triangle = DeafBabe::Triangle;
|
2017-05-22 11:24:24 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
AT_DECL_DNA
|
|
|
|
Value<atUint32> magic;
|
|
|
|
Value<atUint32> version;
|
|
|
|
Value<atUint32> memSize;
|
|
|
|
Value<atUint32> materialCount;
|
|
|
|
Vector<Material, AT_DNA_COUNT(materialCount)> materials;
|
|
|
|
Value<atUint32> vertMatsCount;
|
|
|
|
Vector<atUint8, AT_DNA_COUNT(vertMatsCount)> vertMats;
|
|
|
|
Value<atUint32> edgeMatsCount;
|
|
|
|
Vector<atUint8, AT_DNA_COUNT(edgeMatsCount)> edgeMats;
|
|
|
|
Value<atUint32> triMatsCount;
|
|
|
|
Vector<atUint8, AT_DNA_COUNT(triMatsCount)> triMats;
|
|
|
|
Value<atUint32> edgeVertsCount;
|
|
|
|
Vector<Edge, AT_DNA_COUNT(edgeVertsCount)> edgeVertConnections;
|
|
|
|
Value<atUint32> triangleEdgesCount;
|
|
|
|
Vector<Triangle, AT_DNA_COUNT(triangleEdgesCount / 3)> triangleEdgeConnections;
|
|
|
|
Value<atUint32> vertCount;
|
|
|
|
Vector<atVec3f, AT_DNA_COUNT(vertCount)> verts;
|
|
|
|
|
|
|
|
struct Node : BigDNA {
|
|
|
|
AT_DECL_EXPLICIT_DNA
|
|
|
|
|
|
|
|
struct LeafData : BigDNA {
|
2018-02-22 07:24:51 +00:00
|
|
|
AT_DECL_DNA
|
2018-12-08 05:30:43 +00:00
|
|
|
Value<atUint32> triangleIndexCount;
|
|
|
|
Vector<atUint16, AT_DNA_COUNT(triangleIndexCount)> triangleIndices;
|
|
|
|
size_t getMemoryUsage() const { return (((triangleIndices.size() * 2) + 16) + 3) & ~3; }
|
|
|
|
};
|
|
|
|
|
|
|
|
Value<atVec4f> xf[3];
|
|
|
|
Value<atVec3f> halfExtent;
|
|
|
|
Value<bool> isLeaf;
|
|
|
|
std::unique_ptr<LeafData> leafData;
|
|
|
|
std::unique_ptr<Node> left;
|
|
|
|
std::unique_ptr<Node> right;
|
|
|
|
|
|
|
|
size_t getMemoryUsage() const {
|
|
|
|
size_t ret = 80;
|
|
|
|
if (isLeaf)
|
|
|
|
ret += leafData->getMemoryUsage();
|
|
|
|
else {
|
|
|
|
ret += left->getMemoryUsage();
|
|
|
|
ret += right->getMemoryUsage();
|
|
|
|
}
|
|
|
|
|
|
|
|
return (ret + 3) & ~3;
|
|
|
|
}
|
2017-10-17 05:51:53 +00:00
|
|
|
|
2017-10-17 06:05:23 +00:00
|
|
|
#if DCLN_DUMP_OBB
|
2018-12-08 05:30:43 +00:00
|
|
|
void sendToBlender(hecl::blender::PyOutStream& os) const;
|
2017-10-17 06:05:23 +00:00
|
|
|
#endif
|
2017-05-22 11:24:24 +00:00
|
|
|
};
|
2018-12-08 05:30:43 +00:00
|
|
|
Node root;
|
2019-08-15 02:20:37 +00:00
|
|
|
size_t getMemoryUsage() const { return root.getMemoryUsage(); }
|
2017-05-22 11:24:24 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
/* Dummy MP2 member */
|
|
|
|
void insertNoClimb(hecl::blender::PyOutStream&) const {}
|
|
|
|
};
|
2017-05-22 11:24:24 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
Vector<Collision, AT_DNA_COUNT(colCount)> collision;
|
2017-05-22 11:24:24 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void sendToBlender(hecl::blender::Connection& conn, std::string_view entryName);
|
2017-05-22 11:24:24 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
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,
|
2021-06-30 18:20:45 +00:00
|
|
|
std::function<void(const char*)> fileChanged);
|
2017-10-17 05:51:53 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
static bool Cook(const hecl::ProjectPath& outPath, const std::vector<Mesh>& meshes);
|
2017-05-22 11:24:24 +00:00
|
|
|
};
|
|
|
|
|
2019-05-08 03:50:21 +00:00
|
|
|
template <class Op>
|
|
|
|
void DCLN::Collision::Node::Enumerate(typename Op::StreamT& s) {
|
2019-08-27 03:02:31 +00:00
|
|
|
Do<Op>(athena::io::PropId{"xf[0]"}, xf[0], s);
|
|
|
|
Do<Op>(athena::io::PropId{"xf[1]"}, xf[1], s);
|
|
|
|
Do<Op>(athena::io::PropId{"xf[2]"}, xf[2], s);
|
|
|
|
Do<Op>(athena::io::PropId{"halfExtent"}, halfExtent, s);
|
|
|
|
Do<Op>(athena::io::PropId{"isLeaf"}, isLeaf, s);
|
2019-05-08 03:50:21 +00:00
|
|
|
if (isLeaf) {
|
2020-03-31 16:50:26 +00:00
|
|
|
if (!leafData) {
|
|
|
|
leafData = std::make_unique<LeafData>();
|
|
|
|
}
|
2019-08-27 03:02:31 +00:00
|
|
|
Do<Op>(athena::io::PropId{"leafData"}, *leafData, s);
|
2019-05-08 03:50:21 +00:00
|
|
|
} else {
|
2020-03-31 16:50:26 +00:00
|
|
|
if (!left) {
|
|
|
|
left = std::make_unique<Node>();
|
|
|
|
}
|
2019-08-27 03:02:31 +00:00
|
|
|
Do<Op>(athena::io::PropId{"left"}, *left, s);
|
2020-03-31 16:50:26 +00:00
|
|
|
if (!right) {
|
|
|
|
right = std::make_unique<Node>();
|
|
|
|
}
|
2019-08-27 03:02:31 +00:00
|
|
|
Do<Op>(athena::io::PropId{"right"}, *right, s);
|
2019-05-08 03:50:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
AT_SPECIALIZE_DNA(DCLN::Collision::Node)
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
} // namespace DataSpec::DNAMP1
|