From ba3497bb81f69a70a45f8e8f2d09f9913143a00d Mon Sep 17 00:00:00 2001
From: hiker
Date: Mon, 25 Jul 2016 17:45:24 +1000
Subject: [PATCH 01/39] Properly set the camera type in the constructor (which
previously was always 'CM_TYPE_NORMAL'). Fixes #2576.
---
src/graphics/camera.cpp | 8 +++++---
src/graphics/camera.hpp | 4 ++--
src/graphics/camera_debug.cpp | 2 +-
src/graphics/camera_end.cpp | 2 +-
src/graphics/camera_fps.cpp | 2 +-
src/graphics/camera_normal.cpp | 13 +++++++++++--
src/graphics/camera_normal.hpp | 3 ++-
7 files changed, 23 insertions(+), 11 deletions(-)
diff --git a/src/graphics/camera.cpp b/src/graphics/camera.cpp
index 3e6073eb0..e374c282b 100644
--- a/src/graphics/camera.cpp
+++ b/src/graphics/camera.cpp
@@ -73,7 +73,8 @@ Camera* Camera::createCamera(unsigned int index, CameraType type,
Camera *camera = NULL;
switch (type)
{
- case CM_TYPE_NORMAL: camera = new CameraNormal(index, kart); break;
+ case CM_TYPE_NORMAL: camera = new CameraNormal(CM_TYPE_NORMAL, index, kart);
+ break;
case CM_TYPE_DEBUG: camera = new CameraDebug (index, kart); break;
case CM_TYPE_FPS: camera = new CameraFPS (index, kart); break;
case CM_TYPE_END: camera = new CameraEnd (index, kart); break;
@@ -112,10 +113,11 @@ void Camera::resetAllCameras()
} // resetAllCameras
// ----------------------------------------------------------------------------
-Camera::Camera(int camera_index, AbstractKart* kart) : m_kart(NULL)
+Camera::Camera(CameraType type, int camera_index, AbstractKart* kart)
+ : m_kart(NULL)
{
m_mode = CM_NORMAL;
- m_type = CameraType::CM_TYPE_NORMAL;
+ m_type = type;
m_index = camera_index;
m_original_kart = kart;
m_camera = irr_driver->addCameraSceneNode();
diff --git a/src/graphics/camera.hpp b/src/graphics/camera.hpp
index 502918ef0..27f117557 100644
--- a/src/graphics/camera.hpp
+++ b/src/graphics/camera.hpp
@@ -126,9 +126,9 @@ protected:
AbstractKart *m_kart;
static Camera* createCamera(unsigned int index, CameraType type,
- AbstractKart* kart);
+ AbstractKart* kart);
- Camera(int camera_index, AbstractKart* kart);
+ Camera(CameraType type, int camera_index, AbstractKart* kart);
virtual ~Camera();
virtual void reset();
public:
diff --git a/src/graphics/camera_debug.cpp b/src/graphics/camera_debug.cpp
index ea0009b35..6069a6be7 100644
--- a/src/graphics/camera_debug.cpp
+++ b/src/graphics/camera_debug.cpp
@@ -32,7 +32,7 @@ CameraDebug::CameraDebugType CameraDebug::m_default_debug_Type =
// ============================================================================
CameraDebug::CameraDebug(int camera_index, AbstractKart* kart)
- : CameraNormal(camera_index, kart)
+ : CameraNormal(Camera::CM_TYPE_DEBUG, camera_index, kart)
{
reset();
} // Camera
diff --git a/src/graphics/camera_end.cpp b/src/graphics/camera_end.cpp
index d5f868747..971daaa79 100644
--- a/src/graphics/camera_end.cpp
+++ b/src/graphics/camera_end.cpp
@@ -27,7 +27,7 @@
AlignedArray CameraEnd::m_end_cameras;
// ============================================================================
CameraEnd::CameraEnd(int camera_index, AbstractKart* kart)
- : CameraNormal(camera_index, kart)
+ : CameraNormal(Camera::CM_TYPE_END, camera_index, kart)
{
reset();
if(m_end_cameras.size()>0)
diff --git a/src/graphics/camera_fps.cpp b/src/graphics/camera_fps.cpp
index 477e17d90..f66278a60 100644
--- a/src/graphics/camera_fps.cpp
+++ b/src/graphics/camera_fps.cpp
@@ -30,7 +30,7 @@ using namespace irr;
// ============================================================================
CameraFPS::CameraFPS(int camera_index, AbstractKart* kart)
- : Camera(camera_index, kart)
+ : Camera(Camera::CM_TYPE_FPS, camera_index, kart)
{
m_attached = false;
diff --git a/src/graphics/camera_normal.cpp b/src/graphics/camera_normal.cpp
index cc5231bb2..ea0bf098a 100644
--- a/src/graphics/camera_normal.cpp
+++ b/src/graphics/camera_normal.cpp
@@ -28,8 +28,17 @@
#include "tracks/track.hpp"
// ============================================================================
-CameraNormal::CameraNormal(int camera_index, AbstractKart* kart)
- : Camera(camera_index, kart)
+/** Constructor for the normal camera. This is the only camera constructor
+ * except for the base class that takes a camera type as parameter. This is
+ * because debug and end camera use the normal camera as their base class.
+ * \param type The type of the camera that is created (can be CM_TYPE_END
+ * or CM_TYPE_DEBUG).
+ * \param camera_index Index of this camera.
+ * \param Kart Pointer to the kart for which this camera is used.
+ */
+CameraNormal::CameraNormal(Camera::CameraType type, int camera_index,
+ AbstractKart* kart)
+ : Camera(type, camera_index, kart)
{
m_distance = kart ? kart->getKartProperties()->getCameraDistance() : 1000.0f;
m_ambient_light = World::getWorld()->getTrack()->getDefaultAmbientColor();
diff --git a/src/graphics/camera_normal.hpp b/src/graphics/camera_normal.hpp
index 24edea3bc..742b3aeae 100644
--- a/src/graphics/camera_normal.hpp
+++ b/src/graphics/camera_normal.hpp
@@ -61,7 +61,8 @@ private:
friend class Camera;
friend class CameraDebug;
friend class CameraEnd;
- CameraNormal(int camera_index, AbstractKart* kart);
+ CameraNormal(Camera::CameraType type, int camera_index,
+ AbstractKart* kart);
virtual ~CameraNormal() {}
public:
bool isDebug() { return false; }
From f69d04edd36e3a7e4b7d04c4adc21f10b8815bef Mon Sep 17 00:00:00 2001
From: hiker
Date: Wed, 27 Jul 2016 00:40:44 +1000
Subject: [PATCH 02/39] Fixed STUN protocol (#fixed #2566).
---
src/network/protocols/get_public_address.cpp | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/src/network/protocols/get_public_address.cpp b/src/network/protocols/get_public_address.cpp
index 213cf60df..955c16589 100644
--- a/src/network/protocols/get_public_address.cpp
+++ b/src/network/protocols/get_public_address.cpp
@@ -90,7 +90,7 @@ void GetPublicAddress::createStunRequest()
m_transaction_host = new Network(1, 1, 0, 0);
// Assemble the message for the stun server
- BareNetworkString s(21);
+ BareNetworkString s(20);
// bytes 0-1: the type of the message
// bytes 2-3: message length added to header (attributes)
@@ -105,8 +105,6 @@ void GetPublicAddress::createStunRequest()
s.addUInt8(random_byte);
m_stun_tansaction_id[i] = random_byte;
}
- s.addChar(0);
-
m_transaction_host->sendRawPacket(s,
TransportAddress(m_stun_server_ip,
@@ -140,7 +138,7 @@ std::string GetPublicAddress::parseStunResponse()
return "STUN response contains no data at all";
// Convert to network string.
- NetworkString datas((uint8_t*)buffer, len);
+ BareNetworkString datas(buffer, len);
// check that the stun response is a response, contains the magic cookie
// and the transaction ID
From 0db2a195b67c72783842be47866679fe658282f5 Mon Sep 17 00:00:00 2001
From: hiker
Date: Wed, 27 Jul 2016 07:54:54 +1000
Subject: [PATCH 03/39] Fixed compiler warning.
---
src/states_screens/race_result_gui.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/states_screens/race_result_gui.cpp b/src/states_screens/race_result_gui.cpp
index ccfc81c25..714f2987c 100644
--- a/src/states_screens/race_result_gui.cpp
+++ b/src/states_screens/race_result_gui.cpp
@@ -1420,7 +1420,7 @@ void RaceResultGUI::backToLobby()
if (race_manager->modeHasLaps())
{
core::stringw laps = _("Laps: %i", race_manager->getNumLaps());
- current_y += m_distance_between_rows * 0.8f * 2;
+ current_y += int(m_distance_between_rows * 0.8f * 2);
GUIEngine::getFont()->draw(laps, core::recti(x, current_y, 0, 0),
white_color, false, false, nullptr, true);
}
@@ -1428,7 +1428,7 @@ void RaceResultGUI::backToLobby()
const core::stringw& difficulty_name =
race_manager->getDifficultyName(race_manager->getDifficulty());
core::stringw difficulty_string = _("Difficulty: %s", difficulty_name);
- current_y += m_distance_between_rows * 0.8f;
+ current_y += int(m_distance_between_rows * 0.8f);
GUIEngine::getFont()->draw(difficulty_string, core::recti(x, current_y, 0, 0),
white_color, false, false, nullptr, true);
// show fastest lap
@@ -1437,7 +1437,7 @@ void RaceResultGUI::backToLobby()
float best_lap_time = static_cast(World::getWorld())->getFastestLap();
core::stringw best_lap_string = _("Best lap time: %s",
StringUtils::timeToString(best_lap_time).c_str());
- current_y += m_distance_between_rows * 0.8f;
+ current_y += int(m_distance_between_rows * 0.8f);
GUIEngine::getFont()->draw(best_lap_string,
core::recti(x, current_y, 0, 0), white_color, false, false,
nullptr, true);
From 6d0ad4a4fed9e7259c313acfa997a98db252b67f Mon Sep 17 00:00:00 2001
From: hiker
Date: Wed, 27 Jul 2016 08:26:41 +1000
Subject: [PATCH 04/39] Fixed compiler warning.
---
src/tinygettext/po_parser.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/tinygettext/po_parser.cpp b/src/tinygettext/po_parser.cpp
index 1920dd934..0831c2417 100644
--- a/src/tinygettext/po_parser.cpp
+++ b/src/tinygettext/po_parser.cpp
@@ -338,9 +338,9 @@ POParser::parse()
// skip UTF-8 intro that some text editors produce
// see http://en.wikipedia.org/wiki/Byte-order_mark
if (current_line.size() >= 3 &&
- current_line[0] == static_cast(0xef) &&
- current_line[1] == static_cast(0xbb) &&
- current_line[2] == static_cast(0xbf))
+ current_line[0] == static_cast(0xef) &&
+ current_line[1] == static_cast(0xbb) &&
+ current_line[2] == static_cast(0xbf))
{
current_line = current_line.substr(3);
}
From bc5e2f3e29e544862091e36478b4bad93ac1cebe Mon Sep 17 00:00:00 2001
From: Benau
Date: Wed, 27 Jul 2016 11:48:38 +0800
Subject: [PATCH 05/39] Add unit testing for fonts for translation
---
src/font/font_manager.cpp | 55 +++++++++++++++++++++++++++++++++++++++
src/font/font_manager.hpp | 2 ++
src/main.cpp | 3 +++
3 files changed, 60 insertions(+)
diff --git a/src/font/font_manager.cpp b/src/font/font_manager.cpp
index df237fb0b..82de84b3c 100644
--- a/src/font/font_manager.cpp
+++ b/src/font/font_manager.cpp
@@ -23,6 +23,8 @@
#include "font/digit_face.hpp"
#include "font/face_ttf.hpp"
#include "font/regular_face.hpp"
+#include "utils/string_utils.hpp"
+#include "utils/translation.hpp"
FontManager *font_manager = NULL;
// ----------------------------------------------------------------------------
@@ -77,3 +79,56 @@ void FontManager::checkFTError(FT_Error err, const std::string& desc) const
Log::error("FontManager", "Something wrong when %s!", desc.c_str());
}
} // checkFTError
+
+// ----------------------------------------------------------------------------
+void FontManager::unitTesting()
+{
+ std::vector list = *(translations->getLanguageList());
+ const int cur_log_level = Log::getLogLevel();
+ for (const std::string& lang : list)
+ {
+ // Hide gettext warning
+ Log::setLogLevel(5);
+ delete translations;
+#ifdef WIN32
+ std::string s=std::string("LANGUAGE=") + lang.c_str();
+ _putenv(s.c_str());
+#else
+ setenv("LANGUAGE", lang.c_str(), 1);
+#endif
+ translations = new Translations();
+ Log::setLogLevel(cur_log_level);
+ std::set used_chars = translations->getCurrentAllChar();
+ for (const wchar_t& c : used_chars)
+ {
+ // Skip non-printing characters
+ if (c < 32) continue;
+
+ unsigned int font_number = 0;
+ unsigned int glyph_index = 0;
+ while (font_number < m_normal_ttf->getTotalFaces())
+ {
+ glyph_index =
+ FT_Get_Char_Index(m_normal_ttf->getFace(font_number), c);
+ if (glyph_index > 0) break;
+ font_number++;
+ }
+ if (glyph_index > 0)
+ {
+ Log::debug("UnitTest", "Character %s in language %s"
+ " use face %s",
+ StringUtils::wideToUtf8(core::stringw(&c, 1)).c_str(),
+ lang.c_str(),
+ m_normal_ttf->getFace(font_number)->family_name);
+ }
+ else
+ {
+ Log::warn("UnitTest", "Character %s in language %s"
+ " is not supported by all fonts!",
+ StringUtils::wideToUtf8(core::stringw(&c, 1)).c_str(),
+ lang.c_str());
+ }
+ }
+ }
+
+} // unitTesting
diff --git a/src/font/font_manager.hpp b/src/font/font_manager.hpp
index aae90c0f3..f46249944 100644
--- a/src/font/font_manager.hpp
+++ b/src/font/font_manager.hpp
@@ -76,6 +76,8 @@ public:
// ------------------------------------------------------------------------
void loadFonts();
// ------------------------------------------------------------------------
+ void unitTesting();
+ // ------------------------------------------------------------------------
FT_Library getFTLibrary() const { return m_ft_library; }
}; // FontManager
diff --git a/src/main.cpp b/src/main.cpp
index 39efb33b1..a3100dc51 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1887,6 +1887,9 @@ void runUnitTests()
Log::info("UnitTest", "Battle Graph");
BattleGraph::unitTesting();
+ Log::info("UnitTest", "Fonts for translation");
+ font_manager->unitTesting();
+
Log::info("UnitTest", "=====================");
Log::info("UnitTest", "Testing successful ");
Log::info("UnitTest", "=====================");
From 6ca0eed28f0bbd544d9119e09b8e0e61edb7f406 Mon Sep 17 00:00:00 2001
From: hiker
Date: Wed, 27 Jul 2016 17:34:59 +1000
Subject: [PATCH 06/39] Added debug option to trigger a kart explosion in debug
mode.
---
src/utils/debug.cpp | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/src/utils/debug.cpp b/src/utils/debug.cpp
index 8c3fae93d..7cd03a8c8 100644
--- a/src/utils/debug.cpp
+++ b/src/utils/debug.cpp
@@ -24,6 +24,7 @@
#include "font/regular_face.hpp"
#include "graphics/camera_debug.hpp"
#include "graphics/camera_fps.hpp"
+#include "karts/explosion_animation.hpp"
#include "graphics/irr_driver.hpp"
#include "graphics/light.hpp"
#include "graphics/shaders.hpp"
@@ -99,6 +100,7 @@ enum DebugMenuCommand
DEBUG_ATTACHMENT_PARACHUTE,
DEBUG_ATTACHMENT_BOMB,
DEBUG_ATTACHMENT_ANVIL,
+ DEBUG_ATTACHMENT_EXPLOSION,
DEBUG_GUI_TOGGLE,
DEBUG_GUI_HIDE_KARTS,
DEBUG_GUI_CAM_FREE,
@@ -409,6 +411,13 @@ bool handleContextMenuAction(s32 cmd_id)
case DEBUG_ATTACHMENT_PARACHUTE:
addAttachment(Attachment::ATTACH_PARACHUTE);
break;
+ case DEBUG_ATTACHMENT_EXPLOSION:
+ for (unsigned int i = 0; i < race_manager->getNumLocalPlayers(); i++)
+ {
+ AbstractKart* kart = world->getLocalPlayerKart(i);
+ ExplosionAnimation::create(kart, kart->getXYZ(), true);
+ }
+ break;
case DEBUG_GUI_TOGGLE:
{
if (!world) return false;
@@ -685,6 +694,7 @@ bool onEvent(const SEvent &event)
sub->addItem(L"Bomb", DEBUG_ATTACHMENT_BOMB);
sub->addItem(L"Anvil", DEBUG_ATTACHMENT_ANVIL);
sub->addItem(L"Parachute", DEBUG_ATTACHMENT_PARACHUTE);
+ sub->addItem(L"Explosion", DEBUG_ATTACHMENT_EXPLOSION);
mnu->addItem(L"GUI >",-1,true, true);
sub = mnu->getSubMenu(3);
From 277a4b9262d354985f54ba73d5e87ae77d21ff60 Mon Sep 17 00:00:00 2001
From: qwertychouskie
Date: Wed, 27 Jul 2016 15:31:39 -0700
Subject: [PATCH 07/39] Fix #2542. Also update copyright year. (#2585)
* Fix #2542. Also update copyright year.
* Update header
---
src/config/user_config.cpp | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/config/user_config.cpp b/src/config/user_config.cpp
index 40554f8b8..60df0436e 100644
--- a/src/config/user_config.cpp
+++ b/src/config/user_config.cpp
@@ -1,7 +1,7 @@
//
-// SuperTuxKart - a fun racing game with go-kart
-// Copyright (C) 2006-2015 SuperTuxKart-Team
-// Modelled after Supertux's configfile.cpp
+// SuperTuxKart - A racing game
+// Copyright (C) 2006-2016 SuperTuxKart Team
+// Modeled after Supertux's configfile.cpp
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -683,8 +683,8 @@ bool UserConfig::loadConfig()
XMLNode* root = file_manager->createXMLTree(filename);
if(!root || root->getName() != "stkconfig")
{
- Log::error("UserConfig",
- "Could not read user config file '%s'.", filename.c_str());
+ Log::info("UserConfig",
+ "Could not read user config file '%s'. A new file will be created.", filename.c_str());
if(root) delete root;
// Create a default config file - just in case that stk crashes later
// there is a config file that can be modified (to e.g. disable
From 83117fe6492e2a6e2688362780d0f8969c25b969 Mon Sep 17 00:00:00 2001
From: hiker
Date: Thu, 28 Jul 2016 09:47:56 +1000
Subject: [PATCH 08/39] Fixed wheel position in case of a rescue: if the
suspension of a wheel is stretched at the time a rescue or explosion is
triggered, the wheel will appear to be very far away from the kart (not
connected anymore).
---
src/karts/abstract_kart_animation.cpp | 7 +++++++
src/karts/kart_model.cpp | 14 ++++++++++++++
src/karts/kart_model.hpp | 1 +
3 files changed, 22 insertions(+)
diff --git a/src/karts/abstract_kart_animation.cpp b/src/karts/abstract_kart_animation.cpp
index f51e28f84..5a10b9374 100644
--- a/src/karts/abstract_kart_animation.cpp
+++ b/src/karts/abstract_kart_animation.cpp
@@ -20,6 +20,7 @@
#include "graphics/slip_stream.hpp"
#include "karts/abstract_kart.hpp"
+#include "karts/kart_model.hpp"
#include "karts/skidding.hpp"
#include "modes/world.hpp"
#include "physics/physics.hpp"
@@ -55,6 +56,12 @@ AbstractKartAnimation::AbstractKartAnimation(AbstractKart *kart,
// A time of 0 reset the squashing
kart->setSquash(0.0f, 0.0f);
}
+
+ // Reset the wheels (and any other animation played for that kart)
+ // This avoid the effect that some wheels might be way below the kart
+ // which is very obvious in the rescue animation.
+ m_kart->getKartModel()->resetVisualWheelPosition();
+
} // AbstractKartAnimation
// ----------------------------------------------------------------------------
diff --git a/src/karts/kart_model.cpp b/src/karts/kart_model.cpp
index a47fe4a27..ab0a04424 100644
--- a/src/karts/kart_model.cpp
+++ b/src/karts/kart_model.cpp
@@ -982,6 +982,20 @@ void KartModel::update(float dt, float distance, float steer, float speed,
m_animated_node->setCurrentFrame(frame);
} // update
+//-----------------------------------------------------------------------------
+/** Called when a kart is rescued to reset all visual wheels to their default
+ * position to avoid that some wheels look too far away from the kart (which
+ * is not that visible while a kart is driving).
+ */
+void KartModel::resetVisualWheelPosition()
+{
+ for(unsigned int i=0; i<4; i++)
+ {
+ m_kart->getVehicle()->getWheelInfo(i).m_raycastInfo.m_suspensionLength =
+ m_default_physics_suspension[i];
+ } // for i < 4
+} // resetVisualSuspension
+
//-----------------------------------------------------------------------------
void KartModel::attachHat()
{
diff --git a/src/karts/kart_model.hpp b/src/karts/kart_model.hpp
index be90d9cc4..2e2b537b5 100644
--- a/src/karts/kart_model.hpp
+++ b/src/karts/kart_model.hpp
@@ -249,6 +249,7 @@ public:
float current_lean_angle,
int gt_replay_index = -1);
void finishedRace();
+ void resetVisualWheelPosition();
scene::ISceneNode*
attachModel(bool animatedModels, bool always_animated);
// ------------------------------------------------------------------------
From 611e70ac83188a2788e893d5a275f8859fd6b54d Mon Sep 17 00:00:00 2001
From: qwertychouskie
Date: Thu, 28 Jul 2016 16:24:42 -0700
Subject: [PATCH 09/39] Show boost at startup (#2586)
* Show boost at startup
* Fix https://github.com/supertuxkart/stk-code/pull/2586#issuecomment-235765919
---
src/karts/kart.cpp | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/karts/kart.cpp b/src/karts/kart.cpp
index 802a9e19c..602c1d284 100644
--- a/src/karts/kart.cpp
+++ b/src/karts/kart.cpp
@@ -1,7 +1,7 @@
//
-// SuperTuxKart - a fun racing game with go-kart
-// Copyright (C) 2004-2015 Steve Baker
-// Copyright (C) 2006-2015 SuperTuxKart-Team, Joerg Henrichs, Steve Baker
+// SuperTuxKart - A racing game
+// Copyright (C) 2004-2016 Steve Baker
+// Copyright (C) 2006-2016 SuperTuxKart Team, Joerg Henrichs, Steve Baker
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -2110,6 +2110,7 @@ void Kart::updatePhysics(float dt)
{
m_has_started = true;
float f = getStartupBoost();
+ if(f >= 0.0f) m_kart_gfx->setCreationRateAbsolute(KartGFX::KGFX_ZIPPER, 100*f);
m_max_speed->instantSpeedIncrease(MaxSpeed::MS_INCREASE_ZIPPER,
0.9f*f, f,
/*engine_force*/200.0f,
From 8f7d47d3c384b84321746f29727a6ae65554f88e Mon Sep 17 00:00:00 2001
From: hiker
Date: Fri, 29 Jul 2016 09:53:37 +1000
Subject: [PATCH 10/39] Fix ball-track collision (which should also improve
kart-track collision).
---
src/physics/triangle_mesh.cpp | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/physics/triangle_mesh.cpp b/src/physics/triangle_mesh.cpp
index d0d0f4617..2c410dad9 100644
--- a/src/physics/triangle_mesh.cpp
+++ b/src/physics/triangle_mesh.cpp
@@ -188,6 +188,7 @@ void TriangleMesh::createPhysicalBody(btCollisionObject::CollisionFlags flags,
m_motion_state = new btDefaultMotionState(startTransform);
btRigidBody::btRigidBodyConstructionInfo info(0.0f, m_motion_state,
m_collision_shape);
+ info.m_restitution = 1.0f;
m_body=new btRigidBody(info);
World::getWorld()->getPhysics()->addBody(m_body);
From 637e468f1807c1bef2bf666a88520b7c5e893a43 Mon Sep 17 00:00:00 2001
From: Benau
Date: Fri, 29 Jul 2016 11:50:37 +0800
Subject: [PATCH 11/39] Use uniform copyright header for source
---
src/config/user_config.cpp | 4 ++--
src/karts/kart.cpp | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/config/user_config.cpp b/src/config/user_config.cpp
index 60df0436e..95f013d91 100644
--- a/src/config/user_config.cpp
+++ b/src/config/user_config.cpp
@@ -1,6 +1,6 @@
//
-// SuperTuxKart - A racing game
-// Copyright (C) 2006-2016 SuperTuxKart Team
+// SuperTuxKart - a fun racing game with go-kart
+// Copyright (C) 2006-2016 SuperTuxKart-Team
// Modeled after Supertux's configfile.cpp
//
// This program is free software; you can redistribute it and/or
diff --git a/src/karts/kart.cpp b/src/karts/kart.cpp
index 602c1d284..c6cdc9feb 100644
--- a/src/karts/kart.cpp
+++ b/src/karts/kart.cpp
@@ -1,7 +1,7 @@
//
-// SuperTuxKart - A racing game
+// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2004-2016 Steve Baker
-// Copyright (C) 2006-2016 SuperTuxKart Team, Joerg Henrichs, Steve Baker
+// Copyright (C) 2006-2016 SuperTuxKart-Team, Joerg Henrichs, Steve Baker
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
From a318e3b2167d6280993aad4143fb1769b06d3913 Mon Sep 17 00:00:00 2001
From: "auria.mg"
Date: Sat, 30 Jul 2016 19:43:48 -0400
Subject: [PATCH 12/39] Log out user when deactivating internet connection,
fixes #2589
---
src/states_screens/options_screen_ui.cpp | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/states_screens/options_screen_ui.cpp b/src/states_screens/options_screen_ui.cpp
index 771c62064..b7302f412 100644
--- a/src/states_screens/options_screen_ui.cpp
+++ b/src/states_screens/options_screen_ui.cpp
@@ -21,6 +21,7 @@
#include "audio/sfx_manager.hpp"
#include "audio/sfx_base.hpp"
#include "config/hardware_stats.hpp"
+#include "config/player_manager.hpp"
#include "config/user_config.hpp"
#include "font/bold_face.hpp"
#include "font/regular_face.hpp"
@@ -284,8 +285,10 @@ void OptionsScreenUI::eventCallback(Widget* widget, const std::string& name, con
{
stats->setVisible(false);
stats_label->setVisible(false);
+ PlayerProfile* profile = PlayerManager::getCurrentPlayer();
+ if (profile != NULL && profile->isLoggedIn())
+ profile->requestSignOut();
}
-
}
else if (name=="enable-hw-report")
{
From 347f977ea782fafea14aa62886ed72a1dc8fafbf Mon Sep 17 00:00:00 2001
From: "auria.mg"
Date: Sat, 30 Jul 2016 19:44:21 -0400
Subject: [PATCH 13/39] Fix english string, as reported a while ago but
couldn't fix then due to string freeze
---
src/states_screens/race_setup_screen.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/states_screens/race_setup_screen.cpp b/src/states_screens/race_setup_screen.cpp
index 50c811446..fe51c8dbc 100644
--- a/src/states_screens/race_setup_screen.cpp
+++ b/src/states_screens/race_setup_screen.cpp
@@ -116,7 +116,7 @@ void RaceSetupScreen::init()
irr::core::stringw name5 = irr::core::stringw(
RaceManager::getNameOf(RaceManager::MINOR_MODE_SOCCER)) + L"\n";
- name5 += _("Push the ball to the opposite cage to score goals.");
+ name5 += _("Push the ball into the opposite cage to score goals.");
w2->addItem( name5, IDENT_SOCCER, RaceManager::getIconOf(RaceManager::MINOR_MODE_SOCCER));
#define ENABLE_EASTER_EGG_MODE
From b69faff13d939729f0158912e14f227ad2f10198 Mon Sep 17 00:00:00 2001
From: "auria.mg"
Date: Sat, 30 Jul 2016 19:46:15 -0400
Subject: [PATCH 14/39] Fix indentation (tabs/spaces)
---
src/states_screens/options_screen_ui.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/states_screens/options_screen_ui.cpp b/src/states_screens/options_screen_ui.cpp
index b7302f412..4332e896d 100644
--- a/src/states_screens/options_screen_ui.cpp
+++ b/src/states_screens/options_screen_ui.cpp
@@ -285,9 +285,9 @@ void OptionsScreenUI::eventCallback(Widget* widget, const std::string& name, con
{
stats->setVisible(false);
stats_label->setVisible(false);
- PlayerProfile* profile = PlayerManager::getCurrentPlayer();
- if (profile != NULL && profile->isLoggedIn())
- profile->requestSignOut();
+ PlayerProfile* profile = PlayerManager::getCurrentPlayer();
+ if (profile != NULL && profile->isLoggedIn())
+ profile->requestSignOut();
}
}
else if (name=="enable-hw-report")
From 788f168c7f65b9ad09f5a62864f569360529ea61 Mon Sep 17 00:00:00 2001
From: Benau
Date: Sun, 31 Jul 2016 08:04:16 +0800
Subject: [PATCH 15/39] Fix space before colon
---
src/challenges/challenge_data.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/challenges/challenge_data.cpp b/src/challenges/challenge_data.cpp
index bc3fa8742..7cfb08eb4 100644
--- a/src/challenges/challenge_data.cpp
+++ b/src/challenges/challenge_data.cpp
@@ -256,7 +256,7 @@ ChallengeData::ChallengeData(const std::string& filename)
if (track_node != NULL && m_minor!=RaceManager::MINOR_MODE_FOLLOW_LEADER)
{
//I18N: number of laps to race in a challenge
- description += _("Laps : %i", m_num_laps);
+ description += _("Laps: %i", m_num_laps);
description += core::stringw(L"\n");
}
else if (track_node)
From 40ab343922131d57d5fa640365e8c16dc02589fc Mon Sep 17 00:00:00 2001
From: "auria.mg"
Date: Sat, 30 Jul 2016 20:52:32 -0400
Subject: [PATCH 16/39] Fix string remaining in wrong language when changing
language
---
src/challenges/challenge_data.cpp | 37 ++++++++++++++---------
src/challenges/challenge_data.hpp | 7 +----
src/states_screens/race_gui_overworld.cpp | 9 +++++-
src/states_screens/race_gui_overworld.hpp | 5 +++
4 files changed, 36 insertions(+), 22 deletions(-)
diff --git a/src/challenges/challenge_data.cpp b/src/challenges/challenge_data.cpp
index bc3fa8742..f1fdc2f27 100644
--- a/src/challenges/challenge_data.cpp
+++ b/src/challenges/challenge_data.cpp
@@ -251,23 +251,30 @@ ChallengeData::ChallengeData(const std::string& filename)
throw std::runtime_error("Unknown unlock entry");
}
}
-
- core::stringw description;
- if (track_node != NULL && m_minor!=RaceManager::MINOR_MODE_FOLLOW_LEADER)
- {
- //I18N: number of laps to race in a challenge
- description += _("Laps : %i", m_num_laps);
- description += core::stringw(L"\n");
- }
- else if (track_node)
- {
- // Follow the leader mode:
- description = _("Follow the leader");
- }
-
- m_challenge_description = description;
} // ChallengeData
+// ----------------------------------------------------------------------------
+
+const irr::core::stringw ChallengeData::getChallengeDescription() const
+{
+ core::stringw description;
+ if (!m_track_id.empty())
+ {
+ if (m_minor != RaceManager::MINOR_MODE_FOLLOW_LEADER)
+ {
+ //I18N: number of laps to race in a challenge
+ description += _("Laps: %i", m_num_laps);
+ description += core::stringw(L"\n");
+ }
+ else
+ {
+ // Follow the leader mode:
+ description = _("Follow the leader");
+ }
+ }
+ return description;
+} // getChallengeDescription
+
// ----------------------------------------------------------------------------
void ChallengeData::error(const char *id) const
{
diff --git a/src/challenges/challenge_data.hpp b/src/challenges/challenge_data.hpp
index f563695fb..0cebc4556 100644
--- a/src/challenges/challenge_data.hpp
+++ b/src/challenges/challenge_data.hpp
@@ -110,8 +110,6 @@ private:
/** Number of trophies required to access this challenge */
int m_num_trophies;
- irr::core::stringw m_challenge_description;
-
public:
ChallengeData(const std::string& filename);
@@ -195,10 +193,7 @@ public:
// ------------------------------------------------------------------------
/** Returns the description of this challenge.
*/
- const irr::core::stringw& getChallengeDescription() const
- {
- return m_challenge_description;
- } // getChallengeDescription
+ const irr::core::stringw getChallengeDescription() const;
// ------------------------------------------------------------------------
/** Returns the minimum position the player must have in order to win.
diff --git a/src/states_screens/race_gui_overworld.cpp b/src/states_screens/race_gui_overworld.cpp
index 761836652..abc03fdb1 100644
--- a/src/states_screens/race_gui_overworld.cpp
+++ b/src/states_screens/race_gui_overworld.cpp
@@ -108,6 +108,7 @@ RaceGUIOverworld::RaceGUIOverworld()
m_string_lap = _("Lap");
m_string_rank = _("Rank");
+ m_active_challenge = NULL;
// Determine maximum length of the rank/lap text, in order to
// align those texts properly on the right side of the viewport.
@@ -528,7 +529,13 @@ void RaceGUIOverworld::drawGlobalMiniMap()
pos.UpperLeftCorner.Y += GUIEngine::getTitleFontHeight();
pos.LowerRightCorner.Y = irr_driver->getActualScreenSize().Height;
- GUIEngine::getFont()->draw(challenge->getChallengeDescription().c_str(),
+
+ if (m_active_challenge != challenge)
+ {
+ m_active_challenge = challenge;
+ m_challenge_description = challenge->getChallengeDescription();
+ }
+ GUIEngine::getFont()->draw(m_challenge_description,
pos, video::SColor(255,255,255,255),
false, false /* vcenter */, NULL);
diff --git a/src/states_screens/race_gui_overworld.hpp b/src/states_screens/race_gui_overworld.hpp
index 810f2baec..56d72823b 100644
--- a/src/states_screens/race_gui_overworld.hpp
+++ b/src/states_screens/race_gui_overworld.hpp
@@ -101,6 +101,11 @@ private:
int m_trophy_points_width;
+ /** The latest challenge approached by the kart */
+ const ChallengeData* m_active_challenge;
+
+ core::stringw m_challenge_description;
+
/** The current challenge over which the mouse is hovering. */
const OverworldChallenge *m_current_challenge;
From 690440254750a9e98a3f0d56c421689c69c3d3a1 Mon Sep 17 00:00:00 2001
From: Benau
Date: Sun, 31 Jul 2016 09:04:10 +0800
Subject: [PATCH 17/39] Fix wrong RTL text in arena screen
---
src/states_screens/arenas_screen.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/states_screens/arenas_screen.cpp b/src/states_screens/arenas_screen.cpp
index 999a3babc..24d90ee93 100644
--- a/src/states_screens/arenas_screen.cpp
+++ b/src/states_screens/arenas_screen.cpp
@@ -277,7 +277,7 @@ void ArenasScreen::buildTrackList()
}
else
{
- w->addItem( curr->getName(), curr->getIdent(), curr->getScreenshotFile(), 0,
+ w->addItem( translations->fribidize(curr->getName()), curr->getIdent(), curr->getScreenshotFile(), 0,
IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE );
}
}
@@ -329,7 +329,7 @@ void ArenasScreen::buildTrackList()
}
else
{
- w->addItem( curr->getName(), curr->getIdent(), curr->getScreenshotFile(), 0,
+ w->addItem( translations->fribidize(curr->getName()), curr->getIdent(), curr->getScreenshotFile(), 0,
IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE );
}
}
From ea939459e8769e847222de130a5d31bf1c9bf128 Mon Sep 17 00:00:00 2001
From: "auria.mg"
Date: Sat, 30 Jul 2016 21:51:31 -0400
Subject: [PATCH 18/39] Improve string as suggested on transifex
---
data/gui/options_players.stkgui | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/data/gui/options_players.stkgui b/data/gui/options_players.stkgui
index 286b0971b..5c8de774c 100644
--- a/data/gui/options_players.stkgui
+++ b/data/gui/options_players.stkgui
@@ -30,7 +30,7 @@
From cdde62dadbc4ff71b0e2201f66dcb02f05c3dc96 Mon Sep 17 00:00:00 2001
From: hiker
Date: Mon, 1 Aug 2016 08:00:14 +1000
Subject: [PATCH 19/39] Further tweaked restitution for track and bowling ball
to avoid bowling balls jumping up and down, while still maintaining a push
back for soccer balls.
---
src/items/bowling.cpp | 2 +-
src/physics/triangle_mesh.cpp | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/items/bowling.cpp b/src/items/bowling.cpp
index e0f37d5dc..613a95b12 100644
--- a/src/items/bowling.cpp
+++ b/src/items/bowling.cpp
@@ -57,7 +57,7 @@ Bowling::Bowling(AbstractKart *kart)
createPhysics(y_offset, btVector3(0.0f, 0.0f, m_speed*2),
new btSphereShape(0.5f*m_extend.getY()),
- 1.0f /*restitution*/,
+ 0.8f /*restitution*/,
-70.0f /*gravity*/,
true /*rotates*/);
// Even if the ball is fired backwards, m_speed must be positive,
diff --git a/src/physics/triangle_mesh.cpp b/src/physics/triangle_mesh.cpp
index 2c410dad9..36b403d8f 100644
--- a/src/physics/triangle_mesh.cpp
+++ b/src/physics/triangle_mesh.cpp
@@ -188,7 +188,7 @@ void TriangleMesh::createPhysicalBody(btCollisionObject::CollisionFlags flags,
m_motion_state = new btDefaultMotionState(startTransform);
btRigidBody::btRigidBodyConstructionInfo info(0.0f, m_motion_state,
m_collision_shape);
- info.m_restitution = 1.0f;
+ info.m_restitution = 0.8f;
m_body=new btRigidBody(info);
World::getWorld()->getPhysics()->addBody(m_body);
From 10937333a17d18e8374327aaf88fcc807ceeeecf Mon Sep 17 00:00:00 2001
From: Benau
Date: Wed, 3 Aug 2016 12:37:48 +0800
Subject: [PATCH 20/39] Remove duplicated code in navmesh
---
src/items/item_manager.cpp | 2 +-
src/karts/controller/arena_ai.cpp | 7 +-
src/tracks/battle_graph.cpp | 152 +++++++++++++++-------------
src/tracks/battle_graph.hpp | 70 ++++++-------
src/tracks/graph_structure.cpp | 10 +-
src/tracks/graph_structure.hpp | 1 -
src/tracks/nav_poly.cpp | 87 ----------------
src/tracks/nav_poly.hpp | 75 --------------
src/tracks/navmesh.cpp | 134 +++++++++----------------
src/tracks/navmesh.hpp | 161 +++++++++++-------------------
src/tracks/quad.cpp | 14 ++-
src/tracks/quad.hpp | 2 +-
src/tracks/quad_graph.hpp | 4 -
13 files changed, 245 insertions(+), 474 deletions(-)
delete mode 100644 src/tracks/nav_poly.cpp
delete mode 100644 src/tracks/nav_poly.hpp
diff --git a/src/items/item_manager.cpp b/src/items/item_manager.cpp
index 083d98dac..3141547f3 100644
--- a/src/items/item_manager.cpp
+++ b/src/items/item_manager.cpp
@@ -567,7 +567,7 @@ bool ItemManager::randomItemsForArena(const AlignedArray& pos)
j > NITRO_BIG ? Item::ITEM_NITRO_BIG :
j > NITRO_SMALL ? Item::ITEM_NITRO_SMALL : Item::ITEM_BANANA);
Vec3 loc = BattleGraph::get()
- ->getPolyOfNode(used_location[i]).getCenter();
+ ->getQuadOfNode(used_location[i]).getCenter();
Item* item = newItem(type, loc, Vec3(0, 1, 0));
BattleGraph::get()->insertItems(item, used_location[i]);
}
diff --git a/src/karts/controller/arena_ai.cpp b/src/karts/controller/arena_ai.cpp
index d868d5dee..4c6fa3d7b 100644
--- a/src/karts/controller/arena_ai.cpp
+++ b/src/karts/controller/arena_ai.cpp
@@ -27,6 +27,7 @@
#include "karts/controller/ai_properties.hpp"
#include "karts/kart_properties.hpp"
#include "tracks/battle_graph.hpp"
+#include "tracks/quad.hpp"
#include "utils/log.hpp"
int ArenaAI::m_test_node_for_banana = BattleGraph::UNKNOWN_POLY;
@@ -156,7 +157,7 @@ bool ArenaAI::updateAimingPosition()
if (forward == m_target_node)
{
m_aiming_points.push_back(BattleGraph::get()
- ->getPolyOfNode(forward).getCenter());
+ ->getQuadOfNode(forward).getCenter());
m_aiming_points.push_back(m_target_point);
m_aiming_nodes.insert(forward);
@@ -174,9 +175,9 @@ bool ArenaAI::updateAimingPosition()
}
m_aiming_points.push_back(BattleGraph::get()
- ->getPolyOfNode(forward).getCenter());
+ ->getQuadOfNode(forward).getCenter());
m_aiming_points.push_back(BattleGraph::get()
- ->getPolyOfNode(next_node).getCenter());
+ ->getQuadOfNode(next_node).getCenter());
m_aiming_nodes.insert(forward);
m_aiming_nodes.insert(next_node);
diff --git a/src/tracks/battle_graph.cpp b/src/tracks/battle_graph.cpp
index 72e43ff54..14803b134 100644
--- a/src/tracks/battle_graph.cpp
+++ b/src/tracks/battle_graph.cpp
@@ -28,10 +28,12 @@
#include "items/item_manager.hpp"
#include "race/race_manager.hpp"
#include "tracks/navmesh.hpp"
+#include "tracks/quad.hpp"
#include "tracks/track.hpp"
#include "tracks/track_manager.hpp"
#include "utils/log.hpp"
+#include
#include
const int BattleGraph::UNKNOWN_POLY = -1;
@@ -50,9 +52,10 @@ BattleGraph::BattleGraph(const std::string &navmesh_file_name,
buildGraph(NavMesh::get());
// Compute shortest distance from all nodes
- for(unsigned int i=0; i < NavMesh::get()->getNumberOfPolys(); i++)
+ for(unsigned int i=0; i < NavMesh::get()->getNumberOfQuads(); i++)
computeDijkstra(i);
+ sortNearbyQuad();
if (node && race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER)
loadGoalNodes(node);
@@ -74,35 +77,32 @@ BattleGraph::~BattleGraph(void)
* adjacency matrix. */
void BattleGraph::buildGraph(NavMesh* navmesh)
{
- unsigned int n_polys = navmesh->getNumberOfPolys();
+ const unsigned int n_quads = navmesh->getNumberOfQuads();
- m_distance_matrix = std::vector< std::vector >
- (n_polys, std::vector(n_polys, 9999.9f));
- for(unsigned int i=0; i>
+ (n_quads, std::vector(n_quads, 9999.9f));
+ for(unsigned int i = 0; i < n_quads; i++)
{
- NavPoly currentPoly = navmesh->getNavPoly(i);
- const std::vector &adjacents = navmesh->getAdjacentPolys(i);
- for(unsigned int j=0; jgetQuad(i);
+ for (const int& adjacent : navmesh->getAdjacentQuads(i))
{
- Vec3 diff = navmesh->getCenterOfPoly(adjacents[j])
- - currentPoly.getCenter();
+ Vec3 diff = navmesh->getQuad(adjacent).getCenter()
+ - cur_quad.getCenter();
float distance = diff.length();
- m_distance_matrix[i][adjacents[j]] = distance;
- //m_distance_matrix[adjacents[j]][i] = distance;
+ m_distance_matrix[i][adjacent] = distance;
}
m_distance_matrix[i][i] = 0.0f;
}
// Allocate and initialise the previous node data structure:
- unsigned int n = getNumNodes();
- m_parent_poly = std::vector< std::vector >
- (n, std::vector(n, BattleGraph::UNKNOWN_POLY));
- for(unsigned int i=0; i>
+ (n_quads, std::vector(n_quads, BattleGraph::UNKNOWN_POLY));
+ for (unsigned int i = 0; i < n_quads; i++)
{
- for(unsigned int j=0; j=9899.9f)
- m_parent_poly[i][j]=-1;
+ if(i == j || m_distance_matrix[i][j] >= 9899.9f)
+ m_parent_poly[i][j] = -1;
else
m_parent_poly[i][j] = i;
} // for j
@@ -146,11 +146,9 @@ void BattleGraph::computeDijkstra(int source)
int cur_index = current.first;
if(visited[cur_index]) continue;
visited[cur_index] = true;
- const NavPoly ¤t_poly = navmesh->getNavPoly(cur_index);
- const std::vector &adjacents = current_poly.getAdjacents();
- for(unsigned int j=0; jgetAdjacentQuads(cur_index))
{
- int adjacent = adjacents[j];
// Distance already computed, can be ignored
if(visited[adjacent]) continue;
@@ -225,7 +223,7 @@ void BattleGraph::findItemsOnGraphNodes()
for (unsigned int j = 0; j < this->getNumNodes(); ++j)
{
- if (NavMesh::get()->getNavPoly(j).pointInPoly(xyz, false))
+ if (getQuadOfNode(j).pointInQuad(xyz, false))
polygon = j;
}
@@ -244,70 +242,50 @@ int BattleGraph::pointToNode(const int cur_node,
const Vec3& cur_point,
bool ignore_vertical) const
{
- int final_node = BattleGraph::UNKNOWN_POLY;
-
if (cur_node == BattleGraph::UNKNOWN_POLY)
{
// Try all nodes in the battle graph
- bool found = false;
- unsigned int node = 0;
- while (!found && node < this->getNumNodes())
+ for (unsigned int node = 0; node < this->getNumNodes(); node++)
{
- const NavPoly& p_all = this->getPolyOfNode(node);
- if (p_all.pointInPoly(cur_point, ignore_vertical))
+ const Quad& quad = this->getQuadOfNode(node);
+ if (quad.pointInQuad(cur_point, ignore_vertical))
{
- final_node = node;
- found = true;
+ return node;
}
- node++;
}
}
else
{
// Check if the point is still on the same node
- const NavPoly& p_cur = this->getPolyOfNode(cur_node);
- if (p_cur.pointInPoly(cur_point, ignore_vertical)) return cur_node;
+ const Quad& cur_quad = this->getQuadOfNode(cur_node);
+ if (cur_quad.pointInQuad(cur_point, ignore_vertical)) return cur_node;
- // If not then check all adjacent polys
- const std::vector& adjacents = NavMesh::get()
- ->getAdjacentPolys(cur_node);
-
- bool found = false;
- unsigned int num = 0;
- while (!found && num < adjacents.size())
+ // If not then check all nearby quads (8 quads)
+ // Skip the same node
+ assert(cur_node == m_nearby_quads[cur_node][0]);
+ for (unsigned int i = 1; i < m_nearby_quads[0].size(); i++)
{
- const NavPoly& p_temp = this->getPolyOfNode(adjacents[num]);
- if (p_temp.pointInPoly(cur_point, ignore_vertical))
+ const int test_node = m_nearby_quads[cur_node][i];
+ const Quad& quad = this->getQuadOfNode(test_node);
+ if (quad.pointInQuad(cur_point, ignore_vertical))
{
- final_node = adjacents[num];
- found = true;
+ return test_node;
}
- num++;
}
- // Current node is still unkown
- if (final_node == BattleGraph::UNKNOWN_POLY)
- {
- // Calculated distance from saved node to current position,
- // if it's close enough than use the saved node anyway, it
- // may happen when the kart stays on the edge of obstacles
- const NavPoly& p = this->getPolyOfNode(cur_node);
- const float dist = (p.getCenter() - cur_point).length_2d();
+ // Current node is still unkown:
+ // Calculated distance from saved node to current position,
+ // if it's close enough than use the saved node anyway, it
+ // may happen when the kart stays on the edge of obstacles
+ Vec3 diff = (cur_quad.getCenter() - cur_point);
+ float dist = diff.length();
- if (dist < 3.0f)
- final_node = cur_node;
- }
+ if (dist < 3.0f)
+ return cur_node;
}
- return final_node;
-} // pointToNode
-// -----------------------------------------------------------------------------
-const int BattleGraph::getNextShortestPathPoly(int i, int j) const
-{
- if (i == BattleGraph::UNKNOWN_POLY || j == BattleGraph::UNKNOWN_POLY)
- return BattleGraph::UNKNOWN_POLY;
- return m_parent_poly[j][i];
-} // getNextShortestPathPoly
+ return BattleGraph::UNKNOWN_POLY;
+} // pointToNode
// -----------------------------------------------------------------------------
const bool BattleGraph::differentNodeColor(int n, NodeColor* c) const
@@ -456,4 +434,40 @@ std::vector BattleGraph::getPathFromTo(int from, int to,
path.push_back(to);
}
return path;
-} // getPathFromTo
\ No newline at end of file
+} // getPathFromTo
+
+// ----------------------------------------------------------------------------
+void BattleGraph::sortNearbyQuad()
+{
+ // Only try the nearby 8 quads
+ const unsigned int n = 8;
+ m_nearby_quads = std::vector< std::vector >
+ (this->getNumNodes(), std::vector(n, BattleGraph::UNKNOWN_POLY));
+
+ for (unsigned int i = 0; i < this->getNumNodes(); i++)
+ {
+ // Get the distance to all nodes at i
+ std::vector dist = m_distance_matrix[i];
+ for (unsigned int j = 0; j < n; j++)
+ {
+ std::vector::iterator it =
+ std::min_element(dist.begin(), dist.end());
+ const int pos = it - dist.begin();
+ m_nearby_quads[i][j] = pos;
+ dist[pos] = 999999.0f;
+ }
+ }
+} // sortNearbyQuad
+
+// ----------------------------------------------------------------------------
+void BattleGraph::set3DVerticesOfGraph(int i, video::S3DVertex *v,
+ const video::SColor &color) const
+{
+ NavMesh::get()->getQuad(i).getVertices(v, color);
+} // set3DVerticesOfGraph
+
+// ----------------------------------------------------------------------------
+const bool BattleGraph::isNodeInvisible(int n) const
+{
+ return NavMesh::get()->getQuad(n).isInvisible();
+} // isNodeInvisible
diff --git a/src/tracks/battle_graph.hpp b/src/tracks/battle_graph.hpp
index da62e7c4e..b99fb607c 100644
--- a/src/tracks/battle_graph.hpp
+++ b/src/tracks/battle_graph.hpp
@@ -26,10 +26,8 @@
#include "tracks/graph_structure.hpp"
#include "tracks/navmesh.hpp"
-class GraphStructure;
class Item;
class ItemManager;
-class Navmesh;
class XMLNode;
/**
@@ -53,6 +51,8 @@ private:
/** The matrix that is used to store computed shortest paths */
std::vector< std::vector< int > > m_parent_poly;
+ std::vector< std::vector< int > > m_nearby_quads;
+
/** Stores the name of the file containing the NavMesh data */
std::string m_navmesh_file;
@@ -64,23 +64,19 @@ private:
void buildGraph(NavMesh*);
void computeFloydWarshall();
void loadGoalNodes(const XMLNode *node);
+ void sortNearbyQuad();
BattleGraph(const std::string &navmesh_file_name, const XMLNode *node=NULL);
~BattleGraph(void);
// ------------------------------------------------------------------------
virtual void set3DVerticesOfGraph(int i, video::S3DVertex *v,
- const video::SColor &color) const
- { NavMesh::get()->setVertices(i, v, color); }
+ const video::SColor &color) const;
// ------------------------------------------------------------------------
virtual void getGraphBoundingBox(Vec3 *min, Vec3 *max) const
{ NavMesh::get()->getBoundingBox(min, max); }
// ------------------------------------------------------------------------
- virtual const bool isNodeInvisible(int n) const
- { return false; }
- // ------------------------------------------------------------------------
- virtual const bool isNodeInvalid(int n) const
- { return (NavMesh::get()->getNavPoly(n).getVerticesIndex()).size()!=4; }
+ virtual const bool isNodeInvisible(int n) const;
// ------------------------------------------------------------------------
virtual const bool hasLapLine() const
{ return false; }
@@ -94,15 +90,16 @@ public:
static const int UNKNOWN_POLY;
void findItemsOnGraphNodes();
+ // ----------------------------------------------------------------------
int pointToNode(const int cur_node,
const Vec3& cur_point,
bool ignore_vertical) const;
+ // ------------------------------------------------------------------------
static void unitTesting();
-
-
+ // ------------------------------------------------------------------------
/** Returns the one instance of this object. */
static BattleGraph *get() { return m_battle_graph; }
- // ----------------------------------------------------------------------
+ // ------------------------------------------------------------------------
/** Asserts that no BattleGraph instance exists. Then
* creates a BattleGraph instance. */
static void create(const std::string &navmesh_file_name,
@@ -110,9 +107,8 @@ public:
{
assert(m_battle_graph==NULL);
m_battle_graph = new BattleGraph(navmesh_file_name, node);
-
} // create
- // ----------------------------------------------------------------------
+ // ------------------------------------------------------------------------
/** Cleans up the BattleGraph instance if it exists */
static void destroy()
{
@@ -122,14 +118,13 @@ public:
m_battle_graph = NULL;
}
} // destroy
-
- // ----------------------------------------------------------------------
- /** Returns the number of nodes in the BattleGraph (equal to the number of
- * polygons in the NavMesh */
+ // ------------------------------------------------------------------------
+ /** Returns the number of nodes in the BattleGraph (equal to the number
+ * of quads in the NavMesh
+ */
virtual const unsigned int getNumNodes() const
- { return m_distance_matrix.size(); }
-
- // ----------------------------------------------------------------------
+ { return NavMesh::get()->getNumberOfQuads(); }
+ // ------------------------------------------------------------------------
/** Returns the distance between any two nodes */
float getDistance(int from, int to) const
{
@@ -139,26 +134,33 @@ public:
return m_distance_matrix[from][to];
}
// ------------------------------------------------------------------------
- /** Returns the NavPoly corresponding to the i-th node of the BattleGraph */
- const NavPoly& getPolyOfNode(int i) const
- { return NavMesh::get()->getNavPoly(i); }
-
- // ------------------------------------------------------------------------
- /** Returns true if the NavPoly lies near the edge. */
- bool isNearEdge(int i) const
- { return NavMesh::get()->getNavPoly(i).isPolyNearEdge(); }
- // ------------------------------------------------------------------------
/** Returns the next polygon on the shortest path from i to j.
- * Note: m_parent_poly[j][i] contains the parent of i on path from j to i,
- * which is the next node on the path from i to j (undirected graph) */
- const int getNextShortestPathPoly(int i, int j) const;
-
+ * Note: m_parent_poly[j][i] contains the parent of i on path from j to i,
+ * which is the next node on the path from i to j (undirected graph)
+ */
+ int getNextShortestPathPoly(int i, int j) const
+ {
+ if (i == BattleGraph::UNKNOWN_POLY || j == BattleGraph::UNKNOWN_POLY)
+ return BattleGraph::UNKNOWN_POLY;
+ return m_parent_poly[j][i];
+ }
+ // ------------------------------------------------------------------------
std::vector>& getItemList()
{ return m_items_on_graph; }
// ------------------------------------------------------------------------
void insertItems(Item* item, int polygon)
{ m_items_on_graph.push_back(std::make_pair(item, polygon)); }
// ------------------------------------------------------------------------
+ /** Returns the quad that belongs to a node. */
+ const Quad& getQuadOfNode(unsigned int n) const
+ { return NavMesh::get()->getQuad(n); }
+ // ------------------------------------------------------------------------
+ /** Returns true if the quad lies near the edge, which means it doesn't
+ * have 4 adjacent quads.
+ */
+ bool isNearEdge(unsigned int n) const
+ { return NavMesh::get()->getAdjacentQuads(n).size() != 4; }
+ // ------------------------------------------------------------------------
}; //BattleGraph
#endif
diff --git a/src/tracks/graph_structure.cpp b/src/tracks/graph_structure.cpp
index 17ba02dac..bb006e489 100644
--- a/src/tracks/graph_structure.cpp
+++ b/src/tracks/graph_structure.cpp
@@ -28,6 +28,7 @@
#include "graphics/shaders.hpp"
#include "graphics/rtts.hpp"
#include "modes/world.hpp"
+#include "modes/profile_world.hpp"
#include "utils/log.hpp"
// -----------------------------------------------------------------------------
@@ -140,12 +141,6 @@ void GraphStructure::createMesh(bool show_invisible,
// Ignore invisible quads
if (!show_invisible && isNodeInvisible(count))
continue;
- else if (isNodeInvalid(count))
- {
- // There should not be a node which isn't made of 4 vertices
- Log::warn("Graph Structure", "There is an invalid node!");
- continue;
- }
// Swap the colours from red to blue and back
if (!track_color)
@@ -248,6 +243,9 @@ void GraphStructure::makeMiniMap(const core::dimension2du &dimension,
video::ITexture** oldRttMinimap,
FrameBuffer** newRttMinimap)
{
+ // Skip minimap when profiling
+ if (ProfileWorld::isNoGraphics()) return;
+
const video::SColor oldClearColor = World::getWorld()->getClearColor();
World::getWorld()->setClearbackBufferColor(video::SColor(0, 255, 255, 255));
World::getWorld()->forceFogDisabled(true);
diff --git a/src/tracks/graph_structure.hpp b/src/tracks/graph_structure.hpp
index 572e0a276..d66f156c5 100644
--- a/src/tracks/graph_structure.hpp
+++ b/src/tracks/graph_structure.hpp
@@ -82,7 +82,6 @@ private:
const video::SColor &color) const = 0;
virtual void getGraphBoundingBox(Vec3 *min, Vec3 *max) const = 0;
virtual const bool isNodeInvisible(int n) const = 0;
- virtual const bool isNodeInvalid(int n) const = 0;
virtual const bool hasLapLine() const = 0;
virtual const bool differentNodeColor(int n, NodeColor* c) const = 0;
diff --git a/src/tracks/nav_poly.cpp b/src/tracks/nav_poly.cpp
deleted file mode 100644
index 02518f5a3..000000000
--- a/src/tracks/nav_poly.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-//
-// SuperTuxKart - a fun racing game with go-kart
-// Copyright (C) 2009-2015 Joerg Henrichs
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 3
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-#include "tracks/nav_poly.hpp"
-#include "tracks/navmesh.hpp"
-
-#include
-#include
-
-/** Constructor that takes a vector of points and a vector of adjacent polygons */
-NavPoly::NavPoly(const std::vector &polygonVertIndices,
- const std::vector &adjacentPolygonIndices)
-{
- m_vertices = polygonVertIndices;
-
- m_adjacents = adjacentPolygonIndices;
-
- std::vector xyz_points = getVertices();
-
- Vec3 temp(0.0f,0.0f,0.0f);
- for(unsigned int i=0; i NavPoly::getVertices()
-{
- std::vector points;
- for(unsigned int i=0; igetVertex(m_vertices[i]));
- return points;
-}
-
-//-----------------------------------------------------------------------------
-
-bool NavPoly::pointInPoly(const Vec3& p, bool ignore_vertical) const
-{
- std::vector points;
- for(unsigned int i=0; igetVertex(m_vertices[i]));
-
- // The point is on which side of the first edge
- float side = p.sideOfLine2D(points[0],points[1]);
-
- // The point is inside the polygon if it is on the same side for all edges
- for(unsigned int i=1; i 1.0f)
- return false;
- return true;
-}
-
-//-----------------------------------------------------------------------------
-
-const Vec3& NavPoly::operator[](int i) const
-{
- return NavMesh::get()->getVertex(m_vertices[i]);
-}
diff --git a/src/tracks/nav_poly.hpp b/src/tracks/nav_poly.hpp
deleted file mode 100644
index 8faf19f2a..000000000
--- a/src/tracks/nav_poly.hpp
+++ /dev/null
@@ -1,75 +0,0 @@
-//
-// SuperTuxKart - a fun racing game with go-kart
-// Copyright (C) 2009-2015 Joerg Henrichs
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 3
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-#ifndef HEADER_NAV_POLY_HPP
-#define HEADER_NAV_POLY_HPP
-
-#include
-#include
-#include
-#include "utils/vec3.hpp"
-
-/**
-* \ingroup tracks
-*/
-class NavPoly
-{
-private:
- /** Holds the index of vertices for a polygon **/
- std::vector m_vertices;
-
- /** Center of this polygon. **/
- Vec3 m_center;
-
- /** Holds the index of adjacent polyogns **/
- std::vector m_adjacents;
-
-public:
- NavPoly(const std::vector &polygonVertIndices,
- const std::vector &adjacentPolygonIndices);
-
- // ------------------------------------------------------------------------
- /** Returns the center point of a polygon. */
- const Vec3& getCenter() const { return m_center; }
-
- // ------------------------------------------------------------------------
- /** Returns the adjacent polygons of a polygon. */
- const std::vector& getAdjacents() const { return m_adjacents; }
-
- // ------------------------------------------------------------------------
- /** Returns the vertices(Vec3) of this polygon. */
- const std::vector getVertices();
-
- // ------------------------------------------------------------------------
- /** Returns the indices of the vertices of this polygon */
- const std::vector getVerticesIndex() const
- { return m_vertices; }
- // ------------------------------------------------------------------------
- /** Returns true if a given point lies in this polygon. */
- bool pointInPoly(const Vec3& p,
- bool ignore_vertical) const;
- // ------------------------------------------------------------------------
- /** Returns true if this polygon lies near the edge. */
- bool isPolyNearEdge() const
- { return m_adjacents.size() < 4; }
- // ------------------------------------------------------------------------
- const Vec3& operator[](int i) const ;
-
-}; // class NavPoly
-
-#endif
diff --git a/src/tracks/navmesh.cpp b/src/tracks/navmesh.cpp
index f29afcf31..74d525add 100644
--- a/src/tracks/navmesh.cpp
+++ b/src/tracks/navmesh.cpp
@@ -17,16 +17,13 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "tracks/navmesh.hpp"
-#include "tracks/nav_poly.hpp"
-#include
-#include
-#include
-
-#include "LinearMath/btTransform.h"
#include "io/file_manager.hpp"
#include "io/xml_node.hpp"
-#include "utils/string_utils.hpp"
+#include "tracks/quad.hpp"
+#include "utils/log.hpp"
+
+#include
NavMesh *NavMesh::m_nav_mesh = NULL;
@@ -39,78 +36,68 @@ NavMesh::NavMesh(const std::string &filename)
m_min = Vec3( 99999, 99999, 99999);
m_max = Vec3(-99999, -99999, -99999);
- m_n_verts=0;
- m_n_polys=0;
XMLNode *xml = file_manager->createXMLTree(filename);
- if(xml->getName()!="navmesh")
+ if (xml->getName() != "navmesh")
{
- Log::error("NavMesh", "NavMesh is invalid. \n");
- delete xml;
+ Log::error("NavMesh", "NavMesh is invalid.");
+ delete xml;
return;
}
- // Assigning m_nav_mesh here because constructing NavPoly requires m_nav_mesh to be defined
- m_nav_mesh = this;
-
- for(unsigned int i=0; igetNumNodes(); i++)
+ std::vector all_vertices;
+ for (unsigned int i = 0; i < xml->getNumNodes(); i++)
{
const XMLNode *xml_node = xml->getNode(i);
- if(xml_node->getName()=="vertices")
+ if (xml_node->getName() == "vertices")
{
- for(unsigned int i=0; igetNumNodes(); i++)
+ for (unsigned int i = 0; i < xml_node->getNumNodes(); i++)
{
const XMLNode *xml_node_node = xml_node->getNode(i);
- if(!(xml_node_node->getName()=="vertex"))
+ if (!(xml_node_node->getName() == "vertex"))
{
- Log::error("NavMesh", "Unsupported type '%s' found in '%s' - ignored. \n",
- xml_node_node->getName().c_str(),filename.c_str());
+ Log::error("NavMesh", "Unsupported type '%s' found"
+ "in '%s' - ignored.",
+ xml_node_node->getName().c_str(), filename.c_str());
continue;
}
- //Reading vertices
+ // Reading vertices
Vec3 p;
readVertex(xml_node_node, &p);
m_max.max(p);
m_min.min(p);
- m_n_verts++;
- m_verts.push_back(p);
+ all_vertices.push_back(p);
}
-
}
- if(xml_node->getName()=="faces")
+ if (xml_node->getName() == "faces")
{
- for(unsigned int i=0; igetNumNodes(); i++)
+ for(unsigned int i = 0; i < xml_node->getNumNodes(); i++)
{
const XMLNode *xml_node_node = xml_node->getNode(i);
- if(xml_node_node->getName()!="face")
+ if (xml_node_node->getName() != "face")
{
- Log::error("NavMesh", "Unsupported type '%s' found in '%s' - ignored. \n",
- xml_node_node->getName().c_str(),filename.c_str());
+ Log::error("NavMesh", "Unsupported type '%s' found in '%s'"
+ " - ignored.",
+ xml_node_node->getName().c_str(), filename.c_str());
continue;
}
- //Reading faces/polys
- std::vector polygonVertIndices;
- std::vector adjacentPolygonIndices;
- xml_node_node->get("indices", &polygonVertIndices);
- xml_node_node->get("adjacents", &adjacentPolygonIndices);
- NavPoly *np = new NavPoly(polygonVertIndices, adjacentPolygonIndices);
- m_polys.push_back(*np);
- m_n_polys++;
+ // Reading quads
+ std::vector quad_index;
+ std::vector adjacent_quad_index;
+ xml_node_node->get("indices", &quad_index);
+ xml_node_node->get("adjacents", &adjacent_quad_index);
+ assert(quad_index.size() == 4);
+
+ m_adjacent_quads.push_back(adjacent_quad_index);
+ m_quads.push_back(new Quad(
+ all_vertices[quad_index[0]], all_vertices[quad_index[1]],
+ all_vertices[quad_index[2]], all_vertices[quad_index[3]]));
}
-
}
-
- if(xml_node->getName()=="MaxVertsPerPoly")
- {
- xml_node->get("nvp", &m_nvp);
- }
-
- //delete xml_node;
}
-
delete xml;
} // NavMesh
@@ -119,48 +106,14 @@ NavMesh::NavMesh(const std::string &filename)
NavMesh::~NavMesh()
{
+ for (unsigned int i = 0; i < m_quads.size(); i++)
+ {
+ delete m_quads[i];
+ }
+ m_quads.clear();
} // ~NavMesh
// ----------------------------------------------------------------------------
-/** Sets the vertices in a irrlicht vertex array to the 4 points of this quad.
- */
-void NavMesh::setVertices(int n, video::S3DVertex *v, const video::SColor &color) const
-{
- NavPoly poly = NavMesh::get()->getNavPoly(n);
- const std::vector& p = poly.getVertices();
-
- if (p.size() !=4) return;
-
- // Eps is used to raise the track debug quads a little bit higher than
- // the ground, so that they are actually visible.
- core::vector3df eps(0, 0.1f, 0);
- v[0].Pos = p[0].toIrrVector()+eps;
- v[1].Pos = p[1].toIrrVector()+eps;
- v[2].Pos = p[2].toIrrVector()+eps;
- v[3].Pos = p[3].toIrrVector()+eps;
-
- core::triangle3df tri(p[0].toIrrVector(), p[1].toIrrVector(),
- p[2].toIrrVector());
- core::vector3df normal = tri.getNormal();
- normal.normalize();
- v[0].Normal = normal;
- v[1].Normal = normal;
- v[2].Normal = normal;
-
- core::triangle3df tri1(p[0].toIrrVector(), p[2].toIrrVector(),
- p[3].toIrrVector());
- core::vector3df normal1 = tri1.getNormal();
- normal1.normalize();
- v[3].Normal = normal1;
-
- v[0].Color = color;
- v[1].Color = color;
- v[2].Color = color;
- v[3].Color = color;
-} // setVertices
-
-// ----------------------------------------------------------------------------
-
/** Reads the vertex information from an XMLNode */
void NavMesh::readVertex(const XMLNode *xml, Vec3* result) const
{
@@ -170,4 +123,11 @@ void NavMesh::readVertex(const XMLNode *xml, Vec3* result) const
xml->get("z", &z);
Vec3 temp(x, y, z);
*result = temp;
-} // readVertex
+} // readVertex
+
+// ----------------------------------------------------------------------------
+const Vec3& NavMesh::getCenterOfQuad(unsigned int n) const
+{
+ assert(m_quads.size() > 0 && n < m_quads.size());
+ return m_quads[n]->getCenter();
+} // getCenterOfQuad
diff --git a/src/tracks/navmesh.hpp b/src/tracks/navmesh.hpp
index 5ef79f1ad..bf0f16451 100644
--- a/src/tracks/navmesh.hpp
+++ b/src/tracks/navmesh.hpp
@@ -19,144 +19,103 @@
#ifndef HEADER_NAVMESH_HPP
#define HEADER_NAVMESH_HPP
-#include "tracks/nav_poly.hpp"
-
#include
#include
-#include
#include "utils/vec3.hpp"
-namespace irr
-{
- namespace video { struct S3DVertex; }
-}
-using namespace irr;
-
-class btTransform;
+class Quad;
class XMLNode;
/**
-* \ingroup tracks
-*
-* \brief This class stores a set of navigatoin polygons. It uses a
-* 'simplified singleton' design pattern: it has a static create function
-* to create exactly one instance, a destroy function, and a get function
-* (that does not have the side effect of the 'normal singleton' design
-* pattern to create an instance). Besides saving on the if statement in get(),
-* this is necessary since certain race modes might not have a navigaton
-* mesh at all (e.g. race mode). So get() returns NULL in this case, and
-* this is tested where necessary.
- \ingroup tracks
-*/
+ * \brief This class stores a set of navigation quads. It uses a
+ * 'simplified singleton' design pattern: it has a static create function
+ * to create exactly one instance, a destroy function, and a get function
+ * (that does not have the side effect of the 'normal singleton' design
+ * pattern to create an instance). Besides saving on the if statement in
+ * get(), this is necessary since certain race modes might not have a
+ * navigation mesh at all (e.g. race mode). So get() returns NULL in this
+ * case, and this is tested where necessary.
+ * \ingroup tracks
+ */
class NavMesh
{
private:
- static NavMesh *m_nav_mesh;
+ static NavMesh *m_nav_mesh;
/** The 2d bounding box, used for hashing. */
- Vec3 m_min;
- Vec3 m_max;
+ Vec3 m_min;
+ Vec3 m_max;
- /** The actual set of nav polys that constitute the nav mesh */
- std::vector m_polys;
+ /** The actual set of quads that constitute the nav mesh */
+ std::vector m_quads;
- /** The set of vertices that are part of this nav mesh*/
- std::vector< Vec3 > m_verts;
-
- /** Number of vertices */
- unsigned int m_n_verts;
- /** Number of polygons */
- unsigned int m_n_polys;
- /** Maximum vertices per polygon */
- unsigned int m_nvp;
+ std::vector> m_adjacent_quads;
void readVertex(const XMLNode *xml, Vec3* result) const;
- //void readFace(const XMLNode *xml, Vec3* result) const;
+ // ------------------------------------------------------------------------
NavMesh(const std::string &filename);
+ // ------------------------------------------------------------------------
~NavMesh();
public:
/** Creates a NavMesh instance. */
static void create(const std::string &filename)
{
- assert(m_nav_mesh==NULL);
-
- // m_nav_mesh assigned in the constructor because it needs to defined
- // for NavPoly which is constructed in NavMesh()
- new NavMesh(filename);
+ assert(m_nav_mesh == NULL);
+ m_nav_mesh = new NavMesh(filename);
}
-
+ // ------------------------------------------------------------------------
/** Cleans up the nav mesh. It is possible that this function is called
- * even if no instance exists (e.g. in race). So it is not an
- * error if there is no instance. */
+ * even if no instance exists (e.g. in race). So it is not an
+ * error if there is no instance.
+ */
static void destroy()
{
- if(m_nav_mesh)
- {
- delete m_nav_mesh;
- m_nav_mesh = NULL;
- }
+ if (m_nav_mesh)
+ {
+ delete m_nav_mesh;
+ m_nav_mesh = NULL;
+ }
}
-
+ // ------------------------------------------------------------------------
/** Returns the one instance of this object. It is possible that there
- * is no instance created (e.g. in normal race, since it doesn't have
- * a nav mesh), so we don't assert that an instance exist, and we
- * also don't create one if it doesn't exists. */
- static NavMesh *get() { return m_nav_mesh; }
-
+ * is no instance created (e.g. in normal race, since it doesn't have
+ * a nav mesh), so we don't assert that an instance exist, and we
+ * also don't create one if it doesn't exists.
+ */
+ static NavMesh *get() { return m_nav_mesh; }
// ------------------------------------------------------------------------
/** Return the minimum and maximum coordinates of this navmesh. */
- void getBoundingBox(Vec3 *min, Vec3 *max)
- { *min=m_min; *max=m_max; }
+ void getBoundingBox(Vec3 *min, Vec3 *max) { *min=m_min; *max=m_max; }
// ------------------------------------------------------------------------
- /** Returns a const reference to a NavPoly */
- const NavPoly& getNavPoly(int n) const
- { return m_polys[n]; }
- // ------------------------------------------------------------------------
- /** Returns a const reference to a vertex(Vec3) */
- const Vec3& getVertex(int n) const
- { return m_verts[n]; }
- // ------------------------------------------------------------------------
- /** Sets the vertices in a irrlicht vertex array to
- * the 4 points of a navpoly.
- * \param n The number of a navpoly.
- * \param v The vertex array in which to set the vertices.
- * \param color The color to use for this quad.
- */
- void setVertices(int n, video::S3DVertex *v,
- const video::SColor &color) const;
- // ------------------------------------------------------------------------
- /** Returns a const reference to a vector containing all vertices */
- const std::vector& getAllVertices() const
- { return m_verts; }
- // ------------------------------------------------------------------------
- /** Returns the total number of polys */
- unsigned int getNumberOfPolys() const
- { return m_n_polys; }
- // ------------------------------------------------------------------------
- /** Returns the total number of vertices */
- unsigned int getNumberOfVerts() const
- { return m_n_verts; }
- // ------------------------------------------------------------------------
- /** Returns maximum vertices per polygon */
- unsigned int getMaxVertsPerPoly() const
- { return m_nvp; }
- // ------------------------------------------------------------------------
- /** Returns the center of a polygon */
- const Vec3& getCenterOfPoly(int n) const
- {return m_polys[n].getCenter();}
+ /** Returns a const reference to a quad */
+ const Quad& getQuad(unsigned int n) const
+ {
+ assert(m_quads.size() > 0 && n < m_quads.size());
+ return *(m_quads[n]);
+ }
// ------------------------------------------------------------------------
/** Returns a const referece to a vector containing the indices
- * of polygons adjacent to a given polygon */
- const std::vector& getAdjacentPolys(int n) const
- {return m_polys[n].getAdjacents();}
+ * of quads adjacent to a given quad
+ */
+ const std::vector& getAdjacentQuads(unsigned int n) const
+ {
+ assert(m_adjacent_quads.size() > 0 && n < m_adjacent_quads.size() &&
+ m_quads.size() == m_adjacent_quads.size());
+ return m_adjacent_quads[n];
+ }
// ------------------------------------------------------------------------
- /** Returns a const reference to a vector containing the vertices
- * of a given polygon. */
- const std::vector getVertsOfPoly(int n)
- {return m_polys[n].getVertices();}
+ /** Returns the total number of quads */
+ unsigned int getNumberOfQuads() const
+ {
+ assert(m_quads.size() > 0);
+ return m_quads.size();
+ }
+ // ------------------------------------------------------------------------
+ /** Returns the center of a quad */
+ const Vec3& getCenterOfQuad(unsigned int n) const;
};
#endif
diff --git a/src/tracks/quad.cpp b/src/tracks/quad.cpp
index 729600f44..6fc2d4377 100644
--- a/src/tracks/quad.cpp
+++ b/src/tracks/quad.cpp
@@ -88,7 +88,7 @@ void Quad::getVertices(video::S3DVertex *v, const video::SColor &color) const
} // setVertices
// ----------------------------------------------------------------------------
-bool Quad::pointInQuad(const Vec3& p) const
+bool Quad::pointInQuad(const Vec3& p, bool ignore_vertical) const
{
// In case that a kart can validly run too high over one driveline
// and it should not be considered to be on that driveline. Example:
@@ -98,17 +98,21 @@ bool Quad::pointInQuad(const Vec3& p) const
// is taken into account, too. to simplify this test we only compare
// with the minimum height of the quad (and not with the actual
// height of the quad at the point where the kart is).
- if(p.getY() - m_max_height > 5.0f ||
- p.getY() - m_min_height < -1.0f )
+ if(!ignore_vertical &&
+ (p.getY() - m_max_height > 5.0f ||
+ p.getY() - m_min_height < -1.0f ))
return false;
// If a point is exactly on the line of two quads (e.g. between points
// 0,1 on one quad, and 3,2 of the previous quad), assign this point
// to be on the 'later' quad, i.e. on the line between points 0 and 1.
- if(p.sideOfLine2D(m_p[0], m_p[2])<0) {
+ if(p.sideOfLine2D(m_p[0], m_p[2])<0)
+ {
return p.sideOfLine2D(m_p[0], m_p[1]) >= 0.0 &&
p.sideOfLine2D(m_p[1], m_p[2]) >= 0.0;
- } else {
+ }
+ else
+ {
return p.sideOfLine2D(m_p[2], m_p[3]) > 0.0 &&
p.sideOfLine2D(m_p[3], m_p[0]) >= 0.0;
}
diff --git a/src/tracks/quad.hpp b/src/tracks/quad.hpp
index 74f35abdc..922f4d121 100644
--- a/src/tracks/quad.hpp
+++ b/src/tracks/quad.hpp
@@ -61,7 +61,7 @@ public:
Quad(const Vec3 &p0, const Vec3 &p1, const Vec3 &p2, const Vec3 &p3,
bool invis=false, bool ai_ignore=false);
void getVertices(video::S3DVertex *v, const video::SColor &color) const;
- bool pointInQuad(const Vec3& p) const;
+ bool pointInQuad(const Vec3& p, bool ignore_vertical = false) const;
void transform(const btTransform &t, Quad *result) const;
// ------------------------------------------------------------------------
/** Returns the i-th. point of a quad. */
diff --git a/src/tracks/quad_graph.hpp b/src/tracks/quad_graph.hpp
index 2a9c69364..52c4231fe 100644
--- a/src/tracks/quad_graph.hpp
+++ b/src/tracks/quad_graph.hpp
@@ -29,7 +29,6 @@
#include "utils/aligned_array.hpp"
class CheckLine;
-class GraphStructure;
/**
* \brief This class stores a graph of quads. It uses a 'simplified singleton'
@@ -85,9 +84,6 @@ private:
virtual const bool isNodeInvisible(int n) const
{ return m_all_nodes[n]->getQuad().isInvisible(); }
// ------------------------------------------------------------------------
- virtual const bool isNodeInvalid(int n) const
- { return false; }
- // ------------------------------------------------------------------------
virtual const bool hasLapLine() const
{ return true; }
// ------------------------------------------------------------------------
From 8e8433f08ce6f8ba4b5cd6278231c2e64e92aca0 Mon Sep 17 00:00:00 2001
From: MTres19
Date: Fri, 5 Aug 2016 19:12:52 -0400
Subject: [PATCH 21/39] Credit where credit is due (#2593)
* Give GeekPenguinBR and TuxKartDriver credit
* Give credit to samuncle and konstin
---
data/CREDITS | Bin 16560 -> 16886 bytes
1 file changed, 0 insertions(+), 0 deletions(-)
diff --git a/data/CREDITS b/data/CREDITS
index 96165c2729151f833543c65f7447d9ea4615c165..d12f77486cf78d2bdfdd3535c15d6ebfb4ff3398 100755
GIT binary patch
delta 291
zcmaJ+yAHu%7(Hc?VyS^ebSnujz$OxjO9*yxtq~}@k@5-@-A?BE1gf&)>QGkjn>j@TU)7#Lofx%ct2YF6=taqqm0GF5w
zy@4$^UCxTMCLD}eo8(h5W#56ttU-k6REW2Kc{fIi0oM&St>C5{oRIVDSZh=yL?AHLAVzW7o@z`k0iZECY8wYM2D-^=LHjcf-mN88hQ
Date: Thu, 11 Aug 2016 01:58:18 +0200
Subject: [PATCH 22/39] Allow to set lower RTTs resolution.
It allows to increase performance on devices that have only one available resolution.
It also allows to draw GUI elements in full resolution while rendering the scene with slightly lower resolution, which gives you few additional FPS.
Note that particles don't work as expected yet with this feature.
---
src/config/user_config.hpp | 4 ++++
src/graphics/irr_driver.cpp | 6 ++++--
src/graphics/render.cpp | 1 +
src/graphics/rtts.cpp | 41 +++++++++++++++++++------------------
src/input/input_manager.cpp | 6 +++---
5 files changed, 33 insertions(+), 25 deletions(-)
diff --git a/src/config/user_config.hpp b/src/config/user_config.hpp
index 235515e8a..ccde2db71 100644
--- a/src/config/user_config.hpp
+++ b/src/config/user_config.hpp
@@ -491,6 +491,10 @@ namespace UserConfigParams
PARAM_PREFIX BoolUserConfigParam m_old_driver_popup
PARAM_DEFAULT(BoolUserConfigParam(true, "old_driver_popup",
&m_video_group, "Determines if popup message about too old drivers should be displayed."));
+ PARAM_PREFIX FloatUserConfigParam m_scale_rtts_factor
+ PARAM_DEFAULT(FloatUserConfigParam(1.0f, "m_scale_rtts_factor",
+ &m_video_group, "Allows to increase performance by setting lower RTTs "
+ "resolution. Value should be smaller or equal to 1.0"));
// ---- Debug - not saved to config file
/** If gamepad debugging is enabled. */
diff --git a/src/graphics/irr_driver.cpp b/src/graphics/irr_driver.cpp
index b78457875..075efdbe2 100644
--- a/src/graphics/irr_driver.cpp
+++ b/src/graphics/irr_driver.cpp
@@ -216,8 +216,10 @@ GPUTimer &IrrDriver::getGPUTimer(unsigned i)
void IrrDriver::computeMatrixesAndCameras(scene::ICameraSceneNode *const camnode,
size_t width, size_t height)
{
- m_current_screen_size = core::vector2df(float(width), float(height));
- m_shadow_matrices->computeMatrixesAndCameras(camnode, width, height);
+ float w = width * UserConfigParams::m_scale_rtts_factor;
+ float h = height * UserConfigParams::m_scale_rtts_factor;
+ m_current_screen_size = core::vector2df(w, h);
+ m_shadow_matrices->computeMatrixesAndCameras(camnode, w, h);
} // computeMatrixesAndCameras
// ----------------------------------------------------------------------------
diff --git a/src/graphics/render.cpp b/src/graphics/render.cpp
index cbebacae6..3ef16eefc 100644
--- a/src/graphics/render.cpp
+++ b/src/graphics/render.cpp
@@ -285,6 +285,7 @@ void IrrDriver::renderGLSL(float dt)
glBindFramebuffer(GL_FRAMEBUFFER, 0);
if (CVS->isDefferedEnabled())
camera->activate();
+ glViewport(viewport.UpperLeftCorner.X, viewport.UpperLeftCorner.Y, viewport.LowerRightCorner.X, viewport.LowerRightCorner.Y);
m_post_processing->renderPassThrough(fbo->getRTT()[0], viewport.LowerRightCorner.X - viewport.UpperLeftCorner.X, viewport.LowerRightCorner.Y - viewport.UpperLeftCorner.Y);
glDisable(GL_FRAMEBUFFER_SRGB);
}
diff --git a/src/graphics/rtts.cpp b/src/graphics/rtts.cpp
index 8ea69505e..2e7efa0a4 100644
--- a/src/graphics/rtts.cpp
+++ b/src/graphics/rtts.cpp
@@ -58,13 +58,15 @@ RTT::RTT(size_t width, size_t height)
m_RH_FBO = NULL;
using namespace video;
using namespace core;
-
- const dimension2du res(width, height);
+
+ dimension2du res(width * UserConfigParams::m_scale_rtts_factor,
+ height * UserConfigParams::m_scale_rtts_factor);
+
const dimension2du half = res/2;
const dimension2du quarter = res/4;
const dimension2du eighth = res/8;
- const u16 shadowside = 1024;
+ const u16 shadowside = 1024 * UserConfigParams::m_scale_rtts_factor;
const dimension2du shadowsize0(shadowside, shadowside);
const dimension2du shadowsize1(shadowside / 2, shadowside / 2);
const dimension2du shadowsize2(shadowside / 4, shadowside / 4);
@@ -118,7 +120,6 @@ RTT::RTT(size_t width, size_t height)
std::vector somevector;
somevector.push_back(RenderTargetTextures[RTT_SSAO]);
-
FrameBuffers.push_back(new FrameBuffer(somevector, res.Width, res.Height));
somevector.clear();
somevector.push_back(RenderTargetTextures[RTT_NORMAL_AND_DEPTH]);
@@ -158,12 +159,12 @@ RTT::RTT(size_t width, size_t height)
somevector.push_back(RenderTargetTextures[RTT_LINEAR_DEPTH]);
FrameBuffers.push_back(new FrameBuffer(somevector, res.Width, res.Height));
somevector.clear();
+
somevector.push_back(RenderTargetTextures[RTT_HALF1]);
FrameBuffers.push_back(new FrameBuffer(somevector, half.Width, half.Height));
somevector.clear();
somevector.push_back(RenderTargetTextures[RTT_HALF1_R]);
FrameBuffers.push_back(new FrameBuffer(somevector, half.Width, half.Height));
-
somevector.clear();
somevector.push_back(RenderTargetTextures[RTT_HALF2]);
FrameBuffers.push_back(new FrameBuffer(somevector, half.Width, half.Height));
@@ -186,42 +187,42 @@ RTT::RTT(size_t width, size_t height)
somevector.push_back(RenderTargetTextures[RTT_DISPLACE]);
FrameBuffers.push_back(new FrameBuffer(somevector, DepthStencilTexture, res.Width, res.Height));
somevector.clear();
+
somevector.push_back(RenderTargetTextures[RTT_BLOOM_1024]);
- FrameBuffers.push_back(new FrameBuffer(somevector, 1024, 1024));
+ FrameBuffers.push_back(new FrameBuffer(somevector, shadowsize0.Width, shadowsize0.Height));
somevector.clear();
somevector.push_back(RenderTargetTextures[RTT_SCALAR_1024]);
- FrameBuffers.push_back(new FrameBuffer(somevector, 1024, 1024));
+ FrameBuffers.push_back(new FrameBuffer(somevector, shadowsize0.Width, shadowsize0.Height));
somevector.clear();
+
somevector.push_back(RenderTargetTextures[RTT_BLOOM_512]);
- FrameBuffers.push_back(new FrameBuffer(somevector, 512, 512));
+ FrameBuffers.push_back(new FrameBuffer(somevector, shadowsize1.Width, shadowsize1.Height));
somevector.clear();
somevector.push_back(RenderTargetTextures[RTT_TMP_512]);
- FrameBuffers.push_back(new FrameBuffer(somevector, 512, 512));
+ FrameBuffers.push_back(new FrameBuffer(somevector, shadowsize1.Width, shadowsize1.Height));
somevector.clear();
somevector.push_back(RenderTargetTextures[RTT_LENS_512]);
- FrameBuffers.push_back(new FrameBuffer(somevector, 512, 512));
-
-
+ FrameBuffers.push_back(new FrameBuffer(somevector, shadowsize1.Width, shadowsize1.Height));
somevector.clear();
+
somevector.push_back(RenderTargetTextures[RTT_BLOOM_256]);
- FrameBuffers.push_back(new FrameBuffer(somevector, 256, 256));
+ FrameBuffers.push_back(new FrameBuffer(somevector, shadowsize2.Width, shadowsize2.Height));
somevector.clear();
somevector.push_back(RenderTargetTextures[RTT_TMP_256]);
- FrameBuffers.push_back(new FrameBuffer(somevector, 256, 256));
+ FrameBuffers.push_back(new FrameBuffer(somevector, shadowsize2.Width, shadowsize2.Height));
somevector.clear();
somevector.push_back(RenderTargetTextures[RTT_LENS_256]);
- FrameBuffers.push_back(new FrameBuffer(somevector, 256, 256));
-
-
+ FrameBuffers.push_back(new FrameBuffer(somevector, shadowsize2.Width, shadowsize2.Height));
somevector.clear();
+
somevector.push_back(RenderTargetTextures[RTT_BLOOM_128]);
- FrameBuffers.push_back(new FrameBuffer(somevector, 128, 128));
+ FrameBuffers.push_back(new FrameBuffer(somevector, shadowsize3.Width, shadowsize3.Height));
somevector.clear();
somevector.push_back(RenderTargetTextures[RTT_TMP_128]);
- FrameBuffers.push_back(new FrameBuffer(somevector, 128, 128));
+ FrameBuffers.push_back(new FrameBuffer(somevector, shadowsize3.Width, shadowsize3.Height));
somevector.clear();
somevector.push_back(RenderTargetTextures[RTT_LENS_128]);
- FrameBuffers.push_back(new FrameBuffer(somevector, 128, 128));
+ FrameBuffers.push_back(new FrameBuffer(somevector, shadowsize3.Width, shadowsize3.Height));
if (CVS->isShadowEnabled())
{
diff --git a/src/input/input_manager.cpp b/src/input/input_manager.cpp
index adc6e7e03..ceb261efe 100644
--- a/src/input/input_manager.cpp
+++ b/src/input/input_manager.cpp
@@ -1005,9 +1005,9 @@ EventPropagation InputManager::input(const SEvent& event)
if (cam)
{
// Center of the screen
- core::vector2df screen_size = irr_driver->getCurrentScreenSize();
- int mid_x = (int) screen_size.X / 2;
- int mid_y = (int) screen_size.Y / 2;
+ core::dimension2du screen_size = irr_driver->getActualScreenSize();
+ int mid_x = (int) screen_size.Width / 2;
+ int mid_y = (int) screen_size.Height / 2;
// Relative mouse movement
int diff_x = event.MouseInput.X - m_mouse_val_x;
int diff_y = event.MouseInput.Y - m_mouse_val_y;
From 2d95df1722359308443322b5472dc272c7fbccee Mon Sep 17 00:00:00 2001
From: Benau
Date: Fri, 12 Aug 2016 00:48:57 +0800
Subject: [PATCH 23/39] Update appdata file to latest standard
---
data/supertuxkart.appdata.xml | 32 +++++++++++++++++++++++---------
1 file changed, 23 insertions(+), 9 deletions(-)
diff --git a/data/supertuxkart.appdata.xml b/data/supertuxkart.appdata.xml
index 412961b51..b331807c8 100644
--- a/data/supertuxkart.appdata.xml
+++ b/data/supertuxkart.appdata.xml
@@ -1,9 +1,9 @@
-
-
- supertuxkart.desktop
+
+ supertuxkart.desktop
CC0-1.0
+ GPL-3.0+
SuperTuxKart
A racing game
@@ -25,11 +25,25 @@
against the computer or your friends, and more!
- http://supertuxkart.net/
- http://supertuxkart.sourceforge.net/persistent/images/4/4e/Supertuxkart-0.9-screenshot-2.jpg
- http://supertuxkart.sourceforge.net/persistent/images/a/a9/Supertuxkart-0.9-screenshot-1.jpg
- http://supertuxkart.sourceforge.net/persistent/images/6/63/Supertuxkart-0.9-screenshot-3.jpg
+
+ https://supertuxkart.net/images/8/83/Supertuxkart-0.9.2-screenshot-3.jpg
+ Normal Race
+
+
+ https://supertuxkart.net/images/1/1f/Supertuxkart-0.9.2-screenshot-1.jpg
+ Battle Mode
+
+
+ https://supertuxkart.net/images/2/2a/Supertuxkart-0.9.2-screenshot-2.jpg
+ Soccer Mode
+
- supertuxkart-devel@lists.sourceforge.net
-
+ SuperTuxKart Team
+ supertuxkart-devel@lists.sourceforge.net
+ https://supertuxkart.net
+ https://github.com/supertuxkart/stk-code/issues
+ https://supertuxkart.net/Donate
+ https://supertuxkart.net/Community
+ https://supertuxkart.net/Translating_STK
+
From aa15b0070e4f955f085a0b1a31862200085aa8fe Mon Sep 17 00:00:00 2001
From: Benau
Date: Fri, 12 Aug 2016 08:31:52 +0800
Subject: [PATCH 24/39] Determine the texture size of bold face smartly
---
src/font/bold_face.cpp | 16 ++++++++++++++++
src/font/bold_face.hpp | 2 +-
src/font/digit_face.cpp | 1 +
src/font/font_with_face.cpp | 10 +++++-----
src/font/regular_face.cpp | 1 +
5 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/src/font/bold_face.cpp b/src/font/bold_face.cpp
index f32aea7b5..5afe7ef5b 100644
--- a/src/font/bold_face.cpp
+++ b/src/font/bold_face.cpp
@@ -18,6 +18,7 @@
#include "font/bold_face.hpp"
+#include "config/user_config.hpp"
#include "font/face_ttf.hpp"
// ----------------------------------------------------------------------------
@@ -37,6 +38,7 @@ void BoldFace::init()
setFallbackFontScale(2.0f);*/
} // init
+
// ----------------------------------------------------------------------------
void BoldFace::reset()
{
@@ -52,3 +54,17 @@ void BoldFace::reset()
insertCharacters(preload_chars.c_str());
updateCharactersList();
} // reset
+
+// ----------------------------------------------------------------------------
+unsigned int BoldFace::getGlyphPageSize() const
+{
+ // If players somehow disable "Use high definition textures", irrlicht will
+ // set the max texture size to 512x512, which means it will resize all
+ // large texture, but it doesn't suitable for font texture, as the
+ // rectangle in spritebank depends on the original texture size, so we test
+ // if m_high_definition_textures is enabled here
+ if ((UserConfigParams::m_high_definition_textures & 0x01) == 0)
+ return 512;
+
+ return 1024;
+} // getGlyphPageSize
diff --git a/src/font/bold_face.hpp b/src/font/bold_face.hpp
index 53ddce8f5..12193141a 100644
--- a/src/font/bold_face.hpp
+++ b/src/font/bold_face.hpp
@@ -28,7 +28,7 @@ class BoldFace : public FontWithFace
private:
virtual bool supportLazyLoadChar() const OVERRIDE { return true; }
// ------------------------------------------------------------------------
- virtual unsigned int getGlyphPageSize() const OVERRIDE { return 1024; }
+ virtual unsigned int getGlyphPageSize() const OVERRIDE;
// ------------------------------------------------------------------------
virtual float getScalingFactorOne() const OVERRIDE { return 0.2f; }
// ------------------------------------------------------------------------
diff --git a/src/font/digit_face.cpp b/src/font/digit_face.cpp
index 7b257fce5..2403c4d6d 100644
--- a/src/font/digit_face.cpp
+++ b/src/font/digit_face.cpp
@@ -33,6 +33,7 @@ void DigitFace::init()
m_font_max_height = m_glyph_max_height + 10;
} // init
+
// ----------------------------------------------------------------------------
void DigitFace::reset()
{
diff --git a/src/font/font_with_face.cpp b/src/font/font_with_face.cpp
index 0e1659ae0..a9befa2ae 100644
--- a/src/font/font_with_face.cpp
+++ b/src/font/font_with_face.cpp
@@ -306,11 +306,11 @@ void FontWithFace::dumpGlyphPage(const std::string& name)
video::IImage* image = irr_driver->getVideoDriver()
->createImageFromData(col_format, size, data, false/*copy mem*/);
- tex->unlock();
- irr_driver->getVideoDriver()->writeImageToFile(image, std::string
- (name + "_" + StringUtils::toString(i) + ".png").c_str());
- image->drop();
- }
+ tex->unlock();
+ irr_driver->getVideoDriver()->writeImageToFile(image, std::string
+ (name + "_" + StringUtils::toString(i) + ".png").c_str());
+ image->drop();
+ }
} // dumpGlyphPage
// ----------------------------------------------------------------------------
diff --git a/src/font/regular_face.cpp b/src/font/regular_face.cpp
index f86a9ffc1..0a5fc500a 100644
--- a/src/font/regular_face.cpp
+++ b/src/font/regular_face.cpp
@@ -33,6 +33,7 @@ void RegularFace::init()
m_font_max_height = m_glyph_max_height + 10;
} // init
+
// ----------------------------------------------------------------------------
void RegularFace::reset()
{
From c71b24f98fb0aa0783da601ca2e86c5c0d425855 Mon Sep 17 00:00:00 2001
From: Benau
Date: Fri, 12 Aug 2016 09:41:08 +0800
Subject: [PATCH 25/39] Correct fixes to #2599
---
src/font/bold_face.cpp | 14 --------------
src/font/bold_face.hpp | 2 +-
src/font/font_with_face.cpp | 27 +++++++++++++++++++++++++++
src/font/font_with_face.hpp | 6 ++----
4 files changed, 30 insertions(+), 19 deletions(-)
diff --git a/src/font/bold_face.cpp b/src/font/bold_face.cpp
index 5afe7ef5b..771e35a26 100644
--- a/src/font/bold_face.cpp
+++ b/src/font/bold_face.cpp
@@ -54,17 +54,3 @@ void BoldFace::reset()
insertCharacters(preload_chars.c_str());
updateCharactersList();
} // reset
-
-// ----------------------------------------------------------------------------
-unsigned int BoldFace::getGlyphPageSize() const
-{
- // If players somehow disable "Use high definition textures", irrlicht will
- // set the max texture size to 512x512, which means it will resize all
- // large texture, but it doesn't suitable for font texture, as the
- // rectangle in spritebank depends on the original texture size, so we test
- // if m_high_definition_textures is enabled here
- if ((UserConfigParams::m_high_definition_textures & 0x01) == 0)
- return 512;
-
- return 1024;
-} // getGlyphPageSize
diff --git a/src/font/bold_face.hpp b/src/font/bold_face.hpp
index 12193141a..53ddce8f5 100644
--- a/src/font/bold_face.hpp
+++ b/src/font/bold_face.hpp
@@ -28,7 +28,7 @@ class BoldFace : public FontWithFace
private:
virtual bool supportLazyLoadChar() const OVERRIDE { return true; }
// ------------------------------------------------------------------------
- virtual unsigned int getGlyphPageSize() const OVERRIDE;
+ virtual unsigned int getGlyphPageSize() const OVERRIDE { return 1024; }
// ------------------------------------------------------------------------
virtual float getScalingFactorOne() const OVERRIDE { return 0.2f; }
// ------------------------------------------------------------------------
diff --git a/src/font/font_with_face.cpp b/src/font/font_with_face.cpp
index a9befa2ae..7dedffbef 100644
--- a/src/font/font_with_face.cpp
+++ b/src/font/font_with_face.cpp
@@ -116,6 +116,13 @@ void FontWithFace::createNewGlyphPage()
m_used_width = 0;
m_used_height = 0;
+ // Font textures can not be resized (besides the impact on quality in
+ // this case, the rectangles in spritebank would become wrong).
+ core::dimension2du old_max_size = irr_driver->getVideoDriver()
+ ->getDriverAttributes().getAttributeAsDimension2d("MAX_TEXTURE_SIZE");
+ irr_driver->getVideoDriver()->getNonConstDriverAttributes()
+ .setAttribute("MAX_TEXTURE_SIZE", core::dimension2du(0, 0));
+
video::ITexture* page_texture = irr_driver->getVideoDriver()
->addTexture("Glyph_page", m_page);
m_spritebank->addTexture(NULL);
@@ -127,6 +134,9 @@ void FontWithFace::createNewGlyphPage()
irr_driver->getVideoDriver()->removeTexture(page_texture);
assert(page_texture->getReferenceCount() == 1);
+ irr_driver->getVideoDriver()->getNonConstDriverAttributes()
+ .setAttribute("MAX_TEXTURE_SIZE", old_max_size);
+
} // createNewGlyphPage
// ----------------------------------------------------------------------------
@@ -172,13 +182,22 @@ void FontWithFace::insertGlyph(wchar_t c, const GlyphInfo& gi)
{
// Current glyph page is full:
// Save the old glyph page
+ core::dimension2du old_max_size = irr_driver->getVideoDriver()
+ ->getDriverAttributes().getAttributeAsDimension2d
+ ("MAX_TEXTURE_SIZE");
+ irr_driver->getVideoDriver()->getNonConstDriverAttributes()
+ .setAttribute("MAX_TEXTURE_SIZE", core::dimension2du(0, 0));
video::ITexture* page_texture = irr_driver->getVideoDriver()
->addTexture("Glyph_page", m_page);
+
m_spritebank->setTexture(m_spritebank->getTextureCount() - 1,
page_texture);
irr_driver->getVideoDriver()->removeTexture(page_texture);
assert(page_texture->getReferenceCount() == 1);
+ irr_driver->getVideoDriver()->getNonConstDriverAttributes()
+ .setAttribute("MAX_TEXTURE_SIZE", old_max_size);
+
// Clear and add a new one
createNewGlyphPage();
}
@@ -283,6 +302,11 @@ void FontWithFace::updateCharactersList()
m_new_char_holder.clear();
// Update last glyph page
+ core::dimension2du old_max_size = irr_driver->getVideoDriver()
+ ->getDriverAttributes().getAttributeAsDimension2d("MAX_TEXTURE_SIZE");
+ irr_driver->getVideoDriver()->getNonConstDriverAttributes()
+ .setAttribute("MAX_TEXTURE_SIZE", core::dimension2du(0, 0));
+
video::ITexture* page_texture = irr_driver->getVideoDriver()
->addTexture("Glyph_page", m_page);
m_spritebank->setTexture(m_spritebank->getTextureCount() - 1,
@@ -291,6 +315,9 @@ void FontWithFace::updateCharactersList()
irr_driver->getVideoDriver()->removeTexture(page_texture);
assert(page_texture->getReferenceCount() == 1);
+ irr_driver->getVideoDriver()->getNonConstDriverAttributes()
+ .setAttribute("MAX_TEXTURE_SIZE", old_max_size);
+
} // updateCharactersList
// ----------------------------------------------------------------------------
diff --git a/src/font/font_with_face.hpp b/src/font/font_with_face.hpp
index e219c9c30..52417a03c 100644
--- a/src/font/font_with_face.hpp
+++ b/src/font/font_with_face.hpp
@@ -109,14 +109,12 @@ private:
FontWithFace* m_fallback_font;
float m_fallback_font_scale;
- /** A temporary holder stored new char to be inserted.
- */
+ /** A temporary holder stored new char to be inserted. */
std::set m_new_char_holder;
gui::IGUISpriteBank* m_spritebank;
- /** A full glyph page for this font.
- */
+ /** A full glyph page for this font. */
video::IImage* m_page;
unsigned int m_temp_height;
From c5446c4cf18ad15ad3a1a996ad25c8dd2f73b366 Mon Sep 17 00:00:00 2001
From: Benau
Date: Fri, 12 Aug 2016 10:41:07 +0800
Subject: [PATCH 26/39] Remove unused header
---
src/font/bold_face.cpp | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/font/bold_face.cpp b/src/font/bold_face.cpp
index 771e35a26..e9192de14 100644
--- a/src/font/bold_face.cpp
+++ b/src/font/bold_face.cpp
@@ -18,7 +18,6 @@
#include "font/bold_face.hpp"
-#include "config/user_config.hpp"
#include "font/face_ttf.hpp"
// ----------------------------------------------------------------------------
From 1481da97186e77462ef5a87b27d25a77de0c3fd3 Mon Sep 17 00:00:00 2001
From: Deve
Date: Fri, 12 Aug 2016 20:41:19 +0200
Subject: [PATCH 27/39] Fixed button icons with non-hd textures and low
MAX_TEXTURE_SIZE parameter
---
lib/irrlicht/source/Irrlicht/CGUIButton.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/irrlicht/source/Irrlicht/CGUIButton.cpp b/lib/irrlicht/source/Irrlicht/CGUIButton.cpp
index 1d17f2651..1a946b282 100644
--- a/lib/irrlicht/source/Irrlicht/CGUIButton.cpp
+++ b/lib/irrlicht/source/Irrlicht/CGUIButton.cpp
@@ -381,7 +381,7 @@ void CGUIButton::setImage(video::ITexture* image)
Image = image;
if (image)
- ImageRect = core::rect(core::position2d(0,0), image->getOriginalSize());
+ ImageRect = core::rect(core::position2d(0,0), image->getSize());
if (!PressedImage)
setPressedImage(Image);
@@ -407,7 +407,7 @@ void CGUIButton::setPressedImage(video::ITexture* image)
PressedImage = image;
if (image)
- PressedImageRect = core::rect(core::position2d(0,0), image->getOriginalSize());
+ PressedImageRect = core::rect(core::position2d(0,0), image->getSize());
}
From d320df749f0d1fa99456fb8c31fb30fce232f28e Mon Sep 17 00:00:00 2001
From: Deve
Date: Fri, 12 Aug 2016 23:30:10 +0200
Subject: [PATCH 28/39] Allow to set max texture size in config file.
It gives much lower memory usage when it's set for example to 128.
---
src/config/user_config.hpp | 6 +++++-
src/graphics/irr_driver.cpp | 4 +++-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/config/user_config.hpp b/src/config/user_config.hpp
index ccde2db71..a8267a858 100644
--- a/src/config/user_config.hpp
+++ b/src/config/user_config.hpp
@@ -492,9 +492,13 @@ namespace UserConfigParams
PARAM_DEFAULT(BoolUserConfigParam(true, "old_driver_popup",
&m_video_group, "Determines if popup message about too old drivers should be displayed."));
PARAM_PREFIX FloatUserConfigParam m_scale_rtts_factor
- PARAM_DEFAULT(FloatUserConfigParam(1.0f, "m_scale_rtts_factor",
+ PARAM_DEFAULT(FloatUserConfigParam(1.0f, "scale_rtts_factor",
&m_video_group, "Allows to increase performance by setting lower RTTs "
"resolution. Value should be smaller or equal to 1.0"));
+ PARAM_PREFIX IntUserConfigParam m_max_texture_size
+ PARAM_DEFAULT(IntUserConfigParam(512, "max_texture_size",
+ &m_video_group, "Max texture size when high definition textures are "
+ "disabled"));
// ---- Debug - not saved to config file
/** If gamepad debugging is enabled. */
diff --git a/src/graphics/irr_driver.cpp b/src/graphics/irr_driver.cpp
index 075efdbe2..6fb6bfd5a 100644
--- a/src/graphics/irr_driver.cpp
+++ b/src/graphics/irr_driver.cpp
@@ -673,7 +673,9 @@ void IrrDriver::setMaxTextureSize()
if( (UserConfigParams::m_high_definition_textures & 0x01) == 0)
{
io::IAttributes &att = m_video_driver->getNonConstDriverAttributes();
- att.setAttribute("MAX_TEXTURE_SIZE", core::dimension2du(512, 512));
+ att.setAttribute("MAX_TEXTURE_SIZE", core::dimension2du(
+ UserConfigParams::m_max_texture_size,
+ UserConfigParams::m_max_texture_size));
}
} // setMaxTextureSize
From 08202f2fa8991d0e4915cb431d504c76f98d3ae6 Mon Sep 17 00:00:00 2001
From: Deve
Date: Fri, 12 Aug 2016 23:39:12 +0200
Subject: [PATCH 29/39] Remove USE_XRANDR flag from cmake.
Our vidmode code is old, has some bugs (eg. resolution is not restored properly in some cases), doesn't have multi monitor support and IMO shouldn't be used in current state.
If someone really wants to use it, the flags can be set directly in IrrCompileConfig.h.
---
CMakeLists.txt | 19 ++++---------------
lib/irrlicht/CMakeLists.txt | 2 +-
2 files changed, 5 insertions(+), 16 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 68ae9962b..ae848ef7a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -41,7 +41,6 @@ else()
endif()
if(UNIX AND NOT APPLE)
- option(USE_XRANDR "Use xrandr instead of vidmode" ON)
option(USE_ASAN "Build with Leak/Address sanitizer" OFF)
option(USE_LIBBFD "Use libbfd for crash reporting and leak check" OFF)
endif()
@@ -215,14 +214,9 @@ if(UNIX AND NOT APPLE)
find_package(X11 REQUIRED)
include_directories(${X11_INCLUDE_DIR})
- if(USE_XRANDR)
- find_package(Xrandr REQUIRED)
- if(NOT XRANDR_FOUND)
- message(FATAL_ERROR "XRANDR not found.")
- endif()
- else()
- find_library(IRRLICHT_XF86VM_LIBRARY Xxf86vm)
- mark_as_advanced(IRRLICHT_XF86VM_LIBRARY)
+ find_package(Xrandr REQUIRED)
+ if(NOT XRANDR_FOUND)
+ message(FATAL_ERROR "XRANDR not found.")
endif()
if(USE_LIBBFD)
@@ -382,12 +376,7 @@ else()
endif()
if(UNIX AND NOT APPLE)
- target_link_libraries(supertuxkart ${X11_LIBRARIES})
- if(USE_XRANDR)
- target_link_libraries(supertuxkart ${XRANDR_LIBRARIES})
- else()
- target_link_libraries(supertuxkart ${IRRLICHT_XF86VM_LIBRARY})
- endif()
+ target_link_libraries(supertuxkart ${X11_LIBRARIES} ${XRANDR_LIBRARIES})
if(USE_LIBBFD)
target_link_libraries(supertuxkart ${LIBBFD_LIBRARIES})
endif()
diff --git a/lib/irrlicht/CMakeLists.txt b/lib/irrlicht/CMakeLists.txt
index 07e72b2ea..2a73d0533 100644
--- a/lib/irrlicht/CMakeLists.txt
+++ b/lib/irrlicht/CMakeLists.txt
@@ -47,7 +47,7 @@ if(USE_GLES2)
endif()
# Xrandr
-if(UNIX AND USE_XRANDR)
+if(UNIX AND NOT APPLE)
add_definitions(-DNO_IRR_LINUX_X11_VIDMODE_)
add_definitions(-D_IRR_LINUX_X11_RANDR_)
endif()
From b23f39f1cde28eb0e762614bfa32c950ed418fce Mon Sep 17 00:00:00 2001
From: Deve
Date: Fri, 12 Aug 2016 23:51:29 +0200
Subject: [PATCH 30/39] Fixed non-hd textures in legacy pipeline
---
lib/irrlicht/source/Irrlicht/COpenGLDriver.cpp | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/irrlicht/source/Irrlicht/COpenGLDriver.cpp b/lib/irrlicht/source/Irrlicht/COpenGLDriver.cpp
index f555477a6..1a1d61350 100644
--- a/lib/irrlicht/source/Irrlicht/COpenGLDriver.cpp
+++ b/lib/irrlicht/source/Irrlicht/COpenGLDriver.cpp
@@ -2006,7 +2006,7 @@ void COpenGLDriver::draw2DImageBatch(const video::ITexture* texture,
const u32 drawCount = core::min_(positions.size(), sourceRects.size());
- const core::dimension2d& ss = texture->getOriginalSize();
+ const core::dimension2d& ss = texture->getSize();
const f32 invW = 1.f / static_cast(ss.Width);
const f32 invH = 1.f / static_cast(ss.Height);
const core::dimension2d& renderTargetSize = getCurrentRenderTargetSize();
@@ -2225,7 +2225,7 @@ void COpenGLDriver::draw2DImage(const video::ITexture* texture,
// ok, we've clipped everything.
// now draw it.
- const core::dimension2d& ss = texture->getOriginalSize();
+ const core::dimension2d& ss = texture->getSize();
const f32 invW = 1.f / static_cast(ss.Width);
const f32 invH = 1.f / static_cast(ss.Height);
const core::rect tcoords(
@@ -2268,7 +2268,7 @@ void COpenGLDriver::draw2DImage(const video::ITexture* texture, const core::rect
if (!texture)
return;
- const core::dimension2d& ss = texture->getOriginalSize();
+ const core::dimension2d& ss = texture->getSize();
const f32 invW = 1.f / static_cast(ss.Width);
const f32 invH = 1.f / static_cast(ss.Height);
const core::rect tcoords(
@@ -2361,7 +2361,7 @@ void COpenGLDriver::draw2DImage(const video::ITexture* texture,
clipRect->getWidth(),clipRect->getHeight());
}
- const core::dimension2d& ss = texture->getOriginalSize();
+ const core::dimension2d& ss = texture->getSize();
core::position2d targetPos(pos);
const f32 invW = 1.f / static_cast(ss.Width);
const f32 invH = 1.f / static_cast(ss.Height);
From 26d2bf847cdfb6100848b7aec7cb55d6933bec6b Mon Sep 17 00:00:00 2001
From: Deve
Date: Sat, 13 Aug 2016 00:01:08 +0200
Subject: [PATCH 31/39] Allow to use non-hd textures in OpenGL ES renderer
---
lib/irrlicht/source/Irrlicht/COGLES2Driver.cpp | 14 +++++++-------
lib/irrlicht/source/Irrlicht/COGLES2Texture.cpp | 13 +++++++++++++
2 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/lib/irrlicht/source/Irrlicht/COGLES2Driver.cpp b/lib/irrlicht/source/Irrlicht/COGLES2Driver.cpp
index e49c275f5..e9b8e7efa 100644
--- a/lib/irrlicht/source/Irrlicht/COGLES2Driver.cpp
+++ b/lib/irrlicht/source/Irrlicht/COGLES2Driver.cpp
@@ -1314,7 +1314,7 @@ namespace video
// texcoords need to be flipped horizontally for RTTs
const bool isRTT = texture->isRenderTarget();
- const core::dimension2d& ss = texture->getOriginalSize();
+ const core::dimension2d& ss = texture->getSize();
const f32 invW = 1.f / static_cast(ss.Width);
const f32 invH = 1.f / static_cast(ss.Height);
const core::rect tcoords(
@@ -1443,10 +1443,10 @@ namespace video
// now draw it.
core::rect tcoords;
- tcoords.UpperLeftCorner.X = (((f32)sourcePos.X)) / texture->getOriginalSize().Width ;
- tcoords.UpperLeftCorner.Y = (((f32)sourcePos.Y)) / texture->getOriginalSize().Height;
- tcoords.LowerRightCorner.X = tcoords.UpperLeftCorner.X + ((f32)(sourceSize.Width) / texture->getOriginalSize().Width);
- tcoords.LowerRightCorner.Y = tcoords.UpperLeftCorner.Y + ((f32)(sourceSize.Height) / texture->getOriginalSize().Height);
+ tcoords.UpperLeftCorner.X = (((f32)sourcePos.X)) / texture->getSize().Width ;
+ tcoords.UpperLeftCorner.Y = (((f32)sourcePos.Y)) / texture->getSize().Height;
+ tcoords.LowerRightCorner.X = tcoords.UpperLeftCorner.X + ((f32)(sourceSize.Width) / texture->getSize().Width);
+ tcoords.LowerRightCorner.Y = tcoords.UpperLeftCorner.Y + ((f32)(sourceSize.Height) / texture->getSize().Height);
const core::rect poss(targetPos, sourceSize);
@@ -1496,7 +1496,7 @@ namespace video
// texcoords need to be flipped horizontally for RTTs
const bool isRTT = texture->isRenderTarget();
- const core::dimension2du& ss = texture->getOriginalSize();
+ const core::dimension2du& ss = texture->getSize();
const f32 invW = 1.f / static_cast(ss.Width);
const f32 invH = 1.f / static_cast(ss.Height);
const core::rect tcoords(
@@ -1573,7 +1573,7 @@ namespace video
clipRect->getWidth(), clipRect->getHeight());
}
- const core::dimension2du& ss = texture->getOriginalSize();
+ const core::dimension2du& ss = texture->getSize();
core::position2d targetPos(pos);
// texcoords need to be flipped horizontally for RTTs
const bool isRTT = texture->isRenderTarget();
diff --git a/lib/irrlicht/source/Irrlicht/COGLES2Texture.cpp b/lib/irrlicht/source/Irrlicht/COGLES2Texture.cpp
index ce09c1ec5..4396d6e09 100644
--- a/lib/irrlicht/source/Irrlicht/COGLES2Texture.cpp
+++ b/lib/irrlicht/source/Irrlicht/COGLES2Texture.cpp
@@ -15,6 +15,8 @@
#include "os.h"
#include "CImage.h"
#include "CColorConverter.h"
+#include "IAttributes.h"
+#include "IrrlichtDevice.h"
#include "irrString.h"
@@ -171,6 +173,17 @@ void COGLES2Texture::getImageValues(IImage* image)
ImageSize.Width = (u32)(Driver->MaxTextureSize*ratio);
}
TextureSize=ImageSize.getOptimalSize(false);
+ const core::dimension2du max_size = Driver->getDriverAttributes()
+ .getAttributeAsDimension2d("MAX_TEXTURE_SIZE");
+
+ if (max_size.Width> 0 && TextureSize.Width > max_size.Width)
+ {
+ TextureSize.Width = max_size.Width;
+ }
+ if (max_size.Height> 0 && TextureSize.Height > max_size.Height)
+ {
+ TextureSize.Height = max_size.Height;
+ }
ColorFormat = getBestColorFormat(image->getColorFormat());
}
From bd6ad544cc7d81c65f47416a4205bb7c1975b846 Mon Sep 17 00:00:00 2001
From: Deve
Date: Mon, 15 Aug 2016 08:46:02 +0200
Subject: [PATCH 32/39] Fixed bloom with scale_rtts_factor parameter.
---
data/shaders/bloom.frag | 3 ++-
src/graphics/post_processing.cpp | 6 +++---
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/data/shaders/bloom.frag b/data/shaders/bloom.frag
index 78bfbf965..a94402950 100644
--- a/data/shaders/bloom.frag
+++ b/data/shaders/bloom.frag
@@ -1,4 +1,5 @@
uniform sampler2D tex;
+uniform float scale;
out vec4 FragColor;
@@ -7,7 +8,7 @@ out vec4 FragColor;
void main()
{
- vec2 uv = gl_FragCoord.xy / 512.;
+ vec2 uv = gl_FragCoord.xy / (512. * scale);
vec3 col = texture(tex, uv).xyz;
vec3 Yxy = getCIEYxy(col);
vec3 WhiteYxy = getCIEYxy(vec3(1.));
diff --git a/src/graphics/post_processing.cpp b/src/graphics/post_processing.cpp
index 593565767..d68fc4a21 100644
--- a/src/graphics/post_processing.cpp
+++ b/src/graphics/post_processing.cpp
@@ -327,21 +327,21 @@ public:
}; // ComputeGaussian17TapVShader
// ============================================================================
-class BloomShader : public TextureShader
+class BloomShader : public TextureShader
{
public:
BloomShader()
{
loadProgram(OBJECT, GL_VERTEX_SHADER, "screenquad.vert",
GL_FRAGMENT_SHADER, "bloom.frag");
- assignUniforms();
+ assignUniforms("scale");
assignSamplerNames(0, "tex", ST_NEAREST_FILTERED);
} // BloomShader
// ------------------------------------------------------------------------
void render(GLuint in)
{
BloomShader::getInstance()->setTextureUnits(in);
- drawFullScreenEffect();
+ drawFullScreenEffect(UserConfigParams::m_scale_rtts_factor);
} // render
}; // BloomShader
From 63a82c915c1349544ac47fb7e8d0c41e9b87fd4b Mon Sep 17 00:00:00 2001
From: "auria.mg"
Date: Mon, 15 Aug 2016 20:33:06 -0400
Subject: [PATCH 33/39] Bugfix: prevent activating disabled ribbon items
---
src/guiengine/event_handler.cpp | 3 ++-
src/guiengine/widget.hpp | 2 ++
src/guiengine/widgets/ribbon_widget.cpp | 20 ++++++++++++++++++++
src/guiengine/widgets/ribbon_widget.hpp | 3 +++
4 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/src/guiengine/event_handler.cpp b/src/guiengine/event_handler.cpp
index 58b316b7b..2dc5357cd 100644
--- a/src/guiengine/event_handler.cpp
+++ b/src/guiengine/event_handler.cpp
@@ -532,7 +532,8 @@ void EventHandler::sendEventToUser(GUIEngine::Widget* widget, std::string& name,
EventPropagation EventHandler::onWidgetActivated(GUIEngine::Widget* w, const int playerID)
{
- if (!w->isActivated()) return EVENT_BLOCK;
+ if (w->onActivationInput(playerID) == EVENT_BLOCK)
+ return EVENT_BLOCK;
Widget* parent = w->m_event_handler;
diff --git a/src/guiengine/widget.hpp b/src/guiengine/widget.hpp
index 4e9118112..16fab6c04 100644
--- a/src/guiengine/widget.hpp
+++ b/src/guiengine/widget.hpp
@@ -332,6 +332,8 @@ namespace GUIEngine
bool isActivated() const;
+ virtual EventPropagation onActivationInput(const int playerID) { return EVENT_LET; }
+
/**
* Call to resize/move the widget. Not all widgets can resize gracefully.
*/
diff --git a/src/guiengine/widgets/ribbon_widget.cpp b/src/guiengine/widgets/ribbon_widget.cpp
index a986707d1..cb991d440 100644
--- a/src/guiengine/widgets/ribbon_widget.cpp
+++ b/src/guiengine/widgets/ribbon_widget.cpp
@@ -666,6 +666,26 @@ void RibbonWidget::updateSelection()
if (m_listener) m_listener->onSelectionChange();
} // updateSelection
+// ----------------------------------------------------------------------------
+EventPropagation RibbonWidget::onActivationInput(const int playerID)
+{
+ assert(m_magic_number == 0xCAFEC001);
+
+ if (m_deactivated)
+ return EVENT_BLOCK;
+
+ if (m_selection[playerID] > -1 &&
+ m_selection[playerID] < (int)(m_active_children.size()))
+ {
+ if (m_active_children[m_selection[playerID]].m_deactivated)
+ {
+ return EVENT_BLOCK;
+ }
+ }
+
+ return EVENT_LET;
+}
+
// ----------------------------------------------------------------------------
EventPropagation RibbonWidget::transmitEvent(Widget* w,
const std::string& originator,
diff --git a/src/guiengine/widgets/ribbon_widget.hpp b/src/guiengine/widgets/ribbon_widget.hpp
index 5960568fb..9a9e76875 100644
--- a/src/guiengine/widgets/ribbon_widget.hpp
+++ b/src/guiengine/widgets/ribbon_widget.hpp
@@ -24,6 +24,7 @@
#include "guiengine/widget.hpp"
#include "guiengine/widgets/icon_button_widget.hpp"
+#include "utils/cpp2011.hpp"
#include "utils/leak_check.hpp"
#include "utils/ptr_vector.hpp"
@@ -192,6 +193,8 @@ namespace GUIEngine
void removeChildNamed(const char* name);
PtrVector& getRibbonChildren() { return m_children; }
+
+ virtual EventPropagation onActivationInput(const int playerID) OVERRIDE;
};
}
From 489c34edbf157186cb5126ac70ec327a2ad3663f Mon Sep 17 00:00:00 2001
From: Deve
Date: Tue, 16 Aug 2016 23:59:16 +0200
Subject: [PATCH 34/39] Fixed minimap with scale_rtts_factor parameter
---
src/states_screens/race_gui.cpp | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/states_screens/race_gui.cpp b/src/states_screens/race_gui.cpp
index ed93231dc..930fe6ad2 100644
--- a/src/states_screens/race_gui.cpp
+++ b/src/states_screens/race_gui.cpp
@@ -373,6 +373,7 @@ void RaceGUI::drawGlobalMiniMap()
const Vec3& xyz = kart->getXYZ();
Vec3 draw_at;
world->getTrack()->mapPoint2MiniMap(xyz, &draw_at);
+ draw_at *= UserConfigParams::m_scale_rtts_factor;
video::ITexture* icon = kart->getKartProperties()->getMinimapIcon();
@@ -393,6 +394,7 @@ void RaceGUI::drawGlobalMiniMap()
{
Vec3 draw_at;
world->getTrack()->mapPoint2MiniMap(sw->getBallPosition(), &draw_at);
+ draw_at *= UserConfigParams::m_scale_rtts_factor;
video::ITexture* icon =
irr_driver->getTexture(FileManager::GUI, "soccer_ball_normal.png");
From d213bef9dbf7f0cd84d6f471046fbb546571d5c3 Mon Sep 17 00:00:00 2001
From: Michael Murphey
Date: Tue, 16 Aug 2016 18:08:45 -0500
Subject: [PATCH 35/39] Place buttons in confirm dialog horizontally (#2573)
* Place buttons in confirm dialog horizontally closes #2548
* Use RibbonWidget for MessageDialog
* Use buttonbar for confirm dialog
---
data/gui/confirm_dialog.stkgui | 12 ++++++----
src/states_screens/dialogs/message_dialog.cpp | 24 +++++++++----------
2 files changed, 20 insertions(+), 16 deletions(-)
diff --git a/data/gui/confirm_dialog.stkgui b/data/gui/confirm_dialog.stkgui
index b1f57e61d..70334d1d1 100644
--- a/data/gui/confirm_dialog.stkgui
+++ b/data/gui/confirm_dialog.stkgui
@@ -1,15 +1,19 @@
-
+
-
+
-
+
-
+
+
+
diff --git a/src/states_screens/dialogs/message_dialog.cpp b/src/states_screens/dialogs/message_dialog.cpp
index 998788635..06c27dfdf 100644
--- a/src/states_screens/dialogs/message_dialog.cpp
+++ b/src/states_screens/dialogs/message_dialog.cpp
@@ -17,10 +17,8 @@
#include "states_screens/dialogs/message_dialog.hpp"
-#include "guiengine/engine.hpp"
-#include "guiengine/screen.hpp"
-#include "guiengine/widgets/button_widget.hpp"
#include "guiengine/widgets/label_widget.hpp"
+#include "guiengine/widgets/ribbon_widget.hpp"
#include "modes/world.hpp"
#include "states_screens/state_manager.hpp"
#include "utils/translation.hpp"
@@ -97,7 +95,7 @@ void MessageDialog::doInit(bool from_queue)
MessageDialog::~MessageDialog()
{
- if (m_own_listener) delete m_listener;
+ if (m_own_listener) delete m_listener;
m_listener = NULL;
if (StateManager::get()->getGameState() == GUIEngine::GAME)
@@ -111,28 +109,29 @@ void MessageDialog::loadedFromFile()
{
LabelWidget* message = getWidget("title");
message->setText( m_msg, false );
+ RibbonWidget* ribbon = getWidget("buttons");
+ ribbon->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
// If the dialog is a simple 'OK' dialog, then hide the "Yes" button and
// change "Cancel" to "OK"
if (m_type == MessageDialog::MESSAGE_DIALOG_OK)
{
- ButtonWidget* yesbtn = getWidget("confirm");
+ IconButtonWidget* yesbtn = getWidget("cancel");
yesbtn->setVisible(false);
- ButtonWidget* cancelbtn = getWidget("cancel");
+ IconButtonWidget* cancelbtn = getWidget("confirm");
cancelbtn->setText(_("OK"));
cancelbtn->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
}
else if (m_type == MessageDialog::MESSAGE_DIALOG_YESNO)
{
- ButtonWidget* cancelbtn = getWidget("cancel");
+ IconButtonWidget* cancelbtn = getWidget("cancel");
cancelbtn->setText(_("No"));
-
}
else if (m_type == MessageDialog::MESSAGE_DIALOG_OK_CANCEL)
{
// In case of a OK_CANCEL dialog, change the text from 'Yes' to 'Ok'
- ButtonWidget* yesbtn = getWidget("confirm");
+ IconButtonWidget* yesbtn = getWidget("confirm");
yesbtn->setText(_("OK"));
}
}
@@ -147,8 +146,9 @@ void MessageDialog::onEnterPressedInternal()
GUIEngine::EventPropagation MessageDialog::processEvent(const std::string& eventSource)
{
-
- if (eventSource == "cancel")
+ RibbonWidget* ribbon = getWidget(eventSource.c_str());
+
+ if (ribbon->getSelectionIDString(PLAYER_ID_GAME_MASTER) == "cancel")
{
if (m_listener == NULL)
{
@@ -161,7 +161,7 @@ GUIEngine::EventPropagation MessageDialog::processEvent(const std::string& event
return GUIEngine::EVENT_BLOCK;
}
- else if (eventSource == "confirm")
+ else if (ribbon->getSelectionIDString(PLAYER_ID_GAME_MASTER) == "confirm")
{
if (m_listener == NULL)
{
From f07452842df7b4efe05151d69a10e73682adb1e0 Mon Sep 17 00:00:00 2001
From: Benau
Date: Wed, 17 Aug 2016 11:57:18 +0800
Subject: [PATCH 36/39] Add support for colorizing library objects using
material.xml only
---
src/graphics/material.cpp | 1 +
src/graphics/material.hpp | 20 +++++++++++-
src/graphics/render_info.cpp | 15 ++++++++-
src/graphics/render_info.hpp | 25 ++++++++++++---
src/graphics/stk_animated_mesh.cpp | 40 ++++++++++++++++++------
src/graphics/stk_animated_mesh.hpp | 1 +
src/graphics/stk_mesh_scene_node.cpp | 38 +++++++++++++++++-----
src/graphics/stk_mesh_scene_node.hpp | 1 +
src/scriptengine/script_challenges.cpp | 1 -
src/tracks/track.cpp | 12 +++----
src/tracks/track.hpp | 4 +--
src/tracks/track_object.cpp | 37 +++++++++++++++++++---
src/tracks/track_object.hpp | 12 +++----
src/tracks/track_object_manager.cpp | 5 ++-
src/tracks/track_object_manager.hpp | 5 ++-
src/tracks/track_object_presentation.cpp | 9 +-----
src/tracks/track_object_presentation.hpp | 1 -
17 files changed, 167 insertions(+), 60 deletions(-)
diff --git a/src/graphics/material.cpp b/src/graphics/material.cpp
index fc2c37379..98a4d705b 100644
--- a/src/graphics/material.cpp
+++ b/src/graphics/material.cpp
@@ -143,6 +143,7 @@ Material::Material(const XMLNode *node, bool deprecated)
node->get("disable-z-write", &m_disable_z_write );
node->get("colorizable", &m_colorizable );
node->get("colorization-factor", &m_colorization_factor);
+ node->get("hue-settings", &m_hue_settings );
node->get("fog", &m_fog );
node->get("mask", &m_mask );
diff --git a/src/graphics/material.hpp b/src/graphics/material.hpp
index d5cc5c39d..910e60c12 100644
--- a/src/graphics/material.hpp
+++ b/src/graphics/material.hpp
@@ -21,6 +21,7 @@
#define HEADER_MATERIAL_HPP
#include "utils/no_copy.hpp"
+#include "utils/random_generator.hpp"
#include
#include