private void CheckPhysicsCollidersAgainstCategory() { foreach (EHBaseCollider2D PhysicsCollider in ColliderComponentDictionary[EHBaseCollider2D.EColliderType.PHYSICS]) { if (PhysicsCollider.gameObject.activeInHierarchy) { CollisionNodeHeap.Clear(); foreach (EHBaseCollider2D Static in ColliderComponentDictionary[EHBaseCollider2D.EColliderType.STATIC]) { if (Static.gameObject.activeInHierarchy) { if (PhysicsCollider.IsPhysicsColliderOverlapping(Static) && !Physics2D.GetIgnoreLayerCollision(PhysicsCollider.gameObject.layer, Static.gameObject.layer)) { CollisionNodeHeap.Push(new CollisionNode(PhysicsCollider.GetShortestDistanceFromPreviousPosition(Static), Static)); } } } foreach (EHBaseCollider2D Moveable in ColliderComponentDictionary[EHBaseCollider2D.EColliderType.MOVEABLE]) { if (Moveable.gameObject.activeInHierarchy && !Physics2D.GetIgnoreLayerCollision(PhysicsCollider.gameObject.layer, Moveable.gameObject.layer)) { if (PhysicsCollider.IsPhysicsColliderOverlapping(Moveable)) { CollisionNodeHeap.Push(new CollisionNode(PhysicsCollider.GetShortestDistanceFromPreviousPosition(Moveable), Moveable)); } } } while (!CollisionNodeHeap.IsEmpty()) { EHBaseCollider2D IntersectedCollider = CollisionNodeHeap.Pop().Collider; if (IntersectedCollider.PushOutCollider(PhysicsCollider)) { PhysicsCollider.UpdateColliderBounds(false); } } } } CollisionNodeHeap.Clear(); }
public void RunHeapTest() { EHPriorityQueue <int> MaxHeap = new EHPriorityQueue <int>(); for (int i = 0; i < 1000; ++i) { MaxHeap.Push(Random.Range(0, 10000)); } int j = 0; while (!MaxHeap.IsEmpty()) { print((++j).ToString() + " " + MaxHeap.Pop()); } }