Keyframe::GetInt() and Keyframe::GetLong() use GetValue

GetInt(), GetLong() are exactly the same as GetValue() except that
their result is rounded and converted to the repsective data type.
Thus avoid code duplication and use GetValue().
This commit is contained in:
Daniel Jour
2019-11-19 21:41:08 +01:00
parent 280504f007
commit 5ba0ecfb2b

View File

@@ -251,45 +251,13 @@ double Keyframe::GetValue(int64_t index)
// Get the rounded INT value at a specific index
int Keyframe::GetInt(int64_t index)
{
// Check if it needs to be processed
if (needs_update)
Process();
// Is index a valid point?
if (index >= 0 && index < Values.size())
// Return value
return int(round(Values[index].Y));
else if (index < 0 && Values.size() > 0)
// Return the minimum value
return int(round(Values[0].Y));
else if (index >= Values.size() && Values.size() > 0)
// return the maximum value
return int(round(Values[Values.size() - 1].Y));
else
// return a blank coordinate (0,0)
return 0;
return int(round(GetValue(index)));
}
// Get the rounded INT value at a specific index
int64_t Keyframe::GetLong(int64_t index)
{
// Check if it needs to be processed
if (needs_update)
Process();
// Is index a valid point?
if (index >= 0 && index < Values.size())
// Return value
return long(round(Values[index].Y));
else if (index < 0 && Values.size() > 0)
// Return the minimum value
return long(round(Values[0].Y));
else if (index >= Values.size() && Values.size() > 0)
// return the maximum value
return long(round(Values[Values.size() - 1].Y));
else
// return a blank coordinate (0,0)
return 0;
return long(round(GetValue(index)));
}
// Get the direction of the curve at a specific index (increasing or decreasing)