Przeglądaj źródła

core: add to_string(Vector4)

Daniele Bartolini 5 lat temu
rodzic
commit
590b64dc13
2 zmienionych plików z 11 dodań i 0 usunięć
  1. 6 0
      src/core/math/math.cpp
  2. 5 0
      src/core/math/vector4.inl

+ 6 - 0
src/core/math/math.cpp

@@ -119,6 +119,12 @@ const char* to_string(const Vector3& v, char* buf, u32 buf_len)
 	return buf;
 }
 
+const char* to_string(const Vector4& v, char* buf, u32 buf_len)
+{
+	snprintf(buf, buf_len, "%.4f, %.4f, %.4f, %.4f", v.x, v.y, v.z, v.w);
+	return buf;
+}
+
 const char* to_string(const Quaternion& q, char* buf, u32 buf_len)
 {
 	snprintf(buf, buf_len, "%.4f %.4f %.4f %.4f", q.x, q.y, q.z, q.w);

+ 5 - 0
src/core/math/vector4.inl

@@ -216,6 +216,11 @@ inline Vector3 to_vector3(const Vector4& a)
 	return v;
 }
 
+/// Returns a string representing the vector @v.
+/// @note This function is for debugging purposes only and doesn't
+/// output round-trip safe ASCII conversions. Do not use in production.
+const char* to_string(const Vector4& v, char* buf, u32 buf_len);
+
 /// @}
 
 } // namespace crown