X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Fobject.cpp;h=7a896b6581b40c849e5a3296c513260038b4c230;hb=23e1a988da2efae47e39d93babe7e37b1c0ca554;hp=1b48a862ae6b634c499fa49c094e54bc5c41cb05;hpb=b88d3630a0e3fdd763db018bbe5dbfe3180a95f2;p=r2c2.git diff --git a/source/libr2c2/object.cpp b/source/libr2c2/object.cpp index 1b48a86..7a896b6 100644 --- a/source/libr2c2/object.cpp +++ b/source/libr2c2/object.cpp @@ -2,9 +2,15 @@ #include "object.h" using namespace std; +using namespace Msp; namespace R2C2 { +Object::Object(Layout &l): + layout(l), + shape(0) +{ } + Snap Object::get_snap_node(unsigned) const { throw out_of_range("Object::get_snap_node"); @@ -18,8 +24,8 @@ bool Object::snap(Snap &sn, float limit, SnapType what) const for(unsigned i=0; i > points = s->get_intersections(reverse_trans.transform(ray)); + if(points.empty()) + return false; + *d = points.front().distance; + return true; + } + else + return s->check_intersection(reverse_trans.transform(ray)); +} + +BoundingBox Object::get_bounding_box() const +{ + const Shape *s = get_shape(); + if(!s) + return BoundingBox(); + + Transform trans = Transform::translation(position)* + Transform::rotation(rotation, Vector(0, 0, 1)); + return trans.transform(s->get_axis_aligned_bounding_box()); +} + } // namespace R2C2