Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions rts/Game/UnsyncedGameCommands.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */
#include <array>
#include <format>
#include <functional>
#include <tuple>

Expand Down
8 changes: 8 additions & 0 deletions rts/System/Matrix44f.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <memory.h>
#include <algorithm>
#include <cstring>
#include <format>

#include "System/simd_compat.h"

Expand All @@ -18,6 +19,13 @@ CR_BIND(CMatrix44f, )
CR_REG_METADATA(CMatrix44f, CR_MEMBER(m))

static_assert(alignof(CMatrix44f) == 64);

std::string CMatrix44f::str() const
{
return std::format(
"m44(\n{:.3f} {:.3f} {:.3f} {:.3f}\n{:.3f} {:.3f} {:.3f} {:.3f}\n{:.3f} {:.3f} {:.3f} {:.3f}\n{:.3f} {:.3f} {:.3f} {:.3f})",
m[0], m[4], m[8], m[12], m[1], m[5], m[9], m[13], m[2], m[6], m[10], m[14], m[3], m[7], m[11], m[15]);
}
CMatrix44f::CMatrix44f(const CMatrix44f& mat)
{
memcpy(&m[0], &mat.m[0], sizeof(CMatrix44f));
Expand Down
6 changes: 1 addition & 5 deletions rts/System/Matrix44f.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,7 @@ class CMatrix44f
float4 col[4];
};

std::string str() const {
return std::format(
"m44(\n{:.3f} {:.3f} {:.3f} {:.3f}\n{:.3f} {:.3f} {:.3f} {:.3f}\n{:.3f} {:.3f} {:.3f} {:.3f}\n{:.3f} {:.3f} {:.3f} {:.3f})",
m[0], m[4], m[8], m[12], m[1], m[5], m[9], m[13], m[2], m[6], m[10], m[14], m[3], m[7], m[11], m[15]);
}
std::string str() const;
};


Expand Down
2 changes: 2 additions & 0 deletions rts/System/Sync/DumpHistory.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */

#include <format>

#include "DumpHistory.h"
#include "SyncChecker.h"

Expand Down
6 changes: 6 additions & 0 deletions rts/System/float3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include <algorithm>
#include <cstring>
#include <format>

#include "System/creg/creg_cond.h"
#include "System/SpringMath.h"
Expand All @@ -15,6 +16,11 @@ CR_REG_METADATA(float3, (CR_MEMBER(x), CR_MEMBER(y), CR_MEMBER(z)))
float float3::maxxpos = -1.0f;
float float3::maxzpos = -1.0f;

std::string float3::str() const
{
return std::format("float3({:.3f}, {:.3f}, {:.3f})", x, y, z);
}

float3 float3::PickNonParallel() const
{
// https://math.stackexchange.com/questions/3122010/how-to-deterministically-pick-a-vector-that-is-guaranteed-to-be-non-parallel-to
Expand Down
6 changes: 2 additions & 4 deletions rts/System/float3.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <cassert>
#include <array>
#include <utility>
#include <format>
#include <string>

#include "System/BranchPrediction.h"
#include "System/creg/creg_cond.h"
Expand Down Expand Up @@ -838,9 +838,7 @@ class float3
static constexpr float cmp_eps() { return 1e-04f; }
static constexpr float nrm_eps() { return 1e-12f; }

std::string str() const {
return std::format("float3({:.3f}, {:.3f}, {:.3f})", x, y, z);
}
std::string str() const;

/**
* @brief max x pos
Expand Down
7 changes: 7 additions & 0 deletions rts/System/float4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@
#include "System/creg/creg_cond.h"
#include "System/SpringMath.h"

#include <format>

CR_BIND(float4, )
CR_REG_METADATA(float4, (CR_MEMBER(x), CR_MEMBER(y), CR_MEMBER(z), CR_MEMBER(w)))

std::string float4::str() const
{
return std::format("float4({:.3f}, {:.3f}, {:.3f}, {:.3f})", x, y, z, w);
}

// ensure that we use a continuous block of memory
// (required for passing to gl functions)
static_assert(sizeof(float4) == 4 * sizeof(float), "");
Expand Down
4 changes: 1 addition & 3 deletions rts/System/float4.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,7 @@ struct float4 : public float3
return (x * f.x) + (y * f.y) + (z * f.z) + (w * f.w);
}

std::string str() const {
return std::format("float4({:.3f}, {:.3f}, {:.3f}, {:.3f})", x, y, z, w);
}
std::string str() const;


/// Allows implicit conversion to float* (for passing to gl functions)
Expand Down