Ejemplo n.º 1
0
        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");
        }
Ejemplo n.º 2
0
        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}");
            }
        }
Ejemplo n.º 3
0
 protected virtual void OnUpdated(SceneData newNodes)
 {
 }