Replace floating point angle by Angle class instance

This commit is contained in:
Lynix
2018-10-09 23:20:53 +02:00
parent f02f206aff
commit dc6fbfc90f
17 changed files with 87 additions and 90 deletions

View File

@@ -85,15 +85,15 @@ SCENARIO("PhysicsSystem2D", "[NDK][PHYSICSSYSTEM2D]")
WHEN("We make rotate our entity")
{
float angularSpeed = Nz::FromDegrees(45.f);
Nz::RadianAnglef angularSpeed = Nz::DegreeToRadian(45.f);
physicsComponent2D.SetAngularVelocity(angularSpeed);
world.Update(2.f);
THEN("It should have been rotated")
{
CHECK(physicsComponent2D.GetAngularVelocity() == Approx(angularSpeed));
CHECK(physicsComponent2D.GetAngularVelocity() == angularSpeed);
CHECK(physicsComponent2D.GetAABB() == Nz::Rectf(-2.f, 0.f, 2.f, 1.f));
CHECK(physicsComponent2D.GetRotation() == Approx(Nz::FromDegrees(90.f)));
CHECK(physicsComponent2D.GetRotation() == Nz::RadianAnglef(Nz::DegreeToRadian(90.f)));
CHECK(nodeComponent.GetRotation().ToEulerAngles().roll == Approx(Nz::FromDegrees(90.f)));
}
}
@@ -129,7 +129,7 @@ SCENARIO("PhysicsSystem2D", "[NDK][PHYSICSSYSTEM2D]")
WHEN("We make rotate our entity")
{
float angularSpeed = Nz::FromDegrees(45.f);
Nz::RadianAnglef angularSpeed(Nz::DegreeToRadian(45.f));
physicsComponent2D.SetAngularVelocity(angularSpeed);
world.Update(2.f);
@@ -137,7 +137,7 @@ SCENARIO("PhysicsSystem2D", "[NDK][PHYSICSSYSTEM2D]")
{
CHECK(physicsComponent2D.GetAngularVelocity() == angularSpeed);
CHECK(physicsComponent2D.GetAABB() == Nz::Rectf(1.f, 4.f, 2.f, 1.f));
CHECK(physicsComponent2D.GetRotation() == Approx(Nz::FromDegrees(90.f)));
CHECK(physicsComponent2D.GetRotation() == 2.f * angularSpeed);
CHECK(nodeComponent.GetPosition() == position);
CHECK(nodeComponent.GetRotation().ToEulerAngles().roll == Approx(Nz::FromDegrees(90.f)));
}

View File

@@ -82,29 +82,29 @@ SCENARIO("RenderSystem", "[NDK][RenderSystem]")
WHEN("We set an angular velocity")
{
float angularSpeed = Nz::FromDegrees(90.f);
Nz::RadianAnglef angularSpeed(Nz::DegreeToRadian(90.f));
physicsComponent2D.SetAngularVelocity(angularSpeed);
world.Update(1.f);
THEN("We expect those to be true")
{
CHECK(physicsComponent2D.GetAngularVelocity() == Approx(angularSpeed));
CHECK(physicsComponent2D.GetRotation() == Approx(angularSpeed));
CHECK(physicsComponent2D.GetAngularVelocity() == angularSpeed);
CHECK(physicsComponent2D.GetRotation() == angularSpeed);
CHECK(physicsComponent2D.GetAABB() == Nz::Rectf(1.f, 4.f, 2.f, 1.f));
CompareAABB(physicsComponent2D.GetAABB(), graphicsComponent.GetAABB());
world.Update(1.f);
CHECK(physicsComponent2D.GetRotation() == Approx(2.f * angularSpeed));
CHECK(physicsComponent2D.GetRotation() == 2.f * angularSpeed);
CHECK(physicsComponent2D.GetAABB() == Nz::Rectf(2.f, 2.f, 1.f, 2.f));
CompareAABB(physicsComponent2D.GetAABB(), graphicsComponent.GetAABB());
world.Update(1.f);
CHECK(physicsComponent2D.GetRotation() == Approx(3.f * angularSpeed));
CHECK(physicsComponent2D.GetRotation() == 3.f * angularSpeed);
CHECK(physicsComponent2D.GetAABB() == Nz::Rectf(3.f, 3.f, 2.f, 1.f));
CompareAABB(physicsComponent2D.GetAABB(), graphicsComponent.GetAABB());
world.Update(1.f);
CHECK(physicsComponent2D.GetRotation() == Approx(4.f * angularSpeed));
CHECK(physicsComponent2D.GetRotation() == 4.f * angularSpeed);
}
}
}