internal bool SynchronizeShapes() { XForm transform = default(XForm); transform.R.Set(this._sweep.A0); transform.Position = this._sweep.C0 - Box2DX.Common.Math.Mul(transform.R, this._sweep.LocalCenter); bool flag = true; for (Shape shape = this._shapeList; shape != null; shape = shape._next) { flag = shape.Synchronize(this._world._broadPhase, transform, this._xf); if (!flag) { break; } } bool result; if (!flag) { this._flags |= Body.BodyFlags.Frozen; this._linearVelocity.SetZero(); this._angularVelocity = 0f; for (Shape shape = this._shapeList; shape != null; shape = shape._next) { shape.DestroyProxy(this._world._broadPhase); } result = false; } else { result = true; } return(result); }
public void PutToSleep() { this._flags |= Body.BodyFlags.Sleep; this._sleepTime = 0f; this._linearVelocity.SetZero(); this._angularVelocity = 0f; this._force.SetZero(); this._torque = 0f; }
public void SetBullet(bool flag) { if (flag) { this._flags |= Body.BodyFlags.Bullet; } else { this._flags &= ~Body.BodyFlags.Bullet; } }
public void AllowSleeping(bool flag) { if (flag) { this._flags |= Body.BodyFlags.AllowSleep; } else { this._flags &= ~Body.BodyFlags.AllowSleep; this.WakeUp(); } }
public bool SetXForm(Vec2 position, float angle) { Box2DXDebug.Assert(!this._world._lock); bool result; if (this._world._lock) { result = true; } else { if (this.IsFrozen()) { result = false; } else { this._xf.R.Set(angle); this._xf.Position = position; this._sweep.C0 = (this._sweep.C = Box2DX.Common.Math.Mul(this._xf, this._sweep.LocalCenter)); this._sweep.A = angle; this._sweep.A0 = angle; bool flag = false; for (Shape shape = this._shapeList; shape != null; shape = shape._next) { if (!shape.Synchronize(this._world._broadPhase, this._xf, this._xf)) { flag = true; break; } } if (flag) { this._flags |= Body.BodyFlags.Frozen; this._linearVelocity.SetZero(); this._angularVelocity = 0f; for (Shape shape = this._shapeList; shape != null; shape = shape._next) { shape.DestroyProxy(this._world._broadPhase); } result = false; } else { this._world._broadPhase.Commit(); result = true; } } } return(result); }
public void WakeUp() { this._flags &= ~Body.BodyFlags.Sleep; this._sleepTime = 0f; }
internal bool _useGravity; // STEVE Added internal Body(BodyDef bd, World world) { Box2DXDebug.Assert(!world._lock); this._flags = (Body.BodyFlags) 0; if (bd.IsBullet) { this._flags |= Body.BodyFlags.Bullet; } if (bd.FixedRotation) { this._flags |= Body.BodyFlags.FixedRotation; } if (bd.AllowSleep) { this._flags |= Body.BodyFlags.AllowSleep; } if (bd.IsSleeping) { this._flags |= Body.BodyFlags.Sleep; } this._world = world; this._xf.Position = bd.Position; this._xf.R.Set(bd.Angle); this._sweep.LocalCenter = bd.MassData.Center; this._sweep.T0 = 1f; this._sweep.A0 = (this._sweep.A = bd.Angle); this._sweep.C0 = (this._sweep.C = Box2DX.Common.Math.Mul(this._xf, this._sweep.LocalCenter)); this._jointList = null; this._contactList = null; this._prev = null; this._next = null; this._linearDamping = bd.LinearDamping; this._angularDamping = bd.AngularDamping; this._force.Set(0f, 0f); this._torque = 0f; this._linearVelocity.SetZero(); this._angularVelocity = 0f; this._sleepTime = 0f; this._invMass = 0f; this._I = 0f; this._invI = 0f; this._mass = bd.MassData.Mass; if (this._mass > 0f) { this._invMass = 1f / this._mass; } if ((this._flags & Body.BodyFlags.FixedRotation) == (Body.BodyFlags) 0) { this._I = bd.MassData.I; } if (this._I > 0f) { this._invI = 1f / this._I; } if (this._invMass == 0f && this._invI == 0f) { this._type = Body.BodyType.Static; } else { this._type = Body.BodyType.Dynamic; } this._userData = bd.UserData; this._shapeList = null; this._shapeCount = 0; this._gravity = _world.Gravity; // STEVE Added this._useGravity = false; // STEVE Added }
internal bool SynchronizeShapes() { XForm transform = default(XForm); transform.R.Set(this._sweep.A0); transform.Position = this._sweep.C0 - Box2DX.Common.Math.Mul(transform.R, this._sweep.LocalCenter); bool flag = true; for (Shape shape = this._shapeList; shape != null; shape = shape._next) { flag = shape.Synchronize(this._world._broadPhase, transform, this._xf); if (!flag) { break; } } bool result; if (!flag) { this._flags |= Body.BodyFlags.Frozen; this._linearVelocity.SetZero(); this._angularVelocity = 0f; for (Shape shape = this._shapeList; shape != null; shape = shape._next) { shape.DestroyProxy(this._world._broadPhase); } result = false; } else { result = true; } return result; }
public bool SetXForm(Vec2 position, float angle) { Box2DXDebug.Assert(!this._world._lock); bool result; if (this._world._lock) { result = true; } else { if (this.IsFrozen()) { result = false; } else { this._xf.R.Set(angle); this._xf.Position = position; this._sweep.C0 = (this._sweep.C = Box2DX.Common.Math.Mul(this._xf, this._sweep.LocalCenter)); this._sweep.A = angle; this._sweep.A0 = angle; bool flag = false; for (Shape shape = this._shapeList; shape != null; shape = shape._next) { if (!shape.Synchronize(this._world._broadPhase, this._xf, this._xf)) { flag = true; break; } } if (flag) { this._flags |= Body.BodyFlags.Frozen; this._linearVelocity.SetZero(); this._angularVelocity = 0f; for (Shape shape = this._shapeList; shape != null; shape = shape._next) { shape.DestroyProxy(this._world._broadPhase); } result = false; } else { this._world._broadPhase.Commit(); result = true; } } } return result; }
internal Body(BodyDef bd, World world) { Box2DXDebug.Assert(!world._lock); this._flags = (Body.BodyFlags)0; if (bd.IsBullet) { this._flags |= Body.BodyFlags.Bullet; } if (bd.FixedRotation) { this._flags |= Body.BodyFlags.FixedRotation; } if (bd.AllowSleep) { this._flags |= Body.BodyFlags.AllowSleep; } if (bd.IsSleeping) { this._flags |= Body.BodyFlags.Sleep; } this._world = world; this._xf.Position = bd.Position; this._xf.R.Set(bd.Angle); this._sweep.LocalCenter = bd.MassData.Center; this._sweep.T0 = 1f; this._sweep.A0 = (this._sweep.A = bd.Angle); this._sweep.C0 = (this._sweep.C = Box2DX.Common.Math.Mul(this._xf, this._sweep.LocalCenter)); this._jointList = null; this._contactList = null; this._prev = null; this._next = null; this._linearDamping = bd.LinearDamping; this._angularDamping = bd.AngularDamping; this._force.Set(0f, 0f); this._torque = 0f; this._linearVelocity.SetZero(); this._angularVelocity = 0f; this._sleepTime = 0f; this._invMass = 0f; this._I = 0f; this._invI = 0f; this._mass = bd.MassData.Mass; if (this._mass > 0f) { this._invMass = 1f / this._mass; } if ((this._flags & Body.BodyFlags.FixedRotation) == (Body.BodyFlags)0) { this._I = bd.MassData.I; } if (this._I > 0f) { this._invI = 1f / this._I; } if (this._invMass == 0f && this._invI == 0f) { this._type = Body.BodyType.Static; } else { this._type = Body.BodyType.Dynamic; } this._userData = bd.UserData; this._shapeList = null; this._shapeCount = 0; this._gravity = _world.Gravity; // STEVE Added this._useGravity = false; // STEVE Added }