Ejemplo n.º 1
0
            protected override Bounds OnHandleChanged(
                PrimitiveBoundsHandle.HandleDirection handle,
                Bounds boundsOnClick,
                Bounds newBounds)
            {
                // Enforce minimum size for bounds
                // And ensure it is property quantized
                switch (handle)
                {
                case HandleDirection.NegativeX:
                case HandleDirection.NegativeY:
                case HandleDirection.NegativeZ:
                    newBounds.min = Vector3.Min(newBounds.min, newBounds.max - generator.tileSize);
                    newBounds.min = Round(newBounds.min - newBounds.max) + newBounds.max;
                    break;

                case HandleDirection.PositiveX:
                case HandleDirection.PositiveY:
                case HandleDirection.PositiveZ:
                    newBounds.max = Vector3.Max(newBounds.max, newBounds.min + generator.tileSize);
                    newBounds.max = Round(newBounds.max - newBounds.min) + newBounds.min;
                    break;
                }
                Undo.RecordObject(generator, ChangeBounds);

                generator.bounds = newBounds;

                return(newBounds);
            }
Ejemplo n.º 2
0
        protected override Bounds OnHandleChanged(PrimitiveBoundsHandle.HandleDirection handle, Bounds boundsOnClick, Bounds newBounds)
        {
            Vector3 max = newBounds.max;
            Vector3 min = newBounds.min;
            int     num = 0;

            switch (handle)
            {
            case PrimitiveBoundsHandle.HandleDirection.PositiveY:
            case PrimitiveBoundsHandle.HandleDirection.NegativeY:
                num = 1;
                break;

            case PrimitiveBoundsHandle.HandleDirection.PositiveZ:
            case PrimitiveBoundsHandle.HandleDirection.NegativeZ:
                num = 2;
                break;
            }
            float num2 = 0.5f * (max[num] - min[num]);

            for (int i = 0; i < 3; i++)
            {
                if (i != num)
                {
                    min[i] = base.center[i] - num2;
                    max[i] = base.center[i] + num2;
                }
            }
            return(new Bounds((max + min) * 0.5f, max - min));
        }
Ejemplo n.º 3
0
        protected override Bounds OnHandleChanged(PrimitiveBoundsHandle.HandleDirection handle, Bounds boundsOnClick, Bounds newBounds)
        {
            int num = 0;

            switch (handle)
            {
            case PrimitiveBoundsHandle.HandleDirection.PositiveY:
            case PrimitiveBoundsHandle.HandleDirection.NegativeY:
                num = 1;
                break;

            case PrimitiveBoundsHandle.HandleDirection.PositiveZ:
            case PrimitiveBoundsHandle.HandleDirection.NegativeZ:
                num = 2;
                break;
            }
            Vector3 max = newBounds.max;
            Vector3 min = newBounds.min;

            if (num == this.m_HeightAxis)
            {
                int index;
                this.GetRadiusAxis(out index);
                float num2 = max[index] - min[index];
                float num3 = max[this.m_HeightAxis] - min[this.m_HeightAxis];
                if (num3 < num2)
                {
                    if (handle == PrimitiveBoundsHandle.HandleDirection.PositiveX || handle == PrimitiveBoundsHandle.HandleDirection.PositiveY || handle == PrimitiveBoundsHandle.HandleDirection.PositiveZ)
                    {
                        max[this.m_HeightAxis] = min[this.m_HeightAxis] + num2;
                    }
                    else
                    {
                        min[this.m_HeightAxis] = max[this.m_HeightAxis] - num2;
                    }
                }
            }
            else
            {
                max[this.m_HeightAxis] = boundsOnClick.center[this.m_HeightAxis] + 0.5f * boundsOnClick.size[this.m_HeightAxis];
                min[this.m_HeightAxis] = boundsOnClick.center[this.m_HeightAxis] - 0.5f * boundsOnClick.size[this.m_HeightAxis];
                float num4 = 0.5f * (max[num] - min[num]);
                float a    = 0.5f * (max[this.m_HeightAxis] - min[this.m_HeightAxis]);
                for (int i = 0; i < 3; i++)
                {
                    if (i != num)
                    {
                        float num5 = (i != this.m_HeightAxis) ? num4 : Mathf.Max(a, num4);
                        min[i] = base.center[i] - num5;
                        max[i] = base.center[i] + num5;
                    }
                }
            }
            return(new Bounds((max + min) * 0.5f, max - min));
        }
Ejemplo n.º 4
0
 protected virtual Bounds OnHandleChanged(PrimitiveBoundsHandle.HandleDirection handle, Bounds boundsOnClick, Bounds newBounds)
 {
     return(newBounds);
 }