Example #1
0
KX_LodLevel *KX_LodManager::GetLevel(KX_Scene *scene, short previouslod, float distance2)
{
	unsigned short level = 0;
	unsigned short count = m_levels.size();
	distance2 *= (m_distanceFactor * m_distanceFactor);

	while (level < count) {
		if (level == (count - 1)) {
			break;
		}
		// Go here only when we changed of lod.
		if (previouslod == -1) {
			const float loddistance = m_levels[level + 1]->GetDistance();
			if (loddistance * loddistance > distance2) {
				break;
			}
		}
		else if (level == previouslod || level == (previouslod + 1)) {
			const float hystvariance = GetHysteresis(scene, level);
			const float newdistance = m_levels[level + 1]->GetDistance() + hystvariance;
			if (newdistance * newdistance > distance2) {
				break;
			}
		}
		else if (level == (previouslod - 1)) {
			const float hystvariance = GetHysteresis(scene, level);
			const float newdistance = m_levels[level + 1]->GetDistance() - hystvariance;
			if (newdistance * newdistance > distance2) {
				break;
			}
		}
		++level;
	}
	return m_levels[level];
}
wxString GuideAlgorithmHysteresis::GetSettingsSummary()
{
    // return a loggable summary of current mount settings
    return wxString::Format("Hysteresis = %.3f, Aggression = %.3f, Minimum move = %.3f\n",
            GetHysteresis(),
            GetAggression(),
            GetMinMove()
        );
}