main.cpp

changeset 18
a6732098fed8
parent 13
3955ff2a7d72
child 23
69a91c1ff583
--- 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());
 }
 
 // =============================================================================

mercurial