summaryrefslogtreecommitdiff
path: root/src/grid.h
diff options
context:
space:
mode:
authorMarius Kintel <marius@kintel.net>2011-04-12 18:35:44 (GMT)
committerMarius Kintel <marius@kintel.net>2011-04-12 18:35:44 (GMT)
commitd24b3cc84d0701a5423925765e515db7df9614c5 (patch)
tree0d63867d8b5a3c6ffe107371caa6b29cf8ad0f02 /src/grid.h
parent633343c47e0d2bced64d47f62e814489b8e76dc2 (diff)
parent1754a970a76c071fff91cc7c716aa0b78b4ac6be (diff)
Ported recent changes to master into the visitor branch
Diffstat (limited to 'src/grid.h')
-rw-r--r--src/grid.h16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/grid.h b/src/grid.h
index 6694cf7..74d72f9 100644
--- a/src/grid.h
+++ b/src/grid.h
@@ -2,8 +2,12 @@
#define GRID_H_
#include <QHash>
-#include <math.h>
+#include "mathc99.h"
+#ifdef WIN32
+typedef __int64 int64_t;
+#else
#include <stdint.h>
+#endif
#include <stdlib.h>
const double GRID_COARSE = 0.001;
@@ -33,8 +37,9 @@ public:
for (int64_t jy = iy - 1; jy <= iy + 1; jy++) {
if (!db.contains(QPair<int64_t,int64_t>(jx, jy)))
continue;
- if (abs(ix-jx) + abs(iy-jy) < dist) {
- dist = abs(ix-jx) + abs(iy-jy);
+ int d = abs(int(ix-jx)) + abs(int(iy-jy));
+ if (d < dist) {
+ dist = d;
ix = jx;
iy = jy;
}
@@ -92,8 +97,9 @@ public:
for (int64_t jz = iz - 1; jz <= iz + 1; jz++) {
if (!db.contains(QPair<QPair<int64_t,int64_t>,int64_t>(QPair<int64_t,int64_t>(jx, jy), jz)))
continue;
- if (abs(ix-jx) + abs(iy-jy) + abs(iz-jz) < dist) {
- dist = abs(ix-jx) + abs(iy-jy) + abs(iz-jz);
+ int d = abs(int(ix-jx)) + abs(int(iy-jy)) + abs(int(iz-jz));
+ if (d < dist) {
+ dist = d;
ix = jx;
iy = jy;
iz = jz;
contact: Jan Huwald // Impressum