/* -*-c++-*- */
/* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
 * Copyright 2008-2010 Pelican Mapping
 * http://osgearth.org
 *
 * osgEarth is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 */
#if 0
#ifndef OSGEARTH_TERRAIN_TILE_EDGE_NORMALIZATION_CALLBACK
#define OSGEARTH_TERRAIN_TILE_EDGE_NORMALIZATION_CALLBACK 1

#include <osg/Node>
#include <osgTerrain/TerrainTile>
#include <osgEarth/Common>

class CustomTile;

enum CardinalDirection
{
    NORTH,
    EAST,
    SOUTH,
    WEST,
    NORTH_EAST,
    NORTH_WEST,
    SOUTH_EAST,
    SOUTH_WEST
};

/**
* Update callback that scans adjacent tiles and adjusts the edge verts so that
* they match up. Helps match up mismatched elevation data at tile edges.
*/
class TerrainTileEdgeNormalizerUpdateCallback : public osg::NodeCallback
{
public:
    TerrainTileEdgeNormalizerUpdateCallback();
    void operator()(osg::Node* node, osg::NodeVisitor* nv);

protected:

    bool normalizeCorner(CustomTile *tile, CardinalDirection direction);
    bool normalizeEdge(CustomTile *tile, CardinalDirection direction);
    osgTerrain::TileID getNeighborTile(const osgTerrain::TileID &id, CardinalDirection direction) const;

    bool _normalizedWest;
    bool _normalizedEast;
    bool _normalizedNorth;
    bool _normalizedSouth;
    bool _normalizedNorthWest;
    bool _normalizedNorthEast;
    bool _normalizedSouthWest;
    bool _normalizedSouthEast;

};


#endif //OSGEARTH_TERRAIN_TILE_EDGE_NORMALIZATION_CALLBACK
#endif