Пример #1
0
        private Maybe <EdgeData> TryFindValidEdge(Voxel a, Voxel b, bool horizontal)
        {
            var invalidResult = new Maybe <EdgeData>();

            if (InDifferentStates(a, b))
            {
                return(invalidResult);
            }
            var forward = PickDirection(a, b, out Vector2 from, out Vector2 to);

            var hit = FindValidWorldHitPoint(from, to);

            if (!hit.IsValid)
            {
                return(invalidResult);
            }

            var r          = hit.Item;
            var localPoint = gridTrans.InverseTransformPoint(r.point);

            var offset    = horizontal ? a.xEdge : a.yEdge;
            var newOffset = horizontal ? localPoint.x : localPoint.y;

            if (!EdgeValidToChange(offset, newOffset, forward))
            {
                return(invalidResult);
            }
            var edge = new EdgeData
            {
                EdgeOffset = newOffset,
                Normal     = r.normal
            };

            return(new Maybe <EdgeData>(edge));
        }
Пример #2
0
        public void SetVerticalEdge(EdgeData edge)
        {
            if (edge.EdgeOffset == float.MinValue)
            {
                return;
            }

            yEdge   = edge.EdgeOffset;
            yNormal = edge.Normal;
        }
Пример #3
0
        public void SetHorizontalEdge(EdgeData edge)
        {
            if (edge.EdgeOffset == float.MinValue)
            {
                return;
            }

            xEdge   = edge.EdgeOffset;
            xNormal = edge.Normal;
        }