Changeset 25241

Timestamp:
Apr 12, 2021, 2:39:07 PM (3 years ago)
Author:
Vladislav Belov
Message:

Crops minimap view bounds to map size.

Differential Revision: https://code.wildfiregames.com/D3837

Location:
ps/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • ps/trunk/binaries/data/mods/public/gui/session/minimap/MiniMap.xml

    r25229 r25241  
    55    type="image"
    66>
    7     <!-- MiniMap -->
    8     <object name="minimap" size="8 8 100%-8 100%-8" type="minimap" mask="true"/>
    97
    108    <!-- Background image -->
     
    3432        hotkey="session.diplomacycolors"
    3533    />
     34
     35
     36
    3637</object>
  • ps/trunk/source/gui/ObjectTypes/CMiniMap.cpp

    r25231 r25241  
    5151#include "simulation2/system/ParamNode.h"
    5252
     53
    5354#include <cmath>
     55
    5456
    5557extern bool g_GameRestarted;
     58
     59
     60
    5661
    5762// Set max drawn entities to UINT16_MAX for now, which is more than enough
     
    5964const u16 MAX_ENTITIES_DRAWN = 65535;
    6065
    61 static unsigned int ScaleColor(unsigned int color, float x)
     66unsigned int ScaleColor(unsigned int color, float x)
    6267{
    6368    unsigned int r = unsigned(float(color & 0xff) * x);
     
    6671    return (0xff000000 | b | g<<8 | r<<16);
    6772}
     73
     74
     75
     76
     77
     78
     79
     80
     81
     82
     83
     84
     85
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
     100
     101
     102
     103
     104
     105
     106
    68107
    69108const CStr CMiniMap::EventNameWorldClick = "WorldClick";
     
    260299// This sets up and draws the rectangle on the minimap
    261300//  which represents the view of the camera in the world.
    262 void CMiniMap::DrawViewRect(CMatrix3D transform) const
     301void CMiniMap::DrawViewRect( transform) const
    263302{
    264303    // Compute the camera frustum intersected with a fixed-height plane.
     
    269308    const float invTileMapSize = 1.0f / float(TERRAIN_TILE_SIZE * m_MapSize);
    270309
    271     CVector3D hitPt[4];
    272     hitPt[0] = m_Camera->GetWorldCoordinates(0, g_Renderer.GetHeight(), h);
    273     hitPt[1] = m_Camera->GetWorldCoordinates(g_Renderer.GetWidth(), g_Renderer.GetHeight(), h);
    274     hitPt[2] = m_Camera->GetWorldCoordinates(g_Renderer.GetWidth(), 0, h);
    275     hitPt[3] = m_Camera->GetWorldCoordinates(0, 0, h);
    276 
    277     float ViewRect[4][2];
    278     for (int i = 0; i < 4; ++i)
    279     {
    280         // convert to minimap space
    281         ViewRect[i][0] = (width * hitPt[i].X * invTileMapSize);
    282         ViewRect[i][1] = (height * hitPt[i].Z * invTileMapSize);
    283     }
    284 
    285     float viewVerts[] = {
    286         ViewRect[0][0], -ViewRect[0][1],
    287         ViewRect[1][0], -ViewRect[1][1],
    288         ViewRect[2][0], -ViewRect[2][1],
    289         ViewRect[3][0], -ViewRect[3][1]
     310    const std::array<CVector3D, 4> hitPoints = {
     311        m_Camera->GetWorldCoordinates(0, g_Renderer.GetHeight(), h),
     312        m_Camera->GetWorldCoordinates(g_Renderer.GetWidth(), g_Renderer.GetHeight(), h),
     313        m_Camera->GetWorldCoordinates(g_Renderer.GetWidth(), 0, h),
     314        m_Camera->GetWorldCoordinates(0, 0, h)
    290315    };
     316
     317
     318
     319
     320
     321
     322
     323
     324
     325
     326
     327
     328
     329
     330
     331
    291332
    292333    // Enable Scissoring to restrict the rectangle to only the minimap.
     
    307348    shader->Uniform(str_color, 1.0f, 0.3f, 0.3f, 1.0f);
    308349
    309     shader->VertexPointer(2, GL_FLOAT, 0, viewVerts);
     350    shader->VertexPointer(2, GL_FLOAT, 0, v);
    310351    shader->AssertPointersBound();
    311352
    312353    if (!g_Renderer.m_SkipSubmit)
    313         glDrawArrays(GL_LINE_LOOP, 0, 4);
     354        glDrawArrays(GL_LINE);
    314355
    315356    tech->EndPass();
  • ps/trunk/source/gui/ObjectTypes/CMiniMap.h

    r24141 r25241  
    105105    void DrawTexture(CShaderProgramPtr shader, float coordMax, float angle, float x, float y, float x2, float y2, float z) const;
    106106
    107     void DrawViewRect(CMatrix3D transform) const;
     107    void DrawViewRect( transform) const;
    108108
    109109    void GetMouseWorldCoordinates(float& x, float& z) const;
Note: See TracChangeset for help on using the changeset viewer.