private void OnMoveHandle(LowPolyPointHandle handle) { if (handle != null) { UpdatePosition(handle.LastPosition); } }
private void OnDestroyHandle(LowPolyPointHandle handle) { if (handle != null) { lps.DeletePosition(handle.transform.position); } }
public void RemoveHandleListenners(LowPolyPointHandle handle) { if (handle != null) { handle.RemoveMoveAction(OnMoveHandle); handle.RemoveDestroyAction(OnDestroyHandle); handle.RemoveFusionAction(OnFusionHandle); } }
public void AddHandleListenners(LowPolyPointHandle handle) { if (handle != null) { handle.AddMoveAction(OnMoveHandle); handle.AddDestroyAction(OnDestroyHandle); handle.AddFusionAction(OnFusionHandle); } }
private void RemovePointListeners(LowPolyPointHandle pt) { if (pt != null) { pt.RemoveMoveAction(OnMovePoint); pt.RemoveFusionAction(OnFusionPoint); pt.RemoveDestroyAction(OnDestroyPoint); } }
private void AddPointListeners(LowPolyPointHandle pt) { if (pt != null) { pt.AddMoveAction(OnMovePoint); pt.AddFusionAction(OnFusionPoint); pt.AddDestroyAction(OnDestroyPoint); } }
private void DragHandles(bool drag) { foreach (GameObject go in Selection.gameObjects) { LowPolyPointHandle handle = go.GetComponent <LowPolyPointHandle>(); if (handle != null) { handle.Drag = drag; } } }
public void OnFusionHandle(LowPolyPointHandle replaced) { int replacedIndex = pointHandles.IndexOf(replaced); if (replacedIndex != -1 && replaced.CloseHandle != null) { pointHandles[replacedIndex] = replaced.CloseHandle; UpdatePositions(); UpdateSegmentHandles(); } }
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); }
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; }
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; } }
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()); }
private void OnDestroyPoint(LowPolyPointHandle ptHandle) { DestroyImmediate(this.gameObject); }
private void OnMovePoint(LowPolyPointHandle ptHandle) { UpdatePosition(); }