4 * Created on: Apr 20, 2012
8 #ifndef GEOMETRY_SHAPE_H_
9 #define GEOMETRY_SHAPE_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 Vector2D<Scalar> Vector;
30 typedef std::numeric_limits<Scalar> Limits;
34 virtual ~Shape(void) { };
37 /// Check if this shape overlaps the given and, if it does, write the
38 /// surface normal into given vector.
39 /// All shapes must override this method to dispatch to the specialized
40 /// version of Overlaps().
41 /// See AABB::Overlaps(const Shape &, Vector &normal) const for details.
42 virtual bool Overlaps(const Shape &, Vector &normal) const = 0;
44 virtual bool Overlaps(const AABB &, Vector &normal) const = 0;
45 virtual bool Overlaps(const Circle &, Vector &normal) const = 0;
46 virtual bool Overlaps(const FakeLens &, Vector &normal) const = 0;
49 virtual std::ostream &Write(std::ostream &out) const = 0;
52 virtual void SetPosition(const Vector &) = 0;
53 virtual Vector Center(void) const = 0;
62 inline ostream &operator <<(ostream &out, const geometry::Shape &s) {
68 #endif /* GEOMETRY_SHAPE_H_ */