Exemplo n.º 1
0
        public override void UpdateCachedBrushOrder()
        {
            Transform csgModelTransform = GetCSGModel().transform;

            List <int> reversePositions = new List <int>();

            Transform traversedTransform = transform;

            reversePositions.Add(traversedTransform.GetSiblingIndex());

            while (traversedTransform.parent != null && traversedTransform.parent != csgModelTransform)
            {
                traversedTransform = traversedTransform.parent;
                reversePositions.Add(traversedTransform.GetSiblingIndex());
            }

            BrushOrder brushOrder = new BrushOrder();
            int        count      = reversePositions.Count;

            brushOrder.Position = new int[count];
            for (int i = 0; i < count; i++)
            {
                brushOrder.Position[i] = reversePositions[count - 1 - i];
            }

            cachedBrushOrder = brushOrder;
        }
Exemplo n.º 2
0
        public int CompareTo(object other)
        {
            // If LHS of compare to is bigger than RHS then return 1
            // If RHS of compare to is bigger than LHS then return -1
            // If LHS of compare to is the same as RHS then return 0

            BrushOrder otherBrushOrder = (BrushOrder)other;

            int biggestLength = Position.Length;

            if (otherBrushOrder.Position.Length > biggestLength)
            {
                biggestLength = otherBrushOrder.Position.Length;
            }

            for (int i = 0; i < biggestLength; i++)
            {
                if (i > Position.Length - 1)
                {
                    return(-1);
                }
                else if (i > otherBrushOrder.Position.Length - 1)
                {
                    return(1);
                }
                else if (Position[i] > otherBrushOrder.Position[i])
                {
                    return(1);
                }
                else if (Position[i] < otherBrushOrder.Position[i])
                {
                    return(-1);
                }
            }
            return(0);
        }