public int addAgent(float[] pos, CrowdAgentParams params) {
        // Find empty slot.
        int idx = -1;
        for (int i = 0; i < m_maxAgents; ++i) {
            if (!m_agents[i].active) {
                idx = i;
                break;
            }
        }
        if (idx == -1) {
            return -1;
        }

        CrowdAgent ag = m_agents[idx];

        updateAgentParameters(idx, params);

        // Find nearest position on navmesh and place the agent there.
        Result<FindNearestPolyResult> nearestPoly = m_navquery.findNearestPoly(pos, m_ext,
                m_filters[ag.params.queryFilterType]);

        float[] nearest = nearestPoly.succeeded() ? nearestPoly.result.getNearestPos() : pos;
        long ref = nearestPoly.succeeded() ? nearestPoly.result.getNearestRef() : 0L;
        ag.corridor.reset(ref, nearest);
        ag.boundary.reset();
        ag.partial = false;

        ag.topologyOptTime = 0;
        ag.targetReplanTime = 0;

        vSet(ag.dvel, 0, 0, 0);
        vSet(ag.nvel, 0, 0, 0);
        vSet(ag.vel, 0, 0, 0);
        vCopy(ag.npos, nearest);

        ag.desiredSpeed = 0;

        if (ref != 0) {
            ag.state = CrowdAgentState.DT_CROWDAGENT_STATE_WALKING;
        } else {
            ag.state = CrowdAgentState.DT_CROWDAGENT_STATE_INVALID;
        }

        ag.targetState = MoveRequestState.DT_CROWDAGENT_TARGET_NONE;

        ag.active = true;

        return idx;
    }
public int addAgent ( float [ ] pos , CrowdAgentParams params ) { int idx = - 1 ; for ( int i = 0 ; i < m_maxAgents ; ++ i ) { if ( ! m_agents [ i ] . active ) { idx = i ; break ; } } if ( idx == - 1 ) { return - 1 ; } CrowdAgent ag = m_agents [ idx ] ; updateAgentParameters ( idx , params ) ; Result < FindNearestPolyResult > nearestPoly = m_navquery . findNearestPoly ( pos , m_ext , m_filters [ ag . params . queryFilterType ] ) ; float [ ] nearest = nearestPoly . succeeded ( ) ? nearestPoly . result . getNearestPos ( ) : pos ; long ref = nearestPoly . succeeded ( ) ? nearestPoly . result . getNearestRef ( ) : 0L ; ag . corridor . reset ( ref , nearest ) ; ag . boundary . reset ( ) ; ag . partial = false ; ag . topologyOptTime = 0 ; ag . targetReplanTime = 0 ; vSet ( ag . dvel , 0 , 0 , 0 ) ; vSet ( ag . nvel , 0 , 0 , 0 ) ; vSet ( ag . vel , 0 , 0 , 0 ) ; vCopy ( ag . npos , nearest ) ; ag . desiredSpeed = 0 ; if ( ref != 0 ) { ag . state = CrowdAgentState . DT_CROWDAGENT_STATE_WALKING ; } else { ag . state = CrowdAgentState . DT_CROWDAGENT_STATE_INVALID ; } ag . targetState = MoveRequestState . DT_CROWDAGENT_TARGET_NONE ; ag . active = true ; return idx ; }
/ could not be added.