public Body(BodyDef bd, World world)
{
Debug.Assert(bd.Position.Valid);
Debug.Assert(bd.LinearVelocity.Valid);
Debug.Assert(bd.GravityScale >= 0.0f);
Debug.Assert(bd.AngularDamping >= 0.0f);
Debug.Assert(bd.LinearDamping >= 0.0f);
Flags = TypeFlags.None;
if (bd.Bullet)
{
Flags |= TypeFlags.Bullet;
}
if (bd.FixedRotation)
{
Flags |= TypeFlags.FixedRotation;
}
if (bd.AllowSleep)
{
Flags |= TypeFlags.AutoSleep;
}
if (bd.Awake)
{
Flags |= TypeFlags.Awake;
}
if (bd.Active)
{
Flags |= TypeFlags.Active;
}
World = world;
Xf.P.Set(bd.Position);
Xf.Q.Set(bd.Angle);
Sweep.LocalCenter.SetZero();
Sweep.C0.Set(Xf.P);
Sweep.C.Set(Xf.P);
Sweep.A0 = bd.Angle;
Sweep.A = bd.Angle;
Sweep.Alpha0 = 0.0f;
JointList = null;
ContactList = null;
Prev = null;
Next = null;
m_linearVelocity.Set(bd.LinearVelocity);
m_angularVelocity = bd.AngularVelocity;
LinearDamping = bd.LinearDamping;
AngularDamping = bd.AngularDamping;
GravityScale = bd.GravityScale;
Force.SetZero();
Torque = 0.0f;
SleepTime = 0.0f;
m_type = bd.Type;
if (m_type == BodyType.Dynamic)
{
Mass = 1f;
InvMass = 1f;
}
else
{
Mass = 0f;
InvMass = 0f;
}
I = 0.0f;
InvI = 0.0f;
UserData = bd.UserData;
FixtureList = null;
FixtureCount = 0;
}