Rename Physics2D to ChipmunkPhysics2D

This commit is contained in:
SirLynix
2023-04-10 13:49:36 +02:00
committed by Jérôme Leclercq
parent b1255ad2ad
commit 26b23ccce6
54 changed files with 1620 additions and 1620 deletions

View File

@@ -1,4 +1,4 @@
#include <Nazara/Physics2D/Collider2D.hpp>
#include <Nazara/ChipmunkPhysics2D/ChipmunkCollider2D.hpp>
#include <catch2/catch_approx.hpp>
#include <catch2/catch_test_macros.hpp>
@@ -9,13 +9,13 @@ SCENARIO("Collider2D", "[PHYSICS2D][COLLIDER2D]")
WHEN("We construct a box with Rect")
{
Nz::Rectf aabb(5.f, 3.f, 10.f, 6.f);
Nz::BoxCollider2D box(aabb);
Nz::ChipmunkBoxCollider2D box(aabb);
THEN("We expect those to be true")
{
CHECK(box.GetRect() == aabb);
CHECK(box.GetSize() == aabb.GetLengths());
CHECK(box.GetType() == Nz::ColliderType2D::Box);
CHECK(box.GetType() == Nz::ChipmunkColliderType2D::Box);
}
}
@@ -23,13 +23,13 @@ SCENARIO("Collider2D", "[PHYSICS2D][COLLIDER2D]")
{
Nz::Vector2f vec(5.f, 3.f);
Nz::Rectf aabb(-2.5f, -1.5f, 5.f, 3.f);
Nz::BoxCollider2D box(vec);
Nz::ChipmunkBoxCollider2D box(vec);
THEN("We expect those to be true")
{
CHECK(box.GetRect() == aabb);
CHECK(box.GetSize() == vec);
CHECK(box.GetType() == Nz::ColliderType2D::Box);
CHECK(box.GetType() == Nz::ChipmunkColliderType2D::Box);
}
}
@@ -37,30 +37,30 @@ SCENARIO("Collider2D", "[PHYSICS2D][COLLIDER2D]")
{
Nz::Vector2f position(5.f, 3.f);
float radius = 7.f;
Nz::CircleCollider2D circle(radius, position);
Nz::ChipmunkCircleCollider2D circle(radius, position);
THEN("We expect those to be true")
{
CHECK(circle.GetRadius() == Catch::Approx(radius));
CHECK(circle.GetType() == Nz::ColliderType2D::Circle);
CHECK(circle.GetType() == Nz::ChipmunkColliderType2D::Circle);
}
}
WHEN("We construct a compound")
{
Nz::Rectf aabb(0.f, 0.f, 1.f, 1.f);
std::shared_ptr<Nz::BoxCollider2D> box1 = std::make_shared<Nz::BoxCollider2D>(aabb);
std::shared_ptr<Nz::ChipmunkBoxCollider2D> box1 = std::make_shared<Nz::ChipmunkBoxCollider2D>(aabb);
aabb.Translate(Nz::Vector2f::Unit());
std::shared_ptr<Nz::BoxCollider2D> box2 = std::make_shared<Nz::BoxCollider2D>(aabb);
std::shared_ptr<Nz::ChipmunkBoxCollider2D> box2 = std::make_shared<Nz::ChipmunkBoxCollider2D>(aabb);
std::vector<std::shared_ptr<Nz::Collider2D>> colliders;
std::vector<std::shared_ptr<Nz::ChipmunkCollider2D>> colliders;
colliders.push_back(box1);
colliders.push_back(box2);
Nz::CompoundCollider2D compound(colliders);
Nz::ChipmunkCompoundCollider2D compound(colliders);
THEN("We expect those to be true")
{
CHECK(compound.GetType() == Nz::ColliderType2D::Compound);
CHECK(compound.GetType() == Nz::ChipmunkColliderType2D::Compound);
}
}
@@ -72,21 +72,21 @@ SCENARIO("Collider2D", "[PHYSICS2D][COLLIDER2D]")
vertices.push_back(Nz::Vector2f(1.f, 1.f));
vertices.push_back(Nz::Vector2f(1.f, 0.f));
Nz::ConvexCollider2D convex(Nz::SparsePtr<const Nz::Vector2f>(vertices.data()), vertices.size());
Nz::ChipmunkConvexCollider2D convex(Nz::SparsePtr<const Nz::Vector2f>(vertices.data()), vertices.size());
THEN("We expect those to be true")
{
CHECK(convex.GetType() == Nz::ColliderType2D::Convex);
CHECK(convex.GetType() == Nz::ChipmunkColliderType2D::Convex);
}
}
WHEN("We construct a null")
{
Nz::NullCollider2D null;
Nz::ChipmunkNullCollider2D null;
THEN("We expect those to be true")
{
CHECK(null.GetType() == Nz::ColliderType2D::Null);
CHECK(null.GetType() == Nz::ChipmunkColliderType2D::Null);
}
}
@@ -94,21 +94,21 @@ SCENARIO("Collider2D", "[PHYSICS2D][COLLIDER2D]")
{
Nz::Vector2f firstPoint(2.f, 1.f);
Nz::Vector2f secondPoint(-4.f, -3.f);
Nz::SegmentCollider2D segment(firstPoint, secondPoint);
Nz::ChipmunkSegmentCollider2D segment(firstPoint, secondPoint);
THEN("We expect those to be true")
{
CHECK(segment.GetFirstPoint() == firstPoint);
CHECK(segment.GetLength() == Catch::Approx(firstPoint.Distance(secondPoint)));
CHECK(segment.GetSecondPoint() == secondPoint);
CHECK(segment.GetType() == Nz::ColliderType2D::Segment);
CHECK(segment.GetType() == Nz::ChipmunkColliderType2D::Segment);
}
}
WHEN("We verify general purpose methods")
{
Nz::Rectf aabb(5.f, 3.f, 10.f, 6.f);
Nz::BoxCollider2D box(aabb);
Nz::ChipmunkBoxCollider2D box(aabb);
Nz::UInt32 categoryMask = 1;
Nz::UInt32 groupId = 2;