Merge branch 'master' of https://github.com/supertuxkart/stk-code
This commit is contained in:
@@ -14,5 +14,5 @@ void main()
|
||||
|
||||
Yxy.x = smoothstep(WhiteYxy.x, WhiteYxy.x * 4, Yxy.x);
|
||||
|
||||
FragColor = vec4(getRGBFromCIEXxy(Yxy), 1.0);
|
||||
FragColor = vec4(max(vec3(0.), getRGBFromCIEXxy(Yxy)), 1.0);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ uniform mat4 RSMMatrix;
|
||||
uniform sampler2D dtex;
|
||||
uniform sampler2D ctex;
|
||||
uniform sampler2D ntex;
|
||||
uniform vec3 suncol;
|
||||
|
||||
flat in int slice;
|
||||
layout (location = 0) out vec4 SHRed;
|
||||
@@ -63,7 +64,7 @@ void loop(in int i,
|
||||
float dotprod = max(dot(RSM_to_RH_dir, normal.xyz), 0.);
|
||||
float factor = dotprod / (0.1 + dist * dist);
|
||||
|
||||
vec3 color = RSMAlbedo.rgb * factor;
|
||||
vec3 color = RSMAlbedo.rgb * factor * suncol.rgb;
|
||||
|
||||
SHr += DirToSh(RSM_to_RH_dir, color.r);
|
||||
SHg += DirToSh(RSM_to_RH_dir, color.g);
|
||||
|
||||
@@ -23,15 +23,26 @@
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "online/http_request.hpp"
|
||||
#include "utils/random_generator.hpp"
|
||||
#include "utils/string_utils.hpp"
|
||||
|
||||
#ifdef __APPLE__
|
||||
# include <sys/sysctl.h>
|
||||
#endif
|
||||
|
||||
#include <fstream>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace HardwareStats
|
||||
{
|
||||
|
||||
namespace Private
|
||||
{
|
||||
/** Stores the OS version, e.g. "Windows 7", or "Fedora 21". */
|
||||
static std::string m_os_version;
|
||||
} // namespace Private
|
||||
using namespace Private;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Returns the amount of RAM in MB.
|
||||
@@ -102,6 +113,106 @@ int getNumProcessors()
|
||||
return 0;
|
||||
} // getNumProcessors
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Tries opening and parsing the specified release file in /etc to find
|
||||
* information about the distro used.
|
||||
* \param filename Full path of the file to open.
|
||||
* \return True if file could be read and valid information was paresed,
|
||||
* false otherwise.
|
||||
*/
|
||||
bool readEtcReleaseFile(const std::string &filename)
|
||||
{
|
||||
std::ifstream in(filename);
|
||||
std::string s, distro, version;
|
||||
while( (distro.empty() || version.empty()) &&
|
||||
std::getline(in, s) )
|
||||
{
|
||||
std::vector<std::string> l = StringUtils::split(s, '=');
|
||||
if(l.size()==0) continue;
|
||||
if (l[0]=="NAME" ) distro = l[1];
|
||||
else if(l[0]=="VERSION_ID") version = l[1];
|
||||
}
|
||||
if(!distro.empty() && !version.empty())
|
||||
{
|
||||
distro = StringUtils::replace(distro, "\"", "");
|
||||
version = StringUtils::replace(version, "\"", "");
|
||||
m_os_version = distro + " " + version;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} // readEtcReleaseFile
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Identify more details about the OS, e.g. on linux which distro
|
||||
* and which verison; on windows the version number.
|
||||
* \param json Json data structure to store the os info in.
|
||||
*/
|
||||
void determineOSVersion()
|
||||
{
|
||||
std::string version, distro;
|
||||
|
||||
#ifdef __linux__
|
||||
// First try the standard /etc/os-release. Then check for older versions
|
||||
// e.g. /etc/fedora-release, /etc/SuSE-release, /etc/redhat-release
|
||||
if(readEtcReleaseFile("/etc/os-release")) return;
|
||||
|
||||
std::set<std::string> file_list;
|
||||
file_manager->listFiles(file_list, "./", true);
|
||||
for(std::set<std::string>::iterator i = file_list.begin();
|
||||
i != file_list.end(); i++)
|
||||
{
|
||||
// Only try reading /etc/*-release files
|
||||
if(StringUtils::hasSuffix(*i, "-release"))
|
||||
if (readEtcReleaseFile(*i)) return;
|
||||
}
|
||||
#endif
|
||||
#ifdef WIN32
|
||||
// (C) 2014 by Wildfire Games (0 A.D.), ported by Joerg Henrichs.
|
||||
|
||||
HKEY hKey;
|
||||
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
|
||||
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0,
|
||||
KEY_QUERY_VALUE, &hKey) != ERROR_SUCCESS)
|
||||
{
|
||||
m_os_version = "windows-unknown";
|
||||
return;
|
||||
}
|
||||
char windows_version_string[20];
|
||||
DWORD size = sizeof(windows_version_string);
|
||||
RegQueryValueEx(hKey, "CurrentVersion", 0, 0, (LPBYTE)windows_version_string, &size);
|
||||
unsigned major = 0, minor = 0;
|
||||
const int ret = sscanf_s(windows_version_string, "%u.%u", &major, &minor);
|
||||
int windows_version = (major << 8) | minor;
|
||||
RegCloseKey(hKey);
|
||||
|
||||
switch(windows_version)
|
||||
{
|
||||
case 0x0500: m_os_version="Windows 2000"; break;
|
||||
case 0x0501: m_os_version="Windows XP"; break;
|
||||
case 0x0502: m_os_version="Windows XP64"; break;
|
||||
case 0x0600: m_os_version="Windows Vista"; break;
|
||||
case 0x0601: m_os_version="Windows 7"; break;
|
||||
case 0x0602: m_os_version="Windows 8"; break;
|
||||
default: {
|
||||
m_os_version = StringUtils::insertValues("Windows %d",
|
||||
windows_version);
|
||||
break;
|
||||
}
|
||||
} // switch
|
||||
|
||||
#endif
|
||||
} // determineOSVersion
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Returns the OS version, e.g.: "Windows 7", or "Fedora 21".
|
||||
*/
|
||||
const std::string& getOSVersion()
|
||||
{
|
||||
if(m_os_version.empty())
|
||||
determineOSVersion();
|
||||
return m_os_version;
|
||||
} // getOSVersion
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** If the configuration of this installation has not been reported for the
|
||||
* current version, collect the hardware statistics and send it to STK's
|
||||
@@ -144,6 +255,8 @@ void reportHardwareStats()
|
||||
json.add("build_debug", 1);
|
||||
#endif
|
||||
|
||||
json.add("os_version", getOSVersion());
|
||||
|
||||
unsigned int ogl_version = irr_driver->getGLSLVersion();
|
||||
unsigned int major = ogl_version/100;
|
||||
unsigned int minor = ogl_version - 100*major;
|
||||
@@ -195,7 +308,7 @@ void reportHardwareStats()
|
||||
int m_version;
|
||||
public:
|
||||
HWReportRequest(int version) : Online::HTTPRequest(/*manage memory*/true, 1)
|
||||
,m_version(version)
|
||||
, m_version(version)
|
||||
{}
|
||||
// --------------------------------------------------------------------
|
||||
/** Callback after the request has been executed.
|
||||
|
||||
@@ -25,11 +25,14 @@
|
||||
|
||||
#include "utils/no_copy.hpp"
|
||||
#include "utils/string_utils.hpp"
|
||||
|
||||
namespace HardwareStats
|
||||
{
|
||||
/** A class to manage json data. */
|
||||
class Json : public NoCopy
|
||||
{
|
||||
private:
|
||||
/** The accumulated json data. */
|
||||
std::string m_data;
|
||||
public:
|
||||
/** Constructor. */
|
||||
@@ -78,6 +81,7 @@ namespace HardwareStats
|
||||
|
||||
// ========================================================================
|
||||
void reportHardwareStats();
|
||||
const std::string& getOSVersion();
|
||||
}; // HardwareStats
|
||||
|
||||
#endif
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "modes/world.hpp"
|
||||
#include "tracks/track.hpp"
|
||||
#include "utils/profiler.hpp"
|
||||
#include "callbacks.hpp"
|
||||
|
||||
#define MAX2(a, b) ((a) > (b) ? (a) : (b))
|
||||
#define MIN2(a, b) ((a) > (b) ? (b) : (a))
|
||||
@@ -114,6 +115,7 @@ void IrrDriver::renderLights(unsigned pointlightcount, bool hasShadow)
|
||||
glDisable(GL_BLEND);
|
||||
m_rtts->getRH().Bind();
|
||||
glBindVertexArray(SharedObject::FullScreenQuadVAO);
|
||||
SunLightProvider * const cb = (SunLightProvider *)irr_driver->getCallback(ES_SUNLIGHT);
|
||||
if (irr_driver->needRHWorkaround())
|
||||
{
|
||||
glUseProgram(FullScreenShader::NVWorkaroundRadianceHintsConstructionShader::getInstance()->Program);
|
||||
@@ -121,7 +123,7 @@ void IrrDriver::renderLights(unsigned pointlightcount, bool hasShadow)
|
||||
createVector<GLuint>(m_rtts->getRSM().getRTT()[0], m_rtts->getRSM().getRTT()[1], m_rtts->getRSM().getDepthTexture()));
|
||||
for (unsigned i = 0; i < 32; i++)
|
||||
{
|
||||
FullScreenShader::NVWorkaroundRadianceHintsConstructionShader::getInstance()->setUniforms(rsm_matrix, rh_matrix, rh_extend, i);
|
||||
FullScreenShader::NVWorkaroundRadianceHintsConstructionShader::getInstance()->setUniforms(rsm_matrix, rh_matrix, rh_extend, i, video::SColorf(cb->getRed(), cb->getGreen(), cb->getBlue()));
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
}
|
||||
@@ -135,7 +137,7 @@ void IrrDriver::renderLights(unsigned pointlightcount, bool hasShadow)
|
||||
m_rtts->getRSM().getDepthTexture()
|
||||
)
|
||||
);
|
||||
FullScreenShader::RadianceHintsConstructionShader::getInstance()->setUniforms(rsm_matrix, rh_matrix, rh_extend);
|
||||
FullScreenShader::RadianceHintsConstructionShader::getInstance()->setUniforms(rsm_matrix, rh_matrix, rh_extend, video::SColorf(cb->getRed(), cb->getGreen(), cb->getBlue()));
|
||||
glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, 32);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1496,7 +1496,7 @@ namespace FullScreenShader
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/rh.frag").c_str());
|
||||
}
|
||||
|
||||
AssignUniforms("RSMMatrix", "RHMatrix", "extents");
|
||||
AssignUniforms("RSMMatrix", "RHMatrix", "extents", "suncol");
|
||||
AssignSamplerNames(Program, 0, "ctex", 1, "ntex", 2, "dtex");
|
||||
}
|
||||
|
||||
@@ -1507,7 +1507,7 @@ namespace FullScreenShader
|
||||
GL_GEOMETRY_SHADER, file_manager->getAsset("shaders/rhpassthrough.geom").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/rh.frag").c_str());
|
||||
|
||||
AssignUniforms("RSMMatrix", "RHMatrix", "extents", "slice");
|
||||
AssignUniforms("RSMMatrix", "RHMatrix", "extents", "slice", "suncol");
|
||||
|
||||
AssignSamplerNames(Program, 0, "ctex", 1, "ntex", 2, "dtex");
|
||||
}
|
||||
|
||||
@@ -407,14 +407,14 @@ public:
|
||||
ShadowedSunLightShader();
|
||||
};
|
||||
|
||||
class RadianceHintsConstructionShader : public ShaderHelperSingleton<RadianceHintsConstructionShader, core::matrix4, core::matrix4, core::vector3df>, public TextureRead<Bilinear_Filtered, Bilinear_Filtered, Bilinear_Filtered>
|
||||
class RadianceHintsConstructionShader : public ShaderHelperSingleton<RadianceHintsConstructionShader, core::matrix4, core::matrix4, core::vector3df, video::SColorf>, public TextureRead<Bilinear_Filtered, Bilinear_Filtered, Bilinear_Filtered>
|
||||
{
|
||||
public:
|
||||
RadianceHintsConstructionShader();
|
||||
};
|
||||
|
||||
// Workaround for a bug found in kepler nvidia linux and fermi nvidia windows
|
||||
class NVWorkaroundRadianceHintsConstructionShader : public ShaderHelperSingleton<NVWorkaroundRadianceHintsConstructionShader, core::matrix4, core::matrix4, core::vector3df, int>, public TextureRead<Bilinear_Filtered, Bilinear_Filtered, Bilinear_Filtered>
|
||||
class NVWorkaroundRadianceHintsConstructionShader : public ShaderHelperSingleton<NVWorkaroundRadianceHintsConstructionShader, core::matrix4, core::matrix4, core::vector3df, int, video::SColorf>, public TextureRead<Bilinear_Filtered, Bilinear_Filtered, Bilinear_Filtered>
|
||||
{
|
||||
public:
|
||||
NVWorkaroundRadianceHintsConstructionShader();
|
||||
|
||||
@@ -325,7 +325,8 @@ void STKMeshSceneNode::render()
|
||||
irr_driver->getRenderTargetTexture(RTT_DIFFUSE),
|
||||
irr_driver->getRenderTargetTexture(RTT_SPECULAR),
|
||||
irr_driver->getRenderTargetTexture(RTT_HALF1_R),
|
||||
getTextureGLuint(mesh.textures[0])));
|
||||
getTextureGLuint(mesh.textures[0]),
|
||||
getTextureGLuint(mesh.textures[1])));
|
||||
MeshShader::ObjectPass2Shader::getInstance()->setUniforms(AbsoluteTransformation, mesh.TextureMatrix);
|
||||
assert(mesh.vao);
|
||||
glBindVertexArray(mesh.vao);
|
||||
|
||||
@@ -37,6 +37,7 @@ DynamicRibbonWidget::DynamicRibbonWidget(const bool combo, const bool multi_row)
|
||||
m_needed_cols = 0;
|
||||
m_col_amount = 0;
|
||||
m_previous_item_count = 0;
|
||||
m_max_label_length = 0;
|
||||
m_multi_row = multi_row;
|
||||
m_combo = combo;
|
||||
m_has_label = false;
|
||||
@@ -1158,8 +1159,8 @@ float DynamicRibbonWidget::getFontScale(int icon_width) const
|
||||
|
||||
irr::core::stringw DynamicRibbonWidget::getUserName(const irr::core::stringw& user_name) const
|
||||
{
|
||||
if (user_name.size() < MAX_LABEL_LENGTH)
|
||||
if (m_max_label_length == 0 || user_name.size() < m_max_label_length)
|
||||
return user_name;
|
||||
else
|
||||
return (user_name.subString(0, MAX_LABEL_LENGTH - 3) + L"...");
|
||||
return (user_name.subString(0, m_max_label_length - 3) + L"...");
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ namespace GUIEngine
|
||||
int m_max_label_width;
|
||||
|
||||
/** Max length of a label, in characters */
|
||||
static const int MAX_LABEL_LENGTH = 30;
|
||||
int m_max_label_length;
|
||||
|
||||
public:
|
||||
|
||||
@@ -298,6 +298,9 @@ namespace GUIEngine
|
||||
/** Set approximately how many items are expected to be in this ribbon; will help the layout
|
||||
* algorithm next time add() is called */
|
||||
void setItemCountHint(int hint) { m_item_count_hint = hint; }
|
||||
|
||||
/** Set max length of displayed text. */
|
||||
void setMaxLabelLength(int length) { m_max_label_length = length; }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -141,14 +141,8 @@ void RibbonWidget::add()
|
||||
total_needed_space += m_active_children[i].m_w;
|
||||
}
|
||||
|
||||
int free_w_space = m_w - total_needed_space;
|
||||
|
||||
//int biggest_y = 0;
|
||||
const int button_y = 10;
|
||||
float global_zoom = 1;
|
||||
|
||||
const int min_free_space = 50;
|
||||
global_zoom = (float)m_w / (float)( m_w - free_w_space + min_free_space );
|
||||
|
||||
const int one_button_space =
|
||||
int(roundf((float)m_w / (float)subbuttons_amount));
|
||||
@@ -320,22 +314,10 @@ void RibbonWidget::add()
|
||||
|
||||
float image_h = (float)image->getSize().Height;
|
||||
float image_w = image_h*imageRatio;
|
||||
|
||||
// scale to fit (FIXME: calculate the right value directly...)
|
||||
float zoom = global_zoom;
|
||||
|
||||
if (button_y + image_h*zoom + needed_space_under_button > m_h)
|
||||
{
|
||||
// scale down
|
||||
while (button_y + image_h*zoom +
|
||||
needed_space_under_button > m_h) zoom -= 0.01f;
|
||||
}
|
||||
else
|
||||
{
|
||||
// scale up
|
||||
while (button_y + image_h*zoom +
|
||||
needed_space_under_button < m_h) zoom += 0.01f;
|
||||
}
|
||||
float zoom = (float) (m_h - button_y - needed_space_under_button) / image_h;
|
||||
float zoom_x = (float) one_button_space / image_w;
|
||||
if(zoom_x < zoom)
|
||||
zoom = zoom_x;
|
||||
|
||||
// ---- add bitmap button part
|
||||
// backup and restore position in case the same object is added
|
||||
|
||||
@@ -125,6 +125,10 @@ public:
|
||||
/** Returns true if the achievements for this profile have been fetched. */
|
||||
bool hasFetchedAchievements() const { return m_has_fetched_achievements; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Unsets the flag that all friends of this profile are in cache. Used
|
||||
* when a profile is pushed out of cache. */
|
||||
void unsetHasFetchedFriends() { m_has_fetched_friends = false; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns true if the friend list for this profile has been fetched. */
|
||||
bool hasFetchedFriends() const { return m_has_fetched_friends; }
|
||||
|
||||
@@ -38,7 +38,7 @@ ProfileManager* ProfileManager::m_profile_manager = NULL;
|
||||
*/
|
||||
ProfileManager::ProfileManager()
|
||||
{
|
||||
m_max_cache_size = 2;
|
||||
m_max_cache_size = 100;
|
||||
m_currently_visiting = NULL;
|
||||
} // ProfileManager
|
||||
|
||||
@@ -131,6 +131,7 @@ void ProfileManager::addDirectToCache(OnlineProfile* profile)
|
||||
{
|
||||
if (!iter->second->getCacheBit())
|
||||
{
|
||||
updateAllFriendFlags(iter->second);
|
||||
delete iter->second;
|
||||
iter = m_profiles_cache.erase(iter);
|
||||
// Keep on deleting till enough space is available.
|
||||
@@ -163,6 +164,44 @@ bool ProfileManager::isInCache(const uint32_t id)
|
||||
return false;
|
||||
} // isInCache
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** This function is called when the specified profile id is removed from
|
||||
* cache. It will search all currently cached profiles that have the
|
||||
* 'friends fetched' flag set, and reset that flag if the profile id is
|
||||
* one of their friends. This fixes the problem that friend lists can
|
||||
* get shortened if some of their friends are being pushed out of
|
||||
* cache.
|
||||
*/
|
||||
void ProfileManager::updateFriendFlagsInCache(const ProfilesMap &cache,
|
||||
uint32_t profile_id)
|
||||
{
|
||||
ProfilesMap::const_iterator i;
|
||||
for(i=cache.begin(); i!=cache.end(); i++)
|
||||
{
|
||||
// Profile has no friends fetched, no need to test
|
||||
if(!(*i).second->hasFetchedFriends()) continue;
|
||||
const OnlineProfile::IDList &friend_list = (*i).second->getFriends();
|
||||
OnlineProfile::IDList::const_iterator frnd;
|
||||
frnd = std::find(friend_list.begin(), friend_list.end(), profile_id);
|
||||
if(frnd!=friend_list.end())
|
||||
(*i).second->unsetHasFetchedFriends();
|
||||
}
|
||||
} // updateFriendFlagsInCache
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** This function is called when the specified profile is removed from
|
||||
* cache. It searches through all caches for profiles X, that have the
|
||||
* given profile as friend, and then reset the 'friends fetched' flag
|
||||
* in profile X. Otherwise if a profile is pushed out of the cache,
|
||||
* all friends of this profile in cache will have an incomplete list
|
||||
* of friends.
|
||||
*/
|
||||
void ProfileManager::updateAllFriendFlags(const OnlineProfile *profile)
|
||||
{
|
||||
updateFriendFlagsInCache(m_profiles_persistent, profile->getID());
|
||||
updateFriendFlagsInCache(m_profiles_cache, profile->getID());
|
||||
} // updateAllFriendFlags
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** This function updates the cache bits of all cached entries. It will
|
||||
* set the cache bit of the given profile. Then, if the cachen is full
|
||||
|
||||
@@ -70,9 +70,11 @@ private:
|
||||
* loaded, to make sure they can be all stored). */
|
||||
unsigned int m_max_cache_size;
|
||||
|
||||
void updateCacheBits(OnlineProfile * profile);
|
||||
void addDirectToCache(OnlineProfile * profile);
|
||||
|
||||
void updateCacheBits(OnlineProfile *profile);
|
||||
void addDirectToCache(OnlineProfile *profile);
|
||||
void updateFriendFlagsInCache(const ProfilesMap &cache,
|
||||
uint32_t profile_id);
|
||||
void updateAllFriendFlags(const OnlineProfile *profile);
|
||||
public:
|
||||
/** Create the singleton instance. */
|
||||
static void create()
|
||||
|
||||
@@ -171,6 +171,7 @@ void TracksScreen::init()
|
||||
|
||||
// Reset GP list everytime (accounts for locking changes, etc.)
|
||||
gps_widget->clearItems();
|
||||
gps_widget->setMaxLabelLength(30);
|
||||
|
||||
// Ensure that no GP and no track is NULL
|
||||
grand_prix_manager->checkConsistency();
|
||||
|
||||
@@ -282,7 +282,7 @@ void BaseUserScreen::eventCallback(Widget* widget,
|
||||
else if (button == "cancel")
|
||||
{
|
||||
StateManager::get()->popMenu();
|
||||
onEscapePressed();
|
||||
StateManager::get()->escapePressed();
|
||||
}
|
||||
else if (button == "recover")
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user