Exemple #1
0
        /// <summary> Notification that we've ended an Update frame/iteration</summary>
        public virtual void EndFrame()
        {
            if (!CanRest)
            {
                return ;
            }

            if ((hitCount == 0) || (touchingCount != touching.Size()))
            {
                isResting = false;
                SetMass(originalMass);
                touchingStatic = false;
                touchingCount = touching.Size();
            }
            else
            {
                newPosition = new Vector2f(GetPosition());
                if (!hitByAnother)
                {
                    if (true && (newPosition.DistanceSquared(oldPosition) <= positionTolerance) && (velocity.LengthSquared() <= 0.001f) && (biasedVelocity.LengthSquared() <= 0.001f) && (System.Math.Abs(angularVelocity) <= rotationTolerance))
                    {
                        if (!touchingStatic)
                        {
                            touchingStatic = IsTouchingStatic(new List<Body>());
                        }
                        if (touchingStatic)
                        {
                            isResting = true;
                            SetMass(INFINITE_MASS);
                            velocity.Reconfigure(0.0f, 0.0f);
                            biasedVelocity.Reconfigure(0, 0);
                            angularVelocity = 0.0f;
                            biasedAngularVelocity = 0;
                            force.Reconfigure(0.0f, 0.0f);
                            torque = 0.0f;
                        }
                    }
                }
                else
                {
                    isResting = false;
                    SetMass(originalMass);
                }

                if ((newPosition.DistanceSquared(oldPosition) > positionTolerance) && (System.Math.Abs(angularVelocity) > rotationTolerance))
                {
                    touchingStatic = false;
                }
            }
        }