From: Mikko Rasa Date: Fri, 23 Apr 2010 18:05:44 +0000 (+0000) Subject: Do not render unplaced vehicles X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=dc3b2bce73df40ea885a1960a825e5cd3a33c045;p=r2c2.git Do not render unplaced vehicles --- diff --git a/source/3d/object.h b/source/3d/object.h index 8b9353d..d2cb911 100644 --- a/source/3d/object.h +++ b/source/3d/object.h @@ -20,6 +20,7 @@ public: virtual ~Object3D() { } virtual Point get_node() const = 0; + virtual bool is_visible() const = 0; }; } // namespace Marklin diff --git a/source/3d/overlay.cpp b/source/3d/overlay.cpp index 3f2d621..39428a1 100644 --- a/source/3d/overlay.cpp +++ b/source/3d/overlay.cpp @@ -98,6 +98,9 @@ void Overlay3D::render(const GL::Tag &tag) const for(map::const_iterator i=icons.begin(); i!=icons.end(); ++i) { + if(!i->first->is_visible()) + continue; + const Icon &icon = *i->second; Point node = i->first->get_node(); diff --git a/source/3d/track.h b/source/3d/track.h index 93e3a0d..e55dc21 100644 --- a/source/3d/track.h +++ b/source/3d/track.h @@ -43,6 +43,7 @@ public: Path3D &get_path() { return *path; } virtual Point get_node() const; + virtual bool is_visible() const { return true; } void apply_matrix() const; virtual void render(const Msp::GL::Tag &) const; diff --git a/source/3d/vehicle.cpp b/source/3d/vehicle.cpp index 41bb262..37619eb 100644 --- a/source/3d/vehicle.cpp +++ b/source/3d/vehicle.cpp @@ -37,8 +37,16 @@ Point Vehicle3D::get_node() const return Point(p.x, p.y, p.z+0.01+vehicle.get_type().get_height()); } +bool Vehicle3D::is_visible() const +{ + return vehicle.get_track(); +} + void Vehicle3D::render(const GL::Tag &tag) const { + if(!vehicle.get_track()) + return; + if(tag==0) { GL::PushMatrix push_mat; diff --git a/source/3d/vehicle.h b/source/3d/vehicle.h index feab8a1..075eaef 100644 --- a/source/3d/vehicle.h +++ b/source/3d/vehicle.h @@ -31,6 +31,7 @@ public: Vehicle &get_vehicle() const { return vehicle; } virtual Point get_node() const; + virtual bool is_visible() const; virtual void render(const Msp::GL::Tag &) const; };