コード例 #1
0
        public void ProjectParentVelocityOnLastMoveCollisionTangent(float minimumVectorLengthSquared)
        {
#if FRB_MDX
            if (LastMoveCollisionReposition.LengthSq() > minimumVectorLengthSquared &&
#else
            if (LastMoveCollisionReposition.LengthSquared() > minimumVectorLengthSquared &&
#endif
                Vector2.Dot(
                    new Vector2(TopParent.Velocity.X, TopParent.Velocity.Y), LastMoveCollisionReposition) < 0)
            {
                Vector2 collisionAdjustmentNormalized = LastMoveCollisionReposition;
                collisionAdjustmentNormalized.Normalize();
                float temporaryFloat = collisionAdjustmentNormalized.X;
                collisionAdjustmentNormalized.X = -collisionAdjustmentNormalized.Y;
                collisionAdjustmentNormalized.Y = temporaryFloat;

                float length = Vector2.Dot(
                    new Vector2(TopParent.Velocity.X, TopParent.Velocity.Y), collisionAdjustmentNormalized);
                TopParent.Velocity.X = collisionAdjustmentNormalized.X * length;
                TopParent.Velocity.Y = collisionAdjustmentNormalized.Y * length;
            }
        }