Properly place icons on minimap when the allocated texture was bigger than needed to accomodate drivers/gpus that quite POT textures

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@12015 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria
2012-11-20 01:28:04 +00:00
parent 6aa15502a4
commit b157227e51
3 changed files with 24 additions and 10 deletions

View File

@@ -295,6 +295,7 @@ void RaceGUIOverworld::drawGlobalMiniMap()
if(world->getTrack()->isArena()) return;
const video::ITexture *mini_map = world->getTrack()->getMiniMap();
const core::dimension2du& minimap_size = world->getTrack()->getMiniMapSize();
int upper_y = m_map_bottom - m_map_height;
int lower_y = m_map_bottom;

View File

@@ -101,6 +101,8 @@ Track::Track(const std::string &filename)
m_weather_type = WEATHER_NONE;
m_cache_track = UserConfigParams::m_cache_overworld &&
m_ident=="overworld";
m_minimap_x_scale = 1.0f;
m_minimap_y_scale = 1.0f;
m_all_nodes.clear();
m_all_cached_meshes.clear();
loadTrackInfo();
@@ -452,19 +454,26 @@ void Track::loadQuadGraph(unsigned int mode_id, const bool reverse)
//Check whether the hardware can do nonsquare or
// non power-of-two textures
video::IVideoDriver* const video_driver = irr_driver->getVideoDriver();
bool nonpower = video_driver->queryFeature(video::EVDF_TEXTURE_NPOT);
bool nonpower = false; //video_driver->queryFeature(video::EVDF_TEXTURE_NPOT);
bool nonsquare =
video_driver->queryFeature(video::EVDF_TEXTURE_NSQUARE);
//Create the minimap resizing it as necessary.
core::dimension2du size = World::getWorld()->getRaceGUI()
->getMiniMapSize()
m_mini_map_size = World::getWorld()->getRaceGUI()->getMiniMapSize();
core::dimension2du size = m_mini_map_size
.getOptimalSize(!nonpower,!nonsquare);
m_mini_map = QuadGraph::get()->makeMiniMap(size, "minimap::"+m_ident);
m_minimap_x_scale = float(m_mini_map_size.Width) / float(m_mini_map->getSize().Width);
m_minimap_y_scale = float(m_mini_map_size.Height) / float(m_mini_map->getSize().Height);
}
} // loadQuadGraph
// -----------------------------------------------------------------------------
void Track::mapPoint2MiniMap(const Vec3 &xyz, Vec3 *draw_at) const
{
QuadGraph::get()->mapPoint2MiniMap(xyz, draw_at);
draw_at->setX(draw_at->getX() * m_minimap_x_scale);
draw_at->setY(draw_at->getY() * m_minimap_y_scale);
}
// -----------------------------------------------------------------------------
/** Convert the track tree into its physics equivalents.
* \param main_track_count The number of meshes that are already converted

View File

@@ -350,7 +350,10 @@ private:
/** The texture for the mini map, which is displayed in the race gui. */
video::ITexture *m_mini_map;
core::dimension2du m_mini_map_size;
float m_minimap_x_scale;
float m_minimap_y_scale;
/** List of all bezier curves in the track - for e.g. camera, ... */
std::vector<BezierCurve*> m_all_curves;
@@ -395,9 +398,11 @@ public:
buildHeightMap();
// ------------------------------------------------------------------------
/** Returns the texture with the mini map for this track. */
const video::ITexture*getMiniMap () const { return m_mini_map; }
const video::ITexture* getMiniMap () const { return m_mini_map; }
// ------------------------------------------------------------------------
bool isArena () const { return m_is_arena; }
const core::dimension2du& getMiniMapSize() const { return m_mini_map_size; }
// ------------------------------------------------------------------------
bool isArena () const { return m_is_arena; }
// ------------------------------------------------------------------------
void loadTrackModel (World* parent,
bool reverse_track = false,
@@ -467,8 +472,7 @@ public:
* \param draw_at The coordinates in pixel on the mini map of the point,
* only the first two coordinates will be used.
*/
void mapPoint2MiniMap(const Vec3 &xyz, Vec3 *draw_at) const
{ QuadGraph::get()->mapPoint2MiniMap(xyz, draw_at); }
void mapPoint2MiniMap(const Vec3 &xyz, Vec3 *draw_at) const;
// ------------------------------------------------------------------------
/** Returns the full path of a given file inside this track directory. */
std::string getTrackFile(const std::string &s) const