aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/util')
-rw-r--r--src/util/numeric.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/util/numeric.h b/src/util/numeric.h
index be3e49c56..ff4d89ec4 100644
--- a/src/util/numeric.h
+++ b/src/util/numeric.h
@@ -255,6 +255,17 @@ inline v3s16 floatToInt(v3f p, f32 d)
}
/*
+ Returns integer position of node in given double precision position
+ */
+inline v3s16 doubleToInt(v3d p, double d)
+{
+ return v3s16(
+ (p.X + (p.X > 0 ? d / 2 : -d / 2)) / d,
+ (p.Y + (p.Y > 0 ? d / 2 : -d / 2)) / d,
+ (p.Z + (p.Z > 0 ? d / 2 : -d / 2)) / d);
+}
+
+/*
Returns floating point position of node in given integer position
*/
inline v3f intToFloat(v3s16 p, f32 d)