Esempio n. 1
0
 private void OnMoveHandle(LowPolyPointHandle handle)
 {
     if (handle != null)
     {
         UpdatePosition(handle.LastPosition);
     }
 }
Esempio n. 2
0
 private void OnDestroyHandle(LowPolyPointHandle handle)
 {
     if (handle != null)
     {
         lps.DeletePosition(handle.transform.position);
     }
 }
Esempio n. 3
0
 public void RemoveHandleListenners(LowPolyPointHandle handle)
 {
     if (handle != null)
     {
         handle.RemoveMoveAction(OnMoveHandle);
         handle.RemoveDestroyAction(OnDestroyHandle);
         handle.RemoveFusionAction(OnFusionHandle);
     }
 }
Esempio n. 4
0
 public void AddHandleListenners(LowPolyPointHandle handle)
 {
     if (handle != null)
     {
         handle.AddMoveAction(OnMoveHandle);
         handle.AddDestroyAction(OnDestroyHandle);
         handle.AddFusionAction(OnFusionHandle);
     }
 }
Esempio n. 5
0
 private void RemovePointListeners(LowPolyPointHandle pt)
 {
     if (pt != null)
     {
         pt.RemoveMoveAction(OnMovePoint);
         pt.RemoveFusionAction(OnFusionPoint);
         pt.RemoveDestroyAction(OnDestroyPoint);
     }
 }
Esempio n. 6
0
 private void AddPointListeners(LowPolyPointHandle pt)
 {
     if (pt != null)
     {
         pt.AddMoveAction(OnMovePoint);
         pt.AddFusionAction(OnFusionPoint);
         pt.AddDestroyAction(OnDestroyPoint);
     }
 }
Esempio n. 7
0
 private void DragHandles(bool drag)
 {
     foreach (GameObject go in Selection.gameObjects)
     {
         LowPolyPointHandle handle = go.GetComponent <LowPolyPointHandle>();
         if (handle != null)
         {
             handle.Drag = drag;
         }
     }
 }
Esempio n. 8
0
    public void OnFusionHandle(LowPolyPointHandle replaced)
    {
        int replacedIndex = pointHandles.IndexOf(replaced);

        if (replacedIndex != -1 && replaced.CloseHandle != null)
        {
            pointHandles[replacedIndex] = replaced.CloseHandle;
            UpdatePositions();
            UpdateSegmentHandles();
        }
    }
Esempio n. 9
0
    public static LowPolySegmentHandle InstantiateHandle(LowPolyPointHandle A, LowPolyPointHandle B, string handleName = "segmentHandle")
    {
        if (A == null || B == null)
        {
            return(null);
        }

        LowPolySegmentHandle newHandle = new GameObject().AddComponent <LowPolySegmentHandle>();

        newHandle.name = handleName;
        newHandle.SetPoints(A, B);

        return(newHandle);
    }
Esempio n. 10
0
    public void UpdatePointHandles()
    {
        CleanUpPointHandles();

        int posCount = lps.PositionCount;
        List <LowPolyPointHandle> obsoleteHandles = (pointHandles == null) ? null : new List <LowPolyPointHandle>(pointHandles);
        List <LowPolyPointHandle> newHandles      = new List <LowPolyPointHandle>(new LowPolyPointHandle[posCount]);
        List <LowPolyPointHandle> allHandles      = new List <LowPolyPointHandle>(GameObject.FindObjectsOfType <LowPolyPointHandle>());

        for (int i = 0; i < posCount; i++)
        {
            Vector3 wPos = lps.GetPosition(i);

            LowPolyPointHandle handle = null;

            if (pointHandles != null)
            {
                handle = pointHandles.Find(h => h.transform.position == wPos);
            }

            if (handle != null)
            {
                obsoleteHandles.Remove(handle);
            }
            else
            {
                handle = allHandles.Find(h => h.transform.position == wPos);
                if (handle == null)
                {
                    handle = LowPolyPointHandle.InstantiateHandle(wPos, "PointHandle_" + allHandles.Count);
                    allHandles.Add(handle);
                }
                AddHandleListenners(handle);
            }

            newHandles[i] = handle;
        }

        if (obsoleteHandles != null)
        {
            foreach (LowPolyPointHandle handle in obsoleteHandles)
            {
                RemoveHandleListenners(handle);
            }
        }

        pointHandles = newHandles;
    }
Esempio n. 11
0
    public void SetPoints(LowPolyPointHandle A, LowPolyPointHandle B)
    {
        if (PtA != A)
        {
            RemovePointListeners(PtA);
            AddPointListeners(A);
            PtA = A;
        }

        if (PtB != B)
        {
            RemovePointListeners(PtB);
            AddPointListeners(B);
            PtB = B;
        }
    }
Esempio n. 12
0
    private void OnFusionPoint(LowPolyPointHandle ptHandle)
    {
        LowPolyPointHandle fusiontWith = ptHandle.CloseHandle;

        if (fusiontWith == PtA)
        {
            SetPoints(fusiontWith, PtB);
        }
        else if (fusiontWith == PtB)
        {
            SetPoints(PtA, fusiontWith);
        }
        else
        {
            DestroyImmediate(this.gameObject);
        }
    }
    private LowPolyPointHandle[] GetSelectedHandles()
    {
        List <LowPolyPointHandle> selectedHandles = new List <LowPolyPointHandle>();

        if (Selection.gameObjects != null)
        {
            foreach (GameObject go in Selection.gameObjects)
            {
                LowPolyPointHandle h = go.GetComponent <LowPolyPointHandle>();
                if (h != null)
                {
                    selectedHandles.Add(h);
                }
            }
        }

        return(selectedHandles.ToArray());
    }
Esempio n. 14
0
 private void OnDestroyPoint(LowPolyPointHandle ptHandle)
 {
     DestroyImmediate(this.gameObject);
 }
Esempio n. 15
0
 private void OnMovePoint(LowPolyPointHandle ptHandle)
 {
     UpdatePosition();
 }