summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authoraura <nw@moneybot.cc>2026-03-16 15:40:03 +0100
committeraura <nw@moneybot.cc>2026-03-16 15:40:03 +0100
commit991352b0d2767e6bd1a46f554db4ac9d208c13ad (patch)
treeec89dcc1bf6e5ad21474ee91a8b9d0f8301c7f1c /src/util
parente59a032fb9afac6496acf3fba51a2a329bd0f992 (diff)
finish prop rewrite
Diffstat (limited to 'src/util')
-rw-r--r--src/util/color.h4
-rw-r--r--src/util/string.h8
-rw-r--r--src/util/vector.h8
3 files changed, 16 insertions, 4 deletions
diff --git a/src/util/color.h b/src/util/color.h
index 526cddc..8b1a259 100644
--- a/src/util/color.h
+++ b/src/util/color.h
@@ -1,5 +1,5 @@
#pragma once
-#include "typedef.h"
+#include "string.h"
#include <math.h>
struct CLR {
@@ -166,3 +166,5 @@ struct CLR {
return *this;
}
};
+
+inline STR to_str( CLR c ) { return STR( "%.02f %.02f %.02f %.02f", c.r, c.g, c.b, c.a ); }
diff --git a/src/util/string.h b/src/util/string.h
index 7dfab69..672fb5d 100644
--- a/src/util/string.h
+++ b/src/util/string.h
@@ -274,3 +274,11 @@ struct __str : public LIST<CT> {
using STR = __str<char>;
using WSTR = __str<wchar_t>;
+
+inline STR to_str( F32 f ) { return STR( "%.02f", f ); }
+inline STR to_str( F64 f ) { return STR( "%.02g", f ); }
+inline STR to_str( I32 i ) { return STR( "%d", i ); }
+inline STR to_str( I64 i ) { return STR( "%lld", i ); }
+inline STR to_str( U32 u ) { return STR( "%u", u ); }
+inline STR to_str( U64 u ) { return STR( "%llu", u ); }
+inline STR to_str( void* p ) { return STR( "%llx", (U64)p ); }
diff --git a/src/util/vector.h b/src/util/vector.h
index 854b454..eb386ab 100644
--- a/src/util/vector.h
+++ b/src/util/vector.h
@@ -1,7 +1,7 @@
#pragma once
#include <math.h>
-#include "typedef.h"
+#include "string.h"
static const F32 PI = 3.14159265359f;
static const F32 PIRAD = 0.01745329251f;
@@ -13,7 +13,6 @@ struct VEC2 {
VEC2() { x = y = 0.0f; }
VEC2( F32 X, F32 Y ) { x = X; y = Y; }
- VEC2( const F32* v ) { x = v[0]; y = v[1]; }
VEC2( const VEC2& v ) { x = v.x; y = v.y; }
bool operator==( const VEC2& v ) const { return ( x == v.x && y == v.y ); }
@@ -49,7 +48,6 @@ struct VEC3 {
VEC3() { x = y = z = 0.0f; }
VEC3( F32 X, F32 Y, F32 Z ) { x = X; y = Y; z = Z; }
- VEC3( const F32* v ) { x = v[0]; y = v[1]; z = v[2]; }
VEC3( const VEC3& v ) { x = v.x; y = v.y; z = v.z; }
VEC3( const VEC2& v ) { x = v.x; y = v.y; z = 0.f; }
@@ -250,3 +248,7 @@ inline void angle_vectors( const VEC3& angles, VEC3* forward, VEC3* right, VEC3*
up->z = cr * cp;
}
}
+
+inline STR to_str( VEC2 v ) { return STR( "%.02f, %.02f", v.x, v.y ); }
+inline STR to_str( VEC3 v ) { return STR( "%.02f, %.02f, %.02f", v.x, v.y, v.z ); }
+inline STR to_str( VEC4 v ) { return STR( "%.02f, %.02f, %.02f, %.02f", v.x, v.y, v.z, v.w ); }