/* osgEarth
* Copyright 2008-2014 Pelican Mapping
* MIT License
*/
#ifndef OSGEARTH_DRIVERS_MP_MASK_GENERATOR
#define OSGEARTH_DRIVERS_MP_MASK_GENERATOR 1

#include "Common"
#include <osgEarth/TileKey>
#include <osg/Geometry>

namespace osgEarth { namespace Drivers { namespace MPTerrainEngine
{
    using namespace osgEarth;

    /**
     * Record that stores the data for a single masking region.
     */
    struct MaskRecord
    {
        osg::ref_ptr<osg::Vec3dArray> _boundary;
        osg::Vec3d                    _ndcMin, _ndcMax;
        osg::Geometry*                _geom;
        osg::ref_ptr<osg::Vec3Array>  _internal;

        MaskRecord(osg::Vec3dArray* boundary, osg::Vec3d& ndcMin, osg::Vec3d& ndcMax, osg::Geometry* geom) 
            : _boundary(boundary), _ndcMin(ndcMin), _ndcMax(ndcMax), _geom(geom), _internal(new osg::Vec3Array()) { }
    };

    typedef std::vector<MaskRecord> MaskRecordVector;


    /**
     * Creates geometry for the part of a tile containing mask data.
     */
    class MaskGenerator
    {
    public:
        MaskGenerator(const TileKey& key);

        /** whether a texcoord indicates that the corresponding vert is masked. */
        bool isMasked(const osg::Vec3f& texCoord) const
        {
            return texCoord.z() == 0.0f;
        }

        /** whether the masking geometry contains a unit location. */
        bool contains(float nx, float ny) const
        {
            // Placeholder for now.
            return false;
        }

        bool containedByQuadAtColRow(int col, int row, int tileSize) const
        {
            // Placeholder for now.
            return false;
        }

    protected:
        const TileKey    _key;
        MaskRecordVector _maskRecords;
    };

} } } // namespace osgEarth::Drivers::MPTerrainEngine

#endif // OSGEARTH_DRIVERS_MP_MASK_GENERATOR
