mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-01 17:38:41 +00:00
Rework object attachment handling to fix bugs (#14825)
This commit is contained in:
parent
a0e33ba9ea
commit
85e717fcd1
17 changed files with 245 additions and 172 deletions
|
@ -439,6 +439,17 @@ inline u32 npot2(u32 orig) {
|
|||
return orig + 1;
|
||||
}
|
||||
|
||||
// Distance between two values in a wrapped (circular) system
|
||||
template<typename T>
|
||||
inline unsigned wrappedDifference(T a, T b, const T maximum)
|
||||
{
|
||||
if (a > b)
|
||||
std::swap(a, b);
|
||||
// now b >= a
|
||||
unsigned s = b - a, l = static_cast<unsigned>(maximum - b) + a + 1;
|
||||
return std::min(s, l);
|
||||
}
|
||||
|
||||
// Gradual steps towards the target value in a wrapped (circular) system
|
||||
// using the shorter of both ways
|
||||
template<typename T>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue