/***************************************************************************
*                                                                          *
*  Copyright (C) Golaem S.A.  All Rights Reserved.                         *
*                                                                          *
***************************************************************************/

#pragma once

#include "glmAbstractPathFollower.h"

namespace glm
{
/** 
* \brief Concrete path follower computing a local target sliding on the computed path ahead of the entity.
*
* \ingroup PathFollower
*
* \author Golaem <dev@golaem.com>
*/
class GLM_SDK_API PlatterLiftPathFollower : public AbstractPathFollower
{

  public:
    GLM_CLASS_STAT_ID( glm::MemoryStatIds::Simulation)

    PlatterLiftPathFollower(const PathFollowerConfiguration& configuration = PathFollowerConfiguration::defaultConfiguration());

    ~PlatterLiftPathFollower();

  protected:
    bool updateLocalTarget(PathContext* pathContext, const NavigationData& navigationData, float radius) override;
    bool initLocalTarget(PathContext* pathContext, const NavigationData& navigationData, float radius) override;
    bool planPath(PathContext* pathContext, const NavigationData& navigationData, const glm::Array<NavigationMeshLocation>& waypoints, glm::PODArray<size_t>& discardedWaypoints) override;

  private:
    size_t _maxTargetUpdateCount;

    bool canEntityMoveTo(NavigationMeshLocation& target, float targetCurvilinearAbscissa, const NavigationData& navigationData) const;
    bool dichotomicTargetSearch(const NavigationData& navigationData, float inUpperBound, NavigationMeshLocation& target, float& curvilignAbscissa) const;
    bool updateLocalTarget(PathContext* pathContext, const NavigationData& navigationData, float radius, size_t nbAttempts);

    /**
    * \brief Forbidden copy constructor.
    */
    PlatterLiftPathFollower(const PlatterLiftPathFollower&);

    /**
    * \brief Forbidden assignement.
    */
    PlatterLiftPathFollower& operator=(const PlatterLiftPathFollower&);
};
} // namespace glm
