public void next() {
        // Walk us to our next location based on distances to next X or Z grid
        // line.
        if (distToNextXIntersection < distToNextZIntersection) {
            rayLength = distToNextXIntersection;
            gridLocation.x += stepXDirection;
            distToNextXIntersection += distBetweenXIntersections;
            switch (stepXDirection) {
            case -1:
                stepDirection = Direction.NegativeX;
                break;
            case 0:
                stepDirection = Direction.None;
                break;
            case 1:
                stepDirection = Direction.PositiveX;
                break;
            }
        } else {
            rayLength = distToNextZIntersection;
            gridLocation.y += stepZDirection;
            distToNextZIntersection += distBetweenZIntersections;
            switch (stepZDirection) {
            case -1:
                stepDirection = Direction.NegativeZ;
                break;
            case 0:
                stepDirection = Direction.None;
                break;
            case 1:
                stepDirection = Direction.PositiveZ;
                break;
            }
        }

        rayLocation.set(walkRay.direction).multLocal(rayLength).addLocal(walkRay.origin);
    }
Works on the XZ plane, with positive Y as up.

@author Joshua Slack
@author Brent Owens
jme3-terrain/src/main/java/com/jme3/terrain/geomipmap/picking/BresenhamYUpGridTracer.java