--- a/main.cpp Sat Mar 16 03:42:04 2013 +0200 +++ b/main.cpp Sat Mar 16 13:08:24 2013 +0200 @@ -2,6 +2,7 @@ #include "gui.h" #include "io.h" #include "bbox.h" +#include "misc.h" vector<OpenFile*> g_LoadedFiles; OpenFile* g_CurrentFile = NULL; @@ -30,26 +31,13 @@ return mid; } -static str getCoordinateRep (double fCoord) { - str zRep = str::mkfmt ("%.3f", fCoord); - - // Remove trailing zeroes - while (zRep[~zRep - 1] == '0') - zRep -= 1; +str vertex::getStringRep (const bool bMangled) { + const char* sFormat = (bMangled) ? "(%s, %s, %s)" : "%s %s %s"; - // If there was only zeroes in the decimal place, remove - // the decimal point now. - if (zRep[~zRep - 1] == '.') - zRep -= 1; - - return zRep; -} - -str vertex::getStringRep () { - return str::mkfmt ("(%s, %s, %s)", - getCoordinateRep (x).chars(), - getCoordinateRep (y).chars(), - getCoordinateRep (z).chars()); + return str::mkfmt (sFormat, + ftoa (x).chars(), + ftoa (y).chars(), + ftoa (z).chars()); } // =============================================================================