protected override void DragPlaneExtraDo(ECoordPlane drag_plane)
    {
        Vector3 begin = m_Begin * dataSource.ScaleInverted;
        Vector3 end   = m_End * dataSource.ScaleInverted;

        if (m_Rot == 0 || m_Rot == 2)
        {
            if (drag_plane == ECoordPlane.XY)
            {
                Vector3 size = CalcuSizeXY(begin, end);

                end   = begin + size;
                m_End = new Vector3(end.x * dataSource.Scale,
                                    end.y * dataSource.Scale,
                                    end.z * dataSource.Scale);
            }
        }
        else if (m_Rot == 1 || m_Rot == 3)
        {
            if (drag_plane == ECoordPlane.ZY)
            {
                Vector3 size = CalcuSizeYZ(begin, end);

                end   = begin + size;
                m_End = new Vector3(end.x * dataSource.Scale,
                                    end.y * dataSource.Scale,
                                    end.z * dataSource.Scale);
            }
        }
    }
Esempio n. 2
0
    public static bool RayCastCoordPlane(Ray ray, ECoordPlane coordplane, float position, out RaycastHit rch)
    {
        rch = new RaycastHit();
        float epsilon = 0.0001F;

        ray.direction.Normalize();
        if (coordplane == ECoordPlane.XY)
        {
            if (Mathf.Abs(ray.direction.z) < epsilon)
            {
                return(false);
            }
            float enter = (position - ray.origin.z) / ray.direction.z;
            if (enter < 0.01f)
            {
                return(false);
            }
            rch.point    = ray.GetPoint(enter);
            rch.distance = enter;
            rch.normal   = ray.direction.z > 0 ? Vector3.back : Vector3.forward;
            return(true);
        }
        else if (coordplane == ECoordPlane.XZ)
        {
            if (Mathf.Abs(ray.direction.y) < epsilon)
            {
                return(false);
            }
            float enter = (position - ray.origin.y) / ray.direction.y;
            if (enter < 0.01f)
            {
                return(false);
            }
            rch.point    = ray.GetPoint(enter);
            rch.distance = enter;
            rch.normal   = ray.direction.y > 0 ? Vector3.down : Vector3.up;
            return(true);
        }
        else if (coordplane == ECoordPlane.ZY)
        {
            if (Mathf.Abs(ray.direction.x) < epsilon)
            {
                return(false);
            }
            float enter = (position - ray.origin.x) / ray.direction.x;
            if (enter < 0.01f)
            {
                return(false);
            }
            rch.point    = ray.GetPoint(enter);
            rch.distance = enter;
            rch.normal   = ray.direction.x > 0 ? Vector3.left : Vector3.right;
            return(true);
        }
        else
        {
            return(false);
        }
    }
 // Cancel this selecting action
 void ExitSelecting()
 {
     m_Begin.x    = -1; m_Begin.y = -1; m_Begin.z = -1;
     m_End.x      = -1; m_End.y = -1; m_End.z = -1;
     m_Coord      = ECoordPlane.XZ;
     m_PlanePos   = 0;
     m_NormalSign = 0;
     m_Selecting  = false;
 }
    protected override void AdjustHeightExtraDo(ECoordPlane drag_plane)
    {
        if (m_Rot == 0 || m_Rot == 2)
        {
            Vector3 begin = m_Begin * dataSource.ScaleInverted;
            Vector3 end   = m_End * dataSource.ScaleInverted;

            if (drag_plane == ECoordPlane.XZ)
            {
                Vector3 size = CalcuSizeY(begin, end, ECalcuHeight.XDir);

                end   = begin + size;
                m_End = new Vector3(end.x * dataSource.Scale,
                                    end.y * dataSource.Scale,
                                    end.z * dataSource.Scale);
            }
            else if (drag_plane == ECoordPlane.ZY)
            {
                Vector3 size = CalcuSizeX(begin, end, ECalcuHeight.XDir);

                end   = begin + size;
                m_End = new Vector3(end.x * dataSource.Scale,
                                    end.y * dataSource.Scale,
                                    end.z * dataSource.Scale);
            }
        }
        else if (m_Rot == 1 || m_Rot == 3)
        {
            Vector3 begin = m_Begin * dataSource.ScaleInverted;
            Vector3 end   = m_End * dataSource.ScaleInverted;

            if (drag_plane == ECoordPlane.XZ)
            {
                Vector3 size = CalcuSizeY(begin, end, ECalcuHeight.ZDir);

                end   = begin + size;
                m_End = new Vector3(end.x * dataSource.Scale,
                                    end.y * dataSource.Scale,
                                    end.z * dataSource.Scale);
            }
            else if (drag_plane == ECoordPlane.XY)
            {
                Vector3 size = CalcuSizeX(begin, end, ECalcuHeight.ZDir);

                end   = begin + size;
                m_End = new Vector3(end.x * dataSource.Scale,
                                    end.y * dataSource.Scale,
                                    end.z * dataSource.Scale);
            }
        }
    }
Esempio n. 5
0
    protected void Update()
    {
        if (dataSource == null)
        {
            return;
        }

        if (BSInput.s_MouseOnUI)
        {
            return;
        }

        if (_datasource == dataSource)
        {
            // Clear and rebuild;
            ClearSelection(null);
            _datasource = dataSource;
        }

        if (seletionBoxeRenderer != null)
        {
            seletionBoxeRenderer.m_Boxes = m_SelectionBoxes;
            seletionBoxeRenderer.scale   = dataSource.Scale;
            seletionBoxeRenderer.offset  = dataSource.Offset;
        }

        if (m_RecalcBoxes)
        {
            CalcBoxes();
            m_RecalcBoxes = false;
        }

        if (GameConfig.IsInVCE)
        {
            return;
        }

        // Depth
        if (!BSInput.s_Shift && Input.GetKeyDown(KeyCode.UpArrow))
        {
            Depth      = ++Depth >= maxDragSize ? maxDragSize : Depth;
            m_GUIAlpha = 5;
        }
        else if (!BSInput.s_Shift && Input.GetKeyDown(KeyCode.DownArrow))
        {
            Depth      = --Depth >= 1 ? Depth : 1;
            m_GUIAlpha = 5;
        }

        m_GUIAlpha = Mathf.Lerp(m_GUIAlpha, 0, 0.05f);



        // Drag Box
        //
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        if (!m_Selecting)
        {
            // Cancel
            if (BSInput.s_Cancel)
            {
                if (!canDo)
                {
                    return;
                }

                Dictionary <IntVector3, byte> old_seletion = new Dictionary <IntVector3, byte>(m_Selections);
                Cancel();
                Dictionary <IntVector3, byte> new_selection = new Dictionary <IntVector3, byte>(m_Selections);

                // For History
                if (old_seletion.Count != 0)
                {
                    BSSelectedBoxModify modify = new BSSelectedBoxModify(old_seletion, new_selection, this);
                    m_Action.AddModify(modify);

                    DoHistory();
                }

                return;
            }

            if (BSMath.RayCastDrawTarget(ray, dataSource, out m_Target, minvol, true, BuildingMan.Datas))
            {
                m_Drawing = true;

                m_Begin   = m_Target.snapto;
                _beginPos = m_Begin;
                m_End     = m_Begin;

                float vx = Mathf.Abs(m_Target.rch.normal.x);
                float vy = Mathf.Abs(m_Target.rch.normal.y);
                float vz = Mathf.Abs(m_Target.rch.normal.z);

                if (vx > 0.9f * m_Target.ds.Scale)
                {
                    m_Coord    = ECoordPlane.ZY;
                    m_PlanePos = m_Target.rch.point.x;
                }
                else if (vy > 0.9f * m_Target.ds.Scale)
                {
                    m_Coord    = ECoordPlane.XZ;
                    m_PlanePos = m_Target.rch.point.y;
                }
                else if (vz > 0.9f * m_Target.ds.Scale)
                {
                    m_Coord    = ECoordPlane.XY;
                    m_PlanePos = m_Target.rch.point.z;
                }

                if (Input.GetMouseButtonDown(0))
                {
                    if (canDo)
                    {
                        m_Selecting = true;
                    }
                }
            }
            else
            {
                m_Drawing = false;
            }
        }
        // Selecting
        else
        {
            m_Drawing = true;

            // Cancel
            if (BSInput.s_Cancel)
            {
                if (!canDo)
                {
                    return;
                }
                m_Selecting = false;
                m_Begin     = new Vector3(-10000, -10000, -10000);
                m_End       = new Vector3(-10000, -10000, -10000);
                return;
            }

            RaycastHit rch;
            if (BSMath.RayCastCoordPlane(ray, m_Coord, m_PlanePos, out rch))
            {
                Vector3 point = rch.point - dataSource.Offset;
                if (m_Coord == ECoordPlane.XY)
                {
                    // x componet
                    float x = 0;
                    m_Begin.x = CalcValue(point.x, _beginPos.x, out x);

                    // y componet
                    float y = 0;
                    m_Begin.y = CalcValue(point.y, _beginPos.y, out y);

                    m_End.x = x;
                    m_End.y = y;
                    m_End.z = Mathf.FloorToInt(point.z * dataSource.ScaleInverted) * dataSource.Scale;


                    if (m_Target.rch.normal.z > 0)
                    {
                        m_Begin.z = m_PlanePos - Depth * dataSource.Scale;
                    }
                    else
                    {
                        m_Begin.z = m_PlanePos + Depth * dataSource.Scale;
                    }

                    m_End = Clamp(m_Begin, m_End);
                }
                else if (m_Coord == ECoordPlane.XZ)
                {
                    // x componet
                    float x = 0;
                    m_Begin.x = CalcValue(point.x, _beginPos.x, out x);

                    // z componet
                    float z = 0;
                    m_Begin.z = CalcValue(point.z, _beginPos.z, out z);

                    m_End.x = x;
                    m_End.y = Mathf.FloorToInt(point.y * dataSource.ScaleInverted) * dataSource.Scale;
                    m_End.z = z;

                    if (m_Target.rch.normal.y > 0)
                    {
                        m_Begin.y = m_PlanePos - Depth * dataSource.Scale;
                    }
                    else
                    {
                        m_Begin.y = m_PlanePos + Depth * dataSource.Scale;
                    }

                    m_End = Clamp(m_Begin, m_End);
                }
                else if (m_Coord == ECoordPlane.ZY)
                {
                    // y componet
                    float y = 0;
                    m_Begin.y = CalcValue(point.y, _beginPos.y, out y);

                    // z componet
                    float z = 0;
                    m_Begin.z = CalcValue(point.z, _beginPos.z, out z);

                    m_End.x = Mathf.FloorToInt(point.x * dataSource.ScaleInverted) * dataSource.Scale;
                    m_End.y = y;
                    m_End.z = z;

                    if (m_Target.rch.normal.x > 0)
                    {
                        m_Begin.x = m_PlanePos - Depth * dataSource.Scale;
                    }
                    else
                    {
                        m_Begin.x = m_PlanePos + Depth * dataSource.Scale;
                    }

                    m_End = Clamp(m_Begin, m_End);
                }
            }

            // In Valid area ?
            if (m_PrevDS != null && m_PrevDS == dataSource)
            {
                if (m_Selections.Count != 0)
                {
                    BSTools.SelBox box = new BSTools.SelBox();
                    box.m_Box.xMin = (short)Mathf.FloorToInt(Mathf.Min(m_Begin.x, m_End.x) * dataSource.ScaleInverted);
                    box.m_Box.yMin = (short)Mathf.FloorToInt(Mathf.Min(m_Begin.y, m_End.y) * dataSource.ScaleInverted);
                    box.m_Box.zMin = (short)Mathf.FloorToInt(Mathf.Min(m_Begin.z, m_End.z) * dataSource.ScaleInverted);
                    box.m_Box.xMax = (short)Mathf.FloorToInt(Mathf.Max(m_Begin.x, m_End.x) * dataSource.ScaleInverted);
                    box.m_Box.yMax = (short)Mathf.FloorToInt(Mathf.Max(m_Begin.y, m_End.y) * dataSource.ScaleInverted);
                    box.m_Box.zMax = (short)Mathf.FloorToInt(Mathf.Max(m_Begin.z, m_End.z) * dataSource.ScaleInverted);

                    // Add current box to list temporarily
                    m_SelectionBoxes.Add(box);
                    BSTools.IntBox bound = BSTools.SelBox.CalculateBound(m_SelectionBoxes);

                    Vector3 size = new Vector3(bound.xMax - bound.xMin, bound.yMax - bound.yMin, bound.zMax - bound.zMin);

                    if (size.x > maxSelectBoxSize.x || size.y > maxSelectBoxSize.y || size.z > maxSelectBoxSize.z)
                    {
                        m_IsValidBox = false;
                    }
                    else
                    {
                        m_IsValidBox = true;
                    }

                    // revert the list
                    m_SelectionBoxes.RemoveAt(m_SelectionBoxes.Count - 1);
                }
                else
                {
                    m_IsValidBox = true;
                }
            }
            else
            {
                m_IsValidBox = true;
            }

            if (Input.GetMouseButtonUp(0))
            {
                if (!canDo)
                {
                    return;
                }

//				bool result = false;

                if (m_IsValidBox)
                {
                    // Add
                    if (m_PrevDS == dataSource)
                    {
                        if (BSInput.s_Shift)
                        {
                            if (m_PrevDS == dataSource)
                            {
                                /*result = */ CalcSelection(0);
                            }
                        }
                        // Substract
                        else if (BSInput.s_Alt)
                        {
                            /*result = */ CalcSelection(1);
                        }
                        // Cross
                        else if (BSInput.s_Control)
                        {
                            /*result = */ CalcSelection(2);
                        }
                        else
                        {
                            ClearSelection(m_Action);
                            /*result = */ CalcSelection(0);
                        }

                        m_PrevDS = dataSource;
                    }
                    else
                    {
                        ClearSelection(m_Action);
                        /*result = */ CalcSelection(0);

                        m_PrevDS = dataSource;
                    }
                }

                m_Selecting = false;
                ResetValue();
            }
        }
        // Other Ajust
        if (AfterSelectionUpdate())
        {
            DoHistory();
        }
    }
Esempio n. 6
0
    protected void Update()
    {
        if (dataSource == null)
        {
            return;
        }

        if (pattern == null)
        {
            return;
        }

        if (!ExtraAdjust())
        {
            return;
        }

        if (GameConfig.IsInVCE)
        {
            return;
        }

        gizmoCube.m_VoxelSize = dataSource.Scale;

        if (m_Phase == EPhase.Free)
        {
            if (BSInput.s_MouseOnUI)
            {
                gizmoCube.gameObject.SetActive(false);
                return;
            }

            if (BSInput.s_Cancel)
            {
                ResetDrawing();
            }

            // Ray cast voxel
            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

            bool ignoreDiagonal = (mode == EBSBrushMode.Add);
            bool cast           = BSMath.RayCastDrawTarget(ray, dataSource, out m_Target, minvol, ignoreDiagonal, BuildingMan.Datas);
            if (cast)
            {
                Vector3 cursor = Vector3.zero;

                if (mode == EBSBrushMode.Add)
                {
                    cursor = CalcCursor(m_Target, dataSource, pattern.size);

                    m_Cursor = m_Target.rch.point;
                }
                else if (mode == EBSBrushMode.Subtract)
                {
                    cursor = CalcSnapto(m_Target, dataSource, pattern);

                    m_Cursor = m_Target.rch.point;
                }
                m_GizmoCursor = cursor;

                _drawGL            = true;
                gizmoCube.CubeSize = new IntVector3(pattern.size, pattern.size, pattern.size);
                gizmoCube.gameObject.SetActive(true);
                gizmoCube.transform.position = cursor + dataSource.Offset;

                UpdateGizmoTrigger();

                float   offset = pattern.size * dataSource.Scale;
                Vector3 begin  = cursor;
                Vector3 end    = begin + new Vector3(offset, offset, offset);
                _glCenter   = cursor + new Vector3(offset, offset, offset) * 0.5f + dataSource.Offset;
                _glCenter.y = begin.y;

                // Click mouse and change phase
                if (Input.GetMouseButtonDown(0))
                {
                    m_Begin   = begin;
                    _beginPos = begin;
                    m_End     = end;

                    m_Phase       = EPhase.DragPlane;
                    _prevMousePos = Input.mousePosition;
                }
            }
            else
            {
                ResetDrawing();
            }

            // Switch the panel
            if (Input.GetKeyDown(KeyCode.G))
            {
                if (DragPlane == ECoordPlane.XZ)
                {
                    DragPlane = ECoordPlane.ZY;
                }
                else if (DragPlane == ECoordPlane.ZY)
                {
                    DragPlane = ECoordPlane.XY;
                }
                else if (DragPlane == ECoordPlane.XY)
                {
                    DragPlane = ECoordPlane.XZ;
                }

                Debug.Log("Switch the drag reference plane : " + DragPlane.ToString());
            }
        }
        else if (m_Phase == EPhase.DragPlane)
        {
            if (BSInput.s_Cancel)
            {
                ResetDrawing();
                return;
            }

            RaycastHit rch;
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);

            float position = 0;

            if (DragPlane == ECoordPlane.XY)
            {
                position = m_Cursor.z;
            }
            else if (DragPlane == ECoordPlane.XZ)
            {
                position = m_Cursor.y;
            }
            else if (DragPlane == ECoordPlane.ZY)
            {
                position = m_Cursor.x;
            }

            if (BSMath.RayCastCoordPlane(ray, DragPlane, position, out rch))
            {
                m_PointBeforeAdjustHeight = rch.point;
                if (!Vector3.Equals(_prevMousePos, Input.mousePosition))
                {
                    Vector3 point = rch.point - dataSource.Offset;


                    if (DragPlane == ECoordPlane.XZ)
                    {
                        // x
                        float x = 0;
                        m_Begin.x = CalcValue(point.x, _beginPos.x, out x);

                        // z
                        float z = 0;
                        m_Begin.z = CalcValue(point.z, _beginPos.z, out z);

                        m_End = new Vector3(x, _beginPos.y + (pattern.size) * dataSource.Scale, z);
                        m_End = Clamp(m_Begin, m_End);
                    }
                    else if (DragPlane == ECoordPlane.XY)
                    {
                        // x
                        float x = 0;
                        m_Begin.x = CalcValue(point.x, _beginPos.x, out x);

                        // y
                        float y = 0;
                        m_Begin.y = CalcValue(point.y, _beginPos.y, out y);

                        m_End = new Vector3(x, y, _beginPos.z + (pattern.size) * dataSource.Scale);
                        m_End = Clamp(m_Begin, m_End);
                    }
                    else if (DragPlane == ECoordPlane.ZY)
                    {
                        // y
                        float y = 0;
                        m_Begin.y = CalcValue(point.y, _beginPos.y, out y);

                        // z
                        float z = 0;
                        m_Begin.z = CalcValue(point.z, _beginPos.z, out z);

                        m_End = new Vector3(_beginPos.x + (pattern.size) * dataSource.Scale, y, z);
                        m_End = Clamp(m_Begin, m_End);
                    }

                    // other phase Drag plane
                    DragPlaneExtraDo(DragPlane);

                    gizmoCube.transform.position = Min + dataSource.Offset;

                    gizmoCube.CubeSize = new IntVector3((int)Size.x, (int)Size.y, (int)Size.z);

                    UpdateGizmoTrigger();
                }



                // Click mouse and change phase
                if (Input.GetMouseButtonUp(0))
                {
                    m_Phase       = EPhase.AdjustHeight;
                    _prevMousePos = new Vector3(-100, -100, -100);
                }
            }
        }
        else if (m_Phase == EPhase.AdjustHeight)
        {
            if (BSInput.s_Cancel)
            {
                ResetDrawing();
                return;
            }

            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

//			ECoordAxis axis = ECoordAxis.Y;
            if (DragPlane == ECoordPlane.XZ)
            {
                float adjustHeight = m_PointBeforeAdjustHeight.y;
                BSMath.RayAdjustHeight(ray, ECoordAxis.Y, m_PointBeforeAdjustHeight, out adjustHeight);

                // y
                float y = 0;
                m_Begin.y = CalcValue(adjustHeight, _beginPos.y, out y);
                m_End.y   = y + m_EndOffset.y;
            }
            else if (DragPlane == ECoordPlane.XY)
            {
                float adjustHeight = m_PointBeforeAdjustHeight.z;
                BSMath.RayAdjustHeight(ray, ECoordAxis.Z, m_PointBeforeAdjustHeight, out adjustHeight);


                // z
                float z = 0;
                m_Begin.z = CalcValue(adjustHeight, _beginPos.z, out z);
                m_End.z   = z + m_EndOffset.z;
            }
            else if (DragPlane == ECoordPlane.ZY)
            {
                float adjustHeight = m_PointBeforeAdjustHeight.x;
                BSMath.RayAdjustHeight(ray, ECoordAxis.X, m_PointBeforeAdjustHeight, out adjustHeight);

                // x
                float x = 0;
                m_Begin.x = CalcValue(adjustHeight, _beginPos.x, out x);

                m_End.x = x + m_EndOffset.x;
            }

            m_End = Clamp(m_Begin, m_End);

            // Other adjustHeight
            AdjustHeightExtraDo(DragPlane);


            gizmoCube.transform.position = Min + dataSource.Offset;

            gizmoCube.CubeSize = new IntVector3((int)Size.x, (int)Size.y, (int)Size.z);

            UpdateGizmoTrigger();

            // Click mouse and change phase
            //if (Input.GetMouseButtonDown(0))
            if (PeInput.Get(PeInput.LogicFunction.Build))
            {
                Do();
                m_Phase = EPhase.Free;
            }
        }


        AfterDo();
    }
Esempio n. 7
0
 protected virtual void DragPlaneExtraDo(ECoordPlane drag_plane)
 {
 }
Esempio n. 8
0
 protected virtual void AdjustHeightExtraDo(ECoordPlane drag_plane)
 {
 }
    public override void MainMethod()
    {
        if (VCEInput.s_Increase && !VCEInput.s_Shift)
        {
            if (m_Depth < 300)
            {
                m_Depth++;
            }
            m_GUIAlpha = 5;
        }
        else if (VCEInput.s_Decrease && !VCEInput.s_Shift)
        {
            if (m_Depth > 1)
            {
                m_Depth--;
            }
            m_GUIAlpha = 5;
        }
        //
        // Selecting, mouse dragging
        //
        if (m_Selecting)
        {
            if (VCEInput.s_Cancel)
            {
                ExitSelecting();
                return;
            }
            RaycastHit rch;

            // ray cast coord plane
            if (VCEMath.RayCastCoordPlane(VCEInput.s_PickRay, m_Coord, m_PlanePos, out rch))
            {
                m_End.x = Mathf.FloorToInt(rch.point.x);
                m_End.y = Mathf.FloorToInt(rch.point.y);
                m_End.z = Mathf.FloorToInt(rch.point.z);
                switch (m_Coord)
                {
                case ECoordPlane.XY: m_End.z = m_Begin.z + (m_Depth - 1) * m_NormalSign; break;

                case ECoordPlane.XZ: m_End.y = m_Begin.y == 0 && VCEditor.s_Scene.m_IsoData.GetVoxel(VCIsoData.IPosToKey(m_Begin)).Volume < 128 ?
                                               VCEditor.s_Scene.m_Setting.m_EditorSize.y - 1 :
                                               m_Begin.y + (m_Depth - 1) * m_NormalSign;
                    break;

                case ECoordPlane.ZY: m_End.x = m_Begin.x + (m_Depth - 1) * m_NormalSign; break;

                default: ExitSelecting(); return;
                }
            }
            else
            {
                ExitSelecting();
                return;
            }
            m_Iso.ClampPointI(m_Begin);
            m_Iso.ClampPointI(m_End);

            // Submit this selecting action !
            if (Input.GetMouseButtonUp(0) && m_Selecting)
            {
                Submit();
                m_Selecting  = false;
                m_NeedUpdate = true;
            }
        }         // End selecting

        //
        // Free mouse, prepare to select
        //
        else
        {
            // Mouse not on GUI
            if (!VCEInput.s_MouseOnUI)
            {
                // Click left mouse button
                if (Input.GetMouseButtonDown(0))
                {
                    // has draw target
                    if (m_Parent.m_Target.snapto != null && m_Parent.m_Target.cursor != null)
                    {
                        VCEMath.DrawTarget dtar = m_Parent.m_Target;
                        // snapto has voxel
                        if (m_Iso.GetVoxel(VCIsoData.IPosToKey(dtar.snapto)).Volume > 0)
                        {
                            m_Begin.x = dtar.snapto.x;
                            m_Begin.y = dtar.snapto.y;
                            m_Begin.z = dtar.snapto.z;
                        }
                        // snapto don't has voxel
                        else
                        {
                            m_Begin.x       = dtar.cursor.x;
                            m_Begin.y       = dtar.cursor.y;
                            m_Begin.z       = dtar.cursor.z;
                            dtar.rch.normal = -dtar.rch.normal;
                        }

                        // Assgin end
                        m_End.x = m_Begin.x;
                        m_End.y = m_Begin.y;
                        m_End.z = m_Begin.z;
                        // Assgin coord and position
                        // zy plane
                        if (Mathf.Abs(dtar.rch.normal.x) > 0.9f)
                        {
                            m_Coord      = ECoordPlane.ZY;
                            m_PlanePos   = dtar.rch.point.x;
                            m_Selecting  = true;
                            m_NormalSign = -Mathf.RoundToInt(Mathf.Sign(dtar.rch.normal.x));
                        }
                        // xz plane
                        else if (Mathf.Abs(dtar.rch.normal.y) > 0.9f)
                        {
                            m_Coord      = ECoordPlane.XZ;
                            m_PlanePos   = dtar.rch.point.y;
                            m_Selecting  = true;
                            m_NormalSign = -Mathf.RoundToInt(Mathf.Sign(dtar.rch.normal.y));
                        }
                        // xy plane
                        else if (Mathf.Abs(dtar.rch.normal.z) > 0.9f)
                        {
                            m_Coord      = ECoordPlane.XY;
                            m_PlanePos   = dtar.rch.point.z;
                            m_Selecting  = true;
                            m_NormalSign = -Mathf.RoundToInt(Mathf.Sign(dtar.rch.normal.z));
                        }
                        // it's impossible !!!
                        else
                        {
                            Debug.LogError("It's impossible !!");
                            ExitSelecting();
                        }
                    }
                    // Don't have draw target
                    else
                    {
                        // Select
                        if (!VCEInput.s_Shift && !VCEInput.s_Alt && !VCEInput.s_Control)
                        {
                            m_Selection.Clear();
                        }
                        m_NeedUpdate = true;
                    }
                }
            }

            if (m_MaterialSelectChange)
            {
                Submit();
                m_Selecting  = false;
                m_NeedUpdate = true;
            }
        }         // End free mouse
    }