]> Dogcows Code - chaz/yoink/blobdiff - src/cullable.hh
big batch of progress
[chaz/yoink] / src / cullable.hh
similarity index 55%
rename from src/rectangle.cc
rename to src/cullable.hh
index 0f9bb9f4a74c60977ae9141267886c665e160593..e4fe4ca7f292ee408c37f350c76a6acee31e8b9c 100644 (file)
 
 *******************************************************************************/
 
-#include <algorithm>
+#ifndef _CULLABLE_HH_
+#define _CULLABLE_HH_
 
-#include "rectangle.hh"
+#include "camera.hh"
 
 
 namespace dc {
 
 
-bool rectangle::containsRect(const rectangle& r) const
-{
-       point   o = r.origin;
-       point   s = r.size;
-       if (origin.x <= o.x && origin.y <= o.y)
-       {
-               scalar a = origin.x + size.x;
-               scalar b = origin.y + size.y;
-               scalar c = o.x + s.x;
-               scalar d = o.y + s.y;
-               return o.x <= a && o.y <= b && origin.x <= c &&
-                          origin.y <= d && c <= a && d <= b;
-       }
-       return false;
-}
+/**
+ * Interface for anything that can be culled given a camera's frustrum.
+ */
 
-bool rectangle::intersectsRect(const rectangle& r) const
+class cullable
 {
-       // TODO - Perhaps this could be optimized if it proves to be a bottleneck.
-       rectangle rect = intersectionWith(r);
-       return rect.isValid();
-}
+public:
+       virtual bool isVisible(const camera& cam) = 0;
+};
 
-rectangle rectangle::unionWith(const rectangle& r) const
-{
-       point   o = r.origin;
-       point   s = r.size;
-       scalar  a = std::min(origin.x, o.x);
-       scalar  b = std::min(origin.y, o.y);
-       return rectangle(point(a, b),
-                                        point(std::max(origin.x + size.x, o.x + s.x) - a,
-                                                        std::max(origin.y + size.y, o.y + s.y) - b));
-}
 
-rectangle rectangle::intersectionWith(const rectangle& r) const
-{
-       point   o = r.origin;
-       point   s = r.size;
-       scalar  a = std::max(origin.x, o.x);
-       scalar  b = std::max(origin.y, o.y);
-       return rectangle(point(a, b),
-                                        point(std::min(origin.x + size.x, o.x + s.x) - a,
-                                                        std::min(origin.y + size.y, o.y + s.y) - b));
-}
+} // namespace dc
 
+#endif // _CULLABLE_HH_
 
-} // namespace dc
+/** vim: set ts=4 sw=4 tw=80: *************************************************/
 
This page took 0.018682 seconds and 4 git commands to generate.