mirror of
https://github.com/PrimeDecomp/prime.git
synced 2025-08-05 18:55:36 +00:00
Initial CAreaOctTree work
This commit is contained in:
parent
c4a0f92b44
commit
164136f3b6
@ -11625,7 +11625,7 @@ MakeFromMemory__12CAreaOctTreeFPvUiPP12CAreaOctTreePb = .text:0x802A2B28; // typ
|
||||
__ct__12CAreaOctTreeFRC6CAABoxQ312CAreaOctTree4Node9ETreeTypePUcPvUiPUiPUcPUcPUcUiP14CCollisionEdgeUiPUsUiP9CVector3f = .text:0x802A2CA0; // type:function size:0x9C scope:global
|
||||
GetTriangleArray__Q212CAreaOctTree4NodeCFv = .text:0x802A2D3C; // type:function size:0x24 scope:global
|
||||
GetChild__Q212CAreaOctTree4NodeCFi = .text:0x802A2D60; // type:function size:0x150 scope:global
|
||||
BoxFromIndex__FiRC9CVector3fRC9CVector3fRC9CVector3f = .text:0x802A2EB0; // type:function size:0x1EC scope:global
|
||||
BoxFromIndex__FiRC9CVector3fRC9CVector3fRC9CVector3f = .text:0x802A2EB0; // type:function size:0x1EC scope:local
|
||||
__ct__Q220CMetroidAreaCollider22CMovingAABoxComponentsFRC6CAABoxRC9CVector3f = .text:0x802A309C; // type:function size:0x2E8 scope:global
|
||||
fn_802A3384 = .text:0x802A3384; // type:function size:0x48
|
||||
fn_802A33CC = .text:0x802A33CC; // type:function size:0x28
|
||||
@ -26154,7 +26154,7 @@ lbl_805ADE50 = .sdata2:0x805ADE50; // type:object size:0x4 align:4 data:float
|
||||
lbl_805ADE54 = .sdata2:0x805ADE54; // type:object size:0x4 align:4 data:float
|
||||
lbl_805ADE58 = .sdata2:0x805ADE58; // type:object size:0x4 align:4 data:float
|
||||
lbl_805ADE5C = .sdata2:0x805ADE5C; // type:object size:0x4 align:4 data:float
|
||||
lbl_805ADE60 = .sdata2:0x805ADE60; // type:object size:0x4
|
||||
skDeadArray$48 = .sdata2:0x805ADE60; // type:object size:0x4
|
||||
lbl_805ADE64 = .sdata2:0x805ADE64; // type:object size:0x4 align:4 data:float
|
||||
lbl_805ADE68 = .sdata2:0x805ADE68; // type:object size:0x2 data:2byte
|
||||
lbl_805ADE6A = .sdata2:0x805ADE6A; // type:object size:0x1 data:byte
|
||||
|
@ -54,6 +54,9 @@ public:
|
||||
CVector3f ClosestPointAlongVector(const CVector3f& vec) const;
|
||||
CVector3f FurthestPointAlongVector(const CVector3f& vec) const;
|
||||
CVector3f GetCenterPoint() const;
|
||||
CVector3f CenterPoint() const {
|
||||
return (min + max) * 0.5f;
|
||||
}
|
||||
CVector3f GetPoint(int) const;
|
||||
// Include__6CAABoxFRC9CVector3f weak
|
||||
// Include__6CAABoxFRC6CAABox weak
|
||||
|
@ -69,6 +69,11 @@ public:
|
||||
float lT, float hT, float maxT, const CVector3f& dirRecip) const;
|
||||
};
|
||||
|
||||
CAreaOctTree(const CAABox& bounds, Node::ETreeType treeType, uchar* buf, void* treeBuf,
|
||||
uint materialCount, uint* materials, uchar* vertexMaterials, uchar* edgeMaterials,
|
||||
uchar* triMaterials, uint edgeCount, CCollisionEdge* edges, uint triCount,
|
||||
ushort* triangles, uint vertexCount, CVector3f* vertices);
|
||||
void MakeFromMemory(void* buf, uint bufLen, CAreaOctTree** treeOut, bool*);
|
||||
CCollisionSurface GetMasterListTriangle(ushort idx) const;
|
||||
// TODO
|
||||
|
||||
@ -76,7 +81,7 @@ private:
|
||||
CAABox x0_aabb;
|
||||
Node::ETreeType x18_treeType;
|
||||
const uchar* x1c_buf;
|
||||
const uchar* x20_treeBuf;
|
||||
const void* x20_treeBuf;
|
||||
uint x24_matCount;
|
||||
const uint* x28_materials;
|
||||
const uchar* x2c_vertMats;
|
||||
@ -87,7 +92,7 @@ private:
|
||||
uint x40_polyCount;
|
||||
const ushort* x44_polyEdges;
|
||||
uint x48_vertCount;
|
||||
const float* x4c_verts;
|
||||
const CVector3f* x4c_verts;
|
||||
};
|
||||
CHECK_SIZEOF(CAreaOctTree, 0x50)
|
||||
|
||||
|
0
src/Kyoto/DolphinCMemoryCardSys.cpp
Normal file
0
src/Kyoto/DolphinCMemoryCardSys.cpp
Normal file
96
src/WorldFormat/CAreaOctTree.cpp
Normal file
96
src/WorldFormat/CAreaOctTree.cpp
Normal file
@ -0,0 +1,96 @@
|
||||
#include "WorldFormat/CAreaOctTree.hpp"
|
||||
#include "Kyoto/Basics/CBasics.hpp"
|
||||
#include "Kyoto/Math/CAABox.hpp"
|
||||
#include "Kyoto/Streams/CMemoryInStream.hpp"
|
||||
|
||||
static CAABox BoxFromIndex(int index, const CVector3f& a, const CVector3f& b, const CVector3f& c) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
return CAABox(a, b);
|
||||
case 1:
|
||||
return CAABox(CVector3f(b.GetX(), a.GetY(), a.GetZ()), CVector3f(c.GetX(), b.GetY(), b.GetZ()));
|
||||
case 2:
|
||||
return CAABox(CVector3f(a.GetX(), b.GetY(), a.GetZ()), CVector3f(b.GetX(), c.GetY(), b.GetZ()));
|
||||
case 3:
|
||||
return CAABox(CVector3f(b.GetX(), b.GetY(), a.GetZ()), CVector3f(c.GetX(), c.GetY(), b.GetZ()));
|
||||
case 4:
|
||||
return CAABox(CVector3f(a.GetX(), a.GetY(), b.GetZ()), CVector3f(b.GetX(), b.GetY(), c.GetZ()));
|
||||
case 5:
|
||||
return CAABox(CVector3f(b.GetX(), a.GetY(), b.GetZ()), CVector3f(c.GetX(), b.GetY(), c.GetZ()));
|
||||
case 6:
|
||||
return CAABox(CVector3f(a.GetX(), b.GetY(), b.GetZ()), CVector3f(b.GetX(), c.GetY(), c.GetZ()));
|
||||
case 7:
|
||||
return CAABox(b, c);
|
||||
default:
|
||||
return CAABox(a, c);
|
||||
}
|
||||
}
|
||||
|
||||
CAreaOctTree::Node CAreaOctTree::Node::GetChild(int index) const {
|
||||
const ushort* node = reinterpret_cast< const ushort* >(x18_ptr + (index * 4) + 4);
|
||||
ETreeType type = GetChildType(index);
|
||||
if (type == kTT_Leaf) {
|
||||
CAABox bounds = reinterpret_cast< const Node* >(node)->GetBoundingBox();
|
||||
return Node(reinterpret_cast< const uchar* >(node), bounds, GetOwner(), type);
|
||||
}
|
||||
CAABox bounds =
|
||||
BoxFromIndex(index, x0_aabb.GetMinPoint(), x0_aabb.CenterPoint(), x0_aabb.GetMaxPoint());
|
||||
return Node(reinterpret_cast< const uchar* >(node), bounds, GetOwner(), type);
|
||||
}
|
||||
|
||||
CAreaOctTree::TriListReference CAreaOctTree::Node::GetTriangleArray() const {
|
||||
static const ushort skDeadArray[2] = {0, 0};
|
||||
if (GetTreeType() != kTT_Leaf) {
|
||||
return TriListReference(skDeadArray);
|
||||
}
|
||||
|
||||
return TriListReference(reinterpret_cast< const ushort* >(x18_ptr));
|
||||
}
|
||||
|
||||
CAreaOctTree::CAreaOctTree(const CAABox& bounds, Node::ETreeType treeType, uchar* buf,
|
||||
void* treeBuf, uint materialCount, uint* materials,
|
||||
uchar* vertexMaterials, uchar* edgeMaterials, uchar* polyMaterials,
|
||||
uint edgeCount, CCollisionEdge* edges, uint polyCount, ushort* polyEdges,
|
||||
uint vertexCount, CVector3f* vertices)
|
||||
: x0_aabb(bounds)
|
||||
, x18_treeType(treeType)
|
||||
, x1c_buf(buf)
|
||||
, x20_treeBuf(treeBuf)
|
||||
, x24_matCount(materialCount)
|
||||
, x28_materials(materials)
|
||||
, x2c_vertMats(vertexMaterials)
|
||||
, x30_edgeMats(edgeMaterials)
|
||||
, x34_polyMats(polyMaterials)
|
||||
, x38_edgeCount(edgeCount)
|
||||
, x3c_edges(edges)
|
||||
, x40_polyCount(polyCount)
|
||||
, x44_polyEdges(polyEdges)
|
||||
, x48_vertCount(vertexCount)
|
||||
, x4c_verts(vertices) {}
|
||||
|
||||
void CAreaOctTree::MakeFromMemory(void* buf, const uint bufLen, CAreaOctTree** treeOut,
|
||||
bool* valid) {
|
||||
CMemoryInStream in(buf, bufLen, CMemoryInStream::kOS_NotOwned);
|
||||
in.Get< int >();
|
||||
in.Get< int >();
|
||||
CAABox bounds(in);
|
||||
Node::ETreeType treeType = static_cast< Node::ETreeType >(in.Get< int >());
|
||||
uint treeSize = in.Get< uint >();
|
||||
|
||||
uchar* curBuf = reinterpret_cast< uchar* >(buf) + in.GetReadPosition() + treeSize;
|
||||
uint matCount = CBasics::SwapBytes(*reinterpret_cast< uint* >(curBuf));
|
||||
curBuf += sizeof(uint) * matCount;
|
||||
curBuf += 4;
|
||||
uint* matBuf = reinterpret_cast< uint* >(curBuf);
|
||||
curBuf += 4;
|
||||
uchar* vertexMaterials = curBuf;
|
||||
curBuf += 4;
|
||||
uchar* edgeMaterials = curBuf;
|
||||
curBuf += 4;
|
||||
uchar* polyMaterials = curBuf;
|
||||
*treeOut = rs_new CAreaOctTree(bounds, treeType, reinterpret_cast< uchar* >(buf),
|
||||
reinterpret_cast< uchar* >(buf) + in.GetReadPosition(), matCount,
|
||||
reinterpret_cast< uint* >(matBuf), vertexMaterials, edgeMaterials,
|
||||
polyMaterials, 0, nullptr, 0, nullptr, 0, nullptr);
|
||||
*valid = true;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user