diff --git a/Runtime/AutoMapper/CAutoMapper.cpp b/Runtime/AutoMapper/CAutoMapper.cpp index ef97354fd..8cb468a46 100644 --- a/Runtime/AutoMapper/CAutoMapper.cpp +++ b/Runtime/AutoMapper/CAutoMapper.cpp @@ -417,9 +417,42 @@ void CAutoMapper::BeginMapperStateTransition(EAutoMapperState state, const CStat } } -void CAutoMapper::CompleteMapperStateTransition(const CStateManager&) +void CAutoMapper::CompleteMapperStateTransition(const CStateManager& mgr) { + if (x1bc_state == EAutoMapperState::MapScreenUniverse) + TransformRenderStatesUniverseToWorld(); + if (x1c0_nextState == EAutoMapperState::MapScreen) + { + const CMapWorldInfo& mwInfo = *g_GameState->StateForWorld(x24_world->IGetWorldAssetId()).MapWorldInfo(); + x24_world->IGetMapWorld()->RecalculateWorldSphere(mwInfo, *x24_world); + x1d8_flashTimer = 0.f; + x1dc_playerFlashPulse = 0.f; + } + + if (x1c0_nextState == EAutoMapperState::MiniMap) + { + x28_frmeMapScreen = TLockedToken(); + m_frmeInitialized = false; + x2fc_textpane_hint = nullptr; + x300_textpane_instructions = nullptr; + x304_textpane_instructions1 = nullptr; + x308_textpane_instructions2 = nullptr; + x2f8_textpane_areaname = nullptr; + x30c_basewidget_leftPane = nullptr; + x310_basewidget_yButtonPane = nullptr; + x314_basewidget_bottomPane = nullptr; + SetResLockState(x210_lstick, false); + SetResLockState(x25c_cstick, false); + SetResLockState(x2a8_ltrigger, false); + SetResLockState(x2bc_rtrigger, false); + SetResLockState(x2d0_abutton, false); + } + + if (x1c0_nextState == EAutoMapperState::MapScreenUniverse && x328_ == 1) + LeaveMapScreen(mgr); + + x1bc_state = x1c0_nextState; } void CAutoMapper::ResetInterpolationTimer(float t) @@ -812,7 +845,7 @@ void CAutoMapper::ProcessMapScreenInput(const CFinalInput& input, const CStateMa zeus::CMatrix3f camRot = xa8_renderStates[0].x8_camOrientation.toTransform().buildMatrix3f(); if (x1bc_state == EAutoMapperState::MapScreen) { - if (input.PA() && !x328_ && HasCurrentMapUniverseWorld()) + if (input.PA() && x328_ == 0 && HasCurrentMapUniverseWorld()) BeginMapperStateTransition(EAutoMapperState::MapScreenUniverse, mgr); } else if (x1bc_state == EAutoMapperState::MapScreenUniverse && input.PA()) @@ -981,7 +1014,7 @@ float CAutoMapper::GetDesiredMiniMapCameraDistance(const CStateManager& mgr) con const IGameArea* area = x24_world->IGetAreaAlways(xa0_curAreaId); const CMapArea* mapa = mw->GetMapArea(xa0_curAreaId); bool oneMiniMapArea = g_tweakAutoMapper->GetShowOneMiniMapArea(); - for (int i = -1 ; i < (oneMiniMapArea ? 0 : area->IGetNumAttachedAreas()) ; ++i) + for (int i = -1 ; i < (oneMiniMapArea ? 0 : int(area->IGetNumAttachedAreas())) ; ++i) { TAreaId aid = i == -1 ? xa0_curAreaId : area->IGetAttachedAreaId(i); const CMapArea* attMapa = mw->GetMapArea(aid); @@ -1032,7 +1065,7 @@ void CAutoMapper::ProcessControllerInput(const CFinalInput& input, CStateManager CheckDummyWorldLoad(mgr); else if (x1e0_hintSteps.size()) UpdateHintNavigation(input.DeltaTime(), mgr); - else if (!x328_) + else if (x328_ == 0) ProcessMapScreenInput(input, mgr); } } @@ -1150,7 +1183,7 @@ void CAutoMapper::ProcessControllerInput(const CFinalInput& input, CStateManager if (input.PZ() || input.PB()) { - if (!x328_) + if (x328_ == 0) { if (CanLeaveMapScreenInternal(mgr)) LeaveMapScreen(mgr); diff --git a/Runtime/AutoMapper/CMapWorld.cpp b/Runtime/AutoMapper/CMapWorld.cpp index b026413e0..44c3c1b1c 100644 --- a/Runtime/AutoMapper/CMapWorld.cpp +++ b/Runtime/AutoMapper/CMapWorld.cpp @@ -363,7 +363,7 @@ void CMapWorld::DrawAreas(const CMapWorld::CMapWorldDrawParms& parms, int selAre std::sort(sortInfos.begin(), sortInfos.end(), [](const CMapObjectSortInfo& a, const CMapObjectSortInfo& b) { - return a.GetZDistance() < b.GetZDistance(); + return a.GetZDistance() > b.GetZDistance(); }); int lastAreaIdx = -1; diff --git a/Runtime/AutoMapper/CMappableObject.cpp b/Runtime/AutoMapper/CMappableObject.cpp index 4e39c3ff1..2b414f43d 100644 --- a/Runtime/AutoMapper/CMappableObject.cpp +++ b/Runtime/AutoMapper/CMappableObject.cpp @@ -73,10 +73,9 @@ zeus::CTransform CMappableObject::AdjustTransformForType() } else if (x0_type >= EMappableObjectType::BlueDoor || x0_type <= EMappableObjectType::PlasmaDoorFloor2) { - zeus::CMatrix4f tmp = x10_transform.toMatrix4f().transposed(); - return zeus::CTransform::Translate(tmp.m[1][0], tmp.m[2][1], tmp[3][2]); + return x10_transform; } - return x10_transform; + return zeus::CTransform::Translate(x10_transform.origin); } std::pair @@ -155,8 +154,8 @@ void CMappableObject::Draw(int curArea, const CMapWorldInfo& mwInfo, line.Reset(); line.AddVertex(skDoorVerts[baseIdx[0]], colors.second, 1.f); line.AddVertex(skDoorVerts[baseIdx[1]], colors.second, 1.f); - line.AddVertex(skDoorVerts[baseIdx[2]], colors.second, 1.f); line.AddVertex(skDoorVerts[baseIdx[3]], colors.second, 1.f); + line.AddVertex(skDoorVerts[baseIdx[2]], colors.second, 1.f); line.Render(); } } @@ -229,8 +228,8 @@ void CMappableObject::DrawDoorSurface(int curArea, const CMapWorldInfo& mwInfo, line.Reset(); line.AddVertex(skDoorVerts[baseIdx[0]], colors.second, 1.f); line.AddVertex(skDoorVerts[baseIdx[1]], colors.second, 1.f); - line.AddVertex(skDoorVerts[baseIdx[2]], colors.second, 1.f); line.AddVertex(skDoorVerts[baseIdx[3]], colors.second, 1.f); + line.AddVertex(skDoorVerts[baseIdx[2]], colors.second, 1.f); line.Render(); } diff --git a/Runtime/AutoMapper/CMappableObject.hpp b/Runtime/AutoMapper/CMappableObject.hpp index f3f0f627a..bf0ae03e8 100644 --- a/Runtime/AutoMapper/CMappableObject.hpp +++ b/Runtime/AutoMapper/CMappableObject.hpp @@ -74,7 +74,7 @@ private: CLineRenderer m_outline; DoorSurface(boo::IGraphicsDataFactory::Context& ctx) : m_surface(ctx, g_doorVbo, g_doorIbo), - m_outline(ctx, CLineRenderer::EPrimitiveMode::LineStrip, 5, nullptr, false) + m_outline(ctx, CLineRenderer::EPrimitiveMode::LineLoop, 5, nullptr, false) {} }; std::experimental::optional m_doorSurface; diff --git a/Runtime/Camera/CCameraFilter.cpp b/Runtime/Camera/CCameraFilter.cpp index 176747ca2..d661758d7 100644 --- a/Runtime/Camera/CCameraFilter.cpp +++ b/Runtime/Camera/CCameraFilter.cpp @@ -179,40 +179,17 @@ void CCameraBlurPass::Draw() if (x10_curType == EBlurType::NoBlur) return; - SClipScreenRect rect(g_Viewport); - CGraphics::ResolveSpareTexture(rect); - if (x10_curType == EBlurType::Xray) { - float blurX = x1c_curValue * g_tweakGui->GetXrayBlurScaleLinear() * 0.25f; - float blurY = x1c_curValue * g_tweakGui->GetXrayBlurScaleQuadratic() * 0.25f; - - for (int i=0 ; i<4 ; ++i) - { - float iflt = i; - float uvScale = (1.f - (blurX * iflt + blurY * iflt * iflt)); - float uvOffset = uvScale * -0.5f + 0.5f; - } + if (!m_xrayShader) + m_xrayShader.emplace(x0_paletteTex); + m_xrayShader->draw(x1c_curValue); } else { - for (int i=0 ; i<7 ; ++i) - { - float amtX = 0.f; - float amtY = 0.f; - if (i) - { - float tmp = i - 1; - tmp *= 2.f * M_PIF; - tmp /= 6.f; - - amtX = std::cos(tmp); - amtX *= x1c_curValue / 640.f; - - amtY = std::sin(tmp); - amtY *= x1c_curValue / 448.f; - } - } + if (!m_shader) + m_shader.emplace(); + m_shader->draw(x1c_curValue); } } diff --git a/Runtime/Camera/CCameraFilter.hpp b/Runtime/Camera/CCameraFilter.hpp index f1a53b442..89bf57b34 100644 --- a/Runtime/Camera/CCameraFilter.hpp +++ b/Runtime/Camera/CCameraFilter.hpp @@ -4,6 +4,8 @@ #include "zeus/CColor.hpp" #include "RetroTypes.hpp" #include "CToken.hpp" +#include "Graphics/Shaders/CCameraBlurFilter.hpp" +#include "Graphics/Shaders/CXRayBlurFilter.hpp" namespace urde { @@ -103,6 +105,9 @@ class CCameraBlurPass //bool x2d_noPersistentCopy = false; //u32 x30_persistentBuf = 0; + mutable std::experimental::optional m_shader; + mutable std::experimental::optional m_xrayShader; + public: void Draw(); void Update(float dt); diff --git a/Runtime/Graphics/Shaders/CMapSurfaceShaderGLSL.cpp b/Runtime/Graphics/Shaders/CMapSurfaceShaderGLSL.cpp index c780a90d6..ea284ea2f 100644 --- a/Runtime/Graphics/Shaders/CMapSurfaceShaderGLSL.cpp +++ b/Runtime/Graphics/Shaders/CMapSurfaceShaderGLSL.cpp @@ -91,7 +91,7 @@ CMapSurfaceShader::Initialize(boo::GLDataFactory::Context& ctx) const char* uniNames[] = {"MapSurfaceUniform"}; s_Pipeline = ctx.newShaderPipeline(VS, FS, 0, nullptr, 1, uniNames, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, - boo::Primitive::TriStrips, boo::ZTest::LEqual, false, true, + boo::Primitive::TriStrips, boo::ZTest::None, false, true, false, boo::CullMode::Backface); return new CMapSurfaceShaderGLDataBindingFactory; } @@ -113,7 +113,7 @@ CMapSurfaceShader::Initialize(boo::VulkanDataFactory::Context& ctx) s_VtxFmt = ctx.newVertexFormat(1, VtxVmt); s_Pipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, - boo::ZTest::LEqual, false, true, false, boo::CullMode::Backface); + boo::ZTest::None, false, true, false, boo::CullMode::Backface); return new CMapSurfaceShaderVulkanDataBindingFactory; } diff --git a/Runtime/Graphics/Shaders/CMapSurfaceShaderHLSL.cpp b/Runtime/Graphics/Shaders/CMapSurfaceShaderHLSL.cpp index f6cc5496e..99e44a894 100644 --- a/Runtime/Graphics/Shaders/CMapSurfaceShaderHLSL.cpp +++ b/Runtime/Graphics/Shaders/CMapSurfaceShaderHLSL.cpp @@ -72,7 +72,7 @@ CMapSurfaceShader::Initialize(boo::ID3DDataFactory::Context& ctx) s_VtxFmt = ctx.newVertexFormat(1, VtxVmt); s_Pipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr, nullptr, s_VtxFmt, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, - boo::ZTest::LEqual, false, true, false, boo::CullMode::Backface); + boo::ZTest::None, false, true, false, boo::CullMode::Backface); return new CMapSurfaceShaderD3DDataBindingFactory; } diff --git a/Runtime/Graphics/Shaders/CMapSurfaceShaderMetal.cpp b/Runtime/Graphics/Shaders/CMapSurfaceShaderMetal.cpp index 62fbed474..e701b2f1d 100644 --- a/Runtime/Graphics/Shaders/CMapSurfaceShaderMetal.cpp +++ b/Runtime/Graphics/Shaders/CMapSurfaceShaderMetal.cpp @@ -76,7 +76,7 @@ CMapSurfaceShader::Initialize(boo::MetalDataFactory::Context& ctx) s_Pipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, - boo::ZTest::LEqual, false, true, false, boo::CullMode::Backface); + boo::ZTest::None, false, true, false, boo::CullMode::Backface); return new CMapSurfaceShaderMetalDataBindingFactory; } diff --git a/Runtime/Graphics/Shaders/CXRayBlurFilter.cpp b/Runtime/Graphics/Shaders/CXRayBlurFilter.cpp index b491b25b2..c08b2ee82 100644 --- a/Runtime/Graphics/Shaders/CXRayBlurFilter.cpp +++ b/Runtime/Graphics/Shaders/CXRayBlurFilter.cpp @@ -33,10 +33,8 @@ void CXRayBlurFilter::draw(float amount) { CGraphics::ResolveSpareTexture(CGraphics::g_CroppedViewport); - float blurL = amount * 0.0014f * 0.25f; - float blurQ = amount * 0.0000525f * 0.25f; - //float blurL = amount * g_tweakGui->GetXrayBlurScaleLinear() * 0.25f; - //float blurQ = amount * g_tweakGui->GetXrayBlurScaleQuadratic() * 0.25f; + float blurL = amount * g_tweakGui->GetXrayBlurScaleLinear() * 0.25f; + float blurQ = amount * g_tweakGui->GetXrayBlurScaleQuadratic() * 0.25f; for (int i=0 ; i<4 ; ++i) { diff --git a/Runtime/MP1/CInGameGuiManager.cpp b/Runtime/MP1/CInGameGuiManager.cpp index 709e01f02..e28faebb1 100644 --- a/Runtime/MP1/CInGameGuiManager.cpp +++ b/Runtime/MP1/CInGameGuiManager.cpp @@ -319,7 +319,7 @@ void CInGameGuiManager::OnNewPauseScreenState(CArchitectureQueue& archQueue) { if (x1c0_nextState != EInGameGuiState::PauseGame && x1c0_nextState != EInGameGuiState::PauseLogBook) { - if (x48_pauseScreen->IsTransitioning()) + if (x48_pauseScreen && x48_pauseScreen->IsTransitioning()) return; x48_pauseScreen.reset(); } @@ -481,7 +481,7 @@ void CInGameGuiManager::Update(CStateManager& stateMgr, float dt, CArchitectureQ { if (x1c0_nextState == EInGameGuiState::Zero || x1c0_nextState == EInGameGuiState::InGame) TryReloadAreaTextures(); - if ((x1bc_prevState == x1c0_nextState || !x1e8_enableAutoMapper) && + if ((!x38_autoMapper->IsInMapperStateTransition() || !x1e8_enableAutoMapper) && x3c_pauseScreenBlur->IsNotTransitioning()) OnNewPauseScreenState(archQueue); } diff --git a/hecl b/hecl index 7fe1cb832..97734162b 160000 --- a/hecl +++ b/hecl @@ -1 +1 @@ -Subproject commit 7fe1cb8320ee23d115a222980bba96508a139920 +Subproject commit 97734162b1cbebac86078c07f4586a977091a9a7