From baf23285e72b247dd4b73421685c5a8098cb7430 Mon Sep 17 00:00:00 2001 From: mbjornstk Date: Mon, 5 Jul 2010 00:29:26 +0000 Subject: [PATCH] Make minimap be proportional to real track. Icon position needs fixes, tho. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5636 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/tracks/quad_graph.cpp | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/tracks/quad_graph.cpp b/src/tracks/quad_graph.cpp index 5dcff4c5b..f638526b9 100644 --- a/src/tracks/quad_graph.cpp +++ b/src/tracks/quad_graph.cpp @@ -480,13 +480,21 @@ video::ITexture *QuadGraph::makeMiniMap(const core::dimension2du &dimension, m_all_quads->getBoundingBox(&bb_min, &bb_max); Vec3 center = (bb_max+bb_min)*0.5f; core::matrix4 projection; - projection.buildProjectionMatrixOrthoLH(bb_max.getX()-bb_min.getX(), - bb_max.getZ()-bb_min.getZ(), + + float range; + if((bb_max.getX()-bb_min.getX()) > (bb_max.getZ()-bb_min.getZ())) { + range = bb_max.getX()-bb_min.getX(); + } else { + range = bb_max.getZ()-bb_min.getZ(); + } + + projection.buildProjectionMatrixOrthoLH(range, + range, -1, bb_max.getY()-bb_min.getY()+1); camera->setProjectionMatrix(projection, true); - // Adjust z position by +1 for max, -1 for min - this helps in case that - // the maximum z coordinate is negative (otherwise the minimap is mirrored) - // and avoids problems for tracks which have a flat (max z = min z) minimap. + // Adjust Y position by +1 for max, -1 for min - this helps in case that + // the maximum Y coordinate is negative (otherwise the minimap is mirrored) + // and avoids problems for tracks which have a flat (max Y = min Y) minimap. camera->setPosition(core::vector3df(center.getX(), bb_max.getY()+1, center.getZ())); camera->setUpVector(core::vector3df(0, 0, 1)); camera->setTarget(core::vector3df(center.getX(),bb_min.getY()-1,center.getZ())); @@ -498,6 +506,13 @@ video::ITexture *QuadGraph::makeMiniMap(const core::dimension2du &dimension, m_min_coord = bb_min; m_scaling.setX(dimension.Width/(bb_max.getX()-bb_min.getX())); m_scaling.setZ(dimension.Width/(bb_max.getZ()-bb_min.getZ())); + + if(m_scaling.getX() > m_scaling.getZ()) { + m_scaling.setX(m_scaling.getZ()); + } else { + m_scaling.setZ(m_scaling.getX()); + } + return texture; } // drawMiniMap