From 7ae541e63855e42f271706e90b71025fd2d9f95e Mon Sep 17 00:00:00 2001 From: Deve Date: Sun, 9 Aug 2015 13:12:20 +0200 Subject: [PATCH 01/12] Reload selected GP after changing the name. This fixes #2159 --- src/states_screens/grand_prix_editor_screen.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/states_screens/grand_prix_editor_screen.cpp b/src/states_screens/grand_prix_editor_screen.cpp index 5d0184304..0080837a4 100644 --- a/src/states_screens/grand_prix_editor_screen.cpp +++ b/src/states_screens/grand_prix_editor_screen.cpp @@ -291,6 +291,7 @@ void GrandPrixEditorScreen::onNewGPWithName(const stringw& newName) { m_selection->setName(newName); m_selection->writeToFile(); + setSelection(grand_prix_manager->getGrandPrix(m_selection->getId())); } else if (m_action == "new") { From 78cd8efdd4bd0ae3f12d666a0b6c12d8b889de67 Mon Sep 17 00:00:00 2001 From: Deve Date: Sun, 9 Aug 2015 18:54:59 +0200 Subject: [PATCH 02/12] Reset screensaver counter on linux when joystick event was received --- .../source/Irrlicht/CIrrDeviceLinux.cpp | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.cpp b/lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.cpp index e29a109f0..e48ac2b1d 100644 --- a/lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.cpp +++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.cpp @@ -2081,11 +2081,13 @@ void CIrrDeviceLinux::pollJoysticks() for (u32 j= 0; j< ActiveJoysticks.size(); ++j) { JoystickInfo & info = ActiveJoysticks[j]; + bool event_received = false; #ifdef __FreeBSD__ struct joystick js; if (read(info.fd, &js, sizeof(js)) == sizeof(js)) { + event_received = true; info.persistentData.JoystickEvent.ButtonStates = js.b1 | (js.b2 << 1); /* should be a two-bit field */ info.persistentData.JoystickEvent.Axis[0] = js.x; /* X axis */ info.persistentData.JoystickEvent.Axis[1] = js.y; /* Y axis */ @@ -2098,14 +2100,23 @@ void CIrrDeviceLinux::pollJoysticks() { case JS_EVENT_BUTTON: if (event.value) - info.persistentData.JoystickEvent.ButtonStates |= (1 << event.number); + { + event_received = true; + info.persistentData.JoystickEvent.ButtonStates |= (1 << event.number); + } else - info.persistentData.JoystickEvent.ButtonStates &= ~(1 << event.number); + { + event_received = true; + info.persistentData.JoystickEvent.ButtonStates &= ~(1 << event.number); + } break; case JS_EVENT_AXIS: if (event.number < SEvent::SJoystickEvent::NUMBER_OF_AXES) + { + event_received = true; info.persistentData.JoystickEvent.Axis[event.number] = event.value; + } break; default: @@ -2116,6 +2127,13 @@ void CIrrDeviceLinux::pollJoysticks() // Send an irrlicht joystick event once per ::run() even if no new data were received. (void)postEventFromUser(info.persistentData); + +#ifdef _IRR_COMPILE_WITH_X11_ + if (event_received) + { + XResetScreenSaver(display); + } +#endif } #endif // _IRR_COMPILE_WITH_JOYSTICK_EVENTS_ } From fe1222c5cce5b743ce57262bad8a8382b9c77a14 Mon Sep 17 00:00:00 2001 From: Deve Date: Sun, 9 Aug 2015 20:52:12 +0200 Subject: [PATCH 03/12] Don't add tracks in reversed mode when it's not available. This fixes #2158. --- src/states_screens/edit_gp_screen.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/states_screens/edit_gp_screen.cpp b/src/states_screens/edit_gp_screen.cpp index 8cd5e00f1..1bdffae1c 100644 --- a/src/states_screens/edit_gp_screen.cpp +++ b/src/states_screens/edit_gp_screen.cpp @@ -171,16 +171,19 @@ void EditGPScreen::init() if (edit->getResult()) { + bool reverse = edit->getTrack()->reverseAvailable() ? + edit->getReverse() : false; + if (m_action == "add") { - m_gp->addTrack(edit->getTrack(), edit->getLaps(), edit->getReverse(), - m_selected); + m_gp->addTrack(edit->getTrack(), edit->getLaps(), reverse, + m_selected); setSelected(m_selected + 1); } else if (m_action == "edit") { m_gp->editTrack(m_selected, edit->getTrack(), edit->getLaps(), - edit->getReverse()); + reverse); } setModified(true); } From d488c043d18b8f4e2ddc4eb6a7ef19ea79c8c90d Mon Sep 17 00:00:00 2001 From: Marianne Gagnon Date: Sun, 9 Aug 2015 21:38:01 -0400 Subject: [PATCH 04/12] Continue work on scripting, fixing #2268. Use this as an opportunity to clean up a lot of old hardcoded overworld code, and replace it with cleaner scripting. Make sure to update SVN and the exporter (other commits in SVN coming soon) --- src/audio/sfx_manager.cpp | 3 +- src/karts/kart.cpp | 23 ---- src/modes/overworld.cpp | 23 +++- src/modes/world.cpp | 2 - src/physics/physical_object.cpp | 9 +- src/scriptengine/script_challenges.cpp | 46 ++++++- src/scriptengine/script_gui.cpp | 27 +++- src/scriptengine/script_track.cpp | 84 ++++++++++-- src/states_screens/race_gui_overworld.cpp | 17 ++- src/tracks/track.cpp | 159 +--------------------- src/tracks/track.hpp | 45 +----- src/tracks/track_object.cpp | 89 ++++++++++-- src/tracks/track_object.hpp | 5 +- src/tracks/track_object_manager.cpp | 6 +- src/tracks/track_object_presentation.cpp | 10 ++ src/tracks/track_object_presentation.hpp | 6 + 16 files changed, 278 insertions(+), 276 deletions(-) diff --git a/src/audio/sfx_manager.cpp b/src/audio/sfx_manager.cpp index 9d96ee09e..fb66679be 100644 --- a/src/audio/sfx_manager.cpp +++ b/src/audio/sfx_manager.cpp @@ -978,7 +978,8 @@ SFXBase* SFXManager::quickSound(const std::string &sound_type) else { SFXBase *base_sound = sound->second; - base_sound->play(); + if (base_sound->getStatus() != SFXBase::SFX_PLAYING) + base_sound->play(); return base_sound; } diff --git a/src/karts/kart.cpp b/src/karts/kart.cpp index 6012a0a0b..973430bad 100644 --- a/src/karts/kart.cpp +++ b/src/karts/kart.cpp @@ -1880,29 +1880,6 @@ void Kart::crashed(const Material *m, const Vec3 &normal) push[1] = 0.1f; m_body->applyCentralImpulse( -4000.0f*push ); m_bounce_back_time = 2.0f; - - core::stringw msg = _("You need more points\n" - "to enter this challenge!\n" - "Check the minimap for\n" - "available challenges."); - std::vector parts = - StringUtils::split(msg, '\n', false); - - // For now, until we have scripting, special-case - // the overworld... (TODO) - if (dynamic_cast(World::getWorld()) != NULL) - { - SFXManager::get()->quickSound("forcefield"); - World::getWorld()->getRaceGUI()->clearAllMessages(); - - for (unsigned int n = 0; n < parts.size(); n++) - { - World::getWorld()->getRaceGUI() - ->addMessage(parts[n], NULL, 4.0f, - video::SColor(255, 255,255,255), - true, true); - } // for ngetCollisionReaction() == Material::PUSH_BACK) } // if(m && m->getCollisionReaction() != Material::NORMAL && diff --git a/src/modes/overworld.cpp b/src/modes/overworld.cpp index ba7e7df2d..3a666d7f3 100644 --- a/src/modes/overworld.cpp +++ b/src/modes/overworld.cpp @@ -224,10 +224,6 @@ void OverWorld::onFirePressed(Controller* who) for (unsigned int n=0; nsetKartLastPositionOnOverworld(kart_xyz); - new SelectChallengeDialog(0.8f, 0.8f, - challenges[n].m_challenge_id); + const ChallengeData* challenge = unlock_manager->getChallengeData(challenges[n].m_challenge_id); + if (challenge == NULL) + { + Log::error("track", "Cannot find challenge named '%s'\n", + challenges[n].m_challenge_id.c_str()); + continue; + } + + const unsigned int val = challenge->getNumTrophies(); + bool unlocked = (PlayerManager::getCurrentPlayer()->getPoints() >= val); + if (unlocked) + { + race_manager->setKartLastPositionOnOverworld(kart_xyz); + new SelectChallengeDialog(0.8f, 0.8f, + challenges[n].m_challenge_id); + } } } // end if } // end for diff --git a/src/modes/world.cpp b/src/modes/world.cpp index 4224b1763..e73b1ac64 100644 --- a/src/modes/world.cpp +++ b/src/modes/world.cpp @@ -211,8 +211,6 @@ void World::init() m_weather = new Weather(m_track->getWeatherLightning(), m_track->getWeatherSound()); } - - m_script_engine->compileLoadedScripts(); } // init //----------------------------------------------------------------------------- diff --git a/src/physics/physical_object.cpp b/src/physics/physical_object.cpp index c8d0e2b4b..28cd58d97 100644 --- a/src/physics/physical_object.cpp +++ b/src/physics/physical_object.cpp @@ -129,7 +129,7 @@ PhysicalObject::PhysicalObject(bool is_dynamic, m_object = object; - m_init_xyz = object->getAbsolutePosition(); + m_init_xyz = object->getAbsoluteCenterPosition(); m_init_hpr = object->getRotation(); m_init_scale = object->getScale(); @@ -461,8 +461,11 @@ void PhysicalObject::init() // 2. Create the rigid object // -------------------------- // m_init_pos is the point on the track - add the offset - m_init_pos.setOrigin(m_init_pos.getOrigin() + - btVector3(0,extend.getY()*0.5f, 0)); + if (m_is_dynamic) + { + m_init_pos.setOrigin(m_init_pos.getOrigin() + + btVector3(0, extend.getY()*0.5f, 0)); + } m_motion_state = new btDefaultMotionState(m_init_pos); btVector3 inertia(1,1,1); if (m_body_type != MP_EXACT) diff --git a/src/scriptengine/script_challenges.cpp b/src/scriptengine/script_challenges.cpp index 10d7b0bf1..43e90d0e8 100644 --- a/src/scriptengine/script_challenges.cpp +++ b/src/scriptengine/script_challenges.cpp @@ -19,10 +19,14 @@ #include "script_track.hpp" #include "animations/three_d_animation.hpp" -#include "input/device_manager.hpp" -#include "input/input_device.hpp" -#include "input/input_manager.hpp" +#include "challenges/unlock_manager.hpp" +#include "graphics/central_settings.hpp" +#include "graphics/irr_driver.hpp" +#include "graphics/stk_text_billboard.hpp" +#include "guiengine/engine.hpp" +#include "guiengine/scalable_font.hpp" #include "modes/world.hpp" +#include "config/player_manager.hpp" #include "states_screens/dialogs/tutorial_message_dialog.hpp" #include "tracks/track.hpp" #include "tracks/track_object.hpp" @@ -30,6 +34,8 @@ #include #include +#include +#include /** \cond DOXYGEN_IGNORE */ namespace Scripting @@ -58,6 +64,38 @@ namespace Scripting return track->getChallengeList().size(); } + int getChallengeRequiredPoints(std::string* challenge_name) + { + ::Track* track = World::getWorld()->getTrack(); + const ChallengeData* challenge = unlock_manager->getChallengeData(*challenge_name); + if (challenge == NULL) + { + if (*challenge_name != "tutorial") + Log::error("track", "Cannot find challenge named '%s'\n", + challenge_name->c_str()); + return false; + } + + return challenge->getNumTrophies(); + } + + bool isChallengeUnlocked(std::string* challenge_name) + { + ::Track* track = World::getWorld()->getTrack(); + const ChallengeData* challenge = unlock_manager->getChallengeData(*challenge_name); + if (challenge == NULL) + { + if (*challenge_name != "tutorial") + Log::error("track", "Cannot find challenge named '%s'\n", + challenge_name->c_str()); + return false; + } + + const unsigned int val = challenge->getNumTrophies(); + bool shown = (PlayerManager::getCurrentPlayer()->getPoints() >= val); + return shown; + } + /** @}*/ /** @}*/ @@ -69,6 +107,8 @@ namespace Scripting r = engine->RegisterGlobalFunction("int getCompletedChallengesCount()", asFUNCTION(getCompletedChallengesCount), asCALL_CDECL); assert(r >= 0); r = engine->RegisterGlobalFunction("int getChallengeCount()", asFUNCTION(getChallengeCount), asCALL_CDECL); assert(r >= 0); + r = engine->RegisterGlobalFunction("bool isChallengeUnlocked(string &in)", asFUNCTION(isChallengeUnlocked), asCALL_CDECL); assert(r >= 0); + r = engine->RegisterGlobalFunction("int getChallengeRequiredPoints(string &in)", asFUNCTION(getChallengeRequiredPoints), asCALL_CDECL); assert(r >= 0); } } diff --git a/src/scriptengine/script_gui.cpp b/src/scriptengine/script_gui.cpp index 783351819..af3fb494a 100644 --- a/src/scriptengine/script_gui.cpp +++ b/src/scriptengine/script_gui.cpp @@ -61,12 +61,33 @@ namespace Scripting } /** Show the specified message in a popup */ - void displayMessage(std::string* input) + void displayModalMessage(std::string* input) { irr::core::stringw out = StringUtils::utf8_to_wide(input->c_str()); new TutorialMessageDialog((out), true); } + void clearOverlayMessages() + { + World::getWorld()->getRaceGUI()->clearAllMessages(); + } + + /** Display text in the center of the screen for a few seconds */ + void displayOverlayMessage(std::string* input) + { + irr::core::stringw msg = StringUtils::utf8_to_wide(input->c_str()); + std::vector parts = + StringUtils::split(msg, '\n', false); + + for (unsigned int n = 0; n < parts.size(); n++) + { + World::getWorld()->getRaceGUI() + ->addMessage(parts[n], NULL, 4.0f, + video::SColor(255, 255,255,255), + true, true); + } // for nSetDefaultNamespace("GUI"); - r = engine->RegisterGlobalFunction("void displayMessage(const string &in)", asFUNCTION(displayMessage), asCALL_CDECL); assert(r >= 0); + r = engine->RegisterGlobalFunction("void displayModalMessage(const string &in)", asFUNCTION(displayModalMessage), asCALL_CDECL); assert(r >= 0); + r = engine->RegisterGlobalFunction("void displayOverlayMessage(const string &in)", asFUNCTION(displayOverlayMessage), asCALL_CDECL); assert(r >= 0); + r = engine->RegisterGlobalFunction("void clearOverlayMessages()", asFUNCTION(clearOverlayMessages), asCALL_CDECL); assert(r >= 0); r = engine->RegisterGlobalFunction("string getKeyBinding(int input)", asFUNCTION(getKeyBinding), asCALL_CDECL); assert(r >= 0); r = engine->RegisterGlobalFunction("string translate(const string &in)", asFUNCTION(proxy_translate), asCALL_CDECL); assert(r >= 0); r = engine->RegisterGlobalFunction("string translate(const string &in, const string &in)", asFUNCTION(proxy_translateAndInsertValues1), asCALL_CDECL); assert(r >= 0); diff --git a/src/scriptengine/script_track.cpp b/src/scriptengine/script_track.cpp index 055389275..b909802fb 100644 --- a/src/scriptengine/script_track.cpp +++ b/src/scriptengine/script_track.cpp @@ -19,6 +19,9 @@ #include "script_track.hpp" #include "animations/three_d_animation.hpp" +#include "graphics/central_settings.hpp" +#include "graphics/stk_text_billboard.hpp" +#include "guiengine/scalable_font.hpp" #include "input/device_manager.hpp" #include "input/input_device.hpp" #include "input/input_manager.hpp" @@ -29,8 +32,10 @@ #include "tracks/track_object.hpp" #include "tracks/track_object_manager.hpp" +#include #include #include +#include /** \cond DOXYGEN_IGNORE */ namespace Scripting @@ -57,13 +62,13 @@ namespace Scripting * Get a track object by ID. * @return An object of type @ref Scripting_TrackObject */ - TrackObject* getTrackObject(std::string* libraryInstance, std::string* objID) + ::TrackObject* getTrackObject(std::string* libraryInstance, std::string* objID) { return World::getWorld()->getTrack()->getTrackObjectManager()->getTrackObject(*libraryInstance, *objID); } /** Creates a trigger at the specified location */ - void createTrigger(std::string* triggerID, Vec3* creation_loc, float distance) + void createTrigger(std::string* triggerID, SimpleVec3* creation_loc, float distance) { float x = creation_loc->getX(); float y = creation_loc->getY(); @@ -73,12 +78,51 @@ namespace Scripting core::vector3df scale(1.0f, 1.0f, 1.0f); TrackObjectPresentationActionTrigger* newtrigger = new TrackObjectPresentationActionTrigger(posi, *triggerID, distance); - TrackObject* tobj = new TrackObject(posi, hpr, scale, + ::TrackObject* tobj = new ::TrackObject(posi, hpr, scale, "none", newtrigger, false /* isDynamic */, NULL /* physics settings */); tobj->setID(*triggerID); World::getWorld()->getTrack()->getTrackObjectManager()->insertObject(tobj); } + void createTextBillboard(std::string* text, SimpleVec3* location) + { + core::stringw wtext = StringUtils::utf8_to_wide(text->c_str()); + core::dimension2d textsize = GUIEngine::getHighresDigitFont() + ->getDimension(wtext.c_str()); + + assert(GUIEngine::getHighresDigitFont() != NULL); + + core::vector3df xyz(location->getX(), location->getY(), location->getZ()); + + if (CVS->isGLSL()) + { + gui::ScalableFont* font = GUIEngine::getHighresDigitFont(); + STKTextBillboard* tb = new STKTextBillboard(wtext.c_str(), font, + video::SColor(255, 255, 225, 0), + video::SColor(255, 255, 89, 0), + irr_driver->getSceneManager()->getRootSceneNode(), + irr_driver->getSceneManager(), -1, xyz, + core::vector3df(1.5f, 1.5f, 1.5f)); + + World::getWorld()->getTrack()->addNode(tb); + } + else + { + scene::ISceneManager* sm = irr_driver->getSceneManager(); + scene::ISceneNode* sn = + sm->addBillboardTextSceneNode(GUIEngine::getHighresDigitFont(), + wtext.c_str(), + NULL, + core::dimension2df(textsize.Width / 35.0f, + textsize.Height / 35.0f), + xyz, + -1, // id + video::SColor(255, 255, 225, 0), + video::SColor(255, 255, 89, 0)); + World::getWorld()->getTrack()->addNode(sn); + } + } + /** Exits the race to the main menu */ void exitRace() { @@ -96,6 +140,21 @@ namespace Scripting { /** \endcond */ + namespace TrackObject + { + SimpleVec3 getCenterPosition(::TrackObject* obj) + { + core::vector3df pos = obj->getAbsoluteCenterPosition(); + return SimpleVec3(pos.X, pos.Y, pos.Z); + } + + SimpleVec3 getOrigin(::TrackObject* obj) + { + core::vector3df pos = obj->getAbsolutePosition(); + return SimpleVec3(pos.X, pos.Y, pos.Z); + } + } + // ----------- TrackObjectPresentationMesh methods ----------- // TODO: this method is WRONG, we should in most cases move not the presentation but the entire object //void movePresentation(Vec3 *new_pos, void *memory) @@ -237,19 +296,22 @@ namespace Scripting //r = engine->RegisterGlobalFunction("void disableTrigger(const string &in)", asFUNCTION(disableTrigger), asCALL_CDECL); assert(r >= 0); r = engine->RegisterGlobalFunction("void createTrigger(const string &in, const Vec3 &in, float distance)", asFUNCTION(createTrigger), asCALL_CDECL); assert(r >= 0); + r = engine->RegisterGlobalFunction("void createTextBillboard(const string &in, const Vec3 &in)", + asFUNCTION(createTextBillboard), asCALL_CDECL); assert(r >= 0); r = engine->RegisterGlobalFunction("TrackObject@ getTrackObject(const string &in, const string &in)", asFUNCTION(getTrackObject), asCALL_CDECL); assert(r >= 0); r = engine->RegisterGlobalFunction("void exitRace()", asFUNCTION(exitRace), asCALL_CDECL); assert(r >= 0); r = engine->RegisterGlobalFunction("void pauseRace()", asFUNCTION(pauseRace), asCALL_CDECL); assert(r >= 0); // TrackObject - r = engine->RegisterObjectMethod("TrackObject", "void setEnabled(bool status)", asMETHOD(TrackObject, setEnabled), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("TrackObject", "SoundEmitter@ getSoundEmitter()", asMETHOD(TrackObject, getSoundEmitter), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("TrackObject", "PhysicalObject@ getPhysics()", asMETHOD(TrackObject, getPhysics), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("TrackObject", "Mesh@ getMesh()", asMETHOD(TrackObject, getMesh), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("TrackObject", "ParticleEmitter@ getParticleEmitter()", asMETHOD(TrackObject, getParticleEmitter), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("TrackObject", "Animator@ getIPOAnimator()", asMETHOD(TrackObject, getIPOAnimator), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("TrackObject", "void moveTo(const Vec3 &in, bool)", asMETHOD(TrackObject, moveTo), asCALL_THISCALL); assert(r >= 0); - + r = engine->RegisterObjectMethod("TrackObject", "void setEnabled(bool status)", asMETHOD(::TrackObject, setEnabled), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("TrackObject", "SoundEmitter@ getSoundEmitter()", asMETHOD(::TrackObject, getSoundEmitter), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("TrackObject", "PhysicalObject@ getPhysics()", asMETHOD(::TrackObject, getPhysics), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("TrackObject", "Mesh@ getMesh()", asMETHOD(::TrackObject, getMesh), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("TrackObject", "ParticleEmitter@ getParticleEmitter()", asMETHOD(::TrackObject, getParticleEmitter), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("TrackObject", "Animator@ getIPOAnimator()", asMETHOD(::TrackObject, getIPOAnimator), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("TrackObject", "void moveTo(const Vec3 &in, bool)", asMETHOD(::TrackObject, moveTo), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("TrackObject", "Vec3 getCenterPosition()", asFUNCTION(TrackObject::getCenterPosition), asCALL_CDECL_OBJLAST); assert(r >= 0); + r = engine->RegisterObjectMethod("TrackObject", "Vec3 getOrigin()", asFUNCTION(TrackObject::getOrigin), asCALL_CDECL_OBJLAST); assert(r >= 0); // PhysicalObject r = engine->RegisterObjectMethod("PhysicalObject", "bool isFlattenKartObject()", asMETHOD(PhysicalObject, isFlattenKartObject), asCALL_THISCALL); assert(r >= 0); diff --git a/src/states_screens/race_gui_overworld.cpp b/src/states_screens/race_gui_overworld.cpp index d222b5857..fb90fc867 100644 --- a/src/states_screens/race_gui_overworld.cpp +++ b/src/states_screens/race_gui_overworld.cpp @@ -399,9 +399,10 @@ void RaceGUIOverworld::drawGlobalMiniMap() Vec3 draw_at; track->mapPoint2MiniMap(challenges[n].m_position, &draw_at); - //const ChallengeData* c = unlock_manager->getChallenge(challenges[n].m_challenge_id); - // bool locked = (m_locked_challenges.find(c) != m_locked_challenges.end()); - int state = (challenges[n].getForceField().m_is_locked ? LOCKED : OPEN); + const ChallengeData* challenge = unlock_manager->getChallengeData(challenges[n].m_challenge_id); + const unsigned int val = challenge->getNumTrophies(); + bool unlocked = (PlayerManager::getCurrentPlayer()->getPoints() >= val); + int state = (unlocked ? OPEN : LOCKED); const ChallengeStatus* c = PlayerManager::getCurrentPlayer() ->getChallengeStatus(challenges[n].m_challenge_id); @@ -441,8 +442,14 @@ void RaceGUIOverworld::drawGlobalMiniMap() m_close_to_a_challenge = false; for (unsigned int n=0; ngetChallengeData(challenges[n].m_challenge_id); + const unsigned int val = challenge->getNumTrophies(); + bool unlocked = (PlayerManager::getCurrentPlayer()->getPoints() >= val); + if (!unlocked) + continue; + } if ((kart_xyz - Vec3(challenges[n].m_position)).length2_2d() < CHALLENGE_DISTANCE_SQUARED && fabsf(kart_xyz[1] - challenges[n].m_position.Y) < CHALLENGE_HEIGHT) diff --git a/src/tracks/track.cpp b/src/tracks/track.cpp index 73811b94d..37a96e59d 100644 --- a/src/tracks/track.cpp +++ b/src/tracks/track.cpp @@ -988,7 +988,6 @@ bool Track::loadMainTrack(const XMLNode &root) assert(m_gfx_effect_mesh==NULL); m_challenges.clear(); - m_force_fields.clear(); m_track_mesh = new TriangleMesh(); m_gfx_effect_mesh = new TriangleMesh(); @@ -1117,7 +1116,6 @@ bool Track::loadMainTrack(const XMLNode &root) continue; } - core::vector3df xyz(0,0,0); n->get("xyz", &xyz); core::vector3df hpr(0,0,0); @@ -1125,117 +1123,6 @@ bool Track::loadMainTrack(const XMLNode &root) core::vector3df scale(1.0f, 1.0f, 1.0f); n->get("scale", &scale); - // some static meshes are conditional - std::string condition; - n->get("if", &condition); - - // TODO: convert "if" and "ifnot" to scripting. - if (condition == "splatting") - { - if (!irr_driver->supportsSplatting()) continue; - } - else if (condition == "trophies") - { - // Associate force fields and challenges - // FIXME: this assumes that challenges will appear before force fields in scene.xml - // (which however seems to be the case atm) - int closest_challenge_id = -1; - float closest_distance = 99999.0f; - for (unsigned int c=0; c= 0); - assert(closest_challenge_id < (int)m_challenges.size()); - - const std::string &s = m_challenges[closest_challenge_id].m_challenge_id; - const ChallengeData* challenge = unlock_manager->getChallengeData(s); - if (challenge == NULL) - { - if (s != "tutorial") - Log::error("track", "Cannot find challenge named '%s'\n", - m_challenges[closest_challenge_id].m_challenge_id.c_str()); - continue; - } - - const unsigned int val = challenge->getNumTrophies(); - bool shown = (PlayerManager::getCurrentPlayer()->getPoints() < val); - m_force_fields.push_back(OverworldForceField(xyz, shown, val)); - - m_challenges[closest_challenge_id].setForceField( - m_force_fields[m_force_fields.size() - 1]); - - core::stringw msg = StringUtils::toWString(val); - core::dimension2d textsize = GUIEngine::getHighresDigitFont() - ->getDimension(msg.c_str()); - - assert(GUIEngine::getHighresDigitFont() != NULL); - - if (CVS->isGLSL()) - { - gui::ScalableFont* font = GUIEngine::getHighresDigitFont(); - STKTextBillboard* tb = new STKTextBillboard(msg.c_str(), font, - video::SColor(255, 255, 225, 0), - video::SColor(255, 255, 89, 0), - irr_driver->getSceneManager()->getRootSceneNode(), - irr_driver->getSceneManager(), -1, xyz, - core::vector3df(1.5f, 1.5f, 1.5f)); - m_all_nodes.push_back(tb); - } - else - { - scene::ISceneManager* sm = irr_driver->getSceneManager(); - scene::ISceneNode* sn = - sm->addBillboardTextSceneNode(GUIEngine::getHighresDigitFont(), - msg.c_str(), - NULL, - core::dimension2df(textsize.Width / 35.0f, - textsize.Height / 35.0f), - xyz, - -1, // id - video::SColor(255, 255, 225, 0), - video::SColor(255, 255, 89, 0)); - m_all_nodes.push_back(sn); - } - - if (!shown) continue; - } - else if (condition.size() > 0) - { - unsigned char result = -1; - Scripting::ScriptEngine* script_engine = World::getWorld()->getScriptEngine(); - std::function null_callback; - script_engine->runFunction(true, "bool " + condition + "()", null_callback, - [&](asIScriptContext* ctx) { result = ctx->GetReturnByte(); }); - if (result == 0) - continue; - } - - std::string neg_condition; - n->get("ifnot", &neg_condition); - if (neg_condition == "splatting") - { - if (irr_driver->supportsSplatting()) continue; - } - else if (neg_condition.size() > 0) - { - unsigned char result = -1; - Scripting::ScriptEngine* script_engine = World::getWorld()->getScriptEngine(); - std::function null_callback; - script_engine->runFunction(true, "bool " + neg_condition + "()", null_callback, - [&](asIScriptContext* ctx) { result = ctx->GetReturnByte(); }); - if (result != 0) - continue; - } - - bool tangent = false; n->get("tangents", &tangent); @@ -1253,49 +1140,6 @@ bool Track::loadMainTrack(const XMLNode &root) bool lod_instance = false; n->get("lod_instance", &lod_instance); - /* - if (tangent) - { - scene::IMesh* original_mesh = irr_driver->getMesh(full_path); - - if (std::find(m_detached_cached_meshes.begin(), - m_detached_cached_meshes.end(), - original_mesh) == m_detached_cached_meshes.end()) - { - m_detached_cached_meshes.push_back(original_mesh); - } - - // create a node out of this mesh just for bullet; delete it after, normal maps are special - // and require tangent meshes - scene_node = irr_driver->addMesh(original_mesh, "original_mesh"); - - scene_node->setPosition(xyz); - scene_node->setRotation(hpr); - scene_node->setScale(scale); - - convertTrackToBullet(scene_node); - scene_node->remove(); - irr_driver->grabAllTextures(original_mesh); - - scene::IMesh* mesh = MeshTools::createMeshWithTangents(original_mesh, &MeshTools::isNormalMap); - mesh->grab(); - irr_driver->grabAllTextures(mesh); - - m_all_cached_meshes.push_back(mesh); - scene_node = irr_driver->addMesh(mesh, "original_mesh_with_tangents"); - scene_node->setPosition(xyz); - scene_node->setRotation(hpr); - scene_node->setScale(scale); - -#ifdef DEBUG - std::string debug_name = model_name+" (tangent static track-object)"; - scene_node->setName(debug_name.c_str()); -#endif - - handleAnimatedTextures(scene_node, *n); - m_all_nodes.push_back( scene_node ); - } - else*/ if (lod_instance) { LODNode* node = lodLoader.instanciateAsLOD(n, NULL); @@ -1345,6 +1189,7 @@ bool Track::loadMainTrack(const XMLNode &root) handleAnimatedTextures(scene_node, *n); // for challenge orbs, a bit more work to do + // TODO: this is hardcoded for the overworld, convert to scripting if (challenge.size() > 0) { const ChallengeData* c = NULL; @@ -1810,6 +1655,8 @@ void Track::loadTrackModel(bool reverse_track, unsigned int mode_id) model_def_loader.cleanLibraryNodesAfterLoad(); + World::getWorld()->getScriptEngine()->compileLoadedScripts(); + // Init all track objects m_track_object_manager->init(); diff --git a/src/tracks/track.hpp b/src/tracks/track.hpp index 5ac4daa79..9f35487d0 100644 --- a/src/tracks/track.hpp +++ b/src/tracks/track.hpp @@ -69,30 +69,10 @@ namespace Scripting const int HEIGHT_MAP_RESOLUTION = 256; -struct OverworldForceField -{ - core::vector3df m_position; - bool m_is_locked; - int m_required_points; - - OverworldForceField() - { - } - - OverworldForceField(core::vector3df position, bool is_locked, int required_points) - { - m_position = position; - m_is_locked = is_locked; - m_required_points = required_points; - } -}; +// TODO: eventually remove this and fully replace with scripting struct OverworldChallenge { -private: - OverworldForceField m_force_field; - bool m_force_field_set; public: - core::vector3df m_position; std::string m_challenge_id; @@ -100,27 +80,6 @@ public: { m_position = position; m_challenge_id = challenge_id; - m_force_field_set = false; - } - - void setForceField(OverworldForceField f) - { - m_force_field = f; - m_force_field_set = true; - } - - OverworldForceField& getForceField() - { - assert(m_force_field_set); - return m_force_field; - } - - bool isForceFieldSet() const { return m_force_field_set; } - - const OverworldForceField& getForceField() const - { - assert(m_force_field_set); - return m_force_field; } }; @@ -160,8 +119,6 @@ private: /** Will only be used on overworld */ std::vector m_challenges; - std::vector m_force_fields; - std::vector m_subtitles; /** Start transforms of karts (either the default, or the ones taken diff --git a/src/tracks/track_object.cpp b/src/tracks/track_object.cpp index b407979b6..5e9e054be 100644 --- a/src/tracks/track_object.cpp +++ b/src/tracks/track_object.cpp @@ -131,23 +131,11 @@ void TrackObject::init(const XMLNode &xml_node, scene::ISceneNode* parent, m_type = type; m_initially_visible = true; - std::string condition; - xml_node.get("if", &condition); - if (condition == "false") + xml_node.get("if", &m_visibility_condition); + if (m_visibility_condition == "false") { m_initially_visible = false; } - else if (condition.size() > 0) - { - unsigned char result = -1; - Scripting::ScriptEngine* script_engine = World::getWorld()->getScriptEngine(); - std::function null_callback; - script_engine->runFunction(true, "bool " + condition + "()", null_callback, - [&](asIScriptContext* ctx) { result = ctx->GetReturnByte(); }); - - if (result == 0) - m_initially_visible = false; - } if (!m_initially_visible) setEnabled(false); @@ -295,6 +283,68 @@ void TrackObject::init(const XMLNode &xml_node, scene::ISceneNode* parent, // ---------------------------------------------------------------------------- +void TrackObject::onWorldReady() +{ + if (m_visibility_condition == "false") + { + m_initially_visible = false; + } + else if (m_visibility_condition.size() > 0) + { + unsigned char result = -1; + Scripting::ScriptEngine* script_engine = World::getWorld()->getScriptEngine(); + + std::ostringstream fn_signature; + std::vector arguments; + if (m_visibility_condition.find("(") != std::string::npos && + m_visibility_condition.find(")") != std::string::npos) + { + // There are arguments to pass to the function + // TODO: For the moment we only support string arguments + // TODO: this parsing could be improved + unsigned first = m_visibility_condition.find("("); + unsigned last = m_visibility_condition.find_last_of(")"); + std::string fn_name = m_visibility_condition.substr(0, first); + std::string str_arguments = m_visibility_condition.substr(first + 1, last - first - 1); + arguments = StringUtils::split(str_arguments, ','); + + fn_signature << "bool " << fn_name << "("; + + for (int i = 0; i < arguments.size(); i++) + { + if (i > 0) + fn_signature << ","; + fn_signature << "string"; + } + + fn_signature << ",Track::TrackObject@)"; + } + else + { + fn_signature << "bool " << m_visibility_condition << "(Track::TrackObject@)"; + } + + TrackObject* self = this; + script_engine->runFunction(true, fn_signature.str(), + [&](asIScriptContext* ctx) + { + for (int i = 0; i < arguments.size(); i++) + { + ctx->SetArgObject(i, &arguments[i]); + } + ctx->SetArgObject(arguments.size(), self); + }, + [&](asIScriptContext* ctx) { result = ctx->GetReturnByte(); }); + + if (result == 0) + m_initially_visible = false; + } + if (!m_initially_visible) + setEnabled(false); +} + +// ---------------------------------------------------------------------------- + /** Destructor. Removes the node from the scene graph, and also * drops the textures of the mesh. Sound buffers are also freed. */ @@ -456,6 +506,17 @@ const core::vector3df& TrackObject::getPosition() const return m_init_xyz; } // getPosition +// ---------------------------------------------------------------------------- + +const core::vector3df TrackObject::getAbsoluteCenterPosition() const +{ + if (m_presentation != NULL) + return m_presentation->getAbsoluteCenterPosition(); + else + return m_init_xyz; +} // getAbsolutePosition + + // ---------------------------------------------------------------------------- const core::vector3df TrackObject::getAbsolutePosition() const diff --git a/src/tracks/track_object.hpp b/src/tracks/track_object.hpp index 9252a4180..88e629080 100644 --- a/src/tracks/track_object.hpp +++ b/src/tracks/track_object.hpp @@ -94,6 +94,8 @@ protected: bool m_initially_visible; + std::string m_visibility_condition; + void init(const XMLNode &xml_node, scene::ISceneNode* parent, ModelDefinitionLoader& model_def_loader, TrackObject* parent_library); @@ -120,6 +122,7 @@ public: virtual void reset(); const core::vector3df& getPosition() const; const core::vector3df getAbsolutePosition() const; + const core::vector3df getAbsoluteCenterPosition() const; const core::vector3df& getRotation() const; const core::vector3df& getScale() const; bool castRay(const btVector3 &from, @@ -135,7 +138,7 @@ public: // ------------------------------------------------------------------------ /** To finish object constructions. Called after the track model * is ready. */ - virtual void init() {}; + virtual void onWorldReady(); // ------------------------------------------------------------------------ /** Called when an explosion happens. As a default does nothing, will * e.g. be overwritten by physical objects etc. */ diff --git a/src/tracks/track_object_manager.cpp b/src/tracks/track_object_manager.cpp index bbb4a445b..b1afb6045 100644 --- a/src/tracks/track_object_manager.cpp +++ b/src/tracks/track_object_manager.cpp @@ -66,11 +66,9 @@ void TrackObjectManager::add(const XMLNode &xml_node, scene::ISceneNode* parent, */ void TrackObjectManager::init() { - - TrackObject* curr; - for_in (curr, m_all_objects) + for_var_in(TrackObject*, curr, m_all_objects) { - curr->init(); + curr->onWorldReady(); } } // reset // ---------------------------------------------------------------------------- diff --git a/src/tracks/track_object_presentation.cpp b/src/tracks/track_object_presentation.cpp index 80d4f3773..4dd1a7363 100644 --- a/src/tracks/track_object_presentation.cpp +++ b/src/tracks/track_object_presentation.cpp @@ -88,6 +88,16 @@ const core::vector3df TrackObjectPresentationSceneNode::getAbsolutePosition() co return m_node->getAbsolutePosition(); } // getAbsolutePosition +// ---------------------------------------------------------------------------- + +const core::vector3df& TrackObjectPresentationSceneNode::getAbsoluteCenterPosition() const +{ + if (m_node == NULL) return m_init_xyz; + m_node->updateAbsolutePosition(); + core::aabbox3d bounds = m_node->getTransformedBoundingBox(); + return bounds.getCenter(); +} + // ---------------------------------------------------------------------------- const core::vector3df& TrackObjectPresentationSceneNode::getRotation() const { diff --git a/src/tracks/track_object_presentation.hpp b/src/tracks/track_object_presentation.hpp index 384a08b02..ba78a4d09 100644 --- a/src/tracks/track_object_presentation.hpp +++ b/src/tracks/track_object_presentation.hpp @@ -100,6 +100,11 @@ public: return m_init_xyz; } // getAbsolutePosition // ------------------------------------------------------------------------ + virtual const core::vector3df& getAbsoluteCenterPosition() const + { + return m_init_xyz; + } + // ------------------------------------------------------------------------ /** Returns the initial rotation. */ virtual const core::vector3df& getRotation() const { return m_init_hpr; } // ------------------------------------------------------------------------ @@ -141,6 +146,7 @@ public: // ------------------------------------------------------------------------ virtual const core::vector3df& getPosition() const OVERRIDE; virtual const core::vector3df getAbsolutePosition() const OVERRIDE; + virtual const core::vector3df& getAbsoluteCenterPosition() const OVERRIDE; virtual const core::vector3df& getRotation() const OVERRIDE; virtual const core::vector3df& getScale() const OVERRIDE; virtual void move(const core::vector3df& xyz, const core::vector3df& hpr, From 6529381acd8f3edb02d308ceb0c243d03ea4eb0c Mon Sep 17 00:00:00 2001 From: Marianne Gagnon Date: Mon, 10 Aug 2015 19:01:58 -0400 Subject: [PATCH 05/12] Fix rescue code in tutorial mode, fixes #2279 --- src/modes/tutorial_world.cpp | 26 ++++++++++++++++++++++++++ src/modes/tutorial_world.hpp | 9 +++------ 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/modes/tutorial_world.cpp b/src/modes/tutorial_world.cpp index 8bf0eec48..27def25a0 100644 --- a/src/modes/tutorial_world.cpp +++ b/src/modes/tutorial_world.cpp @@ -26,3 +26,29 @@ TutorialWorld::TutorialWorld() { m_stop_music_when_dialog_open = false; } // TutorialWorld + +unsigned int TutorialWorld::getRescuePositionIndex(AbstractKart *kart) +{ + const int start_spots_amount = getTrack()->getNumberOfStartPositions(); + assert(start_spots_amount > 0); + + float closest_distance = 999999.0f; + int closest_id_found = 0; + + Vec3 kart_pos = kart->getFrontXYZ(); + + for (int n = 0; n Date: Mon, 10 Aug 2015 19:04:35 -0400 Subject: [PATCH 06/12] Add graphical level preset between 4 and 5, the difference between the 2 was a little too steep --- src/states_screens/options_screen_video.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/states_screens/options_screen_video.cpp b/src/states_screens/options_screen_video.cpp index 6939a9e15..dcd77639b 100644 --- a/src/states_screens/options_screen_video.cpp +++ b/src/states_screens/options_screen_video.cpp @@ -95,6 +95,13 @@ static GFXPreset GFX_PRESETS[] = false /* depth of field */, false /* global illumination */, false /* degraded IBL */, 1 /* hd_textures */ }, + { + true /* light */, 512 /* shadow */, true /* bloom */, true /* motionblur */, + true /* lightshaft */, true /* glow */, true /* mlaa */, true /* ssao */, true /* weather */, + true /* animatedScenery */, 2 /* animatedCharacters */, 16 /* anisotropy */, + true /* depth of field */, false /* global illumination */, false /* degraded IBL */, 1 /* hd_textures */ + }, + { true /* light */, 1024 /* shadow */, true /* bloom */, true /* motionblur */, true /* lightshaft */, true /* glow */, true /* mlaa */, true /* ssao */, true /* weather */, @@ -103,7 +110,7 @@ static GFXPreset GFX_PRESETS[] = } }; -static const int GFX_LEVEL_AMOUNT = 5; +static const int GFX_LEVEL_AMOUNT = 6; struct Resolution { From ea9520863db59b9e7effca1f7ccbee25657e21e2 Mon Sep 17 00:00:00 2001 From: Marianne Gagnon Date: Tue, 11 Aug 2015 19:30:20 -0400 Subject: [PATCH 07/12] Try to correct string encoding issue in scripting. Fixes #2278 --- src/scriptengine/script_gui.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/scriptengine/script_gui.cpp b/src/scriptengine/script_gui.cpp index af3fb494a..a7cda59e3 100644 --- a/src/scriptengine/script_gui.cpp +++ b/src/scriptengine/script_gui.cpp @@ -53,10 +53,9 @@ namespace Scripting { InputDevice* device = input_manager->getDeviceManager()->getLatestUsedDevice(); DeviceConfig* config = device->getConfiguration(); - irr::core::stringw control; PlayerAction ScriptAction = (PlayerAction)Enum_value; - control = config->getBindingAsString(ScriptAction); - std::string key = std::string(irr::core::stringc(control).c_str()); + irr::core::stringw control = config->getBindingAsString(ScriptAction); + std::string key = StringUtils::wide_to_utf8(control.c_str()); return key; } From 7b8da0ef342e1d22f19cfb9bbdfb7969a09ad68d Mon Sep 17 00:00:00 2001 From: Marianne Gagnon Date: Tue, 11 Aug 2015 20:55:04 -0400 Subject: [PATCH 08/12] Bugfix : objects with a physics collision from a library should rotate and scale according to the parent library object --- src/physics/physical_object.cpp | 30 ++++++++++++++++++++++++++++-- src/tracks/track_object.cpp | 2 +- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/physics/physical_object.cpp b/src/physics/physical_object.cpp index 28cd58d97..bb1698b4d 100644 --- a/src/physics/physical_object.cpp +++ b/src/physics/physical_object.cpp @@ -252,8 +252,14 @@ void PhysicalObject::init() Log::fatal("PhysicalObject", "Unknown node type"); } - max = max * Vec3(m_init_scale); - min = min * Vec3(m_init_scale); + Vec3 parent_scale(1.0f, 1.0f, 1.0f); + if (m_object->getParentLibrary() != NULL) + { + parent_scale = m_object->getParentLibrary()->getScale(); + } + + max = max * (Vec3(m_init_scale) * parent_scale); + min = min * (Vec3(m_init_scale) * parent_scale); Vec3 extend = max-min; // Adjust the mesth of the graphical object so that its center is where it @@ -466,6 +472,26 @@ void PhysicalObject::init() m_init_pos.setOrigin(m_init_pos.getOrigin() + btVector3(0, extend.getY()*0.5f, 0)); } + + + // If this object has a parent, apply the parent's rotation + if (m_object->getParentLibrary() != NULL) + { + core::vector3df parent_rot_hpr = m_object->getParentLibrary()->getInitRotation(); + core::matrix4 parent_rot_matrix; + parent_rot_matrix.setRotationDegrees(parent_rot_hpr); + + btQuaternion child_rot_quat = m_init_pos.getRotation(); + core::matrix4 child_rot_matrix; + Vec3 axis = child_rot_quat.getAxis(); + child_rot_matrix.setRotationAxisRadians(child_rot_quat.getAngle(), axis.toIrrVector()); + + irr::core::quaternion tempQuat(parent_rot_matrix * child_rot_matrix); + btQuaternion q(tempQuat.X, tempQuat.Y, tempQuat.Z, tempQuat.W); + + m_init_pos.setRotation(q); + } + m_motion_state = new btDefaultMotionState(m_init_pos); btVector3 inertia(1,1,1); if (m_body_type != MP_EXACT) diff --git a/src/tracks/track_object.cpp b/src/tracks/track_object.cpp index 5e9e054be..187d83b7a 100644 --- a/src/tracks/track_object.cpp +++ b/src/tracks/track_object.cpp @@ -544,7 +544,7 @@ const core::vector3df& TrackObject::getScale() const if (m_presentation != NULL) return m_presentation->getScale(); else - return m_init_xyz; + return m_init_scale; } // getScale // ---------------------------------------------------------------------------- From 7a4112e89c4bd80ab21064d1515a52fd6c561c43 Mon Sep 17 00:00:00 2001 From: Deve Date: Wed, 12 Aug 2015 18:37:31 +0200 Subject: [PATCH 09/12] Fixed compiler warning. Based on fread specification, it returns number of elements which has been read. Here is declared one element with size of whole file (len), so returned value should be always equal to 1. --- src/scriptengine/script_engine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scriptengine/script_engine.cpp b/src/scriptengine/script_engine.cpp index aae89ce57..3db73c2b8 100644 --- a/src/scriptengine/script_engine.cpp +++ b/src/scriptengine/script_engine.cpp @@ -107,7 +107,7 @@ namespace Scripting script.resize(len); int c = fread(&script[0], len, 1, f); fclose(f); - if (c == NULL) + if (c != 1) { Log::error("Scripting", "Failed to load script file."); return ""; From 63249309c39822a285b4005b8b0e1af171137df2 Mon Sep 17 00:00:00 2001 From: Deve Date: Wed, 12 Aug 2015 19:23:38 +0200 Subject: [PATCH 10/12] Fixed compiler warning. Previously address of local variable was returned. --- src/tracks/track_object_presentation.cpp | 2 +- src/tracks/track_object_presentation.hpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tracks/track_object_presentation.cpp b/src/tracks/track_object_presentation.cpp index 4dd1a7363..f763336ff 100644 --- a/src/tracks/track_object_presentation.cpp +++ b/src/tracks/track_object_presentation.cpp @@ -90,7 +90,7 @@ const core::vector3df TrackObjectPresentationSceneNode::getAbsolutePosition() co // ---------------------------------------------------------------------------- -const core::vector3df& TrackObjectPresentationSceneNode::getAbsoluteCenterPosition() const +const core::vector3df TrackObjectPresentationSceneNode::getAbsoluteCenterPosition() const { if (m_node == NULL) return m_init_xyz; m_node->updateAbsolutePosition(); diff --git a/src/tracks/track_object_presentation.hpp b/src/tracks/track_object_presentation.hpp index ba78a4d09..a402befc0 100644 --- a/src/tracks/track_object_presentation.hpp +++ b/src/tracks/track_object_presentation.hpp @@ -100,7 +100,7 @@ public: return m_init_xyz; } // getAbsolutePosition // ------------------------------------------------------------------------ - virtual const core::vector3df& getAbsoluteCenterPosition() const + virtual const core::vector3df getAbsoluteCenterPosition() const { return m_init_xyz; } @@ -146,7 +146,7 @@ public: // ------------------------------------------------------------------------ virtual const core::vector3df& getPosition() const OVERRIDE; virtual const core::vector3df getAbsolutePosition() const OVERRIDE; - virtual const core::vector3df& getAbsoluteCenterPosition() const OVERRIDE; + virtual const core::vector3df getAbsoluteCenterPosition() const OVERRIDE; virtual const core::vector3df& getRotation() const OVERRIDE; virtual const core::vector3df& getScale() const OVERRIDE; virtual void move(const core::vector3df& xyz, const core::vector3df& hpr, From bc4e53251073e6aa9d11dbea3c475d2d886932a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torbj=C3=B6rn=20S=C3=B6derstedt?= Date: Wed, 12 Aug 2015 22:54:42 +0200 Subject: [PATCH 11/12] Use actual screen size when fading cutscenes. --- src/states_screens/cutscene_gui.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/states_screens/cutscene_gui.cpp b/src/states_screens/cutscene_gui.cpp index d7e99f977..38fdf0ba2 100644 --- a/src/states_screens/cutscene_gui.cpp +++ b/src/states_screens/cutscene_gui.cpp @@ -16,10 +16,10 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -#include "config/user_config.hpp" #include "guiengine/engine.hpp" #include "guiengine/scalable_font.hpp" #include "graphics/2dutils.hpp" +#include "graphics/irr_driver.hpp" #include "states_screens/cutscene_gui.hpp" // ----------------------------------------------------------------------------- @@ -40,21 +40,23 @@ CutsceneGUI::~CutsceneGUI() void CutsceneGUI::renderGlobal(float dt) { + core::dimension2d screen_size = irr_driver->getActualScreenSize(); + if (m_fade_level > 0.0f) { GL32_draw2DRectangle( video::SColor((int)(m_fade_level*255), 0,0,0), core::rect(0, 0, - UserConfigParams::m_width, - UserConfigParams::m_height)); + screen_size.Width, + screen_size.Height)); } if (m_subtitle.size() > 0) { - core::rect r(0, UserConfigParams::m_height - GUIEngine::getFontHeight()*2, - UserConfigParams::m_width, UserConfigParams::m_height); + core::rect r(0, screen_size.Height - GUIEngine::getFontHeight()*2, + screen_size.Width, screen_size.Height); - if (GUIEngine::getFont()->getDimension(m_subtitle.c_str()).Width > (unsigned int)UserConfigParams::m_width) + if (GUIEngine::getFont()->getDimension(m_subtitle.c_str()).Width > screen_size.Width) { GUIEngine::getSmallFont()->draw(m_subtitle, r, video::SColor(255,255,255,255), true, true, NULL); From 567d08d360571107c7b8220fe433f381a19f8b34 Mon Sep 17 00:00:00 2001 From: hiker Date: Thu, 13 Aug 2015 09:51:45 +1000 Subject: [PATCH 12/12] Visualise invisible physics-only meshes when --physics-debug is specified (helps debugging invisible walls). --- src/tracks/track.cpp | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/src/tracks/track.cpp b/src/tracks/track.cpp index 37a96e59d..52388b669 100644 --- a/src/tracks/track.cpp +++ b/src/tracks/track.cpp @@ -71,6 +71,7 @@ #include #include #include +#include #include #include @@ -293,6 +294,11 @@ void Track::cleanup() irr_driver->removeNode(m_all_nodes[i]); } m_all_nodes.clear(); + + for (unsigned int i = 0; i < m_static_physics_only_nodes.size(); i++) + { + m_static_physics_only_nodes[i]->remove(); + } m_static_physics_only_nodes.clear(); m_all_emitters.clearAndDeleteAll(); @@ -736,9 +742,32 @@ void Track::createPhysicsModel(unsigned int main_track_count) for (unsigned int i = 0; iremoveNode(m_static_physics_only_nodes[i]); + if (UserConfigParams::m_physics_debug && + m_static_physics_only_nodes[i]->getType() == scene::ESNT_MESH) + { + const video::SColor color(255, 255, 105, 180); + + scene::IMesh *mesh = ((scene::IMeshSceneNode*)m_static_physics_only_nodes[i])->getMesh(); + scene::IMeshBuffer *mb = mesh->getMeshBuffer(0); + mb->getMaterial().BackfaceCulling = false; + video::S3DVertex * const verts = (video::S3DVertex *) mb->getVertices(); + const u32 max = mb->getVertexCount(); + for (i = 0; i < max; i++) + { + verts[i].Color = color; + } + + // Color + mb->getMaterial().setTexture(0, getUnicolorTexture(video::SColor(255, 255, 105, 180))); + irr_driver->grabAllTextures(mesh); + // Gloss + mb->getMaterial().setTexture(1, getUnicolorTexture(video::SColor(0, 0, 0, 0))); + } + else + irr_driver->removeNode(m_static_physics_only_nodes[i]); } - m_static_physics_only_nodes.clear(); + if (!UserConfigParams::m_physics_debug) + m_static_physics_only_nodes.clear(); for (unsigned int i = 0; igetMeshBufferCount(); i++) { - scene::IMeshBuffer *mb = mesh->getMeshBuffer(i); + scene::IMeshBuffer *mb = mesh->getMeshBuffer(i); // FIXME: take translation/rotation into account if (mb->getVertexType() != video::EVT_STANDARD && mb->getVertexType() != video::EVT_2TCOORDS &&