protected override void OnUpdated(SceneData newNodes) { IsUpdatingNodes = true; var sw = Stopwatch.StartNew(); var nodeCount = 0; var gridName = GetType().Name; foreach (var scene in newNodes.Scenes) { var nodes = scene.ExplorationNodes.SelectMany(n => n.Nodes, (p, c) => new AvoidanceNode(c)).ToList(); Core.Logger.Verbose($"[{gridName}] Updating grid for scene '{scene.SceneHash}' with {scene.ExplorationNodes.Count} new nodes"); UpdateInnerGrid(nodes); foreach (var node in nodes) { nodeCount++; if (GetNeighbors(node).Any(n => (n.NodeFlags & NodeFlags.AllowWalk) == 0)) { node.NodeFlags |= NodeFlags.NearWall; } } } IsUpdatingNodes = false; IsPopulated = true; sw.Stop(); Core.Logger.Verbose($"Avoidance Grid updated NewNodes={nodeCount} NearestNodeFound={NearestNode != null} Time={sw.Elapsed.TotalMilliseconds}ms"); }
protected override void OnUpdated(SceneData newNodes) { using (var t = new PerformanceLogger(nameof(OnUpdated))) { IsUpdatingNodes = true; var sw = Stopwatch.StartNew(); var nodeCount = 0; foreach (var scene in newNodes.Scenes) { var nodes = scene.ExplorationNodes.SelectMany(n => n.Nodes, (p, c) => new AvoidanceNode(c)) .ToList(); s_logger.Debug( $"[{nameof(OnUpdated)}] Updating grid for scene '{scene.SceneHash}' with {scene.ExplorationNodes.Count} new nodes"); UpdateInnerGrid(nodes); foreach (var node in nodes) { nodeCount++; if (GetNeighbors(node).Any(n => (n.NodeFlags & NodeFlags.AllowWalk) == 0)) { node.NodeFlags |= NodeFlags.NearWall; } } } IsUpdatingNodes = false; IsPopulated = true; sw.Stop(); s_logger.Debug($"[{nameof(OnUpdated)}] Avoidance Grid updated NewNodes={nodeCount} NearestNodeFound={NearestNode != null} Time={t.Elapsed}"); } }
protected virtual void OnUpdated(SceneData newNodes) { }