mirror of https://github.com/zeldaret/botw.git
Added VFR::getDeltaFrame (#122)
* Added getDeltaFrame and changed getDeltaTime * Replaced getDeltaTime usages with getDeltaFrame * Moved getDeltaTime above getDeltaFrame
This commit is contained in:
parent
bdd6e57d63
commit
fd527f9216
|
@ -111,7 +111,7 @@ void PlacementMgr::x() {
|
|||
|
||||
f32 last_time = mTime;
|
||||
auto* vfr = VFR::instance();
|
||||
mTime += vfr->getDeltaTime();
|
||||
mTime += vfr->getDeltaFrame();
|
||||
mTimeUpdated = s32(last_time) != s32(mTime);
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ void SystemTimers::prepareStageUnload() {}
|
|||
void SystemTimers::incrementCountersAndUpdate() {
|
||||
mFrameCounter++;
|
||||
mFrameCounter2++;
|
||||
f32 deltaTime = VFR::instance()->getDeltaTime();
|
||||
f32 deltaTime = VFR::instance()->getDeltaFrame();
|
||||
mVfrTimer += deltaTime;
|
||||
|
||||
while (mVfrTimer >= 1) {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
namespace ksys {
|
||||
|
||||
void Timer::update(f32* t, f32 rate) {
|
||||
*t += VFR::instance()->getDeltaTime() * rate;
|
||||
*t += VFR::instance()->getDeltaFrame() * rate;
|
||||
}
|
||||
|
||||
void Timer::update() {
|
||||
|
|
|
@ -189,7 +189,7 @@ void VFR::ScopedDeltaSetter::set(u32 include_mask, u32 exclude_mask) {
|
|||
|
||||
f32 raw_delta;
|
||||
const auto delta = vfr->getDeltaAndSetMin(&raw_delta, include_mask, exclude_mask);
|
||||
const auto time = vfr->getDeltaTime();
|
||||
const auto time = vfr->getDeltaFrame();
|
||||
if (delta != time) {
|
||||
mPreviousDelta = raw_delta;
|
||||
if (delta > 0.0)
|
||||
|
|
|
@ -69,7 +69,10 @@ public:
|
|||
// TODO: requires ksys::Sound
|
||||
void resetTimeMultiplier(u32 idx);
|
||||
|
||||
f32 getDeltaTime(u32 core) const { return *mDeltaFrames[core]; }
|
||||
f32 getDeltaFrame(u32 core) const { return *mDeltaFrames[core]; }
|
||||
f32 getDeltaFrame() const { return getDeltaFrame(sead::CoreInfo::getCurrentCoreId()); }
|
||||
|
||||
f32 getDeltaTime(u32 core) const { return *mDeltaTimes[core]; }
|
||||
f32 getDeltaTime() const { return getDeltaTime(sead::CoreInfo::getCurrentCoreId()); }
|
||||
|
||||
f32 getIntervalRatio(u32 core) const { return *mIntervalRatios[core]; }
|
||||
|
@ -77,16 +80,16 @@ public:
|
|||
|
||||
template <typename T>
|
||||
static inline void add(T* value, const T& v) {
|
||||
*value += v * instance()->getDeltaTime();
|
||||
*value += v * instance()->getDeltaFrame();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static inline void multiply(T* value, f32 scalar) {
|
||||
*value *= std::pow(scalar, instance()->getDeltaTime());
|
||||
*value *= std::pow(scalar, instance()->getDeltaFrame());
|
||||
}
|
||||
|
||||
static inline f32 getLerpFactor(f32 t) {
|
||||
return 1.0f - std::pow(1.0f - t, instance()->getDeltaTime());
|
||||
return 1.0f - std::pow(1.0f - t, instance()->getDeltaFrame());
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
@ -97,7 +100,7 @@ public:
|
|||
template <typename T>
|
||||
static inline void lerp(T* value, const T& b, f32 t, f32 max_delta) {
|
||||
const auto f = getLerpFactor(t);
|
||||
const auto max_d = instance()->getDeltaTime() * max_delta;
|
||||
const auto max_d = instance()->getDeltaFrame() * max_delta;
|
||||
const auto diff = b - *value;
|
||||
const auto d = f * sead::Mathf::abs(diff);
|
||||
if (d > max_d)
|
||||
|
@ -109,8 +112,8 @@ public:
|
|||
template <typename T>
|
||||
static inline bool lerp(T* value, const T& b, f32 t, f32 max_delta, f32 min_delta) {
|
||||
const auto f = getLerpFactor(t);
|
||||
const auto max_d = instance()->getDeltaTime() * max_delta;
|
||||
const auto min_d = instance()->getDeltaTime() * min_delta;
|
||||
const auto max_d = instance()->getDeltaFrame() * max_delta;
|
||||
const auto min_d = instance()->getDeltaFrame() * min_delta;
|
||||
|
||||
const auto diff = b - *value;
|
||||
const auto d = f * sead::Mathf::abs(diff);
|
||||
|
@ -132,7 +135,7 @@ public:
|
|||
|
||||
template <typename VectorT>
|
||||
static inline bool chaseVec(VectorT* value, const VectorT& target, f32 t) {
|
||||
const auto delta = instance()->getDeltaTime() * t;
|
||||
const auto delta = instance()->getDeltaFrame() * t;
|
||||
const auto diff = target - *value;
|
||||
const auto norm = diff.length();
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ util::InitTimeInfoEx sInitInfo;
|
|||
|
||||
template <typename T>
|
||||
void updateStatsImpl(const T& value, T* prev_value, T* mean) {
|
||||
const T new_mean = ((*prev_value + value) / 2) * VFR::instance()->getDeltaTime();
|
||||
const T new_mean = ((*prev_value + value) / 2) * VFR::instance()->getDeltaFrame();
|
||||
*prev_value = value;
|
||||
*mean = new_mean;
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ bool VFRValue::lerp(const f32& b, f32 t, f32 max_delta, f32 min_delta) {
|
|||
}
|
||||
|
||||
bool VFRValue::chase(const f32& target, f32 step) {
|
||||
const auto delta = step * VFR::instance()->getDeltaTime();
|
||||
const auto delta = step * VFR::instance()->getDeltaFrame();
|
||||
return sead::Mathf::chase(&value, target, delta);
|
||||
}
|
||||
|
||||
|
|
|
@ -345,14 +345,14 @@ void EnvMgr::updateForcedBloodMoon() {
|
|||
case 1:
|
||||
// Update the forced blood moon timer
|
||||
if (evt::Manager::instance()->hasActiveEvent() || mBloodMoonProhibited) {
|
||||
mForcedBloodMoonTimer -= VFR::instance()->getDeltaTime();
|
||||
mForcedBloodMoonTimer -= VFR::instance()->getDeltaFrame();
|
||||
if (mForcedBloodMoonTimer <= 0.0f) {
|
||||
mForcedBloodMoonTimer = 0.0f;
|
||||
mForcedBloodMoonStatus = 0;
|
||||
mForcedBloodMoonReady = false;
|
||||
}
|
||||
} else {
|
||||
mForcedBloodMoonTimer += VFR::instance()->getDeltaTime();
|
||||
mForcedBloodMoonTimer += VFR::instance()->getDeltaFrame();
|
||||
if (mForcedBloodMoonTimer >= BloodMoonTimerDuration) {
|
||||
mForcedBloodMoonTimer = BloodMoonTimerDuration;
|
||||
mForcedBloodMoonReady = true;
|
||||
|
@ -376,7 +376,7 @@ void EnvMgr::updateForcedBloodMoon() {
|
|||
|
||||
case 3:
|
||||
// Slowly fade out the blood moon state
|
||||
mForcedBloodMoonTimer -= VFR::instance()->getDeltaTime();
|
||||
mForcedBloodMoonTimer -= VFR::instance()->getDeltaFrame();
|
||||
if (mForcedBloodMoonTimer <= 0.0f) {
|
||||
mForcedBloodMoonTimer = 0.0f;
|
||||
mForcedBloodMoonStatus = 0;
|
||||
|
@ -389,14 +389,14 @@ void EnvMgr::updateForcedBloodMoon() {
|
|||
case 4:
|
||||
// [Alternative state 2] Wait for blood moons to be allowed again
|
||||
if (mBloodMoonProhibited && !mDeactivateForcedBloodMoon) {
|
||||
mForcedBloodMoonTimer -= VFR::instance()->getDeltaTime();
|
||||
mForcedBloodMoonTimer -= VFR::instance()->getDeltaFrame();
|
||||
if (mForcedBloodMoonTimer <= 0.0f) {
|
||||
mForcedBloodMoonTimer = 0.0f;
|
||||
mForcedBloodMoonStatus = 0;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
mForcedBloodMoonTimer += VFR::instance()->getDeltaTime();
|
||||
mForcedBloodMoonTimer += VFR::instance()->getDeltaFrame();
|
||||
if (mForcedBloodMoonTimer >= BloodMoonTimerDuration) {
|
||||
mForcedBloodMoonTimer = BloodMoonTimerDuration;
|
||||
mForcedBloodMoonReady = true;
|
||||
|
|
|
@ -317,7 +317,7 @@ void TimeMgr::calc_() {
|
|||
if (!mPlayedDemo103Or997 || evt::Manager::instance()->hasActiveEvent())
|
||||
break;
|
||||
|
||||
const auto delta = mTimeStep * VFR::instance()->getDeltaTime();
|
||||
const auto delta = mTimeStep * VFR::instance()->getDeltaFrame();
|
||||
mIsTimeFlowingNormally = true;
|
||||
mTime += delta;
|
||||
if (mTime >= 24_h) {
|
||||
|
@ -431,7 +431,7 @@ void TimeMgr::calc_() {
|
|||
break;
|
||||
|
||||
case TimeUpdateMode::OnlyUpdateTimeOfDay:
|
||||
mTime += mTimeStep * VFR::instance()->getDeltaTime();
|
||||
mTime += mTimeStep * VFR::instance()->getDeltaFrame();
|
||||
if (mTime >= 24_h)
|
||||
mTime -= 24_h;
|
||||
break;
|
||||
|
|
|
@ -7,7 +7,7 @@ SEAD_SINGLETON_DISPOSER_IMPL(DebugInput)
|
|||
|
||||
void DebugInput::update() {
|
||||
if (mFlags.isOnBit(0)) {
|
||||
mLastDelta += VFR::instance()->getDeltaTime();
|
||||
mLastDelta += VFR::instance()->getDeltaFrame();
|
||||
while (mLastDelta > 30.0) {
|
||||
mLastDelta -= 30.0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue