Merge branch 'master' of github.com:supertuxkart/stk-code
This commit is contained in:
commit
8389f4afb6
@ -1,35 +1,26 @@
|
||||
#version 130
|
||||
uniform sampler2D tex;
|
||||
uniform int hastex;
|
||||
uniform float objectid;
|
||||
uniform sampler2D Albedo;
|
||||
uniform sampler2D DiffuseMap;
|
||||
uniform sampler2D SpecularMap;
|
||||
uniform sampler2D SSAO;
|
||||
uniform vec2 screen;
|
||||
uniform vec3 ambient;
|
||||
|
||||
noperspective in vec3 nor;
|
||||
noperspective in vec3 eyenor;
|
||||
noperspective in vec3 viewpos;
|
||||
out vec4 Albedo;
|
||||
out vec4 NormalDepth;
|
||||
out vec4 Specular;
|
||||
noperspective in vec3 normal;
|
||||
in vec2 uv;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
void main() {
|
||||
float rim = 1.0 - dot(eyenor, viewpos);
|
||||
float rim = 1.0 - dot(normal, vec3(0., 0., -1));
|
||||
rim = smoothstep(0.5, 1.5, rim) * 0.35;
|
||||
vec4 color;
|
||||
|
||||
if (hastex != 0) {
|
||||
vec4 col = texture(tex, gl_TexCoord[0].xy);
|
||||
|
||||
if (col.a < 0.1)
|
||||
discard;
|
||||
|
||||
col.xyz += rim;
|
||||
|
||||
color = col;
|
||||
} else {
|
||||
color = gl_Color + vec4(vec3(rim), 0.0);
|
||||
}
|
||||
|
||||
Albedo = vec4(color.xyz, 1.);
|
||||
NormalDepth = vec4(0.5 * normalize(nor) + 0.5, gl_FragCoord.z);
|
||||
Specular = vec4(1. - color.a);
|
||||
vec4 color = texture(Albedo, uv);
|
||||
vec2 tc = gl_FragCoord.xy / screen;
|
||||
vec3 DiffuseComponent = texture(DiffuseMap, tc).xyz;
|
||||
vec3 SpecularComponent = texture(SpecularMap, tc).xyz;
|
||||
float ao = texture(SSAO, tc).x;
|
||||
vec3 LightFactor = ao * ambient + DiffuseComponent + SpecularComponent * (1. - color.a);
|
||||
FragColor = vec4(color.xyz * LightFactor + rim, 1.);
|
||||
}
|
||||
|
||||
|
@ -1,15 +1,16 @@
|
||||
#version 130
|
||||
uniform mat4 ModelViewProjectionMatrix;
|
||||
uniform mat4 TransposeInverseModelView;
|
||||
|
||||
noperspective out vec3 nor;
|
||||
noperspective out vec3 eyenor;
|
||||
noperspective out vec3 viewpos;
|
||||
in vec3 Position;
|
||||
in vec3 Normal;
|
||||
in vec2 Texcoord;
|
||||
in vec4 Color;
|
||||
out vec2 uv;
|
||||
noperspective out vec3 normal;
|
||||
|
||||
void main() {
|
||||
nor = gl_NormalMatrix * gl_Normal;
|
||||
eyenor = gl_NormalMatrix * gl_Normal;
|
||||
viewpos = -normalize((gl_ModelViewMatrix * gl_Vertex).xyz);
|
||||
|
||||
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
|
||||
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
|
||||
gl_FrontColor = gl_Color;
|
||||
normal = (TransposeInverseModelView * vec4(Normal, 0)).xyz;
|
||||
uv = Texcoord;
|
||||
gl_Position = ModelViewProjectionMatrix * vec4(Position, 1.);
|
||||
}
|
||||
|
@ -2583,8 +2583,8 @@ void COpenGLDriver::setRenderStates3DMode()
|
||||
|
||||
ResetRenderStates = true;
|
||||
#ifdef GL_EXT_clip_volume_hint
|
||||
if (FeatureAvailable[IRR_EXT_clip_volume_hint])
|
||||
glHint(GL_CLIP_VOLUME_CLIPPING_HINT_EXT, GL_NICEST);
|
||||
// if (FeatureAvailable[IRR_EXT_clip_volume_hint])
|
||||
// glHint(GL_CLIP_VOLUME_CLIPPING_HINT_EXT, GL_NICEST);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -3241,8 +3241,8 @@ void COpenGLDriver::setRenderStates2DMode(bool alpha, bool texture, bool alphaCh
|
||||
}
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
#ifdef GL_EXT_clip_volume_hint
|
||||
if (FeatureAvailable[IRR_EXT_clip_volume_hint])
|
||||
glHint(GL_CLIP_VOLUME_CLIPPING_HINT_EXT, GL_FASTEST);
|
||||
// if (FeatureAvailable[IRR_EXT_clip_volume_hint])
|
||||
// glHint(GL_CLIP_VOLUME_CLIPPING_HINT_EXT, GL_FASTEST);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
@ -242,6 +242,7 @@ void Shaders::loadShaders()
|
||||
MeshShader::ObjectPass1Shader::init();
|
||||
MeshShader::ObjectRefPass1Shader::init();
|
||||
MeshShader::ObjectPass2Shader::init();
|
||||
MeshShader::ObjectRimLimitShader::init();
|
||||
MeshShader::UntexturedObjectShader::init();
|
||||
MeshShader::ObjectRefPass2Shader::init();
|
||||
MeshShader::SphereMapShader::init();
|
||||
@ -369,6 +370,48 @@ namespace MeshShader
|
||||
glUniform3f(uniform_ambient, s.r, s.g, s.b);
|
||||
}
|
||||
|
||||
GLuint ObjectRimLimitShader::Program;
|
||||
GLuint ObjectRimLimitShader::attrib_position;
|
||||
GLuint ObjectRimLimitShader::attrib_texcoord;
|
||||
GLuint ObjectRimLimitShader::attrib_normal;
|
||||
GLuint ObjectRimLimitShader::uniform_MVP;
|
||||
GLuint ObjectRimLimitShader::uniform_TIMV;
|
||||
GLuint ObjectRimLimitShader::uniform_Albedo;
|
||||
GLuint ObjectRimLimitShader::uniform_DiffuseMap;
|
||||
GLuint ObjectRimLimitShader::uniform_SpecularMap;
|
||||
GLuint ObjectRimLimitShader::uniform_SSAO;
|
||||
GLuint ObjectRimLimitShader::uniform_screen;
|
||||
GLuint ObjectRimLimitShader::uniform_ambient;
|
||||
|
||||
void ObjectRimLimitShader::init()
|
||||
{
|
||||
Program = LoadProgram(file_manager->getAsset("shaders/objectpass_rimlit.vert").c_str(), file_manager->getAsset("shaders/objectpass_rimlit.frag").c_str());
|
||||
attrib_position = glGetAttribLocation(Program, "Position");
|
||||
attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
|
||||
attrib_normal = glGetAttribLocation(Program, "Normal");
|
||||
uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix");
|
||||
uniform_TIMV = glGetUniformLocation(Program, "TransposeInverseModelView");
|
||||
uniform_Albedo = glGetUniformLocation(Program, "Albedo");
|
||||
uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap");
|
||||
uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap");
|
||||
uniform_SSAO = glGetUniformLocation(Program, "SSAO");
|
||||
uniform_screen = glGetUniformLocation(Program, "screen");
|
||||
uniform_ambient = glGetUniformLocation(Program, "ambient");
|
||||
}
|
||||
|
||||
void ObjectRimLimitShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, unsigned TU_Albedo, unsigned TU_DiffuseMap, unsigned TU_SpecularMap, unsigned TU_SSAO)
|
||||
{
|
||||
glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer());
|
||||
glUniformMatrix4fv(uniform_TIMV, 1, GL_FALSE, TransposeInverseModelView.pointer());
|
||||
glUniform1i(uniform_Albedo, TU_Albedo);
|
||||
glUniform1i(uniform_DiffuseMap, TU_DiffuseMap);
|
||||
glUniform1i(uniform_SpecularMap, TU_SpecularMap);
|
||||
glUniform1i(uniform_SSAO, TU_SSAO);
|
||||
glUniform2f(uniform_screen, UserConfigParams::m_width, UserConfigParams::m_height);
|
||||
const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight();
|
||||
glUniform3f(uniform_ambient, s.r, s.g, s.b);
|
||||
}
|
||||
|
||||
GLuint UntexturedObjectShader::Program;
|
||||
GLuint UntexturedObjectShader::attrib_position;
|
||||
GLuint UntexturedObjectShader::attrib_color;
|
||||
|
@ -59,6 +59,17 @@ public:
|
||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, unsigned TU_Albedo, unsigned TU_DiffuseMap, unsigned TU_SpecularMap, unsigned TU_SSAO);
|
||||
};
|
||||
|
||||
class ObjectRimLimitShader
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_normal, attrib_texcoord;
|
||||
static GLuint uniform_MVP, uniform_TIMV, uniform_Albedo, uniform_DiffuseMap, uniform_SpecularMap, uniform_SSAO, uniform_screen, uniform_ambient;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, unsigned TU_Albedo, unsigned TU_DiffuseMap, unsigned TU_SpecularMap, unsigned TU_SSAO);
|
||||
};
|
||||
|
||||
class UntexturedObjectShader
|
||||
{
|
||||
public:
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <IMaterialRenderer.h>
|
||||
#include <ISkinnedMesh.h>
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
|
||||
using namespace irr;
|
||||
|
||||
@ -16,6 +17,46 @@ const core::vector3df& scale) :
|
||||
firstTime = true;
|
||||
}
|
||||
|
||||
void STKAnimatedMesh::setMesh(scene::IAnimatedMesh* mesh)
|
||||
{
|
||||
firstTime = true;
|
||||
GLmeshes.clear();
|
||||
CAnimatedMeshSceneNode::setMesh(mesh);
|
||||
}
|
||||
|
||||
void drawObjectRimLimit(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView)
|
||||
{
|
||||
GLenum ptype = mesh.PrimitiveType;
|
||||
GLenum itype = mesh.IndexType;
|
||||
size_t count = mesh.IndexCount;
|
||||
|
||||
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR);
|
||||
if (irr_driver->getLightViz())
|
||||
{
|
||||
GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ALPHA };
|
||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
||||
}
|
||||
else
|
||||
{
|
||||
GLint swizzleMask[] = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA };
|
||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
||||
}
|
||||
|
||||
setTexture(1, static_cast<irr::video::COpenGLTexture*>(irr_driver->getRTT(RTT_TMP1))->getOpenGLTextureName(), GL_NEAREST, GL_NEAREST);
|
||||
setTexture(2, static_cast<irr::video::COpenGLTexture*>(irr_driver->getRTT(RTT_TMP2))->getOpenGLTextureName(), GL_NEAREST, GL_NEAREST);
|
||||
setTexture(3, static_cast<irr::video::COpenGLTexture*>(irr_driver->getRTT(RTT_SSAO))->getOpenGLTextureName(), GL_NEAREST, GL_NEAREST);
|
||||
if (!UserConfigParams::m_ssao)
|
||||
{
|
||||
GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ONE };
|
||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
||||
}
|
||||
|
||||
glUseProgram(MeshShader::ObjectRimLimitShader::Program);
|
||||
MeshShader::ObjectRimLimitShader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView, 0, 1, 2, 3);
|
||||
|
||||
glBindVertexArray(mesh.vao_second_pass);
|
||||
glDrawElements(ptype, count, itype, 0);
|
||||
}
|
||||
|
||||
void STKAnimatedMesh::drawSolid(const GLMesh &mesh, video::E_MATERIAL_TYPE type)
|
||||
{
|
||||
@ -51,6 +92,8 @@ void STKAnimatedMesh::drawSolid(const GLMesh &mesh, video::E_MATERIAL_TYPE type)
|
||||
|
||||
if (type == irr_driver->getShader(ES_OBJECTPASS_REF))
|
||||
drawObjectRefPass2(mesh, ModelViewProjectionMatrix);
|
||||
else if (type == irr_driver->getShader(ES_OBJECTPASS_RIMLIT))
|
||||
drawObjectRimLimit(mesh, ModelViewProjectionMatrix, TransposeInverseModelView);
|
||||
else
|
||||
drawObjectPass2(mesh, ModelViewProjectionMatrix);
|
||||
break;
|
||||
@ -69,6 +112,8 @@ isObjectPass(video::E_MATERIAL_TYPE type)
|
||||
return true;
|
||||
if (type == irr_driver->getShader(ES_OBJECTPASS_REF))
|
||||
return true;
|
||||
if (type == irr_driver->getShader(ES_OBJECTPASS_RIMLIT))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -123,7 +168,7 @@ void STKAnimatedMesh::render()
|
||||
if (isObjectPass(material.MaterialType))
|
||||
{
|
||||
initvaostate(GLmeshes[i], material.MaterialType);
|
||||
if (irr_driver->getPhase() == 1)
|
||||
if (irr_driver->getPhase() == 0)
|
||||
{
|
||||
glBindBuffer(GL_ARRAY_BUFFER, GLmeshes[i].vertex_buffer);
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, mb->getVertexCount() * GLmeshes[i].Stride, mb->getVertices());
|
||||
|
@ -20,7 +20,9 @@ public:
|
||||
const irr::core::vector3df& position = irr::core::vector3df(0,0,0),
|
||||
const irr::core::vector3df& rotation = irr::core::vector3df(0,0,0),
|
||||
const irr::core::vector3df& scale = irr::core::vector3df(1.0f, 1.0f, 1.0f));
|
||||
|
||||
virtual void render();
|
||||
virtual void setMesh(irr::scene::IAnimatedMesh* mesh);
|
||||
};
|
||||
|
||||
#endif // STKANIMATEDMESH_HPP
|
||||
|
@ -146,28 +146,49 @@ STKMesh::STKMesh(irr::scene::IMesh* mesh, ISceneNode* parent, irr::scene::IScene
|
||||
const irr::core::vector3df& scale) :
|
||||
CMeshSceneNode(mesh, parent, mgr, id, position, rotation, scale)
|
||||
{
|
||||
for (u32 i=0; i<Mesh->getMeshBufferCount(); ++i)
|
||||
createGLMeshes();
|
||||
}
|
||||
|
||||
void STKMesh::createGLMeshes()
|
||||
{
|
||||
for (u32 i = 0; i<Mesh->getMeshBufferCount(); ++i)
|
||||
{
|
||||
scene::IMeshBuffer* mb = Mesh->getMeshBuffer(i);
|
||||
GLmeshes.push_back(allocateMeshBuffer(mb));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void STKMesh::cleanGLMeshes()
|
||||
{
|
||||
for (u32 i = 0; i < GLmeshes.size(); ++i)
|
||||
{
|
||||
GLMesh mesh = GLmeshes[i];
|
||||
if (!mesh.vertex_buffer)
|
||||
continue;
|
||||
if (mesh.vao_first_pass)
|
||||
glDeleteVertexArrays(1, &(mesh.vao_first_pass));
|
||||
if (mesh.vao_second_pass)
|
||||
glDeleteVertexArrays(1, &(mesh.vao_second_pass));
|
||||
if (mesh.vao_glow_pass)
|
||||
glDeleteVertexArrays(1, &(mesh.vao_glow_pass));
|
||||
if (mesh.vao_displace_pass)
|
||||
glDeleteVertexArrays(1, &(mesh.vao_displace_pass));
|
||||
glDeleteBuffers(1, &(mesh.vertex_buffer));
|
||||
glDeleteBuffers(1, &(mesh.index_buffer));
|
||||
}
|
||||
GLmeshes.clear();
|
||||
}
|
||||
|
||||
void STKMesh::setMesh(irr::scene::IMesh* mesh)
|
||||
{
|
||||
CMeshSceneNode::setMesh(mesh);
|
||||
cleanGLMeshes();
|
||||
createGLMeshes();
|
||||
}
|
||||
|
||||
STKMesh::~STKMesh()
|
||||
{
|
||||
for (u32 i = 0; i < Mesh->getMeshBufferCount(); ++i)
|
||||
{
|
||||
scene::IMeshBuffer* mb = Mesh->getMeshBuffer(i);
|
||||
if (!mb)
|
||||
continue;
|
||||
GLMesh mesh = GLmeshes[i];
|
||||
glDeleteVertexArrays(1, &(mesh.vao_first_pass));
|
||||
glDeleteVertexArrays(1, &(mesh.vao_second_pass));
|
||||
glDeleteVertexArrays(1, &(mesh.vao_glow_pass));
|
||||
glDeleteBuffers(1, &(mesh.vertex_buffer));
|
||||
glDeleteBuffers(1, &(mesh.index_buffer));
|
||||
}
|
||||
cleanGLMeshes();
|
||||
}
|
||||
|
||||
void computeMVP(core::matrix4 &ModelViewProjectionMatrix)
|
||||
@ -711,6 +732,11 @@ void initvaostate(GLMesh &mesh, video::E_MATERIAL_TYPE type)
|
||||
mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
|
||||
MeshShader::ObjectRefPass2Shader::attrib_position, MeshShader::ObjectRefPass2Shader::attrib_texcoord, -1, -1, -1, -1, -1, mesh.Stride);
|
||||
}
|
||||
else if (type == irr_driver->getShader(ES_OBJECTPASS_RIMLIT))
|
||||
{
|
||||
mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
|
||||
MeshShader::ObjectRimLimitShader::attrib_position, MeshShader::ObjectRimLimitShader::attrib_texcoord, -1, MeshShader::ObjectRimLimitShader::attrib_normal, -1, -1, -1, mesh.Stride);
|
||||
}
|
||||
else if (type == irr_driver->getShader(ES_GRASS) || type == irr_driver->getShader(ES_GRASS_REF))
|
||||
{
|
||||
mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
|
||||
|
@ -58,12 +58,15 @@ protected:
|
||||
// Misc passes shaders (glow, displace...)
|
||||
void drawGlow(const GLMesh &mesh);
|
||||
void drawDisplace(const GLMesh &mesh);
|
||||
void createGLMeshes();
|
||||
void cleanGLMeshes();
|
||||
public:
|
||||
STKMesh(irr::scene::IMesh* mesh, ISceneNode* parent, irr::scene::ISceneManager* mgr, irr::s32 id,
|
||||
const irr::core::vector3df& position = irr::core::vector3df(0,0,0),
|
||||
const irr::core::vector3df& rotation = irr::core::vector3df(0,0,0),
|
||||
const irr::core::vector3df& scale = irr::core::vector3df(1.0f, 1.0f, 1.0f));
|
||||
virtual void render();
|
||||
virtual void setMesh(irr::scene::IMesh* mesh);
|
||||
~STKMesh();
|
||||
};
|
||||
|
||||
|
@ -45,6 +45,7 @@ m_frame_count(0)
|
||||
{
|
||||
m_curr_time = 0;
|
||||
m_prev_time = 0;
|
||||
m_throttle_fps = true;
|
||||
} // MainLoop
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -78,12 +79,14 @@ float MainLoop::getLimitedDt()
|
||||
// When in menus, reduce FPS much, it's not necessary to push to the maximum for plain menus
|
||||
const int max_fps = (StateManager::get()->throttleFPS() ? 35 : UserConfigParams::m_max_fps);
|
||||
const int current_fps = (int)(1000.0f/dt);
|
||||
if( current_fps > max_fps && !ProfileWorld::isProfileMode())
|
||||
if (m_throttle_fps && current_fps > max_fps && !ProfileWorld::isProfileMode())
|
||||
{
|
||||
int wait_time = 1000/max_fps - 1000/current_fps;
|
||||
if(wait_time < 1) wait_time = 1;
|
||||
|
||||
PROFILER_PUSH_CPU_MARKER("Throttle framerate", 0, 0, 0);
|
||||
StkTime::sleep(wait_time);
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
}
|
||||
else break;
|
||||
}
|
||||
@ -122,7 +125,9 @@ void MainLoop::run()
|
||||
|
||||
if (World::getWorld()) // race is active if world exists
|
||||
{
|
||||
PROFILER_PUSH_CPU_MARKER("Update race", 255, 0, 255);
|
||||
updateRace(dt);
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
} // if race is active
|
||||
|
||||
// We need to check again because update_race may have requested
|
||||
|
@ -29,6 +29,7 @@ class MainLoop
|
||||
{
|
||||
private:
|
||||
bool m_abort;
|
||||
bool m_throttle_fps;
|
||||
|
||||
int m_frame_count;
|
||||
Uint32 m_curr_time;
|
||||
@ -40,6 +41,7 @@ public:
|
||||
~MainLoop();
|
||||
void run();
|
||||
void abort();
|
||||
void setThrottleFPS(bool throttle) { m_throttle_fps = throttle; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns true if STK is to be stoppe. */
|
||||
bool isAborted() const { return m_abort; }
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include "physics/stk_dynamics_world.hpp"
|
||||
#include "physics/triangle_mesh.hpp"
|
||||
#include "tracks/track.hpp"
|
||||
#include "utils/profiler.hpp"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Initialise physics.
|
||||
@ -135,6 +136,8 @@ void Physics::removeKart(const AbstractKart *kart)
|
||||
*/
|
||||
void Physics::update(float dt)
|
||||
{
|
||||
PROFILER_PUSH_CPU_MARKER("Physics", 0, 0, 0);
|
||||
|
||||
m_physics_loop_active = true;
|
||||
// Bullet can report the same collision more than once (up to 4
|
||||
// contact points per collision). Additionally, more than one internal
|
||||
@ -275,6 +278,8 @@ void Physics::update(float dt)
|
||||
for(unsigned int i=0; i<m_karts_to_delete.size(); i++)
|
||||
removeKart(m_karts_to_delete[i]);
|
||||
m_karts_to_delete.clear();
|
||||
|
||||
PROFILER_POP_CPU_MARKER("Physics", 0, 0, 0);
|
||||
} // update
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "physics/irr_debug_drawer.hpp"
|
||||
#include "physics/physics.hpp"
|
||||
#include "race/history.hpp"
|
||||
#include "main_loop.hpp"
|
||||
#include "replay/replay_recorder.hpp"
|
||||
#include "utils/log.hpp"
|
||||
#include <IGUIEnvironment.h>
|
||||
@ -69,7 +70,8 @@ enum DebugMenuCommand
|
||||
DEBUG_POWERUP_SWITCH,
|
||||
DEBUG_POWERUP_ZIPPER,
|
||||
DEBUG_POWERUP_NITRO,
|
||||
DEBUG_TOGGLE_GUI
|
||||
DEBUG_TOGGLE_GUI,
|
||||
DEBUG_THROTTLE_FPS
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@ -133,6 +135,7 @@ bool onEvent(const SEvent &event)
|
||||
sub->addItem(L"Nitro", DEBUG_POWERUP_NITRO );
|
||||
|
||||
mnu->addItem(L"Profiler",DEBUG_PROFILER);
|
||||
mnu->addItem(L"Do not limit FPS", DEBUG_THROTTLE_FPS);
|
||||
mnu->addItem(L"FPS",DEBUG_FPS);
|
||||
mnu->addItem(L"Save replay", DEBUG_SAVE_REPLAY);
|
||||
mnu->addItem(L"Save history", DEBUG_SAVE_HISTORY);
|
||||
@ -251,6 +254,10 @@ bool onEvent(const SEvent &event)
|
||||
UserConfigParams::m_profiler_enabled =
|
||||
!UserConfigParams::m_profiler_enabled;
|
||||
}
|
||||
else if (cmdID == DEBUG_THROTTLE_FPS)
|
||||
{
|
||||
main_loop->setThrottleFPS(false);
|
||||
}
|
||||
else if (cmdID == DEBUG_FPS)
|
||||
{
|
||||
UserConfigParams::m_display_fps =
|
||||
|
@ -225,7 +225,8 @@ void Profiler::draw()
|
||||
}
|
||||
}
|
||||
|
||||
const double factor = profiler_width / (end - start);
|
||||
const double duration = end - start;
|
||||
const double factor = profiler_width / duration;
|
||||
|
||||
// Get the mouse pos
|
||||
core::vector2di mouse_pos = GUIEngine::EventHandler::get()->getMousePos();
|
||||
@ -281,7 +282,10 @@ void Profiler::draw()
|
||||
{
|
||||
Marker& m = hovered_markers.top();
|
||||
std::ostringstream oss;
|
||||
oss << m.name << " [" << (m.end-m.start) << " ms]" << std::endl;
|
||||
oss.precision(4);
|
||||
oss << m.name << " [" << (m.end - m.start) << " ms / ";
|
||||
oss.precision(3);
|
||||
oss << (m.end - m.start)*100.0 / duration << "%]" << std::endl;
|
||||
text += oss.str().c_str();
|
||||
hovered_markers.pop();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user