Merge remote-tracking branch 'upstream/master' into new_login

Conflicts:
	src/challenges/game_slot.cpp
	src/states_screens/kart_selection.cpp
	src/tracks/track.cpp
This commit is contained in:
hiker 2014-02-10 21:37:04 +11:00
commit 8b7754cd4f
95 changed files with 1590 additions and 1540 deletions

2
.gitignore vendored
View File

@ -1,3 +1,4 @@
bld/
build/ build/
build-32/ build-32/
build-64/ build-64/
@ -37,3 +38,4 @@ data/.svn
packets_log.txt packets_log.txt
history.dat history.dat
README.dependencies

View File

@ -1,4 +1,6 @@
#SuperTuxKart #SuperTuxKart
[![Build Status](https://travis-ci.org/supertuxkart/stk-code.png?branch=master)](https://travis-ci.org/supertuxkart/stk-code)
SuperTuxKart is a free kart racing game. It is focusing on fun and SuperTuxKart is a free kart racing game. It is focusing on fun and
not on realistic kart physics. Instruction can be found on the not on realistic kart physics. Instruction can be found on the
in-game help page. in-game help page.

View File

@ -11,7 +11,7 @@ void main()
vec3 col = texture(tex, uv).xyz; vec3 col = texture(tex, uv).xyz;
float luma = dot(weights, col); float luma = dot(weights, col);
col *= smoothstep(low, 0.9, luma); col *= smoothstep(1., 2., luma);
FragColor = vec4(col, 1.0); FragColor = vec4(col, 1.0);
} }

View File

@ -7,7 +7,6 @@ uniform float endH;
uniform float start; uniform float start;
uniform float end; uniform float end;
uniform vec3 col; uniform vec3 col;
uniform vec3 campos;
uniform mat4 ipvmat; uniform mat4 ipvmat;
in vec2 uv; in vec2 uv;
@ -24,9 +23,8 @@ void main()
xpos = ipvmat * xpos; xpos = ipvmat * xpos;
xpos.xyz /= xpos.w; xpos.xyz /= xpos.w;
float dist = distance(campos, xpos.xyz); float dist = length(xpos.xyz);
float fog = smoothstep(start, end, dist); float fog = smoothstep(start, end, dist);
fog *= 1.0 - smoothstep(startH, endH, xpos.y);
fog = min(fog, fogmax); fog = min(fog, fogmax);

View File

@ -1,17 +0,0 @@
#version 130
uniform float far;
uniform float objectid;
uniform sampler2D tex;
noperspective in vec3 nor;
in vec2 uv;
out vec4 Albedo;
out vec4 NormalDepth;
out vec4 Specular;
void main()
{
Albedo = texture(tex, uv);
NormalDepth = vec4(0.5 * normalize(nor) + 0.5, gl_FragCoord.z);
Specular = vec4(0.);
}

View File

@ -1,18 +0,0 @@
#version 130
uniform vec3 windDir;
uniform mat4 ModelViewProjectionMatrix;
uniform mat4 TransposeInverseModelView;
noperspective out vec3 nor;
out vec2 uv;
void main()
{
uv = gl_MultiTexCoord0.st;
vec4 vertexPosition = gl_Vertex;
vertexPosition.xyz += windDir * gl_Color.r;
nor = (TransposeInverseModelView * vec4(gl_Normal, 1.)).xyz;
gl_Position = ModelViewProjectionMatrix * vertexPosition;
}

View File

@ -1,39 +0,0 @@
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2013 the SuperTuxKart team
//
// 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.
// Jean-manuel clemencon (c) supertuxkart 2013
// bubble gum shield
// TODO: Add a nice texture and soft edges when intersect with geometry
#version 130
uniform sampler2D tex;
uniform float transparency;
in vec2 uv;
noperspective in vec3 eyeVec;
noperspective in vec3 normal;
out vec4 FragColor;
void main()
{
float inter = dot(normal, eyeVec);
float m = texture(tex, vec2(0.5, uv.y)).r;
inter = 1.0 - inter;
float alpha = inter + 1.0;// * m;
FragColor = vec4(0.8, 0.16, 0.48, alpha);
}

View File

@ -1,43 +0,0 @@
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2013 the SuperTuxKart team
//
// 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.
// Jean-manuel clemencon (c) supertuxkart 2013
// Creates a bubble gum shield effect
// ---
// TODO: The texture should reflect the strength of the shield,
// such that the user gets to know whether the shield has several
// "layers" or whether the shield is about to break.
#version 130
uniform mat4 ModelViewMatrix;
uniform mat4 ProjectionMatrix;
uniform mat4 TransposeInverseModelView;
out vec2 uv;
noperspective out vec3 eyeVec;
noperspective out vec3 normal;
void main()
{
vec4 viewp = ModelViewMatrix * gl_Vertex;
eyeVec = normalize(-viewp).xyz;
normal = (TransposeInverseModelView * vec4(gl_Normal, 1.).xyz;
gl_Position = ProjectionMatrix * viewp;
uv = (gl_TextureMatrix[0] * gl_MultiTexCoord0).st;
}

View File

@ -1,40 +0,0 @@
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2013 the SuperTuxKart team
//
// 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.
// Jean-manuel clemencon supertuxkart
// Creates a cone lightbeam effect by smoothing edges
// Original idea: http://udn.epicgames.com/Three/VolumetricLightbeamTutorial.html
// TODO: Soft edges when it intesects geometry
// Some artefacts are still visible
#version 130
uniform sampler2D tex;
uniform float transparency;
in vec2 uv;
noperspective in vec3 eyeVec;
noperspective in vec3 normal;
out vec4 FragColor;
void main()
{
float inter = dot(normal, eyeVec);
float m = texture(tex, vec2(0.5, uv.y)).r;
float alpha = inter * inter * inter * inter * m;
FragColor = vec4(1.0, 1.0, 0.8, alpha);
}

View File

@ -1,39 +0,0 @@
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2013 the SuperTuxKart team
//
// 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.
// Jean-manuel clemencon (C) Copyright supertuxkart
// Creates a cone lightbeam effect by smoothing edges
#version 130
uniform mat4 ModelViewMatrix;
uniform mat4 ProjectionMatrix;
uniform mat4 TransposeInverseModelView;
out vec2 uv;
noperspective out vec3 eyeVec;
noperspective out vec3 normal;
void main()
{
vec4 viewp = ModelViewMatrix * gl_Vertex;
eyeVec = normalize(-viewp).xyz;
normal = (TransposeInverseModelView * vec4(gl_Normal, 1.).xyz;
gl_Position = ProjectionMatrix * viewp;
uv = gl_MultiTexCoord0.st;
}

View File

@ -1,21 +0,0 @@
#version 130
uniform sampler2D diffuse;
uniform sampler2D specular;
uniform sampler2D ambient_occlusion;
uniform sampler2D specular_map;
uniform vec3 ambient;
in vec2 uv;
out vec4 FragColor;
void main()
{
vec2 texc = uv;
vec3 diffuse = texture(diffuse, texc).xyz;
vec3 spec = texture(specular, texc).xyz;
float specmap = texture(specular_map, texc).x;
float ao = texture(ambient_occlusion, texc).x;
FragColor = vec4(diffuse + spec * specmap + ao * ambient, 1.0);
}

View File

@ -12,7 +12,6 @@ uniform mat4 invproj;
in vec2 uv; in vec2 uv;
out vec4 Diff; out vec4 Diff;
out vec4 Spec; out vec4 Spec;
out vec4 SpecularMap;
vec3 DecodeNormal(vec2 n) vec3 DecodeNormal(vec2 n)
{ {
@ -58,5 +57,4 @@ void main() {
Diff = vec4(NdotL * col, 1.); Diff = vec4(NdotL * col, 1.);
Spec = vec4(Specular * col, 1.); Spec = vec4(Specular * col, 1.);
SpecularMap = vec4(1.0);
} }

View File

@ -1,95 +1,92 @@
#version 130 #version 130
uniform sampler2D ntex; uniform sampler2D ntex;
uniform sampler2D dtex; uniform sampler2D dtex;
uniform sampler2D cloudtex; uniform sampler2DShadow shadowtex;
uniform sampler2D shadowtex; //uniform sampler2D warpx;
uniform sampler2D warpx; ///uniform sampler2D warpy;
uniform sampler2D warpy;
uniform vec3 center; uniform vec3 direction;
uniform vec3 col; uniform vec3 col;
uniform vec2 screen; uniform mat4 invproj;
uniform mat4 invprojview;
uniform mat4 shadowmat; uniform mat4 shadowmat;
uniform int hasclouds; //uniform int hasclouds;
uniform vec2 wind; //uniform vec2 wind;
uniform float shadowoffset; //uniform float shadowoffset;
out vec4 FragColor; in vec2 uv;
out vec4 OtherOutput; out vec4 Diff;
out vec4 Spec;
float decdepth(vec4 rgba) { vec3 DecodeNormal(vec2 n)
return dot(rgba, vec4(1.0, 1.0/255.0, 1.0/65025.0, 1.0/16581375.0)); {
float z = dot(n, n) * 2. - 1.;
vec2 xy = normalize(n) * sqrt(1. - z * z);
return vec3(xy,z);
} }
void main() { void main() {
float z = texture(dtex, uv).x;
vec2 texc = gl_FragCoord.xy / screen; vec4 xpos = 2.0 * vec4(uv, z, 1.0) - 1.0;
vec4 depthread = texture(dtex, texc); xpos = invproj * xpos;
float z = decdepth(vec4(depthread.xyz, 0.0)); xpos.xyz /= xpos.w;
if (z < 0.03) if (z < 0.03)
{ {
// Skyboxes are fully lit // Skyboxes are fully lit
FragColor = vec4(1.0); Diff = vec4(1.0);
OtherOutput = vec4(0.0); Spec = vec4(1.0);
return; return;
} }
vec3 norm = texture(ntex, texc).xyz; vec3 norm = normalize(DecodeNormal(2. * texture(ntex, uv).xy - 1.));
norm = (norm - 0.5) * 2.0;
// Normalized on the cpu // Normalized on the cpu
vec3 L = center; vec3 L = direction;
float NdotL = max(0.0, dot(norm, L)); float NdotL = max(0.0, dot(norm, L));
if (NdotL < 0.01) discard; vec3 R = reflect(L, norm);
float RdotE = max(0.0, dot(R, normalize(xpos.xyz)));
float Specular = pow(RdotE, 200);
vec3 outcol = NdotL * col; vec3 outcol = NdotL * col;
// World-space position // if (hasclouds == 1)
vec3 tmp = vec3(texc, z); // {
tmp = tmp * 2.0 - 1.0; // vec2 cloudcoord = (xpos.xz * 0.00833333) + wind;
// float cloud = texture(cloudtex, cloudcoord).x;
// //float cloud = step(0.5, cloudcoord.x) * step(0.5, cloudcoord.y);
vec4 xpos = vec4(tmp, 1.0); // outcol *= cloud;
xpos = invprojview * xpos; // }
xpos.xyz /= xpos.w;
if (hasclouds == 1)
{
vec2 cloudcoord = (xpos.xz * 0.00833333) + wind;
float cloud = texture(cloudtex, cloudcoord).x;
//float cloud = step(0.5, cloudcoord.x) * step(0.5, cloudcoord.y);
outcol *= cloud;
}
// Shadows // Shadows
vec3 shadowcoord = (shadowmat * vec4(xpos.xyz, 1.0)).xyz; vec4 shadowcoord = (shadowmat * vec4(xpos.xyz, 1.0));
shadowcoord = (shadowcoord * 0.5) + vec3(0.5); shadowcoord /= shadowcoord.w;
vec2 shadowtexcoord = shadowcoord.xy * 0.5 + 0.5;
// shadowcoord = (shadowcoord * 0.5) + vec3(0.5);
float movex = decdepth(texture(warpx, shadowcoord.xy)); // float movex = decdepth(texture(warpx, shadowcoord.xy));
float movey = decdepth(texture(warpy, shadowcoord.xy)); // float movey = decdepth(texture(warpy, shadowcoord.xy));
float dx = movex * 2.0 - 1.0; // float dx = movex * 2.0 - 1.0;
float dy = movey * 2.0 - 1.0; // float dy = movey * 2.0 - 1.0;
shadowcoord.xy += vec2(dx, dy); // shadowcoord.xy += vec2(dx, dy);*/
vec4 shadowread = texture(shadowtex, shadowcoord.xy); //float shadowmapz = 2. * texture(shadowtex, vec3(shadowtexcoord, shadowcoord.z).x - 1.;
float shadowmapz = decdepth(vec4(shadowread.xyz, 0.0));
float moved = (abs(dx) + abs(dy)) * 0.5;
/*
float bias = 0.002 * tan(acos(NdotL)); // According to the slope float bias = 0.002 * tan(acos(NdotL)); // According to the slope
bias += smoothstep(0.001, 0.1, moved) * 0.014; // According to the warping // bias += smoothstep(0.001, 0.1, moved) * 0.014; // According to the warping
bias = clamp(bias, 0.001, 0.014); bias = clamp(bias, 0.001, 0.014);
*/ float factor = texture(shadowtex, vec3(shadowtexcoord, 0.5 * (shadowcoord.z + bias) + 0.5));
/*
float avi = 0.002;
float abi = 0.0025; */
float avi = 0.0018; Diff = vec4(factor * NdotL * col, 1.);
Spec = vec4(factor * Specular * col, 1.);
return;
// float moved = (abs(dx) + abs(dy)) * 0.5;
// float avi = 0.002;
// float abi = 0.0025;
/* float avi = 0.0018;
float abi = 0.002; float abi = 0.002;
float bias = avi * tan(acos(NdotL)); // According to the slope float bias = avi * tan(acos(NdotL)); // According to the slope
@ -113,11 +110,11 @@ void main() {
float shadowed = step(shadowmapz + bias, shadowcoord.z); float shadowed = step(shadowmapz + bias, shadowcoord.z);
float dist = (shadowcoord.z / shadowmapz) - 1.0; float dist = (shadowcoord.z / shadowmapz) - 1.0;
float penumbra = dist * softness / gl_FragCoord.z; float penumbra = dist * softness / gl_FragCoord.z;
penumbra *= shadowed; penumbra *= shadowed;*/
/* outcol.r = (shadowcoord.z - shadowmapz) * 50.0; /* outcol.r = (shadowcoord.z - shadowmapz) * 50.0;
outcol.g = moved;*/ outcol.g = moved;*/
FragColor = vec4(outcol, 0.05); // FragColor = vec4(outcol, 0.05);
OtherOutput = vec4(shadowed, penumbra, shadowed, shadowed); // OtherOutput = vec4(shadowed, penumbra, shadowed, shadowed);
} }

View File

@ -0,0 +1,32 @@
#version 130
uniform sampler2D tex;
uniform float fogmax;
uniform float startH;
uniform float endH;
uniform float start;
uniform float end;
uniform vec3 col;
uniform mat4 ipvmat;
uniform vec2 screen;
in vec2 uv;
out vec4 FragColor;
void main()
{
vec4 color = texture(tex, uv);
vec3 tmp = vec3(gl_FragCoord.xy / screen, gl_FragCoord.z);
tmp = 2. * tmp - 1.;
vec4 xpos = vec4(tmp, 1.0);
xpos = ipvmat * xpos;
xpos.xyz /= xpos.w;
float dist = length(xpos.xyz);
float fog = smoothstep(start, end, dist);
fog = min(fog, fogmax);
FragColor = vec4(vec4(col, 0.) * fog + color *(1. - fog));
}

View File

@ -210,11 +210,13 @@ CIrrDeviceLinux::~CIrrDeviceLinux()
} }
#if defined(_IRR_COMPILE_WITH_X11_) && defined(_DEBUG) #if defined(_IRR_COMPILE_WITH_X11_)
static bool XErrorSignaled = false;
int IrrPrintXError(Display *display, XErrorEvent *event) int IrrPrintXError(Display *display, XErrorEvent *event)
{ {
char msg[256]; char msg[256];
char msg2[256]; char msg2[256];
XErrorSignaled = true;
snprintf(msg, 256, "%d", event->request_code); snprintf(msg, 256, "%d", event->request_code);
XGetErrorDatabaseText(display, "XRequest", msg, "unknown", msg2, 256); XGetErrorDatabaseText(display, "XRequest", msg, "unknown", msg2, 256);
@ -370,10 +372,8 @@ void IrrPrintXGrabError(int grabResult, const c8 * grabCommand )
bool CIrrDeviceLinux::createWindow() bool CIrrDeviceLinux::createWindow()
{ {
#ifdef _IRR_COMPILE_WITH_X11_ #ifdef _IRR_COMPILE_WITH_X11_
#ifdef _DEBUG
os::Printer::log("Creating X window...", ELL_INFORMATION); os::Printer::log("Creating X window...", ELL_INFORMATION);
XSetErrorHandler(IrrPrintXError); XSetErrorHandler(IrrPrintXError);
#endif
display = XOpenDisplay(0); display = XOpenDisplay(0);
if (!display) if (!display)
@ -750,12 +750,22 @@ bool CIrrDeviceLinux::createWindow()
GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB, GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB,
None None
}; };
PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB = 0; PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB = 0;
glXCreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC) glXCreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)
glXGetProcAddressARB( (const GLubyte *) "glXCreateContextAttribsARB" ); glXGetProcAddressARB( (const GLubyte *) "glXCreateContextAttribsARB" );
// create glx context // create glx context
Context = glXCreateContextAttribsARB(display, glxFBConfig, 0, True, context_attribs); Context = glXCreateContextAttribsARB(display, glxFBConfig, 0, True, context_attribs);
if (XErrorSignaled)
{
int context_attribs[] =
{
GLX_CONTEXT_MAJOR_VERSION_ARB, 2,
GLX_CONTEXT_MINOR_VERSION_ARB, 1,
None
};
Context = glXCreateContextAttribsARB(display, glxFBConfig, 0, True, context_attribs);
XErrorSignaled = false;
}
if (Context) if (Context)
{ {
if (!glXMakeContextCurrent(display, glxWin, glxWin, Context)) if (!glXMakeContextCurrent(display, glxWin, glxWin, Context))

View File

@ -4397,12 +4397,6 @@ IImage* COpenGLDriver::createScreenShot(video::ECOLOR_FORMAT format, video::E_RE
if (target==video::ERT_MULTI_RENDER_TEXTURES || target==video::ERT_RENDER_TEXTURE || target==video::ERT_STEREO_BOTH_BUFFERS) if (target==video::ERT_MULTI_RENDER_TEXTURES || target==video::ERT_RENDER_TEXTURE || target==video::ERT_STEREO_BOTH_BUFFERS)
return 0; return 0;
// allows to read pixels in top-to-bottom order
#ifdef GL_MESA_pack_invert
if (FeatureAvailable[IRR_MESA_pack_invert])
glPixelStorei(GL_PACK_INVERT_MESA, GL_TRUE);
#endif
if (format==video::ECF_UNKNOWN) if (format==video::ECF_UNKNOWN)
format=getColorFormat(); format=getColorFormat();
GLenum fmt; GLenum fmt;
@ -4542,11 +4536,6 @@ IImage* COpenGLDriver::createScreenShot(video::ECOLOR_FORMAT format, video::E_RE
glReadBuffer(GL_BACK); glReadBuffer(GL_BACK);
} }
#ifdef GL_MESA_pack_invert
if (FeatureAvailable[IRR_MESA_pack_invert])
glPixelStorei(GL_PACK_INVERT_MESA, GL_FALSE);
else
#endif
if (pixels) if (pixels)
{ {
// opengl images are horizontally flipped, so we have to fix that here. // opengl images are horizontally flipped, so we have to fix that here.

View File

@ -61,9 +61,9 @@
#include <GL/gl.h> #include <GL/gl.h>
#include <GL/glx.h> #include <GL/glx.h>
#if defined(_IRR_OPENGL_USE_EXTPOINTER_) #if defined(_IRR_OPENGL_USE_EXTPOINTER_)
#include "glext.h" #include <GL/glext.h>
#undef GLX_ARB_get_proc_address // avoid problems with local glxext.h #undef GLX_ARB_get_proc_address // avoid problems with local glxext.h
#include "glxext.h" #include <GL/glxext.h>
#endif #endif
#endif #endif

View File

@ -362,6 +362,7 @@ src/graphics/CBatchingMesh.hpp
src/graphics/explosion.hpp src/graphics/explosion.hpp
src/graphics/glow.hpp src/graphics/glow.hpp
src/graphics/glwrap.hpp src/graphics/glwrap.hpp
src/graphics/gpuparticles.hpp
src/graphics/hardware_skinning.hpp src/graphics/hardware_skinning.hpp
src/graphics/hit_effect.hpp src/graphics/hit_effect.hpp
src/graphics/hit_sfx.hpp src/graphics/hit_sfx.hpp

View File

@ -131,13 +131,14 @@ MapAchievement::MapAchievement(const AchievementInfo * info)
// ============================================================================ // ============================================================================
void MapAchievement::load(XMLNode * input) void MapAchievement::load(XMLNode * input)
{ {
std::string achieved(""); bool achieved = false;
input->get("achieved", &achieved); input->get("achieved", &achieved);
if(achieved == "true") if(achieved)
{ {
m_achieved = true; m_achieved = true;
return; return;
} }
std::vector<XMLNode*> xml_entries; std::vector<XMLNode*> xml_entries;
input->getNodes("entry", xml_entries); input->getNodes("entry", xml_entries);
for (unsigned int n=0; n < xml_entries.size(); n++) for (unsigned int n=0; n < xml_entries.size(); n++)

View File

@ -194,7 +194,7 @@ void AddonsManager::initAddons(const XMLNode *xml)
if(file_manager->fileExists(full_path)) if(file_manager->fileExists(full_path))
{ {
if(UserConfigParams::logAddons()) if(UserConfigParams::logAddons())
Log::warn("[addons] Removing cached icon '%s'.\n", Log::warn("[AddonsManager] Removing cached icon '%s'.\n",
addon.getIconBasename().c_str()); addon.getIconBasename().c_str());
file_manager->removeFile(full_path); file_manager->removeFile(full_path);
} }
@ -225,10 +225,9 @@ void AddonsManager::initAddons(const XMLNode *xml)
} }
else else
{ {
fprintf(stderr, Log::error("[AddonsManager]", "Found invalid node '%s' while downloading addons.",
"[addons] Found invalid node '%s' while downloading addons.\n",
node->getName().c_str()); node->getName().c_str());
fprintf(stderr, "[addons] Ignored.\n"); Log::error("[AddonsManager]", "Ignored.");
} }
} // for i<xml->getNumNodes } // for i<xml->getNumNodes
delete xml; delete xml;
@ -254,7 +253,7 @@ void AddonsManager::initAddons(const XMLNode *xml)
// it from the list. // it from the list.
if(UserConfigParams::logAddons()) if(UserConfigParams::logAddons())
Log::warn( Log::warn(
"[addons] Removing '%s' which is not on the server anymore.\n", "[AddonsManager] Removing '%s' which is not on the server anymore.\n",
m_addons_list.getData()[i].getId().c_str() ); m_addons_list.getData()[i].getId().c_str() );
std::string icon = m_addons_list.getData()[i].getIconBasename(); std::string icon = m_addons_list.getData()[i].getIconBasename();
std::string icon_file =file_manager->getAddonsFile("icons/"+icon); std::string icon_file =file_manager->getAddonsFile("icons/"+icon);
@ -311,7 +310,7 @@ void AddonsManager::checkInstalledAddons()
if(n<0) continue; if(n<0) continue;
if(!m_addons_list.getData()[n].isInstalled()) if(!m_addons_list.getData()[n].isInstalled())
{ {
Log::info("[addons] Marking '%s' as being installed.\n", Log::info("[AddonsManager] Marking '%s' as being installed.",
kp->getIdent().c_str()); kp->getIdent().c_str());
m_addons_list.getData()[n].setInstalled(true); m_addons_list.getData()[n].setInstalled(true);
something_was_changed = true; something_was_changed = true;
@ -330,7 +329,7 @@ void AddonsManager::checkInstalledAddons()
if(n<0) continue; if(n<0) continue;
if(!m_addons_list.getData()[n].isInstalled()) if(!m_addons_list.getData()[n].isInstalled())
{ {
Log::info("[addons] Marking '%s' as being installed.\n", Log::info("[AddonsManager] Marking '%s' as being installed.",
track->getIdent().c_str()); track->getIdent().c_str());
m_addons_list.getData()[n].setInstalled(true); m_addons_list.getData()[n].setInstalled(true);
something_was_changed = true; something_was_changed = true;
@ -361,9 +360,8 @@ void AddonsManager::downloadIcons()
if(icon=="") if(icon=="")
{ {
if(UserConfigParams::logAddons()) if(UserConfigParams::logAddons())
fprintf(stderr, Log::error("[AddonsManager]", "No icon or image specified for '%s'.",
"[addons] No icon or image specified for '%s'.\n", addon.getId().c_str());
addon.getId().c_str());
continue; continue;
} }
@ -401,8 +399,8 @@ void AddonsManager::loadInstalledAddons()
/* checking for installed addons */ /* checking for installed addons */
if(UserConfigParams::logAddons()) if(UserConfigParams::logAddons())
{ {
std::cout << "[addons] Loading an xml file for installed addons: "; Log::info("[AddonsManager]", "Loading an xml file for installed addons: %s",
std::cout << m_file_installed << std::endl; m_file_installed.c_str());
} }
const XMLNode *xml = file_manager->createXMLTree(m_file_installed); const XMLNode *xml = file_manager->createXMLTree(m_file_installed);
if(!xml) if(!xml)
@ -479,16 +477,16 @@ bool AddonsManager::install(const Addon &addon)
if (!success) if (!success)
{ {
// TODO: show a message in the interface // TODO: show a message in the interface
std::cerr << "[addons] Failed to unzip '" << from << "' to '" Log::error("[AddonsManager]", "Failed to unzip '%s' to '%s'",
<< to << "'\n"; from.c_str(), to.c_str());
std::cerr << "[addons] Zip file will not be removed.\n"; Log::error("[AddonsManager]", "Zip file will not be removed.");
return false; return false;
} }
if(!file_manager->removeFile(from)) if(!file_manager->removeFile(from))
{ {
std::cerr << "[addons] Problems removing temporary file '" Log::error("[AddonsManager]", "Problems removing temporary file '%s'",
<< from << "'.\n"; from.c_str());
} }
int index = getAddonIndex(addon.getId()); int index = getAddonIndex(addon.getId());
@ -521,8 +519,8 @@ bool AddonsManager::install(const Addon &addon)
} }
catch (std::exception& e) catch (std::exception& e)
{ {
fprintf(stderr, "[AddonsManager] ERROR: Cannot load track <%s> : %s\n", Log::error("[AddonsManager]", "ERROR: Cannot load track <%s> : %s",
addon.getDataDir().c_str(), e.what()); addon.getDataDir().c_str(), e.what());
} }
} }
saveInstalled(); saveInstalled();
@ -536,8 +534,8 @@ bool AddonsManager::install(const Addon &addon)
*/ */
bool AddonsManager::uninstall(const Addon &addon) bool AddonsManager::uninstall(const Addon &addon)
{ {
std::cout << "[addons] Uninstalling <" Log::info("[AddonsManager]", "Uninstalling <%s>",
<< core::stringc(addon.getName()).c_str() << ">\n"; core::stringc(addon.getName()).c_str());
// addon is a const reference, and to avoid removing the const, we // addon is a const reference, and to avoid removing the const, we
// find the proper index again to modify the installed state // find the proper index again to modify the installed state

View File

@ -208,10 +208,8 @@ void NewsManager::checkRedirect(const XMLNode *xml)
{ {
if(UserConfigParams::logAddons()) if(UserConfigParams::logAddons())
{ {
std::cout << "[Addons] Current server: " Log::info("[Addons]", "Current server: '%s'\n [Addons] New server: '%s'",
<< (std::string)UserConfigParams::m_server_addons UserConfigParams::m_server_addons.c_str(), new_server.c_str());
<< std::endl
<< "[Addons] New server: " << new_server << std::endl;
} }
UserConfigParams::m_server_addons = new_server; UserConfigParams::m_server_addons = new_server;
} }

View File

@ -265,8 +265,10 @@ void GameSlot::grandPrixFinished()
*/ */
void GameSlot::save(UTFWriter &out) void GameSlot::save(UTFWriter &out)
{ {
out << L" <game-slot playerID=\"" << m_player_unique_id out << " <gameslot playerID=\"" << m_player_unique_id.c_str()
<< L"\" firstTime=\"" << m_first_time << L"\">\n"; << "\" kart=\"" << m_kart_ident.c_str()
<< "\" firstTime=\"" << StringUtils::toString(m_first_time)
<< "\"> <!-- " << name.c_str() << " -->\n";
std::map<std::string, Challenge*>::const_iterator i; std::map<std::string, Challenge*>::const_iterator i;
for(i = m_challenges_state.begin(); for(i = m_challenges_state.begin();
i != m_challenges_state.end(); i++) i != m_challenges_state.end(); i++)

View File

@ -254,13 +254,6 @@ void ColorizeProvider::OnSetConstants(IMaterialRendererServices *srv, int)
//------------------------------------- //-------------------------------------
void GlowProvider::OnSetConstants(IMaterialRendererServices *srv, int)
{
srv->setVertexShaderConstant("res", m_res, 2);
}
//-------------------------------------
void ObjectPassProvider::OnSetConstants(IMaterialRendererServices *srv, int) void ObjectPassProvider::OnSetConstants(IMaterialRendererServices *srv, int)
{ {
core::matrix4 ModelViewProjectionMatrix = srv->getVideoDriver()->getTransform(ETS_PROJECTION); core::matrix4 ModelViewProjectionMatrix = srv->getVideoDriver()->getTransform(ETS_PROJECTION);

View File

@ -328,23 +328,6 @@ private:
// //
class GlowProvider: public CallBase
{
public:
virtual void OnSetConstants(video::IMaterialRendererServices *srv, int);
void setResolution(int x, int y)
{
m_res[0] = (float)x;
m_res[1] = (float)y;
}
private:
float m_res[2];
};
//
class ObjectPassProvider: public CallBase class ObjectPassProvider: public CallBase
{ {
public: public:

View File

@ -39,15 +39,6 @@ GlowNode::GlowNode(scene::ISceneManager* mgr, float radius): ISceneNode(mgr->get
{ {
if (!sphere) if (!sphere)
{ {
mat.Lighting = false;
mat.MaterialType = irr_driver->getShader(ES_GLOW);
mat.setTexture(0, irr_driver->getRTT(RTT_QUARTER1));
mat.TextureLayer[0].TextureWrapU =
mat.TextureLayer[0].TextureWrapV = ETC_CLAMP_TO_EDGE;
mat.setFlag(EMF_TRILINEAR_FILTER, true);
mat.BlendOperation = EBO_ADD;
sphere = mgr->getGeometryCreator()->createSphereMesh(1, 4, 4); sphere = mgr->getGeometryCreator()->createSphereMesh(1, 4, 4);
box = sphere->getBoundingBox(); box = sphere->getBoundingBox();
} }
@ -65,10 +56,5 @@ void GlowNode::render()
void GlowNode::OnRegisterSceneNode() void GlowNode::OnRegisterSceneNode()
{ {
if (IsVisible)
{
SceneManager->registerNodeForRendering(this, ESNRP_TRANSPARENT);
}
ISceneNode::OnRegisterSceneNode();
} }

View File

@ -2,6 +2,7 @@
#include "irr_driver.hpp" #include "irr_driver.hpp"
#include <fstream> #include <fstream>
#include <string> #include <string>
#include "config/user_config.hpp"
#ifdef _IRR_WINDOWS_API_ #ifdef _IRR_WINDOWS_API_
#define IRR_OGL_LOAD_EXTENSION(X) wglGetProcAddress(reinterpret_cast<const char*>(X)) #define IRR_OGL_LOAD_EXTENSION(X) wglGetProcAddress(reinterpret_cast<const char*>(X))
@ -273,7 +274,7 @@ void bindUniformToTextureUnit(GLuint location, GLuint texid, unsigned textureUni
glUniform1i(location, textureUnit); glUniform1i(location, textureUnit);
} }
void setTexture(unsigned TextureUnit, GLuint TextureId, GLenum MagFilter, GLenum MinFilter) void setTexture(unsigned TextureUnit, GLuint TextureId, GLenum MagFilter, GLenum MinFilter, bool allowAF)
{ {
glActiveTexture(GL_TEXTURE0 + TextureUnit); glActiveTexture(GL_TEXTURE0 + TextureUnit);
glBindTexture(GL_TEXTURE_2D, TextureId); glBindTexture(GL_TEXTURE_2D, TextureId);
@ -281,6 +282,7 @@ void setTexture(unsigned TextureUnit, GLuint TextureId, GLenum MagFilter, GLenum
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, MinFilter); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, MinFilter);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, allowAF ? UserConfigParams::m_anisotropic : 0);
} }
static void drawTexColoredQuad(const video::ITexture *texture, const video::SColor *col, float width, float height, static void drawTexColoredQuad(const video::ITexture *texture, const video::SColor *col, float width, float height,

View File

@ -22,7 +22,7 @@ void initGL();
GLuint LoadProgram(const char * vertex_file_path, const char * fragment_file_path); GLuint LoadProgram(const char * vertex_file_path, const char * fragment_file_path);
GLuint LoadTFBProgram(const char * vertex_file_path, const char **varyings, unsigned varyingscount); GLuint LoadTFBProgram(const char * vertex_file_path, const char **varyings, unsigned varyingscount);
void bindUniformToTextureUnit(GLuint location, GLuint texid, unsigned textureUnit); void bindUniformToTextureUnit(GLuint location, GLuint texid, unsigned textureUnit);
void setTexture(unsigned TextureUnit, GLuint TextureId, GLenum MagFilter, GLenum MinFilter); void setTexture(unsigned TextureUnit, GLuint TextureId, GLenum MagFilter, GLenum MinFilter, bool allowAF = false);
// already includes glext.h, which defines useful GL constants. // already includes glext.h, which defines useful GL constants.
// COpenGLDriver has already loaded the extension GL functions we use (e.g glBeginQuery) // COpenGLDriver has already loaded the extension GL functions we use (e.g glBeginQuery)

File diff suppressed because it is too large Load Diff

View File

@ -1,98 +0,0 @@
#ifndef GPUPARTICLES_H
#define GPUPARTICLES_H
#include "graphics/glwrap.hpp"
#include "../lib/irrlicht/source/Irrlicht/CParticleSystemSceneNode.h"
#include <ISceneManager.h>
#include <IParticleSystemSceneNode.h>
namespace irr { namespace video{ class ITexture; } }
GLuint getTextureGLuint(irr::video::ITexture *tex);
class GPUParticle : public scene::ISceneNode
{
protected:
video::SMaterial fakemat;
virtual void simulate() = 0;
virtual void draw() = 0;
public:
GPUParticle(scene::ISceneNode *parent, scene::ISceneManager* mgr,
video::ITexture *tex);
virtual void render();
virtual void OnRegisterSceneNode();
};
class ParticleSystemProxy : public scene::CParticleSystemSceneNode {
protected:
video::SMaterial fakemat;
GLuint tfb_buffers[2], initial_values_buffer, heighmapbuffer, heightmaptexture, quaternionsbuffer;
GLuint current_simulation_vao, non_current_simulation_vao;
GLuint current_hm_simulation_vao, non_currenthm__simulation_vao;
GLuint current_rendering_vao, non_current_rendering_vao;
GLuint current_rendering_flip_vao, non_current_rendering_flip_vao;
bool m_alpha_additive, has_height_map, flip;
float size_increase_factor, track_x, track_z, track_x_len, track_z_len;
static GLuint quad_vertex_buffer;
GLuint texture;
unsigned count;
static void SimpleParticleVAOBind(GLuint PositionBuffer);
static void FlipParticleVAOBind(GLuint PositionBuffer, GLuint QuaternionBuffer);
static void SimpleSimulationBind(GLuint PositionBuffer, GLuint InitialValuesBuffer);
static void HeightmapSimulationBind(GLuint PositionBuffer, GLuint InitialValuesBuffer);
void simulateHeightmap();
void simulateNoHeightmap();
void drawFlip();
void drawNotFlip();
virtual void simulate();
virtual void draw();
void generateParticlesFromPointEmitter(scene::IParticlePointEmitter *);
void generateParticlesFromBoxEmitter(scene::IParticleBoxEmitter *);
void generateParticlesFromSphereEmitter(scene::IParticleSphereEmitter *);
public:
static IParticleSystemSceneNode *addParticleNode(
bool withDefaultEmitter = true, ISceneNode* parent = 0, s32 id = -1,
const core::vector3df& position = core::vector3df(0, 0, 0),
const core::vector3df& rotation = core::vector3df(0, 0, 0),
const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f));
ParticleSystemProxy(bool createDefaultEmitter,
ISceneNode* parent, scene::ISceneManager* mgr, s32 id,
const core::vector3df& position,
const core::vector3df& rotation,
const core::vector3df& scale);
~ParticleSystemProxy();
virtual void setEmitter(scene::IParticleEmitter* emitter);
virtual void render();
virtual void OnRegisterSceneNode();
void setAlphaAdditive(bool);
void setIncreaseFactor(float);
void setHeightmap(const std::vector<std::vector<float> >&, float, float, float, float);
void setFlip();
};
class RainNode : public GPUParticle
{
protected:
GLuint SimulationProgram, RenderProgram, tfb_vertex_buffer[2];
unsigned count;
GLuint texture, normal_and_depth;
GLuint loc_campos, loc_viewm, loc_time;
GLuint loc_screenw, loc_screen, loc_invproj, texloc_tex, texloc_normal_and_depths;
s32 area;
core::aabbox3d<f32> box;
virtual void simulate();
virtual void draw();
public:
RainNode(scene::ISceneManager* mgr, video::ITexture *tex);
virtual const core::aabbox3d<f32>& getBoundingBox() const;
virtual u32 getMaterialCount() const { return 1; }
};
#endif // GPUPARTICLES_H

View File

@ -0,0 +1,98 @@
#ifndef GPUPARTICLES_H
#define GPUPARTICLES_H
#include "graphics/glwrap.hpp"
#include "../lib/irrlicht/source/Irrlicht/CParticleSystemSceneNode.h"
#include <ISceneManager.h>
#include <IParticleSystemSceneNode.h>
namespace irr { namespace video{ class ITexture; } }
GLuint getTextureGLuint(irr::video::ITexture *tex);
class GPUParticle : public scene::ISceneNode
{
protected:
video::SMaterial fakemat;
virtual void simulate() = 0;
virtual void draw() = 0;
public:
GPUParticle(scene::ISceneNode *parent, scene::ISceneManager* mgr,
video::ITexture *tex);
virtual void render();
virtual void OnRegisterSceneNode();
};
class ParticleSystemProxy : public scene::CParticleSystemSceneNode {
protected:
video::SMaterial fakemat;
GLuint tfb_buffers[2], initial_values_buffer, heighmapbuffer, heightmaptexture, quaternionsbuffer;
GLuint current_simulation_vao, non_current_simulation_vao;
GLuint current_hm_simulation_vao, non_currenthm__simulation_vao;
GLuint current_rendering_vao, non_current_rendering_vao;
GLuint current_rendering_flip_vao, non_current_rendering_flip_vao;
bool m_alpha_additive, has_height_map, flip;
float size_increase_factor, track_x, track_z, track_x_len, track_z_len;
static GLuint quad_vertex_buffer;
GLuint texture;
unsigned count;
static void SimpleParticleVAOBind(GLuint PositionBuffer);
static void FlipParticleVAOBind(GLuint PositionBuffer, GLuint QuaternionBuffer);
static void SimpleSimulationBind(GLuint PositionBuffer, GLuint InitialValuesBuffer);
static void HeightmapSimulationBind(GLuint PositionBuffer, GLuint InitialValuesBuffer);
void simulateHeightmap();
void simulateNoHeightmap();
void drawFlip();
void drawNotFlip();
virtual void simulate();
virtual void draw();
void generateParticlesFromPointEmitter(scene::IParticlePointEmitter *);
void generateParticlesFromBoxEmitter(scene::IParticleBoxEmitter *);
void generateParticlesFromSphereEmitter(scene::IParticleSphereEmitter *);
public:
static IParticleSystemSceneNode *addParticleNode(
bool withDefaultEmitter = true, ISceneNode* parent = 0, s32 id = -1,
const core::vector3df& position = core::vector3df(0, 0, 0),
const core::vector3df& rotation = core::vector3df(0, 0, 0),
const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f));
ParticleSystemProxy(bool createDefaultEmitter,
ISceneNode* parent, scene::ISceneManager* mgr, s32 id,
const core::vector3df& position,
const core::vector3df& rotation,
const core::vector3df& scale);
~ParticleSystemProxy();
virtual void setEmitter(scene::IParticleEmitter* emitter);
virtual void render();
virtual void OnRegisterSceneNode();
void setAlphaAdditive(bool);
void setIncreaseFactor(float);
void setHeightmap(const std::vector<std::vector<float> >&, float, float, float, float);
void setFlip();
};
class RainNode : public GPUParticle
{
protected:
GLuint SimulationProgram, RenderProgram, tfb_vertex_buffer[2];
unsigned count;
GLuint texture, normal_and_depth;
GLuint loc_campos, loc_viewm, loc_time;
GLuint loc_screenw, loc_screen, loc_invproj, texloc_tex, texloc_normal_and_depths;
s32 area;
core::aabbox3d<f32> box;
virtual void simulate();
virtual void draw();
public:
RainNode(scene::ISceneManager* mgr, video::ITexture *tex);
virtual const core::aabbox3d<f32>& getBoundingBox() const;
virtual u32 getMaterialCount() const { return 1; }
};
#endif // GPUPARTICLES_H

View File

@ -945,17 +945,6 @@ scene::IMeshSceneNode *IrrDriver::addMesh(scene::IMesh *mesh,
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
PerCameraNode *IrrDriver::addPerCameraMesh(scene::IMesh* mesh,
scene::ICameraSceneNode* camera,
scene::ISceneNode *parent)
{
scene::ISceneNode *node = m_scene_manager->addMeshSceneNode(mesh);
return new PerCameraNode((parent ? parent
: m_scene_manager->getRootSceneNode()),
m_scene_manager, -1, camera, node);
} // addMesh
PerCameraNode *IrrDriver::addPerCameraNode(scene::ISceneNode* node, PerCameraNode *IrrDriver::addPerCameraNode(scene::ISceneNode* node,
scene::ICameraSceneNode* camera, scene::ICameraSceneNode* camera,
scene::ISceneNode *parent) scene::ISceneNode *parent)
@ -1457,15 +1446,15 @@ void IrrDriver::setAmbientLight(const video::SColor &light)
*/ */
void IrrDriver::displayFPS() void IrrDriver::displayFPS()
{ {
gui::IGUIFont* font = GUIEngine::getFont(); gui::IGUIFont* font = GUIEngine::getSmallFont();
if(UserConfigParams::m_artist_debug_mode) if(UserConfigParams::m_artist_debug_mode)
{ {
GL32_draw2DRectangle(video::SColor(150, 96, 74, 196),core::rect< s32 >(75,0,1100,50),NULL); GL32_draw2DRectangle(video::SColor(150, 96, 74, 196),core::rect< s32 >(75,0,1100,40),NULL);
} }
else else
{ {
GL32_draw2DRectangle(video::SColor(150, 96, 74, 196),core::rect< s32 >(75,0,900,50),NULL); GL32_draw2DRectangle(video::SColor(150, 96, 74, 196),core::rect< s32 >(75,0,900,40),NULL);
} }
// We will let pass some time to let things settle before trusting FPS counter // We will let pass some time to let things settle before trusting FPS counter
// even if we also ignore fps = 1, which tends to happen in first checks // even if we also ignore fps = 1, which tends to happen in first checks
@ -1520,7 +1509,9 @@ void IrrDriver::displayFPS()
{ {
sprintf(buffer, "FPS: %i/%i/%i - Objects (P1:%d P2:%d T:%d) KTris - LightDst : ~%d", sprintf(buffer, "FPS: %i/%i/%i - Objects (P1:%d P2:%d T:%d) KTris - LightDst : ~%d",
min, fps, max, object_count[SOLID_NORMAL_AND_DEPTH_PASS], object_count[SOLID_NORMAL_AND_DEPTH_PASS], object_count[TRANSPARENT_PASS], m_last_light_bucket_distance); min, fps, max, object_count[SOLID_NORMAL_AND_DEPTH_PASS], object_count[SOLID_NORMAL_AND_DEPTH_PASS], object_count[TRANSPARENT_PASS], m_last_light_bucket_distance);
object_count[SOLID_NORMAL_AND_DEPTH_PASS] = object_count[SOLID_NORMAL_AND_DEPTH_PASS] = object_count[TRANSPARENT_PASS] = 0; object_count[SOLID_NORMAL_AND_DEPTH_PASS] = 0;
object_count[SOLID_NORMAL_AND_DEPTH_PASS] = 0;
object_count[TRANSPARENT_PASS] = 0;
} }
else else
{ {

View File

@ -102,6 +102,7 @@ private:
RTT *m_rtts; RTT *m_rtts;
/** Shadow importance. */ /** Shadow importance. */
ShadowImportance *m_shadow_importance; ShadowImportance *m_shadow_importance;
core::matrix4 sun_ortho_matrix;
/** Additional details to be shown in case that a texture is not found. /** Additional details to be shown in case that a texture is not found.
* This is used to specify details like: "while loading kart '...'" */ * This is used to specify details like: "while loading kart '...'" */
@ -111,7 +112,7 @@ private:
core::array<video::IRenderTarget> m_mrt; core::array<video::IRenderTarget> m_mrt;
/** Matrixes used in several places stored here to avoid recomputation. */ /** Matrixes used in several places stored here to avoid recomputation. */
core::matrix4 m_ViewMatrix, m_ProjMatrix, m_InvProjMatrix, m_ProjViewMatrix, m_InvProjViewMatrix; core::matrix4 m_ViewMatrix, m_InvViewMatrix, m_ProjMatrix, m_InvProjMatrix, m_ProjViewMatrix, m_InvProjViewMatrix;
std::vector<video::ITexture *> SkyboxTextures; std::vector<video::ITexture *> SkyboxTextures;
@ -203,9 +204,9 @@ private:
void renderFixed(float dt); void renderFixed(float dt);
void renderGLSL(float dt); void renderGLSL(float dt);
void renderShadows(ShadowImportanceProvider * const sicb, void renderShadows(//ShadowImportanceProvider * const sicb,
scene::ICameraSceneNode * const camnode, scene::ICameraSceneNode * const camnode,
video::SOverrideMaterial &overridemat, //video::SOverrideMaterial &overridemat,
Camera * const camera); Camera * const camera);
void renderGlow(video::SOverrideMaterial &overridemat, void renderGlow(video::SOverrideMaterial &overridemat,
std::vector<GlowData>& glows, std::vector<GlowData>& glows,
@ -260,9 +261,6 @@ public:
const video::SColor &color=video::SColor(128, 255, 255, 255)); const video::SColor &color=video::SColor(128, 255, 255, 255));
scene::IMeshSceneNode*addMesh(scene::IMesh *mesh, scene::IMeshSceneNode*addMesh(scene::IMesh *mesh,
scene::ISceneNode *parent=NULL); scene::ISceneNode *parent=NULL);
PerCameraNode *addPerCameraMesh(scene::IMesh* mesh,
scene::ICameraSceneNode* node,
scene::ISceneNode *parent = NULL);
PerCameraNode *addPerCameraNode(scene::ISceneNode* node, PerCameraNode *addPerCameraNode(scene::ISceneNode* node,
scene::ICameraSceneNode* cam, scene::ICameraSceneNode* cam,
scene::ISceneNode *parent = NULL); scene::ISceneNode *parent = NULL);
@ -495,8 +493,9 @@ public:
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
scene::IMeshSceneNode *getSunInterposer() { return m_sun_interposer; } scene::IMeshSceneNode *getSunInterposer() { return m_sun_interposer; }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
void setViewMatrix(core::matrix4 matrix) { m_ViewMatrix = matrix; } void setViewMatrix(core::matrix4 matrix) { m_ViewMatrix = matrix; matrix.getInverse(m_InvViewMatrix); }
const core::matrix4 &getViewMatrix() const { return m_ViewMatrix; } const core::matrix4 &getViewMatrix() const { return m_ViewMatrix; }
const core::matrix4 &getInvViewMatrix() const { return m_InvViewMatrix; }
void setProjMatrix(core::matrix4 matrix) { m_ProjMatrix = matrix; matrix.getInverse(m_InvProjMatrix); } void setProjMatrix(core::matrix4 matrix) { m_ProjMatrix = matrix; matrix.getInverse(m_InvProjMatrix); }
const core::matrix4 &getProjMatrix() const { return m_ProjMatrix; } const core::matrix4 &getProjMatrix() const { return m_ProjMatrix; }
const core::matrix4 &getInvProjMatrix() const { return m_InvProjMatrix; } const core::matrix4 &getInvProjMatrix() const { return m_InvProjMatrix; }

View File

@ -66,8 +66,6 @@ public:
protected: protected:
static core::aabbox3df box; static core::aabbox3df box;
class ScreenQuad *sq;
//float m_radius; //float m_radius;
float m_color[3]; float m_color[3];
float m_energy; float m_energy;

View File

@ -28,7 +28,7 @@
#include "tracks/track.hpp" #include "tracks/track.hpp"
#include "utils/constants.hpp" #include "utils/constants.hpp"
#include "utils/helpers.hpp" #include "utils/helpers.hpp"
#include "graphics/gpuparticles.h" #include "graphics/gpuparticles.hpp"
#include <SParticle.h> #include <SParticle.h>
#include <IParticleAffector.h> #include <IParticleAffector.h>

View File

@ -57,7 +57,11 @@ PostProcessing::PostProcessing(IVideoDriver* video_driver)
io::IReadFile *areamap = irr_driver->getDevice()->getFileSystem()-> io::IReadFile *areamap = irr_driver->getDevice()->getFileSystem()->
createMemoryReadFile((void *) AreaMap33, sizeof(AreaMap33), createMemoryReadFile((void *) AreaMap33, sizeof(AreaMap33),
"AreaMap33", false); "AreaMap33", false);
if (!areamap) Log::fatal("postprocessing", "Failed to load the areamap"); if (!areamap)
{
Log::fatal("postprocessing", "Failed to load the areamap");
return;
}
m_areamap = irr_driver->getVideoDriver()->getTexture(areamap); m_areamap = irr_driver->getVideoDriver()->getTexture(areamap);
areamap->drop(); areamap->drop();
@ -342,55 +346,25 @@ void PostProcessing::renderSunlight()
glBindVertexArray(0); glBindVertexArray(0);
} }
void PostProcessing::renderLightbBlend(ITexture *diffuse, ITexture *specular, ITexture *ao, ITexture *specmap, bool debug) void PostProcessing::renderShadowedSunlight(const core::matrix4 &sun_ortho_matrix)
{ {
const SColorf s = irr_driver->getSceneManager()->getAmbientLight(); SunLightProvider * const cb = (SunLightProvider *)irr_driver->getCallback(ES_SUNLIGHT);
glStencilFunc(GL_EQUAL, 1, ~0);
glEnable(GL_STENCIL_TEST);
glEnable(GL_BLEND);
glBlendEquation(GL_FUNC_ADD);
if (debug)
glBlendFunc(GL_ONE, GL_ZERO);
else
glBlendFunc(GL_DST_COLOR, GL_ZERO);
glDisable(GL_DEPTH_TEST);
glUseProgram(FullScreenShader::LightBlendShader::Program); glEnable(GL_BLEND);
glBindVertexArray(FullScreenShader::LightBlendShader::vao); glDisable(GL_DEPTH_TEST);
glBlendFunc(GL_ONE, GL_ONE);
glBlendEquation(GL_FUNC_ADD);
glUniform3f(FullScreenShader::LightBlendShader::uniform_ambient, s.r, s.g, s.b); glUseProgram(FullScreenShader::ShadowedSunLightShader::Program);
glBindVertexArray(FullScreenShader::ShadowedSunLightShader::vao);
glActiveTexture(GL_TEXTURE0); setTexture(0, static_cast<irr::video::COpenGLTexture*>(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH))->getOpenGLTextureName(), GL_NEAREST, GL_NEAREST);
glBindTexture(GL_TEXTURE_2D, static_cast<irr::video::COpenGLTexture*>(diffuse)->getOpenGLTextureName()); setTexture(1, static_cast<irr::video::COpenGLFBOTexture*>(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH))->DepthBufferTexture, GL_NEAREST, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); setTexture(2, static_cast<irr::video::COpenGLFBOTexture*>(irr_driver->getRTT(RTT_SHADOW))->DepthBufferTexture, GL_LINEAR, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
glUniform1i(FullScreenShader::LightBlendShader::uniform_diffuse, 0); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
glActiveTexture(GL_TEXTURE1); FullScreenShader::ShadowedSunLightShader::setUniforms(sun_ortho_matrix, cb->getPosition(), irr_driver->getInvProjMatrix(), cb->getRed(), cb->getGreen(), cb->getBlue(), 0, 1, 2);
glBindTexture(GL_TEXTURE_2D, static_cast<irr::video::COpenGLTexture*>(specular)->getOpenGLTextureName()); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glBindVertexArray(0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glUniform1i(FullScreenShader::LightBlendShader::uniform_specular, 1);
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, static_cast<irr::video::COpenGLTexture*>(ao)->getOpenGLTextureName());
glUniform1i(FullScreenShader::LightBlendShader::uniform_ambient_occlusion, 2);
glActiveTexture(GL_TEXTURE3);
if (!UserConfigParams::m_ssao)
{
GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_ONE};
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
}
glBindTexture(GL_TEXTURE_2D, static_cast<irr::video::COpenGLTexture*>(specmap)->getOpenGLTextureName());
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glUniform1i(FullScreenShader::LightBlendShader::uniform_specular_map, 3);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glEnable(GL_DEPTH_TEST);
glDisable(GL_BLEND);
glDisable(GL_STENCIL_TEST);
} }
@ -495,6 +469,27 @@ void PostProcessing::renderPassThrough(ITexture *tex)
glDisable(GL_BLEND); glDisable(GL_BLEND);
} }
void PostProcessing::renderPassThrough(GLuint tex)
{
glDisable(GL_DEPTH_TEST);
glUseProgram(FullScreenShader::PassThroughShader::Program);
glBindVertexArray(FullScreenShader::PassThroughShader::vao);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, tex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glUniform1i(FullScreenShader::PassThroughShader::uniform_texture, 0);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glEnable(GL_DEPTH_TEST);
glDisable(GL_BLEND);
}
void PostProcessing::renderGlow(ITexture *tex) void PostProcessing::renderGlow(ITexture *tex)
{ {
glDisable(GL_DEPTH_TEST); glDisable(GL_DEPTH_TEST);
@ -542,7 +537,7 @@ void PostProcessing::renderSSAO(const core::matrix4 &invprojm, const core::matri
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
} }
void PostProcessing::renderFog(const core::vector3df &campos, const core::matrix4 &ipvmat) void PostProcessing::renderFog(const core::matrix4 &ipvmat)
{ {
irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getRTT(RTT_COLOR), false, false); irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getRTT(RTT_COLOR), false, false);
const Track * const track = World::getWorld()->getTrack(); const Track * const track = World::getWorld()->getTrack();
@ -568,7 +563,7 @@ void PostProcessing::renderFog(const core::vector3df &campos, const core::matrix
glBindVertexArray(FullScreenShader::FogShader::vao); glBindVertexArray(FullScreenShader::FogShader::vao);
setTexture(0, static_cast<irr::video::COpenGLFBOTexture*>(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH))->DepthBufferTexture, GL_NEAREST, GL_NEAREST); setTexture(0, static_cast<irr::video::COpenGLFBOTexture*>(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH))->DepthBufferTexture, GL_NEAREST, GL_NEAREST);
FullScreenShader::FogShader::setUniforms(ipvmat, fogmax, startH, endH, start, end, col, campos, 0); FullScreenShader::FogShader::setUniforms(ipvmat, fogmax, startH, endH, start, end, col, 0);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glBindVertexArray(0); glBindVertexArray(0);
@ -854,7 +849,7 @@ void PostProcessing::render()
else if (irr_driver->getSSAOViz()) else if (irr_driver->getSSAOViz())
renderPassThrough(irr_driver->getRTT(RTT_SSAO)); renderPassThrough(irr_driver->getRTT(RTT_SSAO));
else if (irr_driver->getShadowViz()) else if (irr_driver->getShadowViz())
renderPassThrough(irr_driver->getRTT(RTT_SHADOW)); renderPassThrough(static_cast<irr::video::COpenGLFBOTexture*>(irr_driver->getRTT(RTT_SHADOW))->DepthBufferTexture);
else else
renderColorLevel(in); renderColorLevel(in);
} }

View File

@ -75,10 +75,9 @@ public:
/** Generate diffuse and specular map */ /** Generate diffuse and specular map */
void renderPointlight(const std::vector<float> &positions, const std::vector<float> &colors, const std::vector<float> &energy); void renderPointlight(const std::vector<float> &positions, const std::vector<float> &colors, const std::vector<float> &energy);
void renderSunlight(); void renderSunlight();
/** Blend all light related map */ void renderShadowedSunlight(const core::matrix4 &sun_ortho_matrix);
void renderLightbBlend(video::ITexture *diffuse, video::ITexture *specular, video::ITexture *ao, video::ITexture *specmap, bool debug);
void renderFog(const core::vector3df &campos, const core::matrix4 &ipvmat); void renderFog(const core::matrix4 &ipvmat);
void renderSSAO(const core::matrix4 &invprojm, const core::matrix4 &projm); void renderSSAO(const core::matrix4 &invprojm, const core::matrix4 &projm);
/** Blur the in texture */ /** Blur the in texture */
@ -87,6 +86,7 @@ public:
/** Render tex. Used for blit/texture resize */ /** Render tex. Used for blit/texture resize */
void renderPassThrough(video::ITexture *tex); void renderPassThrough(video::ITexture *tex);
void renderPassThrough(unsigned tex);
void renderGlow(video::ITexture *tex); void renderGlow(video::ITexture *tex);

View File

@ -20,7 +20,7 @@
#include "audio/sfx_manager.hpp" #include "audio/sfx_manager.hpp"
#include "graphics/camera.hpp" #include "graphics/camera.hpp"
#include "graphics/glwrap.hpp" #include "graphics/glwrap.hpp"
#include "graphics/gpuparticles.h" #include "graphics/gpuparticles.hpp"
#include "graphics/irr_driver.hpp" #include "graphics/irr_driver.hpp"
#include "graphics/material_manager.hpp" #include "graphics/material_manager.hpp"
#include "graphics/material.hpp" #include "graphics/material.hpp"
@ -42,7 +42,7 @@ using namespace core;
// The rain manager // The rain manager
Rain::Rain(Camera *camera, irr::scene::ISceneNode* parent) Rain::Rain(Camera *camera, irr::scene::ISceneNode* parent) : m_thunder_sound(0)
{ {
m_lightning = camera->getIndex()==0; m_lightning = camera->getIndex()==0;

View File

@ -215,10 +215,10 @@ void IrrDriver::renderGLSL(float dt)
const core::aabbox3df cambox = camnode->getViewFrustum()->getBoundingBox(); const core::aabbox3df cambox = camnode->getViewFrustum()->getBoundingBox();
// Shadows // Shadows
if (!m_mipviz && !m_wireframe && UserConfigParams::m_shadows && if (!m_mipviz && !m_wireframe && UserConfigParams::m_shadows)
World::getWorld()->getTrack()->hasShadows()) //&& World::getWorld()->getTrack()->hasShadows())
{ {
//renderShadows(sicb, camnode, overridemat, camera); renderShadows(camnode, camera);
} }
@ -242,7 +242,7 @@ void IrrDriver::renderGLSL(float dt)
if (World::getWorld()->getTrack()->isFogEnabled()) if (World::getWorld()->getTrack()->isFogEnabled())
{ {
PROFILER_PUSH_CPU_MARKER("- Fog", 0xFF, 0x00, 0x00); PROFILER_PUSH_CPU_MARKER("- Fog", 0xFF, 0x00, 0x00);
m_post_processing->renderFog(camnode->getAbsolutePosition(), irr_driver->getInvProjViewMatrix()); m_post_processing->renderFog(irr_driver->getInvProjMatrix());
PROFILER_POP_CPU_MARKER(); PROFILER_POP_CPU_MARKER();
} }
@ -268,7 +268,7 @@ void IrrDriver::renderGLSL(float dt)
// Is the lens flare enabled & visible? Check last frame's query. // Is the lens flare enabled & visible? Check last frame's query.
const bool hasflare = World::getWorld()->getTrack()->hasLensFlare(); const bool hasflare = World::getWorld()->getTrack()->hasLensFlare();
const bool hasgodrays = World::getWorld()->getTrack()->hasGodRays(); const bool hasgodrays = World::getWorld()->getTrack()->hasGodRays();
if (hasflare | hasgodrays) if (hasflare || hasgodrays)
{ {
irr::video::COpenGLDriver* gl_driver = (irr::video::COpenGLDriver*)m_device->getVideoDriver(); irr::video::COpenGLDriver* gl_driver = (irr::video::COpenGLDriver*)m_device->getVideoDriver();
@ -464,9 +464,9 @@ void IrrDriver::renderFixed(float dt)
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void IrrDriver::renderShadows(ShadowImportanceProvider * const sicb, void IrrDriver::renderShadows(//ShadowImportanceProvider * const sicb,
scene::ICameraSceneNode * const camnode, scene::ICameraSceneNode * const camnode,
video::SOverrideMaterial &overridemat, //video::SOverrideMaterial &overridemat,
Camera * const camera) Camera * const camera)
{ {
m_scene_manager->setCurrentRendertime(scene::ESNRP_SOLID); m_scene_manager->setCurrentRendertime(scene::ESNRP_SOLID);
@ -486,7 +486,6 @@ void IrrDriver::renderShadows(ShadowImportanceProvider * const sicb,
camnode->render(); camnode->render();
// Set up a nice ortho projection that contains our camera frustum // Set up a nice ortho projection that contains our camera frustum
core::matrix4 ortho;
core::aabbox3df box = smallcambox; core::aabbox3df box = smallcambox;
box = box.intersect(trackbox); box = box.intersect(trackbox);
@ -518,16 +517,16 @@ void IrrDriver::renderShadows(ShadowImportanceProvider * const sicb,
if (up == down) down += 0.1f; if (up == down) down += 0.1f;
if (z == 30) z += 0.1f; if (z == 30) z += 0.1f;
ortho.buildProjectionMatrixOrthoLH(left, right, sun_ortho_matrix.buildProjectionMatrixOrthoLH(left, right,
up, down, up, down,
30, z); 30, z);
m_suncam->setProjectionMatrix(ortho, true); m_suncam->setProjectionMatrix(sun_ortho_matrix, true);
m_scene_manager->setActiveCamera(m_suncam); m_scene_manager->setActiveCamera(m_suncam);
m_suncam->render(); m_suncam->render();
ortho *= m_suncam->getViewMatrix(); //sun_ortho_matrix *= m_suncam->getViewMatrix();
((SunLightProvider *) m_shaders->m_callbacks[ES_SUNLIGHT])->setShadowMatrix(ortho); /* ((SunLightProvider *) m_shaders->m_callbacks[ES_SUNLIGHT])->setShadowMatrix(ortho);
sicb->setShadowMatrix(ortho); sicb->setShadowMatrix(ortho);
overridemat.Enabled = 0; overridemat.Enabled = 0;
@ -563,7 +562,7 @@ void IrrDriver::renderShadows(ShadowImportanceProvider * const sicb,
m_rtts->getRTT(RTT_WARPV)->getSize().Height, m_rtts->getRTT(RTT_WARPV)->getSize().Height,
m_rtts->getRTT(RTT_WARPV)->getSize().Height); m_rtts->getRTT(RTT_WARPV)->getSize().Height);
/* sq.setMaterialType(m_shaders->getShader(ES_GAUSSIAN6H)); sq.setMaterialType(m_shaders->getShader(ES_GAUSSIAN6H));
sq.setTexture(m_rtts->getRTT(RTT_WARPH)); sq.setTexture(m_rtts->getRTT(RTT_WARPH));
sq.render(m_rtts->getRTT(curh)); sq.render(m_rtts->getRTT(curh));
@ -577,7 +576,7 @@ void IrrDriver::renderShadows(ShadowImportanceProvider * const sicb,
// calculating the min, max, and total, it's several hundred us // calculating the min, max, and total, it's several hundred us
// faster to do that than to do it once in a separate shader // faster to do that than to do it once in a separate shader
// (shader switch overhead, measured). // (shader switch overhead, measured).
colcb->setResolution(m_rtts->getRTT(RTT_WARPV)->getSize().Height, /*colcb->setResolution(m_rtts->getRTT(RTT_WARPV)->getSize().Height,
m_rtts->getRTT(RTT_WARPV)->getSize().Height); m_rtts->getRTT(RTT_WARPV)->getSize().Height);
sq.setMaterialType(m_shaders->getShader(ES_SHADOW_WARPH)); sq.setMaterialType(m_shaders->getShader(ES_SHADOW_WARPH));
@ -586,11 +585,12 @@ void IrrDriver::renderShadows(ShadowImportanceProvider * const sicb,
sq.setMaterialType(m_shaders->getShader(ES_SHADOW_WARPV)); sq.setMaterialType(m_shaders->getShader(ES_SHADOW_WARPV));
sq.setTexture(m_rtts->getRTT(curv)); sq.setTexture(m_rtts->getRTT(curv));
sq.render(m_rtts->getRTT(RTT_WARPV)); sq.render(m_rtts->getRTT(RTT_WARPV));*/
// Actual shadow map // Actual shadow map
m_video_driver->setRenderTarget(m_rtts->getRTT(RTT_SHADOW), true, true);
overridemat.Material.MaterialType = m_shaders->getShader(ES_SHADOWPASS);
/* overridemat.Material.MaterialType = m_shaders->getShader(ES_SHADOWPASS);
overridemat.EnableFlags = video::EMF_MATERIAL_TYPE | video::EMF_TEXTURE1 | overridemat.EnableFlags = video::EMF_MATERIAL_TYPE | video::EMF_TEXTURE1 |
video::EMF_TEXTURE2; video::EMF_TEXTURE2;
overridemat.EnablePasses = scene::ESNRP_SOLID; overridemat.EnablePasses = scene::ESNRP_SOLID;
@ -607,19 +607,22 @@ void IrrDriver::renderShadows(ShadowImportanceProvider * const sicb,
overridemat.Material.TextureLayer[1].AnisotropicFilter = overridemat.Material.TextureLayer[1].AnisotropicFilter =
overridemat.Material.TextureLayer[2].AnisotropicFilter = 0; overridemat.Material.TextureLayer[2].AnisotropicFilter = 0;
overridemat.Material.Wireframe = 1; overridemat.Material.Wireframe = 1;
overridemat.Enabled = true; overridemat.Enabled = true;*/
sun_ortho_matrix = getVideoDriver()->getTransform(video::ETS_PROJECTION);
sun_ortho_matrix *= getVideoDriver()->getTransform(video::ETS_VIEW);
irr_driver->setPhase(SHADOW_PASS);
glDisable(GL_BLEND);
glEnable(GL_CULL_FACE);
glCullFace(GL_FRONT);
m_video_driver->setRenderTarget(m_rtts->getRTT(RTT_SHADOW), true, true);
glDrawBuffer(GL_NONE);
m_scene_manager->drawAll(scene::ESNRP_SOLID); m_scene_manager->drawAll(scene::ESNRP_SOLID);
glCullFace(GL_BACK);
if (m_shadowviz) // overridemat.EnablePasses = 0;
{ // overridemat.Enabled = false;
overridemat.EnableFlags |= video::EMF_WIREFRAME;
m_scene_manager->drawAll(scene::ESNRP_SOLID);
}
overridemat.EnablePasses = 0;
overridemat.Enabled = false;
camera->activate(); camera->activate();
m_scene_manager->drawAll(scene::ESNRP_CAMERA);
tick++; tick++;
tick %= 2; tick %= 2;
@ -640,10 +643,6 @@ void IrrDriver::renderGlow(video::SOverrideMaterial &overridemat,
const u32 glowcount = glows.size(); const u32 glowcount = glows.size();
ColorizeProvider * const cb = (ColorizeProvider *) m_shaders->m_callbacks[ES_COLORIZE]; ColorizeProvider * const cb = (ColorizeProvider *) m_shaders->m_callbacks[ES_COLORIZE];
GlowProvider * const glowcb = (GlowProvider *) m_shaders->m_callbacks[ES_GLOW];
glowcb->setResolution(UserConfigParams::m_width,
UserConfigParams::m_height);
/* overridemat.Material.MaterialType = m_shaders->getShader(ES_COLORIZE); /* overridemat.Material.MaterialType = m_shaders->getShader(ES_COLORIZE);
overridemat.EnableFlags = video::EMF_MATERIAL_TYPE; overridemat.EnableFlags = video::EMF_MATERIAL_TYPE;
overridemat.EnablePasses = scene::ESNRP_SOLID; overridemat.EnablePasses = scene::ESNRP_SOLID;
@ -732,6 +731,7 @@ void IrrDriver::renderLights(const core::aabbox3df& cambox,
video::SOverrideMaterial &overridemat, video::SOverrideMaterial &overridemat,
int cam, float dt) int cam, float dt)
{ {
sun_ortho_matrix *= getInvViewMatrix();
core::array<video::IRenderTarget> rtts; core::array<video::IRenderTarget> rtts;
// Diffuse // Diffuse
rtts.push_back(m_rtts->getRTT(RTT_TMP1)); rtts.push_back(m_rtts->getRTT(RTT_TMP1));
@ -753,7 +753,10 @@ void IrrDriver::renderLights(const core::aabbox3df& cambox,
if (!m_lights[i]->isPointLight()) if (!m_lights[i]->isPointLight())
{ {
m_lights[i]->render(); m_lights[i]->render();
m_post_processing->renderSunlight(); if (UserConfigParams::m_shadows)
m_post_processing->renderShadowedSunlight(sun_ortho_matrix);
else
m_post_processing->renderSunlight();
continue; continue;
} }
const core::vector3df &lightpos = (m_lights[i]->getAbsolutePosition() - campos); const core::vector3df &lightpos = (m_lights[i]->getAbsolutePosition() - campos);

View File

@ -36,7 +36,7 @@ RTT::RTT()
const dimension2du ssaosize = UserConfigParams::m_ssao == 2 ? res : quarter; const dimension2du ssaosize = UserConfigParams::m_ssao == 2 ? res : quarter;
const u16 shadowside = UserConfigParams::m_shadows == 2 ? 2048 : 512; const u16 shadowside = 8192;
const dimension2du shadowsize(shadowside, shadowside); const dimension2du shadowsize(shadowside, shadowside);
const dimension2du warpvsize(1, 512); const dimension2du warpvsize(1, 512);
const dimension2du warphsize(512, 1); const dimension2du warphsize(512, 1);

View File

@ -40,8 +40,6 @@ Shaders::Shaders()
m_callbacks[ES_GAUSSIAN3V] = m_callbacks[ES_GAUSSIAN3H] = new GaussianBlurProvider(); m_callbacks[ES_GAUSSIAN3V] = m_callbacks[ES_GAUSSIAN3H] = new GaussianBlurProvider();
m_callbacks[ES_MIPVIZ] = new MipVizProvider(); m_callbacks[ES_MIPVIZ] = new MipVizProvider();
m_callbacks[ES_COLORIZE] = new ColorizeProvider(); m_callbacks[ES_COLORIZE] = new ColorizeProvider();
m_callbacks[ES_GLOW] = new GlowProvider();
m_callbacks[ES_OBJECTPASS] = new ObjectPassProvider();
m_callbacks[ES_SUNLIGHT] = new SunLightProvider(); m_callbacks[ES_SUNLIGHT] = new SunLightProvider();
m_callbacks[ES_MLAA_COLOR1] = new MLAAColor1Provider(); m_callbacks[ES_MLAA_COLOR1] = new MLAAColor1Provider();
m_callbacks[ES_MLAA_BLEND2] = new MLAABlend2Provider(); m_callbacks[ES_MLAA_BLEND2] = new MLAABlend2Provider();
@ -108,29 +106,24 @@ void Shaders::loadShaders()
memcpy(saved_shaders, m_shaders, sizeof(m_shaders)); memcpy(saved_shaders, m_shaders, sizeof(m_shaders));
// Ok, go // Ok, go
m_shaders[ES_NORMAL_MAP] = glslmat(dir + "normalmap.vert", dir + "normalmap.frag", m_shaders[ES_NORMAL_MAP] = glsl_noinput(dir + "normalmap.vert", dir + "normalmap.frag");
m_callbacks[ES_NORMAL_MAP], EMT_SOLID_2_LAYER); m_shaders[ES_NORMAL_MAP_LIGHTMAP] = glsl_noinput(dir + "normalmap.vert", dir + "normalmap.frag");
m_shaders[ES_NORMAL_MAP_LIGHTMAP] = glslmat(dir + "normalmap.vert", dir + "normalmap.frag",
m_callbacks[ES_NORMAL_MAP_LIGHTMAP], EMT_SOLID_2_LAYER);
m_shaders[ES_SKYBOX] = glslmat(dir + "skybox.vert", dir + "skybox.frag", m_shaders[ES_SKYBOX] = glslmat(dir + "skybox.vert", dir + "skybox.frag",
m_callbacks[ES_SKYBOX], EMT_TRANSPARENT_ALPHA_CHANNEL); m_callbacks[ES_SKYBOX], EMT_TRANSPARENT_ALPHA_CHANNEL);
m_shaders[ES_SPLATTING] = glslmat(dir + "splatting.vert", dir + "splatting.frag", m_shaders[ES_SPLATTING] = glsl_noinput(dir + "splatting.vert", dir + "splatting.frag");
m_callbacks[ES_SPLATTING], EMT_SOLID);
m_shaders[ES_WATER] = glslmat(dir + "water.vert", dir + "water.frag", m_shaders[ES_WATER] = glslmat(dir + "water.vert", dir + "water.frag",
m_callbacks[ES_WATER], EMT_TRANSPARENT_ALPHA_CHANNEL); m_callbacks[ES_WATER], EMT_TRANSPARENT_ALPHA_CHANNEL);
m_shaders[ES_WATER_SURFACE] = glsl(dir + "water.vert", dir + "pass.frag", m_shaders[ES_WATER_SURFACE] = glsl(dir + "water.vert", dir + "pass.frag",
m_callbacks[ES_WATER]); m_callbacks[ES_WATER]);
m_shaders[ES_SPHERE_MAP] = glslmat(dir + "objectpass.vert", dir + "objectpass_spheremap.frag", m_shaders[ES_SPHERE_MAP] = glsl_noinput(dir + "objectpass.vert", dir + "objectpass_spheremap.frag");
m_callbacks[ES_OBJECTPASS], EMT_SOLID);
m_shaders[ES_GRASS] = glslmat(dir + "grass.vert", dir + "grass.frag", m_shaders[ES_GRASS] = glslmat(std::string(""), dir + "pass.frag",
m_callbacks[ES_GRASS], EMT_TRANSPARENT_ALPHA_CHANNEL); m_callbacks[ES_GRASS], EMT_TRANSPARENT_ALPHA_CHANNEL);
m_shaders[ES_GRASS_REF] = glslmat(dir + "grass.vert", dir + "grass.frag", m_shaders[ES_GRASS_REF] = glslmat(std::string(""), dir + "pass.frag",
m_callbacks[ES_GRASS], EMT_TRANSPARENT_ALPHA_CHANNEL_REF); m_callbacks[ES_GRASS], EMT_TRANSPARENT_ALPHA_CHANNEL_REF);
m_shaders[ES_BUBBLES] = glslmat(dir + "bubble.vert", dir + "bubble.frag", m_shaders[ES_BUBBLES] = glslmat(dir + "bubble.vert", dir + "bubble.frag",
@ -155,22 +148,13 @@ void Shaders::loadShaders()
m_shaders[ES_COLORIZE_REF] = glslmat(std::string(""), dir + "colorize_ref.frag", m_shaders[ES_COLORIZE_REF] = glslmat(std::string(""), dir + "colorize_ref.frag",
m_callbacks[ES_COLORIZE], EMT_SOLID); m_callbacks[ES_COLORIZE], EMT_SOLID);
m_shaders[ES_GLOW] = glslmat(std::string(""), dir + "glow.frag", m_shaders[ES_OBJECTPASS] = glsl_noinput(dir + "objectpass.vert", dir + "objectpass.frag");
m_callbacks[ES_GLOW], EMT_TRANSPARENT_ALPHA_CHANNEL); m_shaders[ES_OBJECT_UNLIT] = glsl_noinput(dir + "objectpass.vert", dir + "objectpass.frag");
m_shaders[ES_OBJECTPASS_REF] = glsl_noinput(dir + "objectpass.vert", dir + "objectpass_ref.frag");
m_shaders[ES_OBJECTPASS_RIMLIT] = glsl_noinput(dir + "objectpass_rimlit.vert", dir + "objectpass_rimlit.frag");
m_shaders[ES_OBJECTPASS] = glslmat(dir + "objectpass.vert", dir + "objectpass.frag", m_shaders[ES_SUNLIGHT] = glsl_noinput(std::string(""), dir + "sunlight.frag");
m_callbacks[ES_OBJECTPASS], EMT_SOLID); m_shaders[ES_SUNLIGHT_SHADOW] = glsl_noinput(dir + "pass.vert", dir + "pass.frag");
m_shaders[ES_OBJECT_UNLIT] = glslmat(dir + "objectpass.vert", dir + "objectpass.frag",
m_callbacks[ES_OBJECTPASS], EMT_SOLID);
m_shaders[ES_OBJECTPASS_REF] = glslmat(dir + "objectpass.vert", dir + "objectpass_ref.frag",
m_callbacks[ES_OBJECTPASS], EMT_SOLID);
m_shaders[ES_OBJECTPASS_RIMLIT] = glslmat(dir + "objectpass_rimlit.vert", dir + "objectpass_rimlit.frag",
m_callbacks[ES_OBJECTPASS], EMT_SOLID);
m_shaders[ES_SUNLIGHT] = glslmat(std::string(""), dir + "sunlight.frag",
m_callbacks[ES_SUNLIGHT], EMT_SOLID);
m_shaders[ES_SUNLIGHT_SHADOW] = glslmat(dir + "pass.vert", dir + "sunlightshadow.frag",
m_callbacks[ES_SUNLIGHT], EMT_SOLID);
m_shaders[ES_MLAA_COLOR1] = glsl(dir + "mlaa_offset.vert", dir + "mlaa_color1.frag", m_shaders[ES_MLAA_COLOR1] = glsl(dir + "mlaa_offset.vert", dir + "mlaa_color1.frag",
m_callbacks[ES_MLAA_COLOR1]); m_callbacks[ES_MLAA_COLOR1]);
@ -249,12 +233,12 @@ void Shaders::loadShaders()
FullScreenShader::Gaussian6HBlurShader::init(); FullScreenShader::Gaussian6HBlurShader::init();
FullScreenShader::Gaussian6VBlurShader::init(); FullScreenShader::Gaussian6VBlurShader::init();
FullScreenShader::GlowShader::init(); FullScreenShader::GlowShader::init();
FullScreenShader::LightBlendShader::init();
FullScreenShader::PassThroughShader::init(); FullScreenShader::PassThroughShader::init();
FullScreenShader::PointLightShader::init(); FullScreenShader::PointLightShader::init();
FullScreenShader::PPDisplaceShader::init(); FullScreenShader::PPDisplaceShader::init();
FullScreenShader::SSAOShader::init(); FullScreenShader::SSAOShader::init();
FullScreenShader::SunLightShader::init(); FullScreenShader::SunLightShader::init();
FullScreenShader::ShadowedSunLightShader::init();
MeshShader::ColorizeShader::init(); MeshShader::ColorizeShader::init();
MeshShader::NormalMapShader::init(); MeshShader::NormalMapShader::init();
MeshShader::ObjectPass1Shader::init(); MeshShader::ObjectPass1Shader::init();
@ -271,8 +255,12 @@ void Shaders::loadShaders()
MeshShader::GrassPass2Shader::init(); MeshShader::GrassPass2Shader::init();
MeshShader::BubbleShader::init(); MeshShader::BubbleShader::init();
MeshShader::TransparentShader::init(); MeshShader::TransparentShader::init();
MeshShader::TransparentFogShader::init();
MeshShader::BillboardShader::init(); MeshShader::BillboardShader::init();
MeshShader::DisplaceShader::init(); MeshShader::DisplaceShader::init();
MeshShader::ShadowShader::init();
MeshShader::RefShadowShader::init();
MeshShader::GrassShadowShader::init();
ParticleShader::FlipParticleRender::init(); ParticleShader::FlipParticleRender::init();
ParticleShader::HeightmapSimulationShader::init(); ParticleShader::HeightmapSimulationShader::init();
ParticleShader::SimpleParticleRender::init(); ParticleShader::SimpleParticleRender::init();
@ -794,6 +782,51 @@ namespace MeshShader
glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer()); glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer());
glUniform1i(uniform_tex, TU_tex); glUniform1i(uniform_tex, TU_tex);
} }
GLuint TransparentFogShader::Program;
GLuint TransparentFogShader::attrib_position;
GLuint TransparentFogShader::attrib_texcoord;
GLuint TransparentFogShader::uniform_MVP;
GLuint TransparentFogShader::uniform_tex;
GLuint TransparentFogShader::uniform_fogmax;
GLuint TransparentFogShader::uniform_startH;
GLuint TransparentFogShader::uniform_endH;
GLuint TransparentFogShader::uniform_start;
GLuint TransparentFogShader::uniform_end;
GLuint TransparentFogShader::uniform_col;
GLuint TransparentFogShader::uniform_screen;
GLuint TransparentFogShader::uniform_ipvmat;
void TransparentFogShader::init()
{
Program = LoadProgram(file_manager->getAsset("shaders/transparent.vert").c_str(), file_manager->getAsset("shaders/transparentfog.frag").c_str());
attrib_position = glGetAttribLocation(Program, "Position");
attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix");
uniform_tex = glGetUniformLocation(Program, "tex");
uniform_fogmax = glGetUniformLocation(Program, "fogmax");
uniform_startH = glGetUniformLocation(Program, "startH");
uniform_endH = glGetUniformLocation(Program, "endH");
uniform_start = glGetUniformLocation(Program, "start");
uniform_end = glGetUniformLocation(Program, "end");
uniform_col = glGetUniformLocation(Program, "col");
uniform_screen = glGetUniformLocation(Program, "screen");
uniform_ipvmat = glGetUniformLocation(Program, "ipvmat");
}
void TransparentFogShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &ipvmat, float fogmax, float startH, float endH, float start, float end, const core::vector3df &col, const core::vector3df &campos, unsigned TU_tex)
{
glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer());
glUniform1f(uniform_fogmax, fogmax);
glUniform1f(uniform_startH, startH);
glUniform1f(uniform_endH, endH);
glUniform1f(uniform_start, start);
glUniform1f(uniform_end, end);
glUniform3f(uniform_col, col.X, col.Y, col.Z);
glUniform2f(uniform_screen, UserConfigParams::m_width, UserConfigParams::m_height);
glUniformMatrix4fv(uniform_ipvmat, 1, GL_FALSE, ipvmat.pointer());
glUniform1i(uniform_tex, TU_tex);
}
GLuint BillboardShader::Program; GLuint BillboardShader::Program;
GLuint BillboardShader::attrib_corner; GLuint BillboardShader::attrib_corner;
@ -814,7 +847,6 @@ namespace MeshShader
uniform_Position = glGetUniformLocation(Program, "Position"); uniform_Position = glGetUniformLocation(Program, "Position");
uniform_Size = glGetUniformLocation(Program, "Size"); uniform_Size = glGetUniformLocation(Program, "Size");
uniform_tex = glGetUniformLocation(Program, "tex"); uniform_tex = glGetUniformLocation(Program, "tex");
printf("TUTex is %d, Texcoord is %d\n", uniform_tex, attrib_texcoord);
} }
void BillboardShader::setUniforms(const core::matrix4 &ModelViewMatrix, const core::matrix4 &ProjectionMatrix, const core::vector3df &Position, const core::dimension2d<float> &size, unsigned TU_tex) void BillboardShader::setUniforms(const core::matrix4 &ModelViewMatrix, const core::matrix4 &ProjectionMatrix, const core::vector3df &Position, const core::dimension2d<float> &size, unsigned TU_tex)
@ -845,6 +877,69 @@ namespace MeshShader
glUniform3f(uniform_col, r, g, b); glUniform3f(uniform_col, r, g, b);
} }
GLuint ShadowShader::Program;
GLuint ShadowShader::attrib_position;
GLuint ShadowShader::uniform_MVP;
void ShadowShader::init()
{
Program = LoadProgram(file_manager->getAsset("shaders/object_pass2.vert").c_str(), file_manager->getAsset("shaders/white.frag").c_str());
attrib_position = glGetAttribLocation(Program, "Position");
uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix");
}
void ShadowShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix)
{
glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer());
}
GLuint RefShadowShader::Program;
GLuint RefShadowShader::attrib_position;
GLuint RefShadowShader::attrib_texcoord;
GLuint RefShadowShader::uniform_MVP;
GLuint RefShadowShader::uniform_tex;
void RefShadowShader::init()
{
Program = LoadProgram(file_manager->getAsset("shaders/object_pass2.vert").c_str(), file_manager->getAsset("shaders/object_unlit.frag").c_str());
attrib_position = glGetAttribLocation(Program, "Position");
attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix");
uniform_tex = glGetUniformLocation(Program, "tex");
}
void RefShadowShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, unsigned TU_tex)
{
glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer());
glUniform1i(uniform_tex, TU_tex);
}
GLuint GrassShadowShader::Program;
GLuint GrassShadowShader::attrib_position;
GLuint GrassShadowShader::attrib_texcoord;
GLuint GrassShadowShader::attrib_color;
GLuint GrassShadowShader::uniform_MVP;
GLuint GrassShadowShader::uniform_tex;
GLuint GrassShadowShader::uniform_windDir;
void GrassShadowShader::init()
{
Program = LoadProgram(file_manager->getAsset("shaders/grass_pass2.vert").c_str(), file_manager->getAsset("shaders/object_unlit.frag").c_str());
attrib_position = glGetAttribLocation(Program, "Position");
attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix");
uniform_tex = glGetUniformLocation(Program, "tex");
attrib_color = glGetAttribLocation(Program, "Color");
uniform_windDir = glGetUniformLocation(Program, "windDir");
}
void GrassShadowShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::vector3df &windDirection, unsigned TU_tex)
{
glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer());
glUniform1i(uniform_tex, TU_tex);
glUniform3f(uniform_windDir, windDirection.X, windDirection.Y, windDirection.Z);
}
GLuint DisplaceShader::Program; GLuint DisplaceShader::Program;
GLuint DisplaceShader::attrib_position; GLuint DisplaceShader::attrib_position;
GLuint DisplaceShader::attrib_texcoord; GLuint DisplaceShader::attrib_texcoord;
@ -1180,7 +1275,6 @@ namespace FullScreenShader
uniform_col = glGetUniformLocation(Program, "col"); uniform_col = glGetUniformLocation(Program, "col");
uniform_invproj = glGetUniformLocation(Program, "invproj"); uniform_invproj = glGetUniformLocation(Program, "invproj");
vao = createVAO(Program); vao = createVAO(Program);
printf("uniform %d\n", uniform_ntex);
} }
void SunLightShader::setUniforms(const core::vector3df &direction, const core::matrix4 &InvProjMatrix, float r, float g, float b, unsigned TU_ntex, unsigned TU_dtex) void SunLightShader::setUniforms(const core::vector3df &direction, const core::matrix4 &InvProjMatrix, float r, float g, float b, unsigned TU_ntex, unsigned TU_dtex)
@ -1192,23 +1286,39 @@ namespace FullScreenShader
glUniform1i(uniform_dtex, TU_dtex); glUniform1i(uniform_dtex, TU_dtex);
} }
GLuint LightBlendShader::Program; GLuint ShadowedSunLightShader::Program;
GLuint LightBlendShader::uniform_diffuse; GLuint ShadowedSunLightShader::uniform_ntex;
GLuint LightBlendShader::uniform_specular; GLuint ShadowedSunLightShader::uniform_dtex;
GLuint LightBlendShader::uniform_ambient_occlusion; GLuint ShadowedSunLightShader::uniform_shadowtex;
GLuint LightBlendShader::uniform_specular_map; GLuint ShadowedSunLightShader::uniform_shadowmat;
GLuint LightBlendShader::uniform_ambient; GLuint ShadowedSunLightShader::uniform_direction;
GLuint LightBlendShader::vao; GLuint ShadowedSunLightShader::uniform_col;
void LightBlendShader::init() GLuint ShadowedSunLightShader::uniform_invproj;
{ GLuint ShadowedSunLightShader::vao;
Program = LoadProgram(file_manager->getAsset("shaders/screenquad.vert").c_str(), file_manager->getAsset("shaders/lightblend.frag").c_str());
uniform_diffuse = glGetUniformLocation(Program, "diffuse"); void ShadowedSunLightShader::init()
uniform_specular = glGetUniformLocation(Program, "specular"); {
uniform_ambient_occlusion = glGetUniformLocation(Program, "ambient_occlusion"); Program = LoadProgram(file_manager->getAsset("shaders/screenquad.vert").c_str(), file_manager->getAsset("shaders/sunlightshadow.frag").c_str());
uniform_specular_map = glGetUniformLocation(Program, "specular_map"); uniform_ntex = glGetUniformLocation(Program, "ntex");
uniform_ambient = glGetUniformLocation(Program, "ambient"); uniform_dtex = glGetUniformLocation(Program, "dtex");
vao = createVAO(Program); uniform_shadowtex = glGetUniformLocation(Program, "shadowtex");
} uniform_shadowmat = glGetUniformLocation(Program, "shadowmat"),
uniform_direction = glGetUniformLocation(Program, "direction");
uniform_col = glGetUniformLocation(Program, "col");
uniform_invproj = glGetUniformLocation(Program, "invproj");
vao = createVAO(Program);
}
void ShadowedSunLightShader::setUniforms(const core::matrix4 &shadowmat, const core::vector3df &direction, const core::matrix4 &InvProjMatrix, float r, float g, float b, unsigned TU_ntex, unsigned TU_dtex, unsigned TU_shadowtex)
{
glUniformMatrix4fv(uniform_shadowmat, 1, GL_FALSE, shadowmat.pointer());
glUniformMatrix4fv(uniform_invproj, 1, GL_FALSE, InvProjMatrix.pointer());
glUniform3f(uniform_direction, direction.X, direction.Y, direction.Z);
glUniform3f(uniform_col, r, g, b);
glUniform1i(uniform_ntex, TU_ntex);
glUniform1i(uniform_dtex, TU_dtex);
glUniform1i(uniform_shadowtex, TU_shadowtex);
}
GLuint Gaussian6HBlurShader::Program; GLuint Gaussian6HBlurShader::Program;
GLuint Gaussian6HBlurShader::uniform_tex; GLuint Gaussian6HBlurShader::uniform_tex;
@ -1432,7 +1542,6 @@ namespace FullScreenShader
GLuint FogShader::uniform_start; GLuint FogShader::uniform_start;
GLuint FogShader::uniform_end; GLuint FogShader::uniform_end;
GLuint FogShader::uniform_col; GLuint FogShader::uniform_col;
GLuint FogShader::uniform_campos;
GLuint FogShader::uniform_ipvmat; GLuint FogShader::uniform_ipvmat;
GLuint FogShader::vao; GLuint FogShader::vao;
@ -1446,22 +1555,20 @@ namespace FullScreenShader
uniform_start = glGetUniformLocation(Program, "start"); uniform_start = glGetUniformLocation(Program, "start");
uniform_end = glGetUniformLocation(Program, "end"); uniform_end = glGetUniformLocation(Program, "end");
uniform_col = glGetUniformLocation(Program, "col"); uniform_col = glGetUniformLocation(Program, "col");
uniform_campos = glGetUniformLocation(Program, "campos");
uniform_ipvmat = glGetUniformLocation(Program, "ipvmat"); uniform_ipvmat = glGetUniformLocation(Program, "ipvmat");
vao = createVAO(Program); vao = createVAO(Program);
} }
void FogShader::setUniforms(const core::matrix4 &ipvmat, float fogmax, float startH, float endH, float start, float end, const core::vector3df &col, const core::vector3df &campos, unsigned TU_ntex) void FogShader::setUniforms(const core::matrix4 &ipvmat, float fogmax, float startH, float endH, float start, float end, const core::vector3df &col, unsigned TU_ntex)
{ {
glUniform1f(FullScreenShader::FogShader::uniform_fogmax, fogmax); glUniform1f(uniform_fogmax, fogmax);
glUniform1f(FullScreenShader::FogShader::uniform_startH, startH); glUniform1f(uniform_startH, startH);
glUniform1f(FullScreenShader::FogShader::uniform_endH, endH); glUniform1f(uniform_endH, endH);
glUniform1f(FullScreenShader::FogShader::uniform_start, start); glUniform1f(uniform_start, start);
glUniform1f(FullScreenShader::FogShader::uniform_end, end); glUniform1f(uniform_end, end);
glUniform3f(FullScreenShader::FogShader::uniform_col, col.X, col.Y, col.Z); glUniform3f(uniform_col, col.X, col.Y, col.Z);
glUniform3f(FullScreenShader::FogShader::uniform_campos, campos.X, campos.Y, campos.Z); glUniformMatrix4fv(uniform_ipvmat, 1, GL_FALSE, ipvmat.pointer());
glUniformMatrix4fv(FullScreenShader::FogShader::uniform_ipvmat, 1, GL_FALSE, ipvmat.pointer()); glUniform1i(uniform_tex, TU_ntex);
glUniform1i(FullScreenShader::FogShader::uniform_tex, TU_ntex);
} }
} }

View File

@ -191,6 +191,17 @@ public:
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, unsigned TU_tex); static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, unsigned TU_tex);
}; };
class TransparentFogShader
{
public:
static GLuint Program;
static GLuint attrib_position, attrib_texcoord;
static GLuint uniform_MVP, uniform_tex, uniform_fogmax, uniform_startH, uniform_endH, uniform_start, uniform_end, uniform_col, uniform_screen, uniform_ipvmat;
static void init();
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &ipvmat, float fogmax, float startH, float endH, float start, float end, const core::vector3df &col, const core::vector3df &campos, unsigned TU_tex);
};
class BillboardShader class BillboardShader
{ {
public: public:
@ -214,6 +225,39 @@ public:
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, float r, float g, float b); static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, float r, float g, float b);
}; };
class ShadowShader
{
public:
static GLuint Program;
static GLuint attrib_position;
static GLuint uniform_MVP;
static void init();
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix);
};
class RefShadowShader
{
public:
static GLuint Program;
static GLuint attrib_position, attrib_texcoord;
static GLuint uniform_MVP, uniform_tex;
static void init();
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, unsigned TU_tex);
};
class GrassShadowShader
{
public:
static GLuint Program;
static GLuint attrib_position, attrib_texcoord, attrib_color;
static GLuint uniform_MVP, uniform_tex, uniform_windDir;
static void init();
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::vector3df &windDirection, unsigned TU_tex);
};
class DisplaceShader class DisplaceShader
{ {
public: public:
@ -341,14 +385,15 @@ public:
static void setUniforms(const core::vector3df &direction, const core::matrix4 &InvProjMatrix, float r, float g, float b, unsigned TU_ntex, unsigned TU_dtex); static void setUniforms(const core::vector3df &direction, const core::matrix4 &InvProjMatrix, float r, float g, float b, unsigned TU_ntex, unsigned TU_dtex);
}; };
class LightBlendShader class ShadowedSunLightShader
{ {
public: public:
static GLuint Program; static GLuint Program;
static GLuint uniform_diffuse, uniform_specular, uniform_ambient_occlusion, uniform_specular_map, uniform_ambient; static GLuint uniform_ntex, uniform_dtex, uniform_shadowtex, uniform_shadowmat, uniform_direction, uniform_col, uniform_invproj;
static GLuint vao; static GLuint vao;
static void init(); static void init();
static void setUniforms(const core::matrix4 &shadowmat, const core::vector3df &direction, const core::matrix4 &InvProjMatrix, float r, float g, float b, unsigned TU_ntex, unsigned TU_dtex, unsigned TU_shadowtex);
}; };
class Gaussian6HBlurShader class Gaussian6HBlurShader
@ -427,11 +472,11 @@ class FogShader
{ {
public: public:
static GLuint Program; static GLuint Program;
static GLuint uniform_tex, uniform_fogmax, uniform_startH, uniform_endH, uniform_start, uniform_end, uniform_col, uniform_campos, uniform_ipvmat; static GLuint uniform_tex, uniform_fogmax, uniform_startH, uniform_endH, uniform_start, uniform_end, uniform_col, uniform_ipvmat;
static GLuint vao; static GLuint vao;
static void init(); static void init();
static void setUniforms(const core::matrix4 &ipvmat, float fogmax, float startH, float endH, float start, float end, const core::vector3df &col, const core::vector3df &campos, unsigned TU_ntex); static void setUniforms(const core::matrix4 &ipvmat, float fogmax, float startH, float endH, float start, float end, const core::vector3df &col, unsigned TU_ntex);
}; };
} }
@ -494,7 +539,6 @@ public:
ACT(ES_MIPVIZ) \ ACT(ES_MIPVIZ) \
ACT(ES_COLORIZE) \ ACT(ES_COLORIZE) \
ACT(ES_COLORIZE_REF) \ ACT(ES_COLORIZE_REF) \
ACT(ES_GLOW) \
ACT(ES_OBJECT_UNLIT) \ ACT(ES_OBJECT_UNLIT) \
ACT(ES_OBJECTPASS) \ ACT(ES_OBJECTPASS) \
ACT(ES_OBJECTPASS_REF) \ ACT(ES_OBJECTPASS_REF) \

View File

@ -4,6 +4,8 @@
#include <ISkinnedMesh.h> #include <ISkinnedMesh.h>
#include "graphics/irr_driver.hpp" #include "graphics/irr_driver.hpp"
#include "config/user_config.hpp" #include "config/user_config.hpp"
#include "modes/world.hpp"
#include "tracks/track.hpp"
using namespace irr; using namespace irr;
@ -30,7 +32,10 @@ void STKAnimatedMesh::drawTransparent(const GLMesh &mesh, video::E_MATERIAL_TYPE
computeMVP(ModelViewProjectionMatrix); computeMVP(ModelViewProjectionMatrix);
drawTransparentObject(mesh, ModelViewProjectionMatrix); if (World::getWorld()->getTrack()->isFogEnabled())
drawTransparentFogObject(mesh, ModelViewProjectionMatrix);
else
drawTransparentObject(mesh, ModelViewProjectionMatrix);
return; return;
} }
@ -89,6 +94,20 @@ isObjectPass(video::E_MATERIAL_TYPE type)
return false; return false;
} }
void STKAnimatedMesh::drawShadow(const GLMesh &mesh)
{
GLenum ptype = mesh.PrimitiveType;
GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount;
assert(irr_driver->getPhase() == SHADOW_PASS);
core::matrix4 ShadowMVP;
computeMVP(ShadowMVP);
glUseProgram(MeshShader::ShadowShader::Program);
MeshShader::ShadowShader::setUniforms(ShadowMVP);
glBindVertexArray(mesh.vao_shadow_pass);
glDrawElements(ptype, count, itype, 0);
}
void STKAnimatedMesh::render() void STKAnimatedMesh::render()
{ {
video::IVideoDriver* driver = SceneManager->getVideoDriver(); video::IVideoDriver* driver = SceneManager->getVideoDriver();
@ -106,9 +125,8 @@ void STKAnimatedMesh::render()
} }
else else
{ {
#ifdef _DEBUG Log::error("animated mesh", "Animated Mesh returned no mesh to render.");
os::Printer::log("Animated Mesh returned no mesh to render.", Mesh->getDebugName(), ELL_WARNING); return;
#endif
} }
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
@ -147,7 +165,9 @@ void STKAnimatedMesh::render()
glBindBuffer(GL_ARRAY_BUFFER, GLmeshes[i].vertex_buffer); glBindBuffer(GL_ARRAY_BUFFER, GLmeshes[i].vertex_buffer);
glBufferSubData(GL_ARRAY_BUFFER, 0, mb->getVertexCount() * GLmeshes[i].Stride, mb->getVertices()); glBufferSubData(GL_ARRAY_BUFFER, 0, mb->getVertexCount() * GLmeshes[i].Stride, mb->getVertices());
} }
if (isTransparentPass) if (irr_driver->getPhase() == SHADOW_PASS)
drawShadow(GLmeshes[i]);
else if (isTransparentPass)
drawTransparent(GLmeshes[i], material.MaterialType); drawTransparent(GLmeshes[i], material.MaterialType);
else else
drawSolid(GLmeshes[i], material.MaterialType); drawSolid(GLmeshes[i], material.MaterialType);

View File

@ -15,6 +15,7 @@ protected:
core::matrix4 ModelViewProjectionMatrix, TransposeInverseModelView; core::matrix4 ModelViewProjectionMatrix, TransposeInverseModelView;
void drawSolid(const GLMesh &mesh, video::E_MATERIAL_TYPE type); void drawSolid(const GLMesh &mesh, video::E_MATERIAL_TYPE type);
void drawTransparent(const GLMesh &mesh, video::E_MATERIAL_TYPE type); void drawTransparent(const GLMesh &mesh, video::E_MATERIAL_TYPE type);
void drawShadow(const GLMesh &mesh);
public: public:
STKAnimatedMesh(irr::scene::IAnimatedMesh* mesh, irr::scene::ISceneNode* parent, STKAnimatedMesh(irr::scene::IAnimatedMesh* mesh, irr::scene::ISceneNode* parent,
irr::scene::ISceneManager* mgr, irr::s32 id, irr::scene::ISceneManager* mgr, irr::s32 id,

View File

@ -1,10 +1,13 @@
#include "stkmesh.hpp" #include "stkmesh.hpp"
#include "graphics/irr_driver.hpp" #include "graphics/irr_driver.hpp"
#include "tracks/track.hpp"
#include <ISceneManager.h> #include <ISceneManager.h>
#include <IMaterialRenderer.h> #include <IMaterialRenderer.h>
#include "config/user_config.hpp" #include "config/user_config.hpp"
#include "graphics/callbacks.hpp" #include "graphics/callbacks.hpp"
#include "utils/helpers.hpp" #include "utils/helpers.hpp"
#include "graphics/camera.hpp"
#include "modes/world.hpp"
GLuint createVAO(GLuint vbo, GLuint idx, GLuint attrib_position, GLuint attrib_texcoord, GLuint attrib_second_texcoord, GLuint attrib_normal, GLuint attrib_tangent, GLuint attrib_bitangent, GLuint attrib_color, size_t stride) GLuint createVAO(GLuint vbo, GLuint idx, GLuint attrib_position, GLuint attrib_texcoord, GLuint attrib_second_texcoord, GLuint attrib_normal, GLuint attrib_tangent, GLuint attrib_bitangent, GLuint attrib_color, size_t stride)
@ -222,18 +225,20 @@ void drawObjectPass1(const GLMesh &mesh, const core::matrix4 & ModelViewProjecti
void drawObjectRefPass1(const GLMesh &mesh, const core::matrix4 & ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView) void drawObjectRefPass1(const GLMesh &mesh, const core::matrix4 & ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView)
{ {
glDisable(GL_CULL_FACE);
GLenum ptype = mesh.PrimitiveType; GLenum ptype = mesh.PrimitiveType;
GLenum itype = mesh.IndexType; GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount; size_t count = mesh.IndexCount;
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR); setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
glUseProgram(MeshShader::ObjectRefPass1Shader::Program); glUseProgram(MeshShader::ObjectRefPass1Shader::Program);
MeshShader::ObjectRefPass1Shader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView, 0); MeshShader::ObjectRefPass1Shader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView, 0);
glBindVertexArray(mesh.vao_first_pass); glBindVertexArray(mesh.vao_first_pass);
glDrawElements(ptype, count, itype, 0); glDrawElements(ptype, count, itype, 0);
glEnable(GL_CULL_FACE);
} }
static static
@ -258,7 +263,7 @@ void drawGrassPass1(const GLMesh &mesh, const core::matrix4 & ModelViewProjectio
GLenum itype = mesh.IndexType; GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount; size_t count = mesh.IndexCount;
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR); setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
glUseProgram(MeshShader::GrassPass1Shader::Program); glUseProgram(MeshShader::GrassPass1Shader::Program);
MeshShader::GrassPass1Shader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView, windDir, 0); MeshShader::GrassPass1Shader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView, windDir, 0);
@ -274,7 +279,7 @@ void drawNormalPass(const GLMesh &mesh, const core::matrix4 & ModelViewProjectio
size_t count = mesh.IndexCount; size_t count = mesh.IndexCount;
assert(mesh.textures[1]); assert(mesh.textures[1]);
setTexture(0, mesh.textures[1], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR); setTexture(0, mesh.textures[1], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
glUseProgram(MeshShader::NormalMapShader::Program); glUseProgram(MeshShader::NormalMapShader::Program);
MeshShader::NormalMapShader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView, 0); MeshShader::NormalMapShader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView, 0);
@ -289,7 +294,7 @@ void drawSphereMap(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionM
GLenum itype = mesh.IndexType; GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount; size_t count = mesh.IndexCount;
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR); setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
glUseProgram(MeshShader::SphereMapShader::Program); glUseProgram(MeshShader::SphereMapShader::Program);
MeshShader::SphereMapShader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView, 0); MeshShader::SphereMapShader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView, 0);
@ -305,7 +310,7 @@ void drawSplatting(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionM
size_t count = mesh.IndexCount; size_t count = mesh.IndexCount;
// Texlayout // Texlayout
setTexture(0, mesh.textures[1], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR); setTexture(0, mesh.textures[1], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
if (irr_driver->getLightViz()) if (irr_driver->getLightViz())
{ {
GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_ALPHA}; GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_ALPHA};
@ -317,7 +322,7 @@ void drawSplatting(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionM
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask); glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
} }
//Tex detail0 //Tex detail0
setTexture(1, mesh.textures[2], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR); setTexture(1, mesh.textures[2], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
if (irr_driver->getLightViz()) if (irr_driver->getLightViz())
{ {
GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_ALPHA}; GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_ALPHA};
@ -329,7 +334,7 @@ void drawSplatting(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionM
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask); glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
} }
//Tex detail1 //Tex detail1
setTexture(2, mesh.textures[3], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR); setTexture(2, mesh.textures[3], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
if (irr_driver->getLightViz()) if (irr_driver->getLightViz())
{ {
GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_ALPHA}; GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_ALPHA};
@ -341,7 +346,7 @@ void drawSplatting(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionM
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask); glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
} }
//Tex detail2 //Tex detail2
setTexture(3, mesh.textures[4], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR); setTexture(3, mesh.textures[4], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
if (irr_driver->getLightViz()) if (irr_driver->getLightViz())
{ {
GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_ALPHA}; GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_ALPHA};
@ -353,7 +358,7 @@ void drawSplatting(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionM
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask); glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
} }
//Tex detail3 //Tex detail3
setTexture(4, mesh.textures[5], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR); setTexture(4, mesh.textures[5], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
if (irr_driver->getLightViz()) if (irr_driver->getLightViz())
{ {
GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_ALPHA}; GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_ALPHA};
@ -387,11 +392,12 @@ void drawSplatting(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionM
void drawObjectRefPass2(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix) void drawObjectRefPass2(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix)
{ {
glDisable(GL_CULL_FACE);
GLenum ptype = mesh.PrimitiveType; GLenum ptype = mesh.PrimitiveType;
GLenum itype = mesh.IndexType; GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount; size_t count = mesh.IndexCount;
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR); setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
if (irr_driver->getLightViz()) if (irr_driver->getLightViz())
{ {
GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_ALPHA}; GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_ALPHA};
@ -416,6 +422,7 @@ void drawObjectRefPass2(const GLMesh &mesh, const core::matrix4 &ModelViewProjec
glBindVertexArray(mesh.vao_second_pass); glBindVertexArray(mesh.vao_second_pass);
glDrawElements(ptype, count, itype, 0); glDrawElements(ptype, count, itype, 0);
glEnable(GL_CULL_FACE);
} }
void drawGrassPass2(const GLMesh &mesh, const core::matrix4 & ModelViewProjectionMatrix, core::vector3df windDir) void drawGrassPass2(const GLMesh &mesh, const core::matrix4 & ModelViewProjectionMatrix, core::vector3df windDir)
@ -424,7 +431,7 @@ void drawGrassPass2(const GLMesh &mesh, const core::matrix4 & ModelViewProjectio
GLenum itype = mesh.IndexType; GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount; size_t count = mesh.IndexCount;
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR); setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
if (irr_driver->getLightViz()) if (irr_driver->getLightViz())
{ {
GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_ALPHA}; GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_ALPHA};
@ -480,7 +487,7 @@ void drawObjectRimLimit(const GLMesh &mesh, const core::matrix4 &ModelViewProjec
GLenum itype = mesh.IndexType; GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount; size_t count = mesh.IndexCount;
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR); setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
if (irr_driver->getLightViz()) if (irr_driver->getLightViz())
{ {
GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ALPHA }; GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ALPHA };
@ -514,7 +521,7 @@ void drawObjectUnlit(const GLMesh &mesh, const core::matrix4 &ModelViewProjectio
GLenum itype = mesh.IndexType; GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount; size_t count = mesh.IndexCount;
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR); setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
if (irr_driver->getLightViz()) if (irr_driver->getLightViz())
{ {
GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ALPHA }; GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ALPHA };
@ -540,7 +547,7 @@ void drawDetailledObjectPass2(const GLMesh &mesh, const core::matrix4 &ModelView
GLenum itype = mesh.IndexType; GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount; size_t count = mesh.IndexCount;
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR); setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
if (irr_driver->getLightViz()) if (irr_driver->getLightViz())
{ {
GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_ALPHA}; GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_ALPHA};
@ -552,7 +559,7 @@ void drawDetailledObjectPass2(const GLMesh &mesh, const core::matrix4 &ModelView
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask); glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
} }
setTexture(1, mesh.textures[1], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR); setTexture(1, mesh.textures[1], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
setTexture(2, 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_TMP1))->getOpenGLTextureName(), GL_NEAREST, GL_NEAREST);
setTexture(3, 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_TMP2))->getOpenGLTextureName(), GL_NEAREST, GL_NEAREST);
@ -576,7 +583,7 @@ void drawObjectPass2(const GLMesh &mesh, const core::matrix4 &ModelViewProjectio
GLenum itype = mesh.IndexType; GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount; size_t count = mesh.IndexCount;
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR); setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
if (irr_driver->getLightViz()) if (irr_driver->getLightViz())
{ {
GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ALPHA }; GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ALPHA };
@ -610,7 +617,7 @@ void drawTransparentObject(const GLMesh &mesh, const core::matrix4 &ModelViewPro
GLenum itype = mesh.IndexType; GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount; size_t count = mesh.IndexCount;
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR); setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
glUseProgram(MeshShader::TransparentShader::Program); glUseProgram(MeshShader::TransparentShader::Program);
MeshShader::TransparentShader::setUniforms(ModelViewProjectionMatrix, 0); MeshShader::TransparentShader::setUniforms(ModelViewProjectionMatrix, 0);
@ -619,6 +626,35 @@ void drawTransparentObject(const GLMesh &mesh, const core::matrix4 &ModelViewPro
glDrawElements(ptype, count, itype, 0); glDrawElements(ptype, count, itype, 0);
} }
void drawTransparentFogObject(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix)
{
GLenum ptype = mesh.PrimitiveType;
GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount;
const Track * const track = World::getWorld()->getTrack();
// This function is only called once per frame - thus no need for setters.
const float fogmax = track->getFogMax();
const float startH = track->getFogStartHeight();
const float endH = track->getFogEndHeight();
const float start = track->getFogStart();
const float end = track->getFogEnd();
const video::SColor tmpcol = track->getFogColor();
core::vector3df col(tmpcol.getRed() / 255.0f,
tmpcol.getGreen() / 255.0f,
tmpcol.getBlue() / 255.0f);
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
glUseProgram(MeshShader::TransparentFogShader::Program);
MeshShader::TransparentFogShader::setUniforms(ModelViewProjectionMatrix, irr_driver->getInvProjMatrix(), fogmax, startH, endH, start, end, col, Camera::getCamera(0)->getCameraSceneNode()->getAbsolutePosition(), 0);
glBindVertexArray(mesh.vao_first_pass);
glDrawElements(ptype, count, itype, 0);
}
void drawBubble(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix) void drawBubble(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix)
{ {
const float time = irr_driver->getDevice()->getTimer()->getTime() / 1000.0f; const float time = irr_driver->getDevice()->getTimer()->getTime() / 1000.0f;
@ -628,7 +664,7 @@ void drawBubble(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatr
GLenum itype = mesh.IndexType; GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount; size_t count = mesh.IndexCount;
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR); setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
glUseProgram(MeshShader::BubbleShader::Program); glUseProgram(MeshShader::BubbleShader::Program);
MeshShader::BubbleShader::setUniforms(ModelViewProjectionMatrix, 0, time, transparency); MeshShader::BubbleShader::setUniforms(ModelViewProjectionMatrix, 0, time, transparency);
@ -664,7 +700,7 @@ void STKMesh::drawDisplace(const GLMesh &mesh)
computeMVP(ModelViewProjectionMatrix); computeMVP(ModelViewProjectionMatrix);
core::matrix4 ModelViewMatrix = irr_driver->getVideoDriver()->getTransform(video::ETS_VIEW); core::matrix4 ModelViewMatrix = irr_driver->getVideoDriver()->getTransform(video::ETS_VIEW);
ModelViewMatrix *= irr_driver->getVideoDriver()->getTransform(video::ETS_WORLD); ModelViewMatrix *= irr_driver->getVideoDriver()->getTransform(video::ETS_WORLD);
setTexture(0, static_cast<irr::video::COpenGLTexture*>(irr_driver->getTexture(FileManager::TEXTURE, "displace.png"))->getOpenGLTextureName(), GL_LINEAR, GL_LINEAR); setTexture(0, static_cast<irr::video::COpenGLTexture*>(irr_driver->getTexture(FileManager::TEXTURE, "displace.png"))->getOpenGLTextureName(), GL_LINEAR, GL_LINEAR, true);
glUseProgram(MeshShader::DisplaceShader::Program); glUseProgram(MeshShader::DisplaceShader::Program);
MeshShader::DisplaceShader::setUniforms(ModelViewProjectionMatrix, ModelViewMatrix, cb->getDirX(), cb->getDirY(), cb->getDir2X(), cb->getDir2Y(), 0); MeshShader::DisplaceShader::setUniforms(ModelViewProjectionMatrix, ModelViewMatrix, cb->getDirX(), cb->getDirY(), cb->getDir2X(), cb->getDir2Y(), 0);
@ -678,13 +714,47 @@ void STKMesh::drawTransparent(const GLMesh &mesh, video::E_MATERIAL_TYPE type)
computeMVP(ModelViewProjectionMatrix); computeMVP(ModelViewProjectionMatrix);
if (type == irr_driver->getShader(ES_BUBBLES)) if (type == irr_driver->getShader(ES_BUBBLES))
drawBubble(mesh, ModelViewProjectionMatrix); drawBubble(mesh, ModelViewProjectionMatrix);
else if (World::getWorld()->getTrack()->isFogEnabled())
drawTransparentFogObject(mesh, ModelViewProjectionMatrix);
else else
drawTransparentObject(mesh, ModelViewProjectionMatrix); drawTransparentObject(mesh, ModelViewProjectionMatrix);
return; return;
} }
void STKMesh::drawShadow(const GLMesh &mesh, video::E_MATERIAL_TYPE type)
{
GLenum ptype = mesh.PrimitiveType;
GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount;
core::matrix4 ShadowMVP;
computeMVP(ShadowMVP);
if (type == irr_driver->getShader(ES_OBJECTPASS_REF))
{
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
glUseProgram(MeshShader::RefShadowShader::Program);
MeshShader::RefShadowShader::setUniforms(ShadowMVP, 0);
}
else if (type == irr_driver->getShader(ES_GRASS) || type == irr_driver->getShader(ES_GRASS_REF))
{
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
glUseProgram(MeshShader::GrassShadowShader::Program);
MeshShader::GrassShadowShader::setUniforms(ShadowMVP, windDir, 0);
}
else
{
glUseProgram(MeshShader::ShadowShader::Program);
MeshShader::ShadowShader::setUniforms(ShadowMVP);
}
glBindVertexArray(mesh.vao_shadow_pass);
glDrawElements(ptype, count, itype, 0);
}
void STKMesh::drawSolid(const GLMesh &mesh, video::E_MATERIAL_TYPE type) void STKMesh::drawSolid(const GLMesh &mesh, video::E_MATERIAL_TYPE type)
{ {
switch (irr_driver->getPhase()) switch (irr_driver->getPhase())
@ -856,6 +926,11 @@ void initvaostate(GLMesh &mesh, video::E_MATERIAL_TYPE type)
mesh.vao_first_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, mesh.vao_first_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
MeshShader::BubbleShader::attrib_position, MeshShader::BubbleShader::attrib_texcoord, -1, -1, -1, -1, -1, mesh.Stride); MeshShader::BubbleShader::attrib_position, MeshShader::BubbleShader::attrib_texcoord, -1, -1, -1, -1, -1, mesh.Stride);
} }
else if (World::getWorld()->getTrack()->isFogEnabled())
{
mesh.vao_first_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
MeshShader::TransparentFogShader::attrib_position, MeshShader::TransparentFogShader::attrib_texcoord, -1, -1, -1, -1, -1, mesh.Stride);
}
else else
{ {
mesh.vao_first_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, mesh.vao_first_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
@ -867,6 +942,22 @@ void initvaostate(GLMesh &mesh, video::E_MATERIAL_TYPE type)
return; return;
mesh.vao_displace_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::DisplaceShader::attrib_position, MeshShader::DisplaceShader::attrib_texcoord, MeshShader::DisplaceShader::attrib_second_texcoord, -1, -1, -1, -1, mesh.Stride); mesh.vao_displace_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::DisplaceShader::attrib_position, MeshShader::DisplaceShader::attrib_texcoord, MeshShader::DisplaceShader::attrib_second_texcoord, -1, -1, -1, -1, mesh.Stride);
return; return;
case SHADOW_PASS:
if (mesh.vao_shadow_pass)
return;
if (type == irr_driver->getShader(ES_OBJECTPASS_REF))
{
mesh.vao_shadow_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::RefShadowShader::attrib_position, MeshShader::RefShadowShader::attrib_texcoord, -1, -1, -1, -1, -1, mesh.Stride);
}
else if (type == irr_driver->getShader(ES_GRASS) || type == irr_driver->getShader(ES_GRASS_REF))
{
mesh.vao_shadow_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::GrassShadowShader::attrib_position, MeshShader::GrassShadowShader::attrib_texcoord, -1, -1, -1, -1, MeshShader::GrassShadowShader::attrib_color, mesh.Stride);
}
else
{
mesh.vao_shadow_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::ShadowShader::attrib_position, -1, -1, -1, -1, -1, -1, mesh.Stride);
}
return;
} }
} }
@ -918,6 +1009,11 @@ void STKMesh::render()
initvaostate(GLmeshes[i], material.MaterialType); initvaostate(GLmeshes[i], material.MaterialType);
drawGlow(GLmeshes[i]); drawGlow(GLmeshes[i]);
} }
else if (irr_driver->getPhase() == SHADOW_PASS)
{
initvaostate(GLmeshes[i], material.MaterialType);
drawShadow(GLmeshes[i], material.MaterialType);
}
else else
{ {
irr_driver->IncreaseObjectCount(); irr_driver->IncreaseObjectCount();

View File

@ -13,6 +13,7 @@ struct GLMesh {
GLuint vao_second_pass; GLuint vao_second_pass;
GLuint vao_glow_pass; GLuint vao_glow_pass;
GLuint vao_displace_pass; GLuint vao_displace_pass;
GLuint vao_shadow_pass;
GLuint vertex_buffer; GLuint vertex_buffer;
GLuint index_buffer; GLuint index_buffer;
GLuint textures[6]; GLuint textures[6];
@ -47,6 +48,7 @@ void drawObjectUnlit(const GLMesh &mesh, const core::matrix4 &ModelViewProjectio
// Forward pass (for transparents meshes) // Forward pass (for transparents meshes)
void drawTransparentObject(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix); void drawTransparentObject(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix);
void drawTransparentFogObject(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix);
void drawBubble(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix); void drawBubble(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix);
class STKMesh : public irr::scene::CMeshSceneNode class STKMesh : public irr::scene::CMeshSceneNode
@ -61,6 +63,7 @@ protected:
// Misc passes shaders (glow, displace...) // Misc passes shaders (glow, displace...)
void drawGlow(const GLMesh &mesh); void drawGlow(const GLMesh &mesh);
void drawDisplace(const GLMesh &mesh); void drawDisplace(const GLMesh &mesh);
void drawShadow(const GLMesh &mesh, video::E_MATERIAL_TYPE type);
void createGLMeshes(); void createGLMeshes();
void cleanGLMeshes(); void cleanGLMeshes();
public: public:

View File

@ -24,11 +24,13 @@
#include "config/player.hpp" #include "config/player.hpp"
#include "config/user_config.hpp" #include "config/user_config.hpp"
#include "graphics/irr_driver.hpp" #include "graphics/irr_driver.hpp"
#include "input/wiimote_manager.hpp"
#include "io/file_manager.hpp" #include "io/file_manager.hpp"
#include "states_screens/kart_selection.hpp" #include "states_screens/kart_selection.hpp"
#include "states_screens/state_manager.hpp" #include "states_screens/state_manager.hpp"
#include "utils/log.hpp"
#include "utils/translation.hpp" #include "utils/translation.hpp"
#include "input/wiimote_manager.hpp"
#define INPUT_MODE_DEBUG 0 #define INPUT_MODE_DEBUG 0
@ -56,18 +58,18 @@ bool DeviceManager::initialize()
if(UserConfigParams::logMisc()) if(UserConfigParams::logMisc())
{ {
printf("Initializing Device Manager\n"); Log::info("Device manager","Initializing Device Manager");
printf("---------------------------\n"); Log::info("-","---------------------------");
} }
deserialize(); deserialize();
// Assign a configuration to the keyboard, or create one if we haven't yet // Assign a configuration to the keyboard, or create one if we haven't yet
if(UserConfigParams::logMisc()) printf("Initializing keyboard support.\n"); if(UserConfigParams::logMisc()) Log::info("Device manager","Initializing keyboard support.");
if (m_keyboard_configs.size() == 0) if (m_keyboard_configs.size() == 0)
{ {
if(UserConfigParams::logMisc()) if(UserConfigParams::logMisc())
printf("No keyboard configuration exists, creating one.\n"); Log::info("Device manager","No keyboard configuration exists, creating one.");
m_keyboard_configs.push_back(new KeyboardConfig()); m_keyboard_configs.push_back(new KeyboardConfig());
created = true; created = true;
} }
@ -79,13 +81,13 @@ bool DeviceManager::initialize()
} }
if(UserConfigParams::logMisc()) if(UserConfigParams::logMisc())
printf("Initializing gamepad support.\n"); Log::info("Device manager","Initializing gamepad support.");
irr_driver->getDevice()->activateJoysticks(m_irrlicht_gamepads); irr_driver->getDevice()->activateJoysticks(m_irrlicht_gamepads);
int num_gamepads = m_irrlicht_gamepads.size(); int num_gamepads = m_irrlicht_gamepads.size();
if(UserConfigParams::logMisc()) if(UserConfigParams::logMisc())
{ {
printf("Irrlicht reports %d gamepads are attached to the system.\n", Log::info("Device manager","Irrlicht reports %d gamepads are attached to the system.",
num_gamepads); num_gamepads);
} }
@ -109,19 +111,19 @@ bool DeviceManager::initialize()
if (UserConfigParams::logMisc()) if (UserConfigParams::logMisc())
{ {
printf("#%d: %s detected...", id, name.c_str()); Log::info("Device manager","#%d: %s detected...", id, name.c_str());
} }
// Returns true if new configuration was created // Returns true if new configuration was created
if (getConfigForGamepad(id, name, &gamepadConfig) == true) if (getConfigForGamepad(id, name, &gamepadConfig) == true)
{ {
if(UserConfigParams::logMisc()) if(UserConfigParams::logMisc())
printf("creating new configuration.\n"); Log::info("Device manager","creating new configuration.");
created = true; created = true;
} }
else else
{ {
if(UserConfigParams::logMisc()) if(UserConfigParams::logMisc())
printf("using existing configuration.\n"); Log::info("Device manager","using existing configuration.");
} }
gamepadConfig->setPlugged(); gamepadConfig->setPlugged();
@ -440,12 +442,12 @@ bool DeviceManager::deserialize()
static std::string filepath = file_manager->getUserConfigFile(INPUT_FILE_NAME); static std::string filepath = file_manager->getUserConfigFile(INPUT_FILE_NAME);
if(UserConfigParams::logMisc()) if(UserConfigParams::logMisc())
printf("Deserializing input.xml...\n"); Log::info("Device manager","Deserializing input.xml...");
if(!file_manager->fileExists(filepath)) if(!file_manager->fileExists(filepath))
{ {
if(UserConfigParams::logMisc()) if(UserConfigParams::logMisc())
printf("Warning: no configuration file exists.\n"); Log::warn("Device manager","No configuration file exists.");
} }
else else
{ {
@ -499,15 +501,15 @@ bool DeviceManager::deserialize()
{ {
if(keyboard_config != NULL) if(keyboard_config != NULL)
if(!keyboard_config->deserializeAction(xml)) if(!keyboard_config->deserializeAction(xml))
std::cerr << "Ignoring an ill-formed keyboard action in input config.\n"; Log::error("Device manager","Ignoring an ill-formed keyboard action in input config.");
} }
else if(reading_now == GAMEPAD) else if(reading_now == GAMEPAD)
{ {
if(gamepad_config != NULL) if(gamepad_config != NULL)
if(!gamepad_config->deserializeAction(xml)) if(!gamepad_config->deserializeAction(xml))
std::cerr << "Ignoring an ill-formed gamepad action in input config.\n"; Log::error("Device manager","Ignoring an ill-formed gamepad action in input config.");
} }
else std::cerr << "Warning: An action is placed in an unexpected area in the input config file.\n"; else Log::warn("Device manager","An action is placed in an unexpected area in the input config file.");
} }
} }
break; break;
@ -534,7 +536,7 @@ bool DeviceManager::deserialize()
if(UserConfigParams::logMisc()) if(UserConfigParams::logMisc())
{ {
printf("Found %d keyboard and %d gamepad configurations.\n", Log::info("Device manager","Found %d keyboard and %d gamepad configurations.",
m_keyboard_configs.size(), m_gamepad_configs.size()); m_keyboard_configs.size(), m_gamepad_configs.size());
} }
@ -557,7 +559,7 @@ bool DeviceManager::deserialize()
void DeviceManager::serialize() void DeviceManager::serialize()
{ {
static std::string filepath = file_manager->getUserConfigFile(INPUT_FILE_NAME); static std::string filepath = file_manager->getUserConfigFile(INPUT_FILE_NAME);
if(UserConfigParams::logMisc()) printf("Serializing input.xml...\n"); if(UserConfigParams::logMisc()) Log::info("Device manager","Serializing input.xml...");
std::ofstream configfile; std::ofstream configfile;
@ -565,8 +567,7 @@ void DeviceManager::serialize()
if(!configfile.is_open()) if(!configfile.is_open())
{ {
std::cerr << "Failed to open " << filepath.c_str() Log::error("Device manager","Failed to open %s for writing, controls won't be saved",filepath.c_str());
<< " for writing, controls won't be saved\n";
return; return;
} }
@ -584,7 +585,7 @@ void DeviceManager::serialize()
configfile << "</input>\n"; configfile << "</input>\n";
configfile.close(); configfile.close();
if(UserConfigParams::logMisc()) printf("Serialization complete.\n\n"); if(UserConfigParams::logMisc()) Log::info("Device manager","Serialization complete.");
} // serialize } // serialize
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------

View File

@ -64,7 +64,7 @@ std::vector<std::string> FileManager::m_root_dirs;
bool macSetBundlePathIfRelevant(std::string& data_dir) bool macSetBundlePathIfRelevant(std::string& data_dir)
{ {
Log::debug("FileManager", "Checking whether we are using an app bundle... "); Log::debug("[FileManager]", "Checking whether we are using an app bundle... ");
// the following code will enable STK to find its data when placed in an // the following code will enable STK to find its data when placed in an
// app bundle on mac OS X. // app bundle on mac OS X.
// returns true if path is set, returns false if path was not set // returns true if path is set, returns false if path was not set
@ -82,14 +82,14 @@ bool macSetBundlePathIfRelevant(std::string& data_dir)
std::string contents = std::string(path) + std::string("/Contents"); std::string contents = std::string(path) + std::string("/Contents");
if(contents.find(".app") != std::string::npos) if(contents.find(".app") != std::string::npos)
{ {
Log::debug("FileManager", "yes\n"); Log::debug("[FileManager]", "yes");
// executable is inside an app bundle, use app bundle-relative paths // executable is inside an app bundle, use app bundle-relative paths
data_dir = contents + std::string("/Resources/"); data_dir = contents + std::string("/Resources/");
return true; return true;
} }
else else
{ {
Log::debug("FileManager", "no\n"); Log::debug("[FileManager]", "no");
return false; return false;
} }
} }
@ -197,13 +197,13 @@ FileManager::FileManager()
// We can't use _() here, since translations will only be initalised // We can't use _() here, since translations will only be initalised
// after the filemanager (to get the path to the tranlsations from it) // after the filemanager (to get the path to the tranlsations from it)
for(unsigned int i=0; i<m_root_dirs.size(); i++) for(unsigned int i=0; i<m_root_dirs.size(); i++)
Log::info("FileManager", "Data files will be fetched from: '%s'", Log::info("[FileManager]", "Data files will be fetched from: '%s'",
m_root_dirs[i].c_str()); m_root_dirs[i].c_str());
Log::info("FileManager", "User directory is '%s'.", Log::info("[FileManager]", "User directory is '%s'.",
m_user_config_dir.c_str()); m_user_config_dir.c_str());
Log::info("FileManager", "Addons files will be stored in '%s'.", Log::info("[FileManager]", "Addons files will be stored in '%s'.",
m_addons_dir.c_str()); m_addons_dir.c_str());
Log::info("FileManager", "Screenshots will be stored in '%s'.", Log::info("[FileManager]", "Screenshots will be stored in '%s'.",
m_screenshot_dir.c_str()); m_screenshot_dir.c_str());
/** Now search for the path to all needed subdirectories. */ /** Now search for the path to all needed subdirectories. */
@ -232,16 +232,16 @@ FileManager::FileManager()
{ {
if(!dir_found[i]) if(!dir_found[i])
{ {
Log::warn("FileManager", "Directory '%s' not found, aborting.", Log::warn("[FileManager]", "Directory '%s' not found, aborting.",
m_subdir_name[i].c_str()); m_subdir_name[i].c_str());
was_error = true; was_error = true;
} }
else else
Log::info("FileManager", "Asset %d will be loaded from '%s'.", Log::info("[FileManager]", "Asset %d will be loaded from '%s'.",
i, m_subdir_name[i].c_str()); i, m_subdir_name[i].c_str());
} }
if(was_error) if(was_error)
Log::fatal("FileManager", "Not all assets found - aborting."); Log::fatal("[FileManager]", "Not all assets found - aborting.");
} // FileManager } // FileManager
@ -307,14 +307,14 @@ FileManager::~FileManager()
if(StringUtils::getExtension(*i)!="zip" && if(StringUtils::getExtension(*i)!="zip" &&
StringUtils::getExtension(*i)!="part" ) StringUtils::getExtension(*i)!="part" )
{ {
Log::warn("FileManager", "Unexpected tmp file '%s' found.", Log::warn("[FileManager]", "Unexpected tmp file '%s' found.",
full_path.c_str()); full_path.c_str());
continue; continue;
} }
if(isDirectory(full_path)) if(isDirectory(full_path))
{ {
// Gee, a .zip file which is a directory - stay away from it // Gee, a .zip file which is a directory - stay away from it
Log::warn("FileManager", "'%s' is a directory and will not be deleted.", Log::warn("[FileManager]", "'%s' is a directory and will not be deleted.",
full_path.c_str()); full_path.c_str());
continue; continue;
} }
@ -324,13 +324,13 @@ FileManager::~FileManager()
if(current - mystat.st_ctime <24*3600) if(current - mystat.st_ctime <24*3600)
{ {
if(UserConfigParams::logAddons()) if(UserConfigParams::logAddons())
Log::verbose("FileManager", "'%s' is less than 24h old " Log::verbose("[FileManager]", "'%s' is less than 24h old "
"and will not be deleted.", "and will not be deleted.",
full_path.c_str()); full_path.c_str());
continue; continue;
} }
if(UserConfigParams::logAddons()) if(UserConfigParams::logAddons())
Log::verbose("FileManager", "Deleting tmp file'%s'.",full_path.c_str()); Log::verbose("[FileManager]", "Deleting tmp file'%s'.",full_path.c_str());
removeFile(full_path); removeFile(full_path);
} // for i in all files in tmp } // for i in all files in tmp
@ -380,7 +380,7 @@ XMLNode *FileManager::createXMLTree(const std::string &filename)
{ {
if (UserConfigParams::logMisc()) if (UserConfigParams::logMisc())
{ {
Log::error("FileManager", "createXMLTree: %s\n", e.what()); Log::error("[FileManager]", "createXMLTree: %s", e.what());
} }
return NULL; return NULL;
} }
@ -406,7 +406,7 @@ XMLNode *FileManager::createXMLTreeFromString(const std::string & content)
{ {
if (UserConfigParams::logMisc()) if (UserConfigParams::logMisc())
{ {
Log::error("FileManager", "createXMLTreeFromString: %s\n", e.what()); Log::error("[FileManager]", "createXMLTreeFromString: %s", e.what());
} }
return NULL; return NULL;
} }
@ -532,7 +532,7 @@ std::string FileManager::getAssetChecked(FileManager::AssetType type,
if(abort_on_error) if(abort_on_error)
{ {
Log::fatal("FileManager", "Can not find file '%s' in '%s'", Log::fatal("[FileManager]", "Can not find file '%s' in '%s'",
name.c_str(), m_subdir_name[type].c_str()); name.c_str(), m_subdir_name[type].c_str());
} }
return ""; return "";
@ -636,20 +636,20 @@ bool FileManager::checkAndCreateDirectoryP(const std::string &path)
if(m_file_system->existFile(io::path(path.c_str()))) if(m_file_system->existFile(io::path(path.c_str())))
return true; return true;
std::cout << "[FileManager] Creating directory(ies) '" << path << "'.\n"; Log::info("[FileManager]", "Creating directory(ies) '%s'", path.c_str());
std::vector<std::string> split = StringUtils::split(path,'/'); std::vector<std::string> split = StringUtils::split(path,'/');
std::string current_path = ""; std::string current_path = "";
for (unsigned int i=0; i<split.size(); i++) for (unsigned int i=0; i<split.size(); i++)
{ {
current_path += split[i] + "/"; current_path += split[i] + "/";
std::cout << "[FileManager] Checking for: '" Log::info("[FileManager]", "Checking for: '%s",
<< current_path << "'.\n"; current_path.c_str());
if (!m_file_system->existFile(io::path(current_path.c_str()))) if (!m_file_system->existFile(io::path(current_path.c_str())))
{ {
if (!checkAndCreateDirectory(current_path)) if (!checkAndCreateDirectory(current_path))
{ {
Log::error("FileManager", "Can't create dir '%s'", Log::error("[FileManager]", "Can't create dir '%s'",
current_path.c_str()); current_path.c_str());
break; break;
} }
@ -684,8 +684,8 @@ void FileManager::checkAndCreateConfigDir()
m_user_config_dir = getenv("APPDATA"); m_user_config_dir = getenv("APPDATA");
if(!checkAndCreateDirectory(m_user_config_dir)) if(!checkAndCreateDirectory(m_user_config_dir))
{ {
std::cerr << "[FileManager] Can't create config dir '" Log::error("[FileManager]", "Can't create config dir '%s"
<< m_user_config_dir << "', falling back to '.'.\n"; ", falling back to '.'.", m_user_config_dir);
m_user_config_dir = "."; m_user_config_dir = ".";
} }
} }
@ -702,8 +702,8 @@ void FileManager::checkAndCreateConfigDir()
} }
else else
{ {
std::cerr << Log::error("[FileManager]",
"[FileManager] No home directory, this should NOT happen!\n"; "No home directory, this should NOT happen!");
// Fall back to system-wide app data (rather than // Fall back to system-wide app data (rather than
// user-specific data), but should not happen anyway. // user-specific data), but should not happen anyway.
m_user_config_dir = ""; m_user_config_dir = "";
@ -721,9 +721,9 @@ void FileManager::checkAndCreateConfigDir()
} }
else if (!getenv("HOME")) else if (!getenv("HOME"))
{ {
std::cerr Log::error("[FileManager]",
<< "[FileManager] No home directory, this should NOT happen " "No home directory, this should NOT happen "
<< "- trying '.' for config files!\n"; "- trying '.' for config files!");
m_user_config_dir = "."; m_user_config_dir = ".";
} }
else else
@ -733,9 +733,9 @@ void FileManager::checkAndCreateConfigDir()
if(!checkAndCreateDirectory(m_user_config_dir)) if(!checkAndCreateDirectory(m_user_config_dir))
{ {
// If $HOME/.config can not be created: // If $HOME/.config can not be created:
std::cerr << "[FileManager] Cannot create directory '" Log::error("[FileManager]",
<< m_user_config_dir <<"', falling back to use '" "Cannot create directory '%s', falling back to use '%s'",
<< getenv("HOME")<< "'.\n"; m_user_config_dir.c_str(), getenv("HOME"));
m_user_config_dir = getenv("HOME"); m_user_config_dir = getenv("HOME");
} }
} }

View File

@ -56,8 +56,8 @@ XMLNode::XMLNode(const std::string &filename)
{ {
if(!is_first_element) if(!is_first_element)
{ {
fprintf(stderr, Log::warn("[XMLNode]",
"More than one root element in '%s' - ignored.\n", "More than one root element in '%s' - ignored.",
filename.c_str()); filename.c_str());
} }
readXML(xml); readXML(xml);
@ -223,8 +223,8 @@ int XMLNode::get(const std::string &attribute, Vec3 *value) const
std::vector<std::string> v = StringUtils::split(s,' '); std::vector<std::string> v = StringUtils::split(s,' ');
if (v.size() != 3) if (v.size() != 3)
{ {
fprintf(stderr, "[XMLNode] WARNING: Expected 3 floating-point values, but found '%s' in file %s\n", Log::warn("[XMLNode]", "WARNING: Expected 3 floating-point values, but found '%s' in file %s",
s.c_str(), m_file_name.c_str()); s.c_str(), m_file_name.c_str());
return 0; return 0;
} }
@ -240,8 +240,8 @@ int XMLNode::get(const std::string &attribute, Vec3 *value) const
} }
else else
{ {
fprintf(stderr, "[XMLNode] WARNING: Expected 3 floating-point values, but found '%s' in file %s\n", Log::warn("[XMLNode]", "WARNING: Expected 3 floating-point values, but found '%s' in file %s",
s.c_str(), m_file_name.c_str()); s.c_str(), m_file_name.c_str());
return 0; return 0;
} }
@ -305,8 +305,8 @@ int XMLNode::get(const std::string &attribute, int32_t *value) const
if (!StringUtils::parseString<int>(s, value)) if (!StringUtils::parseString<int>(s, value))
{ {
fprintf(stderr, "[XMLNode] WARNING: Expected int but found '%s' for attribute '%s' of node '%s' in file %s\n", Log::warn("[XMLNode]", "WARNING: Expected int but found '%s' for attribute '%s' of node '%s' in file %s",
s.c_str(), attribute.c_str(), m_name.c_str(), m_file_name.c_str()); s.c_str(), attribute.c_str(), m_name.c_str(), m_file_name.c_str());
return 0; return 0;
} }
@ -321,8 +321,8 @@ int XMLNode::get(const std::string &attribute, int64_t *value) const
if (!StringUtils::parseString<int64_t>(s, value)) if (!StringUtils::parseString<int64_t>(s, value))
{ {
fprintf(stderr, "[XMLNode] WARNING: Expected int but found '%s' for attribute '%s' of node '%s' in file %s\n", Log::warn("[XMLNode]", "WARNING: Expected int but found '%s' for attribute '%s' of node '%s' in file %s",
s.c_str(), attribute.c_str(), m_name.c_str(), m_file_name.c_str()); s.c_str(), attribute.c_str(), m_name.c_str(), m_file_name.c_str());
return 0; return 0;
} }
@ -338,8 +338,8 @@ int XMLNode::get(const std::string &attribute, uint16_t *value) const
if (!StringUtils::parseString<uint16_t>(s, value)) if (!StringUtils::parseString<uint16_t>(s, value))
{ {
fprintf(stderr, "[XMLNode] WARNING: Expected uint but found '%s' for attribute '%s' of node '%s' in file %s\n", Log::warn("[XMLNode]", "WARNING: Expected uint but found '%s' for attribute '%s' of node '%s' in file %s",
s.c_str(), attribute.c_str(), m_name.c_str(), m_file_name.c_str()); s.c_str(), attribute.c_str(), m_name.c_str(), m_file_name.c_str());
return 0; return 0;
} }
@ -354,8 +354,8 @@ int XMLNode::get(const std::string &attribute, uint32_t *value) const
if (!StringUtils::parseString<unsigned int>(s, value)) if (!StringUtils::parseString<unsigned int>(s, value))
{ {
fprintf(stderr, "[XMLNode] WARNING: Expected uint but found '%s' for attribute '%s' of node '%s' in file %s\n", Log::warn("[XMLNode]", "WARNING: Expected uint but found '%s' for attribute '%s' of node '%s' in file %s",
s.c_str(), attribute.c_str(), m_name.c_str(), m_file_name.c_str()); s.c_str(), attribute.c_str(), m_name.c_str(), m_file_name.c_str());
return 0; return 0;
} }
@ -370,8 +370,8 @@ int XMLNode::get(const std::string &attribute, float *value) const
if (!StringUtils::parseString<float>(s, value)) if (!StringUtils::parseString<float>(s, value))
{ {
fprintf(stderr, "[XMLNode] WARNING: Expected float but found '%s' for attribute '%s' of node '%s' in file %s\n", Log::warn("[XMLNode]", "WARNING: Expected float but found '%s' for attribute '%s' of node '%s' in file %s",
s.c_str(), attribute.c_str(), m_name.c_str(), m_file_name.c_str()); s.c_str(), attribute.c_str(), m_name.c_str(), m_file_name.c_str());
return 0; return 0;
} }
@ -429,8 +429,8 @@ int XMLNode::get(const std::string &attribute,
float curr; float curr;
if (!StringUtils::parseString<float>(v[i], &curr)) if (!StringUtils::parseString<float>(v[i], &curr))
{ {
fprintf(stderr, "[XMLNode] WARNING: Expected float but found '%s' for attribute '%s' of node '%s' in file %s\n", Log::warn("[XMLNode]", "WARNING: Expected float but found '%s' for attribute '%s' of node '%s' in file %s",
v[i].c_str(), attribute.c_str(), m_name.c_str(), m_file_name.c_str()); v[i].c_str(), attribute.c_str(), m_name.c_str(), m_file_name.c_str());
return 0; return 0;
} }
@ -460,8 +460,8 @@ int XMLNode::get(const std::string &attribute, std::vector<int> *value) const
int val; int val;
if (!StringUtils::parseString<int>(v[i], &val)) if (!StringUtils::parseString<int>(v[i], &val))
{ {
fprintf(stderr, "[XMLNode] WARNING: Expected int but found '%s' for attribute '%s' of node '%s'\n", Log::warn("[XMLNode]", "WARNING: Expected int but found '%s' for attribute '%s' of node '%s'",
v[i].c_str(), attribute.c_str(), m_name.c_str()); v[i].c_str(), attribute.c_str(), m_name.c_str());
return 0; return 0;
} }
@ -490,22 +490,22 @@ int XMLNode::get(const std::string &attribute, InterpolationArray *value) const
std::vector<std::string> pair = StringUtils::split(pairs[i],':'); std::vector<std::string> pair = StringUtils::split(pairs[i],':');
if(pair.size()!=2) if(pair.size()!=2)
{ {
printf("Incorrect interpolation pair '%s' in '%s'.\n", Log::fatal("[XMLNode]", "Incorrect interpolation pair '%s' in '%s'.",
pairs[i].c_str(), attribute.c_str()); pairs[i].c_str(), attribute.c_str());
printf("Must be x:y.\n"); Log::fatal("[XMLNode]", "Must be x:y.");
exit(-1); exit(-1);
} }
float x; float x;
if(!StringUtils::fromString(pair[0], x)) if(!StringUtils::fromString(pair[0], x))
{ {
printf("Incorrect x in pair '%s' of '%s'.\n", Log::fatal("[XMLNode]", "Incorrect x in pair '%s' of '%s'.",
pairs[i].c_str(), attribute.c_str()); pairs[i].c_str(), attribute.c_str());
exit(-1); exit(-1);
} }
float y; float y;
if(!StringUtils::fromString(pair[1], y)) if(!StringUtils::fromString(pair[1], y))
{ {
printf("Incorrect y in pair '%s' in '%s'.\n", Log::fatal("[XMLNode]", "Incorrect y in pair '%s' in '%s'.",
pair[1].c_str(), attribute.c_str()); pair[1].c_str(), attribute.c_str());
exit(-1); exit(-1);
} }

View File

@ -39,7 +39,6 @@
#include "physics/triangle_mesh.hpp" #include "physics/triangle_mesh.hpp"
#include "tracks/track.hpp" #include "tracks/track.hpp"
#include "utils/constants.hpp" #include "utils/constants.hpp"
#include "utils/log.hpp"
/** Initialises the attachment each kart has. /** Initialises the attachment each kart has.
*/ */

View File

@ -143,9 +143,9 @@ void Flyable::createPhysics(float forw_offset, const Vec3 &velocity,
// Just to get some additional information if the assert is triggered // Just to get some additional information if the assert is triggered
if(isnan(v.getX()) || isnan(v.getY()) || isnan(v.getZ())) if(isnan(v.getX()) || isnan(v.getY()) || isnan(v.getZ()))
{ {
printf("vel %f %f %f v %f %f %f\n", Log::debug("[Flyable]", "vel %f %f %f v %f %f %f",
velocity.getX(),velocity.getY(),velocity.getZ(), velocity.getX(),velocity.getY(),velocity.getZ(),
v.getX(),v.getY(),v.getZ()); v.getX(),v.getY(),v.getZ());
} }
#endif #endif
assert(!isnan(v.getX())); assert(!isnan(v.getX()));

View File

@ -97,8 +97,8 @@ void ItemManager::loadDefaultItemMeshes()
scene::IMesh *mesh = irr_driver->getAnimatedMesh(model_filename); scene::IMesh *mesh = irr_driver->getAnimatedMesh(model_filename);
if(!node || model_filename.size()==0 || !mesh) if(!node || model_filename.size()==0 || !mesh)
{ {
fprintf(stderr, "Item model '%s' in items.xml could not be loaded " Log::fatal("[ItemManager]", "Item model '%s' in items.xml could not be loaded "
"- aborting", name.c_str()); "- aborting", name.c_str());
exit(-1); exit(-1);
} }
mesh->grab(); mesh->grab();

View File

@ -34,8 +34,6 @@
#include "utils/constants.hpp" #include "utils/constants.hpp"
#include "utils/string_utils.hpp" #include "utils/string_utils.hpp"
#include "utils/log.hpp" //TODO: remove after debugging is done
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
Plunger::Plunger(AbstractKart *kart) Plunger::Plunger(AbstractKart *kart)
: Flyable(kart, PowerupManager::POWERUP_PLUNGER) : Flyable(kart, PowerupManager::POWERUP_PLUNGER)

View File

@ -125,8 +125,8 @@ void PowerupManager::loadAllPowerups()
LoadPowerup(type, *node); LoadPowerup(type, *node);
else else
{ {
printf("Can't find item '%s' from powerup.xml, entry %d/\n", Log::fatal("[PowerupManager]", "Can't find item '%s' from powerup.xml, entry %d/",
name.c_str(), i+1); name.c_str(), i+1);
exit(-1); exit(-1);
} }
} }
@ -157,7 +157,7 @@ void PowerupManager::LoadPowerup(PowerupType type, const XMLNode &node)
#ifdef DEBUG #ifdef DEBUG
if (icon_file.size() == 0) if (icon_file.size() == 0)
{ {
fprintf(stderr, "Cannot load powerup %i, no 'icon' attribute under XML node\n", type); Log::debug("[PowerupManager]", "Cannot load powerup %i, no 'icon' attribute under XML node", type);
assert(false); assert(false);
} }
#endif #endif
@ -221,8 +221,9 @@ void PowerupManager::loadWeights(const XMLNode &root,
if(!node || s=="" || s_multi=="") if(!node || s=="" || s_multi=="")
{ {
printf("No weights found for class '%s' - probabilities will be incorrect.\n", Log::error("[PowerupManager]", "No weights found for class '%s'"
class_name.c_str()); " - probabilities will be incorrect.",
class_name.c_str());
return; return;
} }
@ -245,9 +246,9 @@ void PowerupManager::loadWeights(const XMLNode &root,
if(weight_list.size()!=2*(int)POWERUP_LAST) if(weight_list.size()!=2*(int)POWERUP_LAST)
{ {
printf("Incorrect number of weights found in class '%s':\n", Log::error("[PowerupManager]", "Incorrect number of weights found in class '%s':",
class_name.c_str()); class_name.c_str());
printf("%d instead of %d - probabilities will be incorrect.\n", Log::error("[PowerupManager]", "%d instead of %d - probabilities will be incorrect.",
(int)weight_list.size(), (int)POWERUP_LAST); (int)weight_list.size(), (int)POWERUP_LAST);
return; return;
} }

View File

@ -158,7 +158,7 @@ void RubberBall::computeTarget()
if(m_target==m_owner && m_delete_timer < 0) if(m_target==m_owner && m_delete_timer < 0)
{ {
#ifdef PRINT_BALL_REMOVE_INFO #ifdef PRINT_BALL_REMOVE_INFO
Log::debug("RubberBall", Log::debug("[RubberBall]",
"ball %d removed because owner is target.", m_id); "ball %d removed because owner is target.", m_id);
#endif #endif
m_delete_timer = m_st_delete_time; m_delete_timer = m_st_delete_time;
@ -171,7 +171,7 @@ void RubberBall::computeTarget()
// aim at the owner (the ball is unlikely to hit it), and // aim at the owner (the ball is unlikely to hit it), and
// this will trigger the usage of the delete time in updateAndDelete // this will trigger the usage of the delete time in updateAndDelete
#ifdef PRINT_BALL_REMOVE_INFO #ifdef PRINT_BALL_REMOVE_INFO
Log::debug("RubberBall" "ball %d removed because no more active target.", Log::debug("[RubberBall]" "ball %d removed because no more active target.",
m_id); m_id);
#endif #endif
m_delete_timer = m_st_delete_time; m_delete_timer = m_st_delete_time;
@ -312,7 +312,7 @@ bool RubberBall::updateAndDelete(float dt)
{ {
hit(NULL); hit(NULL);
#ifdef PRINT_BALL_REMOVE_INFO #ifdef PRINT_BALL_REMOVE_INFO
Log::debug("RubberBall", "ball %d deleted.", m_id); Log::debug("[RubberBall]", "ball %d deleted.", m_id);
#endif #endif
return true; return true;
} }
@ -355,7 +355,7 @@ bool RubberBall::updateAndDelete(float dt)
float new_y = getHoT()+height; float new_y = getHoT()+height;
if(UserConfigParams::logFlyable()) if(UserConfigParams::logFlyable())
printf("ball %d: %f %f %f height %f new_y %f gethot %f ", Log::debug("[RubberBall]", "ball %d: %f %f %f height %f new_y %f gethot %f ",
m_id, next_xyz.getX(), next_xyz.getY(), next_xyz.getZ(), height, new_y, getHoT()); m_id, next_xyz.getX(), next_xyz.getY(), next_xyz.getZ(), height, new_y, getHoT());
// No need to check for terrain height if the ball is low to the ground // No need to check for terrain height if the ball is low to the ground
@ -503,7 +503,7 @@ bool RubberBall::checkTunneling()
if(m_tunnel_count > 3) if(m_tunnel_count > 3)
{ {
#ifdef PRINT_BALL_REMOVE_INFO #ifdef PRINT_BALL_REMOVE_INFO
Log::debug("RubberBall", Log::debug("[RubberBall]",
"Ball %d nearly tunneled at %f %f %f -> %f %f %f", "Ball %d nearly tunneled at %f %f %f -> %f %f %f",
m_id, m_previous_xyz.getX(),m_previous_xyz.getY(), m_id, m_previous_xyz.getX(),m_previous_xyz.getY(),
m_previous_xyz.getZ(), m_previous_xyz.getZ(),
@ -627,7 +627,7 @@ void RubberBall::updateDistanceToTarget()
m_distance_to_target += world->getTrack()->getTrackLength(); m_distance_to_target += world->getTrack()->getTrackLength();
} }
if(UserConfigParams::logFlyable()) if(UserConfigParams::logFlyable())
printf("ball %d: target %f %f %f distance_2_target %f", Log::debug("[RubberBall]", "ball %d: target %f %f %f distance_2_target %f",
m_id, m_target->getXYZ().getX(),m_target->getXYZ().getY(), m_id, m_target->getXYZ().getX(),m_target->getXYZ().getY(),
m_target->getXYZ().getZ(),m_distance_to_target m_target->getXYZ().getZ(),m_distance_to_target
); );
@ -657,7 +657,7 @@ void RubberBall::updateDistanceToTarget()
{ {
m_delete_timer = m_st_delete_time; m_delete_timer = m_st_delete_time;
#ifdef PRINT_BALL_REMOVE_INFO #ifdef PRINT_BALL_REMOVE_INFO
Log::debug("RubberBall", "ball %d lost target (overtook?).", Log::debug("[RubberBall]", "ball %d lost target (overtook?).",
m_id); m_id);
#endif #endif
@ -690,7 +690,7 @@ bool RubberBall::hit(AbstractKart* kart, PhysicalObject* object)
{ {
#ifdef PRINT_BALL_REMOVE_INFO #ifdef PRINT_BALL_REMOVE_INFO
if(kart) if(kart)
Log::debug("RuberBall", "ball %d hit kart.", m_id); Log::debug("[RuberBall]", "ball %d hit kart.", m_id);
#endif #endif
if(kart && kart!=m_target) if(kart && kart!=m_target)
{ {

View File

@ -111,7 +111,7 @@ void AbstractKart::setKartAnimation(AbstractKartAnimation *ka)
ka->getName().c_str()); ka->getName().c_str());
else Log::debug("Abstract_Kart", "Setting kart animation to NULL."); else Log::debug("Abstract_Kart", "Setting kart animation to NULL.");
if(m_kart_animation) Log::info("Abstract_Kart", "Current kart" if(m_kart_animation) Log::info("Abstract_Kart", "Current kart"
"animation is '%s'.\n", "animation is '%s'.",
m_kart_animation->getName().c_str()); m_kart_animation->getName().c_str());
else Log::debug("Abstract_Kart", "Current kart animation is NULL."); else Log::debug("Abstract_Kart", "Current kart animation is NULL.");
} }

View File

@ -85,7 +85,7 @@ void AIProperties::load(const XMLNode *ai_node)
else else
{ {
Log::fatal("AIProperties", Log::fatal("AIProperties",
"Incorrect nitro-usage '%s' in AI '%s'.\n",s.c_str(), "Incorrect nitro-usage '%s' in AI '%s'.",s.c_str(),
m_ident.c_str()); m_ident.c_str());
} }
// We actually need the square of the distance later // We actually need the square of the distance later
@ -102,7 +102,7 @@ void AIProperties::checkAllSet(const std::string &filename) const
{ {
#define CHECK_NEG( a,str_a) if(a<=UNDEFINED) { \ #define CHECK_NEG( a,str_a) if(a<=UNDEFINED) { \
Log::fatal("AIProperties","Missing default value for" \ Log::fatal("AIProperties","Missing default value for" \
" '%s' in '%s' 'for AI '%s'.\n", \ " '%s' in '%s' 'for AI '%s'.", \
str_a, filename.c_str(), m_ident.c_str()); \ str_a, filename.c_str(), m_ident.c_str()); \
} }
CHECK_NEG(m_max_item_angle, "max-item-angle" ); CHECK_NEG(m_max_item_angle, "max-item-angle" );
@ -118,17 +118,17 @@ void AIProperties::checkAllSet(const std::string &filename) const
if(m_skid_probability.size()==0) if(m_skid_probability.size()==0)
{ {
Log::fatal("AIProperties", "No skid probability defined.\n"); Log::fatal("AIProperties", "No skid probability defined.");
} }
if(m_speed_cap.size()==0) if(m_speed_cap.size()==0)
{ {
Log::fatal("AIProperties", "No speed cap defined.\n"); Log::fatal("AIProperties", "No speed cap defined.");
} }
if(m_collect_item_probability.size()==0) if(m_collect_item_probability.size()==0)
{ {
Log::fatal("AIProperties", "No collect-item-probability defined.\n"); Log::fatal("AIProperties", "No collect-item-probability defined.");
} }
} // checkAllSet } // checkAllSet

View File

@ -218,7 +218,7 @@ void EndController::handleSteering(float dt)
const int next = m_next_node_index[m_track_node]; const int next = m_next_node_index[m_track_node];
target_point = QuadGraph::get()->getQuadOfNode(next).getCenter(); target_point = QuadGraph::get()->getQuadOfNode(next).getCenter();
#ifdef AI_DEBUG #ifdef AI_DEBUG
Log::debug("end_controller.cpp", "- Outside of road: steer to center point.\n"); Log::debug("end_controller.cpp", "- Outside of road: steer to center point.");
#endif #endif
} }
else else

View File

@ -255,7 +255,7 @@ void NetworkPlayerController::update(float dt)
{ {
// Print a dividing line so that it's easier to see which events // Print a dividing line so that it's easier to see which events
// get received in which order in the one frame. // get received in which order in the one frame.
Log::debug("PlayerController", "irr_driver", "-------------------------------------\n"); Log::debug("PlayerController", "irr_driver", "-------------------------------------");
} }
// Don't do steering if it's replay. In position only replay it doesn't // Don't do steering if it's replay. In position only replay it doesn't

View File

@ -311,7 +311,7 @@ void PlayerController::update(float dt)
{ {
// Print a dividing line so that it's easier to see which events // Print a dividing line so that it's easier to see which events
// get received in which order in the one frame. // get received in which order in the one frame.
Log::debug("PlayerController", "irr_driver", "-------------------------------------\n"); Log::debug("PlayerController", "irr_driver", "-------------------------------------");
} }
// Don't do steering if it's replay. In position only replay it doesn't // Don't do steering if it's replay. In position only replay it doesn't

View File

@ -198,7 +198,7 @@ void SkiddingAI::reset()
{ {
Log::error("SkiddingAI", Log::error("SkiddingAI",
"Invalid starting position for '%s' - not on track" "Invalid starting position for '%s' - not on track"
" - can be ignored.\n", " - can be ignored.",
m_kart->getIdent().c_str()); m_kart->getIdent().c_str());
m_track_node = QuadGraph::get()->findOutOfRoadSector(m_kart->getXYZ()); m_track_node = QuadGraph::get()->findOutOfRoadSector(m_kart->getXYZ());
} }
@ -401,7 +401,7 @@ void SkiddingAI::handleBraking()
{ {
#ifdef DEBUG #ifdef DEBUG
if(m_ai_debug) if(m_ai_debug)
Log::debug("SkiddingAI", "braking: %s ahead of leader.\n", Log::debug("SkiddingAI", "braking: %s ahead of leader.",
m_kart->getIdent().c_str()); m_kart->getIdent().c_str());
#endif #endif
@ -421,7 +421,7 @@ void SkiddingAI::handleBraking()
{ {
#ifdef DEBUG #ifdef DEBUG
if(m_ai_debug) if(m_ai_debug)
Log::debug("SkiddingAI", "%s not aligned with track.\n", Log::debug("SkiddingAI", "%s not aligned with track.",
m_kart->getIdent().c_str()); m_kart->getIdent().c_str());
#endif #endif
m_controls->m_brake = true; m_controls->m_brake = true;
@ -486,7 +486,7 @@ void SkiddingAI::handleSteering(float dt)
#ifdef AI_DEBUG #ifdef AI_DEBUG
m_debug_sphere[0]->setPosition(QuadGraph::get()->getQuadOfNode(next) m_debug_sphere[0]->setPosition(QuadGraph::get()->getQuadOfNode(next)
.getCenter().toIrrVector()); .getCenter().toIrrVector());
Log::debug("skidding_ai","-Outside of road: steer to center point.\n"); Log::debug("skidding_ai","-Outside of road: steer to center point.");
#endif #endif
} }
//If we are going to crash against a kart, avoid it if it doesn't //If we are going to crash against a kart, avoid it if it doesn't
@ -522,7 +522,7 @@ void SkiddingAI::handleSteering(float dt)
#ifdef AI_DEBUG #ifdef AI_DEBUG
Log::debug("skidding_ai", "- Velocity vector crashes with kart " Log::debug("skidding_ai", "- Velocity vector crashes with kart "
"and doesn't crashes with road : steer 90 " "and doesn't crashes with road : steer 90 "
"degrees away from kart.\n"); "degrees away from kart.");
#endif #endif
} }
@ -701,7 +701,7 @@ void SkiddingAI::handleItemCollectionAndAvoidance(Vec3 *aim_point,
} }
if(m_ai_debug) if(m_ai_debug)
Log::debug("SkiddingAI", "%s unselects item.\n", Log::debug("SkiddingAI", "%s unselects item.",
m_kart->getIdent().c_str()); m_kart->getIdent().c_str());
// Otherwise remove the pre-selected item (and start // Otherwise remove the pre-selected item (and start
// looking for a new item). // looking for a new item).
@ -771,7 +771,7 @@ void SkiddingAI::handleItemCollectionAndAvoidance(Vec3 *aim_point,
.toIrrVector()); .toIrrVector());
#endif #endif
if(m_ai_debug) if(m_ai_debug)
Log::debug("SkiddingAI", "%s selects item type '%d'.\n", Log::debug("SkiddingAI", "%s selects item type '%d'.",
m_kart->getIdent().c_str(), m_kart->getIdent().c_str(),
item_to_collect->getType()); item_to_collect->getType());
m_item_to_collect = item_to_collect; m_item_to_collect = item_to_collect;
@ -795,7 +795,7 @@ void SkiddingAI::handleItemCollectionAndAvoidance(Vec3 *aim_point,
#endif #endif
if(m_ai_debug) if(m_ai_debug)
Log::debug("SkiddingAI", Log::debug("SkiddingAI",
"%s adjusts to hit type %d angle %f.\n", "%s adjusts to hit type %d angle %f.",
m_kart->getIdent().c_str(), m_kart->getIdent().c_str(),
item_to_collect->getType(), angle); item_to_collect->getType(), angle);
} }
@ -803,7 +803,7 @@ void SkiddingAI::handleItemCollectionAndAvoidance(Vec3 *aim_point,
{ {
if(m_ai_debug) if(m_ai_debug)
Log::debug("SkiddingAI", Log::debug("SkiddingAI",
"%s won't hit '%d', angle %f.\n", "%s won't hit '%d', angle %f.",
m_kart->getIdent().c_str(), m_kart->getIdent().c_str(),
item_to_collect->getType(), angle); item_to_collect->getType(), angle);
} }
@ -1378,7 +1378,7 @@ void SkiddingAI::handleItems(const float dt)
break; break;
default: default:
Log::error("SkiddingAI", Log::error("SkiddingAI",
"Invalid or unhandled powerup '%d' in default AI.\n", "Invalid or unhandled powerup '%d' in default AI.",
m_kart->getPowerup()->getType()); m_kart->getPowerup()->getType());
assert(false); assert(false);
} }
@ -1699,7 +1699,7 @@ void SkiddingAI::checkCrashes(const Vec3& pos )
if(steps<1 || steps>1000) if(steps<1 || steps>1000)
{ {
Log::warn("SkiddingAI", Log::warn("SkiddingAI",
"Incorrect STEPS=%d. kart_length %f velocity %f\n", "Incorrect STEPS=%d. kart_length %f velocity %f",
steps, m_kart_length, m_kart->getVelocityLC().getZ()); steps, m_kart_length, m_kart->getVelocityLC().getZ());
steps=1000; steps=1000;
} }
@ -2181,7 +2181,7 @@ bool SkiddingAI::doSkid(float steer_fraction)
if(m_ai_debug) if(m_ai_debug)
{ {
if(fabsf(steer_fraction)>=2.5f) if(fabsf(steer_fraction)>=2.5f)
Log::debug("SkiddingAI", "%s stops skidding (%f).\n", Log::debug("SkiddingAI", "%s stops skidding (%f).",
m_kart->getIdent().c_str(), steer_fraction); m_kart->getIdent().c_str(), steer_fraction);
} }
#endif #endif
@ -2201,7 +2201,7 @@ bool SkiddingAI::doSkid(float steer_fraction)
#ifdef DEBUG #ifdef DEBUG
if(m_controls->m_skid && m_ai_debug) if(m_controls->m_skid && m_ai_debug)
{ {
Log::debug("SkiddingAI", "%s stops skidding on straight.\n", Log::debug("SkiddingAI", "%s stops skidding on straight.",
m_kart->getIdent().c_str()); m_kart->getIdent().c_str());
} }
#endif #endif
@ -2238,7 +2238,7 @@ bool SkiddingAI::doSkid(float steer_fraction)
if(m_controls->m_skid && duration < 1.0f) if(m_controls->m_skid && duration < 1.0f)
{ {
if(m_ai_debug) if(m_ai_debug)
Log::debug("SkiddingAI", "'%s' too short, stop skid.\n", Log::debug("SkiddingAI", "'%s' too short, stop skid.",
m_kart->getIdent().c_str()); m_kart->getIdent().c_str());
return false; return false;
} }
@ -2254,7 +2254,7 @@ bool SkiddingAI::doSkid(float steer_fraction)
#ifdef DEBUG #ifdef DEBUG
if(m_controls->m_skid && m_ai_debug) if(m_controls->m_skid && m_ai_debug)
Log::debug("SkiddingAI", Log::debug("SkiddingAI",
"%s skidding against track direction.\n", "%s skidding against track direction.",
m_kart->getIdent().c_str()); m_kart->getIdent().c_str());
#endif #endif
return false; return false;
@ -2265,7 +2265,7 @@ bool SkiddingAI::doSkid(float steer_fraction)
{ {
#ifdef DEBUG #ifdef DEBUG
if(!m_controls->m_skid && m_ai_debug) if(!m_controls->m_skid && m_ai_debug)
Log::debug("SkiddingAI", "%s start skid, duration %f.\n", Log::debug("SkiddingAI", "%s start skid, duration %f.",
m_kart->getIdent().c_str(), duration); m_kart->getIdent().c_str(), duration);
#endif #endif
return true; return true;
@ -2274,7 +2274,7 @@ bool SkiddingAI::doSkid(float steer_fraction)
#ifdef DEBUG #ifdef DEBUG
if(m_controls->m_skid && m_ai_debug) if(m_controls->m_skid && m_ai_debug)
Log::debug("SkiddingAI", "%s has no reasons to skid anymore.\n", Log::debug("SkiddingAI", "%s has no reasons to skid anymore.",
m_kart->getIdent().c_str()); m_kart->getIdent().c_str());
#endif #endif
return false; return false;
@ -2353,7 +2353,7 @@ void SkiddingAI::setSteering(float angle, float dt)
m_controls->m_skid = KartControl::SC_NONE; m_controls->m_skid = KartControl::SC_NONE;
#ifdef DEBUG #ifdef DEBUG
if(m_ai_debug) if(m_ai_debug)
Log::info("SkiddingAI", "'%s' wrong steering, stop skid.\n", Log::info("SkiddingAI", "'%s' wrong steering, stop skid.",
m_kart->getIdent().c_str()); m_kart->getIdent().c_str());
#endif #endif
} }
@ -2368,7 +2368,7 @@ void SkiddingAI::setSteering(float angle, float dt)
{ {
#ifdef DEBUG #ifdef DEBUG
if(m_ai_debug) if(m_ai_debug)
Log::info("SkiddingAI", "%s steering too much (%f).\n", Log::info("SkiddingAI", "%s steering too much (%f).",
m_kart->getIdent().c_str(), steer_fraction); m_kart->getIdent().c_str(), steer_fraction);
#endif #endif
m_controls->m_skid = KartControl::SC_NONE; m_controls->m_skid = KartControl::SC_NONE;

View File

@ -26,7 +26,6 @@
#include "karts/kart_properties.hpp" #include "karts/kart_properties.hpp"
#include "modes/world.hpp" #include "modes/world.hpp"
#include "tracks/track.hpp" #include "tracks/track.hpp"
#include "utils/log.hpp" //TODO: remove after debugging is done
/** A static create function that does only create an explosion if /** A static create function that does only create an explosion if
* the explosion happens to be close enough to affect the kart. * the explosion happens to be close enough to affect the kart.

View File

@ -199,7 +199,7 @@ void Kart::init(RaceManager::KartType type)
if(!m_engine_sound) if(!m_engine_sound)
{ {
Log::error("Kart","Could not allocate a sfx object for the kart. Further errors may ensue!\n"); Log::error("Kart","Could not allocate a sfx object for the kart. Further errors may ensue!");
} }
@ -257,7 +257,7 @@ Kart::~Kart()
if(m_slipstream) delete m_slipstream; if(m_slipstream) delete m_slipstream;
if(m_sky_particles_emitter) delete m_sky_particles_emitter; if(m_sky_particles_emitter) delete m_sky_particles_emitter;
if(m_attachment) delete m_attachment; if(m_attachment) delete m_attachment;
if (m_stars_effect) delete m_stars_effect; if(m_stars_effect) delete m_stars_effect;
delete m_shadow; delete m_shadow;
@ -1261,7 +1261,7 @@ void Kart::update(float dt)
#ifdef DEBUG #ifdef DEBUG
if(UserConfigParams::m_material_debug) if(UserConfigParams::m_material_debug)
{ {
Log::info("Kart","%s\tfraction %f\ttime %f.\n", Log::info("Kart","%s\tfraction %f\ttime %f.",
material->getTexFname().c_str(), material->getTexFname().c_str(),
material->getMaxSpeedFraction(), material->getMaxSpeedFraction(),
material->getSlowDownTime() ); material->getSlowDownTime() );
@ -1728,7 +1728,7 @@ void Kart::crashed(const Material *m, const Vec3 &normal)
// Add a counter to make it easier to see if a new line of // Add a counter to make it easier to see if a new line of
// output was added. // output was added.
static int counter=0; static int counter=0;
Log::info("Kart","Kart %s hit track: %d material %s.\n", Log::info("Kart","Kart %s hit track: %d material %s.",
getIdent().c_str(), counter++, getIdent().c_str(), counter++,
m ? m->getTexFname().c_str() : "None"); m ? m->getTexFname().c_str() : "None");
} }
@ -2062,7 +2062,7 @@ void Kart::updatePhysics(float dt)
updateEngineSFX(); updateEngineSFX();
#ifdef XX #ifdef XX
Log::info("Kart","forward %f %f %f %f side %f %f %f %f angVel %f %f %f heading %f\n" Log::info("Kart","forward %f %f %f %f side %f %f %f %f angVel %f %f %f heading %f"
,m_vehicle->m_forwardImpulse[0] ,m_vehicle->m_forwardImpulse[0]
,m_vehicle->m_forwardImpulse[1] ,m_vehicle->m_forwardImpulse[1]
,m_vehicle->m_forwardImpulse[2] ,m_vehicle->m_forwardImpulse[2]

View File

@ -27,6 +27,7 @@
#include "karts/kart_properties.hpp" #include "karts/kart_properties.hpp"
#include "karts/skidding.hpp" #include "karts/skidding.hpp"
#include "physics/btKart.hpp" #include "physics/btKart.hpp"
#include "utils/log.hpp"
#include <iostream> #include <iostream>
@ -122,7 +123,7 @@ void KartGFX::addEffect(KartGFXType type, const std::string &file_name,
// by adding a NULL to the list (which is tested for in all // by adding a NULL to the list (which is tested for in all
// cases). C++ guarantees that all memory allocated in the // cases). C++ guarantees that all memory allocated in the
// constructor is properly freed. // constructor is properly freed.
std::cerr << e.what() << std::endl; Log::error("[KartGFX]", "%s",e.what());
kind = NULL; kind = NULL;
emitter = NULL; emitter = NULL;
} }

View File

@ -201,9 +201,9 @@ void KartProperties::load(const std::string &filename, const std::string &node)
} }
catch(std::exception& err) catch(std::exception& err)
{ {
Log::error("KartProperties", "Error while parsing KartProperties '%s':\n", Log::error("[KartProperties]", "Error while parsing KartProperties '%s':",
filename.c_str()); filename.c_str());
Log::error("KartProperties", "%s\n", err.what()); Log::error("[KartProperties]", "%s", err.what());
} }
if(root) delete root; if(root) delete root;
@ -392,15 +392,15 @@ void KartProperties::getAllData(const XMLNode * root)
engine_node->get("power", &m_engine_power); engine_node->get("power", &m_engine_power);
if(m_engine_power.size()!=RaceManager::DIFFICULTY_COUNT) if(m_engine_power.size()!=RaceManager::DIFFICULTY_COUNT)
{ {
Log::fatal("KartProperties", Log::fatal("[KartProperties]",
"Incorrect engine-power specifications for kart '%s'\n", "Incorrect engine-power specifications for kart '%s'",
getIdent().c_str()); getIdent().c_str());
} }
engine_node->get("max-speed", &m_max_speed); engine_node->get("max-speed", &m_max_speed);
if(m_max_speed.size()!=RaceManager::DIFFICULTY_COUNT) if(m_max_speed.size()!=RaceManager::DIFFICULTY_COUNT)
{ {
Log::fatal("KartProperties", Log::fatal("[KartProperties]",
"Incorrect max-speed specifications for kart '%s'\n", "Incorrect max-speed specifications for kart '%s'",
getIdent().c_str()); getIdent().c_str());
} }
} // if getNode("engine") } // if getNode("engine")
@ -477,8 +477,8 @@ void KartProperties::getAllData(const XMLNode * root)
m_terrain_impulse_type = IMPULSE_TO_DRIVELINE; m_terrain_impulse_type = IMPULSE_TO_DRIVELINE;
else else
{ {
Log::fatal("KartProperties", Log::fatal("[KartProperties]",
"Missing or incorrect value for impulse-type: '%s'.\n", "Missing or incorrect value for impulse-type: '%s'.",
s.c_str()); s.c_str());
} }
} }
@ -560,7 +560,7 @@ void KartProperties::getAllData(const XMLNode * root)
else if (s == "small") m_engine_sfx_type = "engine_small"; else if (s == "small") m_engine_sfx_type = "engine_small";
else else
{ {
Log::warn("KartProperties", "Kart '%s' has invalid engine '%s'.", Log::warn("[KartProperties]", "Kart '%s' has invalid engine '%s'.",
m_name.c_str(), s.c_str()); m_name.c_str(), s.c_str());
m_engine_sfx_type = "engine_small"; m_engine_sfx_type = "engine_small";
} }
@ -603,32 +603,32 @@ void KartProperties::checkAllSet(const std::string &filename)
{ {
if(m_gear_switch_ratio.size()==0) if(m_gear_switch_ratio.size()==0)
{ {
Log::fatal("KartProperties", Log::fatal("[KartProperties]",
"Missing default value for 'gear-switch-ratio' in '%s'.\n", "Missing default value for 'gear-switch-ratio' in '%s'.",
filename.c_str()); filename.c_str());
} }
if(m_gear_power_increase.size()==0) if(m_gear_power_increase.size()==0)
{ {
Log::fatal("KartProperties", Log::fatal("[KartProperties]",
"Missing default value for 'gear-power-increase' in '%s'.\n", "Missing default value for 'gear-power-increase' in '%s'.",
filename.c_str()); filename.c_str());
} }
if(m_gear_switch_ratio.size()!=m_gear_power_increase.size()) { if(m_gear_switch_ratio.size()!=m_gear_power_increase.size()) {
Log::error("KartProperties", Log::error("KartProperties",
"Number of entries for 'gear-switch-ratio' and " "Number of entries for 'gear-switch-ratio' and "
"'gear-power-increase\n"); "'gear-power-increase");
Log::fatal("KartProperties", "in '%s' must be equal.\n", Log::fatal("KartProperties", "in '%s' must be equal.",
filename.c_str()); filename.c_str());
} }
if(m_startup_boost.size()!=m_startup_times.size()) if(m_startup_boost.size()!=m_startup_times.size())
{ {
Log::error("KartProperties", Log::error("[KartProperties]",
"Number of entried for 'startup times' and 'startup-boost\n"); "Number of entried for 'startup times' and 'startup-boost");
Log::fatal("KartProperties", "must be identical.\n"); Log::fatal("KartProperties", "must be identical.");
} }
#define CHECK_NEG( a,strA) if(a<=UNDEFINED) { \ #define CHECK_NEG( a,strA) if(a<=UNDEFINED) { \
Log::fatal("KartProperties", \ Log::fatal("[KartProperties]", \
"Missing default value for '%s' in '%s'.\n", \ "Missing default value for '%s' in '%s'.", \
strA,filename.c_str()); \ strA,filename.c_str()); \
} }

View File

@ -191,8 +191,8 @@ bool KartPropertiesManager::loadKart(const std::string &dir)
} }
catch (std::runtime_error& err) catch (std::runtime_error& err)
{ {
std::cerr << "Giving up loading '" << config_filename.c_str() Log::error("[Kart_Properties_Manager]","Giving up loading '%s': %s",
<< "' : " << err.what() << std::endl; config_filename.c_str(), err.what());
return false; return false;
} }
@ -201,7 +201,7 @@ bool KartPropertiesManager::loadKart(const std::string &dir)
if (kart_properties->getVersion() < stk_config->m_min_kart_version || if (kart_properties->getVersion() < stk_config->m_min_kart_version ||
kart_properties->getVersion() > stk_config->m_max_kart_version) kart_properties->getVersion() > stk_config->m_max_kart_version)
{ {
Log::warn("Kart_Properties_Manager", "Warning: kart '%s' is not " Log::warn("[Kart_Properties_Manager]", "Warning: kart '%s' is not "
"supported by this binary, ignored.", "supported by this binary, ignored.",
kart_properties->getIdent().c_str()); kart_properties->getIdent().c_str());
delete kart_properties; delete kart_properties;
@ -306,7 +306,7 @@ void KartPropertiesManager::setUnavailableKarts(std::vector<std::string> karts)
{ {
m_kart_available[i] = false; m_kart_available[i] = false;
Log::error("Kart_Properties_Manager", Log::error("[Kart_Properties_Manager]",
"Kart '%s' not available on all clients, disabled.", "Kart '%s' not available on all clients, disabled.",
m_karts_properties[i].getIdent().c_str()); m_karts_properties[i].getIdent().c_str());
} // kart not in list } // kart not in list
@ -428,10 +428,8 @@ void KartPropertiesManager::getRandomKartList(int count,
catch (std::runtime_error& ex) catch (std::runtime_error& ex)
{ {
(void)ex; (void)ex;
std::cerr << Log::error("[KartPropertiesManager]", "getRandomKartList : WARNING, "
"[KartPropertiesManager] getRandomKartList : WARNING, " "can't find kart '%s'", existing_karts[i].getKartName().c_str());
"can't find kart '"
<< existing_karts[i].getKartName() << "'\n";
} }
} }
for(unsigned int i=0; i<ai_list->size(); i++) for(unsigned int i=0; i<ai_list->size(); i++)
@ -444,10 +442,8 @@ void KartPropertiesManager::getRandomKartList(int count,
catch (std::runtime_error &ex) catch (std::runtime_error &ex)
{ {
(void)ex; (void)ex;
std::cerr << Log::error("[KartPropertiesManager]", "getRandomKartList : WARNING, "
"[KartPropertiesManager] getRandomKartList : WARNING, " "can't find kart '%s'",(*ai_list)[i].c_str());
"can't find kart '"
<< (*ai_list)[i] << "'\n";
} }
} }

View File

@ -97,7 +97,7 @@ void CutsceneWorld::init()
if (!StringUtils::fromString(frameStr, frame)) if (!StringUtils::fromString(frameStr, frame))
{ {
fprintf(stderr, "[CutsceneWorld] Invalid condition '%s'\n", Log::error("[CutsceneWorld]", "Invalid condition '%s'",
condition.c_str()); condition.c_str());
continue; continue;
} }
@ -117,7 +117,7 @@ void CutsceneWorld::init()
if (!StringUtils::fromString(frameStr, frame)) if (!StringUtils::fromString(frameStr, frame))
{ {
fprintf(stderr, "[CutsceneWorld] Invalid condition '%s'\n", Log::error("[CutsceneWorld]", "Invalid condition '%s'",
condition.c_str()); condition.c_str());
continue; continue;
} }
@ -132,7 +132,7 @@ void CutsceneWorld::init()
if (!StringUtils::fromString(frameStr, frame)) if (!StringUtils::fromString(frameStr, frame))
{ {
fprintf(stderr, "[CutsceneWorld] Invalid condition '%s'\n", Log::error("[CutsceneWorld]", "Invalid condition '%s'",
condition.c_str()); condition.c_str());
continue; continue;
} }
@ -152,7 +152,7 @@ void CutsceneWorld::init()
if (m_duration <= 0.0f) if (m_duration <= 0.0f)
{ {
fprintf(stderr, "[CutsceneWorld] WARNING: cutscene has no duration\n"); Log::error("[CutsceneWorld]", "WARNING: cutscene has no duration");
} }
} // CutsceneWorld } // CutsceneWorld

View File

@ -120,7 +120,7 @@ bool DemoWorld::updateIdleTimeAndStartDemo(float dt)
&& m_demo_tracks.size() > 0) && m_demo_tracks.size() > 0)
{ {
if(!track) if(!track)
printf("Invalid demo track identifier '%s'.\n", Log::warn("[DemoWorld]", "Invalid demo track identifier '%s'.",
m_demo_tracks[0].c_str()); m_demo_tracks[0].c_str());
m_demo_tracks.erase(m_demo_tracks.begin()); m_demo_tracks.erase(m_demo_tracks.begin());
track = track_manager->getTrack(m_demo_tracks[0]); track = track_manager->getTrack(m_demo_tracks[0]);
@ -130,7 +130,7 @@ bool DemoWorld::updateIdleTimeAndStartDemo(float dt)
// be filled up with all the tracks. // be filled up with all the tracks.
if(m_demo_tracks.size()==0) if(m_demo_tracks.size()==0)
{ {
printf("No valid tracks found, no demo started.\n"); Log::warn("[DemoWorld]", "No valid tracks found, no demo started.");
return false; return false;
} }

View File

@ -42,7 +42,7 @@ void EasterEggHunt::init()
// check for possible problems if AI karts were incorrectly added // check for possible problems if AI karts were incorrectly added
if(getNumKarts() > race_manager->getNumPlayers()) if(getNumKarts() > race_manager->getNumPlayers())
{ {
fprintf(stderr, "No AI exists for this game mode\n"); Log::error("EasterEggHunt]", "No AI exists for this game mode");
exit(1); exit(1);
} }
@ -70,7 +70,7 @@ void EasterEggHunt::readData(const std::string &filename)
if(easter->getName()!="EasterEggHunt") if(easter->getName()!="EasterEggHunt")
{ {
printf("Can't load easter egg file '%s' - no EasterEggHunt element.", Log::error("[EasterEggHunt]", "Can't load easter egg file '%s' - no EasterEggHunt element.",
filename.c_str()); filename.c_str());
delete easter; delete easter;
return; return;
@ -121,7 +121,7 @@ void EasterEggHunt::readData(const std::string &filename)
const XMLNode *egg = data->getNode(i); const XMLNode *egg = data->getNode(i);
if(egg->getName()!="easter-egg") if(egg->getName()!="easter-egg")
{ {
printf("Unknown node '%s' in easter egg level '%s' - ignored.\n", Log::warn("[EasterEggHunt]", "Unknown node '%s' in easter egg level '%s' - ignored.",
egg->getName().c_str(), egg->getName().c_str(),
race_manager->getDifficultyAsString(act_difficulty).c_str()); race_manager->getDifficultyAsString(act_difficulty).c_str());
continue; continue;

View File

@ -108,19 +108,19 @@ void FollowTheLeaderRace::countdownReachedZero()
AbstractKart *kart = getKartAtPosition(position_to_remove); AbstractKart *kart = getKartAtPosition(position_to_remove);
if(!kart || kart->isEliminated()) if(!kart || kart->isEliminated())
{ {
fprintf(stderr,"Problem with removing leader: position %d not found\n", Log::error("[FTL]", "Problem with removing leader: position %d not found",
position_to_remove); position_to_remove);
for(unsigned int i=0; i<m_karts.size(); i++) for(unsigned int i=0; i<m_karts.size(); i++)
{ {
fprintf(stderr,"kart %d: eliminated %d position %d\n", Log::error("[FTL]", "kart %u: eliminated %d position %d",
i,m_karts[i]->isEliminated(), m_karts[i]->getPosition()); i, m_karts[i]->isEliminated(), m_karts[i]->getPosition());
} // for i } // for i
} // } //
else else
{ {
if(UserConfigParams::m_ftl_debug) if(UserConfigParams::m_ftl_debug)
{ {
printf("[ftl] Eliminiating kart '%s' at position %d.\n", Log::debug("[FTL", "Eliminiating kart '%s' at position %d.",
kart->getIdent().c_str(), position_to_remove); kart->getIdent().c_str(), position_to_remove);
} }
eliminateKart(kart->getWorldKartId()); eliminateKart(kart->getWorldKartId());

View File

@ -208,10 +208,10 @@ void LinearWorld::update(float dt)
{ {
if(pos_used[m_karts[i]->getPosition()]!=-99) if(pos_used[m_karts[i]->getPosition()]!=-99)
{ {
for(unsigned int j =0; j<kart_amount; j++) for(unsigned int j=0; j<kart_amount; j++)
{ {
printf("kart id=%d, position=%d, finished=%d, laps=%d, " Log::verbose("[LinearWorld]", "kart id=%u, position=%d, finished=%d, laps=%d, "
"distanceDownTrack=%f overallDistance=%f %s\n", "distanceDownTrack=%f overallDistance=%f %s",
j, m_karts[j]->getPosition(), j, m_karts[j]->getPosition(),
m_karts[j]->hasFinishedRace(), m_karts[j]->hasFinishedRace(),
m_kart_info[j].m_race_lap, m_kart_info[j].m_race_lap,
@ -553,9 +553,9 @@ float LinearWorld::estimateFinishTimeForKart(AbstractKart* kart)
#ifdef DEBUG #ifdef DEBUG
if(kart_info.m_overall_distance > full_distance) if(kart_info.m_overall_distance > full_distance)
{ {
printf("WARNING: full distance < distance covered for kart '%s':\n", Log::debug("[LinearWorld]", "Full distance < distance covered for kart '%s':",
kart->getIdent().c_str()); kart->getIdent().c_str());
printf("%f < %f\n", full_distance, kart_info.m_overall_distance); Log::debug("[LinearWorld]", "%f < %f", full_distance, kart_info.m_overall_distance);
} }
#endif #endif
// Avoid potential problems (floating point issues, coding bug?) if a // Avoid potential problems (floating point issues, coding bug?) if a
@ -699,29 +699,29 @@ void LinearWorld::updateRacePosition()
rank_changed |= kart->getPosition()!=p; rank_changed |= kart->getPosition()!=p;
if (!setKartPosition(i,p)) if (!setKartPosition(i,p))
{ {
std::cerr << "ERROR, same rank used twice!!\n"; Log::error("[LinearWorld]", "Same rank used twice!!");
std::cerr << "Info used to decide ranking :\n"; Log::debug("[LinearWorld]", "Info used to decide ranking :");
for (unsigned int d=0; d<kart_amount; d++) for (unsigned int d=0; d<kart_amount; d++)
{ {
std::cerr << " kart " << m_karts[d]->getIdent() Log::debug("[LinearWorld]", "Kart %s has finished (%d), is at lap (%u),"
<< " has finished(" << m_karts[d]->hasFinishedRace() "is at distance (%u), is eliminated(%d)",
<< "), is at lap (" << getLapForKart(d) m_karts[d]->getIdent().c_str(),
<< "), is at distance(" m_karts[d]->hasFinishedRace(),
<< m_kart_info[d].m_overall_distance getLapForKart(d),
<< "), is eliminated(" << m_karts[d]->isEliminated() m_kart_info[d].m_overall_distance,
<< ")" << std::endl; m_karts[d]->isEliminated());
} }
std::cerr << "Who has each ranking so far :\n"; Log::debug("[LinearWorld]", "Who has each ranking so far :");
for (unsigned int d=0; d<i; d++) for (unsigned int d=0; d<i; d++)
{ {
std::cerr << " " << m_karts[d]->getIdent() << " has rank " Log::debug("[LinearWorld]", "%s has rank %d", m_karts[d]->getIdent().c_str(),
<< m_karts[d]->getPosition() << std::endl; m_karts[d]->getPosition());
} }
std::cerr << " --> And " << kart->getIdent() Log::debug("[LinearWorld]", " --> And %s is being set at rank %d",
<< " is being set at rank " << p << std::endl; kart->getIdent().c_str(), p);
history->Save(); history->Save();
assert(false); assert(false);
} }
@ -749,17 +749,18 @@ void LinearWorld::updateRacePosition()
#ifdef DEBUG_KART_RANK #ifdef DEBUG_KART_RANK
if(rank_changed) if(rank_changed)
{ {
std::cout << "Counting laps at "<<getTime()<<" seconds.\n"; Log::debug("[LinearWorld]", "Counting laps at %u seconds.", getTime());
for (unsigned int i=0; i<kart_amount; i++) for (unsigned int i=0; i<kart_amount; i++)
{ {
AbstractKart* kart = m_karts[i]; AbstractKart* kart = m_karts[i];
std::cout << "counting karts ahead of " << kart->getIdent() Log::debug("[LinearWorld]", "counting karts ahead of %s (laps %u,"
<< " (laps " << m_kart_info[i].m_race_lap " progress %u, finished %d, eliminated %d, initial position %u.",
<< ", progress " << m_kart_info[i].m_overall_distance kart->getIdent().c_str(),
<< " finished " << kart->hasFinishedRace() m_kart_info[i].m_race_lap,
<< " eliminated " << kart->isEliminated() m_kart_info[i].m_overall_distance,
<< " initial position "<< kart->getInitialPosition() kart->hasFinishedRace(),
<< ").\n"; kart->isEliminated(),
kart->getInitialPosition());
// Karts that are either eliminated or have finished the // Karts that are either eliminated or have finished the
// race already have their (final) position assigned. If // race already have their (final) position assigned. If
// these karts would get their rank updated, it could happen // these karts would get their rank updated, it could happen
@ -776,36 +777,36 @@ void LinearWorld::updateRacePosition()
if(j == my_id) continue; if(j == my_id) continue;
if(m_karts[j]->isEliminated()) if(m_karts[j]->isEliminated())
{ {
std::cout << " " << p << " : " << m_karts[j]->getIdent() Log::debug("[LinearWorld]", " %u: %s because it is eliminated.",
<< " because it is eliminated.\n"; p, m_karts[j]->getIdent().c_str());
continue; continue;
} }
if(!kart->hasFinishedRace() && m_karts[j]->hasFinishedRace()) if(!kart->hasFinishedRace() && m_karts[j]->hasFinishedRace())
{ {
p++; p++;
std::cout << " " << p << " : " << m_karts[j]->getIdent() Log::debug("[LinearWorld]", " %u: %s because it has finished the race.",
<< " because it has finished the race.\n"; p, m_karts[j]->getIdent().c_str());
continue; continue;
} }
if(m_kart_info[j].m_overall_distance > my_distance) if(m_kart_info[j].m_overall_distance > my_distance)
{ {
p++; p++;
std::cout << " " << p << " : " << m_karts[j]->getIdent() Log::debug("[LinearWorld]", " %u: %s because it is ahead %u.",
<< " because it is ahead " p, m_karts[j]->getIdent().c_str(),
<< m_kart_info[j].m_overall_distance <<".\n"; m_kart_info[j].m_overall_distance);
continue; continue;
} }
if(m_kart_info[j].m_overall_distance == my_distance && if(m_kart_info[j].m_overall_distance == my_distance &&
m_karts[j]->getInitialPosition()<kart->getInitialPosition()) m_karts[j]->getInitialPosition()<kart->getInitialPosition())
{ {
p++; p++;
std::cout << " " << p << " : " << m_karts[j]->getIdent() Log::debug("[LinearWorld]"," %u: %s has same distance, but started ahead %d",
<< " has same distance, but started ahead " p, m_karts[j]->getIdent().c_str(),
<< m_karts[j]->getInitialPosition()<<".\n"; m_karts[j]->getInitialPosition());
} }
} // next kart j } // next kart j
} // for i<kart_amount } // for i<kart_amount
std::cout << "-------------------------------------------\n"; Log::debug("LinearWorld]", "-------------------------------------------");
} // if rank_changed } // if rank_changed
#endif #endif
#endif #endif

View File

@ -69,8 +69,8 @@ void OverWorld::enterOverWorld()
if (!kart_properties_manager->getKart(UserConfigParams::m_default_kart)) if (!kart_properties_manager->getKart(UserConfigParams::m_default_kart))
{ {
Log::warn("overworld", "cannot find kart '%s', " Log::warn("[overworld]", "cannot find kart '%s', "
"will revert to default\n", "will revert to default",
UserConfigParams::m_default_kart.c_str()); UserConfigParams::m_default_kart.c_str());
UserConfigParams::m_default_kart.revertToDefaults(); UserConfigParams::m_default_kart.revertToDefaults();

View File

@ -76,7 +76,7 @@ void SoccerWorld::init()
// check for possible problems if AI karts were incorrectly added // check for possible problems if AI karts were incorrectly added
if(getNumKarts() > race_manager->getNumPlayers()) if(getNumKarts() > race_manager->getNumPlayers())
{ {
fprintf(stderr, "No AI exists for this game mode\n"); Log::error("[SoccerWorld]", "No AI exists for this game mode");
exit(1); exit(1);
} }
m_goal_target = race_manager->getMaxGoal(); m_goal_target = race_manager->getMaxGoal();
@ -85,7 +85,7 @@ void SoccerWorld::init()
} // init } // init
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
/** Called then a battle is restarted. /** Called when a battle is restarted.
*/ */
void SoccerWorld::reset() void SoccerWorld::reset()
{ {
@ -391,8 +391,8 @@ void SoccerWorld::moveKartAfterRescue(AbstractKart* kart)
} }
else else
{ {
fprintf(stderr, "WARNING: invalid position after rescue for kart %s on track %s.\n", Log::warn("[SoccerWorld]", " Invalid position after rescue for kart %s on track %s.",
(kart->getIdent().c_str()), m_track->getIdent().c_str()); kart->getIdent().c_str(), m_track->getIdent().c_str());
} }
} // moveKartAfterRescue } // moveKartAfterRescue

View File

@ -61,7 +61,7 @@ void ThreeStrikesBattle::init()
// check for possible problems if AI karts were incorrectly added // check for possible problems if AI karts were incorrectly added
if(getNumKarts() > race_manager->getNumPlayers()) if(getNumKarts() > race_manager->getNumPlayers())
{ {
Log::fatal("Three Strikes Battle", "No AI exists for this game mode"); Log::fatal("[Three Strikes Battle]", "No AI exists for this game mode");
} }
m_kart_info.resize(m_karts.size()); m_kart_info.resize(m_karts.size());
} // ThreeStrikesBattle } // ThreeStrikesBattle

View File

@ -334,7 +334,7 @@ Controller* World::loadAIController(AbstractKart *kart)
controller = new SkiddingAI(kart); controller = new SkiddingAI(kart);
break; break;
default: default:
Log::warn("World", "Unknown AI, using default."); Log::warn("[World]", "Unknown AI, using default.");
controller = new SkiddingAI(kart); controller = new SkiddingAI(kart);
break; break;
} }
@ -531,12 +531,12 @@ void World::resetAllKarts()
if (!kart_over_ground) if (!kart_over_ground)
{ {
Log::error("World", Log::error("[World]",
"No valid starting position for kart %d on track %s.", "No valid starting position for kart %d on track %s.",
(int)(i-m_karts.begin()), m_track->getIdent().c_str()); (int)(i-m_karts.begin()), m_track->getIdent().c_str());
if (UserConfigParams::m_artist_debug_mode) if (UserConfigParams::m_artist_debug_mode)
{ {
Log::warn("World", "Activating fly mode."); Log::warn("[World]", "Activating fly mode.");
(*i)->flyUp(); (*i)->flyUp();
continue; continue;
} }
@ -582,14 +582,14 @@ void World::resetAllKarts()
&normal); &normal);
if(!material) if(!material)
{ {
Log::error("World", Log::error("[World]",
"No valid starting position for kart %d " "No valid starting position for kart %d "
"on track %s.", "on track %s.",
(int)(i-m_karts.begin()), (int)(i-m_karts.begin()),
m_track->getIdent().c_str()); m_track->getIdent().c_str());
if (UserConfigParams::m_artist_debug_mode) if (UserConfigParams::m_artist_debug_mode)
{ {
Log::warn("World", "Activating fly mode."); Log::warn("[World]", "Activating fly mode.");
(*i)->flyUp(); (*i)->flyUp();
continue; continue;
} }
@ -757,7 +757,7 @@ void World::updateWorld(float dt)
if (!kart_properties_manager->getKart(UserConfigParams::m_default_kart)) if (!kart_properties_manager->getKart(UserConfigParams::m_default_kart))
{ {
Log::warn("World", Log::warn("[World]",
"Cannot find kart '%s', will revert to default.", "Cannot find kart '%s', will revert to default.",
UserConfigParams::m_default_kart.c_str()); UserConfigParams::m_default_kart.c_str());
UserConfigParams::m_default_kart.revertToDefaults(); UserConfigParams::m_default_kart.revertToDefaults();
@ -932,10 +932,10 @@ void World::updateHighscores(int* best_highscore_rank, int* best_finish_time,
// the kart location data is wrong // the kart location data is wrong
#ifdef DEBUG #ifdef DEBUG
Log::error("World", "Incorrect kart positions:"); Log::error("[World]", "Incorrect kart positions:");
for (unsigned int i=0; i<m_karts.size(); i++ ) for (unsigned int i=0; i<m_karts.size(); i++ )
{ {
Log::error("World", "i=%d position %d.",i, Log::error("[World]", "i=%d position %d.",i,
m_karts[i]->getPosition()); m_karts[i]->getPosition());
} }
#endif #endif
@ -948,7 +948,6 @@ void World::updateHighscores(int* best_highscore_rank, int* best_finish_time,
continue; continue;
if (!m_karts[index[pos]]->hasFinishedRace()) continue; if (!m_karts[index[pos]]->hasFinishedRace()) continue;
assert(index[pos] >= 0);
assert(index[pos] < m_karts.size()); assert(index[pos] < m_karts.size());
Kart *k = (Kart*)m_karts[index[pos]]; Kart *k = (Kart*)m_karts[index[pos]];

View File

@ -21,6 +21,7 @@
#include "karts/kart_properties.hpp" #include "karts/kart_properties.hpp"
#include "race/history.hpp" #include "race/history.hpp"
#include "tracks/track.hpp" #include "tracks/track.hpp"
#include "utils/log.hpp"
#include <iostream> #include <iostream>
@ -85,22 +86,22 @@ bool WorldWithRank::setKartPosition(unsigned int kart_id,
assert(m_position_setting_initialised); assert(m_position_setting_initialised);
if(m_position_used[position-1]) if(m_position_used[position-1])
{ {
std::cerr << "== TWO KARTS ARE BEING GIVEN THE SAME POSITION!! ==\n"; Log::error("[WorldWithRank]", "== TWO KARTS ARE BEING GIVEN THE SAME POSITION!! ==");
for (unsigned int j=0; j < m_position_index.size(); j++) for (unsigned int j=0; j < m_position_index.size(); j++)
{ {
if (!m_position_used[j]) if (!m_position_used[j])
{ {
std::cout << " No kart is yet set at position " << j+1 Log::warn("WorldWithRank]", "No kart is yet set at position %u", j+1);
<< std::endl;
} }
else else
{ {
std::cout << " Kart " << m_position_index[j] Log::warn("WorldWithRank]", "Kart %u is at position %u",
<< " is at position " << j << std::endl; m_position_index[j], j);
} }
} }
std::cout << "Kart " << kart_id << " is being given position " Log::warn("WorldWithRank]", "Kart %u is being given position %u,"
<< position << ", but this position is already taken\n"; "but this position is already taken",
kart_id, position);
return false; return false;
} }
m_position_used[position-1] = true; m_position_used[position-1] = true;

View File

@ -123,7 +123,7 @@ void NetworkManager::notifyEvent(Event* event)
((addr>>24)&0xff), ((addr>>24)&0xff),
((addr>>16)&0xff), ((addr>>16)&0xff),
((addr>>8)&0xff), ((addr>>8)&0xff),
(addr&0xff), event->data().c_str()); (addr & 0xff), event->data().std_string().c_str());
} }

View File

@ -146,16 +146,20 @@ class NetworkString
return *this; return *this;
} }
const char* c_str() const const std::string std_string() const
{ {
std::string str(m_string.begin(), m_string.end()); std::string str(m_string.begin(), m_string.end());
return str.c_str(); return str;
} }
int size() const int size() const
{ {
return m_string.size(); return m_string.size();
} }
uint8_t* getBytes() { return &m_string[0]; };
const uint8_t* getBytes() const { return &m_string[0]; };
template<typename T, size_t n> template<typename T, size_t n>
T get(int pos) const T get(int pos) const
{ {

View File

@ -144,7 +144,7 @@ void ProtocolManager::notifyEvent(Event* event)
pthread_mutex_unlock(&m_protocols_mutex); pthread_mutex_unlock(&m_protocols_mutex);
if (searchedProtocol == PROTOCOL_NONE) // no protocol was aimed, show the msg to debug if (searchedProtocol == PROTOCOL_NONE) // no protocol was aimed, show the msg to debug
{ {
Log::debug("ProtocolManager", "NO PROTOCOL : Message is \"%s\"", event2->data().c_str()); Log::debug("ProtocolManager", "NO PROTOCOL : Message is \"%s\"", event2->data().std_string().c_str());
} }
if (protocols_ids.size() != 0) if (protocols_ids.size() != 0)

View File

@ -73,7 +73,7 @@ void* STKHost::receive_data(void* self)
} }
} }
myself->m_listening = false; myself->m_listening = false;
delete myself->m_listening_thread; free(myself->m_listening_thread);
myself->m_listening_thread = NULL; myself->m_listening_thread = NULL;
Log::info("STKHost", "Listening has been stopped"); Log::info("STKHost", "Listening has been stopped");
return NULL; return NULL;
@ -302,7 +302,7 @@ uint8_t* STKHost::receiveRawPacket(TransportAddress sender, int max_tries)
void STKHost::broadcastPacket(const NetworkString& data, bool reliable) void STKHost::broadcastPacket(const NetworkString& data, bool reliable)
{ {
ENetPacket* packet = enet_packet_create(data.c_str(), data.size()+1, ENetPacket* packet = enet_packet_create(data.getBytes(), data.size() + 1,
(reliable ? ENET_PACKET_FLAG_RELIABLE : ENET_PACKET_FLAG_UNSEQUENCED)); (reliable ? ENET_PACKET_FLAG_RELIABLE : ENET_PACKET_FLAG_UNSEQUENCED));
enet_host_broadcast(m_host, 0, packet); enet_host_broadcast(m_host, 0, packet);
STKHost::logPacket(data, false); STKHost::logPacket(data, false);

View File

@ -95,7 +95,7 @@ void STKPeer::sendPacket(NetworkString const& data, bool reliable)
data.size(), (m_peer->address.host>>0)&0xff, data.size(), (m_peer->address.host>>0)&0xff,
(m_peer->address.host>>8)&0xff,(m_peer->address.host>>16)&0xff, (m_peer->address.host>>8)&0xff,(m_peer->address.host>>16)&0xff,
(m_peer->address.host>>24)&0xff,m_peer->address.port); (m_peer->address.host>>24)&0xff,m_peer->address.port);
ENetPacket* packet = enet_packet_create(data.c_str(), data.size()+1, ENetPacket* packet = enet_packet_create(data.getBytes(), data.size() + 1,
(reliable ? ENET_PACKET_FLAG_RELIABLE : ENET_PACKET_FLAG_UNSEQUENCED)); (reliable ? ENET_PACKET_FLAG_RELIABLE : ENET_PACKET_FLAG_UNSEQUENCED));
/* to debug the packet output /* to debug the packet output
printf("STKPeer: "); printf("STKPeer: ");
@ -126,7 +126,7 @@ uint16_t STKPeer::getPort() const
bool STKPeer::isConnected() const bool STKPeer::isConnected() const
{ {
Log::info("STKPeer", "The peer state is %i\n", m_peer->state); Log::info("STKPeer", "The peer state is %i", m_peer->state);
return (m_peer->state == ENET_PEER_STATE_CONNECTED); return (m_peer->state == ENET_PEER_STATE_CONNECTED);
} }

View File

@ -87,7 +87,7 @@ private:
// -------------------------------------------------------------------- // --------------------------------------------------------------------
const UserPointer *getUserPointer(unsigned int n) const const UserPointer *getUserPointer(unsigned int n) const
{ {
assert(n>=0 && n<=1); assert(n<=1);
return m_up[n]; return m_up[n];
} // getUserPointer } // getUserPointer
// -------------------------------------------------------------------- // --------------------------------------------------------------------

View File

@ -143,7 +143,7 @@ void RaceManager::setLocalKartInfo(unsigned int player_id,
const std::string& kart) const std::string& kart)
{ {
assert(kart.size() > 0); assert(kart.size() > 0);
assert(0<=player_id && player_id <m_local_player_karts.size()); assert(player_id <m_local_player_karts.size());
assert(kart_properties_manager->getKart(kart) != NULL); assert(kart_properties_manager->getKart(kart) != NULL);
const PlayerProfile* profile = StateManager::get()->getActivePlayerProfile(player_id); const PlayerProfile* profile = StateManager::get()->getActivePlayerProfile(player_id);
@ -157,7 +157,7 @@ void RaceManager::setLocalKartInfo(unsigned int player_id,
*/ */
void RaceManager::setLocalKartSoccerTeam(unsigned int player_id, SoccerTeam team) void RaceManager::setLocalKartSoccerTeam(unsigned int player_id, SoccerTeam team)
{ {
assert(0<=player_id && player_id <m_local_player_karts.size()); assert(player_id <m_local_player_karts.size());
m_local_player_karts[player_id].setSoccerTeam(team); m_local_player_karts[player_id].setSoccerTeam(team);
} }

View File

@ -106,7 +106,7 @@ void ArenasScreen::beforeAddingWidget()
DynamicRibbonWidget* tracks_widget = this->getWidget<DynamicRibbonWidget>("tracks"); DynamicRibbonWidget* tracks_widget = this->getWidget<DynamicRibbonWidget>("tracks");
assert( tracks_widget != NULL ); assert( tracks_widget != NULL );
tracks_widget->setItemCountHint(num_of_arenas); //set the item hint to that number to prevent weird formatting tracks_widget->setItemCountHint(num_of_arenas+1); //set the item hint to that number to prevent weird formatting
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------

View File

@ -305,7 +305,6 @@ void AddonsLoading::onUpdate(float delta)
**/ **/
void AddonsLoading::startDownload() void AddonsLoading::startDownload()
{ {
std::string file = m_addon.getZipFileName();
std::string save = "tmp/" std::string save = "tmp/"
+ StringUtils::getBasename(m_addon.getZipFileName()); + StringUtils::getBasename(m_addon.getZipFileName());
m_download_request = new Online::HTTPRequest(save, /*manage mem*/false, m_download_request = new Online::HTTPRequest(save, /*manage mem*/false,

View File

@ -176,7 +176,7 @@ void EasterEggScreen::beforeAddingWidget()
DynamicRibbonWidget* tracks_widget = this->getWidget<DynamicRibbonWidget>("tracks"); DynamicRibbonWidget* tracks_widget = this->getWidget<DynamicRibbonWidget>("tracks");
assert( tracks_widget != NULL ); assert( tracks_widget != NULL );
tracks_widget->setItemCountHint(num_of_arenas); //set the item hint to that number to prevent weird formatting tracks_widget->setItemCountHint(num_of_arenas+1); //set the item hint to that number to prevent weird formatting
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------

View File

@ -43,6 +43,7 @@
#include "online/profile.hpp" #include "online/profile.hpp"
#include "states_screens/race_setup_screen.hpp" #include "states_screens/race_setup_screen.hpp"
#include "states_screens/state_manager.hpp" #include "states_screens/state_manager.hpp"
#include "utils/log.hpp"
#include "utils/translation.hpp" #include "utils/translation.hpp"
#include "utils/random_generator.hpp" #include "utils/random_generator.hpp"
#include "utils/string_utils.hpp" #include "utils/string_utils.hpp"
@ -393,9 +394,9 @@ void PlayerKartWidget::setPlayerID(const int newPlayerID)
if (StateManager::get()->getActivePlayer(newPlayerID) if (StateManager::get()->getActivePlayer(newPlayerID)
!= m_associated_player) != m_associated_player)
{ {
std::cerr << "[KartSelectionScreen] WARNING: Internal " Log::warn("[KartSelectionScreen]", "Internal "
"inconsistency, PlayerKartWidget has IDs and " "inconsistency, PlayerKartWidget has IDs and "
"pointers that do not correspond to one player\n"; "pointers that do not correspond to one player");
fprintf(stderr, fprintf(stderr,
" Player: %p - Index: %d - m_associated_player: %p\n", " Player: %p - Index: %d - m_associated_player: %p\n",
StateManager::get()->getActivePlayer(newPlayerID), StateManager::get()->getActivePlayer(newPlayerID),
@ -692,12 +693,11 @@ GUIEngine::EventPropagation PlayerKartWidget::transmitEvent(
{ {
if(UserConfigParams::logGUI()) if(UserConfigParams::logGUI())
{ {
std::cout << "[KartSelectionScreen] Identity changed " Log::info("[KartSelectionScreen]", "Identity changed "
"for player " << m_player_id "for player %s : %s",m_player_id,
<< " : " << irr::core::stringc( irr::core::stringc(
m_player_ident_spinner->getStringValue() m_player_ident_spinner->getStringValue()
.c_str()).c_str() .c_str()).c_str());
<< std::endl;
} }
if (m_parent_screen->m_multiplayer) if (m_parent_screen->m_multiplayer)
@ -1062,7 +1062,7 @@ void KartSelectionScreen::unloaded()
bool KartSelectionScreen::playerJoin(InputDevice* device, bool firstPlayer) bool KartSelectionScreen::playerJoin(InputDevice* device, bool firstPlayer)
{ {
if (UserConfigParams::logGUI()) if (UserConfigParams::logGUI())
std::cout << "[KartSelectionScreen] playerJoin() invoked\n"; Log::info("[KartSelectionScreen]", "playerJoin() invoked");
if (!m_multiplayer && !firstPlayer) return false; if (!m_multiplayer && !firstPlayer) return false;
assert (g_dispatcher != NULL); assert (g_dispatcher != NULL);
@ -1070,21 +1070,21 @@ bool KartSelectionScreen::playerJoin(InputDevice* device, bool firstPlayer)
DynamicRibbonWidget* w = getWidget<DynamicRibbonWidget>("karts"); DynamicRibbonWidget* w = getWidget<DynamicRibbonWidget>("karts");
if (w == NULL) if (w == NULL)
{ {
std::cerr << "[KartSelectionScreen] playerJoin(): Called outside of " Log::error("[KartSelectionScreen]", "playerJoin(): Called outside of "
"kart selection screen.\n"; "kart selection screen.");
return false; return false;
} }
else if (device == NULL) else if (device == NULL)
{ {
std::cerr << "[KartSelectionScreen] playerJoin(): Received null " Log::error("[KartSelectionScreen]", "playerJoin(): Received null "
"device pointer\n"; "device pointer");
return false; return false;
} }
if (StateManager::get()->activePlayerCount() >= MAX_PLAYER_COUNT) if (StateManager::get()->activePlayerCount() >= MAX_PLAYER_COUNT)
{ {
std::cerr << "[KartSelectionScreen] Maximum number of players " Log::error("[KartSelectionScreen]", "Maximum number of players "
"reached\n"; "reached");
sfx_manager->quickSound( "anvil" ); sfx_manager->quickSound( "anvil" );
return false; return false;
} }
@ -1214,10 +1214,10 @@ bool KartSelectionScreen::playerQuit(StateManager::ActivePlayer* player)
DynamicRibbonWidget* w = getWidget<DynamicRibbonWidget>("karts"); DynamicRibbonWidget* w = getWidget<DynamicRibbonWidget>("karts");
if (w == NULL) if (w == NULL)
{ {
std::cerr << "[KartSelectionScreen] ERROR: playerQuit() called " Log::error("[KartSelectionScreen]", "ERROR: playerQuit() called "
"outside of kart selection screen, " "outside of kart selection screen, "
<< "or the XML file for this screen was changed without " "or the XML file for this screen was changed without "
"adapting the code accordingly\n"; "adapting the code accordingly");
return false; return false;
} }
@ -1249,12 +1249,12 @@ bool KartSelectionScreen::playerQuit(StateManager::ActivePlayer* player)
} }
if (playerID == -1) if (playerID == -1)
{ {
std::cerr << "[KartSelectionScreen] WARNING: playerQuit cannot find " Log::warn("[KartSelectionScreen]", " playerQuit cannot find "
"passed player\n"; "passed player");
return false; return false;
} }
if(UserConfigParams::logGUI()) if(UserConfigParams::logGUI())
std::cout << "playerQuit( " << playerID << " )\n"; Log::info("[KartSelectionScreen]", "playerQuit(%s)",playerID);
// Just a cheap way to check if there is any discrepancy // Just a cheap way to check if there is any discrepancy
// between m_kart_widgets and the active player array // between m_kart_widgets and the active player array
@ -1291,8 +1291,8 @@ bool KartSelectionScreen::playerQuit(StateManager::ActivePlayer* player)
// update selections // update selections
const int amount = m_kart_widgets.size(); const unsigned int amount = m_kart_widgets.size();
for (int n=0; n<amount; n++) for (unsigned int n=0; n<amount; n++)
{ {
const std::string& selectedKart = selections[m_kart_widgets.get(n)]; const std::string& selectedKart = selections[m_kart_widgets.get(n)];
if (selectedKart.size() > 0) if (selectedKart.size() > 0)
@ -1303,9 +1303,8 @@ bool KartSelectionScreen::playerQuit(StateManager::ActivePlayer* player)
const bool success = w->setSelection(selectedKart, n, true); const bool success = w->setSelection(selectedKart, n, true);
if (!success) if (!success)
{ {
std::cerr << "[KartSelectionScreen] Failed to select kart " Log::warn("[KartSelectionScreen]", "Failed to select kart %s"
<< selectedKart << " for player " << n " for player %u, what's going on??", selectedKart.c_str(),n);
<< ", what's going on??\n";
} }
} }
} }
@ -1313,7 +1312,7 @@ bool KartSelectionScreen::playerQuit(StateManager::ActivePlayer* player)
// check if all players are ready // check if all players are ready
bool allPlayersReady = true; bool allPlayersReady = true;
for (int n=0; n<amount; n++) for (unsigned int n=0; n<amount; n++)
{ {
if (!m_kart_widgets[n].isReady()) if (!m_kart_widgets[n].isReady())
{ {
@ -1403,8 +1402,8 @@ void KartSelectionScreen::playerConfirm(const int playerID)
!willNeedDuplicates) !willNeedDuplicates)
{ {
if (UserConfigParams::logGUI()) if (UserConfigParams::logGUI())
printf("[KartSelectionScreen] You can't select this identity " Log::warn("[KartSelectionScreen]", "You can't select this identity "
"or kart, someone already took it!!\n"); "or kart, someone already took it!!");
sfx_manager->quickSound( "anvil" ); sfx_manager->quickSound( "anvil" );
return; return;
@ -1571,8 +1570,8 @@ void KartSelectionScreen::eventCallback(Widget* widget,
// if we get here, it means one player "lost" his kart in // if we get here, it means one player "lost" his kart in
// the tab switch // the tab switch
if (UserConfigParams::logGUI()) if (UserConfigParams::logGUI())
std::cout << "[KartSelectionScreen] Player " << n Log::info("[KartSelectionScreen]", "Player %u"
<< " lost their selection when switching tabs!!!\n"; " lost their selection when switching tabs!!!",n);
// Select a random kart in this case // Select a random kart in this case
const int count = w->getItems().size(); const int count = w->getItems().size();
@ -1589,14 +1588,13 @@ void KartSelectionScreen::eventCallback(Widget* widget,
w->setSelection( randomID, n, w->setSelection( randomID, n,
n != PLAYER_ID_GAME_MASTER ); n != PLAYER_ID_GAME_MASTER );
if (!success) if (!success)
std::cerr << "[KartSelectionScreen] WARNING: " Log::warn("[KartSelectionScreen]",
"setting kart of player " << n "setting kart of player %u failed");
<< " failed :(\n";
} }
else else
{ {
std::cerr << "[KartSelectionScreen] WARNING : 0 items " Log::warn("[KartSelectionScreen]", " 0 items "
"in the ribbon\n"; "in the ribbon");
} }
} }
} }
@ -1689,14 +1687,14 @@ void KartSelectionScreen::allPlayersDone()
// ---- Print selection (for debugging purposes) // ---- Print selection (for debugging purposes)
if(UserConfigParams::logGUI()) if(UserConfigParams::logGUI())
{ {
std::cout << "[KartSelectionScreen] " << players.size() Log::info("[KartSelectionScreen]", "players : %d",players.size());
<< " players :\n";
for (unsigned int n=0; n<players.size(); n++) for (unsigned int n=0; n<players.size(); n++)
{ {
std::cout << " Player " << n << " is " Log::info("[KartSelectionScreen]", " Player %u is %s on %s",n,
<< core::stringc( core::stringc(
players[n].getConstProfile()->getName().c_str()).c_str() players[n].getConstProfile()->getName().c_str()).c_str(),
<< " on " << players[n].getDevice()->m_name << std::endl; players[n].getDevice()->m_name.c_str());
} }
} }
@ -1886,10 +1884,10 @@ bool KartSelectionScreen::validateKartChoices()
{ {
bool ok = true; bool ok = true;
const int amount = m_kart_widgets.size(); const unsigned int amount = m_kart_widgets.size();
// reset all marks, we'll re-add them next if errors are still there // reset all marks, we'll re-add them next if errors are still there
for (int n=0; n<amount; n++) for (unsigned int n=0; n<amount; n++)
{ {
m_kart_widgets[n].m_model_view->unsetBadge(BAD_BADGE); m_kart_widgets[n].m_model_view->unsetBadge(BAD_BADGE);
} }
@ -1898,26 +1896,24 @@ bool KartSelectionScreen::validateKartChoices()
// players than karts then just allow duplicates // players than karts then just allow duplicates
DynamicRibbonWidget* w = getWidget<DynamicRibbonWidget>("karts"); DynamicRibbonWidget* w = getWidget<DynamicRibbonWidget>("karts");
assert( w != NULL ); assert( w != NULL );
const int availableKartCount = w->getItems().size(); const unsigned int availableKartCount = w->getItems().size();
if (amount > availableKartCount) return true; if (amount > availableKartCount) return true;
// Check everyone for duplicates // Check everyone for duplicates
for (int n=0; n<amount; n++) for (unsigned int n=0; n<amount; n++)
{ {
for (int m=n+1; m<amount; m++) for (unsigned int m=n+1; m<amount; m++)
{ {
// check if 2 players took the same name // check if 2 players took the same name
if (sameKart(m_kart_widgets[n], m_kart_widgets[m])) if (sameKart(m_kart_widgets[n], m_kart_widgets[m]))
{ {
if (UserConfigParams::logGUI()) if (UserConfigParams::logGUI())
{ {
printf("[KartSelectionScreen] Kart conflict!!\n"); Log::warn("[KartSelectionScreen]", "Kart conflict!!");
std::cout << " Player " << n << " chose " Log::warn("KartSelectionScreen]", " Player %u chose %s",n,
<< m_kart_widgets[n].getKartInternalName() m_kart_widgets[n].getKartInternalName().c_str());
<< std::endl; Log::warn("[KartSelectionScreen]", " Player %u chose %s",m,
std::cout << " Player " << m << " chose " m_kart_widgets[m].getKartInternalName().c_str());
<< m_kart_widgets[m].getKartInternalName()
<< std::endl;
} }
// two players took the same kart. check if one is ready // two players took the same kart. check if one is ready
@ -1925,8 +1921,7 @@ bool KartSelectionScreen::validateKartChoices()
m_kart_widgets[m].isReady()) m_kart_widgets[m].isReady())
{ {
if (UserConfigParams::logGUI()) if (UserConfigParams::logGUI())
std::cout << " --> Setting red badge on player " Log::info("[KartSelectionScreen]", " --> Setting red badge on player %u", n);
<< n << std::endl;
// player m is ready, so player n should not choose // player m is ready, so player n should not choose
// this name // this name
@ -1936,8 +1931,7 @@ bool KartSelectionScreen::validateKartChoices()
!m_kart_widgets[m].isReady()) !m_kart_widgets[m].isReady())
{ {
if (UserConfigParams::logGUI()) if (UserConfigParams::logGUI())
std::cout << " --> Setting red badge on player " Log::info("[KartSelectionScreen]", " --> Setting red badge on player %u",m);
<< m << std::endl;
// player n is ready, so player m should not // player n is ready, so player m should not
// choose this name // choose this name
@ -2089,8 +2083,8 @@ EventPropagation FocusDispatcher::focused(const int playerID)
if (!m_is_initialised) return EVENT_LET; if (!m_is_initialised) return EVENT_LET;
if(UserConfigParams::logGUI()) if(UserConfigParams::logGUI())
std::cout << "[KartSelectionScreen] FocusDispatcher focused by player " Log::info("[KartSelectionScreen]", "FocusDispatcher focused by player %u",
<< playerID << std::endl; playerID);
// since this screen is multiplayer, redirect focus to the right widget // since this screen is multiplayer, redirect focus to the right widget
const int amount = m_parent->m_kart_widgets.size(); const int amount = m_parent->m_kart_widgets.size();

View File

@ -486,6 +486,15 @@ void RaceGUIOverworld::drawGlobalMiniMap()
gui::ScalableFont* font = GUIEngine::getTitleFont(); gui::ScalableFont* font = GUIEngine::getTitleFont();
font->draw(gp->getName(), pos, video::SColor(255,255,255,255), font->draw(gp->getName(), pos, video::SColor(255,255,255,255),
false, true /* vcenter */, NULL); false, true /* vcenter */, NULL);
core::rect<s32> pos(15,
20 + GUIEngine::getTitleFontHeight(),
15 + UserConfigParams::m_width/2,
20 + 2*GUIEngine::getTitleFontHeight());
//just below GP name
font->draw(_("Type: Grand Prix"), pos, video::SColor(255,255,255,255),
false, true /* vcenter */, NULL);
} }
else else
{ {

View File

@ -192,7 +192,7 @@ void TracksScreen::beforeAddingWidget()
DynamicRibbonWidget* tracks_widget = this->getWidget<DynamicRibbonWidget>("tracks"); DynamicRibbonWidget* tracks_widget = this->getWidget<DynamicRibbonWidget>("tracks");
assert( tracks_widget != NULL ); assert( tracks_widget != NULL );
tracks_widget->setItemCountHint( track_manager->getNumberOfTracks() ); tracks_widget->setItemCountHint( track_manager->getNumberOfTracks()+1 );
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------

View File

@ -151,6 +151,29 @@ Track::~Track()
#endif #endif
} // ~Track } // ~Track
//-----------------------------------------------------------------------------
/** Returns number of completed challenges */
unsigned int Track::getNumOfCompletedChallenges()
{
unsigned int unlocked_challenges = 0;
GameSlot* slot = unlock_manager->getCurrentSlot();
for (unsigned int i=0; i<m_challenges.size(); i++)
{
if (m_challenges[i].m_challenge_id == "tutorial")
{
unlocked_challenges++;
continue;
}
if (slot->getChallenge(m_challenges[i].m_challenge_id)
->isSolvedAtAnyDifficulty())
{
unlocked_challenges++;
}
}
return unlocked_challenges;
} // getNumOfCompletedChallenges
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
/** Removes all cached data structures. This is called before the resolution /** Removes all cached data structures. This is called before the resolution
* is changed. * is changed.
@ -963,6 +986,7 @@ bool Track::loadMainTrack(const XMLNode &root)
} }
else if (condition == "allchallenges") else if (condition == "allchallenges")
{ {
<<<<<<< HEAD
unsigned int unlocked_challenges = 0; unsigned int unlocked_challenges = 0;
PlayerProfile *player = PlayerManager::get()->getCurrentPlayer(); PlayerProfile *player = PlayerManager::get()->getCurrentPlayer();
for (unsigned int c=0; c<m_challenges.size(); c++) for (unsigned int c=0; c<m_challenges.size(); c++)
@ -979,8 +1003,11 @@ bool Track::loadMainTrack(const XMLNode &root)
} }
} }
=======
>>>>>>> upstream/master
// allow ONE unsolved challenge : the last one // allow ONE unsolved challenge : the last one
if (unlocked_challenges < m_challenges.size() - 1) continue; if (getNumOfCompletedChallenges() < m_challenges.size() - 1)
continue;
} }
else if (condition.size() > 0) else if (condition.size() > 0)
{ {
@ -995,6 +1022,7 @@ bool Track::loadMainTrack(const XMLNode &root)
} }
else if (neg_condition == "allchallenges") else if (neg_condition == "allchallenges")
{ {
<<<<<<< HEAD
unsigned int unlocked_challenges = 0; unsigned int unlocked_challenges = 0;
PlayerProfile *player = PlayerManager::get()->getCurrentPlayer(); PlayerProfile *player = PlayerManager::get()->getCurrentPlayer();
for (unsigned int c=0; c<m_challenges.size(); c++) for (unsigned int c=0; c<m_challenges.size(); c++)
@ -1011,8 +1039,11 @@ bool Track::loadMainTrack(const XMLNode &root)
} }
} }
=======
>>>>>>> upstream/master
// allow ONE unsolved challenge : the last one // allow ONE unsolved challenge : the last one
if (unlocked_challenges >= m_challenges.size() - 1) continue; if (getNumOfCompletedChallenges() >= m_challenges.size() - 1)
continue;
} }
else if (neg_condition.size() > 0) else if (neg_condition.size() > 0)
{ {

View File

@ -206,6 +206,7 @@ private:
/** True if this track (textures and track data) should be cached. Used /** True if this track (textures and track data) should be cached. Used
* for the overworld. */ * for the overworld. */
bool m_cache_track; bool m_cache_track;
#ifdef DEBUG #ifdef DEBUG
/** A list of textures that were cached before the track is loaded. /** A list of textures that were cached before the track is loaded.
@ -527,6 +528,9 @@ public:
/** Returns the number of modes available for this track. */ /** Returns the number of modes available for this track. */
unsigned int getNumberOfModes() const { return m_all_modes.size(); } unsigned int getNumberOfModes() const { return m_all_modes.size(); }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Returns number of completed challenges. */
unsigned int getNumOfCompletedChallenges();
// ------------------------------------------------------------------------
/** Returns the name of the i-th. mode. */ /** Returns the name of the i-th. mode. */
const std::string &getModeName(unsigned int i) const const std::string &getModeName(unsigned int i) const
{ return m_all_modes[i].m_name; } { return m_all_modes[i].m_name; }

View File

@ -20,6 +20,7 @@
#include "audio/sfx_base.hpp" #include "audio/sfx_base.hpp"
#include "audio/sfx_buffer.hpp" #include "audio/sfx_buffer.hpp"
#include "challenges/unlock_manager.hpp"
#include "graphics/irr_driver.hpp" #include "graphics/irr_driver.hpp"
#include "graphics/material_manager.hpp" #include "graphics/material_manager.hpp"
#include "graphics/particle_emitter.hpp" #include "graphics/particle_emitter.hpp"
@ -674,6 +675,21 @@ void TrackObjectPresentationActionTrigger::onTriggerItemApproached(Item* who)
new RacePausedDialog(0.8f, 0.6f); new RacePausedDialog(0.8f, 0.6f);
//dynamic_cast<OverWorld*>(World::getWorld())->scheduleSelectKart(); //dynamic_cast<OverWorld*>(World::getWorld())->scheduleSelectKart();
} }
//action trigger near big doors in the overword to notify players that they'll open once they finish all the challenges
else if (m_action == "big_door")
{
m_action_active = false;
Track* m_track = World::getWorld()->getTrack();
unsigned int unlocked_challenges = m_track->getNumOfCompletedChallenges();
std::vector<OverworldChallenge> m_challenges = m_track->getChallengeList();
// allow ONE unsolved challenge : the last one
if (unlocked_challenges < m_challenges.size() - 1)
{
new TutorialMessageDialog(_("Complete all challenges to unlock the big door!"), true);
}
}
else if (m_action == "tutorial_drive") else if (m_action == "tutorial_drive")
{ {
//if (World::getWorld()->getPhase() == World::RACE_PHASE) //if (World::getWorld()->getPhase() == World::RACE_PHASE)

View File

@ -167,7 +167,7 @@ bool onEvent(const SEvent &event)
{ {
if(cmdID == DEBUG_GRAPHICS_RELOAD_SHADERS) if(cmdID == DEBUG_GRAPHICS_RELOAD_SHADERS)
{ {
Log::info("Debug", "Reloading shaders...\n"); Log::info("Debug", "Reloading shaders...");
irr_driver->updateShaders(); irr_driver->updateShaders();
} }
else if (cmdID == DEBUG_GRAPHICS_RESET) else if (cmdID == DEBUG_GRAPHICS_RESET)

View File

@ -26,39 +26,6 @@ float clampf(float in, float low, float high) {
return in > high ? high : in < low ? low : in; return in > high ? high : in < low ? low : in;
} }
float smootherstep(float e0, float e1, float x) {
x = clampf((x - e0)/(e1 - e0), 0, 1);
return x*x*x*(x*(x*6 - 15) + 10);
}
void savetex(ITexture *tex, const char *name) {
using namespace core;
using namespace video;
IVideoDriver * const drv = irr_driver->getVideoDriver();
IImage * const tmp = drv->createImage(tex, position2di(0,0), tex->getSize());
if (!name)
{
stringc namec = tex->getName().getPath();
namec += ".png";
drv->writeImageToFile(tmp, namec.c_str());
}
else
{
drv->writeImageToFile(tmp, name);
}
tmp->drop();
}
float mix(float x, float y, float a) {
return x * (1 - a) + y * a;
}
unsigned ispow(const unsigned in) { unsigned ispow(const unsigned in) {
if (in < 2) return 0; if (in < 2) return 0;
@ -66,19 +33,6 @@ unsigned ispow(const unsigned in) {
return !(in & (in - 1)); return !(in & (in - 1));
} }
unsigned npow(unsigned in) {
if (ispow(in)) return in;
in |= in >> 1;
in |= in >> 2;
in |= in >> 4;
in |= in >> 8;
in |= in >> 16;
return in + 1;
}
// Simple 8-bit hash // Simple 8-bit hash
u8 shash8(const u8 * const data, const u16 size) { u8 shash8(const u8 * const data, const u16 size) {

View File

@ -23,15 +23,9 @@
using irr::video::ITexture; using irr::video::ITexture;
float smootherstep(float, float, float);
float clampf(float, float, float); float clampf(float, float, float);
float mix(float x, float y, float a);
unsigned ispow(const unsigned in); unsigned ispow(const unsigned in);
unsigned npow(unsigned in);
void savetex(ITexture *tex, const char *name = NULL);
float noise2d(float v1, float v2 = 0); float noise2d(float v1, float v2 = 0);

View File

@ -72,7 +72,7 @@ namespace StringUtils
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Specialisiation for bools to return 'true' or 'false'*/ /** Specialisiation for bools to return 'true' or 'false'*/
inline std::string toString(bool &b) inline std::string toString(const bool& b)
{ {
return (b ? "true" : "false"); return (b ? "true" : "false");
} // toString(bool) } // toString(bool)