Added small test for OctTree.
This commit is contained in:
@@ -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<AABB>& ContainingBoxes() { return m_ContainingBoxes; }
|
||||
|
||||
private:
|
||||
OctTree* m_Children[8];
|
||||
std::vector<AABB> m_ContainingBoxes;
|
||||
|
||||
@@ -7,6 +7,7 @@ using boost::unit_test_framework::test_case;
|
||||
#include "Engine/Core/AABB.h"
|
||||
#include "Engine/Core/Ray.h"
|
||||
#include <stdlib.h>//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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user