//public List<> public void DoUpdate(LFloat deltaTime) { tempLst.Clear(); //deal layer foreach (var pair in BoundsQuadTreeNode.obj2Node) { var val = pair.Key; if (!val.IsStatic) { val.DoUpdate(deltaTime); if (val.IsMoved) { val.IsMoved = false; tempLst.Add(val); } } } //swap var temp = _prePairs; _prePairs = _curPairs; _curPairs = temp; _curPairs.Clear(); ////class version 1.41ms Profiler.BeginSample("UpdateObj"); foreach (var val in tempLst) { val.IsMoved = false; var bound = val.GetBounds(); var boundsTree = GetBoundTree(val.LayerType); boundsTree.UpdateObj(val, bound); } Profiler.EndSample(); ////0.32~0.42ms Profiler.BeginSample("CheckCollision"); foreach (var val in tempLst) { val.IsMoved = false; var bound = val.GetBounds(); var targetLayers = InterestingMasks[val.LayerType]; foreach (var layerType in targetLayers) { var boundsTree = GetBoundTree(layerType); boundsTree.CheckCollision(val, bound); } } Profiler.EndSample(); Profiler.BeginSample("CheckLastFrameCollison"); foreach (var pairId in _curPairs) { _prePairs.Remove(pairId); } //check stay leave event foreach (var idPair in _prePairs) { var a = GetCollider((int)(idPair >> 32)); var b = GetCollider((int)(idPair & 0xffffffff)); if (a == null || b == null) { continue; } bool isCollided = CollisionHelper.CheckCollision (a.Prefab, a.Transform2D, b.Prefab, b.Transform2D); if (isCollided) { _curPairs.Add(idPair); NotifyCollisionEvent(a, b, ECollisionEvent.Stay); } else { NotifyCollisionEvent(a, b, ECollisionEvent.Exit); } } Profiler.EndSample(); }