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

#pragma once

#include "glmCoreAPI.h"
#include "glmRTTI.h"
#include "glmAssetGroup.h"
#include "glmMeshAssetV5.h"
#include "glmGeometryAssetV3.h"
#include "glmShadingGroup.h"
#include "glmRenderingType.h"
#include "glmGenericSpecificConverterMappingV7.h"
#include "glmCharacterUserData.h"
#include "glmShaderAsset.h"
#include "glmShaderAttributeV2.h"
#include "glmClothAsset.h"
#include "glmGolaemCharacterBlindDataOverride.h"
#include "glmGolaemCharacterSkeletonOverride.h"
#include "glmPhysicsOverride.h"
#include "glmGolaemCharacterInterface.h"

namespace glm
{
    struct GolaemCharacterV17;

    struct GLM_CORE_API GolaemCharacterV18 : public GolaemCharacterInterface
    {
        GLM_VIRTUAL_RTTI("34179ab7-c707-4e79-a57a-b3c049f3ab9f", glm::GolaemCharacterV18, addAttributes);

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

        /// Name of the character
        glm::GlmString _name;
        int _fileVersion;

        glm::PODArray<int> _mainAssetGroups;
        glm::PODArray<int> _mainShaderAttributes;

        glm::Array<AssetGroupV2> _allAssetGroups;
        glm::Array<MeshAssetV5> _meshAssets;

        glm::GlmMap<short, glm::Array<GeometryAssetV3>> _geometryAssetsPerTags;

        glm::Array<ShadingGroupV1> _shadingGroups;

        glm::Array<ShaderAttributeV2> _shaderAttributes;

        glm::Array<ShaderAssetV2> _shaderAssets;

        glm::Array<RenderingTypeV4> _renderingTypes;

        GenericSpecificConverterMappingV7 _converterMapping; // animation data
        CharacterUserDataV0 _characterUserData;              // additional user data

        Array<SkeletonOverrideV0> _skeletonOverrides;
        Array<BlindDataOverrideV0> _blindDataOverrides;
        Array<PhysicsOverrideV0> _physicsOverrides;

        Vector3 _perceptionShapeExtents = Vector3(1.f);
        Vector3 _perceptionShapeOffset = Vector3(0.f);

    public:
        GolaemCharacterV18();
        ~GolaemCharacterV18();

        /**
         * \brief V17 backwards compatibility
         * \note V18 adds perception shape
         */
        void createFromV17(const GolaemCharacterV17& characterV17);

        // Accessors
        const GenericSpecificConverterMappingV7& getConverterMapping() const;
        void setConverterMapping(const GenericSpecificConverterMappingV7& mapping);
        const CharacterUserDataV0& getCharacterUserData() const;
        void setCharacterUserData(const CharacterUserDataV0& userData);

        void autoComputePerceptionShape();

    private:
        GLM_DISALLOW_COPY_AND_ASSIGN(GolaemCharacterV18);
        static void addAttributes();
    };
} // namespace glm
