Add support for meta library objects
This commit is contained in:
parent
48aded5f6d
commit
60a3890c78
@ -466,6 +466,7 @@ void Track::cleanup()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
m_meta_library.clear();
|
||||||
Scripting::ScriptEngine::getInstance()->cleanupCache();
|
Scripting::ScriptEngine::getInstance()->cleanupCache();
|
||||||
|
|
||||||
m_current_track = NULL;
|
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);
|
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();
|
model_def_loader.cleanLibraryNodesAfterLoad();
|
||||||
|
|
||||||
Scripting::ScriptEngine::getInstance()->compileLoadedScripts();
|
Scripting::ScriptEngine::getInstance()->compileLoadedScripts();
|
||||||
|
@ -374,6 +374,8 @@ private:
|
|||||||
/** List of all bezier curves in the track - for e.g. camera, ... */
|
/** List of all bezier curves in the track - for e.g. camera, ... */
|
||||||
std::vector<BezierCurve*> m_all_curves;
|
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.
|
/** The number of laps the track will be raced in a random GP.
|
||||||
* m_actual_number_of_laps is initialised with this value.*/
|
* m_actual_number_of_laps is initialised with this value.*/
|
||||||
int m_default_number_of_laps;
|
int m_default_number_of_laps;
|
||||||
@ -672,6 +674,10 @@ public:
|
|||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
/** Adds mesh to cleanup list */
|
/** Adds mesh to cleanup list */
|
||||||
void addCachedMesh(scene::IMesh* mesh) { m_all_cached_meshes.push_back(mesh); }
|
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
|
}; // class Track
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include "physics/physical_object.hpp"
|
#include "physics/physical_object.hpp"
|
||||||
#include "race/race_manager.hpp"
|
#include "race/race_manager.hpp"
|
||||||
#include "scriptengine/script_engine.hpp"
|
#include "scriptengine/script_engine.hpp"
|
||||||
|
#include "tracks/track.hpp"
|
||||||
#include "tracks/model_definition_loader.hpp"
|
#include "tracks/model_definition_loader.hpp"
|
||||||
|
|
||||||
#include <IAnimatedMeshSceneNode.h>
|
#include <IAnimatedMeshSceneNode.h>
|
||||||
@ -160,6 +161,11 @@ void TrackObject::init(const XMLNode &xml_node, scene::ISceneNode* parent,
|
|||||||
{
|
{
|
||||||
xml_node.get("name", &m_name);
|
xml_node.get("name", &m_name);
|
||||||
m_presentation = new TrackObjectPresentationLibraryNode(this, xml_node, model_def_loader);
|
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")
|
else if (type == "sfx-emitter")
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user