mirror of
https://github.com/love2d/love.git
synced 2026-08-18 03:34:23 +02:00
Updated box2d from 2.2.1 to 2.3.0
--HG-- branch : box2d-2.3
This commit is contained in:
@@ -154,8 +154,8 @@ public:
|
||||
void DestroyFixture(b2Fixture* fixture);
|
||||
|
||||
/// Set the position of the body's origin and rotation.
|
||||
/// This breaks any contacts and wakes the other bodies.
|
||||
/// Manipulating a body's transform may cause non-physical behavior.
|
||||
/// Note: contacts are updated on the next call to b2World::Step.
|
||||
/// @param position the world position of the body's local origin.
|
||||
/// @param angle the world rotation in radians.
|
||||
void SetTransform(const b2Vec2& position, float32 angle);
|
||||
@@ -184,7 +184,7 @@ public:
|
||||
|
||||
/// Get the linear velocity of the center of mass.
|
||||
/// @return the linear velocity of the center of mass.
|
||||
b2Vec2 GetLinearVelocity() const;
|
||||
const b2Vec2& GetLinearVelocity() const;
|
||||
|
||||
/// Set the angular velocity.
|
||||
/// @param omega the new angular velocity in radians/second.
|
||||
@@ -199,28 +199,33 @@ public:
|
||||
/// affect the angular velocity. This wakes up the body.
|
||||
/// @param force the world force vector, usually in Newtons (N).
|
||||
/// @param point the world position of the point of application.
|
||||
void ApplyForce(const b2Vec2& force, const b2Vec2& point);
|
||||
/// @param wake also wake up the body
|
||||
void ApplyForce(const b2Vec2& force, const b2Vec2& point, bool wake);
|
||||
|
||||
/// Apply a force to the center of mass. This wakes up the body.
|
||||
/// @param force the world force vector, usually in Newtons (N).
|
||||
void ApplyForceToCenter(const b2Vec2& force);
|
||||
/// @param wake also wake up the body
|
||||
void ApplyForceToCenter(const b2Vec2& force, bool wake);
|
||||
|
||||
/// Apply a torque. This affects the angular velocity
|
||||
/// without affecting the linear velocity of the center of mass.
|
||||
/// This wakes up the body.
|
||||
/// @param torque about the z-axis (out of the screen), usually in N-m.
|
||||
void ApplyTorque(float32 torque);
|
||||
/// @param wake also wake up the body
|
||||
void ApplyTorque(float32 torque, bool wake);
|
||||
|
||||
/// Apply an impulse at a point. This immediately modifies the velocity.
|
||||
/// It also modifies the angular velocity if the point of application
|
||||
/// is not at the center of mass. This wakes up the body.
|
||||
/// @param impulse the world impulse vector, usually in N-seconds or kg-m/s.
|
||||
/// @param point the world position of the point of application.
|
||||
void ApplyLinearImpulse(const b2Vec2& impulse, const b2Vec2& point);
|
||||
/// @param wake also wake up the body
|
||||
void ApplyLinearImpulse(const b2Vec2& impulse, const b2Vec2& point, bool wake);
|
||||
|
||||
/// Apply an angular impulse.
|
||||
/// @param impulse the angular impulse in units of kg*m*m/s
|
||||
void ApplyAngularImpulse(float32 impulse);
|
||||
/// @param wake also wake up the body
|
||||
void ApplyAngularImpulse(float32 impulse, bool wake);
|
||||
|
||||
/// Get the total mass of the body.
|
||||
/// @return the mass, usually in kilograms (kg).
|
||||
@@ -315,11 +320,11 @@ public:
|
||||
|
||||
/// Set the sleep state of the body. A sleeping body has very
|
||||
/// low CPU cost.
|
||||
/// @param flag set to true to put body to sleep, false to wake it.
|
||||
/// @param flag set to true to wake the body, false to put it to sleep.
|
||||
void SetAwake(bool flag);
|
||||
|
||||
/// Get the sleeping state of this body.
|
||||
/// @return true if the body is sleeping.
|
||||
/// @return true if the body is awake.
|
||||
bool IsAwake() const;
|
||||
|
||||
/// Set the active state of the body. An inactive body is not
|
||||
@@ -387,15 +392,16 @@ private:
|
||||
friend class b2Contact;
|
||||
|
||||
friend class b2DistanceJoint;
|
||||
friend class b2FrictionJoint;
|
||||
friend class b2GearJoint;
|
||||
friend class b2WheelJoint;
|
||||
friend class b2MotorJoint;
|
||||
friend class b2MouseJoint;
|
||||
friend class b2PrismaticJoint;
|
||||
friend class b2PulleyJoint;
|
||||
friend class b2RevoluteJoint;
|
||||
friend class b2WeldJoint;
|
||||
friend class b2FrictionJoint;
|
||||
friend class b2RopeJoint;
|
||||
friend class b2WeldJoint;
|
||||
friend class b2WheelJoint;
|
||||
|
||||
// m_flags
|
||||
enum
|
||||
@@ -505,7 +511,7 @@ inline void b2Body::SetLinearVelocity(const b2Vec2& v)
|
||||
m_linearVelocity = v;
|
||||
}
|
||||
|
||||
inline b2Vec2 b2Body::GetLinearVelocity() const
|
||||
inline const b2Vec2& b2Body::GetLinearVelocity() const
|
||||
{
|
||||
return m_linearVelocity;
|
||||
}
|
||||
@@ -655,20 +661,6 @@ inline bool b2Body::IsActive() const
|
||||
return (m_flags & e_activeFlag) == e_activeFlag;
|
||||
}
|
||||
|
||||
inline void b2Body::SetFixedRotation(bool flag)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
m_flags |= e_fixedRotationFlag;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_flags &= ~e_fixedRotationFlag;
|
||||
}
|
||||
|
||||
ResetMassData();
|
||||
}
|
||||
|
||||
inline bool b2Body::IsFixedRotation() const
|
||||
{
|
||||
return (m_flags & e_fixedRotationFlag) == e_fixedRotationFlag;
|
||||
@@ -742,79 +734,101 @@ inline void* b2Body::GetUserData() const
|
||||
return m_userData;
|
||||
}
|
||||
|
||||
inline void b2Body::ApplyForce(const b2Vec2& force, const b2Vec2& point)
|
||||
inline void b2Body::ApplyForce(const b2Vec2& force, const b2Vec2& point, bool wake)
|
||||
{
|
||||
if (m_type != b2_dynamicBody)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsAwake() == false)
|
||||
if (wake && (m_flags & e_awakeFlag) == 0)
|
||||
{
|
||||
SetAwake(true);
|
||||
}
|
||||
|
||||
m_force += force;
|
||||
m_torque += b2Cross(point - m_sweep.c, force);
|
||||
// Don't accumulate a force if the body is sleeping.
|
||||
if (m_flags & e_awakeFlag)
|
||||
{
|
||||
m_force += force;
|
||||
m_torque += b2Cross(point - m_sweep.c, force);
|
||||
}
|
||||
}
|
||||
|
||||
inline void b2Body::ApplyForceToCenter(const b2Vec2& force)
|
||||
inline void b2Body::ApplyForceToCenter(const b2Vec2& force, bool wake)
|
||||
{
|
||||
if (m_type != b2_dynamicBody)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsAwake() == false)
|
||||
if (wake && (m_flags & e_awakeFlag) == 0)
|
||||
{
|
||||
SetAwake(true);
|
||||
}
|
||||
|
||||
m_force += force;
|
||||
// Don't accumulate a force if the body is sleeping
|
||||
if (m_flags & e_awakeFlag)
|
||||
{
|
||||
m_force += force;
|
||||
}
|
||||
}
|
||||
|
||||
inline void b2Body::ApplyTorque(float32 torque)
|
||||
inline void b2Body::ApplyTorque(float32 torque, bool wake)
|
||||
{
|
||||
if (m_type != b2_dynamicBody)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsAwake() == false)
|
||||
if (wake && (m_flags & e_awakeFlag) == 0)
|
||||
{
|
||||
SetAwake(true);
|
||||
}
|
||||
|
||||
m_torque += torque;
|
||||
// Don't accumulate a force if the body is sleeping
|
||||
if (m_flags & e_awakeFlag)
|
||||
{
|
||||
m_torque += torque;
|
||||
}
|
||||
}
|
||||
|
||||
inline void b2Body::ApplyLinearImpulse(const b2Vec2& impulse, const b2Vec2& point)
|
||||
inline void b2Body::ApplyLinearImpulse(const b2Vec2& impulse, const b2Vec2& point, bool wake)
|
||||
{
|
||||
if (m_type != b2_dynamicBody)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsAwake() == false)
|
||||
if (wake && (m_flags & e_awakeFlag) == 0)
|
||||
{
|
||||
SetAwake(true);
|
||||
}
|
||||
m_linearVelocity += m_invMass * impulse;
|
||||
m_angularVelocity += m_invI * b2Cross(point - m_sweep.c, impulse);
|
||||
|
||||
// Don't accumulate velocity if the body is sleeping
|
||||
if (m_flags & e_awakeFlag)
|
||||
{
|
||||
m_linearVelocity += m_invMass * impulse;
|
||||
m_angularVelocity += m_invI * b2Cross(point - m_sweep.c, impulse);
|
||||
}
|
||||
}
|
||||
|
||||
inline void b2Body::ApplyAngularImpulse(float32 impulse)
|
||||
inline void b2Body::ApplyAngularImpulse(float32 impulse, bool wake)
|
||||
{
|
||||
if (m_type != b2_dynamicBody)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsAwake() == false)
|
||||
if (wake && (m_flags & e_awakeFlag) == 0)
|
||||
{
|
||||
SetAwake(true);
|
||||
}
|
||||
m_angularVelocity += m_invI * impulse;
|
||||
|
||||
// Don't accumulate velocity if the body is sleeping
|
||||
if (m_flags & e_awakeFlag)
|
||||
{
|
||||
m_angularVelocity += m_invI * impulse;
|
||||
}
|
||||
}
|
||||
|
||||
inline void b2Body::SynchronizeTransform()
|
||||
|
||||
Reference in New Issue
Block a user