common: add VecStr convenience function

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
This commit is contained in:
Kevin Shanahan 2013-03-02 11:25:40 +10:30
parent a1e0f192c7
commit 625fc2c61b
2 changed files with 20 additions and 0 deletions

View File

@ -75,3 +75,20 @@ VectorNormalize(vec3_t v)
return (vec_t)length;
}
/*
* VecStr - handy shortcut for printf, not thread safe, obviously
*/
const char *
VecStr(const vec3_t vec)
{
static char buffers[4][20];
static int current = 0;
char *buf;
buf = buffers[current++ & 3];
snprintf(buf, sizeof(buffers[0]), "%i %i %i",
(int)vec[0], (int)vec[1], (int)vec[2]);
return buf;
}

View File

@ -107,4 +107,7 @@ void CrossProduct(const vec3_t v1, const vec3_t v2, vec3_t cross);
vec_t VectorNormalize(vec3_t v);
double VectorLength(const vec3_t v);
/* Shortcut for output of warnings/errors */
const char *VecStr(const vec3_t vec);
#endif /* __COMMON_MATHLIB_H__ */