--- deliantra/server/include/util.h 2011/04/23 04:56:51 1.114 +++ deliantra/server/include/util.h 2011/04/26 14:41:36 1.115 @@ -254,6 +254,26 @@ #endif } +// can be substantially faster than floor, if your value range allows for it +template +inline T +fastfloor (T x) +{ + return std::floor (x); +} + +inline float +fastfloor (float x) +{ + return sint32(x) - (x < 0); +} + +inline double +fastfloor (double x) +{ + return sint64(x) - (x < 0); +} + /* * absdir(int): Returns a number between 1 and 8, which represent * the "absolute" direction of a number (it actually takes care of