mirror of https://github.com/zeldaret/botw.git
ksys: Refactor VFRVec3f::chase into reusable/inlinable function
Might be useful for https://decomp.me/scratch/n58lh
This commit is contained in:
parent
0bdc0c7611
commit
18510196d9
|
@ -130,6 +130,21 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
template <typename VectorT>
|
||||
static inline bool chaseVec(VectorT* value, const VectorT& target, f32 t) {
|
||||
const auto delta = instance()->getDeltaTime() * t;
|
||||
const auto diff = target - *value;
|
||||
const auto norm = diff.length();
|
||||
|
||||
if (norm <= delta) {
|
||||
value->e = target.e;
|
||||
return true;
|
||||
}
|
||||
|
||||
value->setScaleAdd(delta, (1.0f / norm) * diff, *value);
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
struct TimeSpeedMultipliers : sead::Buffer<TimeSpeedMultiplier> {
|
||||
TimeSpeedMultipliers() {
|
||||
|
|
|
@ -71,17 +71,7 @@ void VFRVec3f::lerp(const sead::Vector3f& b, f32 t) {
|
|||
}
|
||||
|
||||
bool VFRVec3f::chase(const sead::Vector3f& target, f32 t) {
|
||||
const auto delta = VFR::instance()->getDeltaTime() * t;
|
||||
const auto diff = target - value;
|
||||
const auto norm = diff.length();
|
||||
|
||||
if (norm <= delta) {
|
||||
sead::MemUtil::copy(&value, &target, sizeof(value));
|
||||
return true;
|
||||
}
|
||||
|
||||
value += diff * (1.0f / norm) * delta;
|
||||
return false;
|
||||
return VFR::chaseVec(&value, target, t);
|
||||
}
|
||||
|
||||
void VFRValue::setToMax(const f32& max) {
|
||||
|
|
Loading…
Reference in New Issue