#include #include #include #include #include #include SCENARIO("PhysicsSystem", "[NDK][PHYSICSSYSTEM]") { GIVEN("A world and a static entity & a dynamic entity") { Ndk::World world; const Ndk::EntityHandle& staticEntity = world.CreateEntity(); Ndk::CollisionComponent& collisionComponentStatic = staticEntity->AddComponent(); Ndk::NodeComponent& nodeComponentStatic = staticEntity->AddComponent(); const Ndk::EntityHandle& dynamicEntity = world.CreateEntity(); Ndk::NodeComponent& nodeComponentDynamic = dynamicEntity->AddComponent(); Ndk::PhysicsComponent& physicsComponentDynamic = dynamicEntity->AddComponent(); WHEN("We make collide these two entities") { nodeComponentDynamic.SetPosition(-Nz::Vector3f::UnitZ()); physicsComponentDynamic.AddForce(Nz::Vector3f::UnitZ()); THEN("The dynamic entity should have hit the static one") { world.Update(1.f); // On origin world.Update(1.f); // On origin due to collision REQUIRE(nodeComponentStatic.GetPosition().SquaredDistance(nodeComponentDynamic.GetPosition()) < 0.2f); } } } }