Пример #1
0
		protected override void RunLogic(TimeStep step)
		{
			Vector2D linear = -viewer.Body.State.Position.Linear;
			Vector2D velocity = -viewer.Body.State.Velocity.Linear;
			if (linear.X < 0)
			{
				linear.X = 0;
				velocity.X = 0;
			}
			else if (viewer.ScrollableWidth > 0 && linear.X > viewer.ScrollableWidth)
			{
				linear.X = viewer.ScrollableWidth;
				velocity.X = 0;
			}
			if (linear.Y < 0)
			{
				linear.Y = 0;
				velocity.Y = 0;
			}
			else if (viewer.ScrollableHeight > 0 && linear.Y > viewer.ScrollableHeight)
			{
				linear.Y = viewer.ScrollableHeight;
				velocity.Y = 0;
			}
			viewer.Body.State.Position.Linear = -linear;
			viewer.Body.State.Velocity.Linear = -velocity;
		}
Пример #2
0
 public CollisionEventArgs(TimeStep step,Body other, object customIntersectionInfo)
     : this(step, other)
 {
     this.customIntersectionInfo = customIntersectionInfo;
 }
Пример #3
0
 public CollisionEventArgs(TimeStep step, Body other, IContact contact)
     :this(step,other)
 {
     this.contact = contact;
 }
Пример #4
0
 private CollisionEventArgs(TimeStep step, Body other)
 {
     this.step = step;
     this.other = other;
 }
Пример #5
0
 public UpdatedEventArgs(TimeStep step) { this.step = step; }
Пример #6
0
 public void UpdatePosition(TimeStep step, ALVector2D extraVelocity)
 {
     UpdatePosition(step, ref extraVelocity);
 }
Пример #7
0
 public void UpdatePosition(TimeStep step, ref ALVector2D extraVelocity)
 {
     state.Position.Linear.X += (state.Velocity.Linear.X + extraVelocity.Linear.X) * step.Dt;
     state.Position.Linear.Y += (state.Velocity.Linear.Y + extraVelocity.Linear.Y) * step.Dt;
     state.Position.Angular  += (state.Velocity.Angular + extraVelocity.Angular) * step.Dt;
 }
Пример #8
0
 public void UpdatePosition(TimeStep step)
 {
     state.Position.Linear.X += state.Velocity.Linear.X * step.Dt;
     state.Position.Linear.Y += state.Velocity.Linear.Y * step.Dt;
     state.Position.Angular  += state.Velocity.Angular * step.Dt;
 }
Пример #9
0
 public CollisionEventArgs(TimeStep step, Body other, object customIntersectionInfo)
     : this(step, other)
 {
     this.customIntersectionInfo = customIntersectionInfo;
 }
Пример #10
0
 public CollisionEventArgs(TimeStep step, Body other, IContact contact)
     : this(step, other)
 {
     this.contact = contact;
 }
Пример #11
0
 private CollisionEventArgs(TimeStep step, Body other)
 {
     this.step  = step;
     this.other = other;
 }
Пример #12
0
		void ISequentialImpulsesJoint.PreStep(TimeStep step)
		{

			Scalar mass1Inv = body.Mass.MassInv;
			Scalar inertia1Inv = body.Mass.MomentOfInertiaInv;

			// Pre-compute anchors, mass matrix, and bias.

			Vector2D.TransformNormal(ref body.Matrices.ToWorld, ref localAnchor1, out r1);

			// deltaV = deltaV0 + K * impulse
			// invM = [(1/m1 + 1/m2) * eye(2) - skew(r1) * invI1 * skew(r1) - skew(r2) * invI2 * skew(r2)]
			//      = [1/m1+1/m2     0    ] + invI1 * [r1.y*r1.y -r1.x*r1.y] + invI2 * [r1.y*r1.y -r1.x*r1.y]
			//        [    0     1/m1+1/m2]           [-r1.x*r1.y r1.x*r1.x]           [-r1.x*r1.y r1.x*r1.x]

			Matrix2x2 K;
			K.m00 = mass1Inv;
			K.m11 = mass1Inv;

			K.m00 += inertia1Inv * r1.Y * r1.Y;
			K.m01 = -inertia1Inv * r1.X * r1.Y;
			K.m10 = -inertia1Inv * r1.X * r1.Y;
			K.m11 += inertia1Inv * r1.X * r1.X;

			K.m00 += softness;
			K.m11 += softness;

			Matrix2x2.Invert(ref K, out M);


			Vector2D dp;
			Vector2D.Add(ref body.State.Position.Linear, ref r1, out dp);
			Vector2D.Subtract(ref anchor, ref dp, out dp);

			if (!Scalar.IsPositiveInfinity(distanceTolerance) &&
			    dp.MagnitudeSq > distanceTolerance * distanceTolerance)
			{
				Lifetime.IsExpired = true;
			}

			if (solver.PositionCorrection)
			{
				//bias = -0.1f * dtInv * dp;
				Scalar flt = -biasFactor * step.DtInv;
				Vector2D.Multiply(ref dp, ref flt, out bias);
			}
			else
			{
				bias = Vector2D.Zero;
			}
			if (solver.WarmStarting)
			{
				PhysicsHelper.SubtractImpulse(
					ref body.State.Velocity, ref accumulatedImpulse,
					ref r1, ref mass1Inv, ref inertia1Inv);
			}
			else
			{
				accumulatedImpulse = Vector2D.Zero;
			}
			body.ApplyProxy();

		}