コード例 #1
0
        public override bool IsIntersectingLine(Vector3 begin, Vector3 end)
        {
            Vector3 tl, tr, bl, br;

            BoxBounds(out tl, out tr, out bl, out br);
            if (GenerationUtility.PointInBox(begin, tl, tr, bl, br) || GenerationUtility.PointInBox(end, tl, tr, bl, br))
            {
                return(true);
            }

            return(GenerationUtility.CheckBoxLineIntersection(begin, end, tl, tr, bl, br));
        }
コード例 #2
0
        public bool IsIntersectingLine(Vector3 begin, Vector3 end)
        {
            Vector3 tl, tr, bl, br;

            GenerationUtility.BoxBounds(this.Start.Position, this.End.Position, this.Width, out tl, out tr, out bl, out br);

            if (GenerationUtility.PointInBox(begin, tl, tr, bl, br) || GenerationUtility.PointInBox(end, tl, tr, bl, br))
            {
                return(true);
            }

            return(GenerationUtility.CheckBoxLineIntersection(begin, end, tl, tr, bl, br));
        }
コード例 #3
0
        public void FillBox(Vector3 tl, Vector3 tr, Vector3 bl, Vector3 br)
        {
            if (this.Reserved)
            {
                return;
            }

            bool topLeft     = GenerationUtility.PointInBox(this.TopLeft.Position, tl, tr, bl, br);
            bool topRight    = GenerationUtility.PointInBox(this.TopRight.Position, tl, tr, bl, br);
            bool bottomLeft  = GenerationUtility.PointInBox(this.BottomLeft.Position, tl, tr, bl, br);
            bool bottomRight = GenerationUtility.PointInBox(this.BottomRight.Position, tl, tr, bl, br);

            if (topLeft)
            {
                this.TopLeft.Filled = true;
            }
            if (topRight)
            {
                this.TopRight.Filled = true;
            }
            if (bottomLeft)
            {
                this.BottomLeft.Filled = true;
            }
            if (bottomRight)
            {
                this.BottomRight.Filled = true;
            }

            if (topLeft || topRight || bottomLeft || bottomRight)
            {
                this.Filled = true;
            }

            if (!this.Filled)
            {
                return; // square is empty so work is done
            }
            if (GenerationUtility.CheckBoxLineIntersection(this.TopLeft.Position, this.TopRight.Position, tl, tr, bl, br))
            {
                this.Top.Filled = true;
                this.Top.SetPosition(
                    GenerationUtility.BoxLineIntersection(this.TopLeft.Position, this.TopRight.Position, tl, tr, bl, br));
            }

            if (GenerationUtility.CheckBoxLineIntersection(this.BottomLeft.Position, this.BottomRight.Position, tl, tr, bl, br))
            {
                this.Bottom.Filled = true;
                this.Bottom.SetPosition(
                    GenerationUtility.BoxLineIntersection(this.BottomLeft.Position, this.BottomRight.Position, tl, tr, bl, br));
            }

            if (GenerationUtility.CheckBoxLineIntersection(this.TopLeft.Position, this.BottomLeft.Position, tl, tr, bl, br))
            {
                this.Left.Filled = true;
                this.Left.SetPosition(
                    GenerationUtility.BoxLineIntersection(this.TopLeft.Position, this.BottomLeft.Position, tl, tr, bl, br));
            }

            if (GenerationUtility.CheckBoxLineIntersection(this.TopRight.Position, this.BottomRight.Position, tl, tr, bl, br))
            {
                this.Right.Filled = true;
                this.Right.SetPosition(
                    GenerationUtility.BoxLineIntersection(this.TopRight.Position, this.BottomRight.Position, tl, tr, bl, br));
            }
        }