diff options
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/numeric.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/util/numeric.h b/src/util/numeric.h index 4a27f657d..573f03788 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) |