private Synchronize ( |
||
broadPhase | ||
Transform1 | Box2DX.Common.Transform | |
Transform2 | Box2DX.Common.Transform | |
Résultat | bool |
internal bool SynchronizeFixtures() { Transform xf1 = default(Transform); xf1.rotation = Box2DX.Common.Math.AngleToRotation(_sweep.A0); //xf1.R = new Mat22(_sweep.A0); xf1.position = _sweep.C0 - xf1.TransformDirection(_sweep.LocalCenter); bool inRange = true; for (Fixture f = _fixtureList; f != null; f = f.Next) { inRange = f.Synchronize(_world._broadPhase, xf1, _xf); if (inRange == false) { break; } } if (inRange == false) { _flags |= BodyFlags.Frozen; _linearVelocity = Vector2.zero; _angularVelocity = 0.0f; // Failure return(false); } // Success return(true); }
internal bool SynchronizeFixtures() { XForm xf1 = new XForm(); xf1.R.Set(_sweep.A0); xf1.Position = _sweep.C0 - Common.Math.Mul(xf1.R, _sweep.LocalCenter); bool inRange = true; for (Fixture f = _fixtureList; f != null; f = f.Next) { inRange = f.Synchronize(_world._broadPhase, xf1, _xf); if (inRange == false) { break; } } if (inRange == false) { _flags |= BodyFlags.Frozen; _linearVelocity.SetZero(); _angularVelocity = 0.0f; // Failure return(false); } // Success return(true); }
public bool SetTransform(Vector2 position, Quaternion rotation) #endif { Box2DXDebug.Assert(_world._lock == false); if (_world._lock == true) { return(true); } if (IsFrozen()) { return(false); } _xf.rotation = rotation; //_xf.R = rotation; _xf.position = position; _sweep.C0 = _sweep.C = _xf.TransformPoint(_sweep.LocalCenter); #if USE_MATRIX_FOR_ROTATION _sweep.A0 = _sweep.A = rotation.GetAngle(); #else _sweep.A0 = _sweep.A = rotation.eulerAngles.z * Mathf.Deg2Rad; #endif bool freeze = false; for (Fixture f = _fixtureList; f != null; f = f.Next) { bool inRange = f.Synchronize(_world._broadPhase, _xf, _xf); if (inRange == false) { freeze = true; break; } } if (freeze == true) { _flags |= BodyFlags.Frozen; _linearVelocity = Vector2.zero; _angularVelocity = 0.0f; // Failure return(false); } // Success _world._broadPhase.Commit(); return(true); }
internal void SynchronizeFixtures() { Transform xf1 = new Transform(); xf1.R.Set(_sweep.A0); xf1.Position = _sweep.C0 - Math.Mul(xf1.R, _sweep.LocalCenter); BroadPhase broadPhase = _world._contactManager._broadPhase; for (Fixture f = _fixtureList; f != null; f = f._next) { f.Synchronize(broadPhase, xf1, _xf); } }
/// <summary> /// Set the position of the body's origin and rotation (radians). /// This breaks any contacts and wakes the other bodies. /// </summary> /// <param name="position">The new world position of the body's origin (not necessarily /// the center of mass).</param> /// <param name="angle">The new world rotation angle of the body in radians.</param> /// <returns>Return false if the movement put a shape outside the world. In this case the /// body is automatically frozen.</returns> public bool SetXForm(Vec2 position, float angle) { Box2DXDebug.Assert(_world._lock == false); if (_world._lock == true) { return(true); } if (IsFrozen()) { return(false); } _xf.R.Set(angle); _xf.Position = position; _sweep.C0 = _sweep.C = Common.Math.Mul(_xf, _sweep.LocalCenter); _sweep.A0 = _sweep.A = angle; bool freeze = false; for (Fixture f = _fixtureList; f != null; f = f.Next) { bool inRange = f.Synchronize(_world._broadPhase, _xf, _xf); if (inRange == false) { freeze = true; break; } } if (freeze == true) { _flags |= BodyFlags.Frozen; _linearVelocity.SetZero(); _angularVelocity = 0.0f; // Failure return(false); } // Success _world._broadPhase.Commit(); return(true); }
public void SetTransform(Vec2 position, float angle) { Box2DXDebug.Assert(_world.IsLocked() == false); if (_world.IsLocked() == true) { return; } _xf.R.Set(angle); _xf.Position = position; _sweep.C0 = _sweep.C = Math.Mul(_xf, _sweep.LocalCenter); _sweep.A0 = _sweep.A = angle; BroadPhase broadPhase = _world._contactManager._broadPhase; for (Fixture f = _fixtureList; f != null; f = f._next) { f.Synchronize(broadPhase, _xf, _xf); } _world._contactManager.FindNewContacts(); }