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

#pragma once

#include "glmCoreAPI.h"
#include "glmRTTI.h"
#include "glmGenericSpecificConverterBone.h"
#include "glmBonePhysicConfiguration.h"
#include "glmEffectorMirrorSource.h"
#include "glmBlindDataV0.h"
#include "glmHierarchicalSkeletonDescription.h"

namespace glm
{
    class HierarchicalSkeletonDescriptionV1;
    struct GenericSpecificConverterMappingV0;
    struct GenericSpecificConverterMappingV1;
    struct GenericSpecificConverterMappingV2;
    struct GenericSpecificConverterMappingV3;
    struct GenericSpecificConverterMappingV4;
    struct GenericSpecificConverterMappingV5;

    /**
	* \brief Represent the generalization of a skeleton (the conversion from the hierarchical skeleton to the generic skeleton)
	*
	* \author dev@golaem.com
	*
	*/
    struct GLM_CORE_API GenericSpecificConverterMappingV6
    {
        GLM_RTTI("77f60027-9d6b-49a6-8a9d-8266fdfe6e16", glm::GenericSpecificConverterMappingV6, addAttributes)

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

        GenericSpecificConverterMappingV6();
        ~GenericSpecificConverterMappingV6();

        //************************************************************
        //! @name Serialized data
        //************************************************************
        //@{
        HierarchicalSkeletonDescriptionV1* _skeletonDescription;
        int _pelvisBoneIndex;
        glm::Array<GenericSpecificConverterBoneV1> _spineBones;
        glm::Array<GenericSpecificConverterBoneV1> _limbBones;
        glm::Array<GenericSpecificConverterBoneV1> _effectorBones;

        glm::Array<glm::GlmString> _spineBoneNames;
        glm::Array<glm::GlmString> _limbBoneNames;
        glm::Array<glm::GlmString> _effectorBoneNames;

        glm::PODArray<int> _ikExcludedBones; // bones excluded from IK solving

        Vector3 _upAxis;
        Vector3 _frontAxis;

        glm::Array<BonePhysicConfigurationV1> _boneConfigurations;

        glm::PODArray<int> _channelMirrorSources;

        glm::Array<EffectorMirrorSourceV0> _effectorMirrorSources;

        glm::PODArray<float> _groundHeightArray;

        glm::Array<BlindDataV0> _blindDataInfo;

        glm::PODArray<float> _squashStretchWeightsArray;

        glm::PODArray<int> _bonesSnsScaleModes; //int because XML serialization does not support char (only 6bits are needed here)

        glm::PODArray<bool> _cacheAllowed;
        //@}

        /**
		* \brief V5 backwards compatibility
		*/
        void createFromV5(GenericSpecificConverterMappingV5& masterV5);

    private:
        GLM_DISALLOW_COPY_AND_ASSIGN(GenericSpecificConverterMappingV6);

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

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