]> git.tdb.fi Git - r2c2.git/commitdiff
Do not render unplaced vehicles
authorMikko Rasa <tdb@tdb.fi>
Fri, 23 Apr 2010 18:05:44 +0000 (18:05 +0000)
committerMikko Rasa <tdb@tdb.fi>
Fri, 23 Apr 2010 18:05:44 +0000 (18:05 +0000)
source/3d/object.h
source/3d/overlay.cpp
source/3d/track.h
source/3d/vehicle.cpp
source/3d/vehicle.h

index 8b9353d06e4b5879445a04e1ab31f670e7f4f1af..d2cb911c5037a16a486ed3f139a8aca10f6f7475 100644 (file)
@@ -20,6 +20,7 @@ public:
        virtual ~Object3D() { }
 
        virtual Point get_node() const = 0;
+       virtual bool is_visible() const = 0;
 };
 
 } // namespace Marklin
index 3f2d621d6b8aade208f8517488a0f3585f2117fc..39428a166d57ff4f622521b21471d9b9092e9eab 100644 (file)
@@ -98,6 +98,9 @@ void Overlay3D::render(const GL::Tag &tag) const
 
                for(map<const Object3D *, Icon *>::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();
index 93e3a0d37ab440d514d93a990fb465ac153fcc40..e55dc21245f146920115c4719acc63267bf54142 100644 (file)
@@ -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;
index 41bb26259da3b2a769c7a93e427acfb76ab1fe0b..37619ebd339461f104dc0bf54aeb6fcfe71e7a67 100644 (file)
@@ -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;
index feab8a1dd2a95972bfed83a966306702d72049f7..075eaef273cdec1289eb983e81dc6c01e02f77a4 100644 (file)
@@ -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;
 };