Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/model
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2013-10-08 19:49:47 +0000
committerStijn Buys <ingar@osirion.org>2013-10-08 19:49:47 +0000
commit3a6c5c7107d53a6388db8df6adf74a56c174ae5a (patch)
treed5aae57fd39dfc052e3cbdfed8009ea0e675bef4 /src/model
parent71e60ee1b4812d27c8c7281b91780da3ea0226a2 (diff)
Sort model tags by location.
Diffstat (limited to 'src/model')
-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;