diff options
author | Perttu Ahola <celeron55@gmail.com> | 2011-02-21 00:45:14 +0200 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2011-02-21 00:45:14 +0200 |
commit | c57637b4c39319e0c0d5d80d0ae2884aec66d691 (patch) | |
tree | 72ba35937c701ec32d07bba3b6dde6fb2a9f2bc0 /src/utility.h | |
parent | f5ff378dd02431cdcf658b210509b170ea2135d1 (diff) | |
download | minetest-c57637b4c39319e0c0d5d80d0ae2884aec66d691.tar.gz minetest-c57637b4c39319e0c0d5d80d0ae2884aec66d691.tar.bz2 minetest-c57637b4c39319e0c0d5d80d0ae2884aec66d691.zip |
Temporary commit; lots of test code and stuff
Diffstat (limited to 'src/utility.h')
-rw-r--r-- | src/utility.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/utility.h b/src/utility.h index 8c81aba91..8db2c2760 100644 --- a/src/utility.h +++ b/src/utility.h @@ -1738,5 +1738,30 @@ inline std::string wrap_rows(const std::string &from, u32 rowlen) #define MYMIN(a,b) ((a)<(b)?(a):(b)) #define MYMAX(a,b) ((a)>(b)?(a):(b)) +/* + Returns integer position of node in given floating point position +*/ +inline v3s16 floatToInt(v3f p, f32 d) +{ + v3s16 p2( + (p.X + (p.X>0 ? BS/2 : -BS/2))/d, + (p.Y + (p.Y>0 ? BS/2 : -BS/2))/d, + (p.Z + (p.Z>0 ? BS/2 : -BS/2))/d); + return p2; +} + +/* + Returns floating point position of node in given integer position +*/ +inline v3f intToFloat(v3s16 p, f32 d) +{ + v3f p2( + (f32)p.X * d, + (f32)p.Y * d, + (f32)p.Z * d + ); + return p2; +} + #endif |