Add support for meta library objects
This commit is contained in:
parent
48aded5f6d
commit
60a3890c78
@ -466,6 +466,7 @@ void Track::cleanup()
|
||||
}
|
||||
#endif
|
||||
|
||||
m_meta_library.clear();
|
||||
Scripting::ScriptEngine::getInstance()->cleanupCache();
|
||||
|
||||
m_current_track = NULL;
|
||||
@ -1757,6 +1758,14 @@ void Track::loadTrackModel(bool reverse_track, unsigned int mode_id)
|
||||
|
||||
loadObjects(root, path, model_def_loader, true, NULL, NULL);
|
||||
|
||||
// Correct the parenting of meta library
|
||||
for (auto& p : m_meta_library)
|
||||
{
|
||||
auto* ln = p.first->getPresentation<TrackObjectPresentationLibraryNode>();
|
||||
assert(ln);
|
||||
p.second->setParent(ln->getNode());
|
||||
}
|
||||
|
||||
model_def_loader.cleanLibraryNodesAfterLoad();
|
||||
|
||||
Scripting::ScriptEngine::getInstance()->compileLoadedScripts();
|
||||
|
@ -374,6 +374,8 @@ private:
|
||||
/** List of all bezier curves in the track - for e.g. camera, ... */
|
||||
std::vector<BezierCurve*> m_all_curves;
|
||||
|
||||
std::vector<std::pair<TrackObject*, scene::ISceneNode*> > 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.*/
|
||||
int m_default_number_of_laps;
|
||||
@ -672,6 +674,10 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
/** Adds mesh to cleanup list */
|
||||
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)
|
||||
{ m_meta_library.emplace_back(parent, meta_library); }
|
||||
}; // class Track
|
||||
|
||||
#endif
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "physics/physical_object.hpp"
|
||||
#include "race/race_manager.hpp"
|
||||
#include "scriptengine/script_engine.hpp"
|
||||
#include "tracks/track.hpp"
|
||||
#include "tracks/model_definition_loader.hpp"
|
||||
|
||||
#include <IAnimatedMeshSceneNode.h>
|
||||
@ -160,6 +161,11 @@ void TrackObject::init(const XMLNode &xml_node, scene::ISceneNode* parent,
|
||||
{
|
||||
xml_node.get("name", &m_name);
|
||||
m_presentation = new TrackObjectPresentationLibraryNode(this, xml_node, model_def_loader);
|
||||
if (parent_library != NULL)
|
||||
{
|
||||
Track::getCurrentTrack()->addMetaLibrary(parent_library,
|
||||
(dynamic_cast<TrackObjectPresentationLibraryNode*>(m_presentation))->getNode());
|
||||
}
|
||||
}
|
||||
else if (type == "sfx-emitter")
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user