fixes
This commit is contained in:
parent
e4dda0861c
commit
83b45a0dea
9 changed files with 251 additions and 7 deletions
|
|
@ -27,6 +27,19 @@ namespace Crafter {
|
|||
return a + static_cast<T>(elapsed * (b - a));
|
||||
}
|
||||
|
||||
// Template specialization for std::string
|
||||
template <>
|
||||
std::string Lerp<std::string>(std::string a, std::string b, double elapsed) {
|
||||
// Clamp elapsed to [0, 1]
|
||||
if (elapsed < 0.0) elapsed = 0.0;
|
||||
if (elapsed > 1.0) elapsed = 1.0;
|
||||
|
||||
// Number of characters from b to reveal
|
||||
std::size_t len = static_cast<std::size_t>(std::floor(b.size() * elapsed));
|
||||
|
||||
return a + b.substr(0, len);
|
||||
}
|
||||
|
||||
template <typename Tuple, std::size_t... Is>
|
||||
constexpr auto LerpTupleImpl(const Tuple& a, const Tuple& b, double elapsed, std::index_sequence<Is...>) {
|
||||
return std::make_tuple(Lerp(std::get<Is>(a), std::get<Is>(b), elapsed)...);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue