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

#pragma once

#include "glmArray.h"
#include "glmPODArray.h"
#include "glmVector3.h"

namespace glm
{
    //-------------------------------------------------------------------------
    class Vehicle
    {
    public:
        struct LateralNoiseScope
        {
            enum Value
            {
                PERBEHAVIOR,
                PERLANE,
                END
            };
        };

        Vehicle();

        void clear();

        // configuration, set Trailer and addTow must be configured with the vehicle boxes "aligned" as if driving in a straight line, as in default gcha / skeleton
        void setSize(float frontLength, float backLength, float width);
        void setSpeeds(float maxspeed, float maxSpeedWhenTurning, float maxAccel, float maxDecel, float maxAngularSpeed, float respectRatio, float lateralNoise, LateralNoiseScope::Value lateralNoiseScope);
        //void setTrailer(int specRefBoneId, const Vector3& boneToBoxCenter, float boxHalfLength, float boxHalfWidth, float boxHalfHeight, const Vector3& boxWorldPos, const Quaternion& boxWorldOrientation);
        //void addTow(int specRefBoneId, const Vector3& boneToBoxCenter, float boxHalfLength, float boxHalfWidth, float boxHalfHeight, const Vector3& boxWorldPos, const Quaternion& boxWorldOrientation);

        // size conf
        float _halfWidth;
        float _frontLength;
        float _backLength;

        // speed conf
        float _maxSpeed;
        float _maxSpeedWhenTurning;
        float _maxAcceleration;
        float _maxDeceleration;
        float _maxAngularSpeed;
        float _respectRatio;                         // ratio applyed on speed limits to avoid uniform speeds on lanes
        float _lateralNoise;                         // = random usage of lateral space jitter, from 0 to 1
        LateralNoiseScope::Value _lateralNoiseScope; // lateral jitter picked once for all or at each lane change ?

        //// binding boxes <-> spec posture bones
        ////glm::Array<VehicleBox> _vehicleBoxes;

        //// helpers for nav (to know quickly the vehicle coverage on its trajectory)
        //float _frontLength; // from first box center
        //float _backLength; // total length information, for overtaking, from first box center
        //float _speed; // runtime speed (replace entity one)
        ////Vector3 _worldUpVector; // runtime up vector ? (would replace entity one if we want to handle that)
        ////float _maxRadius; // max box diagonal, accelerator for sqrt( sqr( _boxHalfLength ) + sqr( _boxHalfWidth))
        //
        float _maxFrontDistance; // from trailer center to front diagonal
        float _maxBackDistance;  // from trailer center to last tow diagonal

        //// Runtime helper, mask for local ori conservation, when going back to posture
        //// initialized with bone ids;
        ////glm::PODArray<bool> _hasAChildBoneHandledByTraffic;
        ////GlmMap<const HierarchicalBone*, int> _boneToBoneId;
        //PODArray<int> _boneIdToFatherBoneId;
    };
} // namespace glm
