|
|
|
|
@ -25,14 +25,14 @@
|
|
|
|
|
#include <TestSuite/Tester.h> |
|
|
|
|
|
|
|
|
|
#include "Math/Matrix4.h" |
|
|
|
|
#include "Physics/Point.h" |
|
|
|
|
#include "Physics/AxisAlignedBox.h" |
|
|
|
|
#include "Physics/Composition.h" |
|
|
|
|
#include "Physics/Sphere.h" |
|
|
|
|
#include "Shapes/Point.h" |
|
|
|
|
#include "Shapes/AxisAlignedBox.h" |
|
|
|
|
#include "Shapes/Composition.h" |
|
|
|
|
#include "Shapes/Sphere.h" |
|
|
|
|
|
|
|
|
|
#include "ShapeTestBase.h" |
|
|
|
|
|
|
|
|
|
namespace Magnum { namespace Physics { namespace Test { |
|
|
|
|
namespace Magnum { namespace Shapes { namespace Test { |
|
|
|
|
|
|
|
|
|
class CompositionTest: public Corrade::TestSuite::Tester { |
|
|
|
|
public: |
|
|
|
|
@ -56,75 +56,75 @@ CompositionTest::CompositionTest() {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void CompositionTest::negated() { |
|
|
|
|
const Physics::Composition2D a = !Physics::Point2D(Vector2::xAxis(0.5f)); |
|
|
|
|
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<Physics::Point2D>(0).position(), Vector2::xAxis(0.5f)); |
|
|
|
|
CORRADE_COMPARE(a.get<Shapes::Point2D>(0).position(), Vector2::xAxis(0.5f)); |
|
|
|
|
|
|
|
|
|
VERIFY_NOT_COLLIDES(a, Physics::Sphere2D({}, 1.0f)); |
|
|
|
|
VERIFY_NOT_COLLIDES(a, Shapes::Sphere2D({}, 1.0f)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void CompositionTest::anded() { |
|
|
|
|
const Physics::Composition2D a = Physics::Sphere2D({}, 1.0f) && Physics::Point2D(Vector2::xAxis(0.5f)); |
|
|
|
|
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<Physics::Sphere2D>(0).position(), Vector2()); |
|
|
|
|
CORRADE_COMPARE(a.get<Physics::Sphere2D>(0).radius(), 1.0f); |
|
|
|
|
CORRADE_COMPARE(a.get<Physics::Point2D>(1).position(), Vector2::xAxis(0.5f)); |
|
|
|
|
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, Physics::Point2D()); |
|
|
|
|
VERIFY_COLLIDES(a, Physics::Sphere2D(Vector2::xAxis(0.5f), 0.25f)); |
|
|
|
|
VERIFY_NOT_COLLIDES(a, Shapes::Point2D()); |
|
|
|
|
VERIFY_COLLIDES(a, Shapes::Sphere2D(Vector2::xAxis(0.5f), 0.25f)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void CompositionTest::ored() { |
|
|
|
|
const Physics::Composition2D a = Physics::Sphere2D({}, 1.0f) || Physics::Point2D(Vector2::xAxis(1.5f)); |
|
|
|
|
const Shapes::Composition2D a = Shapes::Sphere2D({}, 1.0f) || Shapes::Point2D(Vector2::xAxis(1.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<Physics::Sphere2D>(0).position(), Vector2()); |
|
|
|
|
CORRADE_COMPARE(a.get<Physics::Sphere2D>(0).radius(), 1.0f); |
|
|
|
|
CORRADE_COMPARE(a.get<Physics::Point2D>(1).position(), Vector2::xAxis(1.5f)); |
|
|
|
|
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(1.5f)); |
|
|
|
|
|
|
|
|
|
VERIFY_COLLIDES(a, Physics::Point2D()); |
|
|
|
|
VERIFY_COLLIDES(a, Physics::Sphere2D(Vector2::xAxis(1.5f), 0.25f)); |
|
|
|
|
VERIFY_COLLIDES(a, Shapes::Point2D()); |
|
|
|
|
VERIFY_COLLIDES(a, Shapes::Sphere2D(Vector2::xAxis(1.5f), 0.25f)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void CompositionTest::multipleUnary() { |
|
|
|
|
const Physics::Composition2D a = !!!!Physics::Point2D(Vector2::xAxis(0.5f)); |
|
|
|
|
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<Physics::Point2D>(0).position(), Vector2::xAxis(0.5f)); |
|
|
|
|
CORRADE_COMPARE(a.get<Shapes::Point2D>(0).position(), Vector2::xAxis(0.5f)); |
|
|
|
|
|
|
|
|
|
VERIFY_COLLIDES(a, Physics::Sphere2D({}, 1.0f)); |
|
|
|
|
VERIFY_COLLIDES(a, Shapes::Sphere2D({}, 1.0f)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void CompositionTest::hierarchy() { |
|
|
|
|
const Physics::Composition3D a = Physics::Sphere3D({}, 1.0f) && |
|
|
|
|
(Physics::Point3D(Vector3::xAxis(1.5f)) || !Physics::AxisAlignedBox3D({}, Vector3(0.5f))); |
|
|
|
|
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<Physics::Point3D>(1).position(), Vector3::xAxis(1.5f)); |
|
|
|
|
CORRADE_COMPARE(a.get<Shapes::Point3D>(1).position(), Vector3::xAxis(1.5f)); |
|
|
|
|
|
|
|
|
|
VERIFY_COLLIDES(a, Physics::Sphere3D(Vector3::xAxis(1.5f), 0.6f)); |
|
|
|
|
VERIFY_NOT_COLLIDES(a, Physics::Point3D(Vector3(0.25f))); |
|
|
|
|
VERIFY_COLLIDES(a, Shapes::Sphere3D(Vector3::xAxis(1.5f), 0.6f)); |
|
|
|
|
VERIFY_NOT_COLLIDES(a, Shapes::Point3D(Vector3(0.25f))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void CompositionTest::empty() { |
|
|
|
|
const Physics::Composition2D a; |
|
|
|
|
const Shapes::Composition2D a; |
|
|
|
|
|
|
|
|
|
CORRADE_COMPARE(a.size(), 0); |
|
|
|
|
|
|
|
|
|
VERIFY_NOT_COLLIDES(a, Physics::Sphere2D({}, 1.0f)); |
|
|
|
|
VERIFY_NOT_COLLIDES(a, Shapes::Sphere2D({}, 1.0f)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}}} |
|
|
|
|
|
|
|
|
|
CORRADE_TEST_MAIN(Magnum::Physics::Test::CompositionTest) |
|
|
|
|
CORRADE_TEST_MAIN(Magnum::Shapes::Test::CompositionTest) |