diff --git a/ChangeLog.md b/ChangeLog.md index 1c4e14c6a..7ca8835ef 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -157,6 +157,7 @@ Nazara Engine: - ⚠ SoundStream is now responsible for loaders instead of Music, and is now threadsafe (you can now load a stream only once and play it multiple times at the same time) - Added LuaState::RawEqual - Fixed LuaCoroutine movement assignation operator +- Added Arbiter2D::GetBodies Nazara Development Kit: - Added ImageWidget (#139) diff --git a/include/Nazara/Physics2D/Arbiter2D.hpp b/include/Nazara/Physics2D/Arbiter2D.hpp index 64c38dd8d..b8683e2eb 100644 --- a/include/Nazara/Physics2D/Arbiter2D.hpp +++ b/include/Nazara/Physics2D/Arbiter2D.hpp @@ -16,6 +16,8 @@ struct cpArbiter; namespace Nz { + class RigidBody2D; + class NAZARA_PHYSICS2D_API Arbiter2D { public: @@ -27,22 +29,24 @@ namespace Nz float ComputeTotalKinematicEnergy() const; Nz::Vector2f ComputeTotalImpulse() const; + std::pair GetBodies() const; + std::size_t GetContactCount() const; float GetContactDepth(std::size_t i) const; - Nz::Vector2f GetContactPointA(std::size_t i) const; - Nz::Vector2f GetContactPointB(std::size_t i) const; + Vector2f GetContactPointA(std::size_t i) const; + Vector2f GetContactPointB(std::size_t i) const; float GetElasticity() const; float GetFriction() const; - Nz::Vector2f GetNormal() const; - Nz::Vector2f GetSurfaceVelocity() const; + Vector2f GetNormal() const; + Vector2f GetSurfaceVelocity() const; bool IsFirstContact() const; bool IsRemoval() const; void SetElasticity(float elasticity); void SetFriction(float friction); - void SetSurfaceVelocity(const Nz::Vector2f& surfaceVelocity); + void SetSurfaceVelocity(const Vector2f& surfaceVelocity); Arbiter2D& operator=(const Arbiter2D&) = delete; Arbiter2D& operator=(Arbiter2D&&) = default; diff --git a/src/Nazara/Physics2D/Arbiter2D.cpp b/src/Nazara/Physics2D/Arbiter2D.cpp index 8a1243d26..56668bbe5 100644 --- a/src/Nazara/Physics2D/Arbiter2D.cpp +++ b/src/Nazara/Physics2D/Arbiter2D.cpp @@ -19,6 +19,19 @@ namespace Nz return Nz::Vector2f(Nz::Vector2(impulse.x, impulse.y)); } + std::pair Arbiter2D::GetBodies() const + { + std::pair bodies; + cpBody* firstBody; + cpBody* secondBody; + cpArbiterGetBodies(m_arbiter, &firstBody, &secondBody); + + bodies.first = static_cast(cpBodyGetUserData(firstBody)); + bodies.second = static_cast(cpBodyGetUserData(secondBody)); + + return bodies; + } + std::size_t Arbiter2D::GetContactCount() const { return cpArbiterGetCount(m_arbiter);