]> git.localhorst.tv Git - sdl-test8.git/commitdiff
some comments
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Fri, 1 Jun 2012 21:05:45 +0000 (21:05 +0000)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Fri, 1 Jun 2012 21:05:45 +0000 (21:05 +0000)
src/app/Timer.h
src/shape/AABB.cpp
src/shape/AABB.h
src/shape/Shape.h

index 997d92c0ba510bf5d5a22dfbd983b262961da8d8..1b4fdb504aaa50bd8f1c0b3ec0e52663e0d9afca 100644 (file)
@@ -10,6 +10,9 @@
 
 namespace app {
 
+/// Objects of class keep track of the current delta and the time elapsed since
+/// their respective incarnation (which may also be tampered with).
+/// It's also possible to scale the time e.g. for slow-motion or fast-forwarding.
 class Timer {
 
        public:
index 75007ecbd5b42d3e62e53dbc84130995f7975098..71844e8c178d7e57d8c6987c16458d70231bc0a7 100644 (file)
@@ -17,12 +17,16 @@ void AABB::Translate(const Vector &delta) {
 }
 
 void AABB::Rotate(Scalar delta) {
-
+       // by definition AABBs cannot rotate
 }
 
 
 bool AABB::CheckCollision(const Shape &other, Ray &na) const {
+       // This call reveals the real type of this shape by overloading and the
+       // other one via polymorphism.
        if (other.CheckCollision(*this, na)) {
+               // Since the other shape's collision check returns its own surface
+               // normal, it has to be inverted here.
                na.Direction() *= -1;
                return true;
        } else {
index 956114aa1f8d397756340fa637b6bee6d54a818c..74d091644f1e6135a61b9f31c861973142467f0d 100644 (file)
@@ -12,6 +12,8 @@
 
 namespace shape {
 
+/// An axes aligned bounding box.
+/// This shape cannot be rotated.
 class AABB
 : public Shape {
 
index 69eedc252e7f19f1720aa55ea2a833a3b7a7591a..9feb5e1c79ad35988de4e63a0e639d8a079075ed 100644 (file)
@@ -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;