Exemple #1
0
TypedConstraint*	CcdPhysicsEnvironment::getConstraintById(int constraintId)
{
	int numConstraint = m_constraints.size();
	int i;
	for (i=0;i<numConstraint;i++)
	{
		TypedConstraint* constraint = m_constraints[i];
		if (constraint->GetUserConstraintId()==constraintId)
		{
			return constraint;
		}
	}
	return 0;
}
Exemple #2
0
void		CcdPhysicsEnvironment::removeConstraint(int	constraintId)
{
	std::vector<TypedConstraint*>::iterator i;

	for (i=m_constraints.begin();
		!(i==m_constraints.end()); i++)
	{
		TypedConstraint* constraint = (*i);
		if (constraint->GetUserConstraintId() == constraintId)
		{
			std::swap(*i, m_constraints.back());
			m_constraints.pop_back();
			break;
		}
	}

}
Exemple #3
0
void	CcdPhysicsEnvironment::removeCcdPhysicsController(CcdPhysicsController* ctrl)
{

	//also remove constraint

	{
		std::vector<TypedConstraint*>::iterator i;

		for (i=m_constraints.begin();
			!(i==m_constraints.end()); i++)
		{
			TypedConstraint* constraint = (*i);
			if  ((&constraint->GetRigidBodyA() == ctrl->GetRigidBody() ||
				(&constraint->GetRigidBodyB() == ctrl->GetRigidBody())))
			{
				removeConstraint(constraint->GetUserConstraintId());
				//only 1 constraint per constroller
				break;
			}
		}
	}

	{
		std::vector<TypedConstraint*>::iterator i;

		for (i=m_constraints.begin();
			!(i==m_constraints.end()); i++)
		{
			TypedConstraint* constraint = (*i);
			if  ((&constraint->GetRigidBodyA() == ctrl->GetRigidBody() ||
				(&constraint->GetRigidBodyB() == ctrl->GetRigidBody())))
			{
				removeConstraint(constraint->GetUserConstraintId());
				//only 1 constraint per constroller
				break;
			}
		}
	}


	m_collisionWorld->RemoveCollisionObject(ctrl->GetRigidBody());


	{
		std::vector<CcdPhysicsController*>::iterator i =
			std::find(m_controllers.begin(), m_controllers.end(), ctrl);
		if (!(i == m_controllers.end()))
		{
			std::swap(*i, m_controllers.back());
			m_controllers.pop_back();
		}
	}

	//remove it from the triggers
	{
		std::vector<CcdPhysicsController*>::iterator i =
			std::find(m_triggerControllers.begin(), m_triggerControllers.end(), ctrl);
		if (!(i == m_triggerControllers.end()))
		{
			std::swap(*i, m_triggerControllers.back());
			m_triggerControllers.pop_back();
		}
	}


}