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

#pragma once

//golaem motion includes
#include "glmSDKAPI.h"
#include "glmMotionDefinitions.h"
#include <glmAttribute.h>
#include "glmAccessorsAttribute.h"
#include <glmGolaemMotionDeclarations.h> // GolaemMotion declarations

namespace glm
{
	struct GLM_SDK_API GenericSkeletonV3
	{
		GLM_RTTI("a6a18c1c-7fac-4a99-a943-ff18f0b13210", glm::GenericSkeletonV3, addAttributes)

	public:

		GLM_CLASS_STAT_ID( glm::MemoryStatIds::Simulation)

		GenericSkeletonV3();
		~GenericSkeletonV3();

		void finish();			

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

		/**
		* \brief Force children arrays computation in all bones (by default they are NULL)
		*/
		inline bool getComputeBonesChildren() const;
		void setComputeBonesChildren(bool);

	private:
		GLM_DISALLOW_COPY_AND_ASSIGN(GenericSkeletonV3)

	public:
		//************************************************************
		// Bones
		//************************************************************
		//@{
		GenericBone* _rootBone;
		int _nbSpineBones;	//int for serialization purposes... should be size_t
		int _nbLimbBones;
		int _nbEffectorBones;
		glm::Array<GenericBone> _bones;
		glm::PODArray<GenericBone*> _parenting;

		int _blendShapesCount;
		glm::PODArray<int>  _blendShapeGroupIds;
		//@}

		//************************************************************
		// Additional data
		//************************************************************
		//@{
		glm::PODArray<int> _limbCoronalLocations;	//!< an array which size is _locationArraysSize. The value at index i is the coronal location of the generic bone 1+_nbSpineBones+(i*2)
		glm::PODArray<int> _limbTransverseLocations;	//!< an array which size is _locationArraysSize. The value at index i is the coronal location of the generic bone 1+_nbSpineBones+(i*2)
		glm::PODArray<int> _limbSagittalLocations;	//!< an array which size is _locationArraysSize. The value at index i is the coronal location of the generic bone 1+_nbSpineBones+(i*2)

		glm::PODArray<int> _mirrorSources;

		float _rootHeight;
		//@}

		//************************************************************
		// Cached bones positions and orientations
		//************************************************************
		//@{
		glm::Array<Vector3> _boneWorldPositions;
		glm::Array<Vector3> _EOBWorldPositions;
		glm::Array<Quaternion> _boneWorldOrientations;
		glm::Array<Quaternion> _EOBWorldOrientations;

		glm::PODArray<float> _minimalBoneRatios;
		glm::PODArray<float> _maximalBoneRatios;
		//@}
	};

	//************************************************************
	// Definition of inline methods
	//************************************************************

	//------------------------------------------------------------
	// getComputeBonesChildren
	//------------------------------------------------------------
	inline bool GenericSkeletonV3::getComputeBonesChildren() const
	{ 
		return true; 
	}
}

