summaryrefslogtreecommitdiffstats
path: root/src
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
parentb4adc20ef08257124a01499436f2b8b447adcb33 (diff)
downloadzoomedit-master.tar
zoomedit-master.zip
Only respect floor triangles when picking roomHEADmaster
Diffstat (limited to 'src')
-rw-r--r--src/Gui/Renderer/RoomListRenderer.cpp2
-rw-r--r--src/View/TopView.cpp22
2 files changed, 13 insertions, 11 deletions
diff --git a/src/Gui/Renderer/RoomListRenderer.cpp b/src/Gui/Renderer/RoomListRenderer.cpp
index 83b0402..8291c4e 100644
--- a/src/Gui/Renderer/RoomListRenderer.cpp
+++ b/src/Gui/Renderer/RoomListRenderer.cpp
@@ -38,7 +38,7 @@ void RoomListRenderer::render_vfunc(const Glib::RefPtr<Gdk::Drawable> &window, G
const Gdk::Rectangle &/*background_area*/, const Gdk::Rectangle &cell_area,
const Gdk::Rectangle &/*expose_area*/, Gtk::CellRendererState /*flags*/) {
- Data::Room *room = reinterpret_cast<Data::Room*>(value.get_value());
+ Data::Room *room = static_cast<Data::Room*>(value.get_value());
int xpad, ypad;
get_padding(xpad, ypad);
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);
}
}