mirror of https://github.com/AxioDL/metaforce.git
CAreaOctTree fields and reader
This commit is contained in:
parent
02a79b4c80
commit
2eb77b9a7a
|
@ -0,0 +1,85 @@
|
|||
#include "CAreaOctTree.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
CAreaOctTree::CAreaOctTree(const zeus::CAABox& aabb, Node::ETreeType treeType, u8* buf, void* treeBuf,
|
||||
u32 matCount, u32* materials, u8* vertMats, u8* edgeMats, u8* polyMats,
|
||||
u32 edgeCount, CCollisionEdge* edges, u32 polyCount, u16* polyEdges,
|
||||
u32 vertCount, zeus::CVector3f* verts)
|
||||
: x0_aabb(aabb), x18_treeType(treeType), x1c_buf(buf), x20_treeBuf(treeBuf),
|
||||
x24_matCount(matCount), x28_materials(materials), x2c_vertMats(vertMats),
|
||||
x30_edgeMats(edgeMats), x34_polyMats(polyMats), x38_edgeCount(edgeCount),
|
||||
x40_polyCount(polyCount), x44_polyEdges(polyEdges),
|
||||
x48_vertCount(vertCount)
|
||||
{
|
||||
{
|
||||
x3c_edges.reserve(edgeCount);
|
||||
athena::io::MemoryReader r(edges, edgeCount * 4);
|
||||
for (u32 i=0 ; i<vertCount ; ++i)
|
||||
x3c_edges.emplace_back(r);
|
||||
}
|
||||
|
||||
{
|
||||
x4c_verts.reserve(vertCount);
|
||||
athena::io::MemoryReader r(verts, vertCount * 12);
|
||||
for (u32 i=0 ; i<vertCount ; ++i)
|
||||
x4c_verts.push_back(zeus::CVector3f::ReadBig(r));
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<CAreaOctTree> CAreaOctTree::MakeFromMemory(void* buf, unsigned int size)
|
||||
{
|
||||
athena::io::MemoryReader r(buf, size);
|
||||
r.readUint32Big();
|
||||
r.readUint32Big();
|
||||
zeus::CAABox aabb;
|
||||
aabb.readBoundingBoxBig(r);
|
||||
Node::ETreeType nodeType = Node::ETreeType(r.readUint32Big());
|
||||
u32 treeSize = r.readUint32Big();
|
||||
u8* cur = reinterpret_cast<u8*>(buf) + r.position();
|
||||
|
||||
void* treeBuf = cur;
|
||||
cur += treeSize;
|
||||
|
||||
u32 matCount = hecl::SBig(*reinterpret_cast<u32*>(cur));
|
||||
cur += 4;
|
||||
u32* matBuf = reinterpret_cast<u32*>(cur);
|
||||
cur += 4 * matCount;
|
||||
|
||||
u32 vertMatsCount = hecl::SBig(*reinterpret_cast<u32*>(cur));
|
||||
cur += 4;
|
||||
u8* vertMatsBuf = cur;
|
||||
cur += vertMatsCount;
|
||||
|
||||
u32 edgeMatsCount = hecl::SBig(*reinterpret_cast<u32*>(cur));
|
||||
cur += 4;
|
||||
u8* edgeMatsBuf = cur;
|
||||
cur += edgeMatsCount;
|
||||
|
||||
u32 polyMatsCount = hecl::SBig(*reinterpret_cast<u32*>(cur));
|
||||
cur += 4;
|
||||
u8* polyMatsBuf = cur;
|
||||
cur += polyMatsCount;
|
||||
|
||||
u32 edgeCount = hecl::SBig(*reinterpret_cast<u32*>(cur));
|
||||
cur += 4;
|
||||
CCollisionEdge* edgeBuf = reinterpret_cast<CCollisionEdge*>(cur);
|
||||
cur += edgeCount * sizeof(edgeCount);
|
||||
|
||||
u32 polyCount = hecl::SBig(*reinterpret_cast<u32*>(cur));
|
||||
cur += 4;
|
||||
u16* polyBuf = reinterpret_cast<u16*>(cur);
|
||||
cur += polyCount * 2;
|
||||
|
||||
u32 vertCount = hecl::SBig(*reinterpret_cast<u32*>(cur));
|
||||
cur += 4;
|
||||
zeus::CVector3f* vertBuf = reinterpret_cast<zeus::CVector3f*>(cur);
|
||||
cur += polyCount * 2;
|
||||
|
||||
return std::make_unique<CAreaOctTree>(aabb, nodeType, reinterpret_cast<u8*>(buf), treeBuf,
|
||||
matCount, matBuf, vertMatsBuf, edgeMatsBuf, polyMatsBuf,
|
||||
edgeCount, edgeBuf, polyCount, polyBuf, vertCount, vertBuf);
|
||||
}
|
||||
|
||||
}
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "RetroTypes.hpp"
|
||||
#include "zeus/CAABox.hpp"
|
||||
#include "Collision/CCollisionEdge.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
@ -54,11 +55,27 @@ public:
|
|||
ETreeType GetTreeType(s32) const;
|
||||
};
|
||||
|
||||
int x14_;
|
||||
zeus::CAABox x0_aabb;
|
||||
Node::ETreeType x18_treeType;
|
||||
u8* x1c_buf;
|
||||
void* x20_treeBuf;
|
||||
u32 x24_matCount;
|
||||
u32* x28_materials;
|
||||
u8* x2c_vertMats;
|
||||
u8* x30_edgeMats;
|
||||
u8* x34_polyMats;
|
||||
u32 x38_edgeCount;
|
||||
std::vector<CCollisionEdge> x3c_edges;
|
||||
u32 x40_polyCount;
|
||||
u16* x44_polyEdges;
|
||||
u32 x48_vertCount;
|
||||
std::vector<zeus::CVector3f> x4c_verts;
|
||||
|
||||
public:
|
||||
CAreaOctTree(const zeus::CAABox& box, Node::ETreeType treeType, u8*, void*, u32, u32*, u8*, u8*, u8*, u32,
|
||||
CCollisionEdge*, u32, u16*, u32, zeus::CVector3f*);
|
||||
CAreaOctTree(const zeus::CAABox& aabb, Node::ETreeType treeType, u8* buf, void* treeBuf,
|
||||
u32 matCount, u32* materials, u8* vertMats, u8* edgeMats, u8* polyMats,
|
||||
u32 edgeCount, CCollisionEdge* edges, u32 polyCount, u16* polyEdges,
|
||||
u32 vertCount, zeus::CVector3f* verts);
|
||||
|
||||
const Node* GetRootNode() const;
|
||||
void GetTreeMemory() const;
|
||||
|
@ -73,7 +90,21 @@ public:
|
|||
void GetTriangleVertexIndices(u16);
|
||||
void GetTriangleEdgeIndices(u16);
|
||||
|
||||
static void MakeFromMemory(void*, unsigned int, CAreaOctTree*, bool*);
|
||||
static std::unique_ptr<CAreaOctTree> MakeFromMemory(void* buf, unsigned int size);
|
||||
|
||||
void RecursiveMatchXray(std::vector<u32>& out, const zeus::CAABox& inner, const zeus::CAABox& outer)
|
||||
{
|
||||
if (outer.intersects(inner))
|
||||
{
|
||||
if (inner.inside(outer))
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MatchXray(std::vector<u32>& out, const zeus::CAABox&)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
set(COLLISION_SOURCES
|
||||
CAreaOctTree.hpp CAreaOctTree.cpp
|
||||
CollisionUtil.hpp CollisionUtil.cpp
|
||||
CGameCollision.hpp CGameCollision.cpp
|
||||
CCollisionResponseData.hpp CCollisionResponseData.cpp
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include "CModel.hpp"
|
||||
#include "Particle/CParticleGen.hpp"
|
||||
#include "CMetroidModelInstance.hpp"
|
||||
#include "World/CAreaOctTree.hpp"
|
||||
#include "Collision/CAreaOctTree.hpp"
|
||||
|
||||
#define FOGVOL_RAMP_RES 256
|
||||
#define SPHERE_RAMP_RES 32
|
||||
|
@ -598,8 +598,14 @@ void CBooRenderer::DrawThermalModel(const CModel& model, const zeus::CColor& mul
|
|||
model.Draw(flags);
|
||||
}
|
||||
|
||||
void CBooRenderer::DrawXRayOutline(const CModel&, const float*, const float*)
|
||||
void CBooRenderer::DrawXRayOutline(const zeus::CAABox&, const float*, const float*)
|
||||
{
|
||||
for (CAreaListItem& item : x1c_areaListItems)
|
||||
{
|
||||
if (item.x4_octTree)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CBooRenderer::SetWireframeFlags(int)
|
||||
|
|
|
@ -55,9 +55,7 @@ class CBooRenderer : public IRenderer
|
|||
//std::vector<TCachedToken<CTexture>> x8_textures;
|
||||
std::vector<CBooModel*> x10_models;
|
||||
int x18_areaIdx;
|
||||
int x20_unk1 = 0;
|
||||
int x24_unk2 = 0;
|
||||
void* x28_unk3 = nullptr;
|
||||
std::vector<u32> x20_;
|
||||
|
||||
CAreaListItem(const std::vector<CMetroidModelInstance>* geom, const CAreaOctTree* octTree,
|
||||
std::vector<CBooModel*>&& models, int areaIdx);
|
||||
|
@ -189,7 +187,7 @@ public:
|
|||
//void CacheReflection(TReflectionCallback, void*, bool);
|
||||
void DrawSpaceWarp(const zeus::CVector3f&, float);
|
||||
void DrawThermalModel(const CModel& model, const zeus::CColor& multCol, const zeus::CColor& addCol);
|
||||
void DrawXRayOutline(const CModel&, const float*, const float*);
|
||||
void DrawXRayOutline(const zeus::CAABox&, const float*, const float*);
|
||||
void SetWireframeFlags(int);
|
||||
void SetWorldFog(ERglFogMode, float, float, const zeus::CColor&);
|
||||
void RenderFogVolume(const zeus::CColor&, const zeus::CAABox&, const TLockedToken<CModel>*, const CSkinnedModel*);
|
||||
|
|
|
@ -88,7 +88,7 @@ public:
|
|||
//virtual void CacheReflection(TReflectionCallback, void*, bool)=0;
|
||||
virtual void DrawSpaceWarp(const zeus::CVector3f&, float)=0;
|
||||
virtual void DrawThermalModel(const CModel&, const zeus::CColor&, const zeus::CColor&)=0;
|
||||
virtual void DrawXRayOutline(const CModel&, const float*, const float*)=0;
|
||||
virtual void DrawXRayOutline(const zeus::CAABox&, const float*, const float*)=0;
|
||||
virtual void SetWireframeFlags(int)=0;
|
||||
virtual void SetWorldFog(ERglFogMode, float, float, const zeus::CColor&)=0;
|
||||
virtual void RenderFogVolume(const zeus::CColor&, const zeus::CAABox&, const TLockedToken<CModel>*, const CSkinnedModel*)=0;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include "CToken.hpp"
|
||||
#include "RetroTypes.hpp"
|
||||
#include "IGameArea.hpp"
|
||||
#include "CAreaOctTree.hpp"
|
||||
#include "Collision/CAreaOctTree.hpp"
|
||||
#include "hecl/ClientProcess.hpp"
|
||||
#include "Graphics/CMetroidModelInstance.hpp"
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ set(WORLD_SOURCES
|
|||
CAiFuncMap.hpp CAiFuncMap.cpp
|
||||
CPatterned.hpp CPatterned.cpp
|
||||
CPathFindArea.hpp CPathFindArea.cpp
|
||||
CAreaOctTree.hpp CAreaOctTree.cpp
|
||||
CPhysicsActor.hpp CPhysicsActor.cpp
|
||||
CEntity.hpp CEntity.cpp
|
||||
CPhysicsActor.hpp CPhysicsActor.cpp
|
||||
|
|
Loading…
Reference in New Issue