Example #1
0
    IEnumerator _computeCCVelocityField(CM_Unit_Goal_Group cmugg)
    {
        cce = new CCEikonalSolver(
            NavSystem.S.getCCMapPackageFromRect(cmugg.unitGoalSolutionSpace),
            NavSystem.S.getGoalAsLocations(cmugg.unitGoalSolutionSpace, cmugg.goals)
            );
        yield return(StartCoroutine(cce.WaitFor()));

        cmugg.setVelocityField(cce.v);

        if (DEBUG_EIKONAL_SOLN)
        {
            int xs = Mathf.FloorToInt(cmugg.unitGoalSolutionSpace.x);
            int ys = Mathf.FloorToInt(cmugg.unitGoalSolutionSpace.y);
            NavSystem.S._DEBUG_VISUAL_plotTileFields(new Vector2(xs, ys), cce.v);
//			NavSystem.S.theMapAnalyzer.printOutMatrix (cce.f);
        }
    }
Example #2
0
    public void SolveCCforTileWithCallback(
        MapTile tile,
        List <Location> goals,
        Action <Func <Vector2, Vector2> > tileSolutionCallback
        )
    {
        // (1) perform continuum crowd solution on provided tile
        var eikonalSolution = new CCEikonalSolver();
        var ccTile          = ccFields.GetCCTile(tile.Corner);

        eikonalSolution.SolveContinuumCrowdsForTile(ccTile, goals.Select(g => g - tile.Corner).ToList());

        tileSolutionCallback(vel => eikonalSolution.velocity.Interpolate(vel.x, vel.y));

        // (2) store the velocity field (solution) in a list with some identifier
        //      to clearly show what we've solved and can therefore reference later
        // (3) send back a function that will take in a position (vector2) and
        //      return the interpolated velocity on the cc solution (vector2)
    }