public override void UpdateAfterSimulation() { long time = Time(); while (m_entities.Count > 0 && m_entities.MinKey() < time) { m_index.Remove(m_entities.RemoveMin().Entity.EntityId); } if (m_entities.Count == 0) { SetUpdateOrder(MyUpdateOrder.NoUpdate); } }
public void MarkBoxForAddition(BoundingBoxD box) { ProfilerShort.Begin("VoxelNavMesh.MarkBoxForAddition"); Vector3I pos, end; MyVoxelCoordSystems.WorldPositionToVoxelCoord(m_voxelMap.PositionLeftBottomCorner, ref box.Min, out pos); MyVoxelCoordSystems.WorldPositionToVoxelCoord(m_voxelMap.PositionLeftBottomCorner, ref box.Max, out end); m_voxelMap.Storage.ClampVoxelCoord(ref pos); m_voxelMap.Storage.ClampVoxelCoord(ref end); MyVoxelCoordSystems.VoxelCoordToGeometryCellCoord(ref pos, out pos); MyVoxelCoordSystems.VoxelCoordToGeometryCellCoord(ref end, out end); Vector3 center = pos + end; center = center * 0.5f; pos /= 1 << NAVMESH_LOD; end /= 1 << NAVMESH_LOD; for (var it = new Vector3I.RangeIterator(ref pos, ref end); it.IsValid(); it.GetNext(out pos)) { if (!m_processedCells.Contains(ref pos) && !m_markedForAddition.Contains(ref pos)) { float weight = 1.0f / (0.01f + Vector3.RectangularDistance(pos, center)); if (!m_toAdd.Full) { m_toAdd.Insert(pos, weight); m_markedForAddition.Add(ref pos); } else { float min = m_toAdd.MinKey(); if (weight > min) { Vector3I posRemoved = m_toAdd.RemoveMin(); m_markedForAddition.Remove(ref posRemoved); m_toAdd.Insert(pos, weight); m_markedForAddition.Add(ref pos); } } } } ProfilerShort.End(); }
public bool MoveNext() { while (_tmp.Count > 0) { var minKey = _tmp.MinKey(); var min = _tmp.RemoveMin(); int child1, child2; _tree.GetChildren(min, out child1, out child2); if (child1 == -1) { Current = new KeyValuePair <int, double>(min, minKey); return(true); } Insert(child1); Insert(child2); } Current = default(KeyValuePair <int, double>); return(false); }
protected void RunUpdate(long ticks) { ApplyChanges(); _ticks += ticks; do { if (_scheduledUpdates.Count == 0) { return; } if (_scheduledUpdates.MinKey() > _ticks) { return; } var test = _scheduledUpdates.RemoveMin(); test.Callback((ulong)(_ticks - test.LastUpdate)); if (test.Interval > 0) { var next = new ScheduledUpdate(test.Callback, _ticks, test.NextUpdate + test.Interval, test.Interval); _scheduledUpdates.Insert(next, next.NextUpdate); } } while (true); }