void PeopleInfoManager::reloadData()
{
	restoreContacts();

	requestMyAccount();
	requestContactList();
}
Esempio n. 2
0
std::shared_ptr<PhysicsManagerState> CcdCollisionLoop::doUpdate(const double& dt,
		const std::shared_ptr<PhysicsManagerState>& state)
{
	auto ccdState = state;

	auto& collisionPairs = state->getCollisionPairs();
	std::vector<std::shared_ptr<Collision::CollisionPair>> ccdPairs;
	ccdPairs.reserve(collisionPairs.size());

	std::copy_if(collisionPairs.cbegin(), collisionPairs.cend(), std::back_inserter(ccdPairs),
				 [](const std::shared_ptr<Collision::CollisionPair>& p)
	{
		return p->getType() == Collision::COLLISION_DETECTION_TYPE_CONTINUOUS;
	});

	double timeOfImpact = 0.0;
	double localTimeOfImpact = 0.0;
	std::vector<std::list<std::shared_ptr<Collision::Contact>>> oldContacts;

	bool executedOnce = false;
	size_t iterations = 0;
	for (; iterations < m_maxIterations; ++iterations)
	{
		double epsilon = 1.0 / ((1 - timeOfImpact) * m_epsilonFactor);

		ccdState = m_updateCcdData->update(localTimeOfImpact, ccdState);
		ccdState = m_ccdCollision->update(dt, ccdState);
		ccdState = m_contactFilter->update(dt, ccdState);

		if (m_logger->getThreshold() <= SurgSim::Framework::LOG_LEVEL_DEBUG)
		{
			printContacts(ccdPairs);
		}

		// Find the first impact and filter all contacts beyond a given epsilon
		if (!findEarliestContact(ccdPairs, &localTimeOfImpact))
		{
			break;
		}
		filterLaterContacts(&ccdPairs, epsilon, localTimeOfImpact);

		restoreContacts(&ccdPairs, &oldContacts);

		ccdState = m_constraintGeneration->update(dt, ccdState);
		ccdState = m_buildMlcp->update(dt, ccdState);
		ccdState = m_solveMlcp->update(dt, ccdState);
		ccdState = m_pushResults->update(dt, ccdState);
		executedOnce = true;

		backupContacts(&ccdPairs, &oldContacts);

		timeOfImpact += (1.0 - timeOfImpact) * localTimeOfImpact;
		if (timeOfImpact > 1.0)
		{
			SURGSIM_LOG_SEVERE(m_logger) << "Calculated time of impact is greater " <<
										 "than the parametric upper bound of 1.0 (" <<
										 timeOfImpact << ")" << std::endl;
			break;
		}

		// Lambda == 0 means we are no longer generating corrections. Exit the loop.
		// We will take up the collision detection at the start of the next time step.
		if (ccdState->getMlcpSolution().x.isZero())
		{
			break;
		}
	}

	SURGSIM_LOG_IF(iterations == m_maxIterations, m_logger, WARNING) <<
			"Maxed out iterations (" << m_maxIterations << ")";

	restoreContacts(&ccdPairs, &oldContacts);
	if (!executedOnce)
	{
		ccdState = m_constraintGeneration->update(dt, ccdState);
		ccdState = m_buildMlcp->update(dt, ccdState);
		ccdState = m_solveMlcp->update(dt, ccdState);
		ccdState = m_pushResults->update(dt, ccdState);
	}

	return ccdState;
}