Example #1
0
        /**
         * <summary>Clears the simulation.</summary>
         */
        public void Clear()
        {
            agents_            = new List <Agent>();
            agentNo2indexDict_ = new Dictionary <int, int>();
            index2agentNoDict_ = new Dictionary <int, int>();
            defaultAgent_      = null;
            kdTree_            = new KdTree();
            obstacles_         = new List <Obstacle>();
            globalTime_        = 0;
            isError            = false;
            timeStep_          = KInt.ToInt(KInt.divscale / 10);

            SetNumWorkers(0);
        }
Example #2
0
        /**
         * <summary>Computes the neighbors of this agent.</summary>
         */
        internal void computeNeighbors(KdTree kdTree_, IList <Obstacle> obstacles)
        {
            obstacleNeighbors_.Clear();
            agentNeighbors_.Clear();

            float rangeSq = RVOMath.sqr(timeHorizonObst_ * maxSpeed_ + radius_);

            foreach (var obstacle in obstacles)
            {
                insertObstacleNeighbor(obstacle, rangeSq); //mozliwy powod bledu ze wzgledu na rangeSq  // kdTree.computeObstacleNeighbors(this, rangeSq);
            }
            if (maxNeighbors_ > 0)
            {
                rangeSq = RVOMath.sqr(neighborDist_);

                kdTree_.computeAgentNeighbors(this, ref rangeSq);
                //  foreach (var agent in agents)
                //      insertAgentNeighbor(agent, ref rangeSq); //mozliwy powod bledu ze wzgledu na rangeSq // co z obstacle_next // kdTree.computeAgentNeighbors(this, ref rangeSq);
            }
        }
Example #3
0
        public KdTree CopythisToKdtree(IList <Obstacle> target)
        {
            KdTree tree = new KdTree();

            Dictionary <int, KdtreeObstacle> dic = new Dictionary <int, KdtreeObstacle>();

            for (int i = 0; i < obstacles.Count; ++i)
            {
                dic[obstacles[i].id_] = obstacles[i];
            }

            Dictionary <int, KdtreeObstacleTreeNode> treedic = new Dictionary <int, KdtreeObstacleTreeNode>();

            for (int i = 0; i < treenodes.Count; ++i)
            {
                treedic[treenodes[i].id] = treenodes[i];
            }

            Dictionary <int, Obstacle> obsdic = new Dictionary <int, Obstacle>();

            KdTree.ObstacleTreeNode treenode = Assign2Kdtree(treedic[0], dic, treedic, obsdic);

            /*ScriptCommand setnode_cmd = ScriptCommand.Create((int)FrameWorkCmdDefine.SET_KDTREE_TREENODE);
             * setnode_cmd.CallParams.WriteObject(tree);
             * setnode_cmd.CallParams.WriteObject(treenode);
             * setnode_cmd.ExcuteAndRelease();*/

            //assign obstacles
            target.Clear();
            var en = obsdic.GetEnumerator();

            while (en.MoveNext())
            {
                target.Add(en.Current.Value);
            }

            return(tree);
        }