|
|
|
@ -18,6 +18,7 @@ |
|
|
|
#include "Physics/ObjectShapeGroup.h" |
|
|
|
#include "Physics/ObjectShapeGroup.h" |
|
|
|
#include "Physics/ObjectShape.h" |
|
|
|
#include "Physics/ObjectShape.h" |
|
|
|
#include "Physics/Point.h" |
|
|
|
#include "Physics/Point.h" |
|
|
|
|
|
|
|
#include "Physics/Sphere.h" |
|
|
|
#include "SceneGraph/MatrixTransformation3D.h" |
|
|
|
#include "SceneGraph/MatrixTransformation3D.h" |
|
|
|
#include "SceneGraph/Scene.h" |
|
|
|
#include "SceneGraph/Scene.h" |
|
|
|
|
|
|
|
|
|
|
|
@ -28,13 +29,15 @@ class ObjectShapeTest: public Corrade::TestSuite::Tester { |
|
|
|
ObjectShapeTest(); |
|
|
|
ObjectShapeTest(); |
|
|
|
|
|
|
|
|
|
|
|
void clean(); |
|
|
|
void clean(); |
|
|
|
|
|
|
|
void firstCollision(); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
typedef SceneGraph::Scene<SceneGraph::MatrixTransformation3D<>> Scene3D; |
|
|
|
typedef SceneGraph::Scene<SceneGraph::MatrixTransformation3D<>> Scene3D; |
|
|
|
typedef SceneGraph::Object<SceneGraph::MatrixTransformation3D<>> Object3D; |
|
|
|
typedef SceneGraph::Object<SceneGraph::MatrixTransformation3D<>> Object3D; |
|
|
|
|
|
|
|
|
|
|
|
ObjectShapeTest::ObjectShapeTest() { |
|
|
|
ObjectShapeTest::ObjectShapeTest() { |
|
|
|
addTests(&ObjectShapeTest::clean); |
|
|
|
addTests(&ObjectShapeTest::clean, |
|
|
|
|
|
|
|
&ObjectShapeTest::firstCollision); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void ObjectShapeTest::clean() { |
|
|
|
void ObjectShapeTest::clean() { |
|
|
|
@ -78,6 +81,41 @@ void ObjectShapeTest::clean() { |
|
|
|
CORRADE_VERIFY(b.isDirty()); |
|
|
|
CORRADE_VERIFY(b.isDirty()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ObjectShapeTest::firstCollision() { |
|
|
|
|
|
|
|
Scene3D scene; |
|
|
|
|
|
|
|
ObjectShapeGroup3D group; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Object3D a(&scene); |
|
|
|
|
|
|
|
ObjectShape3D* aShape = new ObjectShape3D(&a, &group); |
|
|
|
|
|
|
|
aShape->setShape(Physics::Sphere3D({1.0f, -2.0f, 3.0f}, 1.5f)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Object3D b(&scene); |
|
|
|
|
|
|
|
ObjectShape3D* bShape = new ObjectShape3D(&b, &group); |
|
|
|
|
|
|
|
bShape->setShape(Physics::Point3D({3.0f, -2.0f, 3.0f})); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Object3D c(&scene); |
|
|
|
|
|
|
|
ObjectShape3D* cShape = new ObjectShape3D(&c, &group); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* No-op if the object has no shape */ |
|
|
|
|
|
|
|
CORRADE_VERIFY(group.isDirty()); |
|
|
|
|
|
|
|
CORRADE_VERIFY(!group.firstCollision(cShape)); |
|
|
|
|
|
|
|
CORRADE_VERIFY(group.isDirty()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* No collisions initially */ |
|
|
|
|
|
|
|
CORRADE_VERIFY(!group.firstCollision(aShape)); |
|
|
|
|
|
|
|
CORRADE_VERIFY(!group.firstCollision(bShape)); |
|
|
|
|
|
|
|
CORRADE_VERIFY(!group.isDirty()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Move point into sphere */ |
|
|
|
|
|
|
|
b.translate(Vector3::xAxis(-1.0f)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Collision */ |
|
|
|
|
|
|
|
CORRADE_VERIFY(group.isDirty()); |
|
|
|
|
|
|
|
CORRADE_VERIFY(group.firstCollision(aShape) == bShape); |
|
|
|
|
|
|
|
CORRADE_VERIFY(group.firstCollision(bShape) == aShape); |
|
|
|
|
|
|
|
CORRADE_VERIFY(!group.isDirty()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}}} |
|
|
|
}}} |
|
|
|
|
|
|
|
|
|
|
|
CORRADE_TEST_MAIN(Magnum::Physics::Test::ObjectShapeTest) |
|
|
|
CORRADE_TEST_MAIN(Magnum::Physics::Test::ObjectShapeTest) |
|
|
|
|