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

#pragma once

#include "glmCoreAPI.h"
#include "glmRTTI.h"

#include "glmGenericSpecificConverterBone.h"
#include "glmBonePhysicConfigurationV0.h"
#include "glmEffectorMirrorSource.h"

namespace glm
{
    struct HierarchicalBoneV0;
    struct HierarchicalSkeletonDescriptionV0;

    struct GenericSpecificConverterMappingV0
    {
        GLM_RTTI("b4c8b3e1-b61d-4656-89ba-916b66667178", GenericSpecificConverterMappingV0, addAttributes);

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

        GenericSpecificConverterMappingV0();
        ~GenericSpecificConverterMappingV0();

        //************************************************************
        //! @name Serialized data
        //************************************************************
        //@{
        HierarchicalSkeletonDescriptionV0* _skeletonDescription;

        const HierarchicalBoneV0* _pelvisBone;
        glm::Array<GenericSpecificConverterBoneV0> _spineBones;
        glm::Array<GenericSpecificConverterBoneV0> _limbBones;
        glm::Array<GenericSpecificConverterBoneV0> _effectorBones;
        glm::Array<const HierarchicalBoneV0*> _ikExcludedBones; // bones excluded from IK solving

        Vector3 _upAxis;
        Vector3 _frontAxis;

        glm::Array<BonePhysicConfigurationV0> _boneConfigurations;

        glm::Array<glm::GlmString> _channelNames;

        glm::PODArray<int> _effectorNamesStartIndex; //index in _effectorNames for the effectors of each channel
        glm::PODArray<int> _effectorNamesCount;      //count of effectors names for each channel
        glm::Array<glm::GlmString> _effectorNames;

        glm::PODArray<int> _channelMirrorSources;

        glm::Array<EffectorMirrorSourceV0> _effectorMirrorSources;

        glm::PODArray<float> _groundHeightArray;
        //@}

        const char* getChannelEffectorName(int channelIndex, int effectorIndex) const;

    private:
        GLM_DISALLOW_COPY_AND_ASSIGN(GenericSpecificConverterMappingV0);

        /**
		* \brief register the inspectable attributes to the class RTTI
		*/
        static void addAttributes();

        void finish();
        void clearMappingPart();
    };
} // namespace glm
