metaforce/Runtime/World/CGameArea.hpp

289 lines
8.1 KiB
C++
Raw Normal View History

2016-04-16 23:48:29 +00:00
#ifndef __URDE_CGAMEAREA_HPP__
#define __URDE_CGAMEAREA_HPP__
2016-04-17 02:50:45 +00:00
#include "zeus/CVector2f.hpp"
#include "zeus/CColor.hpp"
2016-04-19 00:17:49 +00:00
#include "zeus/CAABox.hpp"
#include "CToken.hpp"
2016-04-17 02:50:45 +00:00
#include "RetroTypes.hpp"
2016-04-19 00:17:49 +00:00
#include "IGameArea.hpp"
2016-08-05 20:26:23 +00:00
#include "Collision/CAreaOctTree.hpp"
2016-04-19 00:17:49 +00:00
#include "hecl/ClientProcess.hpp"
2016-07-23 00:26:17 +00:00
#include "Graphics/CMetroidModelInstance.hpp"
2016-08-07 00:20:02 +00:00
#include "CObjectList.hpp"
#include "CWorldLight.hpp"
#include "Graphics/CPVSAreaSet.hpp"
2016-04-17 02:50:45 +00:00
2016-04-16 23:48:29 +00:00
namespace urde
{
2016-07-23 00:26:17 +00:00
class CStateManager;
2016-08-07 00:20:02 +00:00
class CPFArea;
2016-04-16 23:48:29 +00:00
2016-04-17 02:50:45 +00:00
enum class ERglFogMode
{
Four = 4
};
2016-07-23 00:26:17 +00:00
class CDummyGameArea : public IGameArea
{
2016-07-24 04:46:32 +00:00
friend class CDummyWorld;
int x4_mlvlVersion;
ResId x8_nameSTRG;
ResId xc_mrea;
ResId x10_areaId;
zeus::CTransform x14_transform;
std::vector<u16> x44_attachedAreaIndices;
std::vector<Dock> x54_docks;
2016-07-23 00:26:17 +00:00
public:
CDummyGameArea(CInputStream& in, int idx, int mlvlVersion);
2016-07-23 00:26:17 +00:00
bool IGetScriptingMemoryAlways() const;
TAreaId IGetAreaId() const;
ResId IGetAreaAssetId() const;
bool IIsActive() const;
TAreaId IGetAttachedAreaId(int) const;
u32 IGetNumAttachedAreas() const;
ResId IGetStringTableAssetId() const;
const zeus::CTransform& IGetTM() const;
};
2016-08-07 00:20:02 +00:00
struct CAreaRenderOctTree
{
struct Node
{
u16 x0_bitmapIdx;
u16 x2_flags;
u16 x4_children[];
u32 GetChildCount() const;
zeus::CAABox GetNodeBounds(const zeus::CAABox& curAABB, int idx) const;
void RecursiveBuildOverlaps(u32* out, const CAreaRenderOctTree& parent, const zeus::CAABox& curAABB,
const zeus::CAABox& testAABB) const;
};
std::unique_ptr<u8[]> x0_buf;
u32 x8_bitmapCount;
u32 xc_meshCount;
u32 x10_nodeCount;
u32 x14_bitmapWordCount;
zeus::CAABox x18_aabb;
u32* x30_bitmaps;
u32* x34_indirectionTable;
u8* x38_entries;
CAreaRenderOctTree(std::unique_ptr<u8[]>&& buf);
void FindOverlappingModels(std::vector<u32>& out, const zeus::CAABox& testAABB) const;
};
2016-04-19 00:17:49 +00:00
class CGameArea : public IGameArea
2016-04-16 23:48:29 +00:00
{
2016-07-24 04:46:32 +00:00
friend class CWorld;
int x4_selfIdx;
2016-04-19 00:17:49 +00:00
ResId x8_nameSTRG;
zeus::CTransform xc_transform;
zeus::CTransform x3c_invTransform;
zeus::CAABox x6c_aabb;
ResId x84_mrea;
u32 x88_areaId;
std::vector<u16> x8c_attachedAreaIndices;
std::vector<SObjectTag> x9c_deps1;
std::vector<SObjectTag> xac_deps2;
2016-08-07 00:20:02 +00:00
std::vector<u32> xbc_layerDepOffsets;
2016-04-19 00:17:49 +00:00
std::vector<Dock> xcc_docks;
std::vector<CToken> xdc_tokens;
u32 xec_totalResourcesSize = 0;
union
{
struct
{
2016-07-23 03:07:07 +00:00
bool xf0_24_postConstructed : 1;
2016-04-23 18:04:49 +00:00
bool xf0_25_active : 1;
2016-08-07 00:20:02 +00:00
bool xf0_26_tokensReady : 1;
2016-04-19 00:17:49 +00:00
bool xf0_27_ : 1;
bool xf0_28_ : 1;
};
u8 _dummy = 0;
};
std::list<std::shared_ptr<const hecl::ClientProcess::BufferTransaction>> xf8_loadTransactions;
2016-04-17 02:50:45 +00:00
public:
2016-08-07 00:20:02 +00:00
class CAreaFog
{
zeus::CVector2f x4_ = {0.f, 1024.f};
zeus::CVector2f xc_ = {0.f, 1024.f};
zeus::CVector2f x14_;
zeus::CVector3f x1c_ = {0.5f};
zeus::CVector3f x28_ = {0.5f};
float x34_ = 0.f;
public:
void SetCurrent() const;
void Update(float dt);
void RollFogOut(float, float, const zeus::CColor& color);
void FadeFog(ERglFogMode, const zeus::CColor& color, const zeus::CVector2f& vec1,
float, const zeus::CVector2f& vec2);
void SetFogExplicit(ERglFogMode, const zeus::CColor& color, const zeus::CVector2f& vec);
bool IsFogDisabled() const;
void DisableFog();
};
2016-07-23 00:26:17 +00:00
struct CPostConstructed
{
2016-08-07 00:20:02 +00:00
std::unique_ptr<CAreaOctTree> x0_collision;
u32 x8_collisionSize = 0;
std::experimental::optional<CAreaRenderOctTree> xc_octTree;
2016-07-28 04:55:06 +00:00
std::vector<CMetroidModelInstance> x4c_insts;
2016-08-07 00:20:02 +00:00
//std::unique_ptr<from unknown, pointless MREA section> x5c_;
std::vector<CWorldLight> x60_lightsA;
std::vector<CLight> x70_gfxLightsA;
std::vector<CWorldLight> x80_lightsB;
std::vector<CLight> x90_gfxLightsB;
std::unique_ptr<CPVSAreaSet::CPVSAreaHolder> xa0_pvs;
2016-07-23 00:26:17 +00:00
u32 xa4_elemCount = 1024;
struct MapEntry
{
s16 x0_id = -1;
TUniqueId x4_uid = kInvalidUniqueId;
} xa8_map[1024];
2016-08-07 00:20:02 +00:00
u32 x10a8_pvsVersion = 0;
TLockedToken<CPFArea> x10ac_path;
2016-07-23 00:26:17 +00:00
// bool x10b8_ = 0; optional flag for CToken
u32 x10bc_ = 0;
2016-08-07 00:20:02 +00:00
std::unique_ptr<CObjectList> x10c0_areaObjs;
std::unique_ptr<CAreaFog> x10c4_areaFog;
std::unique_ptr<u8[]> x10c8_sclyBuf;
u32 x10d0_sclySize = 0;
2016-07-23 00:26:17 +00:00
u32 x10d4_ = 0;
u32 x10d8_ = 0;
u32 x10dc_ = 0;
u32 x10e0_ = 0;
float x10e4_ = 5.f;
u32 x10e8_ = -1;
u32 x10ec_ = 0;
// std::vector<CAramToken> x10f0_tokens;
u32 x1100_ = 0;
u32 x1104_ = 0;
union
{
struct
{
bool x1108_24_ : 1;
bool x1108_25_ : 1;
bool x1108_26_ : 1;
bool x1108_28_ : 1;
bool x1108_29_ : 1;
bool x1108_30_ : 1;
};
u8 _dummy = 0;
};
2016-08-07 00:20:02 +00:00
std::vector<std::pair<u8*, u32>> x110c_layerPtrs;
2016-07-23 03:07:07 +00:00
float x111c_thermalCurrent = 0.f;
float x1120_thermalSpeed = 0.f;
float x1124_thermalTarget = 0.f;
2016-07-23 00:26:17 +00:00
float x1128_ = 1.f;
float x112c_ = 0.f;
float x1130_ = 1.f;
float x1134_ = 0.f;
float x1138_ = 1.f;
u32 x113c_ = 0;
};
2016-07-23 03:07:07 +00:00
private:
2016-08-07 00:20:02 +00:00
std::vector<std::pair<std::unique_ptr<u8[]>, int>> x110_mreaSecBufs;
2016-07-23 03:07:07 +00:00
std::unique_ptr<CPostConstructed> x12c_postConstructed;
void UpdateFog(float dt);
void UpdateThermalVisor(float dt);
2016-08-07 00:20:02 +00:00
struct MREAHeader
{
u32 version = 0;
zeus::CTransform xf;
u32 modelCount;
u32 secCount;
u32 geomSecIdx;
u32 sclySecIdx;
u32 collisionSecIdx;
u32 unkSecIdx;
u32 lightSecIdx;
u32 visiSecIdx;
u32 pathSecIdx;
u32 arotSecIdx;
std::vector<u32> secSizes;
};
2016-07-23 03:07:07 +00:00
public:
2016-07-23 00:26:17 +00:00
struct CAreaObjectList : public IAreaObjectList
{
bool IsQualified(const CEntity& ent);
};
enum class EOcclusionState
{
};
2016-07-24 04:46:32 +00:00
CGameArea(CInputStream& in, int idx, int mlvlVersion);
2016-04-19 00:17:49 +00:00
2016-07-23 00:26:17 +00:00
bool IsFinishedOccluding() const;
void ReadDependencyList();
bool IGetScriptingMemoryAlways() const;
TAreaId IGetAreaId() const;
ResId IGetAreaAssetId() const;
bool IIsActive() const;
TAreaId IGetAttachedAreaId(int) const;
u32 IGetNumAttachedAreas() const;
ResId IGetStringTableAssetId() const;
const zeus::CTransform& IGetTM() const;
bool DoesAreaNeedEnvFx() const;
bool DoesAreaNeedSkyNow() const;
bool OtherAreaOcclusionChanged();
void PingOcclusionState();
void PreRender();
void AliveUpdate(float dt);
void SetOcclusionState(EOcclusionState state);
void RemoveStaticGeometry();
void AddStaticGeometry();
//void TransferTokensToARAM();
//void TransferARAMTokensOver();
void SetChain(CGameArea* other, int);
void StartStreamingMainArea();
//void UnloadAllLoadedTextures();
//void ReloadAllLoadedTextures();
u32 GetNumPartSizes() const;
void AllocNewAreaData(int, int);
void Invalidate(CStateManager& mgr);
void CullDeadAreaRequests();
void StartStreamIn(CStateManager& mgr);
bool Validate(CStateManager& mgr);
void PostConstructArea();
void FillInStaticGeometry();
2016-08-07 00:20:02 +00:00
void VerifyTokenList(CStateManager& stateMgr);
2016-07-23 00:26:17 +00:00
void ClearTokenList();
u32 GetPreConstructedSize() const;
2016-08-07 00:20:02 +00:00
MREAHeader VerifyHeader() const;
2016-07-23 00:26:17 +00:00
2016-04-19 00:17:49 +00:00
const zeus::CTransform& GetTransform() const {return xc_transform;}
const zeus::CTransform& GetInverseTransform() const {return x3c_invTransform;}
const zeus::CAABox& GetAABB() const {return x6c_aabb;}
2016-07-23 03:07:07 +00:00
const std::vector<Dock> GetDocks() const {return xcc_docks;}
bool IsPostConstructed() const {return xf0_24_postConstructed;}
const CPostConstructed* GetPostConstructed() const {return x12c_postConstructed.get();}
2016-04-16 23:48:29 +00:00
};
}
#endif // __URDE_CGAMEAREA_HPP__