/* osgEarth
 * Copyright 2015 Pelican Mapping
 * MIT License
 */
#ifndef OSGEARTH_SPLAT_BIOME_SELECTOR_CALLBACK
#define OSGEARTH_SPLAT_BIOME_SELECTOR_CALLBACK 1

#include "BiomeRegion"
#include "Export"
#include <osg/NodeCallback>
#include <osg/Polytope>

namespace osgEarth { namespace Splat
{
    // TODO: THIS WILL BECOME THE "SURFACE SELECTOR"

    /**
     * Cull callback that applies the approprate stateset based on what
     * it determines to be the active Biome.
     */
    class OSGEARTHSPLAT_EXPORT BiomeRegionSelector : public osg::NodeCallback
    {
    public:
        BiomeRegionSelector(
            const BiomeRegionVector&     biomeRegions,
            const SplatTextureDefVector& textureDefs,
            osg::StateSet*               basicStateSet,
            int                          textureImageUnit);

    public: // osg::NodeCallback

        void operator()(osg::Node* node, osg::NodeVisitor* nv);

    protected:
        BiomeRegionVector                          _biomeRegions;
        std::vector< osg::ref_ptr<osg::StateSet> > _stateSets;
        std::vector< osg::Polytope >               _topes;
    };

} } // namespace osgEarth::Splat

#endif // OSGEARTH_SPLAT_BIOME_SELECTOR_CALLBACK
