summaryrefslogtreecommitdiffstats
path: root/src/View
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2010-01-10 12:40:10 +0100
committerMatthias Schiffer <matthias@gamezock.de>2010-01-10 12:40:10 +0100
commit02d3608a8b853a009dfc437dbbfbff72a2393ef2 (patch)
tree741beb9902aa0cef072a2111dce2bfabc0aab9b2 /src/View
parentb4adc20ef08257124a01499436f2b8b447adcb33 (diff)
downloadzoomedit-02d3608a8b853a009dfc437dbbfbff72a2393ef2.tar
zoomedit-02d3608a8b853a009dfc437dbbfbff72a2393ef2.zip
Only respect floor triangles when picking roomHEADmaster
Diffstat (limited to 'src/View')
-rw-r--r--src/View/TopView.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/View/TopView.cpp b/src/View/TopView.cpp
index 7e649cc..fa894ca 100644
--- a/src/View/TopView.cpp
+++ b/src/View/TopView.cpp
@@ -236,30 +236,32 @@ void TopView::click(float x, float y, unsigned int button) {
vmml::vec2f v(xCenter + x/scale, yCenter + y/scale);
- Data::Room *selectedRoom = 0;
-
const std::list<Data::Room*> &rooms = instance->getLevel()->getRooms();
for(std::list<Data::Room*>::const_iterator room = rooms.begin(); room != rooms.end(); ++room) {
const std::list<Data::Triangle*>& triangles = (*room)->getTriangles();
for(std::list<Data::Triangle*>::const_iterator t = triangles.begin(); t != triangles.end(); ++t) {
+ vmml::vec3f edge1 = (*t)->getVertex(1) - (*t)->getVertex(0);
+ vmml::vec3f edge2 = (*t)->getVertex(2) - (*t)->getVertex(0);
+
+ vmml::vec3f normal = edge1.cross(edge2);
+
+ if(normal.y() <= 0)
+ continue;
+
vmml::vec2f v1((*t)->getVertex(0).x(), (*t)->getVertex(0).z());
vmml::vec2f v2((*t)->getVertex(1).x(), (*t)->getVertex(1).z());
vmml::vec2f v3((*t)->getVertex(2).x(), (*t)->getVertex(2).z());
if(Math::Triangle2D(v1, v2, v3).contains(v)) {
- selectedRoom = *room;
- break;
+ instance->setSelectedRoom(*room);
+ return;
}
}
-
- if(selectedRoom)
- break;
}
-
- instance->setSelectedRoom(selectedRoom);
- signalUpdate().emit();
+
+ instance->setSelectedRoom(0);
}
}