Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
madmann91 committed Dec 1, 2020
1 parent a4508ec commit 46d9e5e
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions test/node_intersectors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,29 @@ using Ray = bvh::Ray<Scalar>;
using Bvh = bvh::Bvh<Scalar>;

template <typename NodeIntersector>
bool test() {
Ray ray(
Vector3(0.25, 0.25, 0.0), // origin
Vector3(0.0, -0.0, 1.0), // direction
0.0, // minimum distance
100.0 // maximum distance
);
bool intersect_bvh_node(const Bvh::Node& node, const Ray& ray) {
NodeIntersector node_intersector(ray);
auto [tentry, texit] = node_intersector.intersect(node, ray);
return tentry <= texit;
}

int main() {
Bvh::Node node;
node.bounds[0] = -1;
node.bounds[1] = 1;
node.bounds[2] = -1;
node.bounds[3] = 1;
node.bounds[4] = 2.1;
node.bounds[5] = 2.1;
auto [tentry, texit] = node_intersector.intersect(node, ray);
return tentry <= texit;
}

int main() {
Ray ray(
Vector3(0.25, 0.25, 0.0), // origin
Vector3(0.0, -0.0, 1.0), // direction
0.0, // minimum distance
100.0 // maximum distance
);

return
test<bvh::FastNodeIntersector<Bvh>>() &&
test<bvh::RobustNodeIntersector<Bvh>>() ? 0 : 1;
intersect_bvh_node<bvh::FastNodeIntersector<Bvh>>(node, ray) &&
intersect_bvh_node<bvh::RobustNodeIntersector<Bvh>>(node, ray) ? 0 : 1;
}

0 comments on commit 46d9e5e

Please sign in to comment.