Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Timestep Interpolation (3D) (3.x) #52846

Merged
merged 1 commit into from
Feb 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions core/local_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,22 @@ class LocalVector {
}
}

U erase_multiple_unordered(const T &p_val) {
U from = 0;
U count = 0;
while (true) {
int64_t idx = find(p_val, from);

if (idx == -1) {
break;
}
remove_unordered(idx);
from = idx;
count++;
}
return count;
}

void invert() {
for (U i = 0; i < count / 2; i++) {
SWAP(data[i], data[count - i - 1]);
Expand Down
10 changes: 10 additions & 0 deletions core/math/basis.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ class _NO_DISCARD_CLASS_ Basis {
bool is_rotation() const;

Basis slerp(const Basis &p_to, const real_t &p_weight) const;
_FORCE_INLINE_ Basis lerp(const Basis &p_to, const real_t &p_weight) const;

operator String() const;

Expand Down Expand Up @@ -340,4 +341,13 @@ real_t Basis::determinant() const {
elements[1][0] * (elements[0][1] * elements[2][2] - elements[2][1] * elements[0][2]) +
elements[2][0] * (elements[0][1] * elements[1][2] - elements[1][1] * elements[0][2]);
}

Basis Basis::lerp(const Basis &p_to, const real_t &p_weight) const {
Basis b;
b.elements[0] = elements[0].linear_interpolate(p_to.elements[0], p_weight);
b.elements[1] = elements[1].linear_interpolate(p_to.elements[1], p_weight);
b.elements[2] = elements[2].linear_interpolate(p_to.elements[2], p_weight);

return b;
}
#endif // BASIS_H
Loading