]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - mathlib.h
mathlib: Implement Q_rint and use it
[xonotic/darkplaces.git] / mathlib.h
index aeab1db8b40b03cf40b4bc0169e08863ef874571..55f1218e462d0571a44fd3313ed51292d9f6697b 100644 (file)
--- a/mathlib.h
+++ b/mathlib.h
@@ -83,6 +83,8 @@ unsigned int CeilPowerOf2(unsigned int value);
 #define RAD2DEG(a) ((a) * (180.0f / (float) M_PI))
 #define ANGLEMOD(a) ((a) - 360.0 * floor((a) / 360.0))
 
+#define Q_rint(x) ((x) > 0 ? (int)((x) + 0.5) : (int)((x) - 0.5)) //johnfitz -- from joequake
+
 #define DotProduct2(a,b) ((a)[0]*(b)[0]+(a)[1]*(b)[1])
 #define Vector2Clear(a) ((a)[0]=(a)[1]=0)
 #define Vector2Compare(a,b) (((a)[0]==(b)[0])&&((a)[1]==(b)[1]))