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

#pragma once

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

#include "glmGenericSpecificConverterBone.h"

namespace glm
{
    struct HierarchicalBoneV0;

    struct GenericSpecificConverterBoneV0
    {
        GLM_RTTI("ad59a1da-8fd8-47c6-8535-9a8cb958f05f", glm::GenericSpecificConverterBoneV0, addAttributes)

    public:
        GenericSpecificConverterBoneV0();

        GLM_CLASS_STAT_ID( glm::MemoryStatIds::Simulation)

        //************************************************************
        //! @name Serialized data
        //************************************************************
        //@{
        int _type; //interpreted as a SkeletonPartType::Value

        const HierarchicalBoneV0* _firstBoneOfChain[2];
        const HierarchicalBoneV0* _lastBoneOfChain[2];

        int _coronalLocation;
        int _transverseLocation;
        int _sagittalLocation;

        Vector3 _relativeIkNormalPlane[2];
        bool _computeFullExtentLength[2]; //!< If true, the length of the generic bone will be the sum of all specific bone in the chain. If false, the length of the bone will be the length of the vector going from the first bone to the last bone

        glm::Array<RollAttributesV0> _rollAttributes[2];
        //@}

    private:
        static void addAttributes();

        // These methods are here for serialization purpose only
        const HierarchicalBoneV0* getFirstBoneOfChain(unsigned int index) const
        {
            return _firstBoneOfChain[index];
        }
        void setFirstBoneOfChain(unsigned int index, const HierarchicalBoneV0* bone)
        {
            _firstBoneOfChain[index] = bone;
        }
        const HierarchicalBoneV0* getLastBoneOfChain(unsigned int index) const
        {
            return _lastBoneOfChain[index];
        }
        void setLastBoneOfChain(unsigned int index, const HierarchicalBoneV0* bone)
        {
            _lastBoneOfChain[index] = bone;
        }
        Vector3 getIkNomalPlane(unsigned int index) const
        {
            return _relativeIkNormalPlane[index];
        }
        void setIkNomalPlane(unsigned int index, Vector3 ikNormalPlane)
        {
            _relativeIkNormalPlane[index] = ikNormalPlane;
        }

        bool getComputeFullExtentLength(unsigned int index) const
        {
            return _computeFullExtentLength[index];
        }
        void setComputeFullExtentLength(unsigned int index, bool computeFullExtentLength)
        {
            _computeFullExtentLength[index] = computeFullExtentLength;
        }

        const glm::Array<RollAttributesV0>& getRollAttributes(unsigned int index) const
        {
            return _rollAttributes[index];
        }
        void setRollAttributes(unsigned int index, const glm::Array<RollAttributesV0>& rollAttributes)
        {
            _rollAttributes[index] = rollAttributes;
        }
    };
    //@}
} // namespace glm
