4 * Created on: Apr 29, 2012
11 #include "../geometry/Ray2D.h"
12 #include "../geometry/Vector2D.h"
22 /// Base class for all "shapes" (i.e. collision primitives).
23 /// This serves as an interface for game::Entity to double dispatch the
24 /// collision detection algorithms.
29 typedef geometry::Vector2D<Scalar> Vector;
30 typedef geometry::Ray2D<Scalar> Ray;
33 virtual ~Shape(void) { };
36 /// Move the shape by given delta.
37 virtual void Translate(const Vector &delta) = 0;
38 /// Rotate the shape by given delta (in radians).
39 virtual void Rotate(Scalar delta) = 0;
42 /// Check if this shape overlaps the given and, if it does, write the
43 /// surface normal into given vector.
44 /// All shapes must override this method to dispatch to the specialized
45 /// version of CheckCollision().
46 /// See AABB::CheckCollision(const Shape &, Ray &) const for details.
47 virtual bool CheckCollision(const Shape &, Ray &) const = 0;
48 virtual bool CheckCollision(const AABB &, Ray &) const = 0;
49 virtual bool CheckCollision(const Circle &, Ray &) const = 0;
52 virtual std::ostream &Write(std::ostream &) const = 0;
57 inline std::ostream &operator <<(std::ostream &out, const Shape &s) {
63 #endif /* SHAPE_SHAPE_H_ */