Add RigidBody2D::GetBodies

This commit is contained in:
Lynix 2019-01-19 02:25:45 +01:00
parent ecd42704a6
commit 9be8d0eae4
3 changed files with 23 additions and 5 deletions

View File

@ -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) - ⚠ 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 - Added LuaState::RawEqual
- Fixed LuaCoroutine movement assignation operator - Fixed LuaCoroutine movement assignation operator
- Added Arbiter2D::GetBodies
Nazara Development Kit: Nazara Development Kit:
- Added ImageWidget (#139) - Added ImageWidget (#139)

View File

@ -16,6 +16,8 @@ struct cpArbiter;
namespace Nz namespace Nz
{ {
class RigidBody2D;
class NAZARA_PHYSICS2D_API Arbiter2D class NAZARA_PHYSICS2D_API Arbiter2D
{ {
public: public:
@ -27,22 +29,24 @@ namespace Nz
float ComputeTotalKinematicEnergy() const; float ComputeTotalKinematicEnergy() const;
Nz::Vector2f ComputeTotalImpulse() const; Nz::Vector2f ComputeTotalImpulse() const;
std::pair<RigidBody2D*, RigidBody2D*> GetBodies() const;
std::size_t GetContactCount() const; std::size_t GetContactCount() const;
float GetContactDepth(std::size_t i) const; float GetContactDepth(std::size_t i) const;
Nz::Vector2f GetContactPointA(std::size_t i) const; Vector2f GetContactPointA(std::size_t i) const;
Nz::Vector2f GetContactPointB(std::size_t i) const; Vector2f GetContactPointB(std::size_t i) const;
float GetElasticity() const; float GetElasticity() const;
float GetFriction() const; float GetFriction() const;
Nz::Vector2f GetNormal() const; Vector2f GetNormal() const;
Nz::Vector2f GetSurfaceVelocity() const; Vector2f GetSurfaceVelocity() const;
bool IsFirstContact() const; bool IsFirstContact() const;
bool IsRemoval() const; bool IsRemoval() const;
void SetElasticity(float elasticity); void SetElasticity(float elasticity);
void SetFriction(float friction); void SetFriction(float friction);
void SetSurfaceVelocity(const Nz::Vector2f& surfaceVelocity); void SetSurfaceVelocity(const Vector2f& surfaceVelocity);
Arbiter2D& operator=(const Arbiter2D&) = delete; Arbiter2D& operator=(const Arbiter2D&) = delete;
Arbiter2D& operator=(Arbiter2D&&) = default; Arbiter2D& operator=(Arbiter2D&&) = default;

View File

@ -19,6 +19,19 @@ namespace Nz
return Nz::Vector2f(Nz::Vector2<cpFloat>(impulse.x, impulse.y)); return Nz::Vector2f(Nz::Vector2<cpFloat>(impulse.x, impulse.y));
} }
std::pair<RigidBody2D*, RigidBody2D*> Arbiter2D::GetBodies() const
{
std::pair<RigidBody2D*, RigidBody2D*> bodies;
cpBody* firstBody;
cpBody* secondBody;
cpArbiterGetBodies(m_arbiter, &firstBody, &secondBody);
bodies.first = static_cast<RigidBody2D*>(cpBodyGetUserData(firstBody));
bodies.second = static_cast<RigidBody2D*>(cpBodyGetUserData(secondBody));
return bodies;
}
std::size_t Arbiter2D::GetContactCount() const std::size_t Arbiter2D::GetContactCount() const
{ {
return cpArbiterGetCount(m_arbiter); return cpArbiterGetCount(m_arbiter);