Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/model/model.cc72
-rw-r--r--src/model/model.h5
2 files changed, 77 insertions, 0 deletions
diff --git a/src/model/model.cc b/src/model/model.cc
index f2fb481..fdff22e 100644
--- a/src/model/model.cc
+++ b/src/model/model.cc
@@ -134,6 +134,75 @@ void Model::print() const
{
}
+bool compare_tag_location(const Tag *first, const Tag *second)
+{
+ if (!first) {
+ return true;
+ } else if (!second) {
+ return true;
+ }
+
+ if (first->location().x() > second->location().x()) {
+ return true;
+
+ } else if (first->location().x() < second->location().x()) {
+ return false;
+
+ } else if (first->location().y() > second->location().y()) {
+ return true;
+
+ } else if (first->location().y() < second->location().y()) {
+ return false;
+
+ } else if (first->location().z() < second->location().z()) {
+ return false;
+
+ } else {
+ return true;
+ }
+
+}
+
+bool compare_tag_location_front(const Tag *first, const Tag *second)
+{
+ if (!first) {
+ return true;
+ } else if (!second) {
+ return true;
+ }
+
+ if (first->location().x() > second->location().x()) {
+ return true;
+
+ } else if (first->location().x() < second->location().x()) {
+ return false;
+
+ } else if (first->location().y() > second->location().y()) {
+ return false;
+
+ } else if (first->location().y() < second->location().y()) {
+ return true;
+
+ } else if (first->location().z() < second->location().z()) {
+ return false;
+
+ } else {
+ return true;
+ }
+
+}
+void Model::sort()
+{
+ model_weapons.sort(compare_tag_location);
+ model_docks.sort(compare_tag_location_front);
+
+ model_particles.sort(compare_tag_location);
+ model_lights.sort(compare_tag_location);
+ model_flares.sort(compare_tag_location);
+ model_sounds.sort(compare_tag_location);
+
+}
+
Model *Model::find(const std::string & name)
{
Registry::iterator it = model_registry.find(name);
@@ -185,6 +254,9 @@ Model *Model::load(const std::string & name)
if (!model) {
con_warn << "Could not open model " << name << std::endl;
} else {
+ // sort model tags
+ model->sort();
+ // add model to registry
model_registry[model->name()] = model;
}
diff --git a/src/model/model.h b/src/model/model.h
index 3c94ad6..4d72793 100644
--- a/src/model/model.h
+++ b/src/model/model.h
@@ -214,6 +214,11 @@ public:
static void list();
private:
+ /**
+ * @brief sort model tags according to location
+ * */
+ void sort();
+
std::string model_name;
Docks model_docks;
Flares model_flares;