///return the local value of parameter
btScalar btHingeConstraint::getParam(int num, int axis) const 
{
	btScalar retVal = 0;
	if((axis == -1) || (axis == 5))
	{
		switch(num)
		{	
			case BT_CONSTRAINT_STOP_ERP :
				btAssertConstrParams(m_flags & BT_HINGE_FLAGS_ERP_STOP);
				retVal = m_stopERP;
				break;
			case BT_CONSTRAINT_STOP_CFM :
				btAssertConstrParams(m_flags & BT_HINGE_FLAGS_CFM_STOP);
				retVal = m_stopCFM;
				break;
			case BT_CONSTRAINT_CFM :
				btAssertConstrParams(m_flags & BT_HINGE_FLAGS_CFM_NORM);
				retVal = m_normalCFM;
				break;
			default : 
				btAssertConstrParams(0);
		}
	}
	else
	{
		btAssertConstrParams(0);
	}
	return retVal;
}
///return the local value of parameter
btScalar btPoint2PointConstraint::getParam(int num, int axis) const 
{
	btScalar retVal(SIMD_INFINITY);
	if(axis != -1)
	{
		btAssertConstrParams(0);
	}
	else
	{
		switch(num)
		{
			case BT_CONSTRAINT_ERP :
			case BT_CONSTRAINT_STOP_ERP :
				btAssertConstrParams(m_flags & BT_P2P_FLAGS_ERP);
				retVal = m_erp; 
				break;
			case BT_CONSTRAINT_CFM :
			case BT_CONSTRAINT_STOP_CFM :
				btAssertConstrParams(m_flags & BT_P2P_FLAGS_CFM);
				retVal = m_cfm; 
				break;
			default: 
				btAssertConstrParams(0);
		}
	}
	return retVal;
}
///override the default global value of a parameter (such as ERP or CFM), optionally provide the axis (0..5). 
///If no axis is provided, it uses the default axis for this constraint.
void btHingeConstraint::setParam(int num, btScalar value, int axis)
{
	if((axis == -1) || (axis == 5))
	{
		switch(num)
		{	
			case BT_CONSTRAINT_STOP_ERP :
				m_stopERP = value;
				m_flags |= BT_HINGE_FLAGS_ERP_STOP;
				break;
			case BT_CONSTRAINT_STOP_CFM :
				m_stopCFM = value;
				m_flags |= BT_HINGE_FLAGS_CFM_STOP;
				break;
			case BT_CONSTRAINT_CFM :
				m_normalCFM = value;
				m_flags |= BT_HINGE_FLAGS_CFM_NORM;
				break;
			default : 
				btAssertConstrParams(0);
		}
	}
	else
	{
		btAssertConstrParams(0);
	}
}
///override the default global value of a parameter (such as ERP or CFM), optionally provide the axis (0..5). 
///If no axis is provided, it uses the default axis for this constraint.
void btPoint2PointConstraint::setParam(int num, btScalar value, int axis)
{
	if(axis != -1)
	{
		btAssertConstrParams(0);
	}
	else
	{
		switch(num)
		{
			case BT_CONSTRAINT_ERP :
			case BT_CONSTRAINT_STOP_ERP :
				m_erp = value; 
				m_flags |= BT_P2P_FLAGS_ERP;
				break;
			case BT_CONSTRAINT_CFM :
			case BT_CONSTRAINT_STOP_CFM :
				m_cfm = value; 
				m_flags |= BT_P2P_FLAGS_CFM;
				break;
			default: 
				btAssertConstrParams(0);
		}
	}
}
///override the default global value of a parameter (such as ERP or CFM), optionally provide the axis (0..5). 
///If no axis is provided, it uses the default axis for this constraint.
void btConeTwistConstraint::setParam(int num, btScalar value, int axis)
{
	switch(num)
	{
		case BT_CONSTRAINT_ERP :
		case BT_CONSTRAINT_STOP_ERP :
			if((axis >= 0) && (axis < 3)) 
			{
				m_linERP = value;
				m_flags |= BT_CONETWIST_FLAGS_LIN_ERP;
			}
			else
			{
				m_biasFactor = value;
			}
			break;
		case BT_CONSTRAINT_CFM :
		case BT_CONSTRAINT_STOP_CFM :
			if((axis >= 0) && (axis < 3)) 
			{
				m_linCFM = value;
				m_flags |= BT_CONETWIST_FLAGS_LIN_CFM;
			}
			else
			{
				m_angCFM = value;
				m_flags |= BT_CONETWIST_FLAGS_ANG_CFM;
			}
			break;
		default:
			btAssertConstrParams(0);
			break;
	}
}
///return the local value of parameter
btScalar btConeTwistConstraint::getParam(int num, int axis) const 
{
	btScalar retVal = 0;
	switch(num)
	{
		case BT_CONSTRAINT_ERP :
		case BT_CONSTRAINT_STOP_ERP :
			if((axis >= 0) && (axis < 3)) 
			{
				btAssertConstrParams(m_flags & BT_CONETWIST_FLAGS_LIN_ERP);
				retVal = m_linERP;
			}
			else if((axis >= 3) && (axis < 6)) 
			{
				retVal = m_biasFactor;
			}
			else
			{
				btAssertConstrParams(0);
			}
			break;
		case BT_CONSTRAINT_CFM :
		case BT_CONSTRAINT_STOP_CFM :
			if((axis >= 0) && (axis < 3)) 
			{
				btAssertConstrParams(m_flags & BT_CONETWIST_FLAGS_LIN_CFM);
				retVal = m_linCFM;
			}
			else if((axis >= 3) && (axis < 6)) 
			{
				btAssertConstrParams(m_flags & BT_CONETWIST_FLAGS_ANG_CFM);
				retVal = m_angCFM;
			}
			else
			{
				btAssertConstrParams(0);
			}
			break;
		default : 
			btAssertConstrParams(0);
	}
	return retVal;
}
Example #7
0
///return the local value of parameter
btScalar btSliderConstraint::getParam(int num, int axis) const 
{
	btScalar retVal(SIMD_INFINITY);
	switch(num)
	{
	case BT_CONSTRAINT_STOP_ERP :
		if(axis < 1)
		{
			btAssertConstrParams(m_flags & BT_SLIDER_FLAGS_ERP_LIMLIN);
			retVal = m_softnessLimLin;
		}
		else if(axis < 3)
		{
			btAssertConstrParams(m_flags & BT_SLIDER_FLAGS_ERP_ORTLIN);
			retVal = m_softnessOrthoLin;
		}
		else if(axis == 3)
		{
			btAssertConstrParams(m_flags & BT_SLIDER_FLAGS_ERP_LIMANG);
			retVal = m_softnessLimAng;
		}
		else if(axis < 6)
		{
			btAssertConstrParams(m_flags & BT_SLIDER_FLAGS_ERP_ORTANG);
			retVal = m_softnessOrthoAng;
		}
		else
		{
			btAssertConstrParams(0);
		}
		break;
	case BT_CONSTRAINT_CFM :
		if(axis < 1)
		{
			btAssertConstrParams(m_flags & BT_SLIDER_FLAGS_CFM_DIRLIN);
			retVal = m_cfmDirLin;
		}
		else if(axis == 3)
		{
			btAssertConstrParams(m_flags & BT_SLIDER_FLAGS_CFM_DIRANG);
			retVal = m_cfmDirAng;
		}
		else
		{
			btAssertConstrParams(0);
		}
		break;
	case BT_CONSTRAINT_STOP_CFM :
		if(axis < 1)
		{
			btAssertConstrParams(m_flags & BT_SLIDER_FLAGS_CFM_LIMLIN);
			retVal = m_cfmLimLin;
		}
		else if(axis < 3)
		{
			btAssertConstrParams(m_flags & BT_SLIDER_FLAGS_CFM_ORTLIN);
			retVal = m_cfmOrthoLin;
		}
		else if(axis == 3)
		{
			btAssertConstrParams(m_flags & BT_SLIDER_FLAGS_CFM_LIMANG);
			retVal = m_cfmLimAng;
		}
		else if(axis < 6)
		{
			btAssertConstrParams(m_flags & BT_SLIDER_FLAGS_CFM_ORTANG);
			retVal = m_cfmOrthoAng;
		}
		else
		{
			btAssertConstrParams(0);
		}
		break;
	}
	return retVal;
}
Example #8
0
///override the default global value of a parameter (such as ERP or CFM), optionally provide the axis (0..5). 
///If no axis is provided, it uses the default axis for this constraint.
void btSliderConstraint::setParam(int num, btScalar value, int axis)
{
	switch(num)
	{
	case BT_CONSTRAINT_STOP_ERP :
		if(axis < 1)
		{
			m_softnessLimLin = value;
			m_flags |= BT_SLIDER_FLAGS_ERP_LIMLIN;
		}
		else if(axis < 3)
		{
			m_softnessOrthoLin = value;
			m_flags |= BT_SLIDER_FLAGS_ERP_ORTLIN;
		}
		else if(axis == 3)
		{
			m_softnessLimAng = value;
			m_flags |= BT_SLIDER_FLAGS_ERP_LIMANG;
		}
		else if(axis < 6)
		{
			m_softnessOrthoAng = value;
			m_flags |= BT_SLIDER_FLAGS_ERP_ORTANG;
		}
		else
		{
			btAssertConstrParams(0);
		}
		break;
	case BT_CONSTRAINT_CFM :
		if(axis < 1)
		{
			m_cfmDirLin = value;
			m_flags |= BT_SLIDER_FLAGS_CFM_DIRLIN;
		}
		else if(axis == 3)
		{
			m_cfmDirAng = value;
			m_flags |= BT_SLIDER_FLAGS_CFM_DIRANG;
		}
		else
		{
			btAssertConstrParams(0);
		}
		break;
	case BT_CONSTRAINT_STOP_CFM :
		if(axis < 1)
		{
			m_cfmLimLin = value;
			m_flags |= BT_SLIDER_FLAGS_CFM_LIMLIN;
		}
		else if(axis < 3)
		{
			m_cfmOrthoLin = value;
			m_flags |= BT_SLIDER_FLAGS_CFM_ORTLIN;
		}
		else if(axis == 3)
		{
			m_cfmLimAng = value;
			m_flags |= BT_SLIDER_FLAGS_CFM_LIMANG;
		}
		else if(axis < 6)
		{
			m_cfmOrthoAng = value;
			m_flags |= BT_SLIDER_FLAGS_CFM_ORTANG;
		}
		else
		{
			btAssertConstrParams(0);
		}
		break;
	}
}