private void ActiveWindow(ChildIndex index) { if (!controllers.ContainsKey(index)) { GameObject window = ResourceManager.Instance.LoadWindow(index.ToString()); controllers.Add(index, window); window.transform.parent = windowPanel.transform; window.transform.localScale = Vector3.one; window.SetActive(true); } foreach (ChildIndex key in controllers.Keys) { if (index == key) { controllers[key].transform.position = Vector3.zero; controllers[key].SetActive(true); lastPreviousWindowIndex = currentWindowIndex; currentWindowIndex = index; } else { controllers[key].SetActive(false); } } }
private void RemoveChildInternal(ChildIndex index, bool cleanup, bool updateNeighbours) { AssertNotDeleted(); if (children == null) { throw new ArgumentException("The child at that index is already removed!", "index"); } var indexInt = (int)index; if (children[indexInt] == null) { throw new ArgumentException("The child at that index is already removed!", "index"); } childCount--; children[indexInt].SetDeleted(updateNeighbours); children[indexInt] = null; if (childCount != 0) { return; } children = null; if (cleanup && parent != null) { // no need to update parent's neighbours! parent.RemoveChildInternal(indexInParent, true, false); } }
void SortDown(T item) { while (true) { ChildIndex childIndex = GetChildIndex(item); int leftChildIndex = childIndex.left; int rightChildIndex = childIndex.right; int swapIndex = 0; if (leftChildIndex < currentItemCount) { swapIndex = leftChildIndex; if (rightChildIndex < currentItemCount) { if (items[leftChildIndex].CompareTo(items[rightChildIndex]) < 0) { swapIndex = rightChildIndex; } } if (item.CompareTo(items[swapIndex]) < 0) { Swap(item, items[swapIndex]); } else { return; } } else { return; } } }
void resetLoginWindow() { needResetLogin = false; currentWindowIndex = ChildIndex.NONE; lastPreviousWindowIndex = ChildIndex.NONE; GuideManager.Instance.currentStep = GuideManager.GUIDE_STEP.NONE; }
private void AddTransparentNode(ChildIndex childIndex) { if (childIndex != ChildIndex.Invalid) { NeighbourSide verticalSide, depthSide, horizontalSide; if (_sideTransparentCount == null) { _sideTransparentCount = new Dictionary<NeighbourSide, int>(); for (var i = 0; i < 6; ++i) { var neighbourSide = (NeighbourSide)i; _sideTransparentCount[neighbourSide] = 0; } } GetNeighbourSides(childIndex, out verticalSide, out horizontalSide, out depthSide); _sideTransparentCount[verticalSide]++; _sideTransparentCount[depthSide]++; _sideTransparentCount[horizontalSide]++; } if (parent != null && _transparentNodeCount == 0) { parent.AddTransparentNode(indexInParent); } _transparentNodeCount++; }
public override int GetHashCode() { var hashCode = -1774268519; hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(NodeTypeName); hashCode = hashCode * -1521134295 + ChildIndex.GetHashCode(); return(hashCode); }
protected static Bounds GetChildBoundsInternal(Bounds originalBounds, ChildIndex childIndex) { var childDirection = GetChildDirection(childIndex); var childSize = originalBounds.extents; var childBounds = new Bounds(originalBounds.center + Vector3.Scale(childSize, childDirection * 0.5f), childSize); return(childBounds); }
private Bounds CreateParentBounds(ChildIndex wantedIndexInParent) { var myBounds = GetBounds(); var parentBoundsCenter = myBounds.center - Vector3.Scale(myBounds.extents, GetChildDirection(wantedIndexInParent)); return(new Bounds(parentBoundsCenter, Vector3.zero) { extents = myBounds.extents * 2 }); }
protected TNode SetChild(ChildIndex index, TNode child) { AssertNotDeleted(); #if USE_ALL_NODES child.AssertNotDeleted(); _allNodes.Add(child.nodeCoords.GetHashCode(), child); #endif children[(int)index] = child; return(child); }
public GameObject getController(ChildIndex index) { if (controllers.ContainsKey(index)) { return(controllers[index]); } else { return(null); } }
private void UnActiveWindow(ChildIndex index) { if (!controllers.ContainsKey(index)) { return; } foreach (ChildIndex key in controllers.Keys) { if (index == key) { controllers[key].SetActive(false); } } }
private void RemoveTransparentNode(ChildIndex childIndex) { if (childIndex != ChildIndex.Invalid) { NeighbourSide verticalSide, depthSide, horizontalSide; GetNeighbourSides(childIndex, out verticalSide, out horizontalSide, out depthSide); _sideTransparentCount[verticalSide]--; _sideTransparentCount[depthSide]--; _sideTransparentCount[horizontalSide]--; } _transparentNodeCount--; if (parent != null && _transparentNodeCount == 0) { parent.RemoveTransparentNode(indexInParent); } }
public TNode GetChild(ChildIndex index) { AssertNotDeleted(); var intIndex = (int)index; if (intIndex < 0 || intIndex > 7) { throw new ArgumentOutOfRangeException("index", "Invalid index specified for GetChild."); } if (children == null) { return(null); } return(children[(int)index]); }
public override int GetHashCode() { int hash = 1; if (ChildIndex != 0) { hash ^= ChildIndex.GetHashCode(); } if (Type.Length != 0) { hash ^= Type.GetHashCode(); } if (Variable.Length != 0) { hash ^= Variable.GetHashCode(); } return(hash); }
private void RemoveSolidNode(ChildIndex childIndex, bool wasActuallySolid) { NeighbourSide verticalSide, depthSide, horizontalSide; if (childIndex != ChildIndex.Invalid) { GetNeighbourSides(childIndex, out verticalSide, out horizontalSide, out depthSide); _sideSolidCount[verticalSide]--; _sideSolidCount[depthSide]--; _sideSolidCount[horizontalSide]--; } else { GetNeighbourSides(indexInParent, out verticalSide, out horizontalSide, out depthSide); } _solidNodeCount--; if (parent != null && _solidNodeCount == 0) { parent.RemoveSolidNode(indexInParent, false); } if (!wasActuallySolid) { return; } VoxelNode actualNode; if (childIndex != ChildIndex.Invalid) { actualNode = GetChild(childIndex); _sideSolidChildren[verticalSide].Remove(actualNode); _sideSolidChildren[depthSide].Remove(actualNode); _sideSolidChildren[horizontalSide].Remove(actualNode); } else { actualNode = this; } var currentParent = parent; while (currentParent != null) { currentParent._sideSolidChildren[verticalSide].Remove(actualNode); currentParent._sideSolidChildren[depthSide].Remove(actualNode); currentParent._sideSolidChildren[horizontalSide].Remove(actualNode); currentParent = currentParent.parent; } }
public static Vector3 GetChildDirection(ChildIndex childIndex) { Vector3 childDirection; switch (childIndex) { case ChildIndex.RightAboveBack: childDirection = RightAboveBack; break; case ChildIndex.LeftAboveBack: childDirection = LeftAboveBack; break; case ChildIndex.RightAboveForward: childDirection = RightAboveForward; break; case ChildIndex.LeftAboveForward: childDirection = LeftAboveForward; break; case ChildIndex.RightBelowBack: childDirection = RightBelowBack; break; case ChildIndex.LeftBelowBack: childDirection = LeftBelowBack; break; case ChildIndex.RightBelowForward: childDirection = RightBelowForward; break; case ChildIndex.LeftBelowForward: childDirection = LeftBelowForward; break; default: throw new ArgumentOutOfRangeException(); } return(childDirection); }
private void ReplaceChild(ChildIndex childIndex, Node newChild) { Assert.AreEqual(newChild.bounds.extents * 2, bounds.extents); var childCoords = new Coords(new[] { OctreeChildCoords.FromIndex(childIndex) }); var childBounds = GetChildBounds(childCoords); Assert.AreEqual(newChild.bounds.center, childBounds.center); if (children == null) { children = new Node[8]; } else if (children[(int)childIndex] != null) { RemoveChild(childIndex); } childCount++; SetChild(childIndex, newChild); }
public TNode AddChild(ChildIndex index) { if (index == ChildIndex.Invalid) { throw new ArgumentOutOfRangeException("index", "Cannot create a child at an invalid index."); } AssertNotDeleted(); if (children == null) { children = new TNode[8]; } if (GetChild(index) != null) { throw new ArgumentException("There is already a child at this index", "index"); } childCount++; return(SetChild(index, ocTree.ConstructNode(GetChildBounds(index), (TNode)this, index))); }
protected OctreeNodeBase(Bounds bounds, TNode parent, ChildIndex indexInParent, TTree ocTree) { deleted = false; this.bounds = bounds; this.parent = parent; if (parent == null) { #if USE_ALL_NODES // ReSharper disable once UseObjectOrCollectionInitializer _allNodes = new Dictionary <int, OctreeNode <T> >(); _allNodes[nodeCoords.GetHashCode()] = this; #endif } else { #if USE_ALL_NODES _allNodes = _root._allNodes; #endif } this.indexInParent = indexInParent; item = default(TItem); this.ocTree = ocTree; }
public Node(Bounds bounds, Node parent, ChildIndex indexInParent, SuperVoxelTree ocTree) : base(bounds, parent, indexInParent, ocTree) { }
public VoxelNode(Bounds bounds, VoxelNode parent, ChildIndex indexInParent, VoxelTree ocTree) : base(bounds, parent, indexInParent, ocTree) { _coords = new Coords(parent._coords, OctreeChildCoords.FromIndex(indexInParent)); }
private void ActiveWindow(ChildIndex index) { // if(index == ChildIndex.GGLController) // { // MainController mc = mainController.GetComponent<MainController>(); // mc.ShowGGL(); // } // else // { // MainController mc = mainController.GetComponent<MainController>(); // mc.ShowtopInfo(); // } foreach (ChildIndex key in controllers.Keys) { if (index != key) { //controllers[key].SendMessage("CloseWindow", SendMessageOptions.DontRequireReceiver); controllers[key].SetActive(false); } } if (!controllers.ContainsKey(index)) { GameObject window = ResourceManager.Instance.LoadWindow(index.ToString()); controllers.Add(index, window); window.transform.parent = windowPanel.transform; window.transform.localScale = Vector3.one; window.transform.localPosition = Vector3.zero; } // else // { // controllers[index].SetActive(false); // } foreach (ChildIndex key in controllers.Keys) { if (index == key) { lastPreviousWindowIndex = currentWindowIndex; currentWindowIndex = index; controllers[key].transform.localPosition = Vector3.zero; controllers[key].SetActive(true); break; } } // for (int i = 0; i < childControllers.Length; i++) // { // if (i == index) // { // //ËùÓеĶŒÒÔ0,0,0µãΪ»ù׌£¬²»ÓÃÿžö¶ŒœšÊý×é //// childControllers[i].transform.localPosition = Vector3.zero;//arrayChildInpos[i]; // childControllers[i].transform.position = Vector3.zero; // childControllers[i].SetActive(true); // lastPreviousWindowIndex = currentWindowIndex; // currentWindowIndex = i; // } // else // { //// Debug.Log("set active false:"+i); // childControllers[i].SetActive(false); // } // } }
INode INode.GetChild(ChildIndex childIndex) { return(GetChild(childIndex)); }
private void AddSolidNode(ChildIndex childIndex, bool actuallySolid) { NeighbourSide verticalSide, depthSide, horizontalSide; if (childIndex != ChildIndex.Invalid) { GetNeighbourSides(childIndex, out verticalSide, out horizontalSide, out depthSide); if (_sideSolidCount == null) { _sideSolidCount = new Dictionary<NeighbourSide, int>(); for (var i = 0; i < 6; ++i) { var neighbourSide = (NeighbourSide) i; _sideSolidCount[neighbourSide] = 0; } } _sideSolidCount[verticalSide]++; _sideSolidCount[depthSide]++; _sideSolidCount[horizontalSide]++; } else { GetNeighbourSides(indexInParent, out verticalSide, out horizontalSide, out depthSide); } if (parent != null && _solidNodeCount == 0) { parent.AddSolidNode(indexInParent, false); } _solidNodeCount++; if (!actuallySolid) { return; } VoxelNode actualNode; if (childIndex != ChildIndex.Invalid) { actualNode = GetChild(childIndex); if (_sideSolidChildren == null) { _sideSolidChildren = new Dictionary<NeighbourSide, HashSet<VoxelNode>>(); for (var i = 0; i < 6; ++i) { var neighbourSide = (NeighbourSide) i; _sideSolidChildren[neighbourSide] = new HashSet<VoxelNode>(); } } _sideSolidChildren[verticalSide].Add(actualNode); _sideSolidChildren[depthSide].Add(actualNode); _sideSolidChildren[horizontalSide].Add(actualNode); } else { actualNode = this; } var currentParent = parent; while (currentParent != null) { if (currentParent._sideSolidChildren == null) { currentParent._sideSolidChildren = new Dictionary<NeighbourSide, HashSet<VoxelNode>>(); for (var i = 0; i < 6; ++i) { var neighbourSide = (NeighbourSide)i; currentParent._sideSolidChildren[neighbourSide] = new HashSet<VoxelNode>(); } } currentParent._sideSolidChildren[verticalSide].Add(actualNode); currentParent._sideSolidChildren[depthSide].Add(actualNode); currentParent._sideSolidChildren[horizontalSide].Add(actualNode); currentParent = currentParent.parent; } }
public void RemoveChild(ChildIndex index, bool cleanup = false) { RemoveChildInternal(index, cleanup, true); }
private Bounds GetChildBounds(ChildIndex childIndex) { AssertNotDeleted(); return(GetChildBoundsInternal(bounds, childIndex)); }
public TestOctreeNode(Bounds bounds, TestOctreeNode <T> parent, ChildIndex indexInParent, TestOctree <T> tree) : base(bounds, parent, indexInParent, tree) { }
protected static void GetNeighbourSides(ChildIndex childIndex, out NeighbourSide verticalSide, out NeighbourSide horizontalSide, out NeighbourSide depthSide) { switch (childIndex) { case ChildIndex.Invalid: // self verticalSide = NeighbourSide.Invalid; horizontalSide = NeighbourSide.Invalid; depthSide = NeighbourSide.Invalid; break; case ChildIndex.LeftBelowBack: verticalSide = NeighbourSide.Below; depthSide = NeighbourSide.Back; horizontalSide = NeighbourSide.Left; break; case ChildIndex.RightBelowBack: verticalSide = NeighbourSide.Below; depthSide = NeighbourSide.Back; horizontalSide = NeighbourSide.Right; break; case ChildIndex.LeftAboveBack: verticalSide = NeighbourSide.Above; depthSide = NeighbourSide.Back; horizontalSide = NeighbourSide.Left; break; case ChildIndex.RightAboveBack: verticalSide = NeighbourSide.Above; depthSide = NeighbourSide.Back; horizontalSide = NeighbourSide.Right; break; case ChildIndex.LeftBelowForward: verticalSide = NeighbourSide.Below; depthSide = NeighbourSide.Forward; horizontalSide = NeighbourSide.Left; break; case ChildIndex.RightBelowForward: verticalSide = NeighbourSide.Below; depthSide = NeighbourSide.Forward; horizontalSide = NeighbourSide.Right; break; case ChildIndex.LeftAboveForward: verticalSide = NeighbourSide.Above; depthSide = NeighbourSide.Forward; horizontalSide = NeighbourSide.Left; break; case ChildIndex.RightAboveForward: verticalSide = NeighbourSide.Above; depthSide = NeighbourSide.Forward; horizontalSide = NeighbourSide.Right; break; default: throw new ArgumentOutOfRangeException("childIndex", childIndex, null); } }