]> git.tdb.fi Git - r2c2.git/blobdiff - source/3d/layout.cpp
Add editable terrain objects
[r2c2.git] / source / 3d / layout.cpp
index 59a23c935aab6be2f3e41c5e53c4e383e3975f14..fdb4dfc24d5477672ae6fd361f989880dcc5659a 100644 (file)
@@ -1,6 +1,7 @@
 #include "beamgate.h"
 #include "layout.h"
 #include "signal.h"
+#include "terrain.h"
 #include "track.h"
 #include "utility.h"
 #include "vehicle.h"
@@ -41,7 +42,11 @@ void Layout3D::get_bounds(Vector &minp, Vector &maxp) const
        Geometry::BoundingBox<float, 3> bbox;
 
        for(ObjectMap::const_iterator i=objects.begin(); i!=objects.end(); ++i)
-               bbox = bbox|i->second->get_object().get_type().get_shape()->get_axis_aligned_bounding_box();
+       {
+               const Shape *shape = i->second->get_object().get_shape();
+               if(shape)
+                       bbox = bbox|shape->get_axis_aligned_bounding_box();
+       }
 
        minp = bbox.get_minimum_point();
        maxp = bbox.get_maximum_point();
@@ -82,6 +87,8 @@ void Layout3D::object_added(Object &o)
                new Vehicle3D(*this, *v);
        else if(BeamGate *g = dynamic_cast<BeamGate *>(&o))
                new BeamGate3D(*this, *g);
+       else if(Terrain *r = dynamic_cast<Terrain *>(&o))
+               new Terrain3D(*this, *r);
 }
 
 void Layout3D::object_removed(Object &o)