ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/include/util.h
(Generate patch)

Comparing deliantra/server/include/util.h (file contents):
Revision 1.114 by root, Sat Apr 23 04:56:51 2011 UTC vs.
Revision 1.115 by root, Tue Apr 26 14:41:36 2011 UTC

252#else 252#else
253 return dx_ + dy_ - min (dx_, dy_) * 5 / 8; 253 return dx_ + dy_ - min (dx_, dy_) * 5 / 8;
254#endif 254#endif
255} 255}
256 256
257// can be substantially faster than floor, if your value range allows for it
258template<typename T>
259inline T
260fastfloor (T x)
261{
262 return std::floor (x);
263}
264
265inline float
266fastfloor (float x)
267{
268 return sint32(x) - (x < 0);
269}
270
271inline double
272fastfloor (double x)
273{
274 return sint64(x) - (x < 0);
275}
276
257/* 277/*
258 * absdir(int): Returns a number between 1 and 8, which represent 278 * absdir(int): Returns a number between 1 and 8, which represent
259 * the "absolute" direction of a number (it actually takes care of 279 * the "absolute" direction of a number (it actually takes care of
260 * "overflow" in previous calculations of a direction). 280 * "overflow" in previous calculations of a direction).
261 */ 281 */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines