+const Shape *Object::get_shape() const
+{
+ if(shape)
+ return shape;
+ return get_type().get_shape();
+}
+
+bool Object::collide_ray(const Ray &ray, float *d) const
+{
+ const Shape *s = get_shape();
+ if(!s)
+ return false;
+
+ Transform reverse_trans = Transform::rotation(rotation, Vector(0, 0, -1))*
+ Transform::translation(-position);
+ if(d)
+ {
+ vector<Geometry::SurfacePoint<float, 3> > 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());
+}
+