Fix wrong aabb returned from PhysicsComponent2D (#127)

This commit is contained in:
Gawaboumga
2017-06-20 06:53:39 +02:00
committed by Jérôme Leclercq
parent 6ff510ad4a
commit 47a22c2785
3 changed files with 42 additions and 5 deletions

View File

@@ -0,0 +1,34 @@
#include <NDK/Systems/PhysicsSystem2D.hpp>
#include <NDK/World.hpp>
#include <NDK/Components/CollisionComponent2D.hpp>
#include <NDK/Components/NodeComponent.hpp>
#include <NDK/Components/PhysicsComponent2D.hpp>
#include <Catch/catch.hpp>
SCENARIO("PhysicsSystem2D", "[NDK][PHYSICSSYSTEM2D]")
{
GIVEN("A world and an entity")
{
Ndk::World world;
const Ndk::EntityHandle& entity = world.CreateEntity();
Ndk::NodeComponent& nodeComponent = entity->AddComponent<Ndk::NodeComponent>();
Nz::Vector2f position(2.f, 3.f);
nodeComponent.SetPosition(position);
Nz::Rectf aabb(0.f, 0.f, 16.f, 18.f);
Nz::BoxCollider2DRef collisionBox = Nz::BoxCollider2D::New(aabb);
Ndk::CollisionComponent2D& collisionComponent = entity->AddComponent<Ndk::CollisionComponent2D>(collisionBox);
Ndk::PhysicsComponent2D& physicsComponent = entity->AddComponent<Ndk::PhysicsComponent2D>();
WHEN("We update the world")
{
world.Update(1.f);
THEN("Entity should have correct bounding box")
{
REQUIRE(nodeComponent.GetPosition() == position);
aabb.Translate(position);
REQUIRE(physicsComponent.GetAABB() == aabb);
}
}
}
}

View File

@@ -5,7 +5,7 @@
#include <NDK/Components/PhysicsComponent3D.hpp>
#include <Catch/catch.hpp>
SCENARIO("PhysicsSystem", "[NDK][PHYSICSSYSTEM]")
SCENARIO("PhysicsSystem3D", "[NDK][PHYSICSSYSTEM3D]")
{
GIVEN("A world and a static entity & a dynamic entity")
{