diff --git a/include/Engine/Core/OctTree.h b/include/Engine/Core/OctTree.h index 6e80fa24..1ae447a9 100644 --- a/include/Engine/Core/OctTree.h +++ b/include/Engine/Core/OctTree.h @@ -21,11 +21,6 @@ public: //Returns true if the ray collides with something in the tree. Result is written to [data]. bool RayCollides(const Ray& ray, Output& data) const; - //Test Getters. - OctTree** Children() { return m_Children; } - const AABB& Box() { return m_Box; } - const std::vector& ContainingBoxes() { return m_ContainingBoxes; } - private: OctTree* m_Children[8]; std::vector m_ContainingBoxes; diff --git a/src/Tests/CollisionTest.cpp b/src/Tests/CollisionTest.cpp index 4d6e9f8c..762fa24e 100644 --- a/src/Tests/CollisionTest.cpp +++ b/src/Tests/CollisionTest.cpp @@ -7,6 +7,7 @@ using boost::unit_test_framework::test_case; #include "Engine/Core/AABB.h" #include "Engine/Core/Ray.h" #include //srand +#include "Engine/Core/OctTree.h" //vs memleaks //#define _CRTDBG_MAP_ALLOC @@ -86,5 +87,17 @@ BOOST_AUTO_TEST_CASE(collisionTest2) BOOST_CHECK(test >= 0); } +BOOST_AUTO_TEST_CASE(octTest) +{ + glm::vec3 mini = glm::vec3(-1, -1, -1); + glm::vec3 maxi = glm::vec3(1, 1, 1); + OctTree tree(AABB(mini, maxi), 2); + tree.AddBox(AABB(mini, 0.1f*maxi)); + OctTree::Output data; + BOOST_CHECK(tree.RayCollides({ glm::vec3(0, 0, 0), glm::normalize(mini) }, data)); + tree.ClearBoxes(); + BOOST_CHECK(!tree.RayCollides({ glm::vec3(0, 0, 0), glm::normalize(mini) }, data)); +} + BOOST_AUTO_TEST_SUITE_END()