X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fshape%2FShape.h;fp=src%2Fshape%2FShape.h;h=9feb5e1c79ad35988de4e63a0e639d8a079075ed;hb=8969939c458bda0a5a9c6ad2197e7600e4c71c86;hp=69eedc252e7f19f1720aa55ea2a833a3b7a7591a;hpb=dae78ac0fb4ecebb1ab9f2d2d1b04420ccd5d4f7;p=sdl-test8.git diff --git a/src/shape/Shape.h b/src/shape/Shape.h index 69eedc2..9feb5e1 100644 --- a/src/shape/Shape.h +++ b/src/shape/Shape.h @@ -19,6 +19,9 @@ namespace shape { class AABB; class Circle; +/// Base class for all "shapes" (i.e. collision primitives). +/// This serves as an interface for game::Entity to double dispatch the +/// collision detection algorithms. class Shape { public: @@ -30,10 +33,17 @@ class Shape { virtual ~Shape(void) { }; public: + /// Move the shape by given delta. virtual void Translate(const Vector &delta) = 0; + /// Rotate the shape by given delta (in radians). virtual void Rotate(Scalar delta) = 0; public: + /// Check if this shape overlaps the given and, if it does, write the + /// surface normal into given vector. + /// All shapes must override this method to dispatch to the specialized + /// version of CheckCollision(). + /// See AABB::CheckCollision(const Shape &, Ray &) const for details. virtual bool CheckCollision(const Shape &, Ray &) const = 0; virtual bool CheckCollision(const AABB &, Ray &) const = 0; virtual bool CheckCollision(const Circle &, Ray &) const = 0;