Box2DX.Dynamics.Controllers.GravityController.Step C# (CSharp) Метод

Step() публичный Метод

public Step ( TimeStep step ) : void
step TimeStep
Результат void
        public override void Step(TimeStep step)
        {
            //B2_NOT_USED(step);
            if (InvSqr)
            {
                for (ControllerEdge i = _bodyList; i != null; i = i.nextBody)
                {
                    Body body1 = i.body;
                    for (ControllerEdge j = _bodyList; j != i; j = j.nextBody)
                    {
                        Body body2 = j.body;
                        Vector2 d = body2.GetWorldCenter() - body1.GetWorldCenter();
                        float r2 = d.sqrMagnitude;
                        if (r2 < Settings.FLT_EPSILON)
                            continue;

                        Vector2 f = G / r2 / Math.Sqrt(r2) * body1.GetMass() * body2.GetMass() * d;
                        body1.ApplyForce(f, body1.GetWorldCenter());
                        body2.ApplyForce(-1.0f * f, body2.GetWorldCenter());
                    }
                }
            }
            else
            {
                for (ControllerEdge i = _bodyList; i != null; i = i.nextBody)
                {
                    Body body1 = i.body;
                    for (ControllerEdge j = _bodyList; j != i; j = j.nextBody)
                    {
                        Body body2 = j.body;
                        Vector2 d = body2.GetWorldCenter() - body1.GetWorldCenter();
                        float r2 = d.sqrMagnitude;
                        if (r2 < Settings.FLT_EPSILON)
                            continue;
                        Vector2 f = G / r2 * body1.GetMass() * body2.GetMass() * d;
                        body1.ApplyForce(f, body1.GetWorldCenter());
                        body2.ApplyForce(-1.0f * f, body2.GetWorldCenter());
                    }
                }
            }
        }
GravityController