本文整理汇总了C++中Phase::evaluateLength方法的典型用法代码示例。如果您正苦于以下问题:C++ Phase::evaluateLength方法的具体用法?C++ Phase::evaluateLength怎么用?C++ Phase::evaluateLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phase
的用法示例。
在下文中一共展示了Phase::evaluateLength方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getValue
float WalkingEngineKick::getValue(Track track, float externValue)
{
std::vector<Phase>& phases = tracks[track];
const int phasesSize = int(phases.size());
int currentPhase = currentPhases[track];
const bool init = currentPhase < 0;
if(init)
currentPhase = currentPhases[track] = 0;
ASSERT(currentPhase < phasesSize - 1);
Phase* phase = &phases[currentPhase];
Phase* nextPhase = &phases[currentPhase + 1];
if(init)
{
const bool precomputedLength = length >= 0.f;
if(!precomputedLength)
{
phase->evaluateLength(0.f);
nextPhase->evaluateLength(phase->end);
}
phase->evaluatePos(externValue);
nextPhase->evaluatePos(externValue);
Phase* const nextNextPhase = currentPhase + 2 < phasesSize ? &phases[currentPhase + 2] : 0;
if(nextNextPhase)
{
if(!precomputedLength)
nextNextPhase->evaluateLength(nextPhase->end);
nextNextPhase->evaluatePos(externValue);
nextPhase->velocity = ((nextPhase->pos - phase->pos) / phase->length + (nextNextPhase->pos - nextPhase->pos) / nextPhase->length) * 0.5f;
}
}
while(phase->end <= currentPosition)
{
Phase* nextNextPhase = currentPhase + 2 < phasesSize ? &phases[currentPhase + 2] : 0;
if(!nextNextPhase)
{
ASSERT(nextPhase->posValue == 0);
return externValue;
}
currentPhase = ++currentPhases[track];
phase = nextPhase;
nextPhase = nextNextPhase;
if(currentPhase + 2 < phasesSize)
{
nextNextPhase = &phases[currentPhase + 2];
const bool precomputedLength = length >= 0.f;
if(!precomputedLength)
nextNextPhase->evaluateLength(nextPhase->end);
nextNextPhase->evaluatePos(externValue);
nextPhase->velocity = ((nextPhase->pos - phase->pos) / phase->length + (nextNextPhase->pos - nextPhase->pos) / nextPhase->length) * 0.5f;
}
}
if(!phase->posValue)
phase->pos = externValue;
if(!nextPhase->posValue)
nextPhase->pos = externValue;
const float nextRatio = (currentPosition - phase->start) / phase->length;
const float d = phase->pos;
const float c = phase->velocity;
const float v2 = nextPhase->velocity;
const float p2 = nextPhase->pos;
const float p2mcmd = p2 - c - d;
const float a = -2.f * p2mcmd + (v2 - c);
const float b = p2mcmd - a;
const float x = nextRatio;
const float xx = x * x;
return a * xx * x + b * xx + c * x + d;
}