public virtual void SetBullet(bool flag) { if (flag) { m_flags |= b2BodyFlags.e_bulletFlag; } else { m_flags &= ~b2BodyFlags.e_bulletFlag; } }
public virtual void SetSleepingAllowed(bool flag) { if (flag) { m_flags |= b2BodyFlags.e_autoSleepFlag; } else { m_flags &= ~b2BodyFlags.e_autoSleepFlag; SetAwake(true); } }
public virtual void SetFixedRotation(bool flag) { if (flag) { m_flags |= b2BodyFlags.e_fixedRotationFlag; } else { m_flags &= ~b2BodyFlags.e_fixedRotationFlag; } ResetMassData(); }
public virtual void SetActive(bool flag) { if (flag == IsActive()) { return; } if (flag) { m_flags |= b2BodyFlags.e_activeFlag; // Create all proxies. b2BroadPhase broadPhase = m_world.ContactManager.BroadPhase; for (b2Fixture f = m_fixtureList; f != null; f = f.Next) { f.CreateProxies(broadPhase, m_xf); } // Contacts are created the next time step. } else { m_flags &= ~b2BodyFlags.e_activeFlag; // Destroy all proxies. b2BroadPhase broadPhase = m_world.ContactManager.BroadPhase; for (b2Fixture f = m_fixtureList; f != null; f = f.Next) { f.DestroyProxies(broadPhase); } // Destroy the attached contacts. b2ContactEdge ce = m_contactList; while (ce != null) { b2ContactEdge ce0 = ce; ce = ce.Next; m_world.ContactManager.Destroy(ce0.Contact); } m_contactList = null; } }
public virtual void SetAwake(bool flag) { if (flag) { if ((m_flags & b2BodyFlags.e_awakeFlag) == 0) { m_flags |= b2BodyFlags.e_awakeFlag; m_sleepTime = 0.0f; } } else { m_flags &= ~b2BodyFlags.e_awakeFlag; m_sleepTime = 0.0f; m_linearVelocity.SetZero(); m_angularVelocity = 0.0f; m_force.SetZero(); m_torque = 0.0f; } }
public virtual void SetFixedRotation(bool flag) { if (flag) { if (m_flags.HasFlag(b2BodyFlags.e_fixedRotationFlag)) { return; } m_flags |= b2BodyFlags.e_fixedRotationFlag; } else { if (!m_flags.HasFlag(b2BodyFlags.e_fixedRotationFlag)) { return; } m_flags &= ~b2BodyFlags.e_fixedRotationFlag; } ResetMassData(); }
public virtual void SetFixedRotation(bool flag) { if (flag) { if ((BodyFlags & b2BodyFlags.e_fixedRotationFlag) != 0) { return; } BodyFlags |= b2BodyFlags.e_fixedRotationFlag; } else { if ((BodyFlags & b2BodyFlags.e_fixedRotationFlag) == 0) { return; } BodyFlags &= ~b2BodyFlags.e_fixedRotationFlag; } ResetMassData(); }
public virtual void SetAwake(bool flag) { if (flag) { if ((BodyFlags & b2BodyFlags.e_awakeFlag) == 0) { BodyFlags |= b2BodyFlags.e_awakeFlag; SleepTime = 0.0f; } } else { if ((BodyFlags & b2BodyFlags.e_awakeFlag) != 0) { BodyFlags &= ~b2BodyFlags.e_awakeFlag; SleepTime = 0.0f; m_linearVelocity = b2Vec2.Zero; m_angularVelocity = 0.0f; Force = b2Vec2.Zero; Torque = 0.0f; } } }
public virtual void SetAwake(bool flag) { if (flag) { if (!m_flags.HasFlag(b2BodyFlags.e_awakeFlag)) { m_flags |= b2BodyFlags.e_awakeFlag; m_sleepTime = 0.0f; } } else { if (m_flags.HasFlag(b2BodyFlags.e_awakeFlag)) { m_flags &= ~b2BodyFlags.e_awakeFlag; m_sleepTime = 0.0f; m_linearVelocity.SetZero(); m_angularVelocity = 0.0f; m_force.SetZero(); m_torque = 0.0f; } } }
public static bool HasFlag(this b2BodyFlags flag, b2BodyFlags testFlag) { return((flag & testFlag) == testFlag); }
public static bool HasFlag(this b2BodyFlags flag, b2BodyFlags testFlag) { return ((flag & testFlag) == testFlag); }
public b2Body(b2BodyDef bd, b2World world) { m_flags = 0; if (bd.bullet) { m_flags |= b2BodyFlags.e_bulletFlag; } if (bd.fixedRotation) { m_flags |= b2BodyFlags.e_fixedRotationFlag; } if (bd.allowSleep) { m_flags |= b2BodyFlags.e_autoSleepFlag; } if (bd.awake) { m_flags |= b2BodyFlags.e_awakeFlag; } if (bd.active) { m_flags |= b2BodyFlags.e_activeFlag; } m_world = world; m_xf.p = bd.position; m_xf.q.Set(bd.angle); Sweep.localCenter.SetZero(); Sweep.c0 = m_xf.p; Sweep.c = m_xf.p; Sweep.a0 = bd.angle; Sweep.a = bd.angle; Sweep.alpha0 = 0.0f; m_jointList = null; m_contactList = null; Prev = null; Next = null; m_linearVelocity = bd.linearVelocity; m_angularVelocity = bd.angularVelocity; m_linearDamping = bd.linearDamping; m_angularDamping = bd.angularDamping; m_gravityScale = bd.gravityScale; m_force.SetZero(); m_torque = 0.0f; m_sleepTime = 0.0f; m_type = bd.type; if (m_type == b2BodyType.b2_dynamicBody) { m_mass = 1.0f; m_invMass = 1.0f; } else { m_mass = 0.0f; m_invMass = 0.0f; } m_I = 0.0f; m_invI = 0.0f; m_userData = bd.userData; m_fixtureList = null; m_fixtureCount = 0; }
protected b2Transform m_xf = b2Transform.Default; // the body origin transform #endregion Fields #region Constructors public b2Body(b2BodyDef bd, b2World world) { m_flags = 0; if (bd.bullet) { m_flags |= b2BodyFlags.e_bulletFlag; } if (bd.fixedRotation) { m_flags |= b2BodyFlags.e_fixedRotationFlag; } if (bd.allowSleep) { m_flags |= b2BodyFlags.e_autoSleepFlag; } if (bd.awake) { m_flags |= b2BodyFlags.e_awakeFlag; } if (bd.active) { m_flags |= b2BodyFlags.e_activeFlag; } m_world = world; m_xf.p = bd.position; m_xf.q.Set(bd.angle); Sweep.localCenter.SetZero(); Sweep.c0 = m_xf.p; Sweep.c = m_xf.p; Sweep.a0 = bd.angle; Sweep.a = bd.angle; Sweep.alpha0 = 0.0f; m_jointList = null; m_contactList = null; Prev = null; Next = null; m_linearVelocity = bd.linearVelocity; m_angularVelocity = bd.angularVelocity; m_linearDamping = bd.linearDamping; m_angularDamping = bd.angularDamping; m_gravityScale = bd.gravityScale; m_force.SetZero(); m_torque = 0.0f; m_sleepTime = 0.0f; m_type = bd.type; if (m_type == b2BodyType.b2_dynamicBody) { m_mass = 1.0f; m_invMass = 1.0f; } else { m_mass = 0.0f; m_invMass = 0.0f; } m_I = 0.0f; m_invI = 0.0f; m_userData = bd.userData; m_fixtureList = null; m_fixtureCount = 0; }
public b2Body(b2BodyDef bd, b2World world) { BodyFlags = 0; if (bd.bullet) { BodyFlags |= b2BodyFlags.e_bulletFlag; } if (bd.fixedRotation) { BodyFlags |= b2BodyFlags.e_fixedRotationFlag; } if (bd.allowSleep) { BodyFlags |= b2BodyFlags.e_autoSleepFlag; } if (bd.awake) { BodyFlags |= b2BodyFlags.e_awakeFlag; } if (bd.active) { BodyFlags |= b2BodyFlags.e_activeFlag; } World = world; Transform.p = bd.position; Transform.q.Set(bd.angle); Sweep.localCenter.SetZero(); Sweep.c0 = Transform.p; Sweep.c = Transform.p; Sweep.a0 = bd.angle; Sweep.a = bd.angle; Sweep.alpha0 = 0.0f; JointList = null; ContactList = null; Prev = null; Next = null; m_linearVelocity = bd.linearVelocity; m_angularVelocity = bd.angularVelocity; LinearDamping = bd.linearDamping; AngularDamping = bd.angularDamping; GravityScale = bd.gravityScale; Force.SetZero(); Torque = 0.0f; SleepTime = 0.0f; BodyType = bd.type; if (BodyType == b2BodyType.b2_dynamicBody) { Mass = 1.0f; InvertedMass = 1.0f; } else { Mass = 0.0f; InvertedMass = 0.0f; } m_I = 0.0f; InvertedI = 0.0f; UserData = bd.userData; FixtureList = null; FixtureCount = 0; }