///////// Material Manager Class ////////////////////
/// This class handles all calls to newton material
/// manager.
/////////////////////////////////////// IPhysics ////


#include "CMaterialManager.h"

/// Constructor for the class.
CMaterialManager::CMaterialManager()
{
}

/// Initializes the class.
void CMaterialManager::init(NewtonWorld* world)
{
	m_world = world;
}

/// Creates a new material group.
int CMaterialManager::createMaterial()
{
	return NewtonMaterialCreateGroupID(m_world);
}

/// Gets the default newton material.
int CMaterialManager::getDefaultMaterial()
{
	return NewtonMaterialGetDefaultGroupID(m_world);
}

/// Sets whether two materials should be collidable or not.
void CMaterialManager::isCollidable(int material1, int material2, bool collidable)
{
	NewtonMaterialSetDefaultCollidable(m_world, material1, material2, collidable);
}

/// Sets the friction on collision of two materials.
void CMaterialManager::setFriction(int material1, int material2, f32 staticFriction, f32 kineticFriction)
{
	NewtonMaterialSetDefaultFriction(m_world, material1, material2, staticFriction, kineticFriction);
}

/// Sets the elasticity on collision of two materials.
void CMaterialManager::setElasticity(int material1, int material2, f32 elasticity)
{
	NewtonMaterialSetDefaultElasticity(m_world, material1, material2, elasticity);
}

/// Sets the softness on collision of two materials.
void CMaterialManager::setSoftness(int material1, int material2, f32 softness)
{
	NewtonMaterialSetDefaultSoftness(m_world, material1, material2, softness);
}

/// Sets the user callback for collision of two materials.
void CMaterialManager::setUserCollisionCallback(int material1, int material2, IMaterialCallback* callback)
{
	NewtonMaterialSetCollisionCallback(m_world, material1, material2, callback, callback->beginContact, callback->processContact, callback->endContact);
}

/// Sets whether two materials should be continiously
//! processed for collision.
void CMaterialManager::doContinuousCollision(int material1, int material2, bool continiousCollision)
{
	NewtonMaterialSetContinuousCollisionMode(m_world, material1, material2, continiousCollision);
}
