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

#pragma once

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

#include <glmGolaemCharacterDeclarations.h> // GolaemCharacter declarations

namespace glm
{
    struct BonePhysicConfigurationV0;

    class GLM_CORE_API BonePhysicConfigurationV1
    {
        GLM_RTTI("de6f6c55-e703-4602-9288-f3ceeb51c44f", glm::BonePhysicConfigurationV1, addAttributes);

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

        BonePhysicConfigurationV1();
        bool operator==(const BonePhysicConfigurationV1& source) const;

    public: //data
        /**
		* \brief V0 backwards compatibility
		*/
        BonePhysicConfigurationV1(const BonePhysicConfigurationV0& physicConfigV0);
        void operator=(const BonePhysicConfigurationV0& physicConfigV0);

        //************************************************************
        //! @name Rigid body Configuration
        //************************************************************
        //@{
        uint32_t _colorABGR; //which means that we get rgba when casted into uint8_t[4] ( const uint8_t* rgba = reinterpret_cast<const uint8_t*>(&_colorABGR); )
        bool _inUse;
        bool _automaticDimensions;
        Vector3 _halfExtents;
        bool _useMassInsteadOfBodyDensity;
        float _bodyDensity;
        int _bodyShape; //!<interpreted as a RagdollRigidBodyShape

        Quaternion _localOrientationOffset;
        Vector3 _localPositionOffset;

        float _restitution;
        float _friction;
        float _linearDamping;
        float _angularDamping;
        float _deactivationTime;         //deprecated, the one from the context is now the one used
        float _linearSleepingThreshold;  //deprecated, the one from the context is now the one used
        float _angularSleepingThreshold; //deprecated, the one from the context is now the one used
        //@}

        //************************************************************
        //! @name Joint with parent configuration
        //************************************************************
        //@{
        Vector3 _jointAngularLowerLimit;
        Vector3 _jointAngularUpperLimit;
        float _linearConstraintForceMixing;    //deprecated, the one from the context is now the one used
        float _angularConstraintForceMixing;   //deprecated, the one from the context is now the one used
        float _linearErrorReductionParameter;  //deprecated, the one from the context is now the one used
        float _angularErrorReductionParameter; //deprecated, the one from the context is now the one used
                                               //@}

    public: //methods
        float getVolume() const;
        float getMass() const;
        float getDensity() const;

        void setLocalOffsetFromWordTransforms(const Quaternion& boneLocalOffset, const Vector3& boneWorldPosition, const Quaternion& boneWorldOrientation, const Vector3& rigidBodyWorldPosition, const Quaternion& rigidBodyWorldOrientation);
        void getRigidBodyWordTransformsFromPosture(Vector3& outRigidBodyPosition, Quaternion& outRigidBodyOrientation, const Quaternion& boneLocalOffsetsInverse, const Vector3& boneWorldPosition, const Quaternion& boneWorldOrientation) const;

    private:
        /**
		* \brief register the inspectable attributes to the class RTTI
		*/
        static void addAttributes();
    };
} // namespace glm
