Refactor TimingData::ScaleRegion(), fixes 297.
This commit is contained in:
+17
-1
@@ -334,7 +334,23 @@ static inline float ToBeat(int row) { return NoteRowToBeat(row); }
|
||||
*/
|
||||
static inline float ToBeat(float beat) { return beat; }
|
||||
|
||||
|
||||
/**
|
||||
* @brief Scales the position.
|
||||
* @param T start - the starting row of the scaling region
|
||||
* @param T length - the length of the scaling region
|
||||
* @param T newLength - the new length of the scaling region
|
||||
* @param T position - the position to scale
|
||||
* @return T the scaled position
|
||||
*/
|
||||
template<typename T>
|
||||
inline T ScalePosition( T start, T length, T newLength, T position )
|
||||
{
|
||||
if( position < start )
|
||||
return position;
|
||||
if( position >= start + length )
|
||||
return position - length + newLength;
|
||||
return start + (position - start) * newLength / length;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user