mirror of
https://github.com/PrimeDecomp/prime.git
synced 2025-12-11 16:23:59 +00:00
Start CWorld
This commit is contained in:
@@ -3,25 +3,71 @@
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#include "MetroidPrime/CStateManager.hpp"
|
||||
#include "MetroidPrime/TGameTypes.hpp"
|
||||
|
||||
#include "Kyoto/Graphics/CColor.hpp"
|
||||
#include "Kyoto/Graphics/CGraphics.hpp"
|
||||
#include "Kyoto/IObjectStore.hpp"
|
||||
#include "Kyoto/Math/CAABox.hpp"
|
||||
#include "Kyoto/Math/CTransform4f.hpp"
|
||||
#include "Kyoto/Math/CVector2f.hpp"
|
||||
|
||||
#include "WorldFormat/CMetroidModelInstance.hpp"
|
||||
#include "WorldFormat/CWorldLight.hpp"
|
||||
|
||||
#include "rstl/auto_ptr.hpp"
|
||||
#include "rstl/list.hpp"
|
||||
#include "rstl/optional_object.hpp"
|
||||
#include "rstl/pair.hpp"
|
||||
#include "rstl/rc_ptr.hpp"
|
||||
#include "rstl/reserved_vector.hpp"
|
||||
#include "rstl/single_ptr.hpp"
|
||||
#include "rstl/vector.hpp"
|
||||
|
||||
class CAreaOctTree;
|
||||
class CDvdRequest;
|
||||
class CPVSAreaSet;
|
||||
class CScriptAreaAttributes;
|
||||
class CToken;
|
||||
|
||||
class IGameArea {
|
||||
public:
|
||||
class Dock {
|
||||
public:
|
||||
struct SDockReference {
|
||||
uint x0_area;
|
||||
s16 x4_dock;
|
||||
bool x6_loadOther;
|
||||
|
||||
SDockReference();
|
||||
};
|
||||
|
||||
private:
|
||||
int x0_referenceCount;
|
||||
rstl::vector< SDockReference > x4_dockReferences;
|
||||
rstl::reserved_vector< CVector3f, 4 > x14_planeVertices;
|
||||
bool x48_isReferenced;
|
||||
|
||||
public:
|
||||
const rstl::reserved_vector< CVector3f, 4 >& GetPlaneVertices() const {
|
||||
return x14_planeVertices;
|
||||
}
|
||||
int GetReferenceCount() const { return x0_referenceCount; }
|
||||
const rstl::vector< SDockReference >& GetDockRefs() const { return x4_dockReferences; }
|
||||
Dock(CInputStream& in, const CTransform4f& xf);
|
||||
TAreaId GetConnectedAreaId(int other) const;
|
||||
s16 GetOtherDockNumber(int other) const;
|
||||
bool GetShouldLoadOther(int other) const;
|
||||
void SetShouldLoadOther(int other, bool should);
|
||||
bool ShouldLoadOtherArea(int other) const;
|
||||
CVector3f GetPoint(int idx) const;
|
||||
bool IsReferenced() const { return x48_isReferenced; }
|
||||
void SetReferenceCount(int v) {
|
||||
x0_referenceCount = v;
|
||||
x48_isReferenced = true;
|
||||
}
|
||||
};
|
||||
|
||||
virtual ~IGameArea();
|
||||
virtual const CTransform4f& IGetTM() const = 0;
|
||||
virtual CAssetId IGetStringTableAssetId() const = 0;
|
||||
@@ -33,21 +79,36 @@ public:
|
||||
virtual rstl::pair< rstl::auto_ptr< uchar >, int > IGetScriptingMemoryAlways() const = 0;
|
||||
};
|
||||
|
||||
enum EChain {
|
||||
kC_Invalid = -1,
|
||||
kC_ToDeallocate,
|
||||
kC_Deallocated,
|
||||
kC_Loading,
|
||||
kC_Alive,
|
||||
kC_AliveJudgement,
|
||||
};
|
||||
struct CAreaRenderOctTree {
|
||||
struct Node {
|
||||
ushort x0_bitmapIdx;
|
||||
ushort x2_flags;
|
||||
ushort x4_children[1];
|
||||
|
||||
class Dock;
|
||||
class CToken;
|
||||
class CDvdRequest;
|
||||
class CScriptAreaAttributes;
|
||||
class CWorldLight;
|
||||
class CPVSAreaSet;
|
||||
uint GetChildCount() const;
|
||||
CAABox GetNodeBounds(const CAABox& curAABB, int idx) const;
|
||||
|
||||
void RecursiveBuildOverlaps(u32* out, const CAreaRenderOctTree& parent, const CAABox& curAABB,
|
||||
const CAABox& testAABB) const;
|
||||
};
|
||||
|
||||
const u8* x0_buf;
|
||||
int x4_; // TODO
|
||||
uint x8_bitmapCount;
|
||||
uint xc_meshCount;
|
||||
uint x10_nodeCount;
|
||||
uint x14_bitmapWordCount;
|
||||
CAABox x18_aabb;
|
||||
const u32* x30_bitmaps;
|
||||
const u32* x34_indirectionTable;
|
||||
const u8* x38_entries;
|
||||
|
||||
explicit CAreaRenderOctTree(const u8* buf);
|
||||
|
||||
void FindOverlappingModels(rstl::vector< u32 >& out, const CAABox& testAABB) const;
|
||||
void FindOverlappingModels(u32* out, const CAABox& testAABB) const;
|
||||
};
|
||||
CHECK_SIZEOF(CAreaRenderOctTree, 0x3c);
|
||||
|
||||
class CGameArea : public IGameArea {
|
||||
public:
|
||||
@@ -96,7 +157,15 @@ public:
|
||||
enum EOcclusionState { kOS_Occluded, kOS_Visible };
|
||||
|
||||
struct CPostConstructed {
|
||||
uchar x0_pad[0xa0];
|
||||
rstl::optional_object< CAreaOctTree* > x0_collision;
|
||||
int x8_; // TODO
|
||||
rstl::optional_object< CAreaRenderOctTree > xc_octTree;
|
||||
rstl::vector< CMetroidModelInstance > x4c_insts;
|
||||
rstl::single_ptr< int > x5c_; // TODO
|
||||
rstl::vector< CWorldLight > x60_lightsA;
|
||||
rstl::vector< CLight > x70_gfxLightsA;
|
||||
rstl::vector< CWorldLight > x80_lightsB;
|
||||
rstl::vector< CLight > x90_gfxLightsB;
|
||||
CPVSAreaSet* xa0_pvs;
|
||||
uchar xa4_pad[0x1020];
|
||||
rstl::single_ptr< CAreaFog > x10c4_areaFog;
|
||||
@@ -136,8 +205,16 @@ public:
|
||||
bool TryTakingOutOfARAM();
|
||||
|
||||
bool StartStreamingMainArea();
|
||||
bool Invalidate(CStateManager* mgr);
|
||||
void Validate(CStateManager& mgr);
|
||||
void SetOcclusionState(EOcclusionState state);
|
||||
void RemoveStaticGeometry();
|
||||
void StartStreamIn(CStateManager& mgr);
|
||||
void SetChain(CGameArea* next, int chain);
|
||||
|
||||
CAssetId GetAreaAssetId() const { return x84_mrea; }
|
||||
const Dock& GetDock(int idx) const { return xcc_docks[idx]; }
|
||||
int GetDockCount() const { return xcc_docks.size(); }
|
||||
const CAreaFog* GetAreaFog() const { return x12c_postConstructed->x10c4_areaFog.get(); }
|
||||
CAreaFog* AreaFog() { return x12c_postConstructed->x10c4_areaFog.get(); }
|
||||
EOcclusionState GetOcclusionState() const { return x12c_postConstructed->x10dc_occlusionState; }
|
||||
@@ -147,6 +224,9 @@ public:
|
||||
bool IsPostConstructed() const { return xf0_24_postConstructed; } // name?
|
||||
CPostConstructed* GetPostConstructed() { return x12c_postConstructed.get(); } // name?
|
||||
const CPostConstructed* GetPostConstructed() const { return x12c_postConstructed.get(); } // name?
|
||||
CGameArea* GetNext() { return x130_next; } // name?
|
||||
CGameArea* GetPrev() { return x134_prev; } // name?
|
||||
int GetCurChain() const { return x138_curChain; } // name?
|
||||
|
||||
private:
|
||||
void AllocNewAreaData(int, int);
|
||||
@@ -187,10 +267,36 @@ private:
|
||||
int x124_secCount;
|
||||
int x128_mreaDataOffset;
|
||||
rstl::single_ptr< CPostConstructed > x12c_postConstructed;
|
||||
CGameArea* x130_next;
|
||||
CGameArea* x134_prev;
|
||||
int x138_curChain;
|
||||
};
|
||||
|
||||
NESTED_CHECK_SIZEOF(CGameArea, CPostConstructed, 0x1140)
|
||||
CHECK_SIZEOF(CGameArea, 0x13c)
|
||||
|
||||
// CHECK_SIZEOF(CGamearea::CAreaFog, 0x38)
|
||||
class CDummyGameArea final : public IGameArea {
|
||||
friend class CDummyWorld;
|
||||
|
||||
public:
|
||||
CDummyGameArea(CInputStream& in, int idx, int mlvlVersion);
|
||||
rstl::pair< rstl::auto_ptr< uchar >, int > IGetScriptingMemoryAlways() const override;
|
||||
int IGetAreaSaveId() const override;
|
||||
CAssetId IGetAreaAssetId() const override;
|
||||
bool IIsActive() const override;
|
||||
TAreaId IGetAttachedAreaId(int) const override;
|
||||
uint IGetNumAttachedAreas() const override;
|
||||
CAssetId IGetStringTableAssetId() const override;
|
||||
const CTransform4f& IGetTM() const override;
|
||||
|
||||
private:
|
||||
int x4_mlvlVersion;
|
||||
CAssetId x8_nameSTRG;
|
||||
CAssetId xc_mrea;
|
||||
int x10_areaId;
|
||||
CTransform4f x14_transform;
|
||||
rstl::vector< u16 > x44_attachedAreaIndices;
|
||||
rstl::vector< Dock > x54_docks;
|
||||
};
|
||||
CHECK_SIZEOF(CDummyGameArea, 0x64)
|
||||
|
||||
#endif // _CGAMEAREA
|
||||
|
||||
Reference in New Issue
Block a user