mirror of
https://github.com/PrimeDecomp/prime.git
synced 2025-12-10 13:47:42 +00:00
Halfway match CAABox; continue CBallCamera
Former-commit-id: 602109d8f0
This commit is contained in:
93
include/WorldFormat/CAreaOctTree.hpp
Normal file
93
include/WorldFormat/CAreaOctTree.hpp
Normal file
@@ -0,0 +1,93 @@
|
||||
#ifndef _CAREAOCTTREE_HPP
|
||||
#define _CAREAOCTTREE_HPP
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#include "WorldFormat/CCollisionSurface.hpp"
|
||||
|
||||
#include "Kyoto/Math/CAABox.hpp"
|
||||
#include "Kyoto/Math/CPlane.hpp"
|
||||
|
||||
#include "rstl/optional_object.hpp"
|
||||
|
||||
class CCollisionEdge;
|
||||
class CLine;
|
||||
class CMaterialFilter;
|
||||
|
||||
class CAreaOctTree {
|
||||
public:
|
||||
struct SRayResult {
|
||||
CPlane x0_plane;
|
||||
rstl::optional_object< CCollisionSurface > x10_surface;
|
||||
f32 x3c_t;
|
||||
};
|
||||
|
||||
class TriListReference {
|
||||
public:
|
||||
explicit TriListReference(const u16* ptr) : m_ptr(ptr) {}
|
||||
u16 GetAt(int idx) const { return m_ptr[idx + 1]; }
|
||||
u16 GetSize() const { return m_ptr[0]; }
|
||||
|
||||
private:
|
||||
const u16* m_ptr;
|
||||
};
|
||||
|
||||
class Node {
|
||||
public:
|
||||
enum ETreeType { kTT_Invalid, kTT_Branch, kTT_Leaf };
|
||||
|
||||
Node(const void* ptr, const CAABox& aabb, const CAreaOctTree& owner, ETreeType type)
|
||||
: x0_aabb(aabb)
|
||||
, x18_ptr(reinterpret_cast< const u8* >(ptr))
|
||||
, x1c_owner(owner)
|
||||
, x20_nodeType(type) {}
|
||||
|
||||
bool LineTest(const CLine& line, const CMaterialFilter& filter, f32 length) const;
|
||||
void LineTestEx(const CLine& line, const CMaterialFilter& filter, SRayResult& res,
|
||||
f32 length) const;
|
||||
|
||||
const CAreaOctTree& GetOwner() const { return x1c_owner; }
|
||||
const CAABox& GetBoundingBox() const { return x0_aabb; }
|
||||
u16 GetChildFlags() const { return *reinterpret_cast< const u16* >(x18_ptr); }
|
||||
Node GetChild(int idx) const;
|
||||
TriListReference GetTriangleArray() const;
|
||||
ETreeType GetChildType(int idx) const {
|
||||
u16 flags = *reinterpret_cast< const u16* >(x18_ptr);
|
||||
return ETreeType((flags >> (2 * idx)) & 0x3);
|
||||
}
|
||||
ETreeType GetTreeType() const { return x20_nodeType; }
|
||||
|
||||
private:
|
||||
CAABox x0_aabb;
|
||||
const u8* x18_ptr;
|
||||
const CAreaOctTree& x1c_owner;
|
||||
ETreeType x20_nodeType;
|
||||
|
||||
bool LineTestInternal(const CLine& line, const CMaterialFilter& filter, f32 lT, f32 hT,
|
||||
f32 maxT, const CVector3f& vec) const;
|
||||
void LineTestExInternal(const CLine& line, const CMaterialFilter& filter, SRayResult& res,
|
||||
f32 lT, f32 hT, f32 maxT, const CVector3f& dirRecip) const;
|
||||
};
|
||||
|
||||
// TODO
|
||||
|
||||
private:
|
||||
CAABox x0_aabb;
|
||||
Node::ETreeType x18_treeType;
|
||||
const u8* x1c_buf;
|
||||
const u8* x20_treeBuf;
|
||||
uint x24_matCount;
|
||||
const uint* x28_materials;
|
||||
const u8* x2c_vertMats;
|
||||
const u8* x30_edgeMats;
|
||||
const u8* x34_polyMats;
|
||||
uint x38_edgeCount;
|
||||
const CCollisionEdge* x3c_edges;
|
||||
uint x40_polyCount;
|
||||
const u16* x44_polyEdges;
|
||||
uint x48_vertCount;
|
||||
const float* x4c_verts;
|
||||
};
|
||||
CHECK_SIZEOF(CAreaOctTree, 0x50)
|
||||
|
||||
#endif
|
||||
20
include/WorldFormat/CCollisionSurface.hpp
Normal file
20
include/WorldFormat/CCollisionSurface.hpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef _CCOLLISIONSURFACE_HPP
|
||||
#define _CCOLLISIONSURFACE_HPP
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#include "Kyoto/Math/CVector3f.hpp"
|
||||
|
||||
class CCollisionSurface {
|
||||
public:
|
||||
typedef CVector3f TVerts[3];
|
||||
|
||||
// TODO
|
||||
|
||||
private:
|
||||
TVerts x0_data;
|
||||
uint x24_flags;
|
||||
};
|
||||
CHECK_SIZEOF(CCollisionSurface, 0x28)
|
||||
|
||||
#endif
|
||||
68
include/WorldFormat/CMetroidAreaCollider.hpp
Normal file
68
include/WorldFormat/CMetroidAreaCollider.hpp
Normal file
@@ -0,0 +1,68 @@
|
||||
#ifndef _CMETROIDAREACOLLIDER_HPP
|
||||
#define _CMETROIDAREACOLLIDER_HPP
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#include "WorldFormat/CAreaOctTree.hpp"
|
||||
|
||||
#include "Kyoto/Math/CAABox.hpp"
|
||||
|
||||
#include "rstl/reserved_vector.hpp"
|
||||
|
||||
class CMetroidAreaCollider {
|
||||
public:
|
||||
class COctreeLeafCache {
|
||||
public:
|
||||
COctreeLeafCache(const CAreaOctTree& octTree);
|
||||
void AddLeaf(const CAreaOctTree::Node& node);
|
||||
u32 GetNumLeaves() const { return x4_nodeCache.size(); }
|
||||
bool HasCacheOverflowed() const { return x908_24_overflow; }
|
||||
const CAreaOctTree& GetOctTree() const { return x0_octTree; }
|
||||
rstl::reserved_vector< CAreaOctTree::Node, 64 >::const_iterator begin() const {
|
||||
return x4_nodeCache.begin();
|
||||
}
|
||||
rstl::reserved_vector< CAreaOctTree::Node, 64 >::const_iterator end() const {
|
||||
return x4_nodeCache.end();
|
||||
}
|
||||
|
||||
private:
|
||||
const CAreaOctTree& x0_octTree;
|
||||
rstl::reserved_vector< CAreaOctTree::Node, 64 > x4_nodeCache;
|
||||
bool x908_24_overflow : 1;
|
||||
};
|
||||
|
||||
// TODO
|
||||
|
||||
private:
|
||||
// TODO
|
||||
};
|
||||
|
||||
class CAreaCollisionCache {
|
||||
public:
|
||||
CAreaCollisionCache(const CAABox& aabb);
|
||||
|
||||
void ClearCache();
|
||||
const CAABox& GetCacheBounds() const { return x0_aabb; }
|
||||
void SetCacheBounds(const CAABox& aabb) { x0_aabb = aabb; }
|
||||
void AddOctreeLeafCache(const CMetroidAreaCollider::COctreeLeafCache& leafCache);
|
||||
u32 GetNumCaches() const { return x18_leafCaches.size(); }
|
||||
const CMetroidAreaCollider::COctreeLeafCache& GetOctreeLeafCache(int idx) {
|
||||
return x18_leafCaches[idx];
|
||||
}
|
||||
bool HasCacheOverflowed() const { return x1b40_24_leafOverflow; }
|
||||
rstl::reserved_vector< CMetroidAreaCollider::COctreeLeafCache, 3 >::const_iterator begin() const {
|
||||
return x18_leafCaches.begin();
|
||||
}
|
||||
rstl::reserved_vector< CMetroidAreaCollider::COctreeLeafCache, 3 >::const_iterator end() const {
|
||||
return x18_leafCaches.end();
|
||||
}
|
||||
|
||||
private:
|
||||
CAABox x0_aabb;
|
||||
rstl::reserved_vector< CMetroidAreaCollider::COctreeLeafCache, 3 > x18_leafCaches;
|
||||
bool x1b40_24_leafOverflow : 1;
|
||||
bool x1b40_25_cacheOverflow : 1;
|
||||
};
|
||||
CHECK_SIZEOF(CAreaCollisionCache, 0x1b44)
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user