Replace floating point angle by Angle class instance
This commit is contained in:
parent
f02f206aff
commit
dc6fbfc90f
|
|
@ -38,25 +38,25 @@ namespace Ndk
|
||||||
|
|
||||||
inline Nz::Rectf GetAABB() const;
|
inline Nz::Rectf GetAABB() const;
|
||||||
inline float GetAngularDamping() const;
|
inline float GetAngularDamping() const;
|
||||||
inline float GetAngularVelocity() const;
|
inline Nz::RadianAnglef GetAngularVelocity() const;
|
||||||
NAZARA_DEPRECATED("Name error, please use GetMassCenter")
|
NAZARA_DEPRECATED("Name error, please use GetMassCenter")
|
||||||
inline Nz::Vector2f GetCenterOfGravity(Nz::CoordSys coordSys = Nz::CoordSys_Local) const;
|
inline Nz::Vector2f GetCenterOfGravity(Nz::CoordSys coordSys = Nz::CoordSys_Local) const;
|
||||||
inline float GetMass() const;
|
inline float GetMass() const;
|
||||||
inline Nz::Vector2f GetMassCenter(Nz::CoordSys coordSys = Nz::CoordSys_Local) const;
|
inline Nz::Vector2f GetMassCenter(Nz::CoordSys coordSys = Nz::CoordSys_Local) const;
|
||||||
inline float GetMomentOfInertia() const;
|
inline float GetMomentOfInertia() const;
|
||||||
inline Nz::Vector2f GetPosition() const;
|
inline Nz::Vector2f GetPosition() const;
|
||||||
inline float GetRotation() const;
|
inline Nz::RadianAnglef GetRotation() const;
|
||||||
inline Nz::Vector2f GetVelocity() const;
|
inline Nz::Vector2f GetVelocity() const;
|
||||||
|
|
||||||
inline bool IsSleeping() const;
|
inline bool IsSleeping() const;
|
||||||
|
|
||||||
inline void SetAngularDamping(float angularDamping);
|
inline void SetAngularDamping(float angularDamping);
|
||||||
inline void SetAngularVelocity(float angularVelocity);
|
inline void SetAngularVelocity(const Nz::RadianAnglef& angularVelocity);
|
||||||
inline void SetMass(float mass);
|
inline void SetMass(float mass);
|
||||||
inline void SetMassCenter(const Nz::Vector2f& center, Nz::CoordSys coordSys = Nz::CoordSys_Local);
|
inline void SetMassCenter(const Nz::Vector2f& center, Nz::CoordSys coordSys = Nz::CoordSys_Local);
|
||||||
inline void SetMomentOfInertia(float moment);
|
inline void SetMomentOfInertia(float moment);
|
||||||
inline void SetPosition(const Nz::Vector2f& position);
|
inline void SetPosition(const Nz::Vector2f& position);
|
||||||
inline void SetRotation(float rotation);
|
inline void SetRotation(const Nz::RadianAnglef& rotation);
|
||||||
inline void SetVelocity(const Nz::Vector2f& velocity);
|
inline void SetVelocity(const Nz::Vector2f& velocity);
|
||||||
|
|
||||||
static ComponentIndex componentIndex;
|
static ComponentIndex componentIndex;
|
||||||
|
|
|
||||||
|
|
@ -151,7 +151,7 @@ namespace Ndk
|
||||||
* \remark Produces a NazaraAssert if the physics object is invalid
|
* \remark Produces a NazaraAssert if the physics object is invalid
|
||||||
*/
|
*/
|
||||||
|
|
||||||
inline float PhysicsComponent2D::GetAngularVelocity() const
|
inline Nz::RadianAnglef PhysicsComponent2D::GetAngularVelocity() const
|
||||||
{
|
{
|
||||||
NazaraAssert(m_object, "Invalid physics object");
|
NazaraAssert(m_object, "Invalid physics object");
|
||||||
|
|
||||||
|
|
@ -180,7 +180,6 @@ namespace Ndk
|
||||||
*
|
*
|
||||||
* \remark Produces a NazaraAssert if the physics object is invalid
|
* \remark Produces a NazaraAssert if the physics object is invalid
|
||||||
*/
|
*/
|
||||||
|
|
||||||
inline float PhysicsComponent2D::GetMass() const
|
inline float PhysicsComponent2D::GetMass() const
|
||||||
{
|
{
|
||||||
NazaraAssert(m_object, "Invalid physics object");
|
NazaraAssert(m_object, "Invalid physics object");
|
||||||
|
|
@ -240,8 +239,7 @@ namespace Ndk
|
||||||
*
|
*
|
||||||
* \remark Produces a NazaraAssert if the physics object is invalid
|
* \remark Produces a NazaraAssert if the physics object is invalid
|
||||||
*/
|
*/
|
||||||
|
inline Nz::RadianAnglef PhysicsComponent2D::GetRotation() const
|
||||||
inline float PhysicsComponent2D::GetRotation() const
|
|
||||||
{
|
{
|
||||||
NazaraAssert(m_object, "Invalid physics object");
|
NazaraAssert(m_object, "Invalid physics object");
|
||||||
|
|
||||||
|
|
@ -300,8 +298,7 @@ namespace Ndk
|
||||||
*
|
*
|
||||||
* \remark Produces a NazaraAssert if the physics object is invalid
|
* \remark Produces a NazaraAssert if the physics object is invalid
|
||||||
*/
|
*/
|
||||||
|
inline void PhysicsComponent2D::SetAngularVelocity(const Nz::RadianAnglef& angularVelocity)
|
||||||
inline void PhysicsComponent2D::SetAngularVelocity(float angularVelocity)
|
|
||||||
{
|
{
|
||||||
NazaraAssert(m_object, "Invalid physics object");
|
NazaraAssert(m_object, "Invalid physics object");
|
||||||
|
|
||||||
|
|
@ -313,10 +310,8 @@ namespace Ndk
|
||||||
*
|
*
|
||||||
* \param mass Mass of the object
|
* \param mass Mass of the object
|
||||||
*
|
*
|
||||||
* \remark Produces a NazaraAssert if the physics object is invalid
|
* \remark Mass must be positive or zero
|
||||||
* \remark Produces a NazaraAssert if the mass is negative
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
inline void PhysicsComponent2D::SetMass(float mass)
|
inline void PhysicsComponent2D::SetMass(float mass)
|
||||||
{
|
{
|
||||||
NazaraAssert(m_object, "Invalid physics object");
|
NazaraAssert(m_object, "Invalid physics object");
|
||||||
|
|
@ -332,13 +327,13 @@ namespace Ndk
|
||||||
*
|
*
|
||||||
* \remark Produces a NazaraAssert if the physics object is invalid
|
* \remark Produces a NazaraAssert if the physics object is invalid
|
||||||
*/
|
*/
|
||||||
|
|
||||||
inline void PhysicsComponent2D::SetMassCenter(const Nz::Vector2f& center, Nz::CoordSys coordSys)
|
inline void PhysicsComponent2D::SetMassCenter(const Nz::Vector2f& center, Nz::CoordSys coordSys)
|
||||||
{
|
{
|
||||||
NazaraAssert(m_object, "Invalid physics object");
|
NazaraAssert(m_object, "Invalid physics object");
|
||||||
|
|
||||||
m_object->SetMassCenter(center, coordSys);
|
m_object->SetMassCenter(center, coordSys);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Sets the angular damping or moment of inertia of the physics object
|
* \brief Sets the angular damping or moment of inertia of the physics object
|
||||||
*
|
*
|
||||||
|
|
@ -348,7 +343,6 @@ namespace Ndk
|
||||||
*
|
*
|
||||||
* \see SetAngularDamping
|
* \see SetAngularDamping
|
||||||
*/
|
*/
|
||||||
|
|
||||||
inline void PhysicsComponent2D::SetMomentOfInertia(float moment)
|
inline void PhysicsComponent2D::SetMomentOfInertia(float moment)
|
||||||
{
|
{
|
||||||
NazaraAssert(m_object, "Invalid physics object");
|
NazaraAssert(m_object, "Invalid physics object");
|
||||||
|
|
@ -363,7 +357,6 @@ namespace Ndk
|
||||||
*
|
*
|
||||||
* \remark Produces a NazaraAssert if the physics object is invalid
|
* \remark Produces a NazaraAssert if the physics object is invalid
|
||||||
*/
|
*/
|
||||||
|
|
||||||
inline void PhysicsComponent2D::SetPosition(const Nz::Vector2f& position)
|
inline void PhysicsComponent2D::SetPosition(const Nz::Vector2f& position)
|
||||||
{
|
{
|
||||||
NazaraAssert(m_object, "Invalid physics object");
|
NazaraAssert(m_object, "Invalid physics object");
|
||||||
|
|
@ -378,8 +371,7 @@ namespace Ndk
|
||||||
*
|
*
|
||||||
* \remark Produces a NazaraAssert if the physics object is invalid
|
* \remark Produces a NazaraAssert if the physics object is invalid
|
||||||
*/
|
*/
|
||||||
|
inline void PhysicsComponent2D::SetRotation(const Nz::RadianAnglef& rotation)
|
||||||
inline void PhysicsComponent2D::SetRotation(float rotation)
|
|
||||||
{
|
{
|
||||||
NazaraAssert(m_object, "Invalid physics object");
|
NazaraAssert(m_object, "Invalid physics object");
|
||||||
|
|
||||||
|
|
@ -405,7 +397,6 @@ namespace Ndk
|
||||||
* \brief Gets the underlying physics object
|
* \brief Gets the underlying physics object
|
||||||
* \return A reference to the physics object
|
* \return A reference to the physics object
|
||||||
*/
|
*/
|
||||||
|
|
||||||
inline Nz::RigidBody2D* PhysicsComponent2D::GetRigidBody()
|
inline Nz::RigidBody2D* PhysicsComponent2D::GetRigidBody()
|
||||||
{
|
{
|
||||||
return m_object.get();
|
return m_object.get();
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ namespace Ndk
|
||||||
using ContactPostSolveCallback = std::function<void(PhysicsSystem2D& world, Nz::Arbiter2D& arbiter, const EntityHandle& bodyA, const EntityHandle& bodyB, void* userdata)>;
|
using ContactPostSolveCallback = std::function<void(PhysicsSystem2D& world, Nz::Arbiter2D& arbiter, const EntityHandle& bodyA, const EntityHandle& bodyB, void* userdata)>;
|
||||||
using ContactStartCallback = std::function<bool(PhysicsSystem2D& world, Nz::Arbiter2D& arbiter, const EntityHandle& bodyA, const EntityHandle& bodyB, void* userdata)>;
|
using ContactStartCallback = std::function<bool(PhysicsSystem2D& world, Nz::Arbiter2D& arbiter, const EntityHandle& bodyA, const EntityHandle& bodyB, void* userdata)>;
|
||||||
|
|
||||||
using DebugDrawCircleCallback = std::function<void(const Nz::Vector2f& origin, float rotation, float radius, Nz::Color outlineColor, Nz::Color fillColor, void* userdata)>;
|
using DebugDrawCircleCallback = std::function<void(const Nz::Vector2f& origin, const Nz::RadianAnglef& rotation, float radius, Nz::Color outlineColor, Nz::Color fillColor, void* userdata)>;
|
||||||
using DebugDrawDotCallback = std::function<void(const Nz::Vector2f& origin, float radius, Nz::Color color, void* userdata)>;
|
using DebugDrawDotCallback = std::function<void(const Nz::Vector2f& origin, float radius, Nz::Color color, void* userdata)>;
|
||||||
using DebugDrawPolygonCallback = std::function<void(const Nz::Vector2f* vertices, std::size_t vertexCount, float radius, Nz::Color outlineColor, Nz::Color fillColor, void* userdata)>;
|
using DebugDrawPolygonCallback = std::function<void(const Nz::Vector2f* vertices, std::size_t vertexCount, float radius, Nz::Color outlineColor, Nz::Color fillColor, void* userdata)>;
|
||||||
using DebugDrawSegmentCallback = std::function<void(const Nz::Vector2f& first, const Nz::Vector2f& second, Nz::Color color, void* userdata)>;
|
using DebugDrawSegmentCallback = std::function<void(const Nz::Vector2f& first, const Nz::Vector2f& second, Nz::Color color, void* userdata)>;
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,6 @@ namespace Ndk
|
||||||
*
|
*
|
||||||
* \remark Produces a NazaraAssert if the entity has no physics component and has no static body
|
* \remark Produces a NazaraAssert if the entity has no physics component and has no static body
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void CollisionComponent2D::SetGeom(Nz::Collider2DRef geom)
|
void CollisionComponent2D::SetGeom(Nz::Collider2DRef geom)
|
||||||
{
|
{
|
||||||
m_geom = std::move(geom);
|
m_geom = std::move(geom);
|
||||||
|
|
|
||||||
|
|
@ -181,7 +181,7 @@ namespace Ndk
|
||||||
PhysicsComponent2D& phys = entity->GetComponent<PhysicsComponent2D>();
|
PhysicsComponent2D& phys = entity->GetComponent<PhysicsComponent2D>();
|
||||||
|
|
||||||
Nz::RigidBody2D* body = phys.GetRigidBody();
|
Nz::RigidBody2D* body = phys.GetRigidBody();
|
||||||
node.SetRotation(Nz::EulerAnglesf(0.f, 0.f, body->GetRotation()), Nz::CoordSys_Global);
|
node.SetRotation(body->GetRotation(), Nz::CoordSys_Global);
|
||||||
node.SetPosition(Nz::Vector3f(body->GetPosition(), node.GetPosition(Nz::CoordSys_Global).z), Nz::CoordSys_Global);
|
node.SetPosition(Nz::Vector3f(body->GetPosition(), node.GetPosition(Nz::CoordSys_Global).z), Nz::CoordSys_Global);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
#include <Nazara/Prerequisites.hpp>
|
#include <Nazara/Prerequisites.hpp>
|
||||||
#include <Nazara/Graphics/InstancedRenderable.hpp>
|
#include <Nazara/Graphics/InstancedRenderable.hpp>
|
||||||
#include <Nazara/Graphics/Material.hpp>
|
#include <Nazara/Graphics/Material.hpp>
|
||||||
|
#include <Nazara/Math/Angle.hpp>
|
||||||
|
|
||||||
namespace Nz
|
namespace Nz
|
||||||
{
|
{
|
||||||
|
|
@ -34,14 +35,14 @@ namespace Nz
|
||||||
std::unique_ptr<InstancedRenderable> Clone() const override;
|
std::unique_ptr<InstancedRenderable> Clone() const override;
|
||||||
|
|
||||||
inline const Color& GetColor() const;
|
inline const Color& GetColor() const;
|
||||||
inline float GetRotation() const;
|
inline const RadianAnglef& GetRotation() const;
|
||||||
inline const Vector2f& GetSize() const;
|
inline const Vector2f& GetSize() const;
|
||||||
|
|
||||||
inline void SetColor(const Color& color);
|
inline void SetColor(const Color& color);
|
||||||
inline void SetDefaultMaterial();
|
inline void SetDefaultMaterial();
|
||||||
inline void SetMaterial(MaterialRef material, bool resizeBillboard = true);
|
inline void SetMaterial(MaterialRef material, bool resizeBillboard = true);
|
||||||
inline void SetMaterial(std::size_t skinIndex, MaterialRef material, bool resizeBillboard = true);
|
inline void SetMaterial(std::size_t skinIndex, MaterialRef material, bool resizeBillboard = true);
|
||||||
inline void SetRotation(float rotation);
|
inline void SetRotation(const RadianAnglef& rotation);
|
||||||
inline void SetSize(const Vector2f& size);
|
inline void SetSize(const Vector2f& size);
|
||||||
inline void SetSize(float sizeX, float sizeY);
|
inline void SetSize(float sizeX, float sizeY);
|
||||||
inline void SetTexture(TextureRef texture, bool resizeBillboard = true);
|
inline void SetTexture(TextureRef texture, bool resizeBillboard = true);
|
||||||
|
|
@ -58,7 +59,7 @@ namespace Nz
|
||||||
Color m_color;
|
Color m_color;
|
||||||
Vector2f m_sinCos;
|
Vector2f m_sinCos;
|
||||||
Vector2f m_size;
|
Vector2f m_size;
|
||||||
float m_rotation;
|
RadianAnglef m_rotation;
|
||||||
|
|
||||||
static BillboardLibrary::LibraryMap s_library;
|
static BillboardLibrary::LibraryMap s_library;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ namespace Nz
|
||||||
* \return Current rotation
|
* \return Current rotation
|
||||||
*/
|
*/
|
||||||
|
|
||||||
inline float Billboard::GetRotation() const
|
inline const RadianAnglef& Billboard::GetRotation() const
|
||||||
{
|
{
|
||||||
return m_rotation;
|
return m_rotation;
|
||||||
}
|
}
|
||||||
|
|
@ -161,10 +161,12 @@ namespace Nz
|
||||||
* \param rotation Rotation for the billboard
|
* \param rotation Rotation for the billboard
|
||||||
*/
|
*/
|
||||||
|
|
||||||
inline void Billboard::SetRotation(float rotation)
|
inline void Billboard::SetRotation(const RadianAnglef& rotation)
|
||||||
{
|
{
|
||||||
m_rotation = rotation;
|
m_rotation = rotation;
|
||||||
m_sinCos.Set(std::sin(m_rotation), std::cos(m_rotation));
|
|
||||||
|
auto sincos = rotation.GetSinCos();
|
||||||
|
m_sinCos.Set(sincos.first, sincos.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include <Nazara/Prerequisites.hpp>
|
#include <Nazara/Prerequisites.hpp>
|
||||||
#include <Nazara/Core/MovablePtr.hpp>
|
#include <Nazara/Core/MovablePtr.hpp>
|
||||||
|
#include <Nazara/Math/Angle.hpp>
|
||||||
#include <Nazara/Physics2D/Config.hpp>
|
#include <Nazara/Physics2D/Config.hpp>
|
||||||
#include <Nazara/Physics2D/PhysWorld2D.hpp>
|
#include <Nazara/Physics2D/PhysWorld2D.hpp>
|
||||||
#include <Nazara/Physics2D/RigidBody2D.hpp>
|
#include <Nazara/Physics2D/RigidBody2D.hpp>
|
||||||
|
|
@ -95,15 +96,15 @@ namespace Nz
|
||||||
class NAZARA_PHYSICS2D_API DampedRotarySpringConstraint2D : public Constraint2D
|
class NAZARA_PHYSICS2D_API DampedRotarySpringConstraint2D : public Constraint2D
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DampedRotarySpringConstraint2D(RigidBody2D& first, RigidBody2D& second, float restAngle, float stiffness, float damping);
|
DampedRotarySpringConstraint2D(RigidBody2D& first, RigidBody2D& second, const RadianAnglef& restAngle, float stiffness, float damping);
|
||||||
~DampedRotarySpringConstraint2D() = default;
|
~DampedRotarySpringConstraint2D() = default;
|
||||||
|
|
||||||
float GetDamping() const;
|
float GetDamping() const;
|
||||||
float GetRestAngle() const;
|
RadianAnglef GetRestAngle() const;
|
||||||
float GetStiffness() const;
|
float GetStiffness() const;
|
||||||
|
|
||||||
void SetDamping(float newDamping);
|
void SetDamping(float newDamping);
|
||||||
void SetRestAngle(float newAngle);
|
void SetRestAngle(const RadianAnglef& newAngle);
|
||||||
void SetStiffness(float newStiffness);
|
void SetStiffness(float newStiffness);
|
||||||
|
|
||||||
template<typename... Args> static DampedRotarySpringConstraint2DRef New(Args&&... args);
|
template<typename... Args> static DampedRotarySpringConstraint2DRef New(Args&&... args);
|
||||||
|
|
@ -200,11 +201,11 @@ namespace Nz
|
||||||
RatchetConstraint2D(RigidBody2D& first, RigidBody2D& second, float phase, float ratchet);
|
RatchetConstraint2D(RigidBody2D& first, RigidBody2D& second, float phase, float ratchet);
|
||||||
~RatchetConstraint2D() = default;
|
~RatchetConstraint2D() = default;
|
||||||
|
|
||||||
float GetAngle() const;
|
RadianAnglef GetAngle() const;
|
||||||
float GetPhase() const;
|
float GetPhase() const;
|
||||||
float GetRatchet() const;
|
float GetRatchet() const;
|
||||||
|
|
||||||
void SetAngle(float angle);
|
void SetAngle(const RadianAnglef& angle);
|
||||||
void SetPhase(float phase);
|
void SetPhase(float phase);
|
||||||
void SetRatchet(float ratchet);
|
void SetRatchet(float ratchet);
|
||||||
|
|
||||||
|
|
@ -219,14 +220,14 @@ namespace Nz
|
||||||
class NAZARA_PHYSICS2D_API RotaryLimitConstraint2D : public Constraint2D
|
class NAZARA_PHYSICS2D_API RotaryLimitConstraint2D : public Constraint2D
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RotaryLimitConstraint2D(RigidBody2D& first, RigidBody2D& second, float minAngle, float maxAngle);
|
RotaryLimitConstraint2D(RigidBody2D& first, RigidBody2D& second, const RadianAnglef& minAngle, const RadianAnglef& maxAngle);
|
||||||
~RotaryLimitConstraint2D() = default;
|
~RotaryLimitConstraint2D() = default;
|
||||||
|
|
||||||
float GetMaxAngle() const;
|
RadianAnglef GetMaxAngle() const;
|
||||||
float GetMinAngle() const;
|
RadianAnglef GetMinAngle() const;
|
||||||
|
|
||||||
void SetMaxAngle(float maxAngle);
|
void SetMaxAngle(const RadianAnglef& maxAngle);
|
||||||
void SetMinAngle(float minAngle);
|
void SetMinAngle(const RadianAnglef& minAngle);
|
||||||
|
|
||||||
template<typename... Args> static RotaryLimitConstraint2DRef New(Args&&... args);
|
template<typename... Args> static RotaryLimitConstraint2DRef New(Args&&... args);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
#include <Nazara/Prerequisites.hpp>
|
#include <Nazara/Prerequisites.hpp>
|
||||||
#include <Nazara/Core/Color.hpp>
|
#include <Nazara/Core/Color.hpp>
|
||||||
#include <Nazara/Core/Signal.hpp>
|
#include <Nazara/Core/Signal.hpp>
|
||||||
|
#include <Nazara/Math/Angle.hpp>
|
||||||
#include <Nazara/Math/Vector2.hpp>
|
#include <Nazara/Math/Vector2.hpp>
|
||||||
#include <Nazara/Physics2D/Config.hpp>
|
#include <Nazara/Physics2D/Config.hpp>
|
||||||
#include <Nazara/Physics2D/RigidBody2D.hpp>
|
#include <Nazara/Physics2D/RigidBody2D.hpp>
|
||||||
|
|
@ -33,7 +34,7 @@ namespace Nz
|
||||||
using ContactPostSolveCallback = std::function<void(PhysWorld2D& world, Arbiter2D& arbiter, RigidBody2D& bodyA, RigidBody2D& bodyB, void* userdata)>;
|
using ContactPostSolveCallback = std::function<void(PhysWorld2D& world, Arbiter2D& arbiter, RigidBody2D& bodyA, RigidBody2D& bodyB, void* userdata)>;
|
||||||
using ContactStartCallback = std::function<bool(PhysWorld2D& world, Arbiter2D& arbiter, RigidBody2D& bodyA, RigidBody2D& bodyB, void* userdata)>;
|
using ContactStartCallback = std::function<bool(PhysWorld2D& world, Arbiter2D& arbiter, RigidBody2D& bodyA, RigidBody2D& bodyB, void* userdata)>;
|
||||||
|
|
||||||
using DebugDrawCircleCallback = std::function<void(const Vector2f& origin, float rotation, float radius, Color outlineColor, Color fillColor, void* userdata)>;
|
using DebugDrawCircleCallback = std::function<void(const Vector2f& origin, const RadianAnglef& rotation, float radius, Color outlineColor, Color fillColor, void* userdata)>;
|
||||||
using DebugDrawDotCallback = std::function<void(const Vector2f& origin, float radius, Color color, void* userdata)>;
|
using DebugDrawDotCallback = std::function<void(const Vector2f& origin, float radius, Color color, void* userdata)>;
|
||||||
using DebugDrawPolygonCallback = std::function<void(const Vector2f* vertices, std::size_t vertexCount, float radius, Color outlineColor, Color fillColor, void* userdata)>;
|
using DebugDrawPolygonCallback = std::function<void(const Vector2f* vertices, std::size_t vertexCount, float radius, Color outlineColor, Color fillColor, void* userdata)>;
|
||||||
using DebugDrawSegmentCallback = std::function<void(const Vector2f& first, const Vector2f& second, Color color, void* userdata)>;
|
using DebugDrawSegmentCallback = std::function<void(const Vector2f& first, const Vector2f& second, Color color, void* userdata)>;
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,7 @@ namespace Nz
|
||||||
|
|
||||||
inline void SetAngularDamping(float angularDamping);
|
inline void SetAngularDamping(float angularDamping);
|
||||||
void SetAngularVelocity(float angularVelocity);
|
void SetAngularVelocity(float angularVelocity);
|
||||||
|
void SetFriction(std::size_t shapeIndex, float friction);
|
||||||
void SetGeom(Collider2DRef geom, bool recomputeMoment = true);
|
void SetGeom(Collider2DRef geom, bool recomputeMoment = true);
|
||||||
void SetMass(float mass, bool recomputeMoment = true);
|
void SetMass(float mass, bool recomputeMoment = true);
|
||||||
void SetMassCenter(const Vector2f& center, CoordSys coordSys = CoordSys_Local);
|
void SetMassCenter(const Vector2f& center, CoordSys coordSys = CoordSys_Local);
|
||||||
|
|
|
||||||
|
|
@ -163,8 +163,8 @@ namespace Nz
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DampedRotarySpringConstraint2D::DampedRotarySpringConstraint2D(RigidBody2D& first, RigidBody2D& second, float restAngle, float stiffness, float damping) :
|
DampedRotarySpringConstraint2D::DampedRotarySpringConstraint2D(RigidBody2D& first, RigidBody2D& second, const RadianAnglef& restAngle, float stiffness, float damping) :
|
||||||
Constraint2D(first.GetWorld(), cpDampedRotarySpringNew(first.GetHandle(), second.GetHandle(), restAngle, stiffness, damping))
|
Constraint2D(first.GetWorld(), cpDampedRotarySpringNew(first.GetHandle(), second.GetHandle(), restAngle.angle, stiffness, damping))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -173,7 +173,7 @@ namespace Nz
|
||||||
return float(cpDampedRotarySpringGetDamping(m_constraint));
|
return float(cpDampedRotarySpringGetDamping(m_constraint));
|
||||||
}
|
}
|
||||||
|
|
||||||
float DampedRotarySpringConstraint2D::GetRestAngle() const
|
RadianAnglef DampedRotarySpringConstraint2D::GetRestAngle() const
|
||||||
{
|
{
|
||||||
return float(cpDampedRotarySpringGetRestAngle(m_constraint));
|
return float(cpDampedRotarySpringGetRestAngle(m_constraint));
|
||||||
}
|
}
|
||||||
|
|
@ -188,9 +188,9 @@ namespace Nz
|
||||||
cpDampedSpringSetDamping(m_constraint, newDamping);
|
cpDampedSpringSetDamping(m_constraint, newDamping);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DampedRotarySpringConstraint2D::SetRestAngle(float newAngle)
|
void DampedRotarySpringConstraint2D::SetRestAngle(const RadianAnglef& newAngle)
|
||||||
{
|
{
|
||||||
cpDampedRotarySpringSetRestAngle(m_constraint, newAngle);
|
cpDampedRotarySpringSetRestAngle(m_constraint, newAngle.angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DampedRotarySpringConstraint2D::SetStiffness(float newStiffness)
|
void DampedRotarySpringConstraint2D::SetStiffness(float newStiffness)
|
||||||
|
|
@ -317,7 +317,7 @@ namespace Nz
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
float RatchetConstraint2D::GetAngle() const
|
RadianAnglef RatchetConstraint2D::GetAngle() const
|
||||||
{
|
{
|
||||||
return float(cpRatchetJointGetAngle(m_constraint));
|
return float(cpRatchetJointGetAngle(m_constraint));
|
||||||
}
|
}
|
||||||
|
|
@ -332,9 +332,9 @@ namespace Nz
|
||||||
return float(cpRatchetJointGetRatchet(m_constraint));
|
return float(cpRatchetJointGetRatchet(m_constraint));
|
||||||
}
|
}
|
||||||
|
|
||||||
void RatchetConstraint2D::SetAngle(float angle)
|
void RatchetConstraint2D::SetAngle(const RadianAnglef& angle)
|
||||||
{
|
{
|
||||||
cpRatchetJointSetAngle(m_constraint, angle);
|
cpRatchetJointSetAngle(m_constraint, angle.angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RatchetConstraint2D::SetPhase(float phase)
|
void RatchetConstraint2D::SetPhase(float phase)
|
||||||
|
|
@ -348,29 +348,29 @@ namespace Nz
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
RotaryLimitConstraint2D::RotaryLimitConstraint2D(RigidBody2D& first, RigidBody2D& second, float minAngle, float maxAngle) :
|
RotaryLimitConstraint2D::RotaryLimitConstraint2D(RigidBody2D& first, RigidBody2D& second, const RadianAnglef& minAngle, const RadianAnglef& maxAngle) :
|
||||||
Constraint2D(first.GetWorld(), cpRotaryLimitJointNew(first.GetHandle(), second.GetHandle(), minAngle, maxAngle))
|
Constraint2D(first.GetWorld(), cpRotaryLimitJointNew(first.GetHandle(), second.GetHandle(), minAngle.angle, maxAngle.angle))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
float RotaryLimitConstraint2D::GetMaxAngle() const
|
RadianAnglef RotaryLimitConstraint2D::GetMaxAngle() const
|
||||||
{
|
{
|
||||||
return float(cpRotaryLimitJointGetMax(m_constraint));
|
return float(cpRotaryLimitJointGetMax(m_constraint));
|
||||||
}
|
}
|
||||||
|
|
||||||
float RotaryLimitConstraint2D::GetMinAngle() const
|
RadianAnglef RotaryLimitConstraint2D::GetMinAngle() const
|
||||||
{
|
{
|
||||||
return float(cpRotaryLimitJointGetMax(m_constraint));
|
return float(cpRotaryLimitJointGetMax(m_constraint));
|
||||||
}
|
}
|
||||||
|
|
||||||
void RotaryLimitConstraint2D::SetMaxAngle(float maxAngle)
|
void RotaryLimitConstraint2D::SetMaxAngle(const RadianAnglef& maxAngle)
|
||||||
{
|
{
|
||||||
cpRotaryLimitJointSetMax(m_constraint, maxAngle);
|
cpRotaryLimitJointSetMax(m_constraint, maxAngle.angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RotaryLimitConstraint2D::SetMinAngle(float minAngle)
|
void RotaryLimitConstraint2D::SetMinAngle(const RadianAnglef& minAngle)
|
||||||
{
|
{
|
||||||
cpRotaryLimitJointSetMin(m_constraint, minAngle);
|
cpRotaryLimitJointSetMin(m_constraint, minAngle.angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ namespace Nz
|
||||||
{
|
{
|
||||||
auto drawOptions = static_cast<PhysWorld2D::DebugDrawOptions*>(userdata);
|
auto drawOptions = static_cast<PhysWorld2D::DebugDrawOptions*>(userdata);
|
||||||
if (drawOptions->circleCallback)
|
if (drawOptions->circleCallback)
|
||||||
drawOptions->circleCallback(Vector2f(float(pos.x), float(pos.y)), float(angle), float(radius), CpDebugColorToColor(outlineColor), CpDebugColorToColor(fillColor), drawOptions->userdata);
|
drawOptions->circleCallback(Vector2f(float(pos.x), float(pos.y)), RadianAnglef(float(angle)), float(radius), CpDebugColorToColor(outlineColor), CpDebugColorToColor(fillColor), drawOptions->userdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawDot(cpFloat size, cpVect pos, cpSpaceDebugColor color, cpDataPointer userdata)
|
void DrawDot(cpFloat size, cpVect pos, cpSpaceDebugColor color, cpDataPointer userdata)
|
||||||
|
|
|
||||||
|
|
@ -185,9 +185,9 @@ namespace Nz
|
||||||
return Rectf(Rect<cpFloat>(bb.l, bb.b, bb.r - bb.l, bb.t - bb.b));
|
return Rectf(Rect<cpFloat>(bb.l, bb.b, bb.r - bb.l, bb.t - bb.b));
|
||||||
}
|
}
|
||||||
|
|
||||||
float RigidBody2D::GetAngularVelocity() const
|
RadianAnglef RigidBody2D::GetAngularVelocity() const
|
||||||
|
return float(cpBodyGetAngularVelocity(m_handle));
|
||||||
{
|
{
|
||||||
return FromRadians(static_cast<float>(cpBodyGetAngularVelocity(m_handle)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const Collider2DRef& RigidBody2D::GetGeom() const
|
const Collider2DRef& RigidBody2D::GetGeom() const
|
||||||
|
|
@ -233,9 +233,9 @@ namespace Nz
|
||||||
return Vector2f(static_cast<float>(pos.x), static_cast<float>(pos.y));
|
return Vector2f(static_cast<float>(pos.x), static_cast<float>(pos.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
float RigidBody2D::GetRotation() const
|
RadianAnglef RigidBody2D::GetRotation() const
|
||||||
{
|
{
|
||||||
return FromRadians(static_cast<float>(cpBodyGetAngle(m_handle)));
|
return float(cpBodyGetAngle(m_handle));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t RigidBody2D::GetShapeIndex(cpShape* shape) const
|
std::size_t RigidBody2D::GetShapeIndex(cpShape* shape) const
|
||||||
|
|
@ -283,9 +283,11 @@ namespace Nz
|
||||||
return m_isStatic;
|
return m_isStatic;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RigidBody2D::SetAngularVelocity(float angularVelocity)
|
void RigidBody2D::SetAngularVelocity(const RadianAnglef& angularVelocity)
|
||||||
{
|
{
|
||||||
cpBodySetAngularVelocity(m_handle, ToRadians(angularVelocity));
|
cpBodySetAngularVelocity(m_handle, angularVelocity.angle);
|
||||||
|
{
|
||||||
|
assert(shapeIndex < m_shapes.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
void RigidBody2D::SetGeom(Collider2DRef geom, bool recomputeMoment)
|
void RigidBody2D::SetGeom(Collider2DRef geom, bool recomputeMoment)
|
||||||
|
|
@ -400,9 +402,9 @@ namespace Nz
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RigidBody2D::SetRotation(float rotation)
|
void RigidBody2D::SetRotation(const RadianAnglef& rotation)
|
||||||
{
|
{
|
||||||
cpBodySetAngle(m_handle, ToRadians(rotation));
|
cpBodySetAngle(m_handle, rotation.angle);
|
||||||
if (m_isStatic)
|
if (m_isStatic)
|
||||||
{
|
{
|
||||||
m_world->RegisterPostStep(this, [](Nz::RigidBody2D* body)
|
m_world->RegisterPostStep(this, [](Nz::RigidBody2D* body)
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ SCENARIO("Billboard", "[GRAPHICS][BILLBOARD]")
|
||||||
{
|
{
|
||||||
REQUIRE(billboard.GetColor() == materialColor);
|
REQUIRE(billboard.GetColor() == materialColor);
|
||||||
REQUIRE(billboard.GetMaterial().Get() == materialRef.Get());
|
REQUIRE(billboard.GetMaterial().Get() == materialRef.Get());
|
||||||
REQUIRE(billboard.GetRotation() == Approx(0.f));
|
REQUIRE(billboard.GetRotation().angle == Approx(0.f));
|
||||||
REQUIRE(billboard.GetSize() == Nz::Vector2f(64.f, 64.f)); // Default sizes
|
REQUIRE(billboard.GetSize() == Nz::Vector2f(64.f, 64.f)); // Default sizes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -125,12 +125,12 @@ SCENARIO("RigidBody2D", "[PHYSICS2D][RIGIDBODY2D]")
|
||||||
THEN("We expect those to be true")
|
THEN("We expect those to be true")
|
||||||
{
|
{
|
||||||
CHECK(body.GetAABB() == aabb);
|
CHECK(body.GetAABB() == aabb);
|
||||||
CHECK(body.GetAngularVelocity() == Approx(0.f));
|
CHECK(body.GetAngularVelocity() == 0.f);
|
||||||
CHECK(body.GetMassCenter() == Nz::Vector2f::Zero());
|
CHECK(body.GetMassCenter() == Nz::Vector2f::Zero());
|
||||||
CHECK(body.GetGeom() == box);
|
CHECK(body.GetGeom() == box);
|
||||||
CHECK(body.GetMass() == Approx(mass));
|
CHECK(body.GetMass() == Approx(mass));
|
||||||
CHECK(body.GetPosition() == position);
|
CHECK(body.GetPosition() == position);
|
||||||
CHECK(body.GetRotation() == Approx(0.f));
|
CHECK(body.GetRotation().angle == Approx(0.f));
|
||||||
CHECK(body.GetUserdata() == &userData);
|
CHECK(body.GetUserdata() == &userData);
|
||||||
CHECK(body.GetVelocity() == Nz::Vector2f::Zero());
|
CHECK(body.GetVelocity() == Nz::Vector2f::Zero());
|
||||||
|
|
||||||
|
|
@ -166,39 +166,38 @@ SCENARIO("RigidBody2D", "[PHYSICS2D][RIGIDBODY2D]")
|
||||||
|
|
||||||
WHEN("We set an angular velocity")
|
WHEN("We set an angular velocity")
|
||||||
{
|
{
|
||||||
float angularSpeed = Nz::FromDegrees(90.f);
|
Nz::RadianAnglef angularSpeed = Nz::RadianAnglef(Nz::DegreeToRadian(90.f));
|
||||||
body.SetAngularVelocity(angularSpeed);
|
body.SetAngularVelocity(angularSpeed);
|
||||||
world.Step(1.f);
|
world.Step(1.f);
|
||||||
|
|
||||||
THEN("We expect those to be true")
|
THEN("We expect those to be true")
|
||||||
{
|
{
|
||||||
CHECK(body.GetAngularVelocity() == Approx(angularSpeed));
|
CHECK(body.GetAngularVelocity() == angularSpeed);
|
||||||
CHECK(body.GetRotation() == Approx(angularSpeed));
|
CHECK(body.GetRotation() == angularSpeed);
|
||||||
CHECK(body.GetAABB() == Nz::Rectf(-6.f, 3.f, 2.f, 1.f));
|
CHECK(body.GetAABB() == Nz::Rectf(-6.f, 3.f, 2.f, 1.f));
|
||||||
|
|
||||||
world.Step(1.f);
|
world.Step(1.f);
|
||||||
CHECK(body.GetRotation() == Approx(2.f * angularSpeed));
|
CHECK(body.GetRotation() == 2.f * angularSpeed);
|
||||||
CHECK(body.GetAABB() == Nz::Rectf(-4.f, -6.f, 1.f, 2.f));
|
CHECK(body.GetAABB() == Nz::Rectf(-4.f, -6.f, 1.f, 2.f));
|
||||||
|
|
||||||
world.Step(1.f);
|
world.Step(1.f);
|
||||||
CHECK(body.GetRotation() == Approx(3.f * angularSpeed));
|
CHECK(body.GetRotation() == 3.f * angularSpeed);
|
||||||
CHECK(body.GetAABB() == Nz::Rectf(4.f, -4.f, 2.f, 1.f));
|
CHECK(body.GetAABB() == Nz::Rectf(4.f, -4.f, 2.f, 1.f));
|
||||||
|
|
||||||
world.Step(1.f);
|
world.Step(1.f);
|
||||||
CHECK(body.GetRotation() == Approx(4.f * angularSpeed));
|
CHECK(body.GetRotation() == 4.f * angularSpeed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WHEN("We apply a torque")
|
WHEN("We apply a torque")
|
||||||
{
|
{
|
||||||
float angularSpeed = Nz::DegreeToRadian(90.f);
|
body.AddTorque(Nz::DegreeToRadian(90.f));
|
||||||
body.AddTorque(angularSpeed);
|
|
||||||
world.Step(1.f);
|
world.Step(1.f);
|
||||||
|
|
||||||
THEN("It is also counter-clockwise")
|
THEN("It is also counter-clockwise")
|
||||||
{
|
{
|
||||||
CHECK(body.GetAngularVelocity() >= 0.f);
|
CHECK(body.GetAngularVelocity().angle >= 0.f);
|
||||||
CHECK(body.GetRotation() >= 0.f);
|
CHECK(body.GetRotation().angle >= 0.f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -316,13 +315,13 @@ Nz::RigidBody2D CreateBody(Nz::PhysWorld2D& world)
|
||||||
void EQUALITY(const Nz::RigidBody2D& left, const Nz::RigidBody2D& right)
|
void EQUALITY(const Nz::RigidBody2D& left, const Nz::RigidBody2D& right)
|
||||||
{
|
{
|
||||||
CHECK(left.GetAABB() == right.GetAABB());
|
CHECK(left.GetAABB() == right.GetAABB());
|
||||||
CHECK(left.GetAngularVelocity() == Approx(right.GetAngularVelocity()));
|
CHECK(left.GetAngularVelocity() == right.GetAngularVelocity());
|
||||||
CHECK(left.GetMassCenter() == right.GetMassCenter());
|
CHECK(left.GetMassCenter() == right.GetMassCenter());
|
||||||
CHECK(left.GetGeom() == right.GetGeom());
|
CHECK(left.GetGeom() == right.GetGeom());
|
||||||
CHECK(left.GetHandle() != right.GetHandle());
|
CHECK(left.GetHandle() != right.GetHandle());
|
||||||
CHECK(left.GetMass() == Approx(right.GetMass()));
|
CHECK(left.GetMass() == Approx(right.GetMass()));
|
||||||
CHECK(left.GetPosition() == right.GetPosition());
|
CHECK(left.GetPosition() == right.GetPosition());
|
||||||
CHECK(left.GetRotation() == Approx(right.GetRotation()));
|
CHECK(left.GetRotation().angle == Approx(right.GetRotation().angle));
|
||||||
CHECK(left.GetUserdata() == right.GetUserdata());
|
CHECK(left.GetUserdata() == right.GetUserdata());
|
||||||
CHECK(left.GetVelocity() == right.GetVelocity());
|
CHECK(left.GetVelocity() == right.GetVelocity());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -85,15 +85,15 @@ SCENARIO("PhysicsSystem2D", "[NDK][PHYSICSSYSTEM2D]")
|
||||||
|
|
||||||
WHEN("We make rotate our entity")
|
WHEN("We make rotate our entity")
|
||||||
{
|
{
|
||||||
float angularSpeed = Nz::FromDegrees(45.f);
|
Nz::RadianAnglef angularSpeed = Nz::DegreeToRadian(45.f);
|
||||||
physicsComponent2D.SetAngularVelocity(angularSpeed);
|
physicsComponent2D.SetAngularVelocity(angularSpeed);
|
||||||
world.Update(2.f);
|
world.Update(2.f);
|
||||||
|
|
||||||
THEN("It should have been rotated")
|
THEN("It should have been rotated")
|
||||||
{
|
{
|
||||||
CHECK(physicsComponent2D.GetAngularVelocity() == Approx(angularSpeed));
|
CHECK(physicsComponent2D.GetAngularVelocity() == angularSpeed);
|
||||||
CHECK(physicsComponent2D.GetAABB() == Nz::Rectf(-2.f, 0.f, 2.f, 1.f));
|
CHECK(physicsComponent2D.GetAABB() == Nz::Rectf(-2.f, 0.f, 2.f, 1.f));
|
||||||
CHECK(physicsComponent2D.GetRotation() == Approx(Nz::FromDegrees(90.f)));
|
CHECK(physicsComponent2D.GetRotation() == Nz::RadianAnglef(Nz::DegreeToRadian(90.f)));
|
||||||
CHECK(nodeComponent.GetRotation().ToEulerAngles().roll == Approx(Nz::FromDegrees(90.f)));
|
CHECK(nodeComponent.GetRotation().ToEulerAngles().roll == Approx(Nz::FromDegrees(90.f)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -129,7 +129,7 @@ SCENARIO("PhysicsSystem2D", "[NDK][PHYSICSSYSTEM2D]")
|
||||||
|
|
||||||
WHEN("We make rotate our entity")
|
WHEN("We make rotate our entity")
|
||||||
{
|
{
|
||||||
float angularSpeed = Nz::FromDegrees(45.f);
|
Nz::RadianAnglef angularSpeed(Nz::DegreeToRadian(45.f));
|
||||||
physicsComponent2D.SetAngularVelocity(angularSpeed);
|
physicsComponent2D.SetAngularVelocity(angularSpeed);
|
||||||
world.Update(2.f);
|
world.Update(2.f);
|
||||||
|
|
||||||
|
|
@ -137,7 +137,7 @@ SCENARIO("PhysicsSystem2D", "[NDK][PHYSICSSYSTEM2D]")
|
||||||
{
|
{
|
||||||
CHECK(physicsComponent2D.GetAngularVelocity() == angularSpeed);
|
CHECK(physicsComponent2D.GetAngularVelocity() == angularSpeed);
|
||||||
CHECK(physicsComponent2D.GetAABB() == Nz::Rectf(1.f, 4.f, 2.f, 1.f));
|
CHECK(physicsComponent2D.GetAABB() == Nz::Rectf(1.f, 4.f, 2.f, 1.f));
|
||||||
CHECK(physicsComponent2D.GetRotation() == Approx(Nz::FromDegrees(90.f)));
|
CHECK(physicsComponent2D.GetRotation() == 2.f * angularSpeed);
|
||||||
CHECK(nodeComponent.GetPosition() == position);
|
CHECK(nodeComponent.GetPosition() == position);
|
||||||
CHECK(nodeComponent.GetRotation().ToEulerAngles().roll == Approx(Nz::FromDegrees(90.f)));
|
CHECK(nodeComponent.GetRotation().ToEulerAngles().roll == Approx(Nz::FromDegrees(90.f)));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -82,29 +82,29 @@ SCENARIO("RenderSystem", "[NDK][RenderSystem]")
|
||||||
|
|
||||||
WHEN("We set an angular velocity")
|
WHEN("We set an angular velocity")
|
||||||
{
|
{
|
||||||
float angularSpeed = Nz::FromDegrees(90.f);
|
Nz::RadianAnglef angularSpeed(Nz::DegreeToRadian(90.f));
|
||||||
physicsComponent2D.SetAngularVelocity(angularSpeed);
|
physicsComponent2D.SetAngularVelocity(angularSpeed);
|
||||||
world.Update(1.f);
|
world.Update(1.f);
|
||||||
|
|
||||||
THEN("We expect those to be true")
|
THEN("We expect those to be true")
|
||||||
{
|
{
|
||||||
CHECK(physicsComponent2D.GetAngularVelocity() == Approx(angularSpeed));
|
CHECK(physicsComponent2D.GetAngularVelocity() == angularSpeed);
|
||||||
CHECK(physicsComponent2D.GetRotation() == Approx(angularSpeed));
|
CHECK(physicsComponent2D.GetRotation() == angularSpeed);
|
||||||
CHECK(physicsComponent2D.GetAABB() == Nz::Rectf(1.f, 4.f, 2.f, 1.f));
|
CHECK(physicsComponent2D.GetAABB() == Nz::Rectf(1.f, 4.f, 2.f, 1.f));
|
||||||
CompareAABB(physicsComponent2D.GetAABB(), graphicsComponent.GetAABB());
|
CompareAABB(physicsComponent2D.GetAABB(), graphicsComponent.GetAABB());
|
||||||
|
|
||||||
world.Update(1.f);
|
world.Update(1.f);
|
||||||
CHECK(physicsComponent2D.GetRotation() == Approx(2.f * angularSpeed));
|
CHECK(physicsComponent2D.GetRotation() == 2.f * angularSpeed);
|
||||||
CHECK(physicsComponent2D.GetAABB() == Nz::Rectf(2.f, 2.f, 1.f, 2.f));
|
CHECK(physicsComponent2D.GetAABB() == Nz::Rectf(2.f, 2.f, 1.f, 2.f));
|
||||||
CompareAABB(physicsComponent2D.GetAABB(), graphicsComponent.GetAABB());
|
CompareAABB(physicsComponent2D.GetAABB(), graphicsComponent.GetAABB());
|
||||||
|
|
||||||
world.Update(1.f);
|
world.Update(1.f);
|
||||||
CHECK(physicsComponent2D.GetRotation() == Approx(3.f * angularSpeed));
|
CHECK(physicsComponent2D.GetRotation() == 3.f * angularSpeed);
|
||||||
CHECK(physicsComponent2D.GetAABB() == Nz::Rectf(3.f, 3.f, 2.f, 1.f));
|
CHECK(physicsComponent2D.GetAABB() == Nz::Rectf(3.f, 3.f, 2.f, 1.f));
|
||||||
CompareAABB(physicsComponent2D.GetAABB(), graphicsComponent.GetAABB());
|
CompareAABB(physicsComponent2D.GetAABB(), graphicsComponent.GetAABB());
|
||||||
|
|
||||||
world.Update(1.f);
|
world.Update(1.f);
|
||||||
CHECK(physicsComponent2D.GetRotation() == Approx(4.f * angularSpeed));
|
CHECK(physicsComponent2D.GetRotation() == 4.f * angularSpeed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue