Merge branch 'master' of https://github.com/supertuxkart/stk-code into ScriptEngine

This commit is contained in:
Sachith Hasaranga Seneviratne 2014-06-08 20:32:08 +05:30
commit 75ed68ac58
21 changed files with 203 additions and 321 deletions

View File

@ -83,12 +83,16 @@ enum TypeFBO
FBO_COLORS,
FBO_LOG_LUMINANCE,
FBO_MLAA_COLORS,
FBO_MLAA_BLEND,
FBO_MLAA_TMP,
FBO_TMP1_WITH_DS,
FBO_TMP2_WITH_DS,
FBO_TMP4,
FBO_LINEAR_DEPTH,
FBO_HALF1,
FBO_HALF1_R,
FBO_HALF2,
FBO_HALF2_R,
FBO_QUARTER1,
FBO_QUARTER2,
FBO_EIGHTH1,
@ -123,6 +127,8 @@ enum QueryPerf
Q_BLOOM,
Q_TONEMAP,
Q_MOTIONBLUR,
Q_MLAA,
Q_GUI,
Q_LAST
};
@ -139,6 +145,8 @@ enum TypeRTT
RTT_HALF1,
RTT_HALF2,
RTT_HALF1_R,
RTT_HALF2_R,
RTT_QUARTER1,
RTT_QUARTER2,
@ -165,6 +173,8 @@ enum TypeRTT
RTT_DISPLACE,
RTT_MLAA_COLORS,
RTT_MLAA_BLEND,
RTT_MLAA_TMP,
RTT_BLOOM_1024,
RTT_BLOOM_512,

View File

@ -400,7 +400,9 @@ void PostProcessing::renderGaussian17TapBlur(FrameBuffer &in_fbo, FrameBuffer &a
assert(in_fbo.getWidth() == auxiliary.getWidth() && in_fbo.getHeight() == auxiliary.getHeight());
float inv_width = 1.0f / in_fbo.getWidth(), inv_height = 1.0f / in_fbo.getHeight();
{
#if WIN32
if (irr_driver->getGLSLVersion() < 430)
#endif
{
auxiliary.Bind();
glUseProgram(FullScreenShader::Gaussian17TapHShader::Program);
@ -415,8 +417,10 @@ void PostProcessing::renderGaussian17TapBlur(FrameBuffer &in_fbo, FrameBuffer &a
glDrawArrays(GL_TRIANGLES, 0, 3);
}
#if WIN32
else
{
glUseProgram(FullScreenShader::ComputeGaussian17TapHShader::Program);
glBindImageTexture(0, in_fbo.getRTT()[0], 0, false, 0, GL_READ_ONLY, GL_R16F);
glBindImageTexture(1, auxiliary.getRTT()[0], 0, false, 0, GL_WRITE_ONLY, GL_R16F);
@ -424,9 +428,12 @@ void PostProcessing::renderGaussian17TapBlur(FrameBuffer &in_fbo, FrameBuffer &a
glUniform1i(FullScreenShader::ComputeGaussian17TapHShader::uniform_dest, 1);
glDispatchCompute(in_fbo.getWidth() / 8, in_fbo.getHeight() / 8, 1);
}
#endif
}
{
#if WIN32
if (irr_driver->getGLSLVersion() < 430)
#endif
{
in_fbo.Bind();
glUseProgram(FullScreenShader::Gaussian17TapVShader::Program);
@ -441,6 +448,7 @@ void PostProcessing::renderGaussian17TapBlur(FrameBuffer &in_fbo, FrameBuffer &a
glDrawArrays(GL_TRIANGLES, 0, 3);
}
#if WIN32
else
{
glUseProgram(FullScreenShader::ComputeGaussian17TapVShader::Program);
@ -450,6 +458,7 @@ void PostProcessing::renderGaussian17TapBlur(FrameBuffer &in_fbo, FrameBuffer &a
glUniform1i(FullScreenShader::ComputeGaussian17TapVShader::uniform_dest, 1);
glDispatchCompute(in_fbo.getWidth() / 8, in_fbo.getHeight() / 8, 1);
}
#endif
}
}
@ -639,7 +648,7 @@ void PostProcessing::applyMLAA()
{
const core::vector2df &PIXEL_SIZE = core::vector2df(1.0f / UserConfigParams::m_width, 1.0f / UserConfigParams::m_height);
IVideoDriver *const drv = irr_driver->getVideoDriver();
irr_driver->getFBO(FBO_TMP1_WITH_DS).Bind();
irr_driver->getFBO(FBO_MLAA_TMP).Bind();
glEnable(GL_STENCIL_TEST);
glClearColor(0.0, 0.0, 0.0, 1.0);
glClear(GL_STENCIL_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
@ -658,11 +667,11 @@ void PostProcessing::applyMLAA()
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
// Pass 2: blend weights
irr_driver->getFBO(FBO_TMP2_WITH_DS).Bind();
irr_driver->getFBO(FBO_MLAA_BLEND).Bind();
glClear(GL_COLOR_BUFFER_BIT);
glUseProgram(FullScreenShader::MLAABlendWeightSHader::Program);
setTexture(0, irr_driver->getRenderTargetTexture(RTT_TMP1), GL_LINEAR, GL_LINEAR);
setTexture(0, irr_driver->getRenderTargetTexture(RTT_MLAA_TMP), GL_LINEAR, GL_LINEAR);
setTexture(1, getTextureGLuint(m_areamap), GL_NEAREST, GL_NEAREST);
FullScreenShader::MLAABlendWeightSHader::setUniforms(PIXEL_SIZE, 0, 1);
@ -670,14 +679,14 @@ void PostProcessing::applyMLAA()
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
// Blit in to tmp1
FrameBuffer::Blit(irr_driver->getFBO(FBO_MLAA_COLORS), irr_driver->getFBO(FBO_TMP1_WITH_DS));
FrameBuffer::Blit(irr_driver->getFBO(FBO_MLAA_COLORS), irr_driver->getFBO(FBO_MLAA_TMP));
// Pass 3: gather
irr_driver->getFBO(FBO_MLAA_COLORS).Bind();
glUseProgram(FullScreenShader::MLAAGatherSHader::Program);
setTexture(0, irr_driver->getRenderTargetTexture(RTT_TMP1), GL_NEAREST, GL_NEAREST);
setTexture(1, irr_driver->getRenderTargetTexture(RTT_TMP2), GL_NEAREST, GL_NEAREST);
setTexture(0, irr_driver->getRenderTargetTexture(RTT_MLAA_TMP), GL_NEAREST, GL_NEAREST);
setTexture(1, irr_driver->getRenderTargetTexture(RTT_MLAA_BLEND), GL_NEAREST, GL_NEAREST);
FullScreenShader::MLAAGatherSHader::setUniforms(PIXEL_SIZE, 0, 1);
glBindVertexArray(FullScreenShader::MLAAGatherSHader::vao);
@ -685,7 +694,6 @@ void PostProcessing::applyMLAA()
// Done.
glDisable(GL_STENCIL_TEST);
}
// ----------------------------------------------------------------------------
@ -850,17 +858,19 @@ FrameBuffer *PostProcessing::render(scene::ICameraSceneNode * const camnode)
PROFILER_POP_CPU_MARKER();
}
glEnable(GL_FRAMEBUFFER_SRGB);
irr_driver->getFBO(FBO_MLAA_COLORS).Bind();
renderPassThrough(in_fbo->getRTT()[0]);
out_fbo = &irr_driver->getFBO(FBO_MLAA_COLORS);
if (UserConfigParams::m_mlaa) // MLAA. Must be the last pp filter.
{
PROFILER_PUSH_CPU_MARKER("- MLAA", 0xFF, 0x00, 0x00);
glEnable(GL_FRAMEBUFFER_SRGB);
irr_driver->getFBO(FBO_MLAA_COLORS).Bind();
renderPassThrough(in_fbo->getRTT()[0]);
glDisable(GL_FRAMEBUFFER_SRGB);
ScopedGPUTimer Timer(irr_driver->getGPUTimer(Q_MLAA));
applyMLAA();
out_fbo = &irr_driver->getFBO(FBO_MLAA_COLORS);
PROFILER_POP_CPU_MARKER();
}
glDisable(GL_FRAMEBUFFER_SRGB);
return out_fbo;
} // render

View File

@ -187,13 +187,10 @@ void IrrDriver::renderGLSL(float dt)
{
FrameBuffer *fbo = m_post_processing->render(camnode);
if (!UserConfigParams::m_mlaa) // MLAA_COLORS already in srgb space
glEnable(GL_FRAMEBUFFER_SRGB);
if (irr_driver->getNormals())
irr_driver->getFBO(FBO_NORMAL_AND_DEPTHS).BlitToDefault(viewport.UpperLeftCorner.X, viewport.UpperLeftCorner.Y, viewport.LowerRightCorner.X, viewport.LowerRightCorner.Y);
else if (irr_driver->getSSAOViz())
irr_driver->getFBO(FBO_SSAO).BlitToDefault(viewport.UpperLeftCorner.X, viewport.UpperLeftCorner.Y, viewport.LowerRightCorner.X, viewport.LowerRightCorner.Y);
irr_driver->getFBO(FBO_HALF1_R).BlitToDefault(viewport.UpperLeftCorner.X, viewport.UpperLeftCorner.Y, viewport.LowerRightCorner.X, viewport.LowerRightCorner.Y);
else if (irr_driver->getRSM())
{
glBindFramebuffer(GL_FRAMEBUFFER, 0);
@ -202,9 +199,6 @@ void IrrDriver::renderGLSL(float dt)
}
else
fbo->BlitToDefault(viewport.UpperLeftCorner.X, viewport.UpperLeftCorner.Y, viewport.LowerRightCorner.X, viewport.LowerRightCorner.Y);
if (!UserConfigParams::m_mlaa)
glDisable(GL_FRAMEBUFFER_SRGB);
}
else
glDisable(GL_FRAMEBUFFER_SRGB);
@ -235,10 +229,13 @@ void IrrDriver::renderGLSL(float dt)
PROFILER_POP_CPU_MARKER();
} // for i<getNumKarts
PROFILER_PUSH_CPU_MARKER("GUIEngine", 0x75, 0x75, 0x75);
// Either render the gui, or the global elements of the race gui.
GUIEngine::render(dt);
PROFILER_POP_CPU_MARKER();
{
ScopedGPUTimer Timer(getGPUTimer(Q_GUI));
PROFILER_PUSH_CPU_MARKER("GUIEngine", 0x75, 0x75, 0x75);
// Either render the gui, or the global elements of the race gui.
GUIEngine::render(dt);
PROFILER_POP_CPU_MARKER();
}
// Render the profiler
if(UserConfigParams::m_profiler_enabled)
@ -600,7 +597,7 @@ void IrrDriver::renderSolidSecondPass()
GroupedSM<SM_UNTEXTURED>::reset();
setTexture(0, m_rtts->getRenderTarget(RTT_TMP1), GL_NEAREST, GL_NEAREST);
setTexture(1, m_rtts->getRenderTarget(RTT_TMP2), GL_NEAREST, GL_NEAREST);
setTexture(2, m_rtts->getRenderTarget(RTT_SSAO), GL_NEAREST, GL_NEAREST);
setTexture(2, m_rtts->getRenderTarget(RTT_HALF1_R), GL_LINEAR, GL_LINEAR);
{
@ -1020,7 +1017,7 @@ void IrrDriver::renderLights(unsigned pointlightcount)
}
m_rtts->getFBO(FBO_COMBINED_TMP1_TMP2).Bind();
if (World::getWorld() && World::getWorld()->getTrack()->hasShadows() && SkyboxCubeMap && UserConfigParams::m_gi)
if (World::getWorld() && World::getWorld()->getTrack()->hasShadows() && SkyboxCubeMap)
irr_driver->getSceneManager()->setAmbientLight(SColor(0, 0, 0, 0));
// Render sunlight if and only if track supports shadow
@ -1045,7 +1042,9 @@ void IrrDriver::renderSSAO()
glClear(GL_COLOR_BUFFER_BIT);
m_post_processing->renderSSAO();
// Blur it to reduce noise.
m_post_processing->renderGaussian17TapBlur(irr_driver->getFBO(FBO_SSAO), irr_driver->getFBO(FBO_TMP4));
FrameBuffer::Blit(m_rtts->getFBO(FBO_SSAO), m_rtts->getFBO(FBO_HALF1_R), GL_COLOR_BUFFER_BIT, GL_LINEAR);
m_post_processing->renderGaussian17TapBlur(irr_driver->getFBO(FBO_HALF1_R), irr_driver->getFBO(FBO_HALF2_R));
}
static void getXYZ(GLenum face, float i, float j, float &x, float &y, float &z)

View File

@ -30,7 +30,13 @@ static GLuint generateRTT3D(GLenum target, size_t w, size_t h, size_t d, GLint i
if (irr_driver->getGLSLVersion() < 420)
glTexImage3D(target, 0, internalFormat, w, h, d, 0, format, type, 0);
else
{
#if !defined(__linux__) || defined(GL_VERSION_4_2)
glTexStorage3D(target, 1, internalFormat, w, h, d);
#else
assert(false);
#endif
}
return result;
}
@ -42,7 +48,13 @@ static GLuint generateRTT(const core::dimension2du &res, GLint internalFormat, G
if (irr_driver->getGLSLVersion() < 420)
glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, res.Width, res.Height, 0, format, type, 0);
else
{
#if !defined(__linux__) || defined(GL_VERSION_4_2)
glTexStorage2D(GL_TEXTURE_2D, mipmaplevel, internalFormat, res.Width, res.Height);
#else
assert(false);
#endif
}
return result;
}
@ -105,16 +117,20 @@ RTT::RTT(size_t width, size_t height)
RenderTargetTextures[RTT_NORMAL_AND_DEPTH] = generateRTT(res, GL_RGBA16F, GL_RGBA, GL_FLOAT);
RenderTargetTextures[RTT_COLOR] = generateRTT(res, GL_RGBA16F, GL_BGRA, GL_FLOAT);
RenderTargetTextures[RTT_MLAA_COLORS] = generateRTT(res, GL_SRGB8_ALPHA8, GL_BGR, GL_UNSIGNED_BYTE);
RenderTargetTextures[RTT_MLAA_TMP] = generateRTT(res, GL_SRGB8_ALPHA8, GL_BGR, GL_UNSIGNED_BYTE);
RenderTargetTextures[RTT_MLAA_BLEND] = generateRTT(res, GL_SRGB8_ALPHA8, GL_BGR, GL_UNSIGNED_BYTE);
RenderTargetTextures[RTT_SSAO] = generateRTT(res, GL_R16F, GL_RED, GL_FLOAT);
RenderTargetTextures[RTT_DISPLACE] = generateRTT(res, GL_RGBA16F, GL_BGRA, GL_FLOAT);
RenderTargetTextures[RTT_HALF1] = generateRTT(half, GL_RGBA16F, GL_BGRA, GL_FLOAT);
RenderTargetTextures[RTT_QUARTER1] = generateRTT(quarter, GL_RGBA16F, GL_BGRA, GL_FLOAT);
RenderTargetTextures[RTT_EIGHTH1] = generateRTT(eighth, GL_RGBA16F, GL_BGRA, GL_FLOAT);
RenderTargetTextures[RTT_HALF1_R] = generateRTT(half, GL_R16F, GL_RED, GL_FLOAT);
RenderTargetTextures[RTT_HALF2] = generateRTT(half, GL_RGBA16F, GL_BGRA, GL_FLOAT);
RenderTargetTextures[RTT_QUARTER2] = generateRTT(quarter, GL_RGBA16F, GL_BGRA, GL_FLOAT);
RenderTargetTextures[RTT_EIGHTH2] = generateRTT(eighth, GL_RGBA16F, GL_BGRA, GL_FLOAT);
RenderTargetTextures[RTT_HALF2_R] = generateRTT(half, GL_R16F, GL_RED, GL_FLOAT);
RenderTargetTextures[RTT_BLOOM_1024] = generateRTT(shadowsize0, GL_RGBA16F, GL_BGR, GL_FLOAT);
RenderTargetTextures[RTT_BLOOM_512] = generateRTT(shadowsize1, GL_RGBA16F, GL_BGR, GL_FLOAT);
@ -150,6 +166,12 @@ RTT::RTT(size_t width, size_t height)
somevector.push_back(RenderTargetTextures[RTT_MLAA_COLORS]);
FrameBuffers.push_back(new FrameBuffer(somevector, res.Width, res.Height));
somevector.clear();
somevector.push_back(RenderTargetTextures[RTT_MLAA_BLEND]);
FrameBuffers.push_back(new FrameBuffer(somevector, res.Width, res.Height));
somevector.clear();
somevector.push_back(RenderTargetTextures[RTT_MLAA_TMP]);
FrameBuffers.push_back(new FrameBuffer(somevector, res.Width, res.Height));
somevector.clear();
somevector.push_back(RenderTargetTextures[RTT_TMP1]);
FrameBuffers.push_back(new FrameBuffer(somevector, DepthStencilTexture, res.Width, res.Height));
somevector.clear();
@ -165,9 +187,15 @@ RTT::RTT(size_t width, size_t height)
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));
somevector.clear();
somevector.push_back(RenderTargetTextures[RTT_HALF2_R]);
FrameBuffers.push_back(new FrameBuffer(somevector, half.Width, half.Height));
somevector.clear();
somevector.push_back(RenderTargetTextures[RTT_QUARTER1]);
FrameBuffers.push_back(new FrameBuffer(somevector, quarter.Width, quarter.Height));
somevector.clear();

View File

@ -277,11 +277,15 @@ void Shaders::loadShaders()
FullScreenShader::DepthOfFieldShader::init();
FullScreenShader::FogShader::init();
FullScreenShader::Gaussian17TapHShader::init();
#if !defined(__linux__) || defined(GL_VERSION_4_3)
FullScreenShader::ComputeGaussian17TapHShader::init();
#endif
FullScreenShader::Gaussian3HBlurShader::init();
FullScreenShader::Gaussian3VBlurShader::init();
FullScreenShader::Gaussian17TapVShader::init();
#if !defined(__linux__) || defined(GL_VERSION_4_3)
FullScreenShader::ComputeGaussian17TapVShader::init();
#endif
FullScreenShader::Gaussian6HBlurShader::init();
FullScreenShader::Gaussian6VBlurShader::init();
FullScreenShader::GlowShader::init();
@ -1197,6 +1201,7 @@ namespace MeshShader
GLuint SphereMapShader::attrib_normal;
GLuint SphereMapShader::uniform_MM;
GLuint SphereMapShader::uniform_IMM;
GLuint SphereMapShader::uniform_ambient;
GLuint SphereMapShader::TU_tex;
void SphereMapShader::init()
@ -1210,6 +1215,7 @@ namespace MeshShader
attrib_normal = glGetAttribLocation(Program, "Normal");
uniform_MM = glGetUniformLocation(Program, "ModelMatrix");
uniform_IMM = glGetUniformLocation(Program, "InverseModelMatrix");
uniform_ambient = glGetUniformLocation(Program, "ambient");
GLuint uniform_tex = glGetUniformLocation(Program, "tex");
GLuint uniform_Albedo = glGetUniformLocation(Program, "Albedo");
GLuint uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap");
@ -1230,12 +1236,13 @@ namespace MeshShader
glUseProgram(0);
}
void SphereMapShader::setUniforms(const core::matrix4 &ModelMatrix, const core::matrix4 &InverseModelMatrix)
void SphereMapShader::setUniforms(const core::matrix4 &ModelMatrix, const core::matrix4 &InverseModelMatrix, const SColorf &ambient)
{
if (UserConfigParams::m_ubo_disabled)
bypassUBO(Program);
glUniformMatrix4fv(uniform_MM, 1, GL_FALSE, ModelMatrix.pointer());
glUniformMatrix4fv(uniform_IMM, 1, GL_FALSE, InverseModelMatrix.pointer());
glUniform3f(uniform_ambient, ambient.r, ambient.g, ambient.b);
}
GLuint SplattingShader::Program;
@ -2441,6 +2448,7 @@ namespace FullScreenShader
vao = createFullScreenVAO(Program);
}
#if !defined(__linux__) || defined(GL_VERSION_4_3)
GLuint ComputeGaussian17TapHShader::Program;
GLuint ComputeGaussian17TapHShader::uniform_source;
GLuint ComputeGaussian17TapHShader::uniform_dest;
@ -2451,7 +2459,7 @@ namespace FullScreenShader
uniform_source = glGetUniformLocation(Program, "source");
uniform_dest = glGetUniformLocation(Program, "dest");
}
#endif
GLuint Gaussian6HBlurShader::Program;
GLuint Gaussian6HBlurShader::uniform_tex;
GLuint Gaussian6HBlurShader::uniform_pixel;
@ -2497,6 +2505,7 @@ namespace FullScreenShader
GLuint ComputeGaussian17TapVShader::Program;
GLuint ComputeGaussian17TapVShader::uniform_source;
GLuint ComputeGaussian17TapVShader::uniform_dest;
#if !defined(__linux__) || defined(GL_VERSION_4_3)
void ComputeGaussian17TapVShader::init()
{
Program = LoadProgram(
@ -2504,7 +2513,7 @@ namespace FullScreenShader
uniform_source = glGetUniformLocation(Program, "source");
uniform_dest = glGetUniformLocation(Program, "dest");
}
#endif
GLuint Gaussian6VBlurShader::Program;
GLuint Gaussian6VBlurShader::uniform_tex;
GLuint Gaussian6VBlurShader::uniform_pixel;

View File

@ -250,11 +250,11 @@ class SphereMapShader
public:
static GLuint Program;
static GLuint attrib_position, attrib_normal;
static GLuint uniform_MM, uniform_IMM;
static GLuint uniform_MM, uniform_IMM, uniform_ambient;
static GLuint TU_tex;
static void init();
static void setUniforms(const core::matrix4 &ModelMatrix, const core::matrix4 &InverseModelMatrix);
static void setUniforms(const core::matrix4 &ModelMatrix, const core::matrix4 &InverseModelMatrix, const video::SColorf &ambient);
};
class SplattingShader

View File

@ -249,7 +249,7 @@ void drawSphereMap(const GLMesh &mesh, const core::matrix4 &ModelMatrix, const c
}
setTexture(MeshShader::SphereMapShader::TU_tex, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
MeshShader::SphereMapShader::setUniforms(ModelMatrix, InverseModelMatrix);
MeshShader::SphereMapShader::setUniforms(ModelMatrix, InverseModelMatrix, irr_driver->getSceneManager()->getAmbientLight());
assert(mesh.vao_second_pass);
glBindVertexArray(mesh.vao_second_pass);
glDrawElements(ptype, count, itype, 0);

View File

@ -1752,7 +1752,7 @@ void Kart::crashed(const Material *m, const Vec3 &normal)
btVector3 gravity = m_body->getGravity();
gravity.normalize();
// Cast necessary since otherwise to operator- (vec3/btvector) exists
Vec3 impulse = (btVector3)normal - gravity* btDot(normal, gravity);
Vec3 impulse = normal - gravity* btDot(normal, gravity);
if(impulse.getX() || impulse.getZ())
impulse.normalize();
else

View File

@ -413,7 +413,7 @@ void CutsceneWorld::enterRaceOverState()
OverWorld::enterOverWorld();
}
// TODO: remove hardcoded knowledge of cutscenes, replace with scripting probably
else if (m_parts.size() == 1 && m_parts[0] == "gplose")
else if (m_parts.size() == 1 && m_parts[0] == "gplose")
{
race_manager->exitRace();
StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
@ -438,6 +438,28 @@ void CutsceneWorld::enterRaceOverState()
StateManager::get()->pushScreen( s );
}
}
// TODO: remove hardcoded knowledge of cutscenes, replace with scripting probably
else if (m_parts.size() == 1 && m_parts[0] == "featunlocked")
{
if (race_manager->getMajorMode() == RaceManager::MAJOR_MODE_GRAND_PRIX)
{
// in GP mode, continue GP after viewing this screen
StateManager::get()->popMenu();
race_manager->next();
}
else
{
// back to menu or overworld
race_manager->exitRace();
StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
//StateManager::get()->popMenu();
if (race_manager->raceWasStartedFromOverworld())
{
OverWorld::enterOverWorld();
}
}
}
else
{
race_manager->exitRace();

View File

@ -189,7 +189,7 @@ void PhysicalObject::move(const Vec3& xyz, const core::vector3df& hpr)
irr::core::quaternion tempQuat(mat);
q = btQuaternion(tempQuat.X, tempQuat.Y, tempQuat.Z, tempQuat.W);
btTransform trans(q,(btVector3)xyz-quatRotate(q,m_graphical_offset));
btTransform trans(q, xyz-quatRotate(q,m_graphical_offset));
m_motion_state->setWorldTransform(trans);
} // move

View File

@ -156,7 +156,7 @@ void FeatureUnlockedCutScene::onCutsceneEnd()
irr_driver->removeNode(m_avoid_irrlicht_bug);
m_avoid_irrlicht_bug = NULL;
#endif
m_unlocked_stuff.clearAndDeleteAll();
m_all_kart_models.clearAndDeleteAll();
@ -353,7 +353,6 @@ void FeatureUnlockedCutScene::init()
void FeatureUnlockedCutScene::tearDown()
{
Screen::tearDown();
((CutsceneWorld*)World::getWorld())->abortCutscene();
} // tearDown
// ----------------------------------------------------------------------------
@ -379,8 +378,6 @@ void FeatureUnlockedCutScene::onUpdate(float dt)
float progress_factor = (m_global_time - GIFT_EXIT_FROM) / (GIFT_EXIT_TO - GIFT_EXIT_FROM);
float smoothed_progress_factor = sin((progress_factor - 0.5f)*M_PI)/2.0f + 0.5f;
Log::info("smoothed_progress_factor", "%f", smoothed_progress_factor);
for (int n=0; n<unlockedStuffCount; n++)
{
if (m_unlocked_stuff[n].m_root_gift_node == NULL) continue;
@ -546,7 +543,6 @@ void FeatureUnlockedCutScene::addUnlockedGP(const GrandPrixData* gp)
bool FeatureUnlockedCutScene::onEscapePressed()
{
((CutsceneWorld*)World::getWorld())->abortCutscene();
continueButtonPressed();
return false; // continueButtonPressed already pop'ed the menu
} // onEscapePressed
@ -555,35 +551,20 @@ bool FeatureUnlockedCutScene::onEscapePressed()
void FeatureUnlockedCutScene::continueButtonPressed()
{
if (m_global_time < GIFT_EXIT_TO)
{
// If animation was not over yet, the button is used to skip the animation
while (m_global_time < GIFT_EXIT_TO)
{
// simulate all the steps of the animation until we reach the end
onUpdate(0.4f);
}
}
else
{
if (race_manager->getMajorMode() == RaceManager::MAJOR_MODE_GRAND_PRIX)
{
// in GP mode, continue GP after viewing this screen
StateManager::get()->popMenu();
race_manager->next();
}
else
{
// back to menu or overworld
race_manager->exitRace();
StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
if (race_manager->raceWasStartedFromOverworld())
{
OverWorld::enterOverWorld();
}
}
}
//if (m_global_time < GIFT_EXIT_TO)
//{
// // If animation was not over yet, the button is used to skip the animation
// while (m_global_time < GIFT_EXIT_TO)
// {
// // simulate all the steps of the animation until we reach the end
// onUpdate(0.4f);
// World::getWorld()->updateWorld(0.4f);
// }
//}
//else
//{
((CutsceneWorld*)World::getWorld())->abortCutscene();
//}
} // continueButtonPressed

View File

@ -117,9 +117,18 @@ void GrandPrixLose::onCutsceneEnd()
PlayerManager::getCurrentPlayer()->getRecentlyCompletedChallenges();
if (unlocked.size() > 0)
{
StateManager::get()->enterGameState();
race_manager->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE);
race_manager->setNumKarts(0);
race_manager->setNumPlayers(0);
race_manager->setNumLocalPlayers(0);
race_manager->startSingleRace("featunlocked", 999, false);
FeatureUnlockedCutScene* scene =
FeatureUnlockedCutScene::getInstance();
std::vector<std::string> parts;
parts.push_back("featunlocked");
((CutsceneWorld*)World::getWorld())->setParts(parts);
scene->addTrophy(race_manager->getDifficulty());
scene->findWhatWasUnlocked(race_manager->getDifficulty());

View File

@ -127,7 +127,18 @@ void GrandPrixWin::onCutsceneEnd()
PlayerManager::getCurrentPlayer()->getRecentlyCompletedChallenges();
PlayerManager::getCurrentPlayer()->clearUnlocked();
FeatureUnlockedCutScene* scene = FeatureUnlockedCutScene::getInstance();
StateManager::get()->enterGameState();
race_manager->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE);
race_manager->setNumKarts(0);
race_manager->setNumPlayers(0);
race_manager->setNumLocalPlayers(0);
race_manager->startSingleRace("featunlocked", 999, false);
FeatureUnlockedCutScene* scene =
FeatureUnlockedCutScene::getInstance();
std::vector<std::string> parts;
parts.push_back("featunlocked");
((CutsceneWorld*)World::getWorld())->setParts(parts);
assert(unlocked.size() > 0);
scene->addTrophy(race_manager->getDifficulty());

View File

@ -273,14 +273,27 @@ void RaceResultGUI::eventCallback(GUIEngine::Widget* widget,
}
else
{
FeatureUnlockedCutScene* scene =
FeatureUnlockedCutScene::getInstance();
scene->addTrophy(race_manager->getDifficulty());
scene->findWhatWasUnlocked(race_manager->getDifficulty());
StateManager::get()->popMenu();
World::deleteWorld();
StateManager::get()->enterGameState();
race_manager->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE);
race_manager->setNumKarts(0);
race_manager->setNumPlayers(0);
race_manager->setNumLocalPlayers(0);
race_manager->startSingleRace("featunlocked", 999, false);
FeatureUnlockedCutScene* scene =
FeatureUnlockedCutScene::getInstance();
scene->addTrophy(race_manager->getDifficulty());
scene->findWhatWasUnlocked(race_manager->getDifficulty());
StateManager::get()->pushScreen(scene);
race_manager->setAIKartOverride("");
std::vector<std::string> parts;
parts.push_back("featunlocked");
((CutsceneWorld*)World::getWorld())->setParts(parts);
}
return;
}
@ -364,7 +377,7 @@ void RaceResultGUI::eventCallback(GUIEngine::Widget* widget,
// FIXME: why is this call necessary here? tearDown should be
// automatically called when the screen is left. Note that the
// NetworkKartSelectionScreen::getInstance()->tearDown(); caused #1347
KartSelectionScreen::getRunningInstance()->tearDown();
KartSelectionScreen::getRunningInstance()->tearDown();
StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
if (race_manager->raceWasStartedFromOverworld())

View File

@ -89,17 +89,11 @@ void RegisterScreen::init()
getWidget<CheckBoxWidget>("online")->setVisible(true);
getWidget<LabelWidget>("label_online")->setVisible(true);
// Check if online is allowed
if (UserConfigParams::m_internet_status != Online::RequestManager::IPERM_NOT_ALLOWED)
{
getWidget<CheckBoxWidget>("online")->setState(true);
makeEntryFieldsVisible(true);
}
else
{
getWidget<CheckBoxWidget>("online")->setState(false);
makeEntryFieldsVisible(false);
}
onDialogClose();
bool online = UserConfigParams::m_internet_status
!= Online::RequestManager::IPERM_NOT_ALLOWED;
getWidget<CheckBoxWidget>("online")->setState(online);
makeEntryFieldsVisible(online);
} // init
// -----------------------------------------------------------------------------
@ -108,6 +102,19 @@ void RegisterScreen::setRename(PlayerProfile *player)
m_existing_player = player;
} // setRename
// -----------------------------------------------------------------------------
/** Will be called first time STK is started, when the 'internet yes/no' dialog
* is closed. Adjust the state of the online checkbox depending on that
* answer.
*/
void RegisterScreen::onDialogClose()
{
bool online = UserConfigParams::m_internet_status
!= Online::RequestManager::IPERM_NOT_ALLOWED;
getWidget<CheckBoxWidget>("online")->setState(online);
makeEntryFieldsVisible(online);
} // onDialogClose
// -----------------------------------------------------------------------------
/** Shows or hides the entry fields for online registration, depending on
* online mode.

View File

@ -64,6 +64,7 @@ public:
virtual void loadedFromFile() OVERRIDE {};
virtual void onUpdate(float dt) OVERRIDE;
virtual bool onEscapePressed() OVERRIDE;
virtual void onDialogClose() OVERRIDE;
void setRename(PlayerProfile *player);
void acceptTerms();

View File

@ -1,204 +0,0 @@
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2014 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 "states_screens/register_screen.hpp"
#include "audio/sfx_manager.hpp"
#include "guiengine/widgets/label_widget.hpp"
#include "guiengine/widgets/ribbon_widget.hpp"
#include "guiengine/widgets/text_box_widget.hpp"
#include "online/current_user.hpp"
#include "online/messages.hpp"
#include "states_screens/dialogs/registration_dialog.hpp"
#include "states_screens/dialogs/message_dialog.hpp"
#include "states_screens/guest_login_screen.hpp"
#include "states_screens/login_screen.hpp"
#include "states_screens/main_menu_screen.hpp"
#include "states_screens/state_manager.hpp"
#include "utils/log.hpp"
#include "utils/translation.hpp"
using namespace GUIEngine;
using namespace Online;
DEFINE_SCREEN_SINGLETON( RegisterScreen );
// -----------------------------------------------------------------------------
RegisterScreen::RegisterScreen() : Screen("online/register.stkgui")
{
} // RegisterScreen
// -----------------------------------------------------------------------------
void RegisterScreen::init()
{
// Make sure this tab is actually focused.
RibbonWidget* tabs = this->getWidget<RibbonWidget>("login_tabs");
if (tabs) tabs->select( "tab_register", PLAYER_ID_GAME_MASTER );
TextBoxWidget *password_widget = getWidget<TextBoxWidget>("password");
password_widget->setPasswordBox(true,L'*');
password_widget = getWidget<TextBoxWidget>("password_confirm");
password_widget->setPasswordBox(true,L'*');
m_info_widget = getWidget<LabelWidget>("info");
assert(m_info_widget);
m_options_widget = getWidget<RibbonWidget>("options");
assert(m_options_widget);
m_signup_request = NULL;
m_info_message_shown = false;
} // init
// -----------------------------------------------------------------------------
void RegisterScreen::doRegister()
{
core::stringw username = getWidget<TextBoxWidget>("username")->getText().trim();
core::stringw password = getWidget<TextBoxWidget>("password")->getText().trim();
core::stringw password_confirm = getWidget<TextBoxWidget>("password_confirm")
->getText().trim();
core::stringw email = getWidget<TextBoxWidget>("email")->getText().trim();
core::stringw email_confirm = getWidget<TextBoxWidget>("email_confirm")
->getText().trim();
m_info_widget->setErrorColor();
if (password != password_confirm)
{
m_info_widget->setText(_("Passwords don't match!"), false);
}
else if (email != email_confirm)
{
m_info_widget->setText(_("Emails don't match!"), false);
}
else if (username.size() < 4 || username.size() > 30)
{
m_info_widget->setText(_("Username has to be between 4 and 30 characters long!"), false);
}
else if (password.size() < 8 || password.size() > 30)
{
m_info_widget->setText(_("Password has to be between 8 and 30 characters long!"), false);
}
else if (email.size() < 4 || email.size() > 50)
{
m_info_widget->setText(_("Email has to be between 4 and 50 characters long!"), false);
}
else
{
m_info_widget->setDefaultColor();
new MessageDialog(
_("=== STK Terms and Conditions ===\n"
"You must agree to these terms in order to register an account for STK."
"Still needs actual content. Preferably in an XML document which can then be parsed to be put here.\n\n"
"By checking the box below, you are confirming that you understand these terms."
"If you have any questions or comments regarding these terms,"
"one of the members of the development team would gladly assist you."
),
MessageDialog::MESSAGE_DIALOG_OK_CANCEL, NULL, false);
return;
}
sfx_manager->quickSound( "anvil" );
} // doRegister
// -----------------------------------------------------------------------------
/** Called from the registration info dialog when 'accept' is clicked.
*/
void RegisterScreen::acceptTerms()
{
m_options_widget->setDeactivated();
core::stringw username = getWidget<TextBoxWidget>("username")->getText().trim();
core::stringw password = getWidget<TextBoxWidget>("password")->getText().trim();
core::stringw password_confirm= getWidget<TextBoxWidget>("password_confirm")->getText().trim();
core::stringw email = getWidget<TextBoxWidget>("email")->getText().trim();
m_signup_request = CurrentUser::get()->requestSignUp(username, password,
password_confirm, email);
} // acceptTerms
// -----------------------------------------------------------------------------
void RegisterScreen::onUpdate(float dt, irr::video::IVideoDriver*)
{
if(m_signup_request)
{
if(!m_options_widget->isActivated())
m_info_widget->setText(Messages::validatingInfo(), false);
if(m_signup_request->isDone())
{
if(m_signup_request->isSuccess())
{
new MessageDialog(
_("You will receive an email with further instructions "
"regarding account activation. Please be patient and be "
"sure to check your spam folder."),
MessageDialog::MESSAGE_DIALOG_OK, NULL, false);
// Set the flag that the message was shown, which will triger
// a pop of this menu and so a return to the main menu
m_info_message_shown = true;
}
else
{
// Error signing up, display error message
m_info_widget->setText(m_signup_request->getInfo(), false);
}
delete m_signup_request;
m_signup_request = NULL;
m_options_widget->setActivated();
}
}
else if(m_info_message_shown && !ModalDialog::isADialogActive())
{
// Once the info message was shown (signup was successful), but the
// message has been gone (user clicked on OK), go back to main menu
StateManager::get()->popMenu();
}
} // onUpdate
// -----------------------------------------------------------------------------
void RegisterScreen::eventCallback(Widget* widget, const std::string& name,
const int playerID)
{
if (name == "login_tabs")
{
const std::string selection =
((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER);
StateManager *sm = StateManager::get();
if (selection == "tab_login")
sm->replaceTopMostScreen(LoginScreen::getInstance());
else if (selection == "tab_guest_login")
sm->replaceTopMostScreen(GuestLoginScreen::getInstance());
}
else if (name=="options")
{
const std::string button = m_options_widget
->getSelectionIDString(PLAYER_ID_GAME_MASTER);
if(button=="next")
{
doRegister();
}
else if(button=="cancel")
StateManager::get()->escapePressed();
}
} // eventCallback
// -----------------------------------------------------------------------------

View File

@ -175,6 +175,10 @@ void BaseUserScreen::selectUser(int index)
m_online_cb->setState(true);
makeEntryFieldsVisible();
m_username_tb->setText(profile->getLastOnlineName());
if(profile->getLastOnlineName().size()>0)
m_username_tb->setDeactivated();
else
m_username_tb->setActivated();
// And make the password invisible if the session is saved (i.e
// the user does not need to enter a password).
@ -332,10 +336,11 @@ void BaseUserScreen::login()
m_sign_out_name = current->getLastOnlineName();
current->requestSignOut();
m_state = (UserScreenState)(m_state | STATE_LOGOUT);
// If the online user name was changed, reset the save data
// for this user (otherwise later the saved session will be
// resumed, not logging the user with the new account).
if(current->getLastOnlineName()!=new_username)
if(player==current && current->getLastOnlineName()!=new_username)
current->clearSession();
}
PlayerManager::get()->setCurrentPlayer(player);
@ -560,34 +565,6 @@ void BaseUserScreen::unloaded()
} // unloaded
// ----------------------------------------------------------------------------
/** Gets called when a dialog closes. At a first time start of STK the
* internet dialog is shown first. Only when this dialog closes is it possible
* to open the next dialog, which is the one to create a new player (which
* is conventient on a first start).
*/
void BaseUserScreen::onDialogClose()
{
return;
// To allow players to exit the game without creating a player, we count
// how often this function was called. The first time is after the
// internet allowed dialog, the 2nd time
static int number_of_calls = 0;
number_of_calls++;
if(PlayerManager::get()->getNumPlayers() == 0)
{
// Still 0 players after the enter player dialog was shown
// --> User wanted to abort, so pop this menu, which will
// trigger the end of STK.
if (number_of_calls > 1)
{
StateManager::get()->popMenu();
return;
}
StateManager::get()->pushScreen(RegisterScreen::getInstance());
} // getNumPlayers == 0
} // onDialogClose
// ============================================================================
/** In the tab version, make sure the right tab is selected.

View File

@ -89,7 +89,6 @@ private:
void deletePlayer();
void doDeletePlayer();
PlayerProfile* getSelectedPlayer();
virtual void onDialogClose();
virtual void onUpdate(float dt) OVERRIDE;
public:

View File

@ -407,7 +407,9 @@ void Profiler::draw()
"Godrays",
"Bloom",
"Tonemap",
"Motion Blur"
"Motion Blur",
"MLAA",
"GUI",
};
std::ostringstream oss;
oss << Phase[hovered_gpu_marker] << " : " << hovered_gpu_marker_elapsed << " us";

View File

@ -168,6 +168,14 @@ public:
Vec3 operator-(const Vec3& v1) const {return (Vec3)(*(btVector3*)this
-(btVector3)v1); }
// ------------------------------------------------------------------------
/** Computes this = this - v1. On VS this special version is needed,
* since otherwise Vec3-btVector3 is ont unique (could be cast to
* btVector3-btVector3, or convert btVector3 to Vec3()). */
Vec3 operator-(const btVector3 v1) const
{
return *(btVector3*)this - v1;
}
// ------------------------------------------------------------------------
/** Helper functions to treat this vec3 as a 2d vector. This returns the
* square of the length of the first 2 dimensions. */
float length2_2d() const { return m_floats[0]*m_floats[0]