summaryrefslogtreecommitdiffstats
path: root/src/Vector3.h
diff options
context:
space:
mode:
authorpeterbell10 <peterbell10@live.co.uk>2018-09-24 22:33:39 +0200
committerAlexander Harkness <me@bearbin.net>2018-09-24 22:33:39 +0200
commit4727ed20846bb3d1a9eabb27aaaa9c5524129556 (patch)
treed6206a51db95a15fd3dfadb9691c868fc6bd8bd1 /src/Vector3.h
parentAdd BurnsInDaylight to Lua API and Monsters.ini (#4295) (diff)
downloadcuberite-4727ed20846bb3d1a9eabb27aaaa9c5524129556.tar
cuberite-4727ed20846bb3d1a9eabb27aaaa9c5524129556.tar.gz
cuberite-4727ed20846bb3d1a9eabb27aaaa9c5524129556.tar.bz2
cuberite-4727ed20846bb3d1a9eabb27aaaa9c5524129556.tar.lz
cuberite-4727ed20846bb3d1a9eabb27aaaa9c5524129556.tar.xz
cuberite-4727ed20846bb3d1a9eabb27aaaa9c5524129556.tar.zst
cuberite-4727ed20846bb3d1a9eabb27aaaa9c5524129556.zip
Diffstat (limited to '')
-rw-r--r--src/Vector3.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/Vector3.h b/src/Vector3.h
index cb39a6cde..0456b9e2f 100644
--- a/src/Vector3.h
+++ b/src/Vector3.h
@@ -350,6 +350,22 @@ public:
z = -z;
}
+ // tolua_end
+
+ /** Allows formatting a Vector<T> using the same format specifiers as for T
+ e.g. `fmt::format("{0:0.2f}", Vector3f{0.0231f, 1.2146f, 1.0f}) == "{0.02, 1.21, 1.00}"` */
+ template <typename ArgFormatter>
+ friend void format_arg(fmt::BasicFormatter<char, ArgFormatter> & a_Formatter, const char *& a_FormatStr, Vector3 a_Vec)
+ {
+ std::array<T, 3> Data{{a_Vec.x, a_Vec.y, a_Vec.z}};
+
+ a_Formatter.writer() << '{';
+ fmt::format_arg(a_Formatter, a_FormatStr, fmt::join(Data.cbegin(), Data.cend(), ", "));
+ a_Formatter.writer() << '}';
+ }
+
+ // tolua_begin
+
/** The max difference between two coords for which the coords are assumed equal. */
static const double EPS;