Commit ce69f257 authored by Lukas Werner's avatar Lukas Werner
Browse files

Updated raytracing tests

parent 6ca2ac89
......@@ -38,7 +38,7 @@ void SphereIntersectsTest()
WALBERLA_CHECK(realIsEqual(t, real_t(6)))
// ray tangential
Ray ray2(Vec3(3,-5,3), Vec3(0,7.5,real_t(std::sqrt(real_t(15))/real_t(2))));
Ray ray2(Vec3(3,-5,3), Vec3(0,7.5,real_t(std::sqrt(real_t(15))/real_t(2))).getNormalized());
WALBERLA_CHECK(!intersects(&sp1, &ray2, &t));
// sphere behind ray origin
......@@ -63,7 +63,7 @@ void PlaneIntersectsTest() {
WALBERLA_CHECK(intersects(&pl1, &ray1, &t), "ray through center did not hit");
WALBERLA_CHECK(realIsEqual(t, real_t(8)), "distance between ray and plane is incorrect");
Ray ray2(Vec3(-5,3,3), Vec3(1,0,-1));
Ray ray2(Vec3(-5,3,3), Vec3(1,0,-1).getNormalized());
WALBERLA_CHECK(intersects(&pl1, &ray2, &t), "ray towards random point on plane didn't hit");
WALBERLA_CHECK(realIsEqual(t, real_t(sqrt(real_t(128)))), "distance between ray and plane is incorrect");
......@@ -95,15 +95,15 @@ void BoxIntersectsTest() {
WALBERLA_CHECK(realIsEqual(t, real_t(5)));
// ray origin within box
Ray ray2(Vec3(-2,0,0), Vec3(1,0,1));
Ray ray2(Vec3(-2,0,0), Vec3(1,0,1).getNormalized());
WALBERLA_CHECK(intersects(&box3, &ray2, &t));
WALBERLA_CHECK(realIsEqual(t, real_t(7.0710), 1e-4));
Ray ray3(Vec3(3,-5,3), Vec3(2, -1.5, 0.5));
Ray ray3(Vec3(3,-5,3), Vec3(2, -1.5, 0.5).getNormalized());
Box box4(128, 5, Vec3(0, 8, 0), Vec3(0, 0, 0), Quat(), Vec3(10, 10, 10), iron, false, true, false);
WALBERLA_CHECK(!intersects(&box4, &ray3, &t));
Ray ray4(Vec3(3,-5,3), Vec3(-2, 3, 0.5));
Ray ray4(Vec3(3,-5,3), Vec3(-2, 3, 0.5).getNormalized());
WALBERLA_CHECK(intersects(&box4, &ray4, &t));
WALBERLA_CHECK(realIsEqual(t, real_t(9.7068), 1e-4));
......@@ -112,8 +112,6 @@ void BoxIntersectsTest() {
Ray ray5(Vec3(0,1.5,0), Vec3(1,0,0));
WALBERLA_CHECK(intersects(&box5, &ray5, &t));
WALBERLA_CHECK(realIsEqual(t, real_t(2.67157), 1e-4));
WALBERLA_LOG_INFO("intersects: " << intersects(&box5, &ray5, &t) << ", t = " << t);
}
int main( int argc, char** argv )
......@@ -123,8 +121,8 @@ int main( int argc, char** argv )
SetBodyTypeIDs<BodyTuple>::execute();
//SphereIntersectsTest();
//PlaneIntersectsTest();
SphereIntersectsTest();
PlaneIntersectsTest();
BoxIntersectsTest();
return EXIT_SUCCESS;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment