From 10fd8bbea23fed2f7a0ea76f4b2f7802f7745095 Mon Sep 17 00:00:00 2001 From: LHoG <1476261+lhog@users.noreply.github.com> Date: Sat, 13 Mar 2021 16:29:54 +0300 Subject: [PATCH] Fixed 625af772e5e0ce09eab9fdece959169893e97e9e --- rts/Game/UI/MiniMap.cpp | 23 +++++++++++++++++++++++ rts/Game/UI/MiniMap.h | 8 ++++++++ 2 files changed, 31 insertions(+) diff --git a/rts/Game/UI/MiniMap.cpp b/rts/Game/UI/MiniMap.cpp index fa9de56cf9..d7fc2571e4 100644 --- a/rts/Game/UI/MiniMap.cpp +++ b/rts/Game/UI/MiniMap.cpp @@ -393,6 +393,29 @@ void CMiniMap::UpdateGeometry() curPos.x = Clamp(curPos.x, 0, globalRendering->viewSizeX - curDim.x); } + { + // Draw{WorldStuff} transform + viewMats[0].LoadIdentity(); + viewMats[0].Translate(UpVector); + viewMats[0].Scale({ +1.0f / (mapDims.mapx * SQUARE_SIZE), -1.0f / (mapDims.mapy * SQUARE_SIZE), 1.0f }); + viewMats[0].RotateX(90.0f * math::DEG_TO_RAD); // rotate to match real 'world' coordinates + viewMats[0].Scale(XZVector + UpVector * 0.0001f); // (invertibly) flatten; LuaOpenGL::DrawScreen uses persp-proj so z-values influence x&y + + viewMats[1].LoadIdentity(); + viewMats[1].Translate(UpVector); + // heightmap (squares) to minimap + viewMats[1].Scale({ 1.0f / mapDims.mapx, -1.0f / mapDims.mapy, 1.0f }); + // worldmap (elmos) to minimap + // viewMats[1].Scale({1.0f / (mapDims.mapx * SQUARE_SIZE), -1.0f / (mapDims.mapy * SQUARE_SIZE), 1.0f}); + + viewMats[2].LoadIdentity(); + viewMats[2].Scale({ 1.0f / curDim.x, 1.0f / curDim.y, 1.0f }); + + projMats[0] = CMatrix44f::ClipOrthoProj01(); + projMats[1] = CMatrix44f::ClipOrthoProj(0.0f, 1.0f, 0.0f, 1.0f, 0.0f, -1.0f, globalRendering->supportClipSpaceControl * 1.0f); + projMats[2] = projMats[1]; + } + lastWindowSizeX = globalRendering->viewSizeX; lastWindowSizeY = globalRendering->viewSizeY; diff --git a/rts/Game/UI/MiniMap.h b/rts/Game/UI/MiniMap.h index 61779ba437..a7aad702d3 100644 --- a/rts/Game/UI/MiniMap.h +++ b/rts/Game/UI/MiniMap.h @@ -7,6 +7,7 @@ #include #include "InputReceiver.h" #include "Rendering/GL/FBO.h" +#include "System/Matrix44f.h" #include "System/Color.h" #include "System/float3.h" #include "System/type2.h" @@ -69,6 +70,9 @@ class CMiniMap : public CInputReceiver { const unsigned char* GetAllyTeamIconColor() const { return &allyColor[0]; } const unsigned char* GetEnemyTeamIconColor() const { return &enemyColor[0]; } + const CMatrix44f& GetViewMat(unsigned int idx) const { return viewMats[idx]; } + const CMatrix44f& GetProjMat(unsigned int idx) const { return projMats[idx]; } + void ApplyConstraintsMatrix() const; protected: @@ -171,6 +175,10 @@ class CMiniMap : public CInputReceiver { SColor allyColor; SColor enemyColor; + // transforms for [0] := Draw, [1] := DrawInMiniMap, [2] := Lua DrawInMiniMap + CMatrix44f viewMats[3]; + CMatrix44f projMats[3]; + FBO fbo; FBO fboResolve; GLuint minimapTex = 0;