Merge pull request #242 from lioncash/const2

CMapWorld: Minor changes
This commit is contained in:
Luke Street 2020-03-18 01:01:45 -04:00 committed by GitHub
commit b3b8c33006
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 70 additions and 67 deletions

View File

@ -194,7 +194,7 @@ bool CAutoMapper::HasCurrentMapUniverseWorld() const {
return false;
}
bool CAutoMapper::CheckDummyWorldLoad(const CStateManager& mgr) {
bool CAutoMapper::CheckDummyWorldLoad(CStateManager& mgr) {
const CMapUniverse::CMapWorldData& mapuWld = x8_mapu->GetMapWorldData(x9c_worldIdx);
auto& dummyWorld = x14_dummyWorlds[x9c_worldIdx];
if (!dummyWorld) {
@ -222,7 +222,7 @@ bool CAutoMapper::CheckDummyWorldLoad(const CStateManager& mgr) {
return true;
}
void CAutoMapper::UpdateHintNavigation(float dt, const CStateManager& mgr) {
void CAutoMapper::UpdateHintNavigation(float dt, CStateManager& mgr) {
SAutoMapperHintStep& nextStep = x1e0_hintSteps.front();
bool oldProcessing = nextStep.x8_processing;
nextStep.x8_processing = true;
@ -321,7 +321,7 @@ void CAutoMapper::SetCurWorldAssetId(CAssetId mlvlId) {
}
}
void CAutoMapper::BeginMapperStateTransition(EAutoMapperState state, const CStateManager& mgr) {
void CAutoMapper::BeginMapperStateTransition(EAutoMapperState state, CStateManager& mgr) {
if (state == x1c0_nextState)
return;
if ((state == EAutoMapperState::MiniMap && x1c0_nextState != EAutoMapperState::MiniMap) ||
@ -378,7 +378,7 @@ void CAutoMapper::CompleteMapperStateTransition(const CStateManager& mgr) {
if (x1c0_nextState == EAutoMapperState::MapScreen) {
const CMapWorldInfo& mwInfo = *g_GameState->StateForWorld(x24_world->IGetWorldAssetId()).MapWorldInfo();
x24_world->IGetMapWorld()->RecalculateWorldSphere(mwInfo, *x24_world);
x24_world->IMapWorld()->RecalculateWorldSphere(mwInfo, *x24_world);
x1d8_flashTimer = 0.f;
x1dc_playerFlashPulse = 0.f;
}
@ -784,7 +784,7 @@ void CAutoMapper::SetShouldRotatingSoundBePlaying(bool b) {
}
}
void CAutoMapper::ProcessMapScreenInput(const CFinalInput& input, const CStateManager& mgr) {
void CAutoMapper::ProcessMapScreenInput(const CFinalInput& input, CStateManager& mgr) {
zeus::CMatrix3f camRot = xa8_renderStates[0].x8_camOrientation.toTransform().buildMatrix3f();
if (x1bc_state == EAutoMapperState::MapScreen) {
if ((input.PA() || input.PSpecialKey(boo::ESpecialKey::Enter)) && x328_ == 0 && HasCurrentMapUniverseWorld())
@ -911,7 +911,7 @@ zeus::CVector2i CAutoMapper::GetMapScreenViewportSize() {
}
float CAutoMapper::GetMapAreaMaxDrawDepth(const CStateManager&, TAreaId aid) const {
return x24_world->IGetMapWorld()->GetCurrentMapAreaDepth(*x24_world, aid);
return x24_world->IMapWorld()->GetCurrentMapAreaDepth(*x24_world, aid);
}
float CAutoMapper::GetMapAreaMiniMapDrawAlphaSurfaceVisited(const CStateManager& stateMgr) {
@ -1224,7 +1224,7 @@ void CAutoMapper::Update(float dt, const CStateManager& mgr) {
else
xa8_renderStates[1].x18_camDist -= 3.f;
} else if (x1bc_state != EAutoMapperState::MiniMap && x1c0_nextState != EAutoMapperState::MiniMap && x24_world) {
x24_world->IGetMapWorld()->RecalculateWorldSphere(
x24_world->IMapWorld()->RecalculateWorldSphere(
*g_GameState->StateForWorld(x24_world->IGetWorldAssetId()).MapWorldInfo(), *x24_world);
}
}
@ -1341,7 +1341,7 @@ void CAutoMapper::Draw(const CStateManager& mgr, const zeus::CTransform& xf, flo
if (x1bc_state != EAutoMapperState::MiniMap && x1c0_nextState != EAutoMapperState::MiniMap) {
if (universeInterp < 1.f && x24_world) {
const CMapWorldInfo& mwInfo = *g_GameState->StateForWorld(x24_world->IGetWorldAssetId()).MapWorldInfo();
const CMapWorld* mw = x24_world->IGetMapWorld();
CMapWorld* mw = x24_world->IMapWorld();
float hintFlash = 0.f;
if (x1e0_hintSteps.size() && x1e0_hintSteps.front().x0_type == SAutoMapperHintStep::Type::ShowBeacon) {
if (xa0_curAreaId == mgr.GetNextAreaId() && x24_world == mgr.GetWorld()) {
@ -1360,35 +1360,37 @@ void CAutoMapper::Draw(const CStateManager& mgr, const zeus::CTransform& xf, flo
}
}
}
zeus::CTransform modelXf = planeXf * preXf;
CMapWorld::CMapWorldDrawParms parms(xa8_renderStates[0].x34_alphaSurfaceVisited * alphaInterp,
xa8_renderStates[0].x38_alphaOutlineVisited * alphaInterp,
xa8_renderStates[0].x3c_alphaSurfaceUnvisited * alphaInterp,
xa8_renderStates[0].x40_alphaOutlineUnvisited * alphaInterp, mapAlpha, 2.f,
mgr, modelXf, camXf, *x24_world, mwInfo, x1dc_playerFlashPulse, hintFlash,
objectScale, true);
const zeus::CTransform modelXf = planeXf * preXf;
const CMapWorld::CMapWorldDrawParms parms(xa8_renderStates[0].x34_alphaSurfaceVisited * alphaInterp,
xa8_renderStates[0].x38_alphaOutlineVisited * alphaInterp,
xa8_renderStates[0].x3c_alphaSurfaceUnvisited * alphaInterp,
xa8_renderStates[0].x40_alphaOutlineUnvisited * alphaInterp, mapAlpha,
2.f, mgr, modelXf, camXf, *x24_world, mwInfo, x1dc_playerFlashPulse,
hintFlash, objectScale, true);
mw->Draw(parms, xa0_curAreaId, xa0_curAreaId, xa8_renderStates[0].x2c_drawDepth1,
xa8_renderStates[0].x30_drawDepth2, true);
}
} else if (IsInMapperState(EAutoMapperState::MiniMap)) {
const CMapWorld* mw = x24_world->IGetMapWorld();
CMapWorld* mw = x24_world->IMapWorld();
const CMapWorldInfo& mwInfo = *g_GameState->StateForWorld(x24_world->IGetWorldAssetId()).MapWorldInfo();
CMapWorld::CMapWorldDrawParms parms(xa8_renderStates[0].x34_alphaSurfaceVisited * alphaInterp,
xa8_renderStates[0].x38_alphaOutlineVisited * alphaInterp,
xa8_renderStates[0].x3c_alphaSurfaceUnvisited * alphaInterp,
xa8_renderStates[0].x40_alphaOutlineUnvisited * alphaInterp, mapAlpha, 1.f, mgr,
planeXf, camXf, *x24_world, mwInfo, 0.f, 0.f, objectScale, false);
const CMapWorld::CMapWorldDrawParms parms(xa8_renderStates[0].x34_alphaSurfaceVisited * alphaInterp,
xa8_renderStates[0].x38_alphaOutlineVisited * alphaInterp,
xa8_renderStates[0].x3c_alphaSurfaceUnvisited * alphaInterp,
xa8_renderStates[0].x40_alphaOutlineUnvisited * alphaInterp, mapAlpha,
1.f, mgr, planeXf, camXf, *x24_world, mwInfo, 0.f, 0.f, objectScale,
false);
mw->Draw(parms, xa0_curAreaId, xa4_otherAreaId, xa8_renderStates[0].x2c_drawDepth1,
xa8_renderStates[0].x30_drawDepth2, false);
} else {
const CMapWorld* mw = x24_world->IGetMapWorld();
CMapWorld* mw = x24_world->IMapWorld();
const CMapWorldInfo& mwInfo = *g_GameState->StateForWorld(x24_world->IGetWorldAssetId()).MapWorldInfo();
zeus::CTransform modelXf = planeXf * preXf;
CMapWorld::CMapWorldDrawParms parms(xa8_renderStates[0].x34_alphaSurfaceVisited * alphaInterp,
xa8_renderStates[0].x38_alphaOutlineVisited * alphaInterp,
xa8_renderStates[0].x3c_alphaSurfaceUnvisited * alphaInterp,
xa8_renderStates[0].x40_alphaOutlineUnvisited * alphaInterp, mapAlpha, 2.f, mgr,
modelXf, camXf, *x24_world, mwInfo, 0.f, 0.f, objectScale, true);
const CMapWorld::CMapWorldDrawParms parms(xa8_renderStates[0].x34_alphaSurfaceVisited * alphaInterp,
xa8_renderStates[0].x38_alphaOutlineVisited * alphaInterp,
xa8_renderStates[0].x3c_alphaSurfaceUnvisited * alphaInterp,
xa8_renderStates[0].x40_alphaOutlineUnvisited * alphaInterp, mapAlpha,
2.f, mgr, modelXf, camXf, *x24_world, mwInfo, 0.f, 0.f, objectScale,
true);
mw->Draw(parms, xa0_curAreaId, xa0_curAreaId, xa8_renderStates[0].x2c_drawDepth1,
xa8_renderStates[0].x30_drawDepth2, false);
}
@ -1410,8 +1412,8 @@ void CAutoMapper::Draw(const CStateManager& mgr, const zeus::CTransform& xf, flo
}
}
CMapUniverse::CMapUniverseDrawParms parms(universeInterp, x9c_worldIdx, g_GameState->CurrentWorldAssetId(), hexIdx,
x1dc_playerFlashPulse, mgr, planeXf, camXf);
const CMapUniverse::CMapUniverseDrawParms parms(universeInterp, x9c_worldIdx, g_GameState->CurrentWorldAssetId(),
hexIdx, x1dc_playerFlashPulse, mgr, planeXf, camXf);
x8_mapu->Draw(parms, zeus::skZero3f, 0.f, 0.f);
}
@ -1601,7 +1603,7 @@ CAssetId CAutoMapper::GetAreaHintDescriptionString(CAssetId mreaId) {
return -1;
}
void CAutoMapper::OnNewInGameGuiState(EInGameGuiState state, const CStateManager& mgr) {
void CAutoMapper::OnNewInGameGuiState(EInGameGuiState state, CStateManager& mgr) {
if (state == EInGameGuiState::MapScreen) {
MP1::CMain::EnsureWorldPaksReady();
const CWorld& wld = *mgr.GetWorld();

View File

@ -128,7 +128,7 @@ private:
ELoadPhase x4_loadPhase = ELoadPhase::LoadResources;
TLockedToken<CMapUniverse> x8_mapu;
std::vector<std::unique_ptr<IWorld>> x14_dummyWorlds;
const CWorld* x24_world;
CWorld* x24_world;
TLockedToken<CGuiFrame> x28_frmeMapScreen; // Used to be ptr
bool m_frmeInitialized = false;
TLockedToken<CModel> x30_miniMapSamus;
@ -197,8 +197,8 @@ private:
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);
bool CheckDummyWorldLoad(CStateManager& mgr);
void UpdateHintNavigation(float dt, CStateManager& mgr);
static zeus::CVector2i GetMiniMapViewportSize();
static zeus::CVector2i GetMapScreenViewportSize();
static float GetMapAreaMiniMapDrawDepth() { return 2.f; }
@ -241,7 +241,7 @@ public:
void Update(float dt, const CStateManager& mgr);
void Draw(const CStateManager&, const zeus::CTransform&, float) const;
float GetTimeIntoInterpolation() const { return x1c8_interpTime; }
void BeginMapperStateTransition(EAutoMapperState, const CStateManager&);
void BeginMapperStateTransition(EAutoMapperState, CStateManager&);
void CompleteMapperStateTransition(const CStateManager&);
void ResetInterpolationTimer(float);
SAutoMapperRenderState BuildMiniMapWorldRenderState(const CStateManager&, const zeus::CQuaternion&, TAreaId) const;
@ -250,7 +250,7 @@ public:
SAutoMapperRenderState BuildMapScreenUniverseRenderState(const CStateManager&, const zeus::CQuaternion&,
TAreaId) const;
void LeaveMapScreenState();
void ProcessMapScreenInput(const CFinalInput& input, const CStateManager& mgr);
void ProcessMapScreenInput(const CFinalInput& input, 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&,
@ -267,7 +267,7 @@ public:
bool IsFullyOutOfMiniMapState() const {
return x1bc_state != EAutoMapperState::MiniMap && x1c0_nextState != EAutoMapperState::MiniMap;
}
void OnNewInGameGuiState(EInGameGuiState, const CStateManager&);
void OnNewInGameGuiState(EInGameGuiState, CStateManager&);
float GetInterp() const {
if (x1c4_interpDur > 0.f)
return x1c8_interpTime / x1c4_interpDur;

View File

@ -1,5 +1,7 @@
#include "Runtime/AutoMapper/CMapWorld.hpp"
#include <algorithm>
#include "Runtime/CSimplePool.hpp"
#include "Runtime/CStateManager.hpp"
#include "Runtime/GameGlobalObjects.hpp"
@ -93,7 +95,7 @@ void CMapWorld::MoveMapAreaToList(CMapWorld::CMapAreaData* data, CMapWorld::EMap
x10_listHeads[int(list)] = data;
}
s32 CMapWorld::GetCurrentMapAreaDepth(const IWorld& wld, TAreaId aid) const {
s32 CMapWorld::GetCurrentMapAreaDepth(const IWorld& wld, TAreaId aid) {
ClearTraversedFlags();
std::vector<CMapAreaBFSInfo> info;
info.reserve(x0_areas.size());
@ -118,8 +120,8 @@ std::vector<int> CMapWorld::GetVisibleAreas(const IWorld& wld, const CMapWorldIn
return ret;
}
void CMapWorld::Draw(const CMapWorld::CMapWorldDrawParms& parms, int curArea, int otherArea, float depth1, float depth2,
bool inMapScreen) const {
void CMapWorld::Draw(const CMapWorldDrawParms& parms, int curArea, int otherArea, float depth1, float depth2,
bool inMapScreen) {
if (depth1 == 0.f && depth2 == 0.f)
return;
SCOPED_GRAPHICS_DEBUG_GROUP("CMapWorld::Draw", zeus::skBlue);
@ -130,7 +132,7 @@ void CMapWorld::Draw(const CMapWorld::CMapWorldDrawParms& parms, int curArea, in
std::vector<CMapAreaBFSInfo> bfsInfos;
bfsInfos.reserve(x0_areas.size());
if (curArea != otherArea) {
const_cast<CMapWorld*>(this)->x20_traversed[otherArea] = true;
x20_traversed[otherArea] = true;
DoBFS(parms.GetWorld(), curArea, areaDepth, depth1, depth2, true, bfsInfos);
float lowD1 = std::ceil(depth1 - 1.f);
@ -150,7 +152,7 @@ void CMapWorld::Draw(const CMapWorld::CMapWorldDrawParms& parms, int curArea, in
int otherDepth = std::ceil(std::max(newD1, newD2));
if (parms.GetWorld().IGetAreaAlways(otherArea)->IIsActive()) {
const_cast<CMapWorld*>(this)->x20_traversed[otherArea] = false;
x20_traversed[otherArea] = false;
DoBFS(parms.GetWorld(), otherArea, otherDepth, newD1, newD2, true, bfsInfos);
}
} else {
@ -161,13 +163,13 @@ void CMapWorld::Draw(const CMapWorld::CMapWorldDrawParms& parms, int curArea, in
}
void CMapWorld::DoBFS(const IWorld& wld, int startArea, int areaCount, float surfDepth, float outlineDepth,
bool checkLoad, std::vector<CMapAreaBFSInfo>& bfsInfos) const {
bool checkLoad, std::vector<CMapAreaBFSInfo>& bfsInfos) {
if (areaCount <= 0 || !IsMapAreaValid(wld, startArea, checkLoad))
return;
size_t size = bfsInfos.size();
bfsInfos.emplace_back(startArea, 1, surfDepth, outlineDepth);
const_cast<CMapWorld*>(this)->x20_traversed[startArea] = true;
x20_traversed[startArea] = true;
for (; size != bfsInfos.size(); ++size) {
CMapAreaBFSInfo& testInfo = bfsInfos[size];
@ -182,7 +184,7 @@ void CMapWorld::DoBFS(const IWorld& wld, int startArea, int areaCount, float sur
TAreaId attId = area->IGetAttachedAreaId(i);
if (IsMapAreaValid(wld, attId, checkLoad) && !x20_traversed[attId]) {
bfsInfos.emplace_back(attId, testInfo.GetDepth() + 1, surfDepth, outlineDepth);
const_cast<CMapWorld*>(this)->x20_traversed[attId] = true;
x20_traversed[attId] = true;
}
}
}
@ -618,7 +620,7 @@ static Circle MinCircle(const std::vector<zeus::CVector2f>& coords) {
return ret;
}
void CMapWorld::RecalculateWorldSphere(const CMapWorldInfo& mwInfo, const IWorld& wld) const {
void CMapWorld::RecalculateWorldSphere(const CMapWorldInfo& mwInfo, const IWorld& wld) {
std::vector<zeus::CVector2f> coords;
coords.reserve(x0_areas.size() * 8);
float zMin = FLT_MAX;
@ -638,11 +640,10 @@ void CMapWorld::RecalculateWorldSphere(const CMapWorldInfo& mwInfo, const IWorld
}
}
Circle circle = MinCircle(coords);
const_cast<CMapWorld*>(this)->x3c_worldSphereRadius = circle.x8_radius;
const_cast<CMapWorld*>(this)->x30_worldSpherePoint =
zeus::CVector3f(circle.x0_point.x(), circle.x0_point.y(), (zMin + zMax) * 0.5f);
const_cast<CMapWorld*>(this)->x40_worldSphereHalfDepth = (zMax - zMin) * 0.5f;
const Circle circle = MinCircle(coords);
x3c_worldSphereRadius = circle.x8_radius;
x30_worldSpherePoint = zeus::CVector3f(circle.x0_point.x(), circle.x0_point.y(), (zMin + zMax) * 0.5f);
x40_worldSphereHalfDepth = (zMax - zMin) * 0.5f;
}
zeus::CVector3f CMapWorld::ConstrainToWorldVolume(const zeus::CVector3f& point, const zeus::CVector3f& lookVec) const {
@ -670,10 +671,8 @@ zeus::CVector3f CMapWorld::ConstrainToWorldVolume(const zeus::CVector3f& point,
return ret;
}
void CMapWorld::ClearTraversedFlags() const {
std::vector<bool>& flags = const_cast<CMapWorld*>(this)->x20_traversed;
for (size_t i = 0; i < flags.size(); ++i)
flags[i] = false;
void CMapWorld::ClearTraversedFlags() {
std::fill(x20_traversed.begin(), x20_traversed.end(), false);
}
CFactoryFnReturn FMapWorldFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& param,

View File

@ -142,22 +142,24 @@ private:
float x40_worldSphereHalfDepth = 0.f;
public:
CMapWorld(CInputStream&);
explicit CMapWorld(CInputStream& in);
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 IsMapAreaInBFSInfoVector(const CMapAreaData* area, const std::vector<CMapAreaBFSInfo>& vec) const;
void SetWhichMapAreasLoaded(const IWorld& wld, 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;
void MoveMapAreaToList(CMapAreaData* data, EMapAreaList list);
s32 GetCurrentMapAreaDepth(const IWorld& wld, TAreaId aid);
std::vector<int> GetVisibleAreas(const IWorld& wld, const CMapWorldInfo& mwInfo) const;
void Draw(const CMapWorldDrawParms& parms, int curArea, int otherArea, float depth1, float depth2, bool inMapScreen);
void DoBFS(const IWorld& wld, int startArea, int areaCount, float surfDepth, float outlineDepth, bool checkLoad,
std::vector<CMapAreaBFSInfo>& bfsInfos);
bool IsMapAreaValid(const IWorld& wld, int areaIdx, bool checkLoad) const;
void DrawAreas(const CMapWorldDrawParms& parms, int selArea, const std::vector<CMapAreaBFSInfo>& bfsInfos,
bool inMapScreen) const;
void RecalculateWorldSphere(const CMapWorldInfo& mwInfo, const IWorld& wld);
zeus::CVector3f ConstrainToWorldVolume(const zeus::CVector3f& point, const zeus::CVector3f& lookVec) const;
void ClearTraversedFlags();
};
CFactoryFnReturn FMapWorldFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& param,