public void ClearDynamicCollisions() { List <int> removeEid = new List <int>(); foreach (KeyValuePair <int, DynamicInfo> item in _dynamicMap) { DynamicInfo info = new DynamicInfo(); info = item.Value; combinedPolygonList[info.polygonIdx].points = null; _delayRemovePolygon.Add(combinedPolygonList[info.polygonIdx]); } foreach (KeyValuePair <int, EditorGridNode> item in _orgNodeMap) { EditorGridNode node = _orgNodeMap[item.Key]; _orgNodeMap[item.Key].CopyTo(ref node); } _orgNodeMap.Clear(); _dynamicMap.Clear(); RemoveDelayDynamicPolygon(); }
public void AddDynamicCollisions(int eid, List <Vector2> points) { Logger.Info("设置SetDynamicCollisions"); ////Logger.Assert(combinedPolygonList != null, "_polygonList is NULL"); List <EditorGridNode> orgGridList = new List <EditorGridNode>(); int curInsertPolygonIdx; if (_dynamicMap.ContainsKey(eid)) { RemoveDynamicCollisions(eid); } Polygon2D dynamic = new Polygon2D(); dynamic.points = points; combinedPolygonList.Add(dynamic); curInsertPolygonIdx = combinedPolygonList.Count - 1; DynamicInfo info = new DynamicInfo(); info.polygonIdx = curInsertPolygonIdx; info.effectNode = new List <int>(); info.uid = eid; _dynamicMap[eid] = info; List <int> effectIdxList = new List <int>(); for (int i = 0; i < dynamic.points.Count; i++) { int startIndex = i; int endIndex = startIndex + 1; if (endIndex >= dynamic.points.Count) { break; } Vector2 startPos = dynamic.points[startIndex]; Vector2 endPos = dynamic.points[endIndex]; ////Logger.Assert(i < ushort.MaxValue && curInsertPolygonIdx < byte.MaxValue, "AddDynamicCollisions 越界"); SetDynamicObsInfo(ref info.effectNode, (ushort)i, startPos, endPos, (byte)curInsertPolygonIdx); } }
public void RemoveDynamicCollisions(int eid) { DynamicInfo info = new DynamicInfo(); if (!_dynamicMap.ContainsKey(eid)) { return; } info = _dynamicMap[eid]; for (int i = 0; i < info.effectNode.Count; i++) { int nodeIdx = info.effectNode[i]; bool result = gridNodeList[nodeIdx].RemoveObsInfo(info.polygonIdx); if (result) { if (!_orgNodeMap.ContainsKey(nodeIdx)) { continue; } if (_orgNodeMap[nodeIdx].obsLists.Count == gridNodeList[nodeIdx].obsLists.Count) { EditorGridNode node = gridNodeList[nodeIdx]; _orgNodeMap[nodeIdx].CopyTo(ref node); _orgNodeMap.Remove(nodeIdx); } } } combinedPolygonList[info.polygonIdx].points = null; _delayRemovePolygon.Add(combinedPolygonList[info.polygonIdx]); _dynamicMap.Remove(eid); if (_dynamicMap.Count == 0) { RemoveDelayDynamicPolygon(); } }