Commits

Daniel K. O. committed d73e5cf

Fixed AABB getCorner

Comments (0)

Files changed (5)

include/kode/AxisAlignedBox.hpp

 #define KODE_AXIS_ALIGNED_BOX_H
 
 #include <stdexcept>
+#include <iosfwd>
 
 #include <kode/Matrix3.hpp>
 #include <kode/Vector3.hpp>
     Vector3
     AxisAlignedBox::getCorner(unsigned i)
     {
-        return isFinite() ? Vector3{i & 1 ? max.x/2 : min.x/2,
-                                    i & 2 ? max.y/2 : min.y/2,
-                                    i & 4 ? max.z/2 : min.z/2} :
+        return isFinite() ? Vector3{i & 1 ? max.x : min.x,
+                                    i & 2 ? max.y : min.y,
+                                    i & 4 ? max.z : min.z} :
                throw std::logic_error{"AAB must be finite to have corners"};
     }
 
             return *this;
     }
 
+
+
+    std::ostream& operator<<(std::ostream& o, const AxisAlignedBox& box);
+
 }
 
 #endif

samples/KODEOgre/free-spheres.cpp

 struct Demo : public App {
 
     //SimpleSpace space;
-    //HashSpace space;
-    QuadTreeSpace space {QuadTreeSpace::Split::XZ};
+    HashSpace space;
+    //QuadTreeSpace space {QuadTreeSpace::Split::XZ};
     Collider collider;
 
     ogre::Plane ground1 = { 0.1, 1, 0.1, 0};

samples/KODEOgre/hinges.cpp

 #include <vector>
-#include <iostream>
 #include <kode/kode.hpp>
 
 #include "App.hpp"
                             }
                 );
 
-            std::clog << "hinge1 angle: " << Degree(hinge1.getAngle()) << std::endl;
             world.step();
         }
     }

src/AxisAlignedBox.cpp

+#include <ostream>
+#include <kode/AxisAlignedBox.hpp>
+
+namespace kode {
+
+    std::ostream&
+    operator<<(std::ostream& o, const AxisAlignedBox& box)
+    {
+        if (box.isEmpty())
+            o << "[]";
+        else if (box.isInfinite())
+            o << "∞";
+        else
+            o << "[" << box.getMin() << " , " << box.getMax() << "]";
+        return o;
+    }
+
+}
 
 libkode_la_SOURCES = \
     Angle.cpp \
+    AxisAlignedBox.cpp \
     Body.cpp \
     Interval.cpp \
     Line3.cpp \