Replace floating point angle by Angle class instance
This commit is contained in:
@@ -163,8 +163,8 @@ namespace Nz
|
||||
}
|
||||
|
||||
|
||||
DampedRotarySpringConstraint2D::DampedRotarySpringConstraint2D(RigidBody2D& first, RigidBody2D& second, float restAngle, float stiffness, float damping) :
|
||||
Constraint2D(first.GetWorld(), cpDampedRotarySpringNew(first.GetHandle(), second.GetHandle(), restAngle, stiffness, damping))
|
||||
DampedRotarySpringConstraint2D::DampedRotarySpringConstraint2D(RigidBody2D& first, RigidBody2D& second, const RadianAnglef& restAngle, float stiffness, float damping) :
|
||||
Constraint2D(first.GetWorld(), cpDampedRotarySpringNew(first.GetHandle(), second.GetHandle(), restAngle.angle, stiffness, damping))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@ namespace Nz
|
||||
return float(cpDampedRotarySpringGetDamping(m_constraint));
|
||||
}
|
||||
|
||||
float DampedRotarySpringConstraint2D::GetRestAngle() const
|
||||
RadianAnglef DampedRotarySpringConstraint2D::GetRestAngle() const
|
||||
{
|
||||
return float(cpDampedRotarySpringGetRestAngle(m_constraint));
|
||||
}
|
||||
@@ -188,9 +188,9 @@ namespace Nz
|
||||
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)
|
||||
@@ -317,7 +317,7 @@ namespace Nz
|
||||
{
|
||||
}
|
||||
|
||||
float RatchetConstraint2D::GetAngle() const
|
||||
RadianAnglef RatchetConstraint2D::GetAngle() const
|
||||
{
|
||||
return float(cpRatchetJointGetAngle(m_constraint));
|
||||
}
|
||||
@@ -332,9 +332,9 @@ namespace Nz
|
||||
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)
|
||||
@@ -348,29 +348,29 @@ namespace Nz
|
||||
}
|
||||
|
||||
|
||||
RotaryLimitConstraint2D::RotaryLimitConstraint2D(RigidBody2D& first, RigidBody2D& second, float minAngle, float maxAngle) :
|
||||
Constraint2D(first.GetWorld(), cpRotaryLimitJointNew(first.GetHandle(), second.GetHandle(), minAngle, maxAngle))
|
||||
RotaryLimitConstraint2D::RotaryLimitConstraint2D(RigidBody2D& first, RigidBody2D& second, const RadianAnglef& minAngle, const RadianAnglef& 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));
|
||||
}
|
||||
|
||||
float RotaryLimitConstraint2D::GetMinAngle() const
|
||||
RadianAnglef RotaryLimitConstraint2D::GetMinAngle() const
|
||||
{
|
||||
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);
|
||||
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)
|
||||
|
||||
@@ -185,9 +185,9 @@ namespace Nz
|
||||
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
|
||||
@@ -233,9 +233,9 @@ namespace Nz
|
||||
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
|
||||
@@ -283,9 +283,11 @@ namespace Nz
|
||||
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)
|
||||
@@ -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)
|
||||
{
|
||||
m_world->RegisterPostStep(this, [](Nz::RigidBody2D* body)
|
||||
|
||||
Reference in New Issue
Block a user