GetSpeedMultiplier in ArrowEffects becomes TimingData::GetDisplayedSpeedPercent.
We might need to use it later in other parts (NoteField).
This commit is contained in:
+1
-45
@@ -211,50 +211,6 @@ void ArrowEffects::Update()
|
||||
}
|
||||
}
|
||||
|
||||
float GetSpeedMultiplier( float fSongBeat, float fMusicSeconds, const TimingData &tim )
|
||||
{
|
||||
if( tim.m_SpeedSegments.size() == 0 )
|
||||
return 1.0;
|
||||
|
||||
const int index = tim.GetSpeedSegmentIndexAtBeat( fSongBeat );
|
||||
|
||||
const SpeedSegment &seg = tim.m_SpeedSegments[index];
|
||||
float fStartBeat = NoteRowToBeat(seg.m_iStartRow);
|
||||
float fStartTime = tim.GetElapsedTimeFromBeat( fStartBeat ) - tim.GetDelayAtBeat( fStartBeat );
|
||||
float fEndTime;
|
||||
float fCurTime = fMusicSeconds;
|
||||
|
||||
if( seg.m_usMode == 1 ) // seconds
|
||||
{
|
||||
fEndTime = fStartTime + seg.m_fWait;
|
||||
}
|
||||
else
|
||||
{
|
||||
fEndTime = tim.GetElapsedTimeFromBeat( fStartBeat + seg.m_fWait ) - tim.GetDelayAtBeat( fStartBeat + seg.m_fWait );
|
||||
}
|
||||
|
||||
if( ( index == 0 && tim.m_SpeedSegments[0].m_fWait > 0.0 ) && fCurTime < fStartTime )
|
||||
{
|
||||
return 1.0;
|
||||
}
|
||||
else if( fEndTime >= fCurTime && ( index > 0 || tim.m_SpeedSegments[0].m_fWait > 0.0 ) )
|
||||
{
|
||||
const float fPriorSpeed = ( index == 0 ? 1 : tim.m_SpeedSegments[index - 1].m_fPercent );
|
||||
float fTimeUsed = fCurTime - fStartTime;
|
||||
float fDuration = fEndTime - fStartTime;
|
||||
float fRatioUsed = fDuration == 0.0 ? 1 : fTimeUsed / fDuration;
|
||||
|
||||
float fDistance = fPriorSpeed - seg.m_fPercent;
|
||||
float fRatioNeed = fRatioUsed * -fDistance;
|
||||
return (fPriorSpeed + fRatioNeed);
|
||||
}
|
||||
else
|
||||
{
|
||||
return seg.m_fPercent;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* For visibility testing: if bAbsolute is false, random modifiers must return
|
||||
* the minimum possible scroll speed. */
|
||||
float ArrowEffects::GetYOffset( const PlayerState* pPlayerState, int iCol, float fNoteBeat, float &fPeakYOffsetOut, bool &bIsPastPeakOut, bool bAbsolute )
|
||||
@@ -277,7 +233,7 @@ float ArrowEffects::GetYOffset( const PlayerState* pPlayerState, int iCol, float
|
||||
{
|
||||
float fBeatsUntilStep = fNoteBeat - fSongBeat;
|
||||
float fYOffsetBeatSpacing = fBeatsUntilStep;
|
||||
float fSpeedMultiplier = ( GAMESTATE->m_bInStepEditor || !GAMESTATE->m_bIsUsingStepTiming ) ? 1.0 : GetSpeedMultiplier( position.m_fSongBeatVisible, position.m_fMusicSecondsVisible, pCurSteps->m_Timing );
|
||||
float fSpeedMultiplier = ( GAMESTATE->m_bInStepEditor || !GAMESTATE->m_bIsUsingStepTiming ) ? 1.0 : pCurSteps->m_Timing.GetDisplayedSpeedPercent( position.m_fSongBeatVisible, position.m_fMusicSecondsVisible );
|
||||
fYOffset += fSpeedMultiplier * fYOffsetBeatSpacing * (1-pPlayerState->m_PlayerOptions.GetCurrent().m_fTimeSpacing);
|
||||
}
|
||||
|
||||
|
||||
@@ -1341,6 +1341,50 @@ void TimingData::DeleteRows( int iStartRow, int iRowsToDelete )
|
||||
this->SetBPMAtRow( iStartRow, fNewBPM );
|
||||
}
|
||||
|
||||
float TimingData::GetDisplayedSpeedPercent( float fSongBeat, float fMusicSeconds )
|
||||
{
|
||||
if( m_SpeedSegments.size() == 0 )
|
||||
return 1.0;
|
||||
|
||||
const int index = GetSpeedSegmentIndexAtBeat( fSongBeat );
|
||||
|
||||
const SpeedSegment &seg = m_SpeedSegments[index];
|
||||
float fStartBeat = NoteRowToBeat(seg.m_iStartRow);
|
||||
float fStartTime = GetElapsedTimeFromBeat( fStartBeat ) - GetDelayAtBeat( fStartBeat );
|
||||
float fEndTime;
|
||||
float fCurTime = fMusicSeconds;
|
||||
|
||||
if( seg.m_usMode == 1 ) // seconds
|
||||
{
|
||||
fEndTime = fStartTime + seg.m_fWait;
|
||||
}
|
||||
else
|
||||
{
|
||||
fEndTime = GetElapsedTimeFromBeat( fStartBeat + seg.m_fWait ) - GetDelayAtBeat( fStartBeat + seg.m_fWait );
|
||||
}
|
||||
|
||||
if( ( index == 0 && m_SpeedSegments[0].m_fWait > 0.0 ) && fCurTime < fStartTime )
|
||||
{
|
||||
return 1.0;
|
||||
}
|
||||
else if( fEndTime >= fCurTime && ( index > 0 || m_SpeedSegments[0].m_fWait > 0.0 ) )
|
||||
{
|
||||
const float fPriorSpeed = ( index == 0 ? 1 : m_SpeedSegments[index - 1].m_fPercent );
|
||||
float fTimeUsed = fCurTime - fStartTime;
|
||||
float fDuration = fEndTime - fStartTime;
|
||||
float fRatioUsed = fDuration == 0.0 ? 1 : fTimeUsed / fDuration;
|
||||
|
||||
float fDistance = fPriorSpeed - seg.m_fPercent;
|
||||
float fRatioNeed = fRatioUsed * -fDistance;
|
||||
return (fPriorSpeed + fRatioNeed);
|
||||
}
|
||||
else
|
||||
{
|
||||
return seg.m_fPercent;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void TimingData::TidyUpData()
|
||||
{
|
||||
// If there are no BPM segments, provide a default.
|
||||
|
||||
@@ -1594,6 +1594,8 @@ public:
|
||||
*/
|
||||
void AddSpeedSegment( const SpeedSegment &seg );
|
||||
|
||||
float GetDisplayedSpeedPercent( float fBeat, float fMusicSeconds );
|
||||
|
||||
/**
|
||||
* @brief Determine when the fakes end.
|
||||
* @param iRow The row you start on.
|
||||
|
||||
Reference in New Issue
Block a user