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

#pragma once
#include "glmSDKAPI.h"
#include "glmPhysX.h"

#include "glmPhysicsDefinitions_PhysX.h"
#include "glmAbstractPhysicsRigidBodyInfo.h"

#include <glmTypes.h>

namespace nvidia
{
	namespace apex
	{
		class ClothingCollision;
		class ClothingActor;
	}
}

namespace glm
{
	class PhysicsWorld_PhysX;
	class RagdollEntityComponent_PhysX;

	/**
	 *
	 * \brief Describe a rigid object in the physics simulation
	 *
	 * \author dev@golaem.com
	 *
	 */
	class GLM_SDK_API PhysicsRigidBody
	{
	public:
		friend class RagdollEntityComponent_PhysX;
		GLM_ABSTRACTCLASS_STAT_ID( glm::MemoryStatIds::Simulation);

	protected:
		/**
		 * \brief default constructor & destructor
		 */
		PhysicsRigidBody();
	public:
		virtual ~PhysicsRigidBody();

		virtual bool init(bool useTriggerShapes) = 0;
		virtual void update(const Time dt) = 0;
		virtual void clean();

		//************************************************************
		//! @name Accessors
		//************************************************************
		//@{
		const physx::PxRigidActor* getRigid() const { return _rigid; }
		physx::PxRigidActor* getRigid() { return _rigid; }
		const physx::PxTransform& getTransform() const { return _transform; }
		//@}

		void setPhysicsWorld(PhysicsWorld_PhysX* physXWorld);

	protected:
		virtual nvidia::apex::ClothingCollision* createClothingCollider(nvidia::apex::ClothingActor* clothingActor) = 0;

	public:
		int					_id;
		uint32_t			_colorABGR;

	protected:
		physx::PxMaterial* _material;
		glm::shapePair _shape;
		physx::PxRigidActor* _rigid;
		physx::PxTransform _transform;
		PhysicsWorld_PhysX* _physXWorld;
		int					_rigidBodyInfoIndex;
		bool				_isInitialized;
	};
}
