From a86b4e489c62a846bf27a74b3b4c92b9321137fd Mon Sep 17 00:00:00 2001 From: hiker Date: Sun, 28 Sep 2014 23:18:52 +1000 Subject: [PATCH 01/42] First version of 'smooth landing' in physics. --- src/physics/btKart.cpp | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/physics/btKart.cpp b/src/physics/btKart.cpp index 8e28cf21a..169610cd8 100644 --- a/src/physics/btKart.cpp +++ b/src/physics/btKart.cpp @@ -234,8 +234,13 @@ btScalar btKart::rayCast(unsigned int index) btScalar depth = -1; - btScalar raylen = wheel.getSuspensionRestLength()+wheel.m_wheelsRadius - + wheel.m_maxSuspensionTravelCm*0.01f; + btScalar max_susp_len = wheel.getSuspensionRestLength()+wheel.m_wheelsRadius + + wheel.m_maxSuspensionTravelCm*0.01f; + + // Do a slightly longer raycast to see if the kart might soon hit the + // ground and some 'cushioning' is needed to avoid that the chassis + // hits the ground. + btScalar raylen = max_susp_len + 0.5f; btVector3 rayvector = wheel.m_raycastInfo.m_wheelDirectionWS * (raylen); const btVector3& source = wheel.m_raycastInfo.m_hardPointWS; @@ -252,10 +257,10 @@ btScalar btKart::rayCast(unsigned int index) wheel.m_raycastInfo.m_groundObject = 0; - if (object) + depth = raylen * rayResults.m_distFraction; + if (object && depth < max_susp_len) { param = rayResults.m_distFraction; - depth = raylen * rayResults.m_distFraction; wheel.m_raycastInfo.m_contactNormalWS = rayResults.m_hitNormalInWorld; wheel.m_raycastInfo.m_contactNormalWS.normalize(); wheel.m_raycastInfo.m_isInContact = true; @@ -309,6 +314,18 @@ btScalar btKart::rayCast(unsigned int index) } else { + if(object) + { + + if(depth + m_chassisBody->getLinearVelocity().getY() *1./60.f < max_susp_len) + { + btVector3 v = -0.25f*0.5f*m_chassisBody->getLinearVelocity(); + v.setZ(0); + v.setX(0); + m_chassisBody->applyCentralImpulse(v/m_chassisBody->getInvMass()); + } + } + depth = btScalar(-1.0); //put wheel info as in rest position wheel.m_raycastInfo.m_suspensionLength = wheel.getSuspensionRestLength(); wheel.m_suspensionRelativeVelocity = btScalar(0.0); From 79873e2d4562447c403bb15d5ef2af12070b7c86 Mon Sep 17 00:00:00 2001 From: hiker Date: Mon, 29 Sep 2014 11:54:46 +1000 Subject: [PATCH 02/42] Added (some) support for driving on walls, added documentation. --- src/physics/btKart.cpp | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/physics/btKart.cpp b/src/physics/btKart.cpp index 169610cd8..b065fbc1f 100644 --- a/src/physics/btKart.cpp +++ b/src/physics/btKart.cpp @@ -314,15 +314,33 @@ btScalar btKart::rayCast(unsigned int index) } else { + // The raycast either hit nothing (object=NULL), or it hit something, + // but not in the maximum suspension range. If it hit something, + // check for the need of cushioning: if(object) { + // If the raycast hit something, see if the jump needs cushioning: + // i.e. a slowdown in fall speed in order to avoid that on landing + // the chassis hits the ground (causing a severe slowdown of the + // kart). The cushioning is done if the fall distance (v_down * dt) + // in this physics step is large enough that the kart would hit the + // ground, i.e. the maximum suspension length plus fall distance + // is larger than the distance to the object that was just detected. - if(depth + m_chassisBody->getLinearVelocity().getY() *1./60.f < max_susp_len) + // To allow for wall driving, properly project the velocity + // onto the normal + btVector3 v = m_chassisBody->getLinearVelocity(); + btVector3 down(0, 1, 0); + btVector3 v_down = (v * down) * down; + + if(depth < max_susp_len + v_down.length() *1./60.f) { - btVector3 v = -0.25f*0.5f*m_chassisBody->getLinearVelocity(); - v.setZ(0); - v.setX(0); - m_chassisBody->applyCentralImpulse(v/m_chassisBody->getInvMass()); + // Apply an impulse that will roughly half the speed. Since + // there are 4 wheels, a single wheel should apply 1/4 of + // the necessary impulse: + btVector3 impulse = (-0.25f*0.5f/m_chassisBody->getInvMass()) + * v_down; + m_chassisBody->applyCentralImpulse(impulse); } } depth = btScalar(-1.0); From 11916dd187d91a4279c4c3275e0a0fe95bde70ea Mon Sep 17 00:00:00 2001 From: hiker Date: Tue, 30 Sep 2014 23:13:48 +1000 Subject: [PATCH 03/42] Different implementation of soft-landing. --- .../src/BulletDynamics/Vehicle/btWheelInfo.h | 4 +- src/physics/btKart.cpp | 64 +++++++++---------- 2 files changed, 32 insertions(+), 36 deletions(-) diff --git a/lib/bullet/src/BulletDynamics/Vehicle/btWheelInfo.h b/lib/bullet/src/BulletDynamics/Vehicle/btWheelInfo.h index f916053ec..daf4157ad 100644 --- a/lib/bullet/src/BulletDynamics/Vehicle/btWheelInfo.h +++ b/lib/bullet/src/BulletDynamics/Vehicle/btWheelInfo.h @@ -77,6 +77,8 @@ struct btWheelInfo bool m_bIsFrontWheel; + bool m_was_on_ground; + void* m_clientInfo;//can be used to store pointer to sync transforms... btWheelInfo(btWheelInfoConstructionInfo& ci) @@ -102,7 +104,7 @@ struct btWheelInfo m_rollInfluence = btScalar(0.1); m_bIsFrontWheel = ci.m_bIsFrontWheel; m_maxSuspensionForce = ci.m_maxSuspensionForce; - + m_was_on_ground = true; } void updateWheel(const btRigidBody& chassis,RaycastInfo& raycastInfo); diff --git a/src/physics/btKart.cpp b/src/physics/btKart.cpp index b065fbc1f..576477b75 100644 --- a/src/physics/btKart.cpp +++ b/src/physics/btKart.cpp @@ -260,18 +260,15 @@ btScalar btKart::rayCast(unsigned int index) depth = raylen * rayResults.m_distFraction; if (object && depth < max_susp_len) { - param = rayResults.m_distFraction; wheel.m_raycastInfo.m_contactNormalWS = rayResults.m_hitNormalInWorld; wheel.m_raycastInfo.m_contactNormalWS.normalize(); wheel.m_raycastInfo.m_isInContact = true; ///@todo for driving on dynamic/movable objects!; wheel.m_raycastInfo.m_groundObject = &getFixedBody(); - btScalar hitDistance = param*raylen; - wheel.m_raycastInfo.m_suspensionLength = - hitDistance - wheel.m_wheelsRadius; - //clamp on max suspension travel + wheel.m_raycastInfo.m_suspensionLength = depth - wheel.m_wheelsRadius; + //clamp on max suspension travel btScalar minSuspensionLength = wheel.getSuspensionRestLength() - wheel.m_maxSuspensionTravelCm*btScalar(0.01); btScalar maxSuspensionLength = wheel.getSuspensionRestLength() @@ -314,35 +311,6 @@ btScalar btKart::rayCast(unsigned int index) } else { - // The raycast either hit nothing (object=NULL), or it hit something, - // but not in the maximum suspension range. If it hit something, - // check for the need of cushioning: - if(object) - { - // If the raycast hit something, see if the jump needs cushioning: - // i.e. a slowdown in fall speed in order to avoid that on landing - // the chassis hits the ground (causing a severe slowdown of the - // kart). The cushioning is done if the fall distance (v_down * dt) - // in this physics step is large enough that the kart would hit the - // ground, i.e. the maximum suspension length plus fall distance - // is larger than the distance to the object that was just detected. - - // To allow for wall driving, properly project the velocity - // onto the normal - btVector3 v = m_chassisBody->getLinearVelocity(); - btVector3 down(0, 1, 0); - btVector3 v_down = (v * down) * down; - - if(depth < max_susp_len + v_down.length() *1./60.f) - { - // Apply an impulse that will roughly half the speed. Since - // there are 4 wheels, a single wheel should apply 1/4 of - // the necessary impulse: - btVector3 impulse = (-0.25f*0.5f/m_chassisBody->getInvMass()) - * v_down; - m_chassisBody->applyCentralImpulse(impulse); - } - } depth = btScalar(-1.0); //put wheel info as in rest position wheel.m_raycastInfo.m_suspensionLength = wheel.getSuspensionRestLength(); @@ -422,6 +390,32 @@ void btKart::updateVehicle( btScalar step ) m_num_wheels_on_ground++; } + bool needs_cushioning_test = false; + for(int i=0; igetLinearVelocity(); + btVector3 down(0, 1, 0); + btVector3 v_down = (v * down) * down; + btScalar max_compensate_speed = m_wheelInfo[0].m_maxSuspensionForce * m_chassisBody->getInvMass() * step *4; + if(-v_down.getY() > max_compensate_speed) + { + btVector3 impulse = down * (-v_down.getY() - max_compensate_speed) / m_chassisBody->getInvMass(); + Log::verbose("physics", "Cushioning %f", impulse.getY()); + m_chassisBody->applyCentralImpulse(impulse); + } + } + for(int i=0; iapplyTorqueImpulse(axis * m_kart->getKartProperties()->getSmoothFlyingImpulse()); } - + // Work around: make sure that either both wheels on one axis // are on ground, or none of them. This avoids the problem of // the kart suddenly getting additional angular velocity because From e55959555e7e3003e9e7d6e560cce28b86aeb26f Mon Sep 17 00:00:00 2001 From: hiker Date: Tue, 30 Sep 2014 23:59:17 +1000 Subject: [PATCH 04/42] Added more debug output. --- src/physics/btKart.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/physics/btKart.cpp b/src/physics/btKart.cpp index 576477b75..2b807b322 100644 --- a/src/physics/btKart.cpp +++ b/src/physics/btKart.cpp @@ -409,8 +409,10 @@ void btKart::updateVehicle( btScalar step ) if(-v_down.getY() > max_compensate_speed) { btVector3 impulse = down * (-v_down.getY() - max_compensate_speed) / m_chassisBody->getInvMass(); - Log::verbose("physics", "Cushioning %f", impulse.getY()); + float v_old = m_chassisBody->getLinearVelocity().getY(); m_chassisBody->applyCentralImpulse(impulse); + Log::verbose("physics", "Cushioning %f from %f m/s to %f m/s", impulse.getY(), + v_old, m_chassisBody->getLinearVelocity().getY()); } } for(int i=0; i Date: Tue, 30 Sep 2014 21:30:37 +0200 Subject: [PATCH 05/42] Fix AZDO with normal/detail --- src/graphics/stkmeshscenenode.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/graphics/stkmeshscenenode.cpp b/src/graphics/stkmeshscenenode.cpp index 0786bbc13..1ede864ec 100644 --- a/src/graphics/stkmeshscenenode.cpp +++ b/src/graphics/stkmeshscenenode.cpp @@ -179,7 +179,7 @@ void STKMeshSceneNode::updateGL() if (!rnd->isTransparent()) { Material* material = material_manager->getMaterialFor(mb->getMaterial().getTexture(0), mb); - Material::ShaderType MatType = material->getShaderType();// MaterialTypeToMeshMaterial(type, mb->getVertexType(), material); + Material::ShaderType MatType = MaterialTypeToMeshMaterial(type, mb->getVertexType(), material); if (!immediate_draw) InitTextures(mesh, MatType); } From 838e1b63da9b39b466c8a73dbeb6b720968b1116 Mon Sep 17 00:00:00 2001 From: Vincent Lejeune Date: Tue, 30 Sep 2014 21:39:56 +0200 Subject: [PATCH 06/42] Split cascade gpu timer --- src/graphics/irr_driver.hpp | 25 ------------------------- src/graphics/render_geometry.cpp | 5 ++--- src/utils/profiler.cpp | 5 ++++- src/utils/profiler.hpp | 28 ++++++++++++++++++++++++++++ 4 files changed, 34 insertions(+), 29 deletions(-) diff --git a/src/graphics/irr_driver.hpp b/src/graphics/irr_driver.hpp index 2b4f121fd..1c90a6413 100644 --- a/src/graphics/irr_driver.hpp +++ b/src/graphics/irr_driver.hpp @@ -108,31 +108,6 @@ enum TypeFBO FBO_COUNT }; -enum QueryPerf -{ - Q_SOLID_PASS1, - Q_SHADOWS, - Q_RSM, - Q_RH, - Q_GI, - Q_ENVMAP, - Q_SUN, - Q_POINTLIGHTS, - Q_SSAO, - Q_SOLID_PASS2, - Q_TRANSPARENT, - Q_PARTICLES, - Q_DISPLACEMENT, - Q_DOF, - Q_GODRAYS, - Q_BLOOM, - Q_TONEMAP, - Q_MOTIONBLUR, - Q_MLAA, - Q_GUI, - Q_LAST -}; - enum TypeRTT { RTT_TMP1 = 0, diff --git a/src/graphics/render_geometry.cpp b/src/graphics/render_geometry.cpp index fca20e664..b0421af7c 100644 --- a/src/graphics/render_geometry.cpp +++ b/src/graphics/render_geometry.cpp @@ -11,6 +11,7 @@ #include "utils/profiler.hpp" #include "utils/tuple.hpp" #include "stkscenemanager.hpp" +#include "utils/profiler.hpp" #include @@ -860,8 +861,6 @@ static void multidrawShadow(unsigned i, Args ...args) void IrrDriver::renderShadows() { - ScopedGPUTimer Timer(getGPUTimer(Q_SHADOWS)); - glDepthFunc(GL_LEQUAL); glDepthMask(GL_TRUE); glEnable(GL_DEPTH_TEST); @@ -875,7 +874,7 @@ void IrrDriver::renderShadows() for (unsigned cascade = 0; cascade < 4; cascade++) { - + ScopedGPUTimer Timer(getGPUTimer(Q_SHADOWS_CASCADE0 + cascade)); std::vector noTexUnits; renderShadow(noTexUnits, cascade, ListMatDefault::getInstance()->Shadows[cascade]); diff --git a/src/utils/profiler.cpp b/src/utils/profiler.cpp index 6df0432dd..48f91e2c7 100644 --- a/src/utils/profiler.cpp +++ b/src/utils/profiler.cpp @@ -31,8 +31,11 @@ static const char* GPU_Phase[Q_LAST] = { + "Shadows Cascade 0", + "Shadows Cascade 1", + "Shadows Cascade 2", + "Shadows Cascade 3", "Solid Pass 1", - "Shadows", "RSM", "RH", "GI", diff --git a/src/utils/profiler.hpp b/src/utils/profiler.hpp index e295f519a..66fd07489 100644 --- a/src/utils/profiler.hpp +++ b/src/utils/profiler.hpp @@ -28,6 +28,34 @@ #include +enum QueryPerf +{ + Q_SHADOWS_CASCADE0, + Q_SHADOWS_CASCADE1, + Q_SHADOWS_CASCADE2, + Q_SHADOWS_CASCADE3, + Q_SOLID_PASS1, + Q_RSM, + Q_RH, + Q_GI, + Q_ENVMAP, + Q_SUN, + Q_POINTLIGHTS, + Q_SSAO, + Q_SOLID_PASS2, + Q_TRANSPARENT, + Q_PARTICLES, + Q_DISPLACEMENT, + Q_DOF, + Q_GODRAYS, + Q_BLOOM, + Q_TONEMAP, + Q_MOTIONBLUR, + Q_MLAA, + Q_GUI, + Q_LAST +}; + class Profiler; extern Profiler profiler; From 83053e0ee42b1b84a9934ff34a6353c81d3fe6b4 Mon Sep 17 00:00:00 2001 From: Vincent Lejeune Date: Tue, 30 Sep 2014 22:00:55 +0200 Subject: [PATCH 07/42] Try to cull object whose aera is below 1 px --- src/graphics/stkscenemanager.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/graphics/stkscenemanager.cpp b/src/graphics/stkscenemanager.cpp index 1f6784757..fa2f5bf81 100644 --- a/src/graphics/stkscenemanager.cpp +++ b/src/graphics/stkscenemanager.cpp @@ -167,7 +167,7 @@ bool isBoxInFrontOfPlane(const core::plane3df &plane, const core::vector3df edge } static -bool isCulledPrecise(const scene::ICameraSceneNode *cam, const scene::ISceneNode *node) +bool isCulledPrecise(const scene::ICameraSceneNode *cam, const scene::ISceneNode *node, bool aera_check) { if (!node->getAutomaticCulling()) return false; @@ -183,6 +183,10 @@ bool isCulledPrecise(const scene::ICameraSceneNode *cam, const scene::ISceneNode for (s32 i = 0; i < scene::SViewFrustum::VF_PLANE_COUNT; ++i) if (isBoxInFrontOfPlane(frust.planes[i], edges)) return true; + + float ratio = cam->getProjectionMatrix().pointer()[0] * cam->getProjectionMatrix().pointer()[5]; + if (aera_check && node->getBoundingBox().getArea() * ratio < 1.) + return true; return false; } @@ -435,14 +439,14 @@ parseSceneManager(core::list List, std::vector(*I)) { - if (!isCulledPrecise(cam, *I) && node->update()) + if (!isCulledPrecise(cam, *I, false) && node->update()) ParticlesList::getInstance()->push_back(node); continue; } if (STKBillboard *node = dynamic_cast(*I)) { - if (!isCulledPrecise(cam, *I)) + if (!isCulledPrecise(cam, *I, false)) BillBoardList::getInstance()->push_back(node); continue; } @@ -502,12 +506,12 @@ void IrrDriver::PrepareDrawCalls(scene::ICameraSceneNode *camnode) for (int i = 0; i < (int)DeferredUpdate.size(); i++) { scene::ISceneNode *node = dynamic_cast(DeferredUpdate[i]); - DeferredUpdate[i]->setCulledForPlayerCam(isCulledPrecise(camnode, node)); - DeferredUpdate[i]->setCulledForRSMCam(isCulledPrecise(m_suncam, node)); - DeferredUpdate[i]->setCulledForShadowCam(0, isCulledPrecise(m_shadow_camnodes[0], node)); - DeferredUpdate[i]->setCulledForShadowCam(1, isCulledPrecise(m_shadow_camnodes[1], node)); - DeferredUpdate[i]->setCulledForShadowCam(2, isCulledPrecise(m_shadow_camnodes[2], node)); - DeferredUpdate[i]->setCulledForShadowCam(3, isCulledPrecise(m_shadow_camnodes[3], node)); + DeferredUpdate[i]->setCulledForPlayerCam(isCulledPrecise(camnode, node, false)); + DeferredUpdate[i]->setCulledForRSMCam(isCulledPrecise(m_suncam, node, true)); + DeferredUpdate[i]->setCulledForShadowCam(0, isCulledPrecise(m_shadow_camnodes[0], node, true)); + DeferredUpdate[i]->setCulledForShadowCam(1, isCulledPrecise(m_shadow_camnodes[1], node, true)); + DeferredUpdate[i]->setCulledForShadowCam(2, isCulledPrecise(m_shadow_camnodes[2], node, true)); + DeferredUpdate[i]->setCulledForShadowCam(3, isCulledPrecise(m_shadow_camnodes[3], node, true)); } // Add a 1 s timeout From 2236e8dd1ce8caf69bed64f33ea31fd9478a8596 Mon Sep 17 00:00:00 2001 From: vlj Date: Wed, 1 Oct 2014 01:19:49 +0200 Subject: [PATCH 08/42] Fix extra respawning particles --- data/shaders/pointemitter.vert | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/shaders/pointemitter.vert b/data/shaders/pointemitter.vert index 3203d965b..68fb15c8b 100644 --- a/data/shaders/pointemitter.vert +++ b/data/shaders/pointemitter.vert @@ -35,7 +35,7 @@ void main(void) float updated_lifetime = lifetime + (float(dt)/lifetime_initial); if (updated_lifetime > 1.) { - if (gl_VertexID <= level) + if (gl_VertexID < level) { float dt_from_last_frame = fract(updated_lifetime) * lifetime_initial; vec4 updated_initialposition = sourcematrix * vec4(particle_position_initial, 1.0); From f4f914e2890f99d5400d6187fba6e79c7358fc67 Mon Sep 17 00:00:00 2001 From: hiker Date: Wed, 1 Oct 2014 09:31:42 +1000 Subject: [PATCH 09/42] Don't send a second, empty GL_EXTENSION string to our stats server. --- src/graphics/glwrap.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/graphics/glwrap.cpp b/src/graphics/glwrap.cpp index 3f68a50cf..86a84c5a5 100644 --- a/src/graphics/glwrap.cpp +++ b/src/graphics/glwrap.cpp @@ -820,7 +820,6 @@ void getGLLimits(HardwareStats::Json *json) STRING(VERSION); STRING(VENDOR); STRING(RENDERER); - STRING(EXTENSIONS); INTEGER(SUBPIXEL_BITS); INTEGER(MAX_TEXTURE_SIZE); INTEGER(MAX_CUBE_MAP_TEXTURE_SIZE); From 7387a51381ea7df71ce7e15a26ebdeb8e3646916 Mon Sep 17 00:00:00 2001 From: Marianne Gagnon Date: Tue, 30 Sep 2014 19:33:25 -0400 Subject: [PATCH 10/42] Disable features of irrlicht's contextual menu that we don't need and cause floods of warnings --- .../source/Irrlicht/CGUIContextMenu.cpp | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/lib/irrlicht/source/Irrlicht/CGUIContextMenu.cpp b/lib/irrlicht/source/Irrlicht/CGUIContextMenu.cpp index 67631e786..3aae5e42c 100644 --- a/lib/irrlicht/source/Irrlicht/CGUIContextMenu.cpp +++ b/lib/irrlicht/source/Irrlicht/CGUIContextMenu.cpp @@ -584,30 +584,30 @@ void CGUIContextMenu::draw() skin->getColor(c), false, true, clip); // draw submenu symbol - if (Items[i].SubMenu && sprites) - { - core::rect r = rect; - r.UpperLeftCorner.X = r.LowerRightCorner.X - 15; - - sprites->draw2DSprite(skin->getIcon(EGDI_CURSOR_RIGHT), - r.getCenter(), clip, skin->getColor(c), - (i == HighLighted) ? ChangeTime : 0, - (i == HighLighted) ? os::Timer::getTime() : 0, - (i == HighLighted), true); - } + //if (Items[i].SubMenu && sprites) + //{ + // core::rect r = rect; + // r.UpperLeftCorner.X = r.LowerRightCorner.X - 15; + // + // sprites->draw2DSprite(skin->getIcon(EGDI_CURSOR_RIGHT), + // r.getCenter(), clip, skin->getColor(c), + // (i == HighLighted) ? ChangeTime : 0, + // (i == HighLighted) ? os::Timer::getTime() : 0, + // (i == HighLighted), true); + //} // draw checked symbol - if (Items[i].Checked && sprites) - { - core::rect r = rect; - r.LowerRightCorner.X = r.UpperLeftCorner.X - 15; - r.UpperLeftCorner.X = r.LowerRightCorner.X + 15; - sprites->draw2DSprite(skin->getIcon(EGDI_CHECK_BOX_CHECKED), - r.getCenter(), clip, skin->getColor(c), - (i == HighLighted) ? ChangeTime : 0, - (i == HighLighted) ? os::Timer::getTime() : 0, - (i == HighLighted), true); - } + //if (Items[i].Checked && sprites) + //{ + // core::rect r = rect; + // r.LowerRightCorner.X = r.UpperLeftCorner.X - 15; + // r.UpperLeftCorner.X = r.LowerRightCorner.X + 15; + // sprites->draw2DSprite(skin->getIcon(EGDI_CHECK_BOX_CHECKED), + // r.getCenter(), clip, skin->getColor(c), + // (i == HighLighted) ? ChangeTime : 0, + // (i == HighLighted) ? os::Timer::getTime() : 0, + // (i == HighLighted), true); + //} } } From 783494b4a820feb83b4bc802d79ac26bfcc14557 Mon Sep 17 00:00:00 2001 From: vlj Date: Wed, 1 Oct 2014 03:03:07 +0200 Subject: [PATCH 11/42] Fix particles being killed too soon --- src/graphics/gpuparticles.cpp | 19 +------------------ src/graphics/gpuparticles.hpp | 2 -- src/graphics/stkscenemanager.cpp | 2 +- 3 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/graphics/gpuparticles.cpp b/src/graphics/gpuparticles.cpp index e51f81736..89ccfdc72 100644 --- a/src/graphics/gpuparticles.cpp +++ b/src/graphics/gpuparticles.cpp @@ -449,21 +449,4 @@ void ParticleSystemProxy::render() { m_first_execution = false; simulate(); draw(); -} - -bool ParticleSystemProxy::update() -{ - doParticleSystem(os::Timer::getTime()); - return (IsVisible && (Particles.size() != 0)); -} - -void ParticleSystemProxy::OnRegisterSceneNode() -{ - doParticleSystem(os::Timer::getTime()); - - if (IsVisible && (Particles.size() != 0)) - { - SceneManager->registerNodeForRendering(this, scene::ESNRP_TRANSPARENT_EFFECT); - ISceneNode::OnRegisterSceneNode(); - } -} +} \ No newline at end of file diff --git a/src/graphics/gpuparticles.hpp b/src/graphics/gpuparticles.hpp index 138734bb9..22844044f 100644 --- a/src/graphics/gpuparticles.hpp +++ b/src/graphics/gpuparticles.hpp @@ -70,7 +70,6 @@ public: virtual void setEmitter(scene::IParticleEmitter* emitter); virtual void render(); - virtual void OnRegisterSceneNode(); void setAlphaAdditive(bool val) { m_alpha_additive = val; } void setIncreaseFactor(float val) { size_increase_factor = val; } void setColorFrom(float r, float g, float b) { m_color_from[0] = r; m_color_from[1] = g; m_color_from[2] = b; } @@ -79,7 +78,6 @@ public: const float* getColorTo() const { return m_color_to; } void setHeightmap(const std::vector >&, float, float, float, float); void setFlip(); - bool update(); }; #endif // GPUPARTICLES_H diff --git a/src/graphics/stkscenemanager.cpp b/src/graphics/stkscenemanager.cpp index fa2f5bf81..a5326473f 100644 --- a/src/graphics/stkscenemanager.cpp +++ b/src/graphics/stkscenemanager.cpp @@ -439,7 +439,7 @@ parseSceneManager(core::list List, std::vector(*I)) { - if (!isCulledPrecise(cam, *I, false) && node->update()) + if (!isCulledPrecise(cam, *I, false)) ParticlesList::getInstance()->push_back(node); continue; } From 49176dd3484f8e594ac65e7e6796c2c610dda043 Mon Sep 17 00:00:00 2001 From: hiker Date: Wed, 1 Oct 2014 12:28:10 +1000 Subject: [PATCH 12/42] Removed debug output, added documentation. --- src/physics/btKart.cpp | 55 ++++++++++++++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 13 deletions(-) diff --git a/src/physics/btKart.cpp b/src/physics/btKart.cpp index 2b807b322..3a992c689 100644 --- a/src/physics/btKart.cpp +++ b/src/physics/btKart.cpp @@ -390,6 +390,9 @@ void btKart::updateVehicle( btScalar step ) m_num_wheels_on_ground++; } + // Test if the kart is falling so fast + // that the chassis might hit the track + // ------------------------------------ bool needs_cushioning_test = false; for(int i=0; igetLinearVelocity(); btVector3 down(0, 1, 0); btVector3 v_down = (v * down) * down; - btScalar max_compensate_speed = m_wheelInfo[0].m_maxSuspensionForce * m_chassisBody->getInvMass() * step *4; + // Estimate what kind of downward speed can be compensated by the + // suspension. Atm the parameters are set that the suspension is + // actually capped at max suspension force, so the maximum + // speed that can be caught by the suspension without the chassis + // hitting the ground can be based on that. Note that there are + // 4 suspensions, all adding together. + btScalar max_compensate_speed = m_wheelInfo[0].m_maxSuspensionForce + * m_chassisBody->getInvMass() + * step * 4; + // If the downward speed is too fast to be caught by the suspension, + // slow down the falling speed by applying an appropriately impulse: if(-v_down.getY() > max_compensate_speed) { - btVector3 impulse = down * (-v_down.getY() - max_compensate_speed) / m_chassisBody->getInvMass(); - float v_old = m_chassisBody->getLinearVelocity().getY(); + btVector3 impulse = down * (-v_down.getY() - max_compensate_speed) + / m_chassisBody->getInvMass(); + //float v_old = m_chassisBody->getLinearVelocity().getY(); m_chassisBody->applyCentralImpulse(impulse); - Log::verbose("physics", "Cushioning %f from %f m/s to %f m/s", impulse.getY(), - v_old, m_chassisBody->getLinearVelocity().getY()); + //Log::verbose("physics", "Cushioning %f from %f m/s to %f m/s", impulse.getY(), + // v_old, m_chassisBody->getLinearVelocity().getY()); } } for(int i=0; igetSpeed() - * m_kart->getKartProperties()->getDownwardImpulseFactor(); - btVector3 downwards_impulse = m_chassisBody->getWorldTransform().getBasis() - * btVector3(0, f, 0); - m_chassisBody->applyCentralImpulse(downwards_impulse); + // If configured, add a force to keep karts on the track + // ----------------------------------------------------- + float dif = m_kart->getKartProperties()->getDownwardImpulseFactor(); + if(dif!=0) + { + float f = -m_kart->getSpeed() * dif; + btVector3 downwards_impulse = m_chassisBody->getWorldTransform().getBasis() + * btVector3(0, f, 0); + m_chassisBody->applyCentralImpulse(downwards_impulse); + } + // Apply additional impulse set by supertuxkart + // -------------------------------------------- if(m_time_additional_impulse>0) { float dt = step > m_time_additional_impulse @@ -528,6 +555,8 @@ void btKart::updateVehicle( btScalar step ) m_time_additional_impulse -= dt; } + // Apply additional rotation set by supertuxkart + // --------------------------------------------- if(m_time_additional_rotation>0) { btTransform &t = m_chassisBody->getWorldTransform(); From 7b308e99768b23705cb7a24bbe60543de5285c2f Mon Sep 17 00:00:00 2001 From: deve Date: Wed, 1 Oct 2014 07:08:19 +0200 Subject: [PATCH 13/42] Partially revert marcoll pull requeust since it causes crashes and memory leaks. --- src/guiengine/widgets/icon_button_widget.cpp | 42 -------------------- src/guiengine/widgets/icon_button_widget.hpp | 7 +--- 2 files changed, 2 insertions(+), 47 deletions(-) diff --git a/src/guiengine/widgets/icon_button_widget.cpp b/src/guiengine/widgets/icon_button_widget.cpp index fa4c4f4f0..4255895a0 100644 --- a/src/guiengine/widgets/icon_button_widget.cpp +++ b/src/guiengine/widgets/icon_button_widget.cpp @@ -43,7 +43,6 @@ IconButtonWidget::IconButtonWidget(ScaleMode scale_mode, const bool tab_stop, m_font = NULL; m_texture = NULL; m_highlight_texture = NULL; - m_deactivated_texture = NULL; m_custom_aspect_ratio = 1.0f; m_texture_w = 0; @@ -56,12 +55,6 @@ IconButtonWidget::IconButtonWidget(ScaleMode scale_mode, const bool tab_stop, m_icon_path_type = pathType; } // ----------------------------------------------------------------------------- -IconButtonWidget::~IconButtonWidget() -{ - if (m_deactivated_texture != NULL) - m_deactivated_texture->drop(); -} -// ----------------------------------------------------------------------------- void IconButtonWidget::add() { // ---- Icon @@ -278,57 +271,22 @@ void IconButtonWidget::unfocused(const int playerID, Widget* new_focus) } } -// ----------------------------------------------------------------------------- -video::ITexture* IconButtonWidget::getDeactivatedTexture(video::ITexture* texture) -{ - SColor c; - u32 g; - - video::IVideoDriver* driver = irr_driver->getVideoDriver(); - video::IImage* image = driver->createImageFromData (texture->getColorFormat(), - texture->getSize(), texture->lock(), false); - texture->unlock(); - - //Turn the image into grayscale - for (u32 x = 0; x < image->getDimension().Width; x++) - { - for (u32 y = 0; y < image->getDimension().Height; y++) - { - c = image->getPixel(x, y); - g = ((c.getRed() + c.getGreen() + c.getBlue()) / 3); - c.set(std::max (0, (int)c.getAlpha() - 120), g, g, g); - image->setPixel(x, y, c); - } - } - - texture = driver->addTexture(texture->getName().getPath() + "_disabled", image); - texture->grab(); - - return texture; -} - // ----------------------------------------------------------------------------- void IconButtonWidget::setTexture(video::ITexture* texture) { m_texture = texture; if (texture == NULL) { - if (m_deactivated_texture != NULL) - m_deactivated_texture->drop(); - - m_deactivated_texture = NULL; m_texture_w = 0; m_texture_h = 0; } else { - m_deactivated_texture = getDeactivatedTexture(texture); m_texture_w = texture->getSize().Width; m_texture_h = texture->getSize().Height; } } - // ----------------------------------------------------------------------------- void IconButtonWidget::setLabelFont() { diff --git a/src/guiengine/widgets/icon_button_widget.hpp b/src/guiengine/widgets/icon_button_widget.hpp index 03fb654cd..e4126ab91 100644 --- a/src/guiengine/widgets/icon_button_widget.hpp +++ b/src/guiengine/widgets/icon_button_widget.hpp @@ -44,10 +44,8 @@ namespace GUIEngine private: irr::video::ITexture* m_texture; irr::video::ITexture* m_highlight_texture; - irr::video::ITexture* m_deactivated_texture; int m_texture_w, m_texture_h; - video::ITexture* getDeactivatedTexture(video::ITexture* texture); void setLabelFont(); public: @@ -90,7 +88,7 @@ namespace GUIEngine IconButtonWidget(ScaleMode scale_mode=SCALE_MODE_KEEP_TEXTURE_ASPECT_RATIO, const bool tab_stop=true, const bool focusable=true, IconPathType pathType=ICON_PATH_TYPE_RELATIVE); - virtual ~IconButtonWidget(); + virtual ~IconButtonWidget() {}; /** \brief Implement callback from base class Widget */ virtual void add(); @@ -160,8 +158,7 @@ namespace GUIEngine virtual void unfocused(const int playerID, Widget* new_focus); // -------------------------------------------------------------------- /** Returns the texture of this button. */ - const video::ITexture* getTexture() const { - return (Widget::isActivated() ? m_texture : m_deactivated_texture); } + const video::ITexture* getTexture() const { return m_texture; } }; } From 2ef8598ddd1ab5593b8b3b9e0ee378cfe0f6bc2c Mon Sep 17 00:00:00 2001 From: Shantanu Singh Date: Wed, 1 Oct 2014 18:42:51 +0530 Subject: [PATCH 14/42] corrected a typo which was earlier written as tpye instead of type --- src/achievements/achievement_info.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/achievements/achievement_info.cpp b/src/achievements/achievement_info.cpp index 56a0c9193..8763ba8e6 100644 --- a/src/achievements/achievement_info.cpp +++ b/src/achievements/achievement_info.cpp @@ -113,7 +113,7 @@ irr::core::stringw AchievementInfo::toString() const count = m_goal_values.begin()->second; break; default: - Log::fatal("AchievementInfo", "Missing toString for tpye %d.", + Log::fatal("AchievementInfo", "Missing toString for type %d.", m_check_type); } return StringUtils::toWString(count); From a643905053fc666d02caea025380253263466229 Mon Sep 17 00:00:00 2001 From: hiker Date: Wed, 1 Oct 2014 23:41:13 +1000 Subject: [PATCH 15/42] Minor fix for the (currently unused) downward impulse: only apply it when all four wheels are touching the ground (otherwise the jump distance is significantly shortened); also fix handling of negative speed (plus some changes to commented out debug output). --- src/physics/btKart.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/physics/btKart.cpp b/src/physics/btKart.cpp index 3a992c689..c1f3bf3f5 100644 --- a/src/physics/btKart.cpp +++ b/src/physics/btKart.cpp @@ -424,9 +424,12 @@ void btKart::updateVehicle( btScalar step ) btVector3 impulse = down * (-v_down.getY() - max_compensate_speed) / m_chassisBody->getInvMass(); //float v_old = m_chassisBody->getLinearVelocity().getY(); + //float x = m_wheelInfo[0].m_raycastInfo.m_isInContact ? m_wheelInfo[0].m_raycastInfo.m_contactPointWS.getY() : -100; m_chassisBody->applyCentralImpulse(impulse); - //Log::verbose("physics", "Cushioning %f from %f m/s to %f m/s", impulse.getY(), - // v_old, m_chassisBody->getLinearVelocity().getY()); + //Log::verbose("physics", "Cushioning %f from %f m/s to %f m/s wheel %f kart %f", impulse.getY(), + // v_old, m_chassisBody->getLinearVelocity().getY(), x, + // m_chassisBody->getWorldTransform().getOrigin().getY() + // ); } } for(int i=0; igetKartProperties()->getDownwardImpulseFactor(); - if(dif!=0) + if(dif!=0 && m_num_wheels_on_ground==4) { - float f = -m_kart->getSpeed() * dif; + float f = -fabsf(m_kart->getSpeed()) * dif; btVector3 downwards_impulse = m_chassisBody->getWorldTransform().getBasis() * btVector3(0, f, 0); m_chassisBody->applyCentralImpulse(downwards_impulse); From de9a1f51a755fa5d93bb0445c7c6003a9b4bd28b Mon Sep 17 00:00:00 2001 From: hiker Date: Thu, 2 Oct 2014 07:59:24 +1000 Subject: [PATCH 16/42] Removed empty 'online overview' page, show the achievements page instead. --- data/gui/online/profile_achievements.stkgui | 3 +- data/gui/online/profile_friends.stkgui | 3 +- data/gui/online/profile_settings.stkgui | 3 +- sources.cmake | 2 +- .../dialogs/user_info_dialog.cpp | 4 +- src/states_screens/main_menu_screen.cpp | 8 +-- src/states_screens/online_profile_base.cpp | 9 +-- src/states_screens/online_profile_base.hpp | 3 +- .../online_profile_overview.cpp | 67 ------------------- .../online_profile_overview.hpp | 55 --------------- src/states_screens/online_screen.cpp | 4 +- 11 files changed, 14 insertions(+), 147 deletions(-) delete mode 100644 src/states_screens/online_profile_overview.cpp delete mode 100644 src/states_screens/online_profile_overview.hpp diff --git a/data/gui/online/profile_achievements.stkgui b/data/gui/online/profile_achievements.stkgui index b8d13653d..0d52222be 100644 --- a/data/gui/online/profile_achievements.stkgui +++ b/data/gui/online/profile_achievements.stkgui @@ -9,9 +9,8 @@ - - + diff --git a/data/gui/online/profile_friends.stkgui b/data/gui/online/profile_friends.stkgui index c2498bfd9..47f2ed31c 100644 --- a/data/gui/online/profile_friends.stkgui +++ b/data/gui/online/profile_friends.stkgui @@ -9,9 +9,8 @@ - - + diff --git a/data/gui/online/profile_settings.stkgui b/data/gui/online/profile_settings.stkgui index 78599ff0b..7b15fc064 100644 --- a/data/gui/online/profile_settings.stkgui +++ b/data/gui/online/profile_settings.stkgui @@ -9,9 +9,8 @@ - - + diff --git a/sources.cmake b/sources.cmake index ddc029d4f..f484b15d5 100644 --- a/sources.cmake +++ b/sources.cmake @@ -1,5 +1,5 @@ # Modify this file to change the last-modified date when you add/remove a file. -# This will then trigger a new cmake run automatically. +# This will then trigger a new cmake run automatically. file(GLOB_RECURSE STK_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.hpp") file(GLOB_RECURSE STK_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.cpp") file(GLOB_RECURSE STK_SHADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "data/shaders/*") diff --git a/src/states_screens/dialogs/user_info_dialog.cpp b/src/states_screens/dialogs/user_info_dialog.cpp index 546d7d091..8c457f518 100644 --- a/src/states_screens/dialogs/user_info_dialog.cpp +++ b/src/states_screens/dialogs/user_info_dialog.cpp @@ -21,8 +21,8 @@ #include "guiengine/dialog_queue.hpp" #include "guiengine/engine.hpp" #include "online/online_profile.hpp" +#include "states_screens/online_profile_achievements.hpp" #include "states_screens/online_profile_friends.hpp" -#include "states_screens/online_profile_overview.hpp" #include "states_screens/state_manager.hpp" #include "utils/translation.hpp" @@ -481,7 +481,7 @@ void UserInfoDialog::onUpdate(float dt) { ModalDialog::dismiss(); if (m_enter_profile) - StateManager::get()->replaceTopMostScreen(OnlineProfileOverview::getInstance()); + StateManager::get()->replaceTopMostScreen(OnlineProfileAchievements::getInstance()); return; } } // onUpdate diff --git a/src/states_screens/main_menu_screen.cpp b/src/states_screens/main_menu_screen.cpp index 755cb1393..68db41b68 100644 --- a/src/states_screens/main_menu_screen.cpp +++ b/src/states_screens/main_menu_screen.cpp @@ -42,7 +42,7 @@ #include "states_screens/grand_prix_editor_screen.hpp" #include "states_screens/help_screen_1.hpp" #include "states_screens/offline_kart_selection.hpp" -#include "states_screens/online_profile_overview.hpp" +#include "states_screens/online_profile_achievements.hpp" #include "states_screens/online_screen.hpp" #include "states_screens/options_screen_video.hpp" #include "states_screens/state_manager.hpp" @@ -442,10 +442,10 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name, } if (PlayerManager::getCurrentOnlineId()) { - // For 0.8.2 disable the server menu, instead go to online profile + // For 0.8.2 disable the server menu, instead go to online profile //OnlineScreen::getInstance()->push(); - ProfileManager::get()->setVisiting(PlayerManager::getCurrentOnlineId()); - OnlineProfileOverview::getInstance()->push(); + ProfileManager::get()->setVisiting(PlayerManager::getCurrentOnlineId()); + OnlineProfileAchievements::getInstance()->push(); } else diff --git a/src/states_screens/online_profile_base.cpp b/src/states_screens/online_profile_base.cpp index c9f6abde7..c7b938a5c 100644 --- a/src/states_screens/online_profile_base.cpp +++ b/src/states_screens/online_profile_base.cpp @@ -24,7 +24,6 @@ #include "online/online_profile.hpp" #include "states_screens/state_manager.hpp" #include "utils/translation.hpp" -#include "states_screens/online_profile_overview.hpp" #include "states_screens/online_profile_friends.hpp" #include "states_screens/online_profile_achievements.hpp" #include "states_screens/online_profile_settings.hpp" @@ -52,9 +51,6 @@ void OnlineProfileBase::loadedFromFile() m_header = getWidget("title"); assert(m_header != NULL); - m_overview_tab = - (IconButtonWidget *)m_profile_tabs->findWidgetNamed("tab_overview"); - assert(m_overview_tab != NULL); m_friends_tab = (IconButtonWidget *) m_profile_tabs->findWidgetNamed("tab_friends"); assert(m_friends_tab != NULL); @@ -91,7 +87,6 @@ void OnlineProfileBase::init() { Screen::init(); - m_overview_tab->setTooltip( _("Overview") ); m_friends_tab->setTooltip( _("Friends") ); m_achievements_tab->setTooltip( _("Achievements") ); m_settings_tab->setTooltip( _("Account Settings") ); @@ -119,9 +114,7 @@ void OnlineProfileBase::eventCallback(Widget* widget, const std::string& name, std::string selection = ((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER); StateManager *sm = StateManager::get(); - if (selection == m_overview_tab->m_properties[PROP_ID]) - sm->replaceTopMostScreen(OnlineProfileOverview::getInstance()); - else if (selection == m_friends_tab->m_properties[PROP_ID]) + if (selection == m_friends_tab->m_properties[PROP_ID]) sm->replaceTopMostScreen(OnlineProfileFriends::getInstance()); else if (selection == m_achievements_tab->m_properties[PROP_ID]) sm->replaceTopMostScreen(OnlineProfileAchievements::getInstance()); diff --git a/src/states_screens/online_profile_base.hpp b/src/states_screens/online_profile_base.hpp index 94bcac23a..956b43d9b 100644 --- a/src/states_screens/online_profile_base.hpp +++ b/src/states_screens/online_profile_base.hpp @@ -30,7 +30,7 @@ namespace GUIEngine { class Widget; } /** Online profile base screen. Used for displaying friends, achievements, - * overview, and settings. It handles the tabs which are common to each + * and settings. It handles the tabs which are common to each * of those screens, and keeps track of the profile to display. * \ingroup states_screens */ @@ -42,7 +42,6 @@ protected: /** Pointer to the various widgets on the screen. */ GUIEngine::LabelWidget * m_header; GUIEngine::RibbonWidget* m_profile_tabs; - GUIEngine::IconButtonWidget * m_overview_tab; GUIEngine::IconButtonWidget * m_friends_tab; GUIEngine::IconButtonWidget * m_achievements_tab; GUIEngine::IconButtonWidget * m_settings_tab; diff --git a/src/states_screens/online_profile_overview.cpp b/src/states_screens/online_profile_overview.cpp deleted file mode 100644 index 128437f47..000000000 --- a/src/states_screens/online_profile_overview.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// SuperTuxKart - a fun racing game with go-kart -// Copyright (C) 2010 Glenn De Jonghe -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 3 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#include "states_screens/online_profile_overview.hpp" - -#include "guiengine/engine.hpp" -#include "guiengine/scalable_font.hpp" -#include "guiengine/screen.hpp" -#include "guiengine/widget.hpp" -#include "states_screens/state_manager.hpp" -#include "utils/translation.hpp" - -#include - -#include -#include - -using namespace GUIEngine; -using namespace irr::core; -using namespace irr::gui; -using namespace Online; - -DEFINE_SCREEN_SINGLETON( OnlineProfileOverview ); - -// ----------------------------------------------------------------------------- - -OnlineProfileOverview::OnlineProfileOverview() : OnlineProfileBase("online/profile_overview.stkgui") -{ -} // OnlineProfileOverview - -// ----------------------------------------------------------------------------- - -void OnlineProfileOverview::loadedFromFile() -{ - OnlineProfileBase::loadedFromFile(); - -} // loadedFromFile - -// ----------------------------------------------------------------------------- - -void OnlineProfileOverview::init() -{ - OnlineProfileBase::init(); - m_profile_tabs->select( m_overview_tab->m_properties[PROP_ID], PLAYER_ID_GAME_MASTER ); -} // init - -// ----------------------------------------------------------------------------- - -void OnlineProfileOverview::eventCallback(Widget* widget, const std::string& name, const int playerID) -{ - OnlineProfileBase::eventCallback( widget, name, playerID); -} // eventCallback - diff --git a/src/states_screens/online_profile_overview.hpp b/src/states_screens/online_profile_overview.hpp deleted file mode 100644 index 6ad7619e1..000000000 --- a/src/states_screens/online_profile_overview.hpp +++ /dev/null @@ -1,55 +0,0 @@ -// SuperTuxKart - a fun racing game with go-kart -// Copyright (C) 2013 Glenn De Jonghe -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 3 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -#ifndef __HEADER_ONLINE_PROFILE_OVERVIEW_HPP__ -#define __HEADER_ONLINE_PROFILE_OVERVIEW_HPP__ - -#include -#include - -#include "guiengine/screen.hpp" -#include "guiengine/widgets.hpp" -#include "states_screens/online_profile_base.hpp" - -namespace GUIEngine { class Widget; } - - -/** - * \brief Online profiel overview screen - * \ingroup states_screens - */ -class OnlineProfileOverview : public OnlineProfileBase, public GUIEngine::ScreenSingleton -{ -protected: - OnlineProfileOverview(); - -public: - friend class GUIEngine::ScreenSingleton; - - /** \brief implement callback from parent class GUIEngine::Screen */ - virtual void loadedFromFile() OVERRIDE; - - /** \brief implement callback from parent class GUIEngine::Screen */ - virtual void eventCallback(GUIEngine::Widget* widget, const std::string& name, - const int playerID) OVERRIDE; - - /** \brief implement callback from parent class GUIEngine::Screen */ - virtual void init() OVERRIDE; -}; - -#endif diff --git a/src/states_screens/online_screen.cpp b/src/states_screens/online_screen.cpp index fdfd54363..c7bf9275f 100644 --- a/src/states_screens/online_screen.cpp +++ b/src/states_screens/online_screen.cpp @@ -40,7 +40,7 @@ #include "states_screens/networking_lobby.hpp" #include "states_screens/server_selection.hpp" #include "states_screens/create_server_screen.hpp" -#include "states_screens/online_profile_overview.hpp" +#include "states_screens/online_profile_achievements.hpp" #include #include @@ -233,7 +233,7 @@ void OnlineScreen::eventCallback(Widget* widget, const std::string& name, else if (selection == m_profile_widget->m_properties[PROP_ID]) { ProfileManager::get()->setVisiting(PlayerManager::getCurrentOnlineId()); - OnlineProfileOverview::getInstance()->push(); + OnlineProfileAchievements::getInstance()->push(); } else if (selection == m_find_server_widget->m_properties[PROP_ID]) { From 11bf9d15c7a6e96db316e771da7093418c9c23ed Mon Sep 17 00:00:00 2001 From: Marianne Gagnon Date: Wed, 1 Oct 2014 20:23:22 -0400 Subject: [PATCH 17/42] Disable source of OpenGL warnings flood in code we don't use --- lib/irrlicht/source/Irrlicht/CGUIButton.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/irrlicht/source/Irrlicht/CGUIButton.cpp b/lib/irrlicht/source/Irrlicht/CGUIButton.cpp index 21be74646..d4e6d9a91 100644 --- a/lib/irrlicht/source/Irrlicht/CGUIButton.cpp +++ b/lib/irrlicht/source/Irrlicht/CGUIButton.cpp @@ -285,7 +285,7 @@ void CGUIButton::draw() } } - if (SpriteBank) + if (false) //SpriteBank) { // pressed / unpressed animation u32 state = Pressed ? (u32)EGBS_BUTTON_DOWN : (u32)EGBS_BUTTON_UP; From bdb722df458a2d4c0437a98197f24a193ad4fd1e Mon Sep 17 00:00:00 2001 From: Marianne Gagnon Date: Wed, 1 Oct 2014 20:26:39 -0400 Subject: [PATCH 18/42] Fix splatting --- src/graphics/stkanimatedmesh.cpp | 6 +++++- src/graphics/stkmesh.cpp | 8 ++++++-- src/graphics/stkmesh.hpp | 3 ++- src/graphics/stkmeshscenenode.cpp | 10 ++++++++-- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/graphics/stkanimatedmesh.cpp b/src/graphics/stkanimatedmesh.cpp index 02f251cd1..7f168c2db 100644 --- a/src/graphics/stkanimatedmesh.cpp +++ b/src/graphics/stkanimatedmesh.cpp @@ -142,7 +142,11 @@ void STKAnimatedMesh::updateGL() if (!rnd->isTransparent()) { Material* material = material_manager->getMaterialFor(mb->getMaterial().getTexture(0), mb); - Material::ShaderType MatType = MaterialTypeToMeshMaterial(type, mb->getVertexType(), material); + Material* material2 = NULL; + if (mb->getMaterial().getTexture(1) != NULL) + material2 = material_manager->getMaterialFor(mb->getMaterial().getTexture(1), mb); + + Material::ShaderType MatType = MaterialTypeToMeshMaterial(type, mb->getVertexType(), material, material2); InitTextures(mesh, MatType); } diff --git a/src/graphics/stkmesh.cpp b/src/graphics/stkmesh.cpp index 0d78ccac0..6dd3c3114 100644 --- a/src/graphics/stkmesh.cpp +++ b/src/graphics/stkmesh.cpp @@ -11,12 +11,16 @@ #include "modes/world.hpp" -Material::ShaderType MaterialTypeToMeshMaterial(video::E_MATERIAL_TYPE MaterialType, video::E_VERTEX_TYPE tp, Material* material) +Material::ShaderType MaterialTypeToMeshMaterial(video::E_MATERIAL_TYPE MaterialType, video::E_VERTEX_TYPE tp, + Material* material, Material* layer2Material) { + if (layer2Material != NULL && layer2Material->getShaderType() == Material::SHADERTYPE_SPLATTING) + return Material::SHADERTYPE_SPLATTING; + switch (material->getShaderType()) { default: - return material->getShaderType(); + return material->getShaderType(); case Material::SHADERTYPE_SOLID: if (MaterialType == irr_driver->getShader(ES_NORMAL_MAP)) return Material::SHADERTYPE_NORMAL_MAP; diff --git a/src/graphics/stkmesh.hpp b/src/graphics/stkmesh.hpp index 574036b88..df533c031 100644 --- a/src/graphics/stkmesh.hpp +++ b/src/graphics/stkmesh.hpp @@ -174,7 +174,8 @@ class ListDisplacement : public MiscList, public std::vector {}; -Material::ShaderType MaterialTypeToMeshMaterial(video::E_MATERIAL_TYPE MaterialType, video::E_VERTEX_TYPE tp, Material* material); +Material::ShaderType MaterialTypeToMeshMaterial(video::E_MATERIAL_TYPE MaterialType, video::E_VERTEX_TYPE tp, + Material* material, Material* layer2Material); TransparentMaterial MaterialTypeToTransparentMaterial(video::E_MATERIAL_TYPE, f32 MaterialTypeParam, Material* material); void InitTextures(GLMesh &mesh, Material::ShaderType); diff --git a/src/graphics/stkmeshscenenode.cpp b/src/graphics/stkmeshscenenode.cpp index 1ede864ec..b23973b25 100644 --- a/src/graphics/stkmeshscenenode.cpp +++ b/src/graphics/stkmeshscenenode.cpp @@ -143,7 +143,10 @@ void STKMeshSceneNode::updateNoGL() else { assert(!isDisplacement); - Material::ShaderType MatType = MaterialTypeToMeshMaterial(type, mb->getVertexType(), material); + Material* material2 = NULL; + if (mb->getMaterial().getTexture(1) != NULL) + material2 = material_manager->getMaterialFor(mb->getMaterial().getTexture(1), mb); + Material::ShaderType MatType = MaterialTypeToMeshMaterial(type, mb->getVertexType(), material, material2); if (!immediate_draw) MeshSolidMaterial[MatType].push_back(&mesh); } @@ -179,7 +182,10 @@ void STKMeshSceneNode::updateGL() if (!rnd->isTransparent()) { Material* material = material_manager->getMaterialFor(mb->getMaterial().getTexture(0), mb); - Material::ShaderType MatType = MaterialTypeToMeshMaterial(type, mb->getVertexType(), material); + Material* material2 = NULL; + if (mb->getMaterial().getTexture(1) != NULL) + material2 = material_manager->getMaterialFor(mb->getMaterial().getTexture(1), mb); + Material::ShaderType MatType = MaterialTypeToMeshMaterial(type, mb->getVertexType(), material, material2); if (!immediate_draw) InitTextures(mesh, MatType); } From 30dda3e343575344d34548d070be5dd4f347e44b Mon Sep 17 00:00:00 2001 From: vlj Date: Thu, 2 Oct 2014 02:53:31 +0200 Subject: [PATCH 19/42] Fix sky warp --- data/shaders/sky.frag | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/data/shaders/sky.frag b/data/shaders/sky.frag index ee8e57d25..e43416722 100644 --- a/data/shaders/sky.frag +++ b/data/shaders/sky.frag @@ -11,8 +11,9 @@ void main(void) { vec3 eyedir = gl_FragCoord.xyz / vec3(screen, 1.); eyedir = 2.0 * eyedir - 1.0; - vec4 tmp = (InverseViewMatrix * InverseProjectionMatrix * vec4(eyedir, 1.)); - eyedir = tmp.xyz / tmp.w; + vec4 tmp = (InverseProjectionMatrix * vec4(eyedir, 1.)); + tmp /= tmp.w; + eyedir = (InverseViewMatrix * vec4(tmp.xyz, 0.)).xyz; vec4 color = texture(tex, eyedir); FragColor = vec4(color.xyz, 1.); } From ecd5aa1668dd94f22a0550d006b5f2af7b03fef8 Mon Sep 17 00:00:00 2001 From: hiker Date: Thu, 2 Oct 2014 17:08:26 +1000 Subject: [PATCH 20/42] Bugfix: tall karts would easily topple over (since wrong height value was used). --- src/karts/kart.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/karts/kart.cpp b/src/karts/kart.cpp index 8d036defb..ee2ab1ac6 100644 --- a/src/karts/kart.cpp +++ b/src/karts/kart.cpp @@ -573,8 +573,9 @@ void Kart::createPhysics() { // First: Create the chassis of the kart // ------------------------------------- - float kart_length = getKartLength(); - float kart_height = getKartHeight(); + const float kart_length = getKartLength(); + const float kart_width = getKartWidth(); + float kart_height = getKartHeight(); // improve physics for tall karts if (kart_height > kart_length*0.6f) @@ -596,9 +597,9 @@ void Kart::createPhysics() { for (int x = -1; x <= 1; x += 2) { - Vec3 p(x*getKartModel()->getWidth() *0.5f, - y*getKartModel()->getHeight()*0.5f, - z*getKartModel()->getLength()*0.5f); + Vec3 p(x*kart_width *0.5f, + y*kart_height *0.5f, + z*kart_length *0.5f); hull->addPoint(p*orig_factor); hull->addPoint(p*bevel_factor); @@ -614,7 +615,7 @@ void Kart::createPhysics() { // All wheel positions are relative to the center of // the collision shape. - wheel_pos[index].setX(x*0.5f*getKartWidth()); + wheel_pos[index].setX(x*0.5f*kart_width); float radius = getKartProperties()->getWheelRadius(); // The y position of the wheels (i.e. the points where // the suspension is attached to) is just at the @@ -624,8 +625,8 @@ void Kart::createPhysics() // point 'radius' up. That means that if the suspension // is fully compressed (0), the wheel will just be at // the bottom of the kart chassis and touch the ground - wheel_pos[index].setY(- 0.5f*getKartHeight() + radius); - wheel_pos[index].setZ((0.5f*getKartLength() - radius)* z); + wheel_pos[index].setY(- 0.5f*kart_height + radius); + wheel_pos[index].setZ((0.5f*kart_length - radius)* z); } else From 97772ba1aee8346070ac4620e4e4080d2f206610 Mon Sep 17 00:00:00 2001 From: samuncle Date: Thu, 2 Oct 2014 13:53:59 +0200 Subject: [PATCH 21/42] set the downard impulse to 5 + a more easy to use backward camera --- data/stk_config.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/data/stk_config.xml b/data/stk_config.xml index 5e0fdfbe0..da07bc15a 100644 --- a/data/stk_config.xml +++ b/data/stk_config.xml @@ -153,8 +153,8 @@ when the camera is pointing backwards. This is usually larger than the forward-up-angle, since the kart itself otherwise obstricts too much of the view. --> - + @@ -380,7 +380,7 @@ From e495b42d60b9929d56ec88886c8f2f3978ee168a Mon Sep 17 00:00:00 2001 From: hiker Date: Thu, 2 Oct 2014 22:35:13 +1000 Subject: [PATCH 22/42] Try to fix #1356 (camera NAN crash). --- src/graphics/camera.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/graphics/camera.cpp b/src/graphics/camera.cpp index 2688cac09..446f308c1 100644 --- a/src/graphics/camera.cpp +++ b/src/graphics/camera.cpp @@ -350,6 +350,18 @@ void Camera::smoothMoveCamera(float dt) current_position += (wanted_position - current_position) * dt * 5; } + // Avoid camera crash: if the speed is negative, the current_position + // can oscillate between plus and minus, getting bigger and bigger. If + // this happens often enough, floating point overflow happens (large + // negative speeds can happen when the kart is tumbling/falling) + // To avoid this, we just move the camera to the wanted position if + // the distance becomes too large (see #1356). + if( (current_position - wanted_position).getLengthSQ() > 100) + { + Log::debug("camera", "Resetting camera position to avoid crash"); + current_position = wanted_position; + } + if(m_mode!=CM_FALLING) m_camera->setPosition(current_position); m_camera->setTarget(current_target);//set new target From 4ecff3e46b5bb67d7afd5473c8735d53b28c46bd Mon Sep 17 00:00:00 2001 From: Deve Date: Thu, 2 Oct 2014 20:09:59 +0200 Subject: [PATCH 23/42] Use global number of oponents for grand prix --- src/states_screens/gp_info_screen.cpp | 37 ++++++++++++++++++++++++--- src/states_screens/gp_info_screen.hpp | 3 +++ 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/src/states_screens/gp_info_screen.cpp b/src/states_screens/gp_info_screen.cpp index 4539320be..e006013e9 100644 --- a/src/states_screens/gp_info_screen.cpp +++ b/src/states_screens/gp_info_screen.cpp @@ -81,6 +81,8 @@ void GPInfoScreen::loadedFromFile() // Only init the number of tracks here, this way the previously selected // number of tracks will be the default. m_num_tracks_spinner->setValue(1); + + m_ai_kart_spinner = getWidget("ai-spinner"); } // loadedFromFile // ---------------------------------------------------------------------------- @@ -213,6 +215,32 @@ void GPInfoScreen::init() getWidget("name")->setText(m_gp.getName(), false); m_gp.checkConsistency(); } + + // Number of AIs + // ------------- + const bool has_AI = race_manager->hasAI(); + m_ai_kart_spinner->setVisible(has_AI); + getWidget("ai-text")->setVisible(has_AI); + if (has_AI) + { + m_ai_kart_spinner->setActivated(); + + // Avoid negative numbers (which can happen if e.g. the number of karts + // in a previous race was lower than the number of players now. + int num_ai = UserConfigParams::m_num_karts - race_manager->getNumLocalPlayers(); + if (num_ai < 0) num_ai = 0; + m_ai_kart_spinner->setValue(num_ai); + race_manager->setNumKarts(num_ai + race_manager->getNumLocalPlayers()); + m_ai_kart_spinner->setMax(stk_config->m_max_karts - race_manager->getNumLocalPlayers()); + // A ftl reace needs at least three karts to make any sense + if(race_manager->getMinorMode()==RaceManager::MINOR_MODE_FOLLOW_LEADER) + { + m_ai_kart_spinner->setMin(3-race_manager->getNumLocalPlayers()); + } + else + m_ai_kart_spinner->setMin(0); + + } // has_AI addTracks(); addScreenshot(); @@ -296,10 +324,7 @@ void GPInfoScreen::eventCallback(Widget *, const std::string &name, else if (button == "start" || button=="continue") { // Normal GP: start/continue a saved GP - int n = getWidget("ai-spinner")->getValue(); - m_gp.changeReverse(getReverse()); - race_manager->setNumKarts(race_manager->getNumLocalPlayers() + n); race_manager->startGP(m_gp, false, (name == "continue")); } } // name=="buttons" @@ -329,6 +354,12 @@ void GPInfoScreen::eventCallback(Widget *, const std::string &name, m_gp.changeTrackNumber(m_num_tracks_spinner->getValue(), m_group_name); addTracks(); } + else if (name=="ai-spinner") + { + const int num_ai = m_ai_kart_spinner->getValue(); + race_manager->setNumKarts( race_manager->getNumLocalPlayers() + num_ai ); + UserConfigParams::m_num_karts = race_manager->getNumLocalPlayers() + num_ai; + } else if(name=="back") { StateManager::get()->escapePressed(); diff --git a/src/states_screens/gp_info_screen.hpp b/src/states_screens/gp_info_screen.hpp index 8e72b89b2..039936e61 100644 --- a/src/states_screens/gp_info_screen.hpp +++ b/src/states_screens/gp_info_screen.hpp @@ -47,6 +47,9 @@ private: /** Spinner for number of tracks (in case of random GP). */ GUIEngine::SpinnerWidget *m_num_tracks_spinner; + + /** Spinner for number of AI karts. */ + GUIEngine::SpinnerWidget* m_ai_kart_spinner; /** The currently selected group name. */ std::string m_group_name; From 710f7e7296c2b3e7b00f6a7b3bb899bc35b1676a Mon Sep 17 00:00:00 2001 From: Deve Date: Thu, 2 Oct 2014 20:19:15 +0200 Subject: [PATCH 24/42] Fixed continue GPs --- src/karts/kart.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/karts/kart.cpp b/src/karts/kart.cpp index ee2ab1ac6..9ed44a55f 100644 --- a/src/karts/kart.cpp +++ b/src/karts/kart.cpp @@ -1245,9 +1245,9 @@ void Kart::update(float dt) // let kart fall a bit before rescuing const Vec3 *min, *max; World::getWorld()->getTrack()->getAABB(&min, &max); - if(min->getY() - getXYZ().getY() > 17 && !m_flying && - !getKartAnimation()) - new RescueAnimation(this); + //~ if(min->getY() - getXYZ().getY() > 17 && !m_flying && + //~ !getKartAnimation()) + //~ new RescueAnimation(this); } else { From fccac9ed3cb45f20c54dbf5ffd5623cf44bed98f Mon Sep 17 00:00:00 2001 From: Deve Date: Thu, 2 Oct 2014 20:20:50 +0200 Subject: [PATCH 25/42] Revert "Fixed continue GPs" This reverts commit 710f7e7296c2b3e7b00f6a7b3bb899bc35b1676a. --- src/karts/kart.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/karts/kart.cpp b/src/karts/kart.cpp index 9ed44a55f..ee2ab1ac6 100644 --- a/src/karts/kart.cpp +++ b/src/karts/kart.cpp @@ -1245,9 +1245,9 @@ void Kart::update(float dt) // let kart fall a bit before rescuing const Vec3 *min, *max; World::getWorld()->getTrack()->getAABB(&min, &max); - //~ if(min->getY() - getXYZ().getY() > 17 && !m_flying && - //~ !getKartAnimation()) - //~ new RescueAnimation(this); + if(min->getY() - getXYZ().getY() > 17 && !m_flying && + !getKartAnimation()) + new RescueAnimation(this); } else { From 69217bd03c1e593ee2b08d632dd917358a079817 Mon Sep 17 00:00:00 2001 From: Deve Date: Thu, 2 Oct 2014 20:21:46 +0200 Subject: [PATCH 26/42] Grr, wrong file. Fixed continue GPs --- src/states_screens/gp_info_screen.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/states_screens/gp_info_screen.cpp b/src/states_screens/gp_info_screen.cpp index e006013e9..9e9fbe3b5 100644 --- a/src/states_screens/gp_info_screen.cpp +++ b/src/states_screens/gp_info_screen.cpp @@ -321,11 +321,11 @@ void GPInfoScreen::eventCallback(Widget *, const std::string &name, /*new tracks*/ true ); addTracks(); } - else if (button == "start" || button=="continue") + else if (button == "start" || button == "continue") { // Normal GP: start/continue a saved GP m_gp.changeReverse(getReverse()); - race_manager->startGP(m_gp, false, (name == "continue")); + race_manager->startGP(m_gp, false, (button == "continue")); } } // name=="buttons" else if (name=="group-spinner") From ce51824d47a9d0d78fb0402d2ac716595ba93ad2 Mon Sep 17 00:00:00 2001 From: Deve Date: Thu, 2 Oct 2014 21:56:46 +0200 Subject: [PATCH 27/42] Redraw GP info screen when number of oponents was changed. This allows to show or hide "Continue" button without opening screen once again. --- src/states_screens/gp_info_screen.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/states_screens/gp_info_screen.cpp b/src/states_screens/gp_info_screen.cpp index 9e9fbe3b5..d36133c92 100644 --- a/src/states_screens/gp_info_screen.cpp +++ b/src/states_screens/gp_info_screen.cpp @@ -359,6 +359,11 @@ void GPInfoScreen::eventCallback(Widget *, const std::string &name, const int num_ai = m_ai_kart_spinner->getValue(); race_manager->setNumKarts( race_manager->getNumLocalPlayers() + num_ai ); UserConfigParams::m_num_karts = race_manager->getNumLocalPlayers() + num_ai; + + //Redraw scene because available buttons depend on current settings + getWidget("buttons")->setSelection(0, PLAYER_ID_GAME_MASTER); + reshowCurrentScreen(); + m_ai_kart_spinner->setFocusForPlayer(PLAYER_ID_GAME_MASTER); } else if(name=="back") { From e4e91bf25a24d9461bb6c947e75e98d81b260810 Mon Sep 17 00:00:00 2001 From: hiker Date: Fri, 3 Oct 2014 08:18:31 +1000 Subject: [PATCH 28/42] Only cosmetical changes to follow our coding style. --- src/utils/debug.cpp | 167 ++++++++++++++++++++++++-------------------- 1 file changed, 92 insertions(+), 75 deletions(-) diff --git a/src/utils/debug.cpp b/src/utils/debug.cpp index c053c7036..cf70335c1 100644 --- a/src/utils/debug.cpp +++ b/src/utils/debug.cpp @@ -40,8 +40,9 @@ using namespace gui; namespace Debug { -/** This is to let mouse input events go through when the debug menu is visible, otherwise - GUI events would be blocked while in a race... */ +/** This is to let mouse input events go through when the debug menu is + * visible, otherwise GUI events would be blocked while in a race... + */ static bool g_debug_menu_visible = false; // ----------------------------------------------------------------------------- @@ -85,7 +86,7 @@ enum DebugMenuCommand DEBUG_HIDE_KARTS, DEBUG_THROTTLE_FPS, DEBUG_VISUAL_VALUES, -}; +}; // DebugMenuCommand // ----------------------------------------------------------------------------- // Add powerup selected from debug menu for all player karts @@ -98,39 +99,38 @@ void addPowerup(PowerupManager::PowerupType powerup) AbstractKart* kart = world->getLocalPlayerKart(i); kart->setPowerup(powerup, 10000); } -} - +} // addPowerup +// ---------------------------------------------------------------------------- void addAttachment(Attachment::AttachmentType type) { World* world = World::getWorld(); - if (world == NULL) return; - for(unsigned int i = 0; i < world->getNumKarts(); i++) - { + if (world == NULL) return; + for (unsigned int i = 0; i < world->getNumKarts(); i++) + { AbstractKart *kart = world->getKart(i); - if (kart->getController()->isPlayerController()) { - if (type == Attachment::ATTACH_ANVIL) - { - kart->getAttachment() - ->set(type, stk_config->m_anvil_time); - kart->adjustSpeed(stk_config->m_anvil_speed_factor); - kart->updateWeight(); - } - else if (type == Attachment::ATTACH_PARACHUTE) - { - kart->getAttachment() - ->set(type, stk_config->m_parachute_time); - } - else if (type == Attachment::ATTACH_BOMB) - { - kart->getAttachment() - ->set(type, stk_config->m_bomb_time); - } + if (!kart->getController()->isPlayerController()) + continue; + if (type == Attachment::ATTACH_ANVIL) + { + kart->getAttachment() + ->set(type, stk_config->m_anvil_time); + kart->adjustSpeed(stk_config->m_anvil_speed_factor); + kart->updateWeight(); } + else if (type == Attachment::ATTACH_PARACHUTE) + { + kart->getAttachment() + ->set(type, stk_config->m_parachute_time); } + else if (type == Attachment::ATTACH_BOMB) + { + kart->getAttachment() + ->set(type, stk_config->m_bomb_time); + } + } -} - +} // addAttachment // ----------------------------------------------------------------------------- // Debug menu handling @@ -143,19 +143,20 @@ bool onEvent(const SEvent &event) if(event.EventType == EET_MOUSE_INPUT_EVENT) { // Create the menu (only one menu at a time) - if(event.MouseInput.Event == EMIE_RMOUSE_PRESSED_DOWN && !g_debug_menu_visible) + if(event.MouseInput.Event == EMIE_RMOUSE_PRESSED_DOWN && + !g_debug_menu_visible) { // root menu gui::IGUIEnvironment* guienv = irr_driver->getGUI(); - IGUIContextMenu* mnu = guienv->addContextMenu( - core::rect(event.MouseInput.X, event.MouseInput.Y, event.MouseInput.Y+100, event.MouseInput.Y+100),NULL); + core::rect r(event.MouseInput.X, event.MouseInput.Y, + event.MouseInput.Y+100, event.MouseInput.Y+100); + IGUIContextMenu* mnu = guienv->addContextMenu(r, NULL); int graphicsMenuIndex = mnu->addItem(L"Graphics >",-1,true,true); // graphics menu IGUIContextMenu* sub = mnu->getSubMenu(graphicsMenuIndex); sub->addItem(L"Reload shaders", DEBUG_GRAPHICS_RELOAD_SHADERS ); - sub->addItem(L"Reset debug views", DEBUG_GRAPHICS_RESET ); sub->addItem(L"Wireframe", DEBUG_GRAPHICS_WIREFRAME ); sub->addItem(L"Mipmap viz", DEBUG_GRAPHICS_MIPMAP_VIZ ); sub->addItem(L"Normals viz", DEBUG_GRAPHICS_NORMALS_VIZ ); @@ -168,6 +169,7 @@ bool onEvent(const SEvent &event) sub->addItem(L"Distort viz", DEBUG_GRAPHICS_DISTORT_VIZ ); sub->addItem(L"Physics debug", DEBUG_GRAPHICS_BULLET_1); sub->addItem(L"Physics debug (no kart)", DEBUG_GRAPHICS_BULLET_2); + sub->addItem(L"Reset debug views", DEBUG_GRAPHICS_RESET ); mnu->addItem(L"Items >",-1,true,true); sub = mnu->getSubMenu(1); @@ -192,7 +194,8 @@ bool onEvent(const SEvent &event) mnu->addItem(L"Profiler",DEBUG_PROFILER); if (UserConfigParams::m_profiler_enabled) - mnu->addItem(L"Toggle capture profiler report", DEBUG_PROFILER_GENERATE_REPORT); + mnu->addItem(L"Toggle capture profiler report", + DEBUG_PROFILER_GENERATE_REPORT); mnu->addItem(L"Do not limit FPS", DEBUG_THROTTLE_FPS); mnu->addItem(L"FPS",DEBUG_FPS); mnu->addItem(L"Save replay", DEBUG_SAVE_REPLAY); @@ -205,14 +208,16 @@ bool onEvent(const SEvent &event) irr_driver->showPointer(); } - // Let Irrlicht handle the event while the menu is visible - otherwise in a race the GUI events won't be generated + // Let Irrlicht handle the event while the menu is visible. + // Otherwise in a race the GUI events won't be generated if(g_debug_menu_visible) return false; } if (event.EventType == EET_GUI_EVENT) { - if (event.GUIEvent.Caller != NULL && event.GUIEvent.Caller->getType() == EGUIET_CONTEXT_MENU ) + if (event.GUIEvent.Caller != NULL && + event.GUIEvent.Caller->getType() == EGUIET_CONTEXT_MENU ) { IGUIContextMenu *menu = (IGUIContextMenu*)event.GUIEvent.Caller; s32 cmdID = menu->getItemCommandId(menu->getSelectedItem()); @@ -224,6 +229,8 @@ bool onEvent(const SEvent &event) if (event.GUIEvent.EventType == gui::EGET_MENU_ITEM_SELECTED) { + World *world = World::getWorld(); + Physics *physics = world ? world->getPhysics() : NULL; if(cmdID == DEBUG_GRAPHICS_RELOAD_SHADERS) { Log::info("Debug", "Reloading shaders..."); @@ -231,87 +238,87 @@ bool onEvent(const SEvent &event) } else if (cmdID == DEBUG_GRAPHICS_RESET) { - World* world = World::getWorld(); - if (world != NULL) world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NONE); + if (physics) + physics->setDebugMode(IrrDebugDrawer::DM_NONE); irr_driver->resetDebugModes(); } else if (cmdID == DEBUG_GRAPHICS_WIREFRAME) { - World* world = World::getWorld(); - if (world != NULL) world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NONE); + if (physics) + physics->setDebugMode(IrrDebugDrawer::DM_NONE); irr_driver->resetDebugModes(); irr_driver->toggleWireframe(); } else if (cmdID == DEBUG_GRAPHICS_MIPMAP_VIZ) { - World* world = World::getWorld(); - if (world != NULL) world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NONE); + if (physics) + physics->setDebugMode(IrrDebugDrawer::DM_NONE); irr_driver->resetDebugModes(); irr_driver->toggleMipVisualization(); } else if (cmdID == DEBUG_GRAPHICS_NORMALS_VIZ) { - World* world = World::getWorld(); - if (world != NULL) world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NONE); + if (physics) + physics->setDebugMode(IrrDebugDrawer::DM_NONE); irr_driver->resetDebugModes(); irr_driver->toggleNormals(); } else if (cmdID == DEBUG_GRAPHICS_SSAO_VIZ) { - World* world = World::getWorld(); - if (world != NULL) world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NONE); + if (physics) + physics->setDebugMode(IrrDebugDrawer::DM_NONE); irr_driver->resetDebugModes(); irr_driver->toggleSSAOViz(); } else if (cmdID == DEBUG_GRAPHICS_RSM_VIZ) { - World* world = World::getWorld(); - if (world != NULL) world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NONE); + if (physics) + physics->setDebugMode(IrrDebugDrawer::DM_NONE); irr_driver->resetDebugModes(); irr_driver->toggleRSM(); } else if (cmdID == DEBUG_GRAPHICS_RH_VIZ) { - World* world = World::getWorld(); - if (world != NULL) world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NONE); + if (physics) + physics->setDebugMode(IrrDebugDrawer::DM_NONE); irr_driver->resetDebugModes(); irr_driver->toggleRH(); } else if (cmdID == DEBUG_GRAPHICS_GI_VIZ) { - World* world = World::getWorld(); - if (world != NULL) world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NONE); + if (physics) + physics->setDebugMode(IrrDebugDrawer::DM_NONE); irr_driver->resetDebugModes(); irr_driver->toggleGI(); } else if (cmdID == DEBUG_GRAPHICS_SHADOW_VIZ) { - World* world = World::getWorld(); - if (world != NULL) world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NONE); + if (physics) + physics->setDebugMode(IrrDebugDrawer::DM_NONE); irr_driver->resetDebugModes(); irr_driver->toggleShadowViz(); } else if (cmdID == DEBUG_GRAPHICS_LIGHT_VIZ) { - World* world = World::getWorld(); - if (world != NULL) world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NONE); + if (physics) + physics->setDebugMode(IrrDebugDrawer::DM_NONE); irr_driver->resetDebugModes(); irr_driver->toggleLightViz(); } else if (cmdID == DEBUG_GRAPHICS_DISTORT_VIZ) { - World* world = World::getWorld(); - if (world != NULL) world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NONE); + if (physics) + physics->setDebugMode(IrrDebugDrawer::DM_NONE); irr_driver->resetDebugModes(); irr_driver->toggleDistortViz(); @@ -320,17 +327,16 @@ bool onEvent(const SEvent &event) { irr_driver->resetDebugModes(); - World* world = World::getWorld(); - if (world == NULL) return false; - world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_KARTS_PHYSICS); + if (!world) return false; + physics->setDebugMode(IrrDebugDrawer::DM_KARTS_PHYSICS); } else if (cmdID == DEBUG_GRAPHICS_BULLET_2) { irr_driver->resetDebugModes(); - World* world = World::getWorld(); - if (world == NULL) return false; - world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NO_KARTS_GRAPHICS); + if (!world) return false; + Physics *physics = world->getPhysics(); + physics->setDebugMode(IrrDebugDrawer::DM_NO_KARTS_GRAPHICS); } else if (cmdID == DEBUG_PROFILER) { @@ -396,9 +402,10 @@ bool onEvent(const SEvent &event) } else if (cmdID == DEBUG_POWERUP_NITRO) { - World* world = World::getWorld(); - if (world == NULL) return false; - for(unsigned int i = 0; i < race_manager->getNumLocalPlayers(); i++) + if (!world) return false; + const unsigned int num_local_players = + race_manager->getNumLocalPlayers(); + for(unsigned int i = 0; i < num_local_players; i++) { AbstractKart* kart = world->getLocalPlayerKart(i); kart->setEnergy(100.0f); @@ -439,31 +446,37 @@ bool onEvent(const SEvent &event) { #if !defined(__APPLE__) DebugSliderDialog *dsd = new DebugSliderDialog(); - dsd->setSliderHook( "red_slider", 0, 255, [](){ return int(irr_driver->getAmbientLight().r * 255.f); }, + dsd->setSliderHook( "red_slider", 0, 255, + [](){ return int(irr_driver->getAmbientLight().r * 255.f); }, [](int v){ video::SColorf ambient = irr_driver->getAmbientLight(); ambient.setColorComponentValue(0, v / 255.f); irr_driver->setAmbientLight(ambient); } ); - dsd->setSliderHook("green_slider", 0, 255, [](){ return int(irr_driver->getAmbientLight().g * 255.f); }, + dsd->setSliderHook("green_slider", 0, 255, + [](){ return int(irr_driver->getAmbientLight().g * 255.f); }, [](int v){ video::SColorf ambient = irr_driver->getAmbientLight(); ambient.setColorComponentValue(1, v / 255.f); irr_driver->setAmbientLight(ambient); } ); - dsd->setSliderHook("blue_slider", 0, 255, [](){ return int(irr_driver->getAmbientLight().b * 255.f); }, + dsd->setSliderHook("blue_slider", 0, 255, + [](){ return int(irr_driver->getAmbientLight().b * 255.f); }, [](int v){ video::SColorf ambient = irr_driver->getAmbientLight(); ambient.setColorComponentValue(2, v / 255.f); irr_driver->setAmbientLight(ambient); } ); - dsd->setSliderHook("ssao_radius", 0, 100, [](){ return int(irr_driver->getSSAORadius() * 10.f); }, + dsd->setSliderHook("ssao_radius", 0, 100, + [](){ return int(irr_driver->getSSAORadius() * 10.f); }, [](int v){irr_driver->setSSAORadius(v / 10.f); } ); - dsd->setSliderHook("ssao_k", 0, 100, [](){ return int(irr_driver->getSSAOK() * 10.f); }, + dsd->setSliderHook("ssao_k", 0, 100, + [](){ return int(irr_driver->getSSAOK() * 10.f); }, [](int v){irr_driver->setSSAOK(v / 10.f); } ); - dsd->setSliderHook("ssao_sigma", 0, 100, [](){ return int(irr_driver->getSSAOSigma() * 10.f); }, + dsd->setSliderHook("ssao_sigma", 0, 100, + [](){ return int(irr_driver->getSSAOSigma() * 10.f); }, [](int v){irr_driver->setSSAOSigma(v / 10.f); } ); #endif @@ -474,10 +487,14 @@ bool onEvent(const SEvent &event) } } return true; // continue event handling -} +} // onEvent +// ---------------------------------------------------------------------------- +/** Returns if the debug menu is visible. + */ bool isOpen() { return g_debug_menu_visible; -} -} +} // isOpen + +} // namespace Debug From 22a884828a9cfb271622b18398eac503dbeaab94 Mon Sep 17 00:00:00 2001 From: Marianne Gagnon Date: Thu, 2 Oct 2014 18:52:17 -0400 Subject: [PATCH 29/42] Use unlit material for minimap, to avoid dark minimap segments --- src/tracks/quad_graph.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/tracks/quad_graph.cpp b/src/tracks/quad_graph.cpp index ab673d7b3..0ce062ea0 100644 --- a/src/tracks/quad_graph.cpp +++ b/src/tracks/quad_graph.cpp @@ -524,6 +524,8 @@ void QuadGraph::createMesh(bool show_invisible, m_mesh_buffer->recalculateBoundingBox(); m_mesh->setBoundingBox(m_mesh_buffer->getBoundingBox()); + m_mesh_buffer->getMaterial().setTexture(0, irr_driver->getTexture("unlit.png")); + delete[] ind; delete[] new_v; } // createMesh From 9f5b2fbc919f2cc146d268e05362fd1b4ac936aa Mon Sep 17 00:00:00 2001 From: hiker Date: Fri, 3 Oct 2014 08:58:28 +1000 Subject: [PATCH 30/42] Added a 'print start position' option, which prints a line that can be copied into a scene.xml file to start a kart at the current position (which is useful to testing to avoid long races before a location to be tested is reached). --- src/utils/debug.cpp | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/src/utils/debug.cpp b/src/utils/debug.cpp index cf70335c1..622bd0f77 100644 --- a/src/utils/debug.cpp +++ b/src/utils/debug.cpp @@ -17,12 +17,13 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "debug.hpp" + #include "config/user_config.hpp" -#include "karts/controller/controller.hpp" -#include "karts/abstract_kart.hpp" #include "graphics/irr_driver.hpp" #include "items/powerup_manager.hpp" #include "items/attachment.hpp" +#include "karts/abstract_kart.hpp" +#include "karts/controller/controller.hpp" #include "modes/world.hpp" #include "physics/irr_debug_drawer.hpp" #include "physics/physics.hpp" @@ -30,8 +31,10 @@ #include "main_loop.hpp" #include "replay/replay_recorder.hpp" #include "states_screens/dialogs/debug_slider.hpp" +#include "utils/constants.hpp" #include "utils/log.hpp" #include "utils/profiler.hpp" + #include #include @@ -86,6 +89,7 @@ enum DebugMenuCommand DEBUG_HIDE_KARTS, DEBUG_THROTTLE_FPS, DEBUG_VISUAL_VALUES, + DEBUG_PRINT_START_POS, }; // DebugMenuCommand // ----------------------------------------------------------------------------- @@ -93,7 +97,7 @@ enum DebugMenuCommand void addPowerup(PowerupManager::PowerupType powerup) { World* world = World::getWorld(); - if (world == NULL) return; + if (!world) return; for(unsigned int i = 0; i < race_manager->getNumLocalPlayers(); i++) { AbstractKart* kart = world->getLocalPlayerKart(i); @@ -202,7 +206,7 @@ bool onEvent(const SEvent &event) mnu->addItem(L"Save history", DEBUG_SAVE_HISTORY); mnu->addItem(L"Toggle GUI", DEBUG_TOGGLE_GUI); mnu->addItem(L"Hide karts", DEBUG_HIDE_KARTS); - + mnu->addItem(L"Print position", DEBUG_PRINT_START_POS); g_debug_menu_visible = true; irr_driver->showPointer(); @@ -425,23 +429,33 @@ bool onEvent(const SEvent &event) } else if (cmdID == DEBUG_TOGGLE_GUI) { - World* world = World::getWorld(); - if (world == NULL) return false; + if (!world) return false; RaceGUIBase* gui = world->getRaceGUI(); if (gui != NULL) gui->m_enabled = !gui->m_enabled; } else if (cmdID == DEBUG_HIDE_KARTS) { - World* world = World::getWorld(); - if (world == NULL) return false; - const int count = World::getWorld()->getNumKarts(); - for (int n = 0; ngetNumKarts(); n++) { AbstractKart* kart = world->getKart(n); if (kart->getController()->isPlayerController()) kart->getNode()->setVisible(false); } } + else if (cmdID == DEBUG_PRINT_START_POS) + { + if(!world) return false; + for(unsigned int i=0; igetNumKarts(); i++) + { + AbstractKart *kart = world->getKart(i); + Log::warn(kart->getIdent().c_str(), + "", + i, kart->getXYZ().getX(), kart->getXYZ().getY(), + kart->getXYZ().getZ(),kart->getHeading()*RAD_TO_DEGREE + ); + } + } else if (cmdID == DEBUG_VISUAL_VALUES) { #if !defined(__APPLE__) From b5a85ae1004917908979500d5677f4d1b90b7eea Mon Sep 17 00:00:00 2001 From: hiker Date: Fri, 3 Oct 2014 16:48:47 +1000 Subject: [PATCH 31/42] Fixed typo in xml output. --- src/utils/debug.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/debug.cpp b/src/utils/debug.cpp index 622bd0f77..19c011e70 100644 --- a/src/utils/debug.cpp +++ b/src/utils/debug.cpp @@ -450,7 +450,7 @@ bool onEvent(const SEvent &event) { AbstractKart *kart = world->getKart(i); Log::warn(kart->getIdent().c_str(), - "", + "", i, kart->getXYZ().getX(), kart->getXYZ().getY(), kart->getXYZ().getZ(),kart->getHeading()*RAD_TO_DEGREE ); From ab252a306de99b206356bc25367da83f9d55cea9 Mon Sep 17 00:00:00 2001 From: hiker Date: Sat, 4 Oct 2014 00:39:32 +1000 Subject: [PATCH 32/42] Try to avoid graphical kart chassis being partially in ground (still not perfect). --- src/karts/kart.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/karts/kart.cpp b/src/karts/kart.cpp index ee2ab1ac6..aee0d8b7c 100644 --- a/src/karts/kart.cpp +++ b/src/karts/kart.cpp @@ -2546,8 +2546,9 @@ void Kart::updateGraphics(float dt, const Vec3& offset_xyz, float lean_height = tan(fabsf(m_current_lean)) * getKartWidth()*0.5f; float heading = m_skidding->getVisualSkidRotation(); + float xx = fabsf(m_speed)* getKartProperties()->getDownwardImpulseFactor()*0.0006f; Vec3 center_shift = Vec3(0, m_skidding->getGraphicalJumpOffset() - + lean_height +m_graphical_y_offset, 0); + + lean_height +m_graphical_y_offset+xx, 0); center_shift = getTrans().getBasis() * center_shift; Moveable::updateGraphics(dt, center_shift, From 8033c5a8395b81bcf50dccda9ca6ef377a306c98 Mon Sep 17 00:00:00 2001 From: Marianne Gagnon Date: Fri, 3 Oct 2014 18:39:07 -0400 Subject: [PATCH 33/42] Don't set animation strength on speed weighted objects, it's probably unnecessary and produces weird artifacts --- src/karts/kart_model.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/karts/kart_model.cpp b/src/karts/kart_model.cpp index 464acb111..b3bc16b4a 100644 --- a/src/karts/kart_model.cpp +++ b/src/karts/kart_model.cpp @@ -441,7 +441,6 @@ scene::ISceneNode* KartModel::attachModel(bool animated_models, bool always_anim obj.m_node = irr_driver->addAnimatedMesh(obj.m_model, node); obj.m_node->grab(); - obj.m_node->setAnimationStrength(0.0f); obj.m_node->setFrameLoop(m_animation_frame[AF_SPEED_WEIGHTED_START], m_animation_frame[AF_SPEED_WEIGHTED_END]); #ifdef DEBUG @@ -826,7 +825,6 @@ void KartModel::update(float dt, float rotation_dt, float steer, float speed) strength = speed * strength_factor; btClamp(strength, 0.0f, 1.0f); } - obj.m_node->setAnimationStrength(strength); // Animation speed const float speed_factor = GET_VALUE(obj, m_speed_factor); From 3a1b2442e8a53ee9aa8bbafa598347def80b412b Mon Sep 17 00:00:00 2001 From: Vincent Lejeune Date: Sat, 4 Oct 2014 00:59:37 +0200 Subject: [PATCH 34/42] Revert "Try to cull object whose aera is below 1 px" This reverts commit 83053e0ee42b1b84a9934ff34a6353c81d3fe6b4. --- src/graphics/stkscenemanager.cpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/graphics/stkscenemanager.cpp b/src/graphics/stkscenemanager.cpp index a5326473f..2ff2e33b6 100644 --- a/src/graphics/stkscenemanager.cpp +++ b/src/graphics/stkscenemanager.cpp @@ -167,7 +167,7 @@ bool isBoxInFrontOfPlane(const core::plane3df &plane, const core::vector3df edge } static -bool isCulledPrecise(const scene::ICameraSceneNode *cam, const scene::ISceneNode *node, bool aera_check) +bool isCulledPrecise(const scene::ICameraSceneNode *cam, const scene::ISceneNode *node) { if (!node->getAutomaticCulling()) return false; @@ -183,10 +183,6 @@ bool isCulledPrecise(const scene::ICameraSceneNode *cam, const scene::ISceneNode for (s32 i = 0; i < scene::SViewFrustum::VF_PLANE_COUNT; ++i) if (isBoxInFrontOfPlane(frust.planes[i], edges)) return true; - - float ratio = cam->getProjectionMatrix().pointer()[0] * cam->getProjectionMatrix().pointer()[5]; - if (aera_check && node->getBoundingBox().getArea() * ratio < 1.) - return true; return false; } @@ -439,14 +435,14 @@ parseSceneManager(core::list List, std::vector(*I)) { - if (!isCulledPrecise(cam, *I, false)) + if (!isCulledPrecise(cam, *I)) ParticlesList::getInstance()->push_back(node); continue; } if (STKBillboard *node = dynamic_cast(*I)) { - if (!isCulledPrecise(cam, *I, false)) + if (!isCulledPrecise(cam, *I)) BillBoardList::getInstance()->push_back(node); continue; } @@ -506,12 +502,12 @@ void IrrDriver::PrepareDrawCalls(scene::ICameraSceneNode *camnode) for (int i = 0; i < (int)DeferredUpdate.size(); i++) { scene::ISceneNode *node = dynamic_cast(DeferredUpdate[i]); - DeferredUpdate[i]->setCulledForPlayerCam(isCulledPrecise(camnode, node, false)); - DeferredUpdate[i]->setCulledForRSMCam(isCulledPrecise(m_suncam, node, true)); - DeferredUpdate[i]->setCulledForShadowCam(0, isCulledPrecise(m_shadow_camnodes[0], node, true)); - DeferredUpdate[i]->setCulledForShadowCam(1, isCulledPrecise(m_shadow_camnodes[1], node, true)); - DeferredUpdate[i]->setCulledForShadowCam(2, isCulledPrecise(m_shadow_camnodes[2], node, true)); - DeferredUpdate[i]->setCulledForShadowCam(3, isCulledPrecise(m_shadow_camnodes[3], node, true)); + DeferredUpdate[i]->setCulledForPlayerCam(isCulledPrecise(camnode, node)); + DeferredUpdate[i]->setCulledForRSMCam(isCulledPrecise(m_suncam, node)); + DeferredUpdate[i]->setCulledForShadowCam(0, isCulledPrecise(m_shadow_camnodes[0], node)); + DeferredUpdate[i]->setCulledForShadowCam(1, isCulledPrecise(m_shadow_camnodes[1], node)); + DeferredUpdate[i]->setCulledForShadowCam(2, isCulledPrecise(m_shadow_camnodes[2], node)); + DeferredUpdate[i]->setCulledForShadowCam(3, isCulledPrecise(m_shadow_camnodes[3], node)); } // Add a 1 s timeout From b56901bacdcce084b84dc63934cccd4f1ab10ad7 Mon Sep 17 00:00:00 2001 From: Vincent Lejeune Date: Sat, 4 Oct 2014 01:42:25 +0200 Subject: [PATCH 35/42] Fix minimap halo second time it is rendered. --- src/modes/world.cpp | 2 +- src/modes/world.hpp | 3 +++ src/tracks/quad_graph.cpp | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/modes/world.cpp b/src/modes/world.cpp index 65fc1a2d0..5637925f4 100644 --- a/src/modes/world.cpp +++ b/src/modes/world.cpp @@ -1229,7 +1229,7 @@ void World::escapePressed() bool World::isFogEnabled() const { - return m_track != NULL && m_track->isFogEnabled(); + return !m_force_disable_fog && (m_track != NULL && m_track->isFogEnabled()); } /* EOF */ diff --git a/src/modes/world.hpp b/src/modes/world.hpp index 4d34dbfa6..765f833e3 100644 --- a/src/modes/world.hpp +++ b/src/modes/world.hpp @@ -92,6 +92,7 @@ protected: RandomGenerator m_random; Physics* m_physics; + bool m_force_disable_fog; AbstractKart* m_fastest_kart; /** Number of eliminated karts. */ int m_eliminated_karts; @@ -332,6 +333,8 @@ public: { m_clear_color = color; } + /** Override track fog value to force disabled */ + void forceFogDisabled(bool v) { m_force_disable_fog = v; } // ------------------------------------------------------------------------ /** Override if you want to know when a kart presses fire */ virtual void onFirePressed(Controller* who) {} diff --git a/src/tracks/quad_graph.cpp b/src/tracks/quad_graph.cpp index 0ce062ea0..a8198cdd1 100644 --- a/src/tracks/quad_graph.cpp +++ b/src/tracks/quad_graph.cpp @@ -983,6 +983,7 @@ void QuadGraph::makeMiniMap(const core::dimension2du &dimension, { const SColor oldClearColor = World::getWorld()->getClearColor(); World::getWorld()->setClearbackBufferColor(SColor(0, 255, 255, 255)); + World::getWorld()->forceFogDisabled(true); *oldRttMinimap = NULL; *newRttMinimap = NULL; @@ -1102,6 +1103,7 @@ void QuadGraph::makeMiniMap(const core::dimension2du &dimension, *oldRttMinimap = texture; *newRttMinimap = frame_buffer; World::getWorld()->setClearbackBufferColor(oldClearColor); + World::getWorld()->forceFogDisabled(false); } // makeMiniMap //----------------------------------------------------------------------------- From f63e7d93b861989b79ce5bfd3192ad9d7ca97ca3 Mon Sep 17 00:00:00 2001 From: hiker Date: Sat, 4 Oct 2014 23:32:54 +1000 Subject: [PATCH 36/42] Fixed #1598 (error message about font texture not found). --- data/fonts/materials.xml | 22 ++++++++++++++++++++++ src/main.cpp | 10 +++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 data/fonts/materials.xml diff --git a/data/fonts/materials.xml b/data/fonts/materials.xml new file mode 100644 index 000000000..105ab3111 --- /dev/null +++ b/data/fonts/materials.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main.cpp b/src/main.cpp index 50e80db02..546757998 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1206,7 +1206,15 @@ int main(int argc, char *argv[] ) // Get into menu mode initially. input_manager->setMode(InputManager::MENU); main_loop = new MainLoop(); - material_manager -> loadMaterial (); + material_manager->loadMaterial(); + + // Load the font textures + file_manager->pushTextureSearchPath( + file_manager->getAsset(FileManager::FONT,"")); + material_manager->addSharedMaterial( + file_manager->getAsset(FileManager::FONT,"materials.xml")); + file_manager->popTextureSearchPath(); + GUIEngine::addLoadingIcon( irr_driver->getTexture(FileManager::GUI, "options_video.png")); kart_properties_manager -> loadAllKarts (); From 78b21eb8402eb900208ab3a287eb22e67dfebef7 Mon Sep 17 00:00:00 2001 From: Deve Date: Sat, 4 Oct 2014 21:50:11 +0200 Subject: [PATCH 37/42] Fixed visibility parameter for icon button widget. It was set for widget but not for irrlicht gui element. --- src/guiengine/widgets/icon_button_widget.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/guiengine/widgets/icon_button_widget.cpp b/src/guiengine/widgets/icon_button_widget.cpp index 4255895a0..66342ebfc 100644 --- a/src/guiengine/widgets/icon_button_widget.cpp +++ b/src/guiengine/widgets/icon_button_widget.cpp @@ -189,6 +189,9 @@ void IconButtonWidget::add() m_id = m_element->getID(); if (m_tab_stop) m_element->setTabOrder(m_id); m_element->setTabGroup(false); + + if (!m_is_visible) + m_element->setVisible(false); } // ----------------------------------------------------------------------------- From 5a07fd0fa46f6c6c23286ce835ec4ac806067376 Mon Sep 17 00:00:00 2001 From: Marianne Gagnon Date: Sat, 4 Oct 2014 19:05:27 -0400 Subject: [PATCH 38/42] FIx crash in LOD --- src/graphics/lod_node.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/graphics/lod_node.cpp b/src/graphics/lod_node.cpp index 1fea813a6..31ab6d731 100644 --- a/src/graphics/lod_node.cpp +++ b/src/graphics/lod_node.cpp @@ -80,7 +80,11 @@ int LODNode::getLevel() if (camera == NULL) return (int)m_detail.size() - 1; AbstractKart* kart = camera->getKart(); - const Vec3 &pos = kart->getFrontXYZ(); + // use kart position and not camera position when a kart is available, + // because for some effects the camera will be moved to various locations + // (for instance shadows), so using camera position for LOD may result + // in objects being culled when they shouldn't + const Vec3 &pos = (kart != NULL ? kart->getFrontXYZ() : camera->getCameraSceneNode()->getAbsolutePosition()); const int dist = (int)((m_nodes[0]->getAbsolutePosition()).getDistanceFromSQ(pos.toIrrVector() )); From c1d6c054c8af02c17705f1eb49314c0980685846 Mon Sep 17 00:00:00 2001 From: Marianne Gagnon Date: Sat, 4 Oct 2014 19:38:44 -0400 Subject: [PATCH 39/42] Route a few more controls rendering through the skin, to make them use OpenGL 3 --- lib/irrlicht/source/Irrlicht/CGUIButton.cpp | 2 +- lib/irrlicht/source/Irrlicht/CGUIImage.cpp | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/irrlicht/source/Irrlicht/CGUIButton.cpp b/lib/irrlicht/source/Irrlicht/CGUIButton.cpp index d4e6d9a91..74c335a35 100644 --- a/lib/irrlicht/source/Irrlicht/CGUIButton.cpp +++ b/lib/irrlicht/source/Irrlicht/CGUIButton.cpp @@ -277,7 +277,7 @@ void CGUIButton::draw() pos.X += skin->getSize(EGDS_BUTTON_PRESSED_IMAGE_OFFSET_X); pos.Y += skin->getSize(EGDS_BUTTON_PRESSED_IMAGE_OFFSET_Y); } - driver->draw2DImage(PressedImage, + skin->draw2DImage(PressedImage, ScaleImage? AbsoluteRect : core::recti(pos, PressedImageRect.getSize()), PressedImageRect, &AbsoluteClippingRect, diff --git a/lib/irrlicht/source/Irrlicht/CGUIImage.cpp b/lib/irrlicht/source/Irrlicht/CGUIImage.cpp index 17d30e0ec..184a6e5cc 100644 --- a/lib/irrlicht/source/Irrlicht/CGUIImage.cpp +++ b/lib/irrlicht/source/Irrlicht/CGUIImage.cpp @@ -78,20 +78,20 @@ void CGUIImage::draw() if (Texture) { - if (ScaleImage) - { + //if (ScaleImage) + //{ const video::SColor Colors[] = {Color,Color,Color,Color}; - driver->draw2DImage(Texture, AbsoluteRect, + skin->draw2DImage(Texture, AbsoluteRect, core::rect(core::position2d(0,0), core::dimension2di(Texture->getOriginalSize())), &AbsoluteClippingRect, Colors, UseAlphaChannel); - } - else - { - driver->draw2DImage(Texture, AbsoluteRect.UpperLeftCorner, - core::rect(core::position2d(0,0), core::dimension2di(Texture->getOriginalSize())), - &AbsoluteClippingRect, Color, UseAlphaChannel); - } + //} + //else + //{ + // driver->draw2DImage(Texture, AbsoluteRect.UpperLeftCorner, + // core::rect(core::position2d(0,0), core::dimension2di(Texture->getOriginalSize())), + // &AbsoluteClippingRect, Color, UseAlphaChannel); + //} } else { From 83b25768cc8910d6378443f29c75317f08952cd0 Mon Sep 17 00:00:00 2001 From: Marianne Gagnon Date: Sat, 4 Oct 2014 19:44:04 -0400 Subject: [PATCH 40/42] tweak players screen, checkbox placement was weird --- data/gui/user_screen.stkgui | 10 ++++++---- data/gui/user_screen_tab.stkgui | 12 +++++++----- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/data/gui/user_screen.stkgui b/data/gui/user_screen.stkgui index acb65467f..0a7d83e31 100644 --- a/data/gui/user_screen.stkgui +++ b/data/gui/user_screen.stkgui @@ -13,15 +13,17 @@ square_items="true" child_width="128" child_height="128" /> -
+
-
-