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

#pragma once

#include "glmSDKAPI.h"
#include <glmRTTI.h>
#include <glmGolaemMotionDeclarations.h> // GolaemMotion declarations

namespace glm
{
	/**
	* \brief Represent a generic normalized skeleton
	*
	* \author dev@golaem.com
	*
	*/
	struct GLM_SDK_API GenericSkeletonV1
	{
		GLM_RTTI( "4bb887d2-6e74-4f38-a53d-faf6088e8c39", glm::GenericSkeletonV1, addAttributes )

	public:

		GLM_CLASS_STAT_ID( glm::MemoryStatIds::Simulation)

		GenericSkeletonV1();
		~GenericSkeletonV1();
		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(GenericSkeletonV1)

	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;
		//@}

		//************************************************************
		// 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)

		float _rootHeight;
		//@}

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

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

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

