Initial Commit
This commit is contained in:
commit
6088fc29ed
978 changed files with 353647 additions and 0 deletions
31
src/TimePoint.cpp
Normal file
31
src/TimePoint.cpp
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#include "TimePoint.hpp"
|
||||
|
||||
TimePoint::TimePoint():
|
||||
tp(std::chrono::steady_clock::now()),
|
||||
timeSince(0.0f)
|
||||
{}
|
||||
|
||||
void TimePoint::update_time_point() {
|
||||
tp = std::chrono::steady_clock::now();
|
||||
}
|
||||
|
||||
void TimePoint::update_time_since() {
|
||||
timeSince = std::chrono::duration_cast<std::chrono::duration<float>>(std::chrono::steady_clock::now() - tp).count();
|
||||
}
|
||||
|
||||
float TimePoint::get_time_since() const {
|
||||
return timeSince;
|
||||
}
|
||||
|
||||
TimePoint::operator float() const {
|
||||
return get_time_since();
|
||||
}
|
||||
|
||||
float smooth_two_way_time(float& timeToUpdate, float deltaTime, bool isWay1, float animDuration) {
|
||||
timeToUpdate = std::clamp(isWay1 ? (timeToUpdate + deltaTime) : (timeToUpdate - deltaTime), 0.0f, animDuration);
|
||||
return timeToUpdate / animDuration;
|
||||
}
|
||||
|
||||
WorldVec lerp_world_vec_double(const WorldVec& v1, const WorldVec& v2, double t) {
|
||||
return {FixedPoint::lerp_double(v1.x(), v2.x(), t), FixedPoint::lerp_double(v1.y(), v2.y(), t)};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue