From cf8cb69b6188d2369d066712606e8c453af3be93 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Fri, 23 Jun 2023 17:15:06 -0700 Subject: [PATCH] Start COBBTree Former-commit-id: e5668e767ea04df07a403b3041ca4a8b8ae8e297 --- include/Kyoto/Streams/CInputStream.hpp | 6 ++++++ include/WorldFormat/CCollisionEdge.hpp | 22 ++++++++++++++++++++++ include/WorldFormat/COBBTree.hpp | 25 +++++++++++++++++++++++++ src/WorldFormat/COBBTree.cpp | 14 ++++++++++++++ 4 files changed, 67 insertions(+) create mode 100644 include/WorldFormat/CCollisionEdge.hpp create mode 100644 include/WorldFormat/COBBTree.hpp create mode 100644 src/WorldFormat/COBBTree.cpp diff --git a/include/Kyoto/Streams/CInputStream.hpp b/include/Kyoto/Streams/CInputStream.hpp index a1a298fb..86eda00c 100644 --- a/include/Kyoto/Streams/CInputStream.hpp +++ b/include/Kyoto/Streams/CInputStream.hpp @@ -44,6 +44,7 @@ public: // CIEKeyframeEmitter / rstl::vector(CInputStream&) // why? int ReadInt32() { return static_cast< uint >(Get(TType< int >())); } + u16 ReadUint16() { return Get(); } uint GetBlockOffset() const { return x4_blockOffset; } @@ -74,6 +75,11 @@ inline char cinput_stream_helper(const TType< char >& type, CInputStream& in) { return in.ReadChar(); } +template <> +inline unsigned char cinput_stream_helper(const TType< unsigned char >& type, CInputStream& in) { + return in.ReadChar(); +} + template <> inline int cinput_stream_helper(const TType< int >& type, CInputStream& in) { return in.ReadLong(); diff --git a/include/WorldFormat/CCollisionEdge.hpp b/include/WorldFormat/CCollisionEdge.hpp new file mode 100644 index 00000000..7255fd66 --- /dev/null +++ b/include/WorldFormat/CCollisionEdge.hpp @@ -0,0 +1,22 @@ +#ifndef _CCOLLISIONEDGE +#define _CCOLLISIONEDGE + +#include "types.h" + +#include "Kyoto/Streams/CInputStream.hpp" + +class CCollisionEdge { +public: + CCollisionEdge(CInputStream& in){ + x0_index1 = in.Get(); + x2_index2 = in.Get(); + } + + u16 GetVertIndex1() const { return x0_index1; } + u16 GetVertIndex2() const { return x2_index2; } +private: + u16 x0_index1; + u16 x2_index2; +}; + +#endif // _CCOLLISIONEDGE diff --git a/include/WorldFormat/COBBTree.hpp b/include/WorldFormat/COBBTree.hpp new file mode 100644 index 00000000..391348d8 --- /dev/null +++ b/include/WorldFormat/COBBTree.hpp @@ -0,0 +1,25 @@ +#ifndef _COBBTREE +#define _COBBTREE + +#include "Kyoto/Math/CVector3f.hpp" + +#include "WorldFormat/CCollisionEdge.hpp" + + +#include "rstl/vector.hpp" + + +class COBBTree { + struct SIndexData { + rstl::vector x0_materials; + rstl::vector x10_vertMaterials; + rstl::vector x20_edgeMaterials; + rstl::vector x30_surfaceMaterials; + rstl::vector x40_edges; + rstl::vector x50_surfaceIndices; + rstl::vector x60_vertices; + SIndexData(CInputStream& in); + }; +}; + +#endif // _COBBTREE diff --git a/src/WorldFormat/COBBTree.cpp b/src/WorldFormat/COBBTree.cpp new file mode 100644 index 00000000..ac24f904 --- /dev/null +++ b/src/WorldFormat/COBBTree.cpp @@ -0,0 +1,14 @@ +#include "WorldFormat/COBBTree.hpp" + +#include "Kyoto/Streams/CInputStream.hpp" + + +COBBTree::SIndexData::SIndexData(CInputStream& in) +: x0_materials(in) +, x10_vertMaterials(in) +, x20_edgeMaterials(in) +, x30_surfaceMaterials(in) +, x40_edges(in) +, x50_surfaceIndices(in) +, x60_vertices(in) { +}