diff options
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/numeric.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/util/numeric.h b/src/util/numeric.h index e66af2376..3e82997bd 100644 --- a/src/util/numeric.h +++ b/src/util/numeric.h @@ -140,6 +140,22 @@ inline v3s16 arealim(v3s16 p, s16 d) return p; } +// The naive swap performs better than the xor version +#define SWAP(t, x, y) do { \ + t temp = x; \ + x = y; \ + y = temp; \ +} while (0) + +inline void sortBoxVerticies(v3s16 &p1, v3s16 &p2) { + if (p1.X > p2.X) + SWAP(s16, p1.X, p2.X); + if (p1.Y > p2.Y) + SWAP(s16, p1.Y, p2.Y); + if (p1.Z > p2.Z) + SWAP(s16, p1.Z, p2.Z); +} + /* See test.cpp for example cases. |