示例#1
0
        protected override void Update()
        {
            base.Update();

            // Move the rectangle to cover the hitobjects
            var topLeft     = new Vector2(float.MaxValue, float.MaxValue);
            var bottomRight = new Vector2(float.MinValue, float.MinValue);

            topLeft     = Vector2Extensions.ComponentMin(topLeft, Parent.ToLocalSpace(DrawableObject.ScreenSpaceDrawQuad.TopLeft));
            bottomRight = Vector2Extensions.ComponentMax(bottomRight, Parent.ToLocalSpace(DrawableObject.ScreenSpaceDrawQuad.BottomRight));

            Size     = bottomRight - topLeft;
            Position = topLeft;
        }
示例#2
0
        /// <summary>
        /// Returns a quad surrounding the provided points.
        /// </summary>
        /// <param name="points">The points to calculate a quad for.</param>
        protected static Quad GetSurroundingQuad(IEnumerable <Vector2> points)
        {
            if (!points.Any())
            {
                return(new Quad());
            }

            Vector2 minPosition = new Vector2(float.MaxValue, float.MaxValue);
            Vector2 maxPosition = new Vector2(float.MinValue, float.MinValue);

            // Go through all hitobjects to make sure they would remain in the bounds of the editor after movement, before any movement is attempted
            foreach (var p in points)
            {
                minPosition = Vector2Extensions.ComponentMin(minPosition, p);
                maxPosition = Vector2Extensions.ComponentMax(maxPosition, p);
            }

            Vector2 size = maxPosition - minPosition;

            return(new Quad(minPosition.X, minPosition.Y, size.X, size.Y));
        }