aboutsummaryrefslogtreecommitdiff
path: root/src/util/numeric.h
diff options
context:
space:
mode:
authorkwolekr <kwolekr@minetest.net>2013-06-22 00:29:44 -0400
committerkwolekr <kwolekr@minetest.net>2013-06-22 01:11:52 -0400
commitc1b829077a3518f3a129eee11887b2358a53f20b (patch)
tree966230881a6fba1ce81d5b356f03c273bb6584dd /src/util/numeric.h
parentb1a74df26d73aab2463ad0f18e04d1970bf83d96 (diff)
downloadminetest-c1b829077a3518f3a129eee11887b2358a53f20b.tar.gz
minetest-c1b829077a3518f3a129eee11887b2358a53f20b.tar.bz2
minetest-c1b829077a3518f3a129eee11887b2358a53f20b.zip
Decoration: Add Schematic decoration type
Diffstat (limited to 'src/util/numeric.h')
-rw-r--r--src/util/numeric.h16
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.