예제 #1
0
        /**
         * <summary>Computes the neighbors of this agent.</summary>
         */
        internal void computeNeighbors(KdTree kdTree_)
        {
            obstacleNeighbors_.Clear();
            float rangeSq = RVOMath.sqr(timeHorizonObst_ * maxSpeed_ + radius_);

            kdTree_.computeObstacleNeighbors(this, rangeSq);

            agentNeighbors_.Clear();

            if (maxNeighbors_ > 0)
            {
                rangeSq = RVOMath.sqr(neighborDist_);
                kdTree_.computeAgentNeighbors(this, ref rangeSq);
            }
        }
예제 #2
0
        public Vector2 compute(IList <State> sate, Vector2 currentPosition)
        {
            CurrentAgent.position_ = currentPosition;

            // CurrentAgent.velocity_ = new Vector2(0, 0); //bug bug bug gdy jest zerowane powoduje problem roboty powinny uwzgledniac velocity z poptrzedniego wyliczenia

            IList <Agent> agents = getAgents(sate);

            agents.Add(CurrentAgent);

            agents_ = agents;
            kdTree_ = new KdTree();
            kdTree_.buildAgentTree(agents_);
            kdTree_.buildObstacleTree(obstacles_);

            setAgentPrefVelocity();

            CurrentAgent.computeNeighbors(kdTree_); //Simulator.Instance.agents_[agentNo].computeNeighbors();
            CurrentAgent.computeNewVelocity();      //Simulator.Instance.agents_[agentNo].computeNewVelocity();

            CurrentAgent.update();

            return(CurrentAgent.velocity_);
        }