Physics2D/RigidBody2D: Add ForEachArbiter method
This commit is contained in:
parent
9be8d0eae4
commit
40cd8a7987
|
|
@ -158,6 +158,7 @@ Nazara Engine:
|
||||||
- Added LuaState::RawEqual
|
- Added LuaState::RawEqual
|
||||||
- Fixed LuaCoroutine movement assignation operator
|
- Fixed LuaCoroutine movement assignation operator
|
||||||
- Added Arbiter2D::GetBodies
|
- Added Arbiter2D::GetBodies
|
||||||
|
- Added RigidBody2D::ForEachArbiter
|
||||||
|
|
||||||
Nazara Development Kit:
|
Nazara Development Kit:
|
||||||
- Added ImageWidget (#139)
|
- Added ImageWidget (#139)
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,8 @@ namespace Ndk
|
||||||
|
|
||||||
inline void EnableNodeSynchronization(bool nodeSynchronization);
|
inline void EnableNodeSynchronization(bool nodeSynchronization);
|
||||||
|
|
||||||
|
inline void ForEachArbiter(const std::function<void(Nz::Arbiter2D&)>& callback);
|
||||||
|
|
||||||
inline Nz::Rectf GetAABB() const;
|
inline Nz::Rectf GetAABB() const;
|
||||||
inline float GetAngularDamping() const;
|
inline float GetAngularDamping() const;
|
||||||
inline Nz::RadianAnglef GetAngularVelocity() const;
|
inline Nz::RadianAnglef GetAngularVelocity() const;
|
||||||
|
|
|
||||||
|
|
@ -138,6 +138,15 @@ namespace Ndk
|
||||||
m_entity->Invalidate();
|
m_entity->Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
TODO
|
||||||
|
*/
|
||||||
|
inline void PhysicsComponent2D::ForEachArbiter(const std::function<void(Nz::Arbiter2D&)>& callback)
|
||||||
|
{
|
||||||
|
NazaraAssert(m_object, "Invalid physics object");
|
||||||
|
|
||||||
|
return m_object->ForEachArbiter(callback);
|
||||||
|
}
|
||||||
/*!
|
/*!
|
||||||
* \brief Gets the AABB of the physics object
|
* \brief Gets the AABB of the physics object
|
||||||
* \return AABB of the object
|
* \return AABB of the object
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,8 @@ namespace Nz
|
||||||
|
|
||||||
void EnableSimulation(bool simulation);
|
void EnableSimulation(bool simulation);
|
||||||
|
|
||||||
|
void ForEachArbiter(std::function<void(Nz::Arbiter2D& /*arbiter*/)> callback);
|
||||||
|
|
||||||
Rectf GetAABB() const;
|
Rectf GetAABB() const;
|
||||||
inline float GetAngularDamping() const;
|
inline float GetAngularDamping() const;
|
||||||
RadianAnglef GetAngularVelocity() const;
|
RadianAnglef GetAngularVelocity() const;
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
#include <Nazara/Physics2D/RigidBody2D.hpp>
|
#include <Nazara/Physics2D/RigidBody2D.hpp>
|
||||||
|
#include <Nazara/Physics2D/Arbiter2D.hpp>
|
||||||
#include <Nazara/Physics2D/PhysWorld2D.hpp>
|
#include <Nazara/Physics2D/PhysWorld2D.hpp>
|
||||||
#include <chipmunk/chipmunk.h>
|
#include <chipmunk/chipmunk.h>
|
||||||
#include <chipmunk/chipmunk_private.h>
|
#include <chipmunk/chipmunk_private.h>
|
||||||
|
|
@ -175,6 +176,21 @@ namespace Nz
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RigidBody2D::ForEachArbiter(std::function<void(Nz::Arbiter2D&)> callback)
|
||||||
|
{
|
||||||
|
using CallbackType = decltype(callback);
|
||||||
|
|
||||||
|
auto RealCallback = [](cpBody* body, cpArbiter* arbiter, void* data)
|
||||||
|
{
|
||||||
|
CallbackType& cb = *static_cast<CallbackType*>(data);
|
||||||
|
|
||||||
|
Arbiter2D nzArbiter(arbiter);
|
||||||
|
cb(nzArbiter);
|
||||||
|
};
|
||||||
|
|
||||||
|
cpBodyEachArbiter(m_handle, RealCallback, &callback);
|
||||||
|
}
|
||||||
|
|
||||||
Rectf RigidBody2D::GetAABB() const
|
Rectf RigidBody2D::GetAABB() const
|
||||||
{
|
{
|
||||||
if (m_shapes.empty())
|
if (m_shapes.empty())
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue