diff --git a/src/states_screens/feature_unlocked.cpp b/src/states_screens/feature_unlocked.cpp index 8ae059181..eb69539b4 100644 --- a/src/states_screens/feature_unlocked.cpp +++ b/src/states_screens/feature_unlocked.cpp @@ -581,20 +581,20 @@ bool FeatureUnlockedCutScene::onEscapePressed() void FeatureUnlockedCutScene::continueButtonPressed() { - //if (m_global_time < GIFT_EXIT_TO) - //{ - // // If animation was not over yet, the button is used to skip the animation - // while (m_global_time < GIFT_EXIT_TO) - // { - // // simulate all the steps of the animation until we reach the end - // onUpdate(0.4f); - // World::getWorld()->updateWorld(0.4f); - // } - //} - //else - //{ + if (m_global_time < GIFT_EXIT_TO) + { + // If animation was not over yet, the button is used to skip the animation + while (m_global_time < GIFT_EXIT_TO) + { + // simulate all the steps of the animation until we reach the end + onUpdate(0.4f); + World::getWorld()->updateWorld(0.4f); + } + } + else + { ((CutsceneWorld*)World::getWorld())->abortCutscene(); - //} + } } // continueButtonPressed diff --git a/src/tracks/track.cpp b/src/tracks/track.cpp index ca3fabb63..48818f4bd 100644 --- a/src/tracks/track.cpp +++ b/src/tracks/track.cpp @@ -1571,6 +1571,39 @@ void Track::createWater(const XMLNode &node) scene_node->getMaterial(0).setFlag(video::EMF_GOURAUD_SHADING, true); } // createWater +// ---------------------------------------------------------------------------- +static void recursiveUpdatePosition(scene::ISceneNode *node) +{ + node->updateAbsolutePosition(); + + scene::ISceneNodeList::ConstIterator it = node->getChildren().begin(); + for (; it != node->getChildren().end(); ++it) + { + recursiveUpdatePosition(*it); + } +} // recursiveUpdatePosition + +// ---------------------------------------------------------------------------- +static void recursiveUpdatePhysics(std::vector& tos) +{ + for (TrackObject* to : tos) + { + if (to->getPhysicalObject()) + { + TrackObjectPresentationSceneNode* sn = to + ->getPresentation(); + if (sn) + { + to->getPhysicalObject()->move( + sn->getNode()->getAbsoluteTransformation().getTranslation(), + sn->getNode()->getAbsoluteTransformation() + .getRotationDegrees()); + } + } + recursiveUpdatePhysics(to->getChildren()); + } +} // recursiveUpdatePhysics + // ---------------------------------------------------------------------------- /** This function load the actual scene, i.e. all parts of the track, * animations, items, ... It is called from world during initialisation. @@ -1763,7 +1796,12 @@ void Track::loadTrackModel(bool reverse_track, unsigned int mode_id) { auto* ln = p.first->getPresentation(); assert(ln); - p.second->setParent(ln->getNode()); + TrackObjectPresentationLibraryNode* meta_ln = p.second + ->getPresentation(); + assert(meta_ln); + meta_ln->getNode()->setParent(ln->getNode()); + recursiveUpdatePosition(meta_ln->getNode()); + recursiveUpdatePhysics(p.second->getChildren()); } model_def_loader.cleanLibraryNodesAfterLoad(); diff --git a/src/tracks/track.hpp b/src/tracks/track.hpp index 4a4603547..f050f5959 100644 --- a/src/tracks/track.hpp +++ b/src/tracks/track.hpp @@ -374,7 +374,7 @@ private: /** List of all bezier curves in the track - for e.g. camera, ... */ std::vector m_all_curves; - std::vector > m_meta_library; + std::vector > m_meta_library; /** The number of laps the track will be raced in a random GP. * m_actual_number_of_laps is initialised with this value.*/ @@ -676,7 +676,7 @@ public: void addCachedMesh(scene::IMesh* mesh) { m_all_cached_meshes.push_back(mesh); } // ------------------------------------------------------------------------ /** Adds the parent of the meta library for correction later */ - void addMetaLibrary(TrackObject* parent, scene::ISceneNode* meta_library) + void addMetaLibrary(TrackObject* parent, TrackObject* meta_library) { m_meta_library.emplace_back(parent, meta_library); } }; // class Track diff --git a/src/tracks/track_object.cpp b/src/tracks/track_object.cpp index 0e11cd069..255f00129 100644 --- a/src/tracks/track_object.cpp +++ b/src/tracks/track_object.cpp @@ -163,8 +163,7 @@ void TrackObject::init(const XMLNode &xml_node, scene::ISceneNode* parent, m_presentation = new TrackObjectPresentationLibraryNode(this, xml_node, model_def_loader); if (parent_library != NULL) { - Track::getCurrentTrack()->addMetaLibrary(parent_library, - (dynamic_cast(m_presentation))->getNode()); + Track::getCurrentTrack()->addMetaLibrary(parent_library, this); } } else if (type == "sfx-emitter")