예제 #1
0
        private void GenerateHighLevelPath()
        {
            ClearPathNodes();

            if (m_hlBegin == null)
            {
                return;
            }

            var path = m_goal.FindHighLevelPath(m_pathfinding, m_hlBegin);

            if (path == null)
            {
                // CH: TODO: No path found (not even to an unexplored primitive). We're trapped! What now?
                return;
            }

            foreach (var primitive in path)
            {
                Debug.Assert(primitive.Vertex is MyHighLevelPrimitive);

                var hlPrimitive = primitive.Vertex as MyHighLevelPrimitive;
                m_pathNodes.Add(hlPrimitive);

                if (hlPrimitive != m_hlBegin)
                {
                    hlPrimitive.Parent.ObservePrimitive(hlPrimitive, this);
                }
            }

            m_pathNodePosition = 0;
        }
예제 #2
0
        // MW:TODO optimize or change
        public bool ReachableUnderThreshold(Vector3D begin, IMyDestinationShape end, float thresholdDistance)
        {
            m_reachPredicateDistance = thresholdDistance;
            var beginPrimitive = FindClosestPrimitive(begin, false);
            var endPrimitive   = FindClosestPrimitive(end.GetDestination(), false);

            if (beginPrimitive == null || endPrimitive == null)
            {
                return(false);
            }

            var beginHL = beginPrimitive.GetHighLevelPrimitive();
            var endHL   = endPrimitive.GetHighLevelPrimitive();

            ProfilerShort.Begin("HL");
            MySmartGoal goal = new MySmartGoal(end);
            var         path = goal.FindHighLevelPath(this, beginHL);

            ProfilerShort.End();
            if (path == null)
            {
                return(false);
            }

            m_reachEndPrimitive = endPrimitive;
            ProfilerShort.Begin("Prepare for travesal");
            PrepareTraversal(beginPrimitive, null, ReachablePredicate);
            ProfilerShort.End();
            ProfilerShort.Begin("checking for vertices");
            try
            {
                foreach (var vertex in this)
                {
                    if (vertex.Equals(m_reachEndPrimitive))
                    {
                        return(true);
                    }
                }
            }
            finally
            {
                ProfilerShort.End();
            }

            return(false);
        }