From 06ac8cf904868bc4ffcd2d77938354850ae6f03c Mon Sep 17 00:00:00 2001 From: Faymoon Date: Tue, 21 Nov 2017 12:17:11 +0100 Subject: [PATCH] Add AddImpulse for PhysicsComponent2D (#141) * Update PhysicsComponent2D.hpp * Update LuaBinding_SDK.hpp * Update LuaBinding_SDK.cpp * Update LuaBinding_SDK.cpp * Add : AddImpulse * Add : AddImpulse * Add : binding of PhysicsComponent2D * add : handle * fix alphabetical order * complete PhysicsComponent2D binding * Update LuaBinding_SDK.cpp * Update LuaBinding_SDK.hpp * Update PhysicsComponent2D.hpp * Update PhysicsComponent2D.inl * forgot : use namespace Nz and open namespace Ndk * Update PhysicsComponent2D.hpp * Add Addimpulse * Update PhysicsComponent3D.hpp --- .../NDK/Components/PhysicsComponent2D.hpp | 4 ++- .../NDK/Components/PhysicsComponent2D.inl | 33 ++++++++++++++++++- SDK/src/NDK/Lua/LuaBinding_SDK.cpp | 2 +- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/SDK/include/NDK/Components/PhysicsComponent2D.hpp b/SDK/include/NDK/Components/PhysicsComponent2D.hpp index e43b87814..1d57e08b8 100644 --- a/SDK/include/NDK/Components/PhysicsComponent2D.hpp +++ b/SDK/include/NDK/Components/PhysicsComponent2D.hpp @@ -22,9 +22,11 @@ namespace Ndk PhysicsComponent2D() = default; PhysicsComponent2D(const PhysicsComponent2D& physics); ~PhysicsComponent2D() = default; - + void AddForce(const Nz::Vector2f& force, Nz::CoordSys coordSys = Nz::CoordSys_Global); void AddForce(const Nz::Vector2f& force, const Nz::Vector2f& point, Nz::CoordSys coordSys = Nz::CoordSys_Global); + void AddImpulse(const Nz::Vector2f& impulse, Nz::CoordSys coordSys = Nz::CoordSys_Global); + void AddImpulse(const Nz::Vector2f& impulse, const Nz::Vector2f& point, Nz::CoordSys coordSys = Nz::CoordSys_Global); void AddTorque(float torque); Nz::Rectf GetAABB() const; diff --git a/SDK/include/NDK/Components/PhysicsComponent2D.inl b/SDK/include/NDK/Components/PhysicsComponent2D.inl index 5d1b23110..39752b645 100644 --- a/SDK/include/NDK/Components/PhysicsComponent2D.inl +++ b/SDK/include/NDK/Components/PhysicsComponent2D.inl @@ -50,7 +50,38 @@ namespace Ndk m_object->AddForce(force, point, coordSys); } - + + /*! + * \brief Applies a impulse to the entity + * + * \param impulse Impulse to apply on the entity + * + * \remark Produces a NazaraAssert if the physics object is invalid + */ + + inline void PhysicsComponent2D::AddImpulse(const Nz::Vector2f& impulse, Nz::CoordSys coordSys) + { + NazaraAssert(m_object, "Invalid physics object"); + + m_object->AddImpulse(impulse, coordSys); + } + + /*! + * \brief Applies a impulse to the entity + * + * \param impulse Impulse to apply on the entity + * \param point Point where the impulse is applied + * + * \remark Produces a NazaraAssert if the physics object is invalid + */ + + inline void PhysicsComponent2D::AddImpulse(const Nz::Vector2f& impulse, const Nz::Vector2f& point, Nz::CoordSys coordSys) + { + NazaraAssert(m_object, "Invalid physics object"); + + m_object->AddImpulse(impulse, point, coordSys); + } + /*! * \brief Applies a torque to the entity * diff --git a/SDK/src/NDK/Lua/LuaBinding_SDK.cpp b/SDK/src/NDK/Lua/LuaBinding_SDK.cpp index 8952ce7d9..88190fc09 100644 --- a/SDK/src/NDK/Lua/LuaBinding_SDK.cpp +++ b/SDK/src/NDK/Lua/LuaBinding_SDK.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq, Arnaud Cadot +// Copyright (C) 2017 Jérôme Leclercq, Arnaud Cadot // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp