more raycaster tests, without repeating the hollowing every time

This commit is contained in:
tamasmeszaros 2020-01-09 16:57:11 +01:00
parent f22961edae
commit 7ac0e0a8c9

View File

@ -37,24 +37,28 @@ TEST_CASE("Raycaster with loaded drillholes", "[sla_raycast]")
emesh.load_holes(holes); emesh.load_holes(holes);
Vec3d s = center.cast<double>(); Vec3d s = center.cast<double>();
SECTION("Fire from center, should hit the interior wall") { // Fire from center, should hit the interior wall
auto hit = emesh.query_ray_hit(s, {0, 1., 0.}); auto hit = emesh.query_ray_hit(s, {0, 1., 0.});
REQUIRE(hit.distance() == Approx(boxbb.size().x() / 2 - hcfg.min_thickness)); REQUIRE(hit.distance() == Approx(boxbb.size().x() / 2 - hcfg.min_thickness));
}
SECTION("Fire upward from hole center, hit distance equals the radius") { // Fire upward from hole center, hit distance equals the radius (hits the
s.y() = hcfg.min_thickness / 2; // side of the hole cut.
auto hit = emesh.query_ray_hit(s, {0, 0., 1.}); s.y() = hcfg.min_thickness / 2;
REQUIRE(hit.distance() == Approx(radius)); hit = emesh.query_ray_hit(s, {0, 0., 1.});
} REQUIRE(hit.distance() == Approx(radius));
// Fire from outside, hit the back side of the cube interior
s.y() = -1.;
hit = emesh.query_ray_hit(s, {0, 1., 0.});
REQUIRE(hit.distance() == Approx(boxbb.max.y() - hcfg.min_thickness - s.y()));
SECTION("Fire from outside, hit the back side of the hole cylinder.") { // Fire downwards from above the hole cylinder. Has to go through the cyl.
s.y() = -1.; // as it was not there.
auto hit = emesh.query_ray_hit(s, {0, 1., 0.}); s = center.cast<double>();
REQUIRE(hit.distance() == Approx(boxbb.size().y() - hcfg.min_thickness + 1.)); s.z() = boxbb.max.z() - hcfg.min_thickness - 1.;
} hit = emesh.query_ray_hit(s, {0, 0., -1.});
REQUIRE(hit.distance() == Approx(s.z() - boxbb.min.z() - hcfg.min_thickness));
SECTION("Check for support tree correctness") {
test_support_model_collision("20mm_cube.obj", {}, hcfg, holes); // Check for support tree correctness
} test_support_model_collision("20mm_cube.obj", {}, hcfg, holes);
} }