2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-08 13:44:56 +00:00

New code style refactor

This commit is contained in:
Jack Andersen
2018-12-07 19:30:43 -10:00
parent 41ae32be31
commit 636c82a568
1451 changed files with 171430 additions and 203303 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -7,298 +7,259 @@
#include "zeus/CVector3f.hpp"
#include "MP1/CInGameGuiManager.hpp"
namespace urde
{
namespace urde {
struct CFinalInput;
class IWorld;
class CMapWorldInfo;
class CStateManager;
class CMapUniverse;
class CAutoMapper
{
class CAutoMapper {
public:
using EInGameGuiState = MP1::EInGameGuiState;
enum class ELoadPhase
{
LoadResources,
LoadUniverse,
Done
using EInGameGuiState = MP1::EInGameGuiState;
enum class ELoadPhase { LoadResources, LoadUniverse, Done };
enum class EAutoMapperState { MiniMap, MapScreen, MapScreenUniverse };
struct SAutoMapperRenderState {
enum class Ease { None, Linear, Out, In, InOut };
typedef zeus::CVector2i (*FGetViewportSize)();
FGetViewportSize m_getViewportSize;
zeus::CVector2i x0_viewportSize;
zeus::CQuaternion x8_camOrientation;
float x18_camDist;
float x1c_camAngle;
zeus::CVector3f x20_areaPoint;
float x2c_drawDepth1;
float x30_drawDepth2;
float x34_alphaSurfaceVisited;
float x38_alphaOutlineVisited;
float x3c_alphaSurfaceUnvisited;
float x40_alphaOutlineUnvisited;
Ease x44_viewportEase;
Ease x48_camEase;
Ease x4c_pointEase;
Ease x50_depth1Ease;
Ease x54_depth2Ease;
Ease x58_alphaEase;
SAutoMapperRenderState() = default;
SAutoMapperRenderState(FGetViewportSize v1, const zeus::CQuaternion& rot, float f1, float f2,
const zeus::CVector3f& v2, float f3, float f4, float f5, float f6, float f7, float f8)
: m_getViewportSize(v1)
, x0_viewportSize(v1())
, x8_camOrientation(rot)
, x18_camDist(f1)
, x1c_camAngle(f2)
, x20_areaPoint(v2)
, x2c_drawDepth1(f3)
, x30_drawDepth2(f4)
, x34_alphaSurfaceVisited(f5)
, x38_alphaOutlineVisited(f6)
, x3c_alphaSurfaceUnvisited(f7)
, x40_alphaOutlineUnvisited(f8)
, x44_viewportEase(Ease::None)
, x48_camEase(Ease::None)
, x4c_pointEase(Ease::None)
, x50_depth1Ease(Ease::None)
, x54_depth2Ease(Ease::None)
, x58_alphaEase(Ease::None) {}
static void InterpolateWithClamp(const SAutoMapperRenderState& a, SAutoMapperRenderState& out,
const SAutoMapperRenderState& b, float t);
void ResetInterpolation() {
x44_viewportEase = Ease::None;
x48_camEase = Ease::None;
x4c_pointEase = Ease::None;
x50_depth1Ease = Ease::None;
x54_depth2Ease = Ease::None;
x58_alphaEase = Ease::None;
}
zeus::CVector2i GetViewportSize() const {
if (m_getViewportSize)
return m_getViewportSize();
else
return x0_viewportSize;
}
};
struct SAutoMapperHintStep {
enum class Type { PanToArea, PanToWorld, SwitchToUniverse, SwitchToWorld, ShowBeacon, ZoomIn, ZoomOut };
struct PanToArea {};
struct PanToWorld {};
struct SwitchToUniverse {};
struct SwitchToWorld {};
struct ShowBeacon {};
struct ZoomIn {};
struct ZoomOut {};
Type x0_type;
union {
CAssetId x4_worldId;
TAreaId x4_areaId;
float x4_float;
};
enum class EAutoMapperState
{
MiniMap,
MapScreen,
MapScreenUniverse
};
struct SAutoMapperRenderState
{
enum class Ease
{
None,
Linear,
Out,
In,
InOut
};
typedef zeus::CVector2i(*FGetViewportSize)();
FGetViewportSize m_getViewportSize;
zeus::CVector2i x0_viewportSize;
zeus::CQuaternion x8_camOrientation;
float x18_camDist;
float x1c_camAngle;
zeus::CVector3f x20_areaPoint;
float x2c_drawDepth1;
float x30_drawDepth2;
float x34_alphaSurfaceVisited;
float x38_alphaOutlineVisited;
float x3c_alphaSurfaceUnvisited;
float x40_alphaOutlineUnvisited;
Ease x44_viewportEase;
Ease x48_camEase;
Ease x4c_pointEase;
Ease x50_depth1Ease;
Ease x54_depth2Ease;
Ease x58_alphaEase;
SAutoMapperRenderState() = default;
SAutoMapperRenderState(FGetViewportSize v1, const zeus::CQuaternion& rot,
float f1, float f2, const zeus::CVector3f& v2, float f3, float f4,
float f5, float f6, float f7, float f8)
: m_getViewportSize(v1), x0_viewportSize(v1()), x8_camOrientation(rot), x18_camDist(f1), x1c_camAngle(f2),
x20_areaPoint(v2), x2c_drawDepth1(f3), x30_drawDepth2(f4),
x34_alphaSurfaceVisited(f5), x38_alphaOutlineVisited(f6),
x3c_alphaSurfaceUnvisited(f7), x40_alphaOutlineUnvisited(f8),
x44_viewportEase(Ease::None), x48_camEase(Ease::None), x4c_pointEase(Ease::None),
x50_depth1Ease(Ease::None), x54_depth2Ease(Ease::None), x58_alphaEase(Ease::None) {}
bool x8_processing = false;
static void InterpolateWithClamp(const SAutoMapperRenderState& a,
SAutoMapperRenderState& out,
const SAutoMapperRenderState& b,
float t);
void ResetInterpolation()
{
x44_viewportEase = Ease::None;
x48_camEase = Ease::None;
x4c_pointEase = Ease::None;
x50_depth1Ease = Ease::None;
x54_depth2Ease = Ease::None;
x58_alphaEase = Ease::None;
}
SAutoMapperHintStep(PanToArea, TAreaId areaId) : x0_type(Type::PanToArea), x4_areaId(areaId) {}
SAutoMapperHintStep(PanToWorld, CAssetId worldId) : x0_type(Type::PanToWorld), x4_worldId(worldId) {}
SAutoMapperHintStep(SwitchToUniverse) : x0_type(Type::SwitchToUniverse), x4_worldId(0) {}
SAutoMapperHintStep(SwitchToWorld, CAssetId worldId) : x0_type(Type::SwitchToWorld), x4_worldId(worldId) {}
SAutoMapperHintStep(ShowBeacon, float val) : x0_type(Type::ShowBeacon), x4_float(val) {}
SAutoMapperHintStep(ZoomIn) : x0_type(Type::ZoomIn), x4_worldId(0) {}
SAutoMapperHintStep(ZoomOut) : x0_type(Type::ZoomOut), x4_worldId(0) {}
};
zeus::CVector2i GetViewportSize() const
{
if (m_getViewportSize)
return m_getViewportSize();
else
return x0_viewportSize;
}
};
struct SAutoMapperHintStep
{
enum class Type
{
PanToArea,
PanToWorld,
SwitchToUniverse,
SwitchToWorld,
ShowBeacon,
ZoomIn,
ZoomOut
};
struct PanToArea {};
struct PanToWorld {};
struct SwitchToUniverse {};
struct SwitchToWorld {};
struct ShowBeacon {};
struct ZoomIn {};
struct ZoomOut {};
Type x0_type;
union
{
CAssetId x4_worldId;
TAreaId x4_areaId;
float x4_float;
};
bool x8_processing = false;
SAutoMapperHintStep(PanToArea, TAreaId areaId) : x0_type(Type::PanToArea), x4_areaId(areaId) {}
SAutoMapperHintStep(PanToWorld, CAssetId worldId) : x0_type(Type::PanToWorld), x4_worldId(worldId) {}
SAutoMapperHintStep(SwitchToUniverse) : x0_type(Type::SwitchToUniverse), x4_worldId(0) {}
SAutoMapperHintStep(SwitchToWorld, CAssetId worldId) : x0_type(Type::SwitchToWorld), x4_worldId(worldId) {}
SAutoMapperHintStep(ShowBeacon, float val) : x0_type(Type::ShowBeacon), x4_float(val) {}
SAutoMapperHintStep(ZoomIn) : x0_type(Type::ZoomIn), x4_worldId(0) {}
SAutoMapperHintStep(ZoomOut) : x0_type(Type::ZoomOut), x4_worldId(0) {}
};
struct SAutoMapperHintLocation
{
u32 x0_showBeacon;
float x4_beaconAlpha;
CAssetId x8_worldId;
TAreaId xc_areaId;
};
struct SAutoMapperHintLocation {
u32 x0_showBeacon;
float x4_beaconAlpha;
CAssetId x8_worldId;
TAreaId xc_areaId;
};
private:
enum class EZoomState
{
None,
In,
Out
};
enum class EZoomState { None, In, Out };
ELoadPhase x4_loadPhase = ELoadPhase::LoadResources;
TLockedToken<CMapUniverse> x8_mapu;
std::vector<std::unique_ptr<IWorld>> x14_dummyWorlds;
const CWorld* x24_world;
TLockedToken<CGuiFrame> x28_frmeMapScreen; // Used to be ptr
bool m_frmeInitialized = false;
TLockedToken<CModel> x30_miniMapSamus;
TLockedToken<CTexture> x3c_hintBeacon;
std::vector<CTexturedQuadFilter> m_hintBeaconFilters;
rstl::reserved_vector<TLockedToken<CTexture>, 5> x48_mapIcons;
CAssetId x74_areaHintDescId;
TLockedToken<CStringTable> x78_areaHintDesc;
CAssetId x88_mapAreaStringId;
TLockedToken<CStringTable> x8c_mapAreaString; // Used to be optional
u32 x9c_worldIdx = 0;
TAreaId xa0_curAreaId;
TAreaId xa4_otherAreaId;
SAutoMapperRenderState xa8_renderStates[3]; // xa8, x104, x160; current, next, prev
EAutoMapperState x1bc_state = EAutoMapperState::MiniMap;
EAutoMapperState x1c0_nextState = EAutoMapperState::MiniMap;
float x1c4_interpDur = 0.f;
float x1c8_interpTime = 0.f;
CSfxHandle x1cc_panningSfx;
CSfxHandle x1d0_rotatingSfx;
CSfxHandle x1d4_zoomingSfx;
float x1d8_flashTimer = 0.f;
float x1dc_playerFlashPulse = 0.f;
std::list<SAutoMapperHintStep> x1e0_hintSteps;
std::list<SAutoMapperHintLocation> x1f8_hintLocations;
rstl::reserved_vector<TLockedToken<CTexture>, 9> x210_lstick;
rstl::reserved_vector<TLockedToken<CTexture>, 9> x25c_cstick;
rstl::reserved_vector<TLockedToken<CTexture>, 2> x2a8_ltrigger;
rstl::reserved_vector<TLockedToken<CTexture>, 2> x2bc_rtrigger;
rstl::reserved_vector<TLockedToken<CTexture>, 2> x2d0_abutton;
u32 x2e4_lStickPos = 0;
u32 x2e8_rStickPos = 0;
u32 x2ec_lTriggerPos = 0;
u32 x2f0_rTriggerPos = 0;
u32 x2f4_aButtonPos = 0;
CGuiTextPane* x2f8_textpane_areaname = nullptr;
CGuiTextPane* x2fc_textpane_hint = nullptr;
CGuiTextPane* x300_textpane_instructions = nullptr;
CGuiTextPane* x304_textpane_instructions1 = nullptr;
CGuiTextPane* x308_textpane_instructions2 = nullptr;
CGuiWidget* x30c_basewidget_leftPane = nullptr;
CGuiWidget* x310_basewidget_yButtonPane = nullptr;
CGuiWidget* x314_basewidget_bottomPane = nullptr;
float x318_leftPanePos = 0.f;
float x31c_yButtonPanePos = 0.f;
float x320_bottomPanePos = 0.f;
EZoomState x324_zoomState = EZoomState::None;
u32 x328_ = 0;
bool x32c_loadingDummyWorld = false;
ELoadPhase x4_loadPhase = ELoadPhase::LoadResources;
TLockedToken<CMapUniverse> x8_mapu;
std::vector<std::unique_ptr<IWorld>> x14_dummyWorlds;
const CWorld* x24_world;
TLockedToken<CGuiFrame> x28_frmeMapScreen; // Used to be ptr
bool m_frmeInitialized = false;
TLockedToken<CModel> x30_miniMapSamus;
TLockedToken<CTexture> x3c_hintBeacon;
std::vector<CTexturedQuadFilter> m_hintBeaconFilters;
rstl::reserved_vector<TLockedToken<CTexture>, 5> x48_mapIcons;
CAssetId x74_areaHintDescId;
TLockedToken<CStringTable> x78_areaHintDesc;
CAssetId x88_mapAreaStringId;
TLockedToken<CStringTable> x8c_mapAreaString; // Used to be optional
u32 x9c_worldIdx = 0;
TAreaId xa0_curAreaId;
TAreaId xa4_otherAreaId;
SAutoMapperRenderState xa8_renderStates[3]; // xa8, x104, x160; current, next, prev
EAutoMapperState x1bc_state = EAutoMapperState::MiniMap;
EAutoMapperState x1c0_nextState = EAutoMapperState::MiniMap;
float x1c4_interpDur = 0.f;
float x1c8_interpTime = 0.f;
CSfxHandle x1cc_panningSfx;
CSfxHandle x1d0_rotatingSfx;
CSfxHandle x1d4_zoomingSfx;
float x1d8_flashTimer = 0.f;
float x1dc_playerFlashPulse = 0.f;
std::list<SAutoMapperHintStep> x1e0_hintSteps;
std::list<SAutoMapperHintLocation> x1f8_hintLocations;
rstl::reserved_vector<TLockedToken<CTexture>, 9> x210_lstick;
rstl::reserved_vector<TLockedToken<CTexture>, 9> x25c_cstick;
rstl::reserved_vector<TLockedToken<CTexture>, 2> x2a8_ltrigger;
rstl::reserved_vector<TLockedToken<CTexture>, 2> x2bc_rtrigger;
rstl::reserved_vector<TLockedToken<CTexture>, 2> x2d0_abutton;
u32 x2e4_lStickPos = 0;
u32 x2e8_rStickPos = 0;
u32 x2ec_lTriggerPos = 0;
u32 x2f0_rTriggerPos = 0;
u32 x2f4_aButtonPos = 0;
CGuiTextPane* x2f8_textpane_areaname = nullptr;
CGuiTextPane* x2fc_textpane_hint = nullptr;
CGuiTextPane* x300_textpane_instructions = nullptr;
CGuiTextPane* x304_textpane_instructions1 = nullptr;
CGuiTextPane* x308_textpane_instructions2 = nullptr;
CGuiWidget* x30c_basewidget_leftPane = nullptr;
CGuiWidget* x310_basewidget_yButtonPane = nullptr;
CGuiWidget* x314_basewidget_bottomPane = nullptr;
float x318_leftPanePos = 0.f;
float x31c_yButtonPanePos = 0.f;
float x320_bottomPanePos = 0.f;
EZoomState x324_zoomState = EZoomState::None;
u32 x328_ = 0;
bool x32c_loadingDummyWorld = false;
template <class T>
static void SetResLockState(T& list, bool lock)
{
for (auto& res : list)
if (lock)
res.Lock();
else
res.Unlock();
}
bool NotHintNavigating() const;
bool CanLeaveMapScreenInternal(const CStateManager& mgr) const;
void LeaveMapScreen(const CStateManager& mgr);
void SetupMiniMapWorld(const CStateManager& mgr);
bool HasCurrentMapUniverseWorld() const;
bool CheckDummyWorldLoad(const CStateManager& mgr);
void UpdateHintNavigation(float dt, const CStateManager& mgr);
static zeus::CVector2i GetMiniMapViewportSize();
static zeus::CVector2i GetMapScreenViewportSize();
static float GetMapAreaMiniMapDrawDepth() { return 2.f; }
float GetMapAreaMaxDrawDepth(const CStateManager&, TAreaId) const;
static float GetMapAreaMiniMapDrawAlphaSurfaceVisited(const CStateManager&);
static float GetMapAreaMiniMapDrawAlphaOutlineVisited(const CStateManager&);
static float GetMapAreaMiniMapDrawAlphaSurfaceUnvisited(const CStateManager&);
static float GetMapAreaMiniMapDrawAlphaOutlineUnvisited(const CStateManager&);
float GetDesiredMiniMapCameraDistance(const CStateManager&) const;
static float GetBaseMapScreenCameraMoveSpeed();
float GetClampedMapScreenCameraDistance(float);
float GetFinalMapScreenCameraMoveSpeed() const;
void ProcessMapRotateInput(const CFinalInput& input, const CStateManager& mgr);
void ProcessMapZoomInput(const CFinalInput& input, const CStateManager& mgr);
void ProcessMapPanInput(const CFinalInput& input, const CStateManager& mgr);
void SetShouldPanningSoundBePlaying(bool);
void SetShouldZoomingSoundBePlaying(bool);
void SetShouldRotatingSoundBePlaying(bool);
void TransformRenderStatesWorldToUniverse();
void TransformRenderStatesUniverseToWorld();
void TransformRenderStateWorldToUniverse(SAutoMapperRenderState&);
void SetupHintNavigation();
CAssetId GetAreaHintDescriptionString(CAssetId mreaId);
template <class T>
static void SetResLockState(T& list, bool lock) {
for (auto& res : list)
if (lock)
res.Lock();
else
res.Unlock();
}
bool NotHintNavigating() const;
bool CanLeaveMapScreenInternal(const CStateManager& mgr) const;
void LeaveMapScreen(const CStateManager& mgr);
void SetupMiniMapWorld(const CStateManager& mgr);
bool HasCurrentMapUniverseWorld() const;
bool CheckDummyWorldLoad(const CStateManager& mgr);
void UpdateHintNavigation(float dt, const CStateManager& mgr);
static zeus::CVector2i GetMiniMapViewportSize();
static zeus::CVector2i GetMapScreenViewportSize();
static float GetMapAreaMiniMapDrawDepth() { return 2.f; }
float GetMapAreaMaxDrawDepth(const CStateManager&, TAreaId) const;
static float GetMapAreaMiniMapDrawAlphaSurfaceVisited(const CStateManager&);
static float GetMapAreaMiniMapDrawAlphaOutlineVisited(const CStateManager&);
static float GetMapAreaMiniMapDrawAlphaSurfaceUnvisited(const CStateManager&);
static float GetMapAreaMiniMapDrawAlphaOutlineUnvisited(const CStateManager&);
float GetDesiredMiniMapCameraDistance(const CStateManager&) const;
static float GetBaseMapScreenCameraMoveSpeed();
float GetClampedMapScreenCameraDistance(float);
float GetFinalMapScreenCameraMoveSpeed() const;
void ProcessMapRotateInput(const CFinalInput& input, const CStateManager& mgr);
void ProcessMapZoomInput(const CFinalInput& input, const CStateManager& mgr);
void ProcessMapPanInput(const CFinalInput& input, const CStateManager& mgr);
void SetShouldPanningSoundBePlaying(bool);
void SetShouldZoomingSoundBePlaying(bool);
void SetShouldRotatingSoundBePlaying(bool);
void TransformRenderStatesWorldToUniverse();
void TransformRenderStatesUniverseToWorld();
void TransformRenderStateWorldToUniverse(SAutoMapperRenderState&);
void SetupHintNavigation();
CAssetId GetAreaHintDescriptionString(CAssetId mreaId);
public:
CAutoMapper(CStateManager& stateMgr);
bool CheckLoadComplete();
bool CanLeaveMapScreen(const CStateManager&) const;
float GetMapRotationX() const;
float GetMapRotationZ() const;
u32 GetFocusAreaIndex() const;
CAssetId GetCurrWorldAssetId() const;
void SetCurWorldAssetId(CAssetId mlvlId);
void MuteAllLoopedSounds();
void UnmuteAllLoopedSounds();
void ProcessControllerInput(const CFinalInput&, CStateManager&);
bool IsInPlayerControlState() const;
void Update(float dt, const CStateManager& mgr);
void Draw(const CStateManager&, const zeus::CTransform&, float) const;
bool IsInOrTransitioningToMapScreenState() const;
float GetTimeIntoInterpolation() const;
bool IsFullyInMapScreenState() const;
void BeginMapperStateTransition(EAutoMapperState, const CStateManager&);
void CompleteMapperStateTransition(const CStateManager&);
void ResetInterpolationTimer(float);
SAutoMapperRenderState BuildMiniMapWorldRenderState(const CStateManager&, const zeus::CQuaternion&, TAreaId) const;
SAutoMapperRenderState BuildMapScreenWorldRenderState(const CStateManager&, const zeus::CQuaternion&, TAreaId, bool) const;
SAutoMapperRenderState BuildMapScreenUniverseRenderState(const CStateManager&, const zeus::CQuaternion&, TAreaId) const;
void LeaveMapScreenState();
void ProcessMapScreenInput(const CFinalInput& input, const CStateManager& mgr);
zeus::CQuaternion GetMiniMapCameraOrientation(const CStateManager&) const;
zeus::CVector3f GetAreaPointOfInterest(const CStateManager&, TAreaId) const;
TAreaId FindClosestVisibleArea(const zeus::CVector3f&, const zeus::CUnitVector3f&, const CStateManager&,
const IWorld&, const CMapWorldInfo&) const;
std::pair<int, int>
FindClosestVisibleWorld(const zeus::CVector3f&, const zeus::CUnitVector3f&, const CStateManager&) const;
CAutoMapper(CStateManager& stateMgr);
bool CheckLoadComplete();
bool CanLeaveMapScreen(const CStateManager&) const;
float GetMapRotationX() const;
float GetMapRotationZ() const;
u32 GetFocusAreaIndex() const;
CAssetId GetCurrWorldAssetId() const;
void SetCurWorldAssetId(CAssetId mlvlId);
void MuteAllLoopedSounds();
void UnmuteAllLoopedSounds();
void ProcessControllerInput(const CFinalInput&, CStateManager&);
bool IsInPlayerControlState() const;
void Update(float dt, const CStateManager& mgr);
void Draw(const CStateManager&, const zeus::CTransform&, float) const;
bool IsInOrTransitioningToMapScreenState() const;
float GetTimeIntoInterpolation() const;
bool IsFullyInMapScreenState() const;
void BeginMapperStateTransition(EAutoMapperState, const CStateManager&);
void CompleteMapperStateTransition(const CStateManager&);
void ResetInterpolationTimer(float);
SAutoMapperRenderState BuildMiniMapWorldRenderState(const CStateManager&, const zeus::CQuaternion&, TAreaId) const;
SAutoMapperRenderState BuildMapScreenWorldRenderState(const CStateManager&, const zeus::CQuaternion&, TAreaId,
bool) const;
SAutoMapperRenderState BuildMapScreenUniverseRenderState(const CStateManager&, const zeus::CQuaternion&,
TAreaId) const;
void LeaveMapScreenState();
void ProcessMapScreenInput(const CFinalInput& input, const CStateManager& mgr);
zeus::CQuaternion GetMiniMapCameraOrientation(const CStateManager&) const;
zeus::CVector3f GetAreaPointOfInterest(const CStateManager&, TAreaId) const;
TAreaId FindClosestVisibleArea(const zeus::CVector3f&, const zeus::CUnitVector3f&, const CStateManager&,
const IWorld&, const CMapWorldInfo&) const;
std::pair<int, int> FindClosestVisibleWorld(const zeus::CVector3f&, const zeus::CUnitVector3f&,
const CStateManager&) const;
EAutoMapperState GetNextState() const { return x1c0_nextState; }
bool IsInMapperState(EAutoMapperState state) const
{
return state == x1bc_state && state == x1c0_nextState;
}
bool IsInMapperStateTransition() const
{
return x1c0_nextState != x1bc_state;
}
bool IsRenderStateInterpolating() const
{
return x1c8_interpTime < x1c4_interpDur;
}
bool IsStateTransitioning() const { return x1bc_state != x1c0_nextState; }
bool IsFullyInMiniMapState() const { return IsInMapperState(EAutoMapperState::MiniMap); }
bool IsFullyOutOfMiniMapState() const { return x1bc_state != EAutoMapperState::MiniMap &&
x1c0_nextState != EAutoMapperState::MiniMap; }
void OnNewInGameGuiState(EInGameGuiState, const CStateManager&);
float GetInterp() const
{
if (x1c4_interpDur > 0.f)
return x1c8_interpTime / x1c4_interpDur;
return 0.f;
}
EAutoMapperState GetNextState() const { return x1c0_nextState; }
bool IsInMapperState(EAutoMapperState state) const { return state == x1bc_state && state == x1c0_nextState; }
bool IsInMapperStateTransition() const { return x1c0_nextState != x1bc_state; }
bool IsRenderStateInterpolating() const { return x1c8_interpTime < x1c4_interpDur; }
bool IsStateTransitioning() const { return x1bc_state != x1c0_nextState; }
bool IsFullyInMiniMapState() const { return IsInMapperState(EAutoMapperState::MiniMap); }
bool IsFullyOutOfMiniMapState() const {
return x1bc_state != EAutoMapperState::MiniMap && x1c0_nextState != EAutoMapperState::MiniMap;
}
void OnNewInGameGuiState(EInGameGuiState, const CStateManager&);
float GetInterp() const {
if (x1c4_interpDur > 0.f)
return x1c8_interpTime / x1c4_interpDur;
return 0.f;
}
};
}
} // namespace urde

View File

@@ -6,126 +6,105 @@
#include "World/CGameArea.hpp"
#include "CResFactory.hpp"
namespace urde
{
namespace urde {
CMapArea::CMapArea(CInputStream& in, u32 size)
: x0_magic(in.readUint32()),
x4_version(in.readUint32Big()),
x8_(in.readUint32Big()),
xc_visibilityMode(EVisMode(in.readUint32Big())),
x10_box(zeus::CAABox::ReadBoundingBoxBig(in)),
x28_mappableObjCount(in.readUint32Big()),
x2c_vertexCount(in.readUint32Big()),
x30_surfaceCount(in.readUint32Big()),
x34_size(size - 52)
{
x44_buf.reset(new u8[x34_size]);
in.readUBytesToBuf(x44_buf.get(), x34_size);
PostConstruct();
: x0_magic(in.readUint32())
, x4_version(in.readUint32Big())
, x8_(in.readUint32Big())
, xc_visibilityMode(EVisMode(in.readUint32Big()))
, x10_box(zeus::CAABox::ReadBoundingBoxBig(in))
, x28_mappableObjCount(in.readUint32Big())
, x2c_vertexCount(in.readUint32Big())
, x30_surfaceCount(in.readUint32Big())
, x34_size(size - 52) {
x44_buf.reset(new u8[x34_size]);
in.readUBytesToBuf(x44_buf.get(), x34_size);
PostConstruct();
}
void CMapArea::PostConstruct()
{
x38_moStart = x44_buf.get();
x3c_vertexStart = x38_moStart + (x28_mappableObjCount * 0x50);
x40_surfaceStart = x3c_vertexStart + (x2c_vertexCount * 12);
void CMapArea::PostConstruct() {
x38_moStart = x44_buf.get();
x3c_vertexStart = x38_moStart + (x28_mappableObjCount * 0x50);
x40_surfaceStart = x3c_vertexStart + (x2c_vertexCount * 12);
m_mappableObjects.reserve(x28_mappableObjCount);
for (u32 i = 0, j=0 ; i<x28_mappableObjCount ; ++i, j += 0x50)
{
m_mappableObjects.emplace_back(x38_moStart + j);
m_mappableObjects.back().PostConstruct(x44_buf.get());
}
m_mappableObjects.reserve(x28_mappableObjCount);
for (u32 i = 0, j = 0; i < x28_mappableObjCount; ++i, j += 0x50) {
m_mappableObjects.emplace_back(x38_moStart + j);
m_mappableObjects.back().PostConstruct(x44_buf.get());
}
u8* tmp = x3c_vertexStart;
m_verts.reserve(x2c_vertexCount);
for (u32 i = 0 ; i<x2c_vertexCount ; ++i)
{
float* fl = reinterpret_cast<float*>(tmp);
m_verts.emplace_back(hecl::SBig(fl[0]), hecl::SBig(fl[1]), hecl::SBig(fl[2]));
tmp += 12;
}
u8* tmp = x3c_vertexStart;
m_verts.reserve(x2c_vertexCount);
for (u32 i = 0; i < x2c_vertexCount; ++i) {
float* fl = reinterpret_cast<float*>(tmp);
m_verts.emplace_back(hecl::SBig(fl[0]), hecl::SBig(fl[1]), hecl::SBig(fl[2]));
tmp += 12;
}
std::vector<u32> index;
m_surfaces.reserve(x30_surfaceCount);
for (u32 i = 0, j = 0 ; i<x30_surfaceCount ; ++i, j += 32)
{
m_surfaces.emplace_back(x40_surfaceStart + j);
m_surfaces.back().PostConstruct(x44_buf.get(), index);
}
std::vector<u32> index;
m_surfaces.reserve(x30_surfaceCount);
for (u32 i = 0, j = 0; i < x30_surfaceCount; ++i, j += 32) {
m_surfaces.emplace_back(x40_surfaceStart + j);
m_surfaces.back().PostConstruct(x44_buf.get(), index);
}
CGraphics::CommitResources([this, &index](boo::IGraphicsDataFactory::Context& ctx)
{
m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, m_verts.data(), 16, m_verts.size());
m_ibo = ctx.newStaticBuffer(boo::BufferUse::Index, index.data(), 4, index.size());
CGraphics::CommitResources([this, &index](boo::IGraphicsDataFactory::Context& ctx) {
m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, m_verts.data(), 16, m_verts.size());
m_ibo = ctx.newStaticBuffer(boo::BufferUse::Index, index.data(), 4, index.size());
/* Only the map universe specifies Always; it draws a maximum of 1016 instances */
size_t instCount = (xc_visibilityMode == EVisMode::Always) ? 1024 : 1;
/* Only the map universe specifies Always; it draws a maximum of 1016 instances */
size_t instCount = (xc_visibilityMode == EVisMode::Always) ? 1024 : 1;
for (u32 i = 0 ; i<x30_surfaceCount ; ++i)
{
CMapAreaSurface& surf = m_surfaces[i];
surf.m_instances.reserve(instCount);
for (u32 inst = 0 ; inst < instCount ; ++inst)
{
surf.m_instances.emplace_back(ctx, m_vbo, m_ibo);
CMapAreaSurface::Instance& instance = surf.m_instances.back();
for (u32 i = 0; i < x30_surfaceCount; ++i) {
CMapAreaSurface& surf = m_surfaces[i];
surf.m_instances.reserve(instCount);
for (u32 inst = 0; inst < instCount; ++inst) {
surf.m_instances.emplace_back(ctx, m_vbo, m_ibo);
CMapAreaSurface::Instance& instance = surf.m_instances.back();
athena::io::MemoryReader r(surf.x1c_outlineOffset, INT_MAX);
u32 outlineCount = r.readUint32Big();
athena::io::MemoryReader r(surf.x1c_outlineOffset, INT_MAX);
u32 outlineCount = r.readUint32Big();
std::vector<CLineRenderer>& linePrims = instance.m_linePrims;
linePrims.reserve(outlineCount * 2);
for (u32 j=0 ; j<2 ; ++j)
{
r.seek(4, athena::SeekOrigin::Begin);
for (u32 i=0 ; i<outlineCount ; ++i)
{
u32 count = r.readUint32Big();
r.seek(count);
r.seekAlign4();
linePrims.emplace_back(ctx, CLineRenderer::EPrimitiveMode::LineStrip, count,
nullptr, false, false, true);
}
}
}
std::vector<CLineRenderer>& linePrims = instance.m_linePrims;
linePrims.reserve(outlineCount * 2);
for (u32 j = 0; j < 2; ++j) {
r.seek(4, athena::SeekOrigin::Begin);
for (u32 i = 0; i < outlineCount; ++i) {
u32 count = r.readUint32Big();
r.seek(count);
r.seekAlign4();
linePrims.emplace_back(ctx, CLineRenderer::EPrimitiveMode::LineStrip, count, nullptr, false, false, true);
}
}
for (u32 i = 0 ; i<x28_mappableObjCount ; ++i)
{
CMappableObject& mapObj = m_mappableObjects[i];
if (CMappableObject::IsDoorType(mapObj.GetType()))
mapObj.m_doorSurface.emplace(ctx);
}
return true;
} BooTrace);
}
bool CMapArea::GetIsVisibleToAutoMapper(bool worldVis, bool areaVis) const
{
switch (xc_visibilityMode)
{
case EVisMode::Always:
return true;
case EVisMode::MapStationOrVisit:
return worldVis || areaVis;
case EVisMode::Visit:
return areaVis;
case EVisMode::Never:
return false;
default:
return true;
}
}
for (u32 i = 0; i < x28_mappableObjCount; ++i) {
CMappableObject& mapObj = m_mappableObjects[i];
if (CMappableObject::IsDoorType(mapObj.GetType()))
mapObj.m_doorSurface.emplace(ctx);
}
return true;
} BooTrace);
}
static const zeus::CVector3f MinesPostTransforms[3] =
{
{0.f, 0.f, 200.f},
{0.f, 0.f, 0.f},
{0.f, 0.f, -200.f}
};
static const u8 MinesPostTransformIndices[] =
{
bool CMapArea::GetIsVisibleToAutoMapper(bool worldVis, bool areaVis) const {
switch (xc_visibilityMode) {
case EVisMode::Always:
return true;
case EVisMode::MapStationOrVisit:
return worldVis || areaVis;
case EVisMode::Visit:
return areaVis;
case EVisMode::Never:
return false;
default:
return true;
}
}
static const zeus::CVector3f MinesPostTransforms[3] = {{0.f, 0.f, 200.f}, {0.f, 0.f, 0.f}, {0.f, 0.f, -200.f}};
static const u8 MinesPostTransformIndices[] = {
0, // 00 Transport to Tallon Overworld South
0, // 01 Quarry Access
0, // 02 Main Quarry
@@ -170,172 +149,145 @@ static const u8 MinesPostTransformIndices[] =
2, // 41 Fungal Hall A
};
zeus::CTransform CMapArea::GetAreaPostTransform(const IWorld& world, TAreaId aid) const
{
if (world.IGetWorldAssetId() == g_ResFactory->TranslateOriginalToNew(0xB1AC4D65)) // Phazon Mines
{
const zeus::CTransform& areaXf = world.IGetAreaAlways(aid)->IGetTM();
const zeus::CVector3f& postVec = MinesPostTransforms[MinesPostTransformIndices[aid]];
return zeus::CTransform::Translate(postVec) * areaXf;
}
else
{
return world.IGetAreaAlways(aid)->IGetTM();
}
zeus::CTransform CMapArea::GetAreaPostTransform(const IWorld& world, TAreaId aid) const {
if (world.IGetWorldAssetId() == g_ResFactory->TranslateOriginalToNew(0xB1AC4D65)) // Phazon Mines
{
const zeus::CTransform& areaXf = world.IGetAreaAlways(aid)->IGetTM();
const zeus::CVector3f& postVec = MinesPostTransforms[MinesPostTransformIndices[aid]];
return zeus::CTransform::Translate(postVec) * areaXf;
} else {
return world.IGetAreaAlways(aid)->IGetTM();
}
}
const zeus::CVector3f& CMapArea::GetAreaPostTranslate(const IWorld& world, TAreaId aid)
{
if (world.IGetWorldAssetId() == g_ResFactory->TranslateOriginalToNew(0xB1AC4D65)) // Phazon Mines
return MinesPostTransforms[MinesPostTransformIndices[aid]];
else
return zeus::CVector3f::skZero;
const zeus::CVector3f& CMapArea::GetAreaPostTranslate(const IWorld& world, TAreaId aid) {
if (world.IGetWorldAssetId() == g_ResFactory->TranslateOriginalToNew(0xB1AC4D65)) // Phazon Mines
return MinesPostTransforms[MinesPostTransformIndices[aid]];
else
return zeus::CVector3f::skZero;
}
CMapArea::CMapAreaSurface::CMapAreaSurface(const void* surfBuf)
{
athena::io::MemoryReader r(surfBuf, 32);
x0_normal = r.readVec3fBig();
xc_centroid = r.readVec3fBig();
x18_surfOffset = reinterpret_cast<const u8*>(uintptr_t(r.readUint32Big()));
x1c_outlineOffset = reinterpret_cast<const u8*>(uintptr_t(r.readUint32Big()));
CMapArea::CMapAreaSurface::CMapAreaSurface(const void* surfBuf) {
athena::io::MemoryReader r(surfBuf, 32);
x0_normal = r.readVec3fBig();
xc_centroid = r.readVec3fBig();
x18_surfOffset = reinterpret_cast<const u8*>(uintptr_t(r.readUint32Big()));
x1c_outlineOffset = reinterpret_cast<const u8*>(uintptr_t(r.readUint32Big()));
}
void CMapArea::CMapAreaSurface::PostConstruct(const u8* buf, std::vector<u32>& index)
{
x18_surfOffset = buf + reinterpret_cast<uintptr_t>(x18_surfOffset);
x1c_outlineOffset = buf + reinterpret_cast<uintptr_t>(x1c_outlineOffset);
void CMapArea::CMapAreaSurface::PostConstruct(const u8* buf, std::vector<u32>& index) {
x18_surfOffset = buf + reinterpret_cast<uintptr_t>(x18_surfOffset);
x1c_outlineOffset = buf + reinterpret_cast<uintptr_t>(x1c_outlineOffset);
m_primStart = index.size();
bool start = true;
{
athena::io::MemoryReader r(x18_surfOffset, INT_MAX);
u32 primCount = r.readUint32Big();
for (u32 i=0 ; i<primCount ; ++i)
{
GX::Primitive prim = GX::Primitive(r.readUint32Big());
u32 count = r.readUint32Big();
switch (prim)
{
case GX::Primitive::TRIANGLES:
{
for (u32 v=0 ; v<count ; v+=3)
{
if (!start)
{
index.push_back(index.back());
index.push_back(r.readUByte());
index.push_back(index.back());
}
else
{
index.push_back(r.readUByte());
start = false;
}
index.push_back(r.readUByte());
index.push_back(r.readUByte());
index.push_back(index.back());
}
break;
}
case GX::Primitive::TRIANGLESTRIP:
{
if (!start)
{
index.push_back(index.back());
index.push_back(r.readUByte());
index.push_back(index.back());
}
else
{
index.push_back(r.readUByte());
start = false;
}
for (u32 v=1 ; v<count ; ++v)
index.push_back(r.readUByte());
if (count & 1)
index.push_back(index.back());
break;
}
case GX::Primitive::TRIANGLEFAN:
{
u8 firstVert = r.readUByte();
if (!start)
{
index.push_back(index.back());
index.push_back(r.readUByte());
}
else
{
index.push_back(r.readUByte());
index.push_back(index.back());
start = false;
}
for (u32 v=1 ; v<count ; ++v)
{
index.push_back(firstVert);
index.push_back(r.readUByte());
}
break;
}
default: break;
}
r.seekAlign4();
m_primStart = index.size();
bool start = true;
{
athena::io::MemoryReader r(x18_surfOffset, INT_MAX);
u32 primCount = r.readUint32Big();
for (u32 i = 0; i < primCount; ++i) {
GX::Primitive prim = GX::Primitive(r.readUint32Big());
u32 count = r.readUint32Big();
switch (prim) {
case GX::Primitive::TRIANGLES: {
for (u32 v = 0; v < count; v += 3) {
if (!start) {
index.push_back(index.back());
index.push_back(r.readUByte());
index.push_back(index.back());
} else {
index.push_back(r.readUByte());
start = false;
}
index.push_back(r.readUByte());
index.push_back(r.readUByte());
index.push_back(index.back());
}
break;
}
case GX::Primitive::TRIANGLESTRIP: {
if (!start) {
index.push_back(index.back());
index.push_back(r.readUByte());
index.push_back(index.back());
} else {
index.push_back(r.readUByte());
start = false;
}
for (u32 v = 1; v < count; ++v)
index.push_back(r.readUByte());
if (count & 1)
index.push_back(index.back());
break;
}
case GX::Primitive::TRIANGLEFAN: {
u8 firstVert = r.readUByte();
if (!start) {
index.push_back(index.back());
index.push_back(r.readUByte());
} else {
index.push_back(r.readUByte());
index.push_back(index.back());
start = false;
}
for (u32 v = 1; v < count; ++v) {
index.push_back(firstVert);
index.push_back(r.readUByte());
}
break;
}
default:
break;
}
r.seekAlign4();
}
m_primCount = index.size() - m_primStart;
}
m_primCount = index.size() - m_primStart;
}
void CMapArea::CMapAreaSurface::Draw(const zeus::CVector3f* verts, const zeus::CColor& surfColor,
const zeus::CColor& lineColor, float lineWidth, int instIdx) const
{
if (instIdx >= m_instances.size())
return;
const zeus::CColor& lineColor, float lineWidth, int instIdx) const {
if (instIdx >= m_instances.size())
return;
Instance& instance = const_cast<Instance&>(m_instances[instIdx]);
Instance& instance = const_cast<Instance&>(m_instances[instIdx]);
if (surfColor.a())
instance.m_surfacePrims.draw(surfColor, m_primStart, m_primCount);
if (surfColor.a())
instance.m_surfacePrims.draw(surfColor, m_primStart, m_primCount);
if (lineColor.a())
{
bool draw2 = lineWidth > 1.f;
athena::io::MemoryReader r(x1c_outlineOffset, INT_MAX);
u32 outlineCount = r.readUint32Big();
if (lineColor.a()) {
bool draw2 = lineWidth > 1.f;
athena::io::MemoryReader r(x1c_outlineOffset, INT_MAX);
u32 outlineCount = r.readUint32Big();
std::vector<CLineRenderer>& linePrims = instance.m_linePrims;
zeus::CColor color = lineColor;
if (draw2)
color.a() *= 0.5f;
float width = lineWidth;
std::vector<CLineRenderer>& linePrims = instance.m_linePrims;
zeus::CColor color = lineColor;
if (draw2)
color.a() *= 0.5f;
float width = lineWidth;
auto primIt = linePrims.begin();
for (u32 j=0 ; j<=u32(draw2) ; ++j)
{
r.seek(4, athena::SeekOrigin::Begin);
for (u32 i=0 ; i<outlineCount ; ++i)
{
CLineRenderer& prim = *primIt++;
prim.Reset();
u32 count = r.readUint32Big();
for (u32 v=0 ; v<count ; ++v)
{
u8 idx = r.readUByte();
prim.AddVertex(verts[idx], color, width);
}
r.seekAlign4();
prim.Render();
}
width -= 1.f;
auto primIt = linePrims.begin();
for (u32 j = 0; j <= u32(draw2); ++j) {
r.seek(4, athena::SeekOrigin::Begin);
for (u32 i = 0; i < outlineCount; ++i) {
CLineRenderer& prim = *primIt++;
prim.Reset();
u32 count = r.readUint32Big();
for (u32 v = 0; v < count; ++v) {
u8 idx = r.readUByte();
prim.AddVertex(verts[idx], color, width);
}
r.seekAlign4();
prim.Render();
}
width -= 1.f;
}
}
}
CFactoryFnReturn FMapAreaFactory(const SObjectTag& objTag, CInputStream& in, const CVParamTransfer&,
CObjectReference*)
{
u32 size = g_ResFactory->ResourceSize(objTag);
return TToken<CMapArea>::GetIObjObjectFor(std::make_unique<CMapArea>(in, size));
CObjectReference*) {
u32 size = g_ResFactory->ResourceSize(objTag);
return TToken<CMapArea>::GetIObjObjectFor(std::make_unique<CMapArea>(in, size));
}
}
} // namespace urde

View File

@@ -9,85 +9,74 @@
#include "Graphics/Shaders/CMapSurfaceShader.hpp"
#include "CMappableObject.hpp"
namespace urde
{
namespace urde {
class IWorld;
class CMapArea
{
class CMapArea {
public:
class CMapAreaSurface
{
friend class CMapArea;
zeus::CVector3f x0_normal;
zeus::CVector3f xc_centroid;
const u8* x18_surfOffset;
const u8* x1c_outlineOffset;
u32 m_primStart;
u32 m_primCount;
struct Instance
{
CMapSurfaceShader m_surfacePrims;
std::vector<CLineRenderer> m_linePrims;
Instance(boo::IGraphicsDataFactory::Context& ctx,
const boo::ObjToken<boo::IGraphicsBufferS>& vbo,
const boo::ObjToken<boo::IGraphicsBufferS>& ibo)
: m_surfacePrims(ctx, vbo, ibo) {}
Instance(Instance&&) = default;
Instance& operator=(Instance&&) = default;
};
std::vector<Instance> m_instances;
public:
CMapAreaSurface(const void* surfBuf);
CMapAreaSurface(CMapAreaSurface&&) = default;
void PostConstruct(const u8* buf, std::vector<u32>& index);
void Draw(const zeus::CVector3f* verts, const zeus::CColor& surfColor,
const zeus::CColor& lineColor, float lineWidth, int instIdx=0) const;
const zeus::CVector3f& GetNormal() const { return x0_normal; }
const zeus::CVector3f& GetCenterPosition() const { return xc_centroid; }
};
enum class EVisMode
{
Always,
MapStationOrVisit,
Visit,
Never
class CMapAreaSurface {
friend class CMapArea;
zeus::CVector3f x0_normal;
zeus::CVector3f xc_centroid;
const u8* x18_surfOffset;
const u8* x1c_outlineOffset;
u32 m_primStart;
u32 m_primCount;
struct Instance {
CMapSurfaceShader m_surfacePrims;
std::vector<CLineRenderer> m_linePrims;
Instance(boo::IGraphicsDataFactory::Context& ctx, const boo::ObjToken<boo::IGraphicsBufferS>& vbo,
const boo::ObjToken<boo::IGraphicsBufferS>& ibo)
: m_surfacePrims(ctx, vbo, ibo) {}
Instance(Instance&&) = default;
Instance& operator=(Instance&&) = default;
};
std::vector<Instance> m_instances;
public:
CMapAreaSurface(const void* surfBuf);
CMapAreaSurface(CMapAreaSurface&&) = default;
void PostConstruct(const u8* buf, std::vector<u32>& index);
void Draw(const zeus::CVector3f* verts, const zeus::CColor& surfColor, const zeus::CColor& lineColor,
float lineWidth, int instIdx = 0) const;
const zeus::CVector3f& GetNormal() const { return x0_normal; }
const zeus::CVector3f& GetCenterPosition() const { return xc_centroid; }
};
enum class EVisMode { Always, MapStationOrVisit, Visit, Never };
private:
u32 x0_magic;
u32 x4_version;
u32 x8_;
EVisMode xc_visibilityMode;
zeus::CAABox x10_box;
u32 x28_mappableObjCount;
u32 x2c_vertexCount;
u32 x30_surfaceCount;
u32 x34_size;
u8* x38_moStart;
std::vector<CMappableObject> m_mappableObjects;
u8* x3c_vertexStart;
std::vector<zeus::CVector3f> m_verts;
u8* x40_surfaceStart;
std::vector<CMapAreaSurface> m_surfaces;
std::unique_ptr<u8[]> x44_buf;
boo::ObjToken<boo::IGraphicsBufferS> m_vbo;
boo::ObjToken<boo::IGraphicsBufferS> m_ibo;
u32 x0_magic;
u32 x4_version;
u32 x8_;
EVisMode xc_visibilityMode;
zeus::CAABox x10_box;
u32 x28_mappableObjCount;
u32 x2c_vertexCount;
u32 x30_surfaceCount;
u32 x34_size;
u8* x38_moStart;
std::vector<CMappableObject> m_mappableObjects;
u8* x3c_vertexStart;
std::vector<zeus::CVector3f> m_verts;
u8* x40_surfaceStart;
std::vector<CMapAreaSurface> m_surfaces;
std::unique_ptr<u8[]> x44_buf;
boo::ObjToken<boo::IGraphicsBufferS> m_vbo;
boo::ObjToken<boo::IGraphicsBufferS> m_ibo;
public:
CMapArea(CInputStream& in, u32 size);
void PostConstruct();
bool GetIsVisibleToAutoMapper(bool worldVis, bool areaVis) const;
zeus::CVector3f GetAreaCenterPoint() const { return x10_box.center(); }
const zeus::CAABox& GetBoundingBox() const { return x10_box; }
const CMappableObject& GetMappableObject(int idx) const { return m_mappableObjects[idx]; }
const CMapAreaSurface& GetSurface(int idx) const { return m_surfaces[idx]; }
u32 GetNumMappableObjects() const { return m_mappableObjects.size(); }
u32 GetNumSurfaces() const { return m_surfaces.size(); }
zeus::CTransform GetAreaPostTransform(const IWorld& world, TAreaId aid) const;
static const zeus::CVector3f& GetAreaPostTranslate(const IWorld& world, TAreaId aid);
const zeus::CVector3f* GetVertices() const { return m_verts.data(); }
CMapArea(CInputStream& in, u32 size);
void PostConstruct();
bool GetIsVisibleToAutoMapper(bool worldVis, bool areaVis) const;
zeus::CVector3f GetAreaCenterPoint() const { return x10_box.center(); }
const zeus::CAABox& GetBoundingBox() const { return x10_box; }
const CMappableObject& GetMappableObject(int idx) const { return m_mappableObjects[idx]; }
const CMapAreaSurface& GetSurface(int idx) const { return m_surfaces[idx]; }
u32 GetNumMappableObjects() const { return m_mappableObjects.size(); }
u32 GetNumSurfaces() const { return m_surfaces.size(); }
zeus::CTransform GetAreaPostTransform(const IWorld& world, TAreaId aid) const;
static const zeus::CVector3f& GetAreaPostTranslate(const IWorld& world, TAreaId aid);
const zeus::CVector3f* GetVertices() const { return m_verts.data(); }
};
CFactoryFnReturn FMapAreaFactory(const SObjectTag& objTag, CInputStream& in, const CVParamTransfer&,
CObjectReference*);
}
CFactoryFnReturn FMapAreaFactory(const SObjectTag& objTag, CInputStream& in, const CVParamTransfer&, CObjectReference*);
} // namespace urde

View File

@@ -3,140 +3,120 @@
#include "CSimplePool.hpp"
#include "CGameState.hpp"
namespace urde
{
namespace urde {
CMapUniverse::CMapUniverse(CInputStream& in, u32 version)
: x0_hexagonId(in.readUint32Big())
{
x4_hexagonToken = g_SimplePool->GetObj({FOURCC('MAPA'), x0_hexagonId});
u32 count = in.readUint32Big();
x10_worldDatas.reserve(count);
for (u32 i = 0 ; i<count ; ++i)
x10_worldDatas.emplace_back(in, version);
CMapUniverse::CMapUniverse(CInputStream& in, u32 version) : x0_hexagonId(in.readUint32Big()) {
x4_hexagonToken = g_SimplePool->GetObj({FOURCC('MAPA'), x0_hexagonId});
u32 count = in.readUint32Big();
x10_worldDatas.reserve(count);
for (u32 i = 0; i < count; ++i)
x10_worldDatas.emplace_back(in, version);
}
CMapUniverse::CMapWorldData::CMapWorldData(CInputStream& in, u32 version)
: x0_label(in.readString()),
x10_worldAssetId(in.readUint32Big())
{
x14_transform.read34RowMajor(in);
u32 worldCount = in.readUint32Big();
x44_hexagonXfs.reserve(worldCount);
for (u32 i = 0 ; i<worldCount ; ++i)
{
x44_hexagonXfs.emplace_back();
x44_hexagonXfs.back().read34RowMajor(in);
: x0_label(in.readString()), x10_worldAssetId(in.readUint32Big()) {
x14_transform.read34RowMajor(in);
u32 worldCount = in.readUint32Big();
x44_hexagonXfs.reserve(worldCount);
for (u32 i = 0; i < worldCount; ++i) {
x44_hexagonXfs.emplace_back();
x44_hexagonXfs.back().read34RowMajor(in);
}
if (version != 0)
x54_surfColorSelected.readRGBABig(in);
else
x54_surfColorSelected.fromRGBA32(255 | (u32(x10_worldAssetId.Value()) & 0xFFFFFF00));
x58_outlineColorSelected = zeus::CColor::lerp(zeus::CColor::skWhite, x54_surfColorSelected, 0.5f);
x5c_surfColorUnselected = zeus::CColor::lerp(zeus::CColor::skBlack, x54_surfColorSelected, 0.5f);
x60_outlineColorUnselected = zeus::CColor::lerp(zeus::CColor::skWhite, x5c_surfColorUnselected, 0.5f);
for (const zeus::CTransform& xf : x44_hexagonXfs)
x64_centerPoint += xf.origin;
x64_centerPoint *= zeus::CVector3f(1.0f / float(x44_hexagonXfs.size()));
}
void CMapUniverse::Draw(const CMapUniverseDrawParms& parms, const zeus::CVector3f&, float, float) const {
if (!x4_hexagonToken.IsLoaded())
return;
u32 totalSurfaceCount = 0;
for (const CMapWorldData& data : x10_worldDatas)
totalSurfaceCount += data.GetNumMapAreaDatas() * x4_hexagonToken->GetNumSurfaces();
std::vector<CMapObjectSortInfo> sortInfos;
sortInfos.reserve(totalSurfaceCount);
for (int w = 0; w < x10_worldDatas.size(); ++w) {
const CMapWorldData& data = x10_worldDatas[w];
const CMapWorldInfo& mwInfo = *g_GameState->StateForWorld(data.GetWorldAssetId()).MapWorldInfo();
if (!mwInfo.IsAnythingSet())
continue;
zeus::CColor surfColor, outlineColor;
if (w == parms.GetFocusWorldIndex()) {
surfColor = data.GetSurfaceColorSelected();
surfColor.a() *= parms.GetAlpha();
outlineColor = data.GetOutlineColorSelected();
outlineColor.a() *= parms.GetAlpha();
} else {
surfColor = data.GetSurfaceColorUnselected();
surfColor.a() *= parms.GetAlpha();
outlineColor = data.GetSurfaceColorUnselected();
outlineColor.a() *= parms.GetAlpha();
}
if (version != 0)
x54_surfColorSelected.readRGBABig(in);
else
x54_surfColorSelected.fromRGBA32(255 | (u32(x10_worldAssetId.Value()) & 0xFFFFFF00));
for (int h = 0; h < data.GetNumMapAreaDatas(); ++h) {
zeus::CTransform hexXf = parms.GetCameraTransform().inverse() * data.GetMapAreaData(h);
for (int s = 0; s < x4_hexagonToken->GetNumSurfaces(); ++s) {
const CMapArea::CMapAreaSurface& surf = x4_hexagonToken->GetSurface(s);
zeus::CVector3f centerPos = hexXf * surf.GetCenterPosition();
sortInfos.emplace_back(centerPos.y(), w, h, s, surfColor, outlineColor);
}
}
}
x58_outlineColorSelected = zeus::CColor::lerp(zeus::CColor::skWhite, x54_surfColorSelected, 0.5f);
x5c_surfColorUnselected = zeus::CColor::lerp(zeus::CColor::skBlack, x54_surfColorSelected, 0.5f);
x60_outlineColorUnselected = zeus::CColor::lerp(zeus::CColor::skWhite, x5c_surfColorUnselected, 0.5f);
std::sort(sortInfos.begin(), sortInfos.end(), [](const CMapObjectSortInfo& a, const CMapObjectSortInfo& b) {
return a.GetZDistance() > b.GetZDistance();
});
for (const zeus::CTransform& xf : x44_hexagonXfs)
x64_centerPoint += xf.origin;
x64_centerPoint *= zeus::CVector3f(1.0f / float(x44_hexagonXfs.size()));
}
void CMapUniverse::Draw(const CMapUniverseDrawParms& parms, const zeus::CVector3f&, float, float) const
{
if (!x4_hexagonToken.IsLoaded())
return;
u32 totalSurfaceCount = 0;
for (const CMapWorldData& data : x10_worldDatas)
totalSurfaceCount += data.GetNumMapAreaDatas() * x4_hexagonToken->GetNumSurfaces();
std::vector<CMapObjectSortInfo> sortInfos;
sortInfos.reserve(totalSurfaceCount);
for (int w=0 ; w<x10_worldDatas.size() ; ++w)
{
const CMapWorldData& data = x10_worldDatas[w];
const CMapWorldInfo& mwInfo = *g_GameState->StateForWorld(data.GetWorldAssetId()).MapWorldInfo();
if (!mwInfo.IsAnythingSet())
continue;
zeus::CColor surfColor, outlineColor;
if (w == parms.GetFocusWorldIndex())
{
surfColor = data.GetSurfaceColorSelected();
surfColor.a() *= parms.GetAlpha();
outlineColor = data.GetOutlineColorSelected();
outlineColor.a() *= parms.GetAlpha();
}
else
{
surfColor = data.GetSurfaceColorUnselected();
surfColor.a() *= parms.GetAlpha();
outlineColor = data.GetSurfaceColorUnselected();
outlineColor.a() *= parms.GetAlpha();
}
for (int h=0 ; h<data.GetNumMapAreaDatas() ; ++h)
{
zeus::CTransform hexXf = parms.GetCameraTransform().inverse() * data.GetMapAreaData(h);
for (int s=0 ; s<x4_hexagonToken->GetNumSurfaces() ; ++s)
{
const CMapArea::CMapAreaSurface& surf = x4_hexagonToken->GetSurface(s);
zeus::CVector3f centerPos = hexXf * surf.GetCenterPosition();
sortInfos.emplace_back(centerPos.y(), w, h, s, surfColor, outlineColor);
}
}
int lastWldIdx = -1;
int lastHexIdx = -1;
int instIdx = 0;
for (const CMapObjectSortInfo& info : sortInfos) {
const CMapWorldData& mwData = x10_worldDatas[info.GetWorldIndex()];
zeus::CColor surfColor = info.GetSurfaceColor();
zeus::CColor outlineColor = info.GetOutlineColor();
if (parms.GetWorldAssetId() == mwData.GetWorldAssetId() && parms.GetClosestArea() == info.GetAreaIndex()) {
surfColor = zeus::CColor::lerp(g_tweakAutoMapper->GetSurfaceSelectVisitedColor(),
g_tweakAutoMapper->GetAreaFlashPulseColor(), parms.GetFlashPulse());
surfColor.a() = info.GetSurfaceColor().a();
outlineColor = zeus::CColor::lerp(g_tweakAutoMapper->GetOutlineSelectVisitedColor(),
g_tweakAutoMapper->GetAreaFlashPulseColor(), parms.GetFlashPulse());
outlineColor.a() = info.GetOutlineColor().a();
}
std::sort(sortInfos.begin(), sortInfos.end(),
[](const CMapObjectSortInfo& a, const CMapObjectSortInfo& b)
{
return a.GetZDistance() > b.GetZDistance();
});
zeus::CTransform hexXf = mwData.GetMapAreaData(info.GetAreaIndex());
hexXf.orthonormalize();
const CMapArea::CMapAreaSurface& surf = x4_hexagonToken->GetSurface(info.GetObjectIndex());
zeus::CColor color(std::max(0.f, (-parms.GetCameraTransform().basis[1]).dot(hexXf.rotate(surf.GetNormal()))) *
g_tweakAutoMapper->GetMapSurfaceNormColorLinear() +
g_tweakAutoMapper->GetMapSurfaceNormColorConstant());
surfColor *= color;
int lastWldIdx = -1;
int lastHexIdx = -1;
int instIdx = 0;
for (const CMapObjectSortInfo& info : sortInfos)
{
const CMapWorldData& mwData = x10_worldDatas[info.GetWorldIndex()];
zeus::CColor surfColor = info.GetSurfaceColor();
zeus::CColor outlineColor = info.GetOutlineColor();
if (parms.GetWorldAssetId() == mwData.GetWorldAssetId() && parms.GetClosestArea() == info.GetAreaIndex())
{
surfColor = zeus::CColor::lerp(g_tweakAutoMapper->GetSurfaceSelectVisitedColor(),
g_tweakAutoMapper->GetAreaFlashPulseColor(),
parms.GetFlashPulse());
surfColor.a() = info.GetSurfaceColor().a();
outlineColor = zeus::CColor::lerp(g_tweakAutoMapper->GetOutlineSelectVisitedColor(),
g_tweakAutoMapper->GetAreaFlashPulseColor(),
parms.GetFlashPulse());
outlineColor.a() = info.GetOutlineColor().a();
}
if (info.GetAreaIndex() != lastHexIdx || info.GetWorldIndex() != lastWldIdx)
CGraphics::SetModelMatrix(parms.GetPaneProjectionTransform() * mwData.GetMapAreaData(info.GetAreaIndex()));
zeus::CTransform hexXf = mwData.GetMapAreaData(info.GetAreaIndex());
hexXf.orthonormalize();
const CMapArea::CMapAreaSurface& surf = x4_hexagonToken->GetSurface(info.GetObjectIndex());
zeus::CColor color(std::max(0.f, (-parms.GetCameraTransform().basis[1]).dot(hexXf.rotate(surf.GetNormal()))) *
g_tweakAutoMapper->GetMapSurfaceNormColorLinear() + g_tweakAutoMapper->GetMapSurfaceNormColorConstant());
surfColor *= color;
if (info.GetAreaIndex() != lastHexIdx || info.GetWorldIndex() != lastWldIdx)
CGraphics::SetModelMatrix(parms.GetPaneProjectionTransform() * mwData.GetMapAreaData(info.GetAreaIndex()));
surf.Draw(x4_hexagonToken->GetVertices(), surfColor, outlineColor, 2.f, instIdx++);
}
surf.Draw(x4_hexagonToken->GetVertices(), surfColor, outlineColor, 2.f, instIdx++);
}
}
CFactoryFnReturn FMapUniverseFactory(const SObjectTag&, CInputStream& in, const CVParamTransfer&,
CObjectReference*)
{
in.readUint32Big();
u32 version = in.readUint32Big();
CFactoryFnReturn FMapUniverseFactory(const SObjectTag&, CInputStream& in, const CVParamTransfer&, CObjectReference*) {
in.readUint32Big();
u32 version = in.readUint32Big();
return TToken<CMapUniverse>::GetIObjObjectFor(std::make_unique<CMapUniverse>(in, version));
return TToken<CMapUniverse>::GetIObjObjectFor(std::make_unique<CMapUniverse>(in, version));
}
}
} // namespace urde

View File

@@ -8,115 +8,116 @@
#include "CToken.hpp"
#include "CMapArea.hpp"
namespace urde
{
namespace urde {
class CStateManager;
class CMapUniverse
{
class CMapUniverse {
public:
class CMapUniverseDrawParms
{
float x0_alpha;
int x4_wldIdx;
CAssetId x8_wldRes;
int xc_closestHex;
float x10_flashPulse;
//const CStateManager& x14_mgr;
const zeus::CTransform& x18_model;
const zeus::CTransform& x1c_view;
public:
CMapUniverseDrawParms(float alpha, int wldIdx, CAssetId wldRes, int closestHex,
float flashPulse, const CStateManager& mgr,
const zeus::CTransform& model, const zeus::CTransform& view)
: x0_alpha(alpha),
x4_wldIdx(wldIdx),
x8_wldRes(wldRes),
xc_closestHex(closestHex),
x10_flashPulse(flashPulse),
//x14_mgr(mgr),
x18_model(model),
x1c_view(view)
{}
int GetFocusWorldIndex() const { return x4_wldIdx; }
const zeus::CTransform& GetCameraTransform() const { return x1c_view; }
const zeus::CTransform& GetPaneProjectionTransform() const { return x18_model; }
float GetAlpha() const { return x0_alpha; }
CAssetId GetWorldAssetId() const { return x8_wldRes; }
int GetClosestArea() const { return xc_closestHex; }
float GetFlashPulse() const { return x10_flashPulse; }
};
class CMapUniverseDrawParms {
float x0_alpha;
int x4_wldIdx;
CAssetId x8_wldRes;
int xc_closestHex;
float x10_flashPulse;
// const CStateManager& x14_mgr;
const zeus::CTransform& x18_model;
const zeus::CTransform& x1c_view;
class CMapObjectSortInfo
{
float x0_zDist;
int x4_wldIdx;
int x8_hexIdx;
int xc_surfIdx;
zeus::CColor x10_surfColor;
zeus::CColor x14_outlineColor;
public:
CMapObjectSortInfo(float zDist, int wldIdx, int hexIdx, int surfIdx,
const zeus::CColor& surf, const zeus::CColor& outline)
: x0_zDist(zDist), x4_wldIdx(wldIdx), x8_hexIdx(hexIdx), xc_surfIdx(surfIdx),
x10_surfColor(surf), x14_outlineColor(outline) {}
const zeus::CColor& GetOutlineColor() const { return x14_outlineColor; }
const zeus::CColor& GetSurfaceColor() const { return x10_surfColor; }
int GetObjectIndex() const { return xc_surfIdx; }
int GetAreaIndex() const { return x8_hexIdx; }
int GetWorldIndex() const { return x4_wldIdx; }
float GetZDistance() const { return x0_zDist; }
};
public:
CMapUniverseDrawParms(float alpha, int wldIdx, CAssetId wldRes, int closestHex, float flashPulse,
const CStateManager& mgr, const zeus::CTransform& model, const zeus::CTransform& view)
: x0_alpha(alpha)
, x4_wldIdx(wldIdx)
, x8_wldRes(wldRes)
, xc_closestHex(closestHex)
, x10_flashPulse(flashPulse)
,
// x14_mgr(mgr),
x18_model(model)
, x1c_view(view) {}
int GetFocusWorldIndex() const { return x4_wldIdx; }
const zeus::CTransform& GetCameraTransform() const { return x1c_view; }
const zeus::CTransform& GetPaneProjectionTransform() const { return x18_model; }
float GetAlpha() const { return x0_alpha; }
CAssetId GetWorldAssetId() const { return x8_wldRes; }
int GetClosestArea() const { return xc_closestHex; }
float GetFlashPulse() const { return x10_flashPulse; }
};
class CMapWorldData
{
std::string x0_label;
CAssetId x10_worldAssetId;
zeus::CTransform x14_transform;
std::vector<zeus::CTransform> x44_hexagonXfs;
zeus::CColor x54_surfColorSelected;
zeus::CColor x58_outlineColorSelected = zeus::CColor(1.0f, 0.0f, 1.0f);
zeus::CColor x5c_surfColorUnselected = zeus::CColor(1.0f, 0.0f, 1.0f);
zeus::CColor x60_outlineColorUnselected = zeus::CColor(1.0f, 0.0f, 1.0f);
zeus::CVector3f x64_centerPoint = zeus::CVector3f::skZero;
public:
CMapWorldData(CInputStream& in, u32 version);
CAssetId GetWorldAssetId() const { return x10_worldAssetId; }
const zeus::CVector3f& GetWorldCenterPoint() const { return x64_centerPoint; }
std::string_view GetWorldLabel() const { return x0_label; }
const zeus::CTransform& GetWorldTransform() const { return x14_transform; }
const zeus::CTransform& GetMapAreaData(s32 idx) const { return x44_hexagonXfs[idx]; }
u32 GetNumMapAreaDatas() const { return x44_hexagonXfs.size(); }
const zeus::CColor& GetOutlineColorUnselected() const { return x60_outlineColorUnselected; }
const zeus::CColor& GetOutlineColorSelected() const { return x58_outlineColorSelected; }
const zeus::CColor& GetSurfaceColorUnselected() const { return x5c_surfColorUnselected; }
const zeus::CColor& GetSurfaceColorSelected() const { return x54_surfColorSelected; }
};
class CMapObjectSortInfo {
float x0_zDist;
int x4_wldIdx;
int x8_hexIdx;
int xc_surfIdx;
zeus::CColor x10_surfColor;
zeus::CColor x14_outlineColor;
public:
CMapObjectSortInfo(float zDist, int wldIdx, int hexIdx, int surfIdx, const zeus::CColor& surf,
const zeus::CColor& outline)
: x0_zDist(zDist)
, x4_wldIdx(wldIdx)
, x8_hexIdx(hexIdx)
, xc_surfIdx(surfIdx)
, x10_surfColor(surf)
, x14_outlineColor(outline) {}
const zeus::CColor& GetOutlineColor() const { return x14_outlineColor; }
const zeus::CColor& GetSurfaceColor() const { return x10_surfColor; }
int GetObjectIndex() const { return xc_surfIdx; }
int GetAreaIndex() const { return x8_hexIdx; }
int GetWorldIndex() const { return x4_wldIdx; }
float GetZDistance() const { return x0_zDist; }
};
class CMapWorldData {
std::string x0_label;
CAssetId x10_worldAssetId;
zeus::CTransform x14_transform;
std::vector<zeus::CTransform> x44_hexagonXfs;
zeus::CColor x54_surfColorSelected;
zeus::CColor x58_outlineColorSelected = zeus::CColor(1.0f, 0.0f, 1.0f);
zeus::CColor x5c_surfColorUnselected = zeus::CColor(1.0f, 0.0f, 1.0f);
zeus::CColor x60_outlineColorUnselected = zeus::CColor(1.0f, 0.0f, 1.0f);
zeus::CVector3f x64_centerPoint = zeus::CVector3f::skZero;
public:
CMapWorldData(CInputStream& in, u32 version);
CAssetId GetWorldAssetId() const { return x10_worldAssetId; }
const zeus::CVector3f& GetWorldCenterPoint() const { return x64_centerPoint; }
std::string_view GetWorldLabel() const { return x0_label; }
const zeus::CTransform& GetWorldTransform() const { return x14_transform; }
const zeus::CTransform& GetMapAreaData(s32 idx) const { return x44_hexagonXfs[idx]; }
u32 GetNumMapAreaDatas() const { return x44_hexagonXfs.size(); }
const zeus::CColor& GetOutlineColorUnselected() const { return x60_outlineColorUnselected; }
const zeus::CColor& GetOutlineColorSelected() const { return x58_outlineColorSelected; }
const zeus::CColor& GetSurfaceColorUnselected() const { return x5c_surfColorUnselected; }
const zeus::CColor& GetSurfaceColorSelected() const { return x54_surfColorSelected; }
};
private:
CAssetId x0_hexagonId;
TLockedToken<CMapArea> x4_hexagonToken;
std::vector<CMapWorldData> x10_worldDatas;
zeus::CVector3f x20_universeCenter = zeus::CVector3f::skZero;
float x2c_universeRadius = 1600.f;
CAssetId x0_hexagonId;
TLockedToken<CMapArea> x4_hexagonToken;
std::vector<CMapWorldData> x10_worldDatas;
zeus::CVector3f x20_universeCenter = zeus::CVector3f::skZero;
float x2c_universeRadius = 1600.f;
public:
CMapUniverse(CInputStream&, u32);
const CMapWorldData& GetMapWorldData(s32 idx) const { return x10_worldDatas[idx]; }
const CMapWorldData& GetMapWorldDataByWorldId(CAssetId id) const
{
for (const CMapWorldData& data : x10_worldDatas)
if (data.GetWorldAssetId() == id)
return data;
return x10_worldDatas.front();
}
u32 GetNumMapWorldDatas() const { return x10_worldDatas.size(); }
float GetMapUniverseRadius() const { return x2c_universeRadius; }
const zeus::CVector3f& GetMapUniverseCenterPoint() const { return x20_universeCenter; }
void Draw(const CMapUniverseDrawParms&, const zeus::CVector3f&, float, float) const;
std::vector<CMapWorldData>::const_iterator begin() const { return x10_worldDatas.cbegin(); }
std::vector<CMapWorldData>::const_iterator end() const { return x10_worldDatas.cend(); }
CMapUniverse(CInputStream&, u32);
const CMapWorldData& GetMapWorldData(s32 idx) const { return x10_worldDatas[idx]; }
const CMapWorldData& GetMapWorldDataByWorldId(CAssetId id) const {
for (const CMapWorldData& data : x10_worldDatas)
if (data.GetWorldAssetId() == id)
return data;
return x10_worldDatas.front();
}
u32 GetNumMapWorldDatas() const { return x10_worldDatas.size(); }
float GetMapUniverseRadius() const { return x2c_universeRadius; }
const zeus::CVector3f& GetMapUniverseCenterPoint() const { return x20_universeCenter; }
void Draw(const CMapUniverseDrawParms&, const zeus::CVector3f&, float, float) const;
std::vector<CMapWorldData>::const_iterator begin() const { return x10_worldDatas.cbegin(); }
std::vector<CMapWorldData>::const_iterator end() const { return x10_worldDatas.cend(); }
};
CFactoryFnReturn FMapUniverseFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms,
CObjectReference*);
}
} // namespace urde

File diff suppressed because it is too large Load Diff

View File

@@ -7,169 +7,155 @@
#include "zeus/CTransform.hpp"
#include "CMapArea.hpp"
namespace urde
{
namespace urde {
class IWorld;
class CMapWorldInfo;
class CStateManager;
class CMapWorld
{
class CMapWorld {
public:
/* skDrawProfileItemNames; */
enum class EMapAreaList
{
Loaded,
Loading,
Unloaded
};
/* skDrawProfileItemNames; */
enum class EMapAreaList { Loaded, Loading, Unloaded };
class CMapAreaBFSInfo
{
int x0_areaIdx;
int x4_depth;
float x8_surfDrawDepth;
float xc_outlineDrawDepth;
public:
CMapAreaBFSInfo(int areaIdx, int depth, float a, float b)
: x0_areaIdx(areaIdx), x4_depth(depth), x8_surfDrawDepth(a), xc_outlineDrawDepth(b) {}
int GetAreaIndex() const { return x0_areaIdx; }
int GetDepth() const { return x4_depth; }
float GetOutlineDrawDepth() const { return x8_surfDrawDepth; }
float GetSurfaceDrawDepth() const { return xc_outlineDrawDepth; }
};
class CMapAreaBFSInfo {
int x0_areaIdx;
int x4_depth;
float x8_surfDrawDepth;
float xc_outlineDrawDepth;
class CMapObjectSortInfo
{
float x0_zDist;
int x4_areaIdx;
int x8_typeAndIdx;
zeus::CColor xc_surfColor;
zeus::CColor x10_outlineColor;
public:
enum class EObjectCode
{
Invalid = -1,
Object = 1 << 16,
DoorSurface = 2 << 16,
Door = 3 << 16,
Surface = 4 << 16
};
public:
CMapAreaBFSInfo(int areaIdx, int depth, float a, float b)
: x0_areaIdx(areaIdx), x4_depth(depth), x8_surfDrawDepth(a), xc_outlineDrawDepth(b) {}
int GetAreaIndex() const { return x0_areaIdx; }
int GetDepth() const { return x4_depth; }
float GetOutlineDrawDepth() const { return x8_surfDrawDepth; }
float GetSurfaceDrawDepth() const { return xc_outlineDrawDepth; }
};
CMapObjectSortInfo(float zDist, int areaIdx, EObjectCode type, int idx,
const zeus::CColor& surfColor, const zeus::CColor& outlineColor)
: x0_zDist(zDist), x4_areaIdx(areaIdx), x8_typeAndIdx(int(type) | idx),
xc_surfColor(surfColor), x10_outlineColor(outlineColor) {}
const zeus::CColor& GetOutlineColor() const { return x10_outlineColor; }
const zeus::CColor& GetSurfaceColor() const { return xc_surfColor; }
u32 GetLocalObjectIndex() const { return x8_typeAndIdx & 0xffff; }
EObjectCode GetObjectCode() const { return EObjectCode(x8_typeAndIdx & 0xffff0000); }
u32 GetAreaIndex() const { return x4_areaIdx; }
float GetZDistance() const { return x0_zDist; }
};
class CMapObjectSortInfo {
float x0_zDist;
int x4_areaIdx;
int x8_typeAndIdx;
zeus::CColor xc_surfColor;
zeus::CColor x10_outlineColor;
class CMapAreaData
{
TCachedToken<CMapArea> x0_area;
EMapAreaList x10_list;
CMapAreaData* x14_next = nullptr;
public:
CMapAreaData(CAssetId areaRes, EMapAreaList list, CMapAreaData* next);
void Lock() { x0_area.Lock(); }
void Unlock() { x0_area.Unlock(); }
bool IsLoaded() const { return x0_area.IsLoaded(); }
const CMapArea* GetMapArea() const { return x0_area.GetObj(); }
const CMapAreaData* GetNextMapAreaData() const { return x14_next; }
EMapAreaList GetContainingList() const { return x10_list; }
CMapAreaData* NextMapAreaData() { return x14_next; }
void SetContainingList(EMapAreaList list) { x10_list = list; }
void SetNextMapArea(CMapAreaData* next) { x14_next = next; }
};
public:
enum class EObjectCode { Invalid = -1, Object = 1 << 16, DoorSurface = 2 << 16, Door = 3 << 16, Surface = 4 << 16 };
class CMapWorldDrawParms
{
float x0_alphaSurfVisited;
float x4_alphaOlVisited;
float x8_alphaSurfUnvisited;
float xc_alphaOlUnvisited;
float x10_alpha;
float x14_outlineWidthScale;
const CStateManager& x18_mgr;
const zeus::CTransform& x1c_modelXf;
const zeus::CTransform& x20_viewXf;
const IWorld& x24_wld;
const CMapWorldInfo& x28_mwInfo;
float x2c_playerFlashIntensity;
float x30_hintFlashIntensity;
float x34_objectScale;
bool x38_sortDoorSurfs;
public:
CMapWorldDrawParms(float alphaSurfVisited, float alphaOlVisited,
float alphaSurfUnvisited, float alphaOlUnvisited,
float alpha, float outlineWidthScale, const CStateManager& mgr,
const zeus::CTransform& modelXf, const zeus::CTransform& viewXf,
const IWorld& wld, const CMapWorldInfo& mwInfo, float playerFlash,
float hintFlash, float objectScale, bool sortDoorSurfs)
: x0_alphaSurfVisited(alphaSurfVisited),
x4_alphaOlVisited(alphaOlVisited),
x8_alphaSurfUnvisited(alphaSurfUnvisited),
xc_alphaOlUnvisited(alphaOlUnvisited),
x10_alpha(alpha),
x14_outlineWidthScale(outlineWidthScale),
x18_mgr(mgr),
x1c_modelXf(modelXf),
x20_viewXf(viewXf),
x24_wld(wld),
x28_mwInfo(mwInfo),
x2c_playerFlashIntensity(playerFlash),
x30_hintFlashIntensity(hintFlash),
x34_objectScale(objectScale),
x38_sortDoorSurfs(sortDoorSurfs)
{}
const IWorld& GetWorld() const { return x24_wld; }
float GetOutlineWidthScale() const { return x14_outlineWidthScale; }
const zeus::CTransform& GetPlaneProjectionTransform() const { return x1c_modelXf; }
float GetHintAreaFlashIntensity() const { return x30_hintFlashIntensity; }
float GetPlayerAreaFlashIntensity() const { return x2c_playerFlashIntensity; }
const zeus::CTransform& GetCameraTransform() const { return x20_viewXf; }
float GetAlphaOutlineUnvisited() const { return xc_alphaOlUnvisited; }
float GetAlphaSurfaceUnvisited() const { return x8_alphaSurfUnvisited; }
float GetAlphaOutlineVisited() const { return x4_alphaOlVisited; }
float GetAlphaSurfaceVisited() const { return x0_alphaSurfVisited; }
float GetAlpha() const { return x10_alpha; }
const CMapWorldInfo& GetMapWorldInfo() const { return x28_mwInfo; }
const CStateManager& GetStateManager() const { return x18_mgr; }
bool GetIsSortDoorSurfaces() const { return x38_sortDoorSurfs; }
float GetObjectScale() const { return x34_objectScale; }
};
CMapObjectSortInfo(float zDist, int areaIdx, EObjectCode type, int idx, const zeus::CColor& surfColor,
const zeus::CColor& outlineColor)
: x0_zDist(zDist)
, x4_areaIdx(areaIdx)
, x8_typeAndIdx(int(type) | idx)
, xc_surfColor(surfColor)
, x10_outlineColor(outlineColor) {}
const zeus::CColor& GetOutlineColor() const { return x10_outlineColor; }
const zeus::CColor& GetSurfaceColor() const { return xc_surfColor; }
u32 GetLocalObjectIndex() const { return x8_typeAndIdx & 0xffff; }
EObjectCode GetObjectCode() const { return EObjectCode(x8_typeAndIdx & 0xffff0000); }
u32 GetAreaIndex() const { return x4_areaIdx; }
float GetZDistance() const { return x0_zDist; }
};
class CMapAreaData {
TCachedToken<CMapArea> x0_area;
EMapAreaList x10_list;
CMapAreaData* x14_next = nullptr;
public:
CMapAreaData(CAssetId areaRes, EMapAreaList list, CMapAreaData* next);
void Lock() { x0_area.Lock(); }
void Unlock() { x0_area.Unlock(); }
bool IsLoaded() const { return x0_area.IsLoaded(); }
const CMapArea* GetMapArea() const { return x0_area.GetObj(); }
const CMapAreaData* GetNextMapAreaData() const { return x14_next; }
EMapAreaList GetContainingList() const { return x10_list; }
CMapAreaData* NextMapAreaData() { return x14_next; }
void SetContainingList(EMapAreaList list) { x10_list = list; }
void SetNextMapArea(CMapAreaData* next) { x14_next = next; }
};
class CMapWorldDrawParms {
float x0_alphaSurfVisited;
float x4_alphaOlVisited;
float x8_alphaSurfUnvisited;
float xc_alphaOlUnvisited;
float x10_alpha;
float x14_outlineWidthScale;
const CStateManager& x18_mgr;
const zeus::CTransform& x1c_modelXf;
const zeus::CTransform& x20_viewXf;
const IWorld& x24_wld;
const CMapWorldInfo& x28_mwInfo;
float x2c_playerFlashIntensity;
float x30_hintFlashIntensity;
float x34_objectScale;
bool x38_sortDoorSurfs;
public:
CMapWorldDrawParms(float alphaSurfVisited, float alphaOlVisited, float alphaSurfUnvisited, float alphaOlUnvisited,
float alpha, float outlineWidthScale, const CStateManager& mgr, const zeus::CTransform& modelXf,
const zeus::CTransform& viewXf, const IWorld& wld, const CMapWorldInfo& mwInfo,
float playerFlash, float hintFlash, float objectScale, bool sortDoorSurfs)
: x0_alphaSurfVisited(alphaSurfVisited)
, x4_alphaOlVisited(alphaOlVisited)
, x8_alphaSurfUnvisited(alphaSurfUnvisited)
, xc_alphaOlUnvisited(alphaOlUnvisited)
, x10_alpha(alpha)
, x14_outlineWidthScale(outlineWidthScale)
, x18_mgr(mgr)
, x1c_modelXf(modelXf)
, x20_viewXf(viewXf)
, x24_wld(wld)
, x28_mwInfo(mwInfo)
, x2c_playerFlashIntensity(playerFlash)
, x30_hintFlashIntensity(hintFlash)
, x34_objectScale(objectScale)
, x38_sortDoorSurfs(sortDoorSurfs) {}
const IWorld& GetWorld() const { return x24_wld; }
float GetOutlineWidthScale() const { return x14_outlineWidthScale; }
const zeus::CTransform& GetPlaneProjectionTransform() const { return x1c_modelXf; }
float GetHintAreaFlashIntensity() const { return x30_hintFlashIntensity; }
float GetPlayerAreaFlashIntensity() const { return x2c_playerFlashIntensity; }
const zeus::CTransform& GetCameraTransform() const { return x20_viewXf; }
float GetAlphaOutlineUnvisited() const { return xc_alphaOlUnvisited; }
float GetAlphaSurfaceUnvisited() const { return x8_alphaSurfUnvisited; }
float GetAlphaOutlineVisited() const { return x4_alphaOlVisited; }
float GetAlphaSurfaceVisited() const { return x0_alphaSurfVisited; }
float GetAlpha() const { return x10_alpha; }
const CMapWorldInfo& GetMapWorldInfo() const { return x28_mwInfo; }
const CStateManager& GetStateManager() const { return x18_mgr; }
bool GetIsSortDoorSurfaces() const { return x38_sortDoorSurfs; }
float GetObjectScale() const { return x34_objectScale; }
};
private:
std::vector<CMapAreaData> x0_areas;
rstl::reserved_vector<CMapAreaData*, 3> x10_listHeads;
std::vector<bool> x20_traversed;
zeus::CVector3f x30_worldSpherePoint;
float x3c_worldSphereRadius = 0.f;
float x40_worldSphereHalfDepth = 0.f;
std::vector<CMapAreaData> x0_areas;
rstl::reserved_vector<CMapAreaData*, 3> x10_listHeads;
std::vector<bool> x20_traversed;
zeus::CVector3f x30_worldSpherePoint;
float x3c_worldSphereRadius = 0.f;
float x40_worldSphereHalfDepth = 0.f;
public:
CMapWorld(CInputStream&);
u32 GetNumAreas() const { return x0_areas.size(); }
const CMapArea* GetMapArea(int aid) const { return x0_areas[aid].GetMapArea(); }
bool IsMapAreaInBFSInfoVector(const CMapAreaData*, const std::vector<CMapAreaBFSInfo>&) const;
void SetWhichMapAreasLoaded(const IWorld&, int start, int count);
bool IsMapAreasStreaming() const;
void MoveMapAreaToList(CMapAreaData*, EMapAreaList);
s32 GetCurrentMapAreaDepth(const IWorld&, int areaIdx) const;
std::vector<int> GetVisibleAreas(const IWorld&, const CMapWorldInfo&) const;
void Draw(const CMapWorldDrawParms&, int, int, float, float, bool) const;
void DoBFS(const IWorld&, int, int, float, float, bool, std::vector<CMapAreaBFSInfo>&) const;
bool IsMapAreaValid(const IWorld&, int, bool) const;
void DrawAreas(const CMapWorldDrawParms&, int, const std::vector<CMapAreaBFSInfo>&, bool) const;
void RecalculateWorldSphere(const CMapWorldInfo&, const IWorld&) const;
zeus::CVector3f ConstrainToWorldVolume(const zeus::CVector3f&, const zeus::CVector3f&) const;
void ClearTraversedFlags() const;
CMapWorld(CInputStream&);
u32 GetNumAreas() const { return x0_areas.size(); }
const CMapArea* GetMapArea(int aid) const { return x0_areas[aid].GetMapArea(); }
bool IsMapAreaInBFSInfoVector(const CMapAreaData*, const std::vector<CMapAreaBFSInfo>&) const;
void SetWhichMapAreasLoaded(const IWorld&, int start, int count);
bool IsMapAreasStreaming() const;
void MoveMapAreaToList(CMapAreaData*, EMapAreaList);
s32 GetCurrentMapAreaDepth(const IWorld&, int areaIdx) const;
std::vector<int> GetVisibleAreas(const IWorld&, const CMapWorldInfo&) const;
void Draw(const CMapWorldDrawParms&, int, int, float, float, bool) const;
void DoBFS(const IWorld&, int, int, float, float, bool, std::vector<CMapAreaBFSInfo>&) const;
bool IsMapAreaValid(const IWorld&, int, bool) const;
void DrawAreas(const CMapWorldDrawParms&, int, const std::vector<CMapAreaBFSInfo>&, bool) const;
void RecalculateWorldSphere(const CMapWorldInfo&, const IWorld&) const;
zeus::CVector3f ConstrainToWorldVolume(const zeus::CVector3f&, const zeus::CVector3f&) const;
void ClearTraversedFlags() const;
};
CFactoryFnReturn FMapWorldFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& param,
CObjectReference* selfRef);
}
} // namespace urde

View File

@@ -2,136 +2,110 @@
#include "GameGlobalObjects.hpp"
#include "CMemoryCardSys.hpp"
namespace urde
{
namespace urde {
CMapWorldInfo::CMapWorldInfo(CBitStreamReader& reader, const CSaveWorld& savw, CAssetId mlvlId)
{
const CSaveWorldMemory& worldMem = g_MemoryCardSys->GetSaveWorldMemory(mlvlId);
CMapWorldInfo::CMapWorldInfo(CBitStreamReader& reader, const CSaveWorld& savw, CAssetId mlvlId) {
const CSaveWorldMemory& worldMem = g_MemoryCardSys->GetSaveWorldMemory(mlvlId);
x4_visitedAreas.reserve((worldMem.GetAreaCount() + 31) / 32);
for (int i=0 ; i<worldMem.GetAreaCount() ; ++i)
{
bool visited = reader.ReadEncoded(1);
SetAreaVisited(i, visited);
}
x4_visitedAreas.reserve((worldMem.GetAreaCount() + 31) / 32);
for (int i = 0; i < worldMem.GetAreaCount(); ++i) {
bool visited = reader.ReadEncoded(1);
SetAreaVisited(i, visited);
}
x18_mappedAreas.reserve((worldMem.GetAreaCount() + 31) / 32);
for (int i=0 ; i<worldMem.GetAreaCount() ; ++i)
{
bool mapped = reader.ReadEncoded(1);
SetIsMapped(i, mapped);
}
x18_mappedAreas.reserve((worldMem.GetAreaCount() + 31) / 32);
for (int i = 0; i < worldMem.GetAreaCount(); ++i) {
bool mapped = reader.ReadEncoded(1);
SetIsMapped(i, mapped);
}
for (TEditorId doorId : savw.GetDoors())
SetDoorVisited(doorId, reader.ReadEncoded(1));
for (TEditorId doorId : savw.GetDoors())
SetDoorVisited(doorId, reader.ReadEncoded(1));
x38_mapStationUsed = reader.ReadEncoded(1);
x38_mapStationUsed = reader.ReadEncoded(1);
}
void CMapWorldInfo::PutTo(CBitStreamWriter& writer, const CSaveWorld& savw, CAssetId mlvlId) const
{
const CSaveWorldMemory& worldMem = g_MemoryCardSys->GetSaveWorldMemory(mlvlId);
void CMapWorldInfo::PutTo(CBitStreamWriter& writer, const CSaveWorld& savw, CAssetId mlvlId) const {
const CSaveWorldMemory& worldMem = g_MemoryCardSys->GetSaveWorldMemory(mlvlId);
for (int i=0 ; i<worldMem.GetAreaCount() ; ++i)
{
if (i < x0_visitedAreasAllocated)
writer.WriteEncoded(IsAreaVisted(i), 1);
else
writer.WriteEncoded(0, 1);
}
for (int i=0 ; i<worldMem.GetAreaCount() ; ++i)
{
if (i < x14_mappedAreasAllocated)
writer.WriteEncoded(IsMapped(i), 1);
else
writer.WriteEncoded(0, 1);
}
for (TEditorId doorId : savw.GetDoors())
writer.WriteEncoded(IsDoorVisited(doorId), 1);
writer.WriteEncoded(x38_mapStationUsed, 1);
}
void CMapWorldInfo::SetDoorVisited(TEditorId eid, bool visited)
{
x28_visitedDoors[eid] = visited;
}
bool CMapWorldInfo::IsDoorVisited(TEditorId eid) const
{
return x28_visitedDoors.find(eid) != x28_visitedDoors.end();
}
bool CMapWorldInfo::IsAreaVisted(TAreaId aid) const
{
if (aid + 1 > x0_visitedAreasAllocated)
{
const_cast<CMapWorldInfo&>(*this).x4_visitedAreas.resize((aid + 32) / 32);
const_cast<CMapWorldInfo&>(*this).x0_visitedAreasAllocated = aid + 1;
}
return (x4_visitedAreas[aid / 32] >> (aid % 32)) & 0x1;
}
void CMapWorldInfo::SetAreaVisited(TAreaId aid, bool visited)
{
if (aid + 1 > x0_visitedAreasAllocated)
{
x4_visitedAreas.resize((aid + 32) / 32);
x0_visitedAreasAllocated = aid + 1;
}
if (visited)
x4_visitedAreas[aid / 32] |= 1 << (aid % 32);
for (int i = 0; i < worldMem.GetAreaCount(); ++i) {
if (i < x0_visitedAreasAllocated)
writer.WriteEncoded(IsAreaVisted(i), 1);
else
x4_visitedAreas[aid / 32] &= ~(1 << (aid % 32));
}
writer.WriteEncoded(0, 1);
}
bool CMapWorldInfo::IsMapped(TAreaId aid) const
{
if (aid + 1 > x14_mappedAreasAllocated)
{
const_cast<CMapWorldInfo&>(*this).x18_mappedAreas.resize((aid + 32) / 32);
const_cast<CMapWorldInfo&>(*this).x14_mappedAreasAllocated = aid + 1;
}
return (x18_mappedAreas[aid / 32] >> (aid % 32)) & 0x1;
}
void CMapWorldInfo::SetIsMapped(TAreaId aid, bool mapped)
{
if (aid + 1 > x14_mappedAreasAllocated)
{
x18_mappedAreas.resize((aid + 32) / 32);
x14_mappedAreasAllocated = aid + 1;
}
if (mapped)
x18_mappedAreas[aid / 32] |= 1 << (aid % 32);
for (int i = 0; i < worldMem.GetAreaCount(); ++i) {
if (i < x14_mappedAreasAllocated)
writer.WriteEncoded(IsMapped(i), 1);
else
x18_mappedAreas[aid / 32] &= ~(1 << (aid % 32));
writer.WriteEncoded(0, 1);
}
for (TEditorId doorId : savw.GetDoors())
writer.WriteEncoded(IsDoorVisited(doorId), 1);
writer.WriteEncoded(x38_mapStationUsed, 1);
}
bool CMapWorldInfo::IsWorldVisible(TAreaId aid) const
{
return x38_mapStationUsed || IsMapped(aid);
void CMapWorldInfo::SetDoorVisited(TEditorId eid, bool visited) { x28_visitedDoors[eid] = visited; }
bool CMapWorldInfo::IsDoorVisited(TEditorId eid) const { return x28_visitedDoors.find(eid) != x28_visitedDoors.end(); }
bool CMapWorldInfo::IsAreaVisted(TAreaId aid) const {
if (aid + 1 > x0_visitedAreasAllocated) {
const_cast<CMapWorldInfo&>(*this).x4_visitedAreas.resize((aid + 32) / 32);
const_cast<CMapWorldInfo&>(*this).x0_visitedAreasAllocated = aid + 1;
}
return (x4_visitedAreas[aid / 32] >> (aid % 32)) & 0x1;
}
bool CMapWorldInfo::IsAreaVisible(TAreaId aid) const
{
if (IsAreaVisted(aid) || IsMapped(aid))
return true;
return false;
void CMapWorldInfo::SetAreaVisited(TAreaId aid, bool visited) {
if (aid + 1 > x0_visitedAreasAllocated) {
x4_visitedAreas.resize((aid + 32) / 32);
x0_visitedAreasAllocated = aid + 1;
}
if (visited)
x4_visitedAreas[aid / 32] |= 1 << (aid % 32);
else
x4_visitedAreas[aid / 32] &= ~(1 << (aid % 32));
}
bool CMapWorldInfo::IsAnythingSet() const
{
for (int i=0 ; i<x0_visitedAreasAllocated ; ++i)
if (x4_visitedAreas[i / 32] & (1 << (i % 32)))
return true;
for (int i=0 ; i<x14_mappedAreasAllocated ; ++i)
if (x18_mappedAreas[i / 32] & (1 << (i % 32)))
return true;
return x38_mapStationUsed;
bool CMapWorldInfo::IsMapped(TAreaId aid) const {
if (aid + 1 > x14_mappedAreasAllocated) {
const_cast<CMapWorldInfo&>(*this).x18_mappedAreas.resize((aid + 32) / 32);
const_cast<CMapWorldInfo&>(*this).x14_mappedAreasAllocated = aid + 1;
}
return (x18_mappedAreas[aid / 32] >> (aid % 32)) & 0x1;
}
void CMapWorldInfo::SetIsMapped(TAreaId aid, bool mapped) {
if (aid + 1 > x14_mappedAreasAllocated) {
x18_mappedAreas.resize((aid + 32) / 32);
x14_mappedAreasAllocated = aid + 1;
}
if (mapped)
x18_mappedAreas[aid / 32] |= 1 << (aid % 32);
else
x18_mappedAreas[aid / 32] &= ~(1 << (aid % 32));
}
bool CMapWorldInfo::IsWorldVisible(TAreaId aid) const { return x38_mapStationUsed || IsMapped(aid); }
bool CMapWorldInfo::IsAreaVisible(TAreaId aid) const {
if (IsAreaVisted(aid) || IsMapped(aid))
return true;
return false;
}
bool CMapWorldInfo::IsAnythingSet() const {
for (int i = 0; i < x0_visitedAreasAllocated; ++i)
if (x4_visitedAreas[i / 32] & (1 << (i % 32)))
return true;
for (int i = 0; i < x14_mappedAreasAllocated; ++i)
if (x18_mappedAreas[i / 32] & (1 << (i % 32)))
return true;
return x38_mapStationUsed;
}
} // namespace urde

View File

@@ -2,32 +2,30 @@
#include "RetroTypes.hpp"
namespace urde
{
namespace urde {
class CSaveWorld;
class CMapWorldInfo
{
u32 x0_visitedAreasAllocated = 0;
std::vector<u32> x4_visitedAreas;
u32 x14_mappedAreasAllocated = 0;
std::vector<u32> x18_mappedAreas;
std::map<TEditorId, bool> x28_visitedDoors;
bool x38_mapStationUsed = false;
public:
CMapWorldInfo()=default;
CMapWorldInfo(CBitStreamReader&, const CSaveWorld& saveWorld, CAssetId mlvlId);
void PutTo(CBitStreamWriter& writer, const CSaveWorld& savw, CAssetId mlvlId) const;
bool IsMapped(TAreaId) const;
void SetIsMapped(TAreaId, bool);
void SetDoorVisited(TEditorId eid, bool val);
bool IsDoorVisited(TEditorId eid) const;
bool IsAreaVisted(TAreaId) const;
void SetAreaVisited(TAreaId, bool);
bool IsWorldVisible(TAreaId) const;
bool IsAreaVisible(TAreaId) const;
bool IsAnythingSet() const;
void SetMapStationUsed(bool val) { x38_mapStationUsed = val; }
};
}
class CMapWorldInfo {
u32 x0_visitedAreasAllocated = 0;
std::vector<u32> x4_visitedAreas;
u32 x14_mappedAreasAllocated = 0;
std::vector<u32> x18_mappedAreas;
std::map<TEditorId, bool> x28_visitedDoors;
bool x38_mapStationUsed = false;
public:
CMapWorldInfo() = default;
CMapWorldInfo(CBitStreamReader&, const CSaveWorld& saveWorld, CAssetId mlvlId);
void PutTo(CBitStreamWriter& writer, const CSaveWorld& savw, CAssetId mlvlId) const;
bool IsMapped(TAreaId) const;
void SetIsMapped(TAreaId, bool);
void SetDoorVisited(TEditorId eid, bool val);
bool IsDoorVisited(TEditorId eid) const;
bool IsAreaVisted(TAreaId) const;
void SetAreaVisited(TAreaId, bool);
bool IsWorldVisible(TAreaId) const;
bool IsAreaVisible(TAreaId) const;
bool IsAnythingSet() const;
void SetMapStationUsed(bool val) { x38_mapStationUsed = val; }
};
} // namespace urde

View File

@@ -5,308 +5,255 @@
#include "CToken.hpp"
#include "Graphics/CTexture.hpp"
namespace urde
{
namespace urde {
const zeus::CVector3f CMappableObject::skDoorVerts[8] = {};
static const u32 DoorIndices[] =
{
6, 4, 2, 0,
3, 1, 7, 5,
1, 0, 5, 4,
7, 6, 3, 2,
3, 2, 1, 0,
5, 4, 7, 6
};
static const u32 DoorIndices[] = {6, 4, 2, 0, 3, 1, 7, 5, 1, 0, 5, 4, 7, 6, 3, 2, 3, 2, 1, 0, 5, 4, 7, 6};
CMappableObject::CMappableObject(const void* buf)
{
athena::io::MemoryReader r(buf, 64);
x0_type = EMappableObjectType(r.readUint32Big());
x4_visibilityMode = EVisMode(r.readUint32Big());
x8_objId = r.readUint32Big();
xc_ = r.readUint32Big();
x10_transform.read34RowMajor(r);
CMappableObject::CMappableObject(const void* buf) {
athena::io::MemoryReader r(buf, 64);
x0_type = EMappableObjectType(r.readUint32Big());
x4_visibilityMode = EVisMode(r.readUint32Big());
x8_objId = r.readUint32Big();
xc_ = r.readUint32Big();
x10_transform.read34RowMajor(r);
}
zeus::CTransform CMappableObject::AdjustTransformForType()
{
const float doorCenterX = g_tweakAutoMapper->GetDoorCenter().x();
const float doorCenterZ = g_tweakAutoMapper->GetDoorCenter().z();
if (x0_type == EMappableObjectType::BigDoor1)
{
zeus::CTransform orientation;
orientation.origin = {-1.4f*doorCenterX, 0.0f, 0.0f};
orientation.rotateLocalZ(zeus::degToRad(90.0f));
return (x10_transform * orientation) * zeus::CTransform::Scale(zeus::CVector3f{1.5f});
}
else if (x0_type == EMappableObjectType::BigDoor2)
{
zeus::CTransform orientation;
orientation.origin = {0.f, -2.0f * doorCenterZ, -1.4f * doorCenterX};
orientation.rotateLocalZ(zeus::degToRad(-90.f));
return (x10_transform * orientation) * zeus::CTransform::Scale(zeus::CVector3f{1.5f});
}
else if (x0_type == EMappableObjectType::IceDoorCeiling || x0_type == EMappableObjectType::WaveDoorCeiling
|| x0_type == EMappableObjectType::PlasmaDoorCeiling)
{
zeus::CTransform orientation;
orientation.origin = {-1.65f * doorCenterX, 0.f, -1.5f * doorCenterZ};
orientation.rotateLocalY(zeus::degToRad(90.f));
return x10_transform * orientation;
}
else if (x0_type == EMappableObjectType::IceDoorFloor || x0_type == EMappableObjectType::WaveDoorFloor
|| x0_type == EMappableObjectType::PlasmaDoorFloor)
{
zeus::CTransform orientation;
orientation.origin = {-1.65f * doorCenterX, 0.f, -1.f * doorCenterZ};
orientation.rotateLocalY(zeus::degToRad(90.f));
return x10_transform * orientation;
}
else if ((u32(x0_type) - u32(EMappableObjectType::IceDoorFloor2)) <= u32(EMappableObjectType::ShieldDoor)
|| x0_type == EMappableObjectType::PlasmaDoorFloor2)
{
zeus::CTransform orientation;
orientation.origin = {-0.49f * doorCenterX, 0.f, -1.f * doorCenterZ};
orientation.rotateLocalY(zeus::degToRad(90.f));
return x10_transform * orientation;
}
else if (x0_type >= EMappableObjectType::BlueDoor || x0_type <= EMappableObjectType::PlasmaDoorFloor2)
{
return x10_transform;
}
return zeus::CTransform::Translate(x10_transform.origin);
zeus::CTransform CMappableObject::AdjustTransformForType() {
const float doorCenterX = g_tweakAutoMapper->GetDoorCenter().x();
const float doorCenterZ = g_tweakAutoMapper->GetDoorCenter().z();
if (x0_type == EMappableObjectType::BigDoor1) {
zeus::CTransform orientation;
orientation.origin = {-1.4f * doorCenterX, 0.0f, 0.0f};
orientation.rotateLocalZ(zeus::degToRad(90.0f));
return (x10_transform * orientation) * zeus::CTransform::Scale(zeus::CVector3f{1.5f});
} else if (x0_type == EMappableObjectType::BigDoor2) {
zeus::CTransform orientation;
orientation.origin = {0.f, -2.0f * doorCenterZ, -1.4f * doorCenterX};
orientation.rotateLocalZ(zeus::degToRad(-90.f));
return (x10_transform * orientation) * zeus::CTransform::Scale(zeus::CVector3f{1.5f});
} else if (x0_type == EMappableObjectType::IceDoorCeiling || x0_type == EMappableObjectType::WaveDoorCeiling ||
x0_type == EMappableObjectType::PlasmaDoorCeiling) {
zeus::CTransform orientation;
orientation.origin = {-1.65f * doorCenterX, 0.f, -1.5f * doorCenterZ};
orientation.rotateLocalY(zeus::degToRad(90.f));
return x10_transform * orientation;
} else if (x0_type == EMappableObjectType::IceDoorFloor || x0_type == EMappableObjectType::WaveDoorFloor ||
x0_type == EMappableObjectType::PlasmaDoorFloor) {
zeus::CTransform orientation;
orientation.origin = {-1.65f * doorCenterX, 0.f, -1.f * doorCenterZ};
orientation.rotateLocalY(zeus::degToRad(90.f));
return x10_transform * orientation;
} else if ((u32(x0_type) - u32(EMappableObjectType::IceDoorFloor2)) <= u32(EMappableObjectType::ShieldDoor) ||
x0_type == EMappableObjectType::PlasmaDoorFloor2) {
zeus::CTransform orientation;
orientation.origin = {-0.49f * doorCenterX, 0.f, -1.f * doorCenterZ};
orientation.rotateLocalY(zeus::degToRad(90.f));
return x10_transform * orientation;
} else if (x0_type >= EMappableObjectType::BlueDoor || x0_type <= EMappableObjectType::PlasmaDoorFloor2) {
return x10_transform;
}
return zeus::CTransform::Translate(x10_transform.origin);
}
std::pair<zeus::CColor, zeus::CColor>
CMappableObject::GetDoorColors(int curAreaId, const CMapWorldInfo& mwInfo, float alpha) const
{
zeus::CColor color = {1.f, 0.f, 1.f, 1.f};
if (x8_objId.AreaNum() == curAreaId)
{
if (mwInfo.IsDoorVisited(x8_objId) && x0_type == EMappableObjectType::ShieldDoor)
{
color = g_tweakAutoMapper->GetDoorColor(0);
}
else
{
int colorIdx = 0;
switch (x0_type)
{
case EMappableObjectType::ShieldDoor:
colorIdx = 1;
break;
case EMappableObjectType::IceDoor:
case EMappableObjectType::IceDoorCeiling:
case EMappableObjectType::IceDoorFloor:
case EMappableObjectType::IceDoorFloor2:
colorIdx = 2;
break;
case EMappableObjectType::WaveDoor:
case EMappableObjectType::WaveDoorCeiling:
case EMappableObjectType::WaveDoorFloor:
case EMappableObjectType::WaveDoorFloor2:
colorIdx = 3;
break;
case EMappableObjectType::PlasmaDoor:
case EMappableObjectType::PlasmaDoorCeiling:
case EMappableObjectType::PlasmaDoorFloor:
case EMappableObjectType::PlasmaDoorFloor2:
colorIdx = 4;
default: break;
}
color = g_tweakAutoMapper->GetDoorColor(colorIdx);
}
}
else if (mwInfo.IsDoorVisited(x8_objId))
{
color = g_tweakAutoMapper->GetOpenDoorColor();
}
else
{
color = zeus::CColor::skClear;
std::pair<zeus::CColor, zeus::CColor> CMappableObject::GetDoorColors(int curAreaId, const CMapWorldInfo& mwInfo,
float alpha) const {
zeus::CColor color = {1.f, 0.f, 1.f, 1.f};
if (x8_objId.AreaNum() == curAreaId) {
if (mwInfo.IsDoorVisited(x8_objId) && x0_type == EMappableObjectType::ShieldDoor) {
color = g_tweakAutoMapper->GetDoorColor(0);
} else {
int colorIdx = 0;
switch (x0_type) {
case EMappableObjectType::ShieldDoor:
colorIdx = 1;
break;
case EMappableObjectType::IceDoor:
case EMappableObjectType::IceDoorCeiling:
case EMappableObjectType::IceDoorFloor:
case EMappableObjectType::IceDoorFloor2:
colorIdx = 2;
break;
case EMappableObjectType::WaveDoor:
case EMappableObjectType::WaveDoorCeiling:
case EMappableObjectType::WaveDoorFloor:
case EMappableObjectType::WaveDoorFloor2:
colorIdx = 3;
break;
case EMappableObjectType::PlasmaDoor:
case EMappableObjectType::PlasmaDoorCeiling:
case EMappableObjectType::PlasmaDoorFloor:
case EMappableObjectType::PlasmaDoorFloor2:
colorIdx = 4;
default:
break;
}
color = g_tweakAutoMapper->GetDoorColor(colorIdx);
}
} else if (mwInfo.IsDoorVisited(x8_objId)) {
color = g_tweakAutoMapper->GetOpenDoorColor();
} else {
color = zeus::CColor::skClear;
}
color.a() *= alpha;
return {color, zeus::CColor(std::min(1.4f * color.r(), 1.f),
std::min(1.4f * color.g(), 1.f),
std::min(1.4f * color.b(), 1.f),
std::min(1.4f * color.a(), 1.f))};
color.a() *= alpha;
return {color, zeus::CColor(std::min(1.4f * color.r(), 1.f), std::min(1.4f * color.g(), 1.f),
std::min(1.4f * color.b(), 1.f), std::min(1.4f * color.a(), 1.f))};
}
void CMappableObject::PostConstruct(const void *)
{
x10_transform = AdjustTransformForType();
}
void CMappableObject::PostConstruct(const void*) { x10_transform = AdjustTransformForType(); }
void CMappableObject::Draw(int curArea, const CMapWorldInfo& mwInfo,
float alpha, bool needsVtxLoad) const
{
if (IsDoorType(x0_type))
{
std::pair<zeus::CColor, zeus::CColor> colors = GetDoorColors(curArea, mwInfo, alpha);
for (int s=0 ; s<6 ; ++s)
{
DoorSurface& ds = const_cast<DoorSurface&>(*m_doorSurface);
ds.m_surface.draw(colors.first, s * 4, 4);
CLineRenderer& line = ds.m_outline;
const u32* baseIdx = &DoorIndices[s * 4];
line.Reset();
line.AddVertex(skDoorVerts[baseIdx[0]], colors.second, 1.f);
line.AddVertex(skDoorVerts[baseIdx[1]], colors.second, 1.f);
line.AddVertex(skDoorVerts[baseIdx[3]], colors.second, 1.f);
line.AddVertex(skDoorVerts[baseIdx[2]], colors.second, 1.f);
line.Render();
}
}
else
{
CAssetId iconRes;
zeus::CColor iconColor = zeus::CColor::skWhite;
switch (x0_type)
{
case EMappableObjectType::DownArrowYellow:
iconRes = g_tweakPlayerRes->x10_minesBreakFirstTopIcon;
iconColor = zeus::CColor{1.f, 1.f, 0.588f, 1.f};
break;
case EMappableObjectType::UpArrowYellow:
iconRes = g_tweakPlayerRes->x14_minesBreakFirstBottomIcon;
iconColor = zeus::CColor{1.f, 1.f, 0.588f, 1.f};
break;
case EMappableObjectType::DownArrowGreen:
iconRes = g_tweakPlayerRes->x10_minesBreakFirstTopIcon;
iconColor = zeus::CColor{0.392f, 1.f, 0.588f, 1.f};
break;
case EMappableObjectType::UpArrowGreen:
iconRes = g_tweakPlayerRes->x14_minesBreakFirstBottomIcon;
iconColor = zeus::CColor{0.392f, 1.f, 0.588f, 1.f};
break;
case EMappableObjectType::DownArrowRed:
iconRes = g_tweakPlayerRes->x10_minesBreakFirstTopIcon;
iconColor = zeus::CColor{1.f, 0.392f, 0.588f, 1.f};
break;
case EMappableObjectType::UpArrowRed:
iconRes = g_tweakPlayerRes->x14_minesBreakFirstBottomIcon;
iconColor = zeus::CColor{1.f, 0.392f, 0.588f, 1.f};
break;
case EMappableObjectType::SaveStation:
iconRes = g_tweakPlayerRes->x4_saveStationIcon;
break;
case EMappableObjectType::MissileStation:
iconRes = g_tweakPlayerRes->x8_missileStationIcon;
break;
default:
iconRes = g_tweakPlayerRes->xc_elevatorIcon;
break;
}
iconColor.a() *= alpha;
TLockedToken<CTexture> tex = g_SimplePool->GetObj(SObjectTag{FOURCC('TXTR'), iconRes});
if (!m_texQuadFilter || m_texQuadFilter->GetTex().GetObj() != tex.GetObj())
const_cast<CMappableObject*>(this)->m_texQuadFilter.emplace(EFilterType::Add, tex,
CTexturedQuadFilter::ZTest::GEqual);
CTexturedQuadFilter::Vert verts[4] =
{
{{-2.6f, 0.f, 2.6f}, {0.f, 1.f}},
{{-2.6f, 0.f, -2.6f}, {0.f, 0.f}},
{{2.6f, 0.f, 2.6f}, {1.f, 1.f}},
{{2.6f, 0.f, -2.6f}, {1.f, 0.f}}
};
const_cast<CMappableObject*>(this)->m_texQuadFilter->drawVerts(iconColor, verts);
}
}
void CMappableObject::DrawDoorSurface(int curArea, const CMapWorldInfo& mwInfo,
float alpha, int surfIdx, bool needsVtxLoad) const
{
void CMappableObject::Draw(int curArea, const CMapWorldInfo& mwInfo, float alpha, bool needsVtxLoad) const {
if (IsDoorType(x0_type)) {
std::pair<zeus::CColor, zeus::CColor> colors = GetDoorColors(curArea, mwInfo, alpha);
DoorSurface& ds = const_cast<DoorSurface&>(*m_doorSurface);
ds.m_surface.draw(colors.first, surfIdx * 4, 4);
CLineRenderer& line = ds.m_outline;
const u32* baseIdx = &DoorIndices[surfIdx * 4];
line.Reset();
line.AddVertex(skDoorVerts[baseIdx[0]], colors.second, 1.f);
line.AddVertex(skDoorVerts[baseIdx[1]], colors.second, 1.f);
line.AddVertex(skDoorVerts[baseIdx[3]], colors.second, 1.f);
line.AddVertex(skDoorVerts[baseIdx[2]], colors.second, 1.f);
line.Render();
}
zeus::CVector3f CMappableObject::BuildSurfaceCenterPoint(int surfIdx) const
{
const zeus::CVector3f& doorCenter = g_tweakAutoMapper->GetDoorCenter();
switch (surfIdx)
{
case 0:
return x10_transform * zeus::CVector3f::skZero;
case 1:
return x10_transform * zeus::CVector3f{0.f, 0.f, 2.f * doorCenter.x()};
case 2:
return x10_transform * zeus::CVector3f{0.f, -doorCenter.y(), 0.f};
case 3:
return x10_transform * zeus::CVector3f{0.f, doorCenter.y(), 0.f};
case 4:
return x10_transform * zeus::CVector3f{-doorCenter.x(), 0.f, 0.f};
case 5:
return x10_transform * zeus::CVector3f{doorCenter.x(), 0.f, 0.f};
default: break;
for (int s = 0; s < 6; ++s) {
DoorSurface& ds = const_cast<DoorSurface&>(*m_doorSurface);
ds.m_surface.draw(colors.first, s * 4, 4);
CLineRenderer& line = ds.m_outline;
const u32* baseIdx = &DoorIndices[s * 4];
line.Reset();
line.AddVertex(skDoorVerts[baseIdx[0]], colors.second, 1.f);
line.AddVertex(skDoorVerts[baseIdx[1]], colors.second, 1.f);
line.AddVertex(skDoorVerts[baseIdx[3]], colors.second, 1.f);
line.AddVertex(skDoorVerts[baseIdx[2]], colors.second, 1.f);
line.Render();
}
return {};
}
bool CMappableObject::IsVisibleToAutoMapper(bool worldVis, const CMapWorldInfo& mwInfo) const
{
bool areaVis = mwInfo.IsAreaVisible(x8_objId.AreaNum());
switch (x4_visibilityMode)
{
case EVisMode::Always:
} else {
CAssetId iconRes;
zeus::CColor iconColor = zeus::CColor::skWhite;
switch (x0_type) {
case EMappableObjectType::DownArrowYellow:
iconRes = g_tweakPlayerRes->x10_minesBreakFirstTopIcon;
iconColor = zeus::CColor{1.f, 1.f, 0.588f, 1.f};
break;
case EMappableObjectType::UpArrowYellow:
iconRes = g_tweakPlayerRes->x14_minesBreakFirstBottomIcon;
iconColor = zeus::CColor{1.f, 1.f, 0.588f, 1.f};
break;
case EMappableObjectType::DownArrowGreen:
iconRes = g_tweakPlayerRes->x10_minesBreakFirstTopIcon;
iconColor = zeus::CColor{0.392f, 1.f, 0.588f, 1.f};
break;
case EMappableObjectType::UpArrowGreen:
iconRes = g_tweakPlayerRes->x14_minesBreakFirstBottomIcon;
iconColor = zeus::CColor{0.392f, 1.f, 0.588f, 1.f};
break;
case EMappableObjectType::DownArrowRed:
iconRes = g_tweakPlayerRes->x10_minesBreakFirstTopIcon;
iconColor = zeus::CColor{1.f, 0.392f, 0.588f, 1.f};
break;
case EMappableObjectType::UpArrowRed:
iconRes = g_tweakPlayerRes->x14_minesBreakFirstBottomIcon;
iconColor = zeus::CColor{1.f, 0.392f, 0.588f, 1.f};
break;
case EMappableObjectType::SaveStation:
iconRes = g_tweakPlayerRes->x4_saveStationIcon;
break;
case EMappableObjectType::MissileStation:
iconRes = g_tweakPlayerRes->x8_missileStationIcon;
break;
default:
return true;
case EVisMode::MapStationOrVisit:
case EVisMode::MapStationOrVisit2:
return worldVis || areaVis;
case EVisMode::Visit:
if (IsDoorType(x0_type))
return mwInfo.IsDoorVisited(x8_objId);
return areaVis;
case EVisMode::Never:
return false;
iconRes = g_tweakPlayerRes->xc_elevatorIcon;
break;
}
iconColor.a() *= alpha;
TLockedToken<CTexture> tex = g_SimplePool->GetObj(SObjectTag{FOURCC('TXTR'), iconRes});
if (!m_texQuadFilter || m_texQuadFilter->GetTex().GetObj() != tex.GetObj())
const_cast<CMappableObject*>(this)->m_texQuadFilter.emplace(EFilterType::Add, tex,
CTexturedQuadFilter::ZTest::GEqual);
CTexturedQuadFilter::Vert verts[4] = {{{-2.6f, 0.f, 2.6f}, {0.f, 1.f}},
{{-2.6f, 0.f, -2.6f}, {0.f, 0.f}},
{{2.6f, 0.f, 2.6f}, {1.f, 1.f}},
{{2.6f, 0.f, -2.6f}, {1.f, 0.f}}};
const_cast<CMappableObject*>(this)->m_texQuadFilter->drawVerts(iconColor, verts);
}
}
void CMappableObject::DrawDoorSurface(int curArea, const CMapWorldInfo& mwInfo, float alpha, int surfIdx,
bool needsVtxLoad) const {
std::pair<zeus::CColor, zeus::CColor> colors = GetDoorColors(curArea, mwInfo, alpha);
DoorSurface& ds = const_cast<DoorSurface&>(*m_doorSurface);
ds.m_surface.draw(colors.first, surfIdx * 4, 4);
CLineRenderer& line = ds.m_outline;
const u32* baseIdx = &DoorIndices[surfIdx * 4];
line.Reset();
line.AddVertex(skDoorVerts[baseIdx[0]], colors.second, 1.f);
line.AddVertex(skDoorVerts[baseIdx[1]], colors.second, 1.f);
line.AddVertex(skDoorVerts[baseIdx[3]], colors.second, 1.f);
line.AddVertex(skDoorVerts[baseIdx[2]], colors.second, 1.f);
line.Render();
}
zeus::CVector3f CMappableObject::BuildSurfaceCenterPoint(int surfIdx) const {
const zeus::CVector3f& doorCenter = g_tweakAutoMapper->GetDoorCenter();
switch (surfIdx) {
case 0:
return x10_transform * zeus::CVector3f::skZero;
case 1:
return x10_transform * zeus::CVector3f{0.f, 0.f, 2.f * doorCenter.x()};
case 2:
return x10_transform * zeus::CVector3f{0.f, -doorCenter.y(), 0.f};
case 3:
return x10_transform * zeus::CVector3f{0.f, doorCenter.y(), 0.f};
case 4:
return x10_transform * zeus::CVector3f{-doorCenter.x(), 0.f, 0.f};
case 5:
return x10_transform * zeus::CVector3f{doorCenter.x(), 0.f, 0.f};
default:
break;
}
return {};
}
bool CMappableObject::IsVisibleToAutoMapper(bool worldVis, const CMapWorldInfo& mwInfo) const {
bool areaVis = mwInfo.IsAreaVisible(x8_objId.AreaNum());
switch (x4_visibilityMode) {
case EVisMode::Always:
default:
return true;
case EVisMode::MapStationOrVisit:
case EVisMode::MapStationOrVisit2:
return worldVis || areaVis;
case EVisMode::Visit:
if (IsDoorType(x0_type))
return mwInfo.IsDoorVisited(x8_objId);
return areaVis;
case EVisMode::Never:
return false;
}
}
boo::ObjToken<boo::IGraphicsBufferS> CMappableObject::g_doorVbo;
boo::ObjToken<boo::IGraphicsBufferS> CMappableObject::g_doorIbo;
void CMappableObject::ReadAutoMapperTweaks(const ITweakAutoMapper& tweaks)
{
const zeus::CVector3f& center = tweaks.GetDoorCenter();
zeus::simd_floats centerF(center.mSimd);
zeus::CVector3f* doorVerts = const_cast<zeus::CVector3f*>(&CMappableObject::skDoorVerts[0]);
/* Wrap door verts around -Z to build surface */
doorVerts[0].assign( -centerF[2], -centerF[1], 0.f);
doorVerts[1].assign( -centerF[2], -centerF[1], 2.f * centerF[0]);
doorVerts[2].assign( -centerF[2], centerF[1], 0.f);
doorVerts[3].assign( -centerF[2], centerF[1], 2.f * centerF[0]);
doorVerts[4].assign(.2f * -centerF[2], -centerF[1], 0.f);
doorVerts[5].assign(.2f * -centerF[2], -centerF[1], 2.f * centerF[0]);
doorVerts[6].assign(.2f * -centerF[2], centerF[1], 0.f);
doorVerts[7].assign(.2f * -centerF[2], centerF[1], 2.f * centerF[0]);
void CMappableObject::ReadAutoMapperTweaks(const ITweakAutoMapper& tweaks) {
const zeus::CVector3f& center = tweaks.GetDoorCenter();
zeus::simd_floats centerF(center.mSimd);
zeus::CVector3f* doorVerts = const_cast<zeus::CVector3f*>(&CMappableObject::skDoorVerts[0]);
/* Wrap door verts around -Z to build surface */
doorVerts[0].assign(-centerF[2], -centerF[1], 0.f);
doorVerts[1].assign(-centerF[2], -centerF[1], 2.f * centerF[0]);
doorVerts[2].assign(-centerF[2], centerF[1], 0.f);
doorVerts[3].assign(-centerF[2], centerF[1], 2.f * centerF[0]);
doorVerts[4].assign(.2f * -centerF[2], -centerF[1], 0.f);
doorVerts[5].assign(.2f * -centerF[2], -centerF[1], 2.f * centerF[0]);
doorVerts[6].assign(.2f * -centerF[2], centerF[1], 0.f);
doorVerts[7].assign(.2f * -centerF[2], centerF[1], 2.f * centerF[0]);
CGraphics::CommitResources([](boo::IGraphicsDataFactory::Context& ctx)
{
g_doorVbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, skDoorVerts, 16, 8);
g_doorIbo = ctx.newStaticBuffer(boo::BufferUse::Index, DoorIndices, 4, 24);
return true;
} BooTrace);
CGraphics::CommitResources([](boo::IGraphicsDataFactory::Context& ctx) {
g_doorVbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, skDoorVerts, 16, 8);
g_doorIbo = ctx.newStaticBuffer(boo::BufferUse::Index, DoorIndices, 4, 24);
return true;
} BooTrace);
}
void CMappableObject::Shutdown()
{
g_doorVbo.reset();
g_doorIbo.reset();
}
void CMappableObject::Shutdown() {
g_doorVbo.reset();
g_doorIbo.reset();
}
} // namespace urde

View File

@@ -8,98 +8,87 @@
#include "Graphics/Shaders/CTexturedQuadFilter.hpp"
#include "Graphics/CLineRenderer.hpp"
namespace urde
{
namespace urde {
class CStateManager;
class CMapWorldInfo;
class CMappableObject
{
friend class CMapArea;
static boo::ObjToken<boo::IGraphicsBufferS> g_doorVbo;
static boo::ObjToken<boo::IGraphicsBufferS> g_doorIbo;
class CMappableObject {
friend class CMapArea;
static boo::ObjToken<boo::IGraphicsBufferS> g_doorVbo;
static boo::ObjToken<boo::IGraphicsBufferS> g_doorIbo;
public:
enum class EMappableObjectType
{
BlueDoor = 0,
ShieldDoor = 1,
IceDoor = 2,
WaveDoor = 3,
PlasmaDoor = 4,
BigDoor1 = 5,
BigDoor2 = 6,
IceDoorCeiling = 7,
IceDoorFloor = 8,
WaveDoorCeiling = 9,
WaveDoorFloor = 10,
PlasmaDoorCeiling= 11,
PlasmaDoorFloor = 12,
IceDoorFloor2 = 13,
WaveDoorFloor2 = 14,
PlasmaDoorFloor2 = 15,
DownArrowYellow = 27, /* Maintenance Tunnel */
UpArrowYellow = 28, /* Phazon Processing Center */
DownArrowGreen = 29, /* Elevator A */
UpArrowGreen = 30, /* Elite Control Access */
DownArrowRed = 31, /* Elevator B */
UpArrowRed = 32, /* Fungal Hall Access */
TransportLift = 33,
SaveStation = 34,
MissileStation = 37
};
enum class EMappableObjectType {
BlueDoor = 0,
ShieldDoor = 1,
IceDoor = 2,
WaveDoor = 3,
PlasmaDoor = 4,
BigDoor1 = 5,
BigDoor2 = 6,
IceDoorCeiling = 7,
IceDoorFloor = 8,
WaveDoorCeiling = 9,
WaveDoorFloor = 10,
PlasmaDoorCeiling = 11,
PlasmaDoorFloor = 12,
IceDoorFloor2 = 13,
WaveDoorFloor2 = 14,
PlasmaDoorFloor2 = 15,
DownArrowYellow = 27, /* Maintenance Tunnel */
UpArrowYellow = 28, /* Phazon Processing Center */
DownArrowGreen = 29, /* Elevator A */
UpArrowGreen = 30, /* Elite Control Access */
DownArrowRed = 31, /* Elevator B */
UpArrowRed = 32, /* Fungal Hall Access */
TransportLift = 33,
SaveStation = 34,
MissileStation = 37
};
enum class EVisMode
{
Always,
MapStationOrVisit,
Visit,
Never,
MapStationOrVisit2
};
enum class EVisMode { Always, MapStationOrVisit, Visit, Never, MapStationOrVisit2 };
private:
static const zeus::CVector3f skDoorVerts[8];
static const zeus::CVector3f skDoorVerts[8];
EMappableObjectType x0_type;
EVisMode x4_visibilityMode;
TEditorId x8_objId;
u32 xc_;
zeus::CTransform x10_transform;
EMappableObjectType x0_type;
EVisMode x4_visibilityMode;
TEditorId x8_objId;
u32 xc_;
zeus::CTransform x10_transform;
struct DoorSurface
{
CMapSurfaceShader m_surface;
CLineRenderer m_outline;
DoorSurface(boo::IGraphicsDataFactory::Context& ctx)
: m_surface(ctx, g_doorVbo, g_doorIbo),
m_outline(ctx, CLineRenderer::EPrimitiveMode::LineLoop, 5, nullptr, false, false, true)
{}
};
std::experimental::optional<DoorSurface> m_doorSurface;
std::experimental::optional<CTexturedQuadFilter> m_texQuadFilter;
struct DoorSurface {
CMapSurfaceShader m_surface;
CLineRenderer m_outline;
DoorSurface(boo::IGraphicsDataFactory::Context& ctx)
: m_surface(ctx, g_doorVbo, g_doorIbo)
, m_outline(ctx, CLineRenderer::EPrimitiveMode::LineLoop, 5, nullptr, false, false, true) {}
};
std::experimental::optional<DoorSurface> m_doorSurface;
std::experimental::optional<CTexturedQuadFilter> m_texQuadFilter;
zeus::CTransform AdjustTransformForType();
std::pair<zeus::CColor, zeus::CColor> GetDoorColors(int idx, const CMapWorldInfo& mwInfo, float alpha) const;
zeus::CTransform AdjustTransformForType();
std::pair<zeus::CColor, zeus::CColor> GetDoorColors(int idx, const CMapWorldInfo& mwInfo, float alpha) const;
public:
CMappableObject(const void* buf);
CMappableObject(CMappableObject&&) = default;
void PostConstruct(const void*);
const zeus::CTransform& GetTransform() const { return x10_transform; }
EMappableObjectType GetType() const { return x0_type; }
void Draw(int, const CMapWorldInfo&, float, bool) const;
void DrawDoorSurface(int curArea, const CMapWorldInfo& mwInfo, float alpha,
int surfIdx, bool needsVtxLoad) const;
zeus::CVector3f BuildSurfaceCenterPoint(int surfIdx) const;
bool IsDoorConnectedToArea(int idx, const CStateManager&) const;
bool IsDoorConnectedToVisitedArea(const CStateManager&) const;
bool IsVisibleToAutoMapper(bool worldVis, const CMapWorldInfo& mwInfo) const;
bool GetIsSeen() const;
CMappableObject(const void* buf);
CMappableObject(CMappableObject&&) = default;
void PostConstruct(const void*);
const zeus::CTransform& GetTransform() const { return x10_transform; }
EMappableObjectType GetType() const { return x0_type; }
void Draw(int, const CMapWorldInfo&, float, bool) const;
void DrawDoorSurface(int curArea, const CMapWorldInfo& mwInfo, float alpha, int surfIdx, bool needsVtxLoad) const;
zeus::CVector3f BuildSurfaceCenterPoint(int surfIdx) const;
bool IsDoorConnectedToArea(int idx, const CStateManager&) const;
bool IsDoorConnectedToVisitedArea(const CStateManager&) const;
bool IsVisibleToAutoMapper(bool worldVis, const CMapWorldInfo& mwInfo) const;
bool GetIsSeen() const;
static void ReadAutoMapperTweaks(const ITweakAutoMapper&);
static bool GetTweakIsMapVisibilityCheat();
static bool IsDoorType(EMappableObjectType type) { return type >= EMappableObjectType::BlueDoor &&
type <= EMappableObjectType::PlasmaDoorFloor2; }
static void Shutdown();
static void ReadAutoMapperTweaks(const ITweakAutoMapper&);
static bool GetTweakIsMapVisibilityCheat();
static bool IsDoorType(EMappableObjectType type) {
return type >= EMappableObjectType::BlueDoor && type <= EMappableObjectType::PlasmaDoorFloor2;
}
static void Shutdown();
};
}
} // namespace urde