X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Fobject.cpp;fp=source%2Flibr2c2%2Fobject.cpp;h=e9e58abf97041c44351a7becd185895e95f79304;hb=bde934f7d5ba07a9442a305192e10024820d13ed;hp=cc56edeb6af28883f6619dd7953c8e21925d9e15;hpb=c6cd59c4d40706ccd0f894fee3dc11c48dd20a38;p=r2c2.git diff --git a/source/libr2c2/object.cpp b/source/libr2c2/object.cpp index cc56ede..e9e58ab 100644 --- a/source/libr2c2/object.cpp +++ b/source/libr2c2/object.cpp @@ -77,4 +77,26 @@ void Object::break_links() break_link(i); } +bool Object::collide_ray(const Ray &ray) const +{ + const Shape *shape = get_type().get_shape(); + if(!shape) + return false; + + Transform reverse_trans = Transform::rotation(rotation, Vector(0, 0, -1))* + Transform::translation(-position); + return shape->check_intersection(reverse_trans.transform(ray)); +} + +BoundingBox Object::get_bounding_box() const +{ + const Shape *shape = get_type().get_shape(); + if(!shape) + return BoundingBox(); + + Transform trans = Transform::translation(position)* + Transform::rotation(rotation, Vector(0, 0, 1)); + return trans.transform(shape->get_axis_aligned_bounding_box()); +} + } // namespace R2C2