Physics2D: Expose elasticity/friction/surface velocity

This commit is contained in:
Lynix
2018-10-09 23:22:28 +02:00
parent dc6fbfc90f
commit 30348525d7
8 changed files with 294 additions and 14 deletions

View File

@@ -174,6 +174,36 @@ namespace Ndk
return m_object->GetMassCenter(coordSys);
}
/*!
* \brief Gets the elasticity of a shape belonging to this physics object
* \return Elasticity of the shape
*
* \param shapeIndex Shape index of the collider we're interested
*
* \remark Produces a NazaraAssert if the physics object is invalid
*/
inline float PhysicsComponent2D::GetElasticity(std::size_t shapeIndex) const
{
NazaraAssert(m_object, "Invalid physics object");
return m_object->GetElasticity(shapeIndex);
}
/*!
* \brief Gets the friction of a shape belonging to this physics object
* \return Friction of the shape
*
* \param shapeIndex Shape index of the collider we're interested
*
* \remark Produces a NazaraAssert if the physics object is invalid
*/
inline float PhysicsComponent2D::GetFriction(std::size_t shapeIndex) const
{
NazaraAssert(m_object, "Invalid physics object");
return m_object->GetFriction(shapeIndex);
}
/*!
* \brief Gets the mass of the physics object
* \return Mass of the object
@@ -246,6 +276,30 @@ namespace Ndk
return m_object->GetRotation();
}
/*!
* \brief Gets the surface velocity of a shape belonging to this physics object
* \return Surface velocity of the shape
*
* \param shapeIndex Shape index of the collider we're interested
*
* \remark Produces a NazaraAssert if the physics object is invalid
*/
inline Nz::Vector2f PhysicsComponent2D::GetSurfaceVelocity(std::size_t shapeIndex) const
{
return m_object->GetSurfaceVelocity(shapeIndex);
}
/*!
* \brief Gets the rotation of the physics object
* \return Shape count of the object
*
* \remark Produces a NazaraAssert if the physics object is invalid
*/
inline std::size_t PhysicsComponent2D::GetShapeCount() const
{
return m_object->GetShapeCount();
}
/*!
* \brief Gets the velocity of the physics object
* \return Velocity of the object
@@ -305,6 +359,72 @@ namespace Ndk
m_object->SetAngularVelocity(angularVelocity);
}
/*!
* \brief Sets the elasticity of the whole physics object
*
* Overrides all shapes elasticity with a single value
*
* \param elasticity Elasticity to be applied
*
* \remark Elasticity must be positive or zero
*/
inline void PhysicsComponent2D::SetElasticity(float elasticity)
{
NazaraAssert(m_object, "Invalid physics object");
NazaraAssert(elasticity >= 0.f, "Friction must be positive");
m_object->SetElasticity(elasticity);
}
/*!
* \brief Sets the elasticity of a single shape of the physics object
*
* \param shapeIndex Target shape index
* \param elasticity Elasticity to be applied
*
* \remark Elasticity must be positive or zero
*/
inline void PhysicsComponent2D::SetElasticity(std::size_t shapeIndex, float elasticity)
{
NazaraAssert(m_object, "Invalid physics object");
NazaraAssert(elasticity >= 0.f, "Friction must be positive");
m_object->SetElasticity(shapeIndex, elasticity);
}
/*!
* \brief Sets the friction of the whole physics object
*
* Overrides all shapes friction with a single value
*
* \param friction Friction to be applied
*
* \remark Friction must be positive or zero
*/
inline void PhysicsComponent2D::SetFriction(float friction)
{
NazaraAssert(m_object, "Invalid physics object");
NazaraAssert(friction >= 0.f, "Friction must be positive");
m_object->SetFriction(friction);
}
/*!
* \brief Sets the friction of a single shape of the physics object
*
* \param shapeIndex Target shape index
* \param friction Friction to be applied
*
* \remark Friction must be positive or zero
*/
inline void PhysicsComponent2D::SetFriction(std::size_t shapeIndex, float friction)
{
NazaraAssert(m_object, "Invalid physics object");
NazaraAssert(friction >= 0.f, "Friction must be positive");
m_object->SetFriction(shapeIndex, friction);
}
/*!
* \brief Sets the mass of the physics object
*
@@ -378,14 +498,38 @@ namespace Ndk
m_object->SetRotation(rotation);
}
/*!
* \brief Sets the surface velocity of the whole physics object
*
* Overrides all shapes surface velocity with a single value
*
* \param velocity Surface velocity to be applied
*/
inline void PhysicsComponent2D::SetSurfaceVelocity(const Nz::Vector2f& velocity)
{
NazaraAssert(m_object, "Invalid physics object");
m_object->SetSurfaceVelocity(velocity);
}
/*!
* \brief Sets the surface velocity of a single shape of the physics object
*
* \param shapeIndex Target shape index
* \param velocity Surface velocity to be applied
*/
inline void PhysicsComponent2D::SetSurfaceVelocity(std::size_t shapeIndex, const Nz::Vector2f& velocity)
{
NazaraAssert(m_object, "Invalid physics object");
m_object->SetSurfaceVelocity(shapeIndex, velocity);
}
/*!
* \brief Sets the velocity of the physics object
*
* \param velocity Velocity of the object
*
* \remark Produces a NazaraAssert if the physics object is invalid
*/
inline void PhysicsComponent2D::SetVelocity(const Nz::Vector2f& velocity)
{
NazaraAssert(m_object, "Invalid physics object");