From: Mikko Rasa Date: Fri, 23 Apr 2010 16:31:59 +0000 (+0000) Subject: Only pick once per rendered frame X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=ff20abc71ef697eb241e1aea9f7d61adeccfefd6;p=r2c2.git Only pick once per rendered frame Don't add new routes to layout manually --- diff --git a/source/designer/toolbar.cpp b/source/designer/toolbar.cpp index 36b4882..ee990dd 100644 --- a/source/designer/toolbar.cpp +++ b/source/designer/toolbar.cpp @@ -80,7 +80,6 @@ void Toolbar::route_selected(unsigned index, const string &) { Layout &layout = *designer.get_layout(); Route *route = new Route(layout, format("Route %d", layout.get_routes().size()+1)); - designer.get_layout()->add_route(*route); designer.edit_route(*route); const map &routes = designer.get_layout()->get_routes(); diff --git a/source/engineer/engineer.cpp b/source/engineer/engineer.cpp index 897c7ca..c809287 100644 --- a/source/engineer/engineer.cpp +++ b/source/engineer/engineer.cpp @@ -50,7 +50,10 @@ Engineer::Engineer(int argc, char **argv): picking(false), picking_track(0), picking_entry(0), - picking_path(0) + picking_path(0), + pointer_x(0), + pointer_y(0), + pointer_moved(false) { // Setup GUI window.set_title("Railroad Engineer"); @@ -173,6 +176,31 @@ void Engineer::tick() overlay->render(0); } + if(pointer_moved) + { + pointer_moved = false; + + if(picking) + { + Track3D *track = pick_track(pointer_x, window.get_height()-pointer_y-1); + if(track && &track->get_track()!=picking_track) + { + picking_track = &track->get_track(); + if(picking_entry>=0) + picking_entry = 0; + + delete picking_path; + picking_path = new Path3D(*track); + if(picking_entry>=0) + picking_path->set_mask(picking_track->get_type().get_endpoints()[picking_entry].paths); + else + picking_path->set_mask(picking_track->get_type().get_paths()); + picking_path->set_color(GL::Color(0)); + picking_path->set_layer(1); + } + } + } + if(picking && picking_track && picking_entry>=0) { GL::PushMatrix push_mat; @@ -255,25 +283,9 @@ void Engineer::button_press(int x, int y, unsigned btn, unsigned) void Engineer::pointer_motion(int x, int y) { - if(picking) - { - Track3D *track = pick_track(x, window.get_height()-y-1); - if(track && &track->get_track()!=picking_track) - { - picking_track = &track->get_track(); - if(picking_entry>=0) - picking_entry = 0; - - delete picking_path; - picking_path = new Path3D(*track); - if(picking_entry>=0) - picking_path->set_mask(picking_track->get_type().get_endpoints()[picking_entry].paths); - else - picking_path->set_mask(picking_track->get_type().get_paths()); - picking_path->set_color(GL::Color(0)); - picking_path->set_layer(1); - } - } + pointer_x = x; + pointer_y = y; + pointer_moved = true; } void Engineer::view_all() diff --git a/source/engineer/engineer.h b/source/engineer/engineer.h index 8ce848e..dc7a7a0 100644 --- a/source/engineer/engineer.h +++ b/source/engineer/engineer.h @@ -61,6 +61,9 @@ private: Marklin::Track *picking_track; int picking_entry; Marklin::Path3D *picking_path; + int pointer_x; + int pointer_y; + bool pointer_moved; public: Engineer(int argc, char **argv);