Skip to content

Commit

Permalink
Implement sphere intersection test
Browse files Browse the repository at this point in the history
  • Loading branch information
JacksonCampolattaro committed Aug 20, 2020
1 parent 7eda09d commit d29ec3d
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions Octree/test/Octree/test_octree_intersecting.cpp
Expand Up @@ -61,12 +61,21 @@ int main(void) {
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
{
// Set the search point
auto query = Kernel::Sphere_3(Point{1, 1, 1}, 4.0);
auto query = Kernel::Sphere_3(Point{1, 0.5, 1}, 1.0);

// Get a list of nodes intersected
std::vector<const Octree::Node *> nodes{};
octree.intersecting_nodes(query, std::back_inserter(nodes));

// Print out the results
for (auto node : nodes)
std::cout << *node << std::endl;

assert(4 == nodes.size());
assert(octree[Octree::Node::RIGHT_TOP_BACK] == *nodes[0]);
assert(octree[Octree::Node::RIGHT_BOTTOM_FRONT] == *nodes[1]);
assert(octree[Octree::Node::LEFT_TOP_FRONT] == *nodes[2]);
assert(octree[Octree::Node::RIGHT_TOP_FRONT] == *nodes[3]);
}

// Intersection with a ray
Expand All @@ -81,8 +90,5 @@ int main(void) {

}

// Print out the tree
std::cout << octree;

return EXIT_SUCCESS;
}

0 comments on commit d29ec3d

Please sign in to comment.