]> git.tdb.fi Git - r2c2.git/blobdiff - source/designer/manipulator.cpp
Make use of the geometry part of libmspmath
[r2c2.git] / source / designer / manipulator.cpp
index 8620fe7af8a6a53e8c0a43fd960d509805fa736f..2ee967679428ebdf1595b74669128a194b31291a 100644 (file)
@@ -504,38 +504,12 @@ void Manipulator::selection_changed()
 
 void Manipulator::update_objects()
 {
-       Vector minp, maxp;
+       Geometry::BoundingBox<float, 3> bbox;
        for(vector<MObject>::iterator i=objects.begin(); i!=objects.end(); ++i)
-       {
-               // XXX Use generic bounding box when it is implemented
-               if(Track *track = dynamic_cast<Track *>(i->object))
-               {
-                       unsigned n_endpoints = track->get_type().get_endpoints().size();
-                       for(unsigned j=0; j<n_endpoints; ++j)
-                       {
-                               Vector p = track->get_snap_node(j).position;
-                               if(i==objects.begin() && j==0)
-                                       minp = maxp = p;
-                               else
-                               {
-                                       minp.x = min(minp.x, p.x);
-                                       maxp.x = max(maxp.x, p.x);
-                                       minp.y = min(minp.y, p.y);
-                                       maxp.y = max(maxp.y, p.y);
-                                       minp.z = min(minp.z, p.z);
-                               }
-                       }
-               }
-               else
-               {
-                       const Vector &p = i->object->get_position();
-                       minp.x = min(minp.x, p.x);
-                       maxp.x = max(maxp.x, p.x);
-                       minp.y = min(minp.y, p.y);
-                       maxp.y = max(maxp.y, p.y);
-                       minp.z = min(minp.z, p.z);
-               }
-       }
+               bbox = bbox|i->object->get_bounding_box();
+
+       const Vector &minp = bbox.get_minimum_point();
+       const Vector &maxp = bbox.get_maximum_point();
 
        center = (minp+maxp)/2.0f;
        center.z = minp.z;