Example #1
0
void PlaneTest::collisionLineSegment() {
    Shapes::Plane plane(Vector3(), Vector3::yAxis());
    Shapes::LineSegment3D line({0.0f, -0.1f, 0.0f}, {0.0f, 7.0f, 0.0f});
    Shapes::LineSegment3D line2({0.0f, 0.1f, 0.0f}, {0.0f, 7.0f, 0.0f});
    Shapes::LineSegment3D line3({0.0f, -7.0f, 0.0f}, {0.0f, -0.1f, 0.0f});

    VERIFY_COLLIDES(plane, line);
    VERIFY_NOT_COLLIDES(plane, line2);
    VERIFY_NOT_COLLIDES(plane, line3);
}
Example #2
0
void PlaneTest::collisionLineSegment() {
    Physics::Plane plane(Vector3(), Vector3::yAxis());
    Physics::LineSegment3D line({0.0f, -0.1f, 0.0f}, {0.0f, 7.0f, 0.0f});
    Physics::LineSegment3D line2({0.0f, 0.1f, 0.0f}, {0.0f, 7.0f, 0.0f});
    Physics::LineSegment3D line3({0.0f, -7.0f, 0.0f}, {0.0f, -0.1f, 0.0f});

    randomTransformation(plane);
    randomTransformation(line);
    randomTransformation(line2);
    randomTransformation(line3);

    VERIFY_COLLIDES(plane, line);
    VERIFY_NOT_COLLIDES(plane, line2);
    VERIFY_NOT_COLLIDES(plane, line3);
}
Example #3
0
void CompositionTest::empty() {
    const Shapes::Composition2D a;

    CORRADE_COMPARE(a.size(), 0);

    VERIFY_NOT_COLLIDES(a, Shapes::Sphere2D({}, 1.0f));
}
void SphereTest::collisionLineSegment() {
    Shapes::Sphere3D sphere({1.0f, 2.0f, 3.0f}, 2.0f);
    Shapes::LineSegment3D line({1.0f, 2.0f, 4.9f}, {1.0f, 2.0f, 7.0f});
    Shapes::LineSegment3D line2({1.0f, 2.0f, 5.1f}, {1.0f, 2.0f, 7.0f});

    VERIFY_COLLIDES(sphere, line);
    VERIFY_NOT_COLLIDES(sphere, line2);
}
void SphereTest::collisionLine() {
    Shapes::Sphere3D sphere({1.0f, 2.0f, 3.0f}, 2.0f);
    Shapes::Line3D line({1.0f, 1.5f, 3.5f}, {1.0f, 2.5f, 2.5f});
    Shapes::Line3D line2({1.0f, 2.0f, 5.1f}, {1.0f, 3.0f, 5.1f});

    VERIFY_COLLIDES(sphere, line);
    VERIFY_NOT_COLLIDES(sphere, line2);
}
Example #6
0
void AxisAlignedBoxTest::collisionPoint() {
    Shapes::AxisAlignedBox3D box({-1.0f, -2.0f, -3.0f}, {1.0f, 2.0f, 3.0f});
    Shapes::Point3D point1({-1.5f, -1.0f, 2.0f});
    Shapes::Point3D point2({0.5f, 1.0f, -2.5f});

    VERIFY_NOT_COLLIDES(box, point1);
    VERIFY_COLLIDES(box, point2);
}
Example #7
0
void CompositionTest::negated() {
    const Shapes::Composition2D a = !Shapes::Point2D(Vector2::xAxis(0.5f));

    CORRADE_COMPARE(a.size(), 1);
    CORRADE_COMPARE(a.type(0), Composition2D::Type::Point);
    CORRADE_COMPARE(a.get<Shapes::Point2D>(0).position(), Vector2::xAxis(0.5f));

    VERIFY_NOT_COLLIDES(a, Shapes::Sphere2D({}, 1.0f));
}
Example #8
0
void CapsuleTest::collisionSphere() {
    Shapes::Capsule3D capsule({-1.0f, -1.0f, 0.0f}, {1.0f, 1.0f, 0.0f}, 2.0f);
    Shapes::Sphere3D sphere({3.0f, 0.0f, 0.0f}, 0.9f);
    Shapes::Sphere3D sphere1({3.5f, 1.0f, 0.0f}, 0.6f);
    Shapes::Sphere3D sphere2({1.0f, 4.1f, 0.0f}, 1.0f);

    VERIFY_COLLIDES(capsule, sphere);
    VERIFY_COLLIDES(capsule, sphere1);
    VERIFY_NOT_COLLIDES(capsule, sphere2);
}
Example #9
0
void CylinderTest::collisionSphere() {
    Shapes::Cylinder3D cylinder({-1.0f, -1.0f, 0.0f}, {1.0f, 1.0f, 0.0f}, 2.0f);
    Shapes::Sphere3D sphere({3.0f, 0.0f, 0.0f}, 0.9f);
    Shapes::Sphere3D sphere1({1.0f, 4.1f, 0.0f}, 1.0f);
    Shapes::Sphere3D sphere2({3.5f, -1.0f, 0.0f}, 0.6f);

    VERIFY_COLLIDES(cylinder, sphere);
    VERIFY_COLLIDES(cylinder, sphere1);
    VERIFY_NOT_COLLIDES(cylinder, sphere2);
}
Example #10
0
void CylinderTest::collisionPoint() {
    Shapes::Cylinder3D cylinder({-1.0f, -1.0f, 0.0f}, {1.0f, 1.0f, 0.0f}, 2.0f);
    Shapes::Point3D point({2.0f, 0.0f, 0.0f});
    Shapes::Point3D point1({1.0f, 3.1f, 0.0f});
    Shapes::Point3D point2({2.9f, -1.0f, 0.0f});

    VERIFY_COLLIDES(cylinder, point);
    VERIFY_COLLIDES(cylinder, point1);
    VERIFY_NOT_COLLIDES(cylinder, point2);
}
Example #11
0
void CapsuleTest::collisionPoint() {
    Shapes::Capsule3D capsule({-1.0f, -1.0f, 0.0f}, {1.0f, 1.0f, 0.0f}, 2.0f);
    Shapes::Point3D point({2.0f, 0.0f, 0.0f});
    Shapes::Point3D point1({2.9f, 1.0f, 0.0f});
    Shapes::Point3D point2({1.0f, 3.1f, 0.0f});

    VERIFY_COLLIDES(capsule, point);
    VERIFY_COLLIDES(capsule, point1);
    VERIFY_NOT_COLLIDES(capsule, point2);
}
Example #12
0
void SphereTest::collisionSphere() {
    Physics::Sphere3D sphere({1.0f, 2.0f, 3.0f}, 2.0f);
    Physics::Sphere3D sphere1({1.0f, 3.0f, 5.0f}, 1.0f);
    Physics::Sphere3D sphere2({1.0f, 3.0f, 0.0f}, 1.0f);

    randomTransformation(sphere);
    randomTransformation(sphere1);
    randomTransformation(sphere2);

    VERIFY_COLLIDES(sphere, sphere1);
    VERIFY_NOT_COLLIDES(sphere, sphere2);
}
Example #13
0
void AxisAlignedBoxTest::collisionPoint() {
    Physics::AxisAlignedBox3D box({-1.0f, -2.0f, -3.0f}, {1.0f, 2.0f, 3.0f});
    Physics::Point3D point1({-1.5f, -1.0f, 2.0f});
    Physics::Point3D point2({0.5f, 1.0f, -2.5f});

    randomTransformation(box);
    randomTransformation(point1);
    randomTransformation(point2);

    VERIFY_NOT_COLLIDES(box, point1);
    VERIFY_COLLIDES(box, point2);
}
Example #14
0
void SphereTest::collisionLineSegment() {
    Physics::Sphere3D sphere({1.0f, 2.0f, 3.0f}, 2.0f);
    Physics::LineSegment3D line({1.0f, 2.0f, 4.9f}, {1.0f, 2.0f, 7.0f});
    Physics::LineSegment3D line2({1.0f, 2.0f, 5.1f}, {1.0f, 2.0f, 7.0f});

    randomTransformation(sphere);
    randomTransformation(line);
    randomTransformation(line2);

    VERIFY_COLLIDES(sphere, line);
    VERIFY_NOT_COLLIDES(sphere, line2);
}
Example #15
0
void SphereTest::collisionPoint() {
    Physics::Sphere3D sphere({1.0f, 2.0f, 3.0f}, 2.0f);
    Physics::Point3D point({1.0f, 3.0f, 3.0f});
    Physics::Point3D point2({1.0f, 3.0f, 1.0f});

    randomTransformation(sphere);
    randomTransformation(point);
    randomTransformation(point2);

    VERIFY_COLLIDES(sphere, point);
    VERIFY_NOT_COLLIDES(sphere, point2);
}
Example #16
0
void CompositionTest::anded() {
    const Shapes::Composition2D a = Shapes::Sphere2D({}, 1.0f) && Shapes::Point2D(Vector2::xAxis(0.5f));

    CORRADE_COMPARE(a.size(), 2);
    CORRADE_COMPARE(a.type(0), Composition2D::Type::Sphere);
    CORRADE_COMPARE(a.type(1), Composition2D::Type::Point);
    CORRADE_COMPARE(a.get<Shapes::Sphere2D>(0).position(), Vector2());
    CORRADE_COMPARE(a.get<Shapes::Sphere2D>(0).radius(), 1.0f);
    CORRADE_COMPARE(a.get<Shapes::Point2D>(1).position(), Vector2::xAxis(0.5f));

    VERIFY_NOT_COLLIDES(a, Shapes::Point2D());
    VERIFY_COLLIDES(a, Shapes::Sphere2D(Vector2::xAxis(0.5f), 0.25f));
}
Example #17
0
void CompositionTest::hierarchy() {
    const Shapes::Composition3D a = Shapes::Sphere3D({}, 1.0f) &&
        (Shapes::Point3D(Vector3::xAxis(1.5f)) || !Shapes::AxisAlignedBox3D({}, Vector3(0.5f)));

    CORRADE_COMPARE(a.size(), 3);
    CORRADE_COMPARE(a.type(0), Composition3D::Type::Sphere);
    CORRADE_COMPARE(a.type(1), Composition3D::Type::Point);
    CORRADE_COMPARE(a.type(2), Composition3D::Type::AxisAlignedBox);
    CORRADE_COMPARE(a.get<Shapes::Point3D>(1).position(), Vector3::xAxis(1.5f));

    VERIFY_COLLIDES(a, Shapes::Sphere3D(Vector3::xAxis(1.5f), 0.6f));
    VERIFY_NOT_COLLIDES(a, Shapes::Point3D(Vector3(0.25f)));
}
Example #18
0
void CapsuleTest::collisionSphere() {
    Physics::Capsule3D capsule({-1.0f, -1.0f, 0.0f}, {1.0f, 1.0f, 0.0f}, 2.0f);
    Physics::Sphere3D sphere({3.0f, 0.0f, 0.0f}, 0.9f);
    Physics::Sphere3D sphere1({3.5f, 1.0f, 0.0f}, 0.6f);
    Physics::Sphere3D sphere2({1.0f, 4.1f, 0.0f}, 1.0f);

    randomTransformation(capsule);
    randomTransformation(sphere);
    randomTransformation(sphere1);
    randomTransformation(sphere2);

    VERIFY_COLLIDES(capsule, sphere);
    VERIFY_COLLIDES(capsule, sphere1);
    VERIFY_NOT_COLLIDES(capsule, sphere2);
}
Example #19
0
void CapsuleTest::collisionPoint() {
    Physics::Capsule3D capsule({-1.0f, -1.0f, 0.0f}, {1.0f, 1.0f, 0.0f}, 2.0f);
    Physics::Point3D point({2.0f, 0.0f, 0.0f});
    Physics::Point3D point1({2.9f, 1.0f, 0.0f});
    Physics::Point3D point2({1.0f, 3.1f, 0.0f});

    randomTransformation(capsule);
    randomTransformation(point);
    randomTransformation(point1);
    randomTransformation(point2);

    VERIFY_COLLIDES(capsule, point);
    VERIFY_COLLIDES(capsule, point1);
    VERIFY_NOT_COLLIDES(capsule, point2);
}