Consolidate various to_string implementations for math classes
Signed-off-by: puvvadar <puvvadar@amazon.com>
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzCore/Math/MathStringConversions.h>
|
||||
#include <AzCore/Math/Aabb.h>
|
||||
#include <AzCore/Math/Color.h>
|
||||
#include <AzCore/Math/Matrix3x3.h>
|
||||
#include <AzCore/Math/Matrix3x4.h>
|
||||
#include <AzCore/Math/Matrix4x4.h>
|
||||
#include <AzCore/Math/Transform.h>
|
||||
#include <AzCore/Math/Quaternion.h>
|
||||
#include <AzCore/Math/Vector2.h>
|
||||
#include <AzCore/Math/Vector3.h>
|
||||
|
||||
namespace AZStd
|
||||
{
|
||||
void to_string(string& str, const AZ::Vector2& value)
|
||||
{
|
||||
str = AZStd::string::format("%.8f,%.8f",
|
||||
static_cast<float>(value.GetX()),
|
||||
static_cast<float>(value.GetY()));
|
||||
}
|
||||
|
||||
void to_string(string& str, const AZ::Vector3& value)
|
||||
{
|
||||
str = AZStd::string::format("%.8f,%.8f,%.8f",
|
||||
static_cast<float>(value.GetX()),
|
||||
static_cast<float>(value.GetY()),
|
||||
static_cast<float>(value.GetZ()));
|
||||
}
|
||||
|
||||
void to_string(string& str, const AZ::Vector4& value)
|
||||
{
|
||||
str = AZStd::string::format("%.8f,%.8f,%.8f,%.8f",
|
||||
static_cast<float>(value.GetX()),
|
||||
static_cast<float>(value.GetY()),
|
||||
static_cast<float>(value.GetZ()),
|
||||
static_cast<float>(value.GetW()));
|
||||
}
|
||||
|
||||
void to_string(string& str, const AZ::Quaternion& value)
|
||||
{
|
||||
str = AZStd::string::format("%.8f,%.8f,%.8f,%.8f",
|
||||
static_cast<float>(value.GetX()),
|
||||
static_cast<float>(value.GetY()),
|
||||
static_cast<float>(value.GetZ()),
|
||||
static_cast<float>(value.GetW()));
|
||||
}
|
||||
|
||||
void to_string(string& str, const AZ::Matrix3x3& value)
|
||||
{
|
||||
str = AZStd::string::format(
|
||||
"%.8f,%.8f,%.8f\n%.8f,%.8f,%.8f\n%.8f,%.8f,%.8f",
|
||||
static_cast<float>(value(0, 0)), static_cast<float>(value(1, 0)), static_cast<float>(value(2, 0)),
|
||||
static_cast<float>(value(0, 1)), static_cast<float>(value(1, 1)), static_cast<float>(value(2, 1)),
|
||||
static_cast<float>(value(0, 2)), static_cast<float>(value(1, 2)), static_cast<float>(value(2, 2)));
|
||||
}
|
||||
|
||||
void to_string(string& str, const AZ::Matrix4x4& value)
|
||||
{
|
||||
str = AZStd::string::format("%.8f,%.8f,%.8f,%.8f\n%.8f,%.8f,%.8f,%.8f\n%.8f,%.8f,%.8f,%.8f\n%.8f,%.8f,%.8f,%.8f",
|
||||
static_cast<float>(value(0, 0)), static_cast<float>(value(1, 0)), static_cast<float>(value(2, 0)), static_cast<float>(value(3, 0)),
|
||||
static_cast<float>(value(0, 1)), static_cast<float>(value(1, 1)), static_cast<float>(value(2, 1)), static_cast<float>(value(3, 1)),
|
||||
static_cast<float>(value(0, 2)), static_cast<float>(value(1, 2)), static_cast<float>(value(2, 2)), static_cast<float>(value(3, 2)),
|
||||
static_cast<float>(value(0, 3)), static_cast<float>(value(1, 3)), static_cast<float>(value(2, 3)), static_cast<float>(value(3, 3)));
|
||||
}
|
||||
|
||||
void to_string(string& str, const AZ::Transform& value)
|
||||
{
|
||||
AZ::Matrix3x4 matrix3x4 = AZ::Matrix3x4::CreateFromTransform(value);
|
||||
|
||||
str = AZStd::string::format("%.8f,%.8f,%.8f\n%.8f,%.8f,%.8f\n%.8f,%.8f,%.8f\n%.8f,%.8f,%.8f",
|
||||
static_cast<float>(matrix3x4(0, 0)), static_cast<float>(matrix3x4(1, 0)), static_cast<float>(matrix3x4(2, 0)),
|
||||
static_cast<float>(matrix3x4(0, 1)), static_cast<float>(matrix3x4(1, 1)), static_cast<float>(matrix3x4(2, 1)),
|
||||
static_cast<float>(matrix3x4(0, 2)), static_cast<float>(matrix3x4(1, 2)), static_cast<float>(matrix3x4(2, 2)),
|
||||
static_cast<float>(matrix3x4(0, 3)), static_cast<float>(matrix3x4(1, 3)), static_cast<float>(matrix3x4(2, 3)));
|
||||
}
|
||||
|
||||
void to_string(string& str, const AZ::Aabb& value)
|
||||
{
|
||||
str = AZStd::string::format(
|
||||
"%.8f,%.8f,%.8f\n%.8f,%.8f,%.8f",
|
||||
static_cast<float>(value.GetMin().GetX()), static_cast<float>(value.GetMin().GetY()),
|
||||
static_cast<float>(value.GetMin().GetZ()), static_cast<float>(value.GetMax().GetX()),
|
||||
static_cast<float>(value.GetMax().GetY()), static_cast<float>(value.GetMax().GetZ()));
|
||||
}
|
||||
|
||||
void to_string(string& str, const AZ::Color& color)
|
||||
{
|
||||
str = AZStd::string::format("R:%d, G:%d, B:%d A:%d", color.GetR8(), color.GetG8(), color.GetB8(), color.GetA8());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/std/functional.h>
|
||||
#include <AzCore/std/string/conversions.h>
|
||||
#include <AzCore/std/string/string.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
class Aabb;
|
||||
class Color;
|
||||
class Matrix3x3;
|
||||
class Matrix4x4;
|
||||
class Quaternion;
|
||||
class Transform;
|
||||
class Vector2;
|
||||
class Vector3;
|
||||
class Vector4;
|
||||
}
|
||||
|
||||
namespace AZStd
|
||||
{
|
||||
//! Prints a Vector2 with precision to 8 decimal points
|
||||
void to_string(string& str, const AZ::Vector2& value);
|
||||
|
||||
//! Prints a Vector3 with precision to 8 decimal points
|
||||
void to_string(string& str, const AZ::Vector3& value);
|
||||
|
||||
//! Prints a Vector4 with precision to 8 decimal points
|
||||
void to_string(string& str, const AZ::Vector4& value);
|
||||
|
||||
//! Prints a Quaternion with precision to 8 decimal points
|
||||
void to_string(string& str, const AZ::Quaternion& value);
|
||||
|
||||
//! Prints a 3x3 matrix in row major order over three lines with precision to 8 decimal points
|
||||
void to_string(string& str, const AZ::Matrix3x3& value);
|
||||
|
||||
//! Prints a 4x4 matrix in row major order over four lines with precision to 8 decimal points
|
||||
void to_string(string& str, const AZ::Matrix4x4& value);
|
||||
|
||||
//! Prints a transform as a 3x4 matrix in row major order over four lines with precision to 8 decimal points
|
||||
void to_string(string& str, const AZ::Transform& value);
|
||||
|
||||
//! Prints an AABB as a pair of Vector3s with precision to 8 decimal points
|
||||
void to_string(string& str, const AZ::Aabb& value);
|
||||
|
||||
//! Prints a Color as four unsigned ints representing RGBA
|
||||
void to_string(string& str, const AZ::Color& value);
|
||||
|
||||
inline AZStd::string to_string(const AZ::Vector2& val) { AZStd::string str; to_string(str, val); return str; }
|
||||
inline AZStd::string to_string(const AZ::Vector3& val) { AZStd::string str; to_string(str, val); return str; }
|
||||
inline AZStd::string to_string(const AZ::Vector4& val) { AZStd::string str; to_string(str, val); return str; }
|
||||
inline AZStd::string to_string(const AZ::Quaternion& val) { AZStd::string str; to_string(str, val); return str; }
|
||||
inline AZStd::string to_string(const AZ::Matrix3x3& val) { AZStd::string str; to_string(str, val); return str; }
|
||||
inline AZStd::string to_string(const AZ::Matrix4x4& val) { AZStd::string str; to_string(str, val); return str; }
|
||||
inline AZStd::string to_string(const AZ::Transform& val) { AZStd::string str; to_string(str, val); return str; }
|
||||
inline AZStd::string to_string(const AZ::Aabb& val) { AZStd::string str; to_string(str, val); return str; }
|
||||
inline AZStd::string to_string(const AZ::Color& val) { AZStd::string str; to_string(str, val); return str; }
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ToString.h"
|
||||
|
||||
#include <AzCore/Math/Vector2.h>
|
||||
#include <AzCore/Math/Vector3.h>
|
||||
#include <AzCore/Math/Vector4.h>
|
||||
#include <AzCore/Math/Quaternion.h>
|
||||
#include <AzCore/Math/Transform.h>
|
||||
#include <AzCore/Math/Matrix3x3.h>
|
||||
#include <AzCore/Math/Matrix4x4.h>
|
||||
#include <AzCore/Math/Color.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
AZStd::string ToString(const AZ::Vector2& vector2)
|
||||
{
|
||||
return AZStd::string::format("(X:%f, Y:%f)", static_cast<float>(vector2.GetX()), static_cast<float>(vector2.GetY()));
|
||||
}
|
||||
|
||||
AZStd::string ToString(const AZ::Vector3& vector3)
|
||||
{
|
||||
return AZStd::string::format("(X:%f, Y:%f, Z:%f)", static_cast<float>(vector3.GetX()), static_cast<float>(vector3.GetY()), static_cast<float>(vector3.GetZ()));
|
||||
}
|
||||
|
||||
AZStd::string ToString(const AZ::Vector4& vector4)
|
||||
{
|
||||
return AZStd::string::format("(X:%f, Y:%f, Z:%f W:%f)", static_cast<float>(vector4.GetX()), static_cast<float>(vector4.GetY()), static_cast<float>(vector4.GetZ()), static_cast<float>(vector4.GetW()));
|
||||
}
|
||||
|
||||
AZStd::string ToString(const AZ::Quaternion& quaternion)
|
||||
{
|
||||
return AZStd::string::format("(X:%f, Y:%f, Z:%f W:%f)", static_cast<float>(quaternion.GetX()), static_cast<float>(quaternion.GetY()), static_cast<float>(quaternion.GetZ()), static_cast<float>(quaternion.GetW()));
|
||||
}
|
||||
|
||||
AZStd::string ToString(const AZ::Transform& transform)
|
||||
{
|
||||
AZ::Vector3 cols[4];
|
||||
transform.GetBasisAndTranslation(&cols[0], &cols[1], &cols[2], &cols[3]);
|
||||
|
||||
return AZStd::string::format(
|
||||
"[%f, %f, %f, %f]\n"
|
||||
"[%f, %f, %f, %f]\n"
|
||||
"[%f, %f, %f, %f]",
|
||||
cols[0].GetX(), cols[1].GetX(), cols[2].GetX(), cols[3].GetX(),
|
||||
cols[0].GetY(), cols[1].GetY(), cols[2].GetY(), cols[3].GetY(),
|
||||
cols[0].GetZ(), cols[1].GetZ(), cols[2].GetZ(), cols[3].GetZ()
|
||||
);
|
||||
}
|
||||
|
||||
AZStd::string ToString(const AZ::Matrix3x3& matrix33)
|
||||
{
|
||||
auto row1 = matrix33.GetRow(0);
|
||||
auto row2 = matrix33.GetRow(1);
|
||||
auto row3 = matrix33.GetRow(2);
|
||||
|
||||
return AZStd::string::format(
|
||||
"[%f, %f, %f]\n"
|
||||
"[%f, %f, %f]\n"
|
||||
"[%f, %f, %f]",
|
||||
static_cast<float>(row1.GetX()), static_cast<float>(row1.GetY()), static_cast<float>(row1.GetZ()),
|
||||
static_cast<float>(row2.GetX()), static_cast<float>(row2.GetY()), static_cast<float>(row2.GetZ()),
|
||||
static_cast<float>(row3.GetX()), static_cast<float>(row3.GetY()), static_cast<float>(row3.GetZ())
|
||||
);
|
||||
}
|
||||
|
||||
AZStd::string ToString(const AZ::Matrix4x4& matrix44)
|
||||
{
|
||||
auto row1 = matrix44.GetRow(0);
|
||||
auto row2 = matrix44.GetRow(1);
|
||||
auto row3 = matrix44.GetRow(2);
|
||||
auto row4 = matrix44.GetRow(3);
|
||||
|
||||
return AZStd::string::format(
|
||||
"[%f, %f, %f %f]\n"
|
||||
"[%f, %f, %f %f]\n"
|
||||
"[%f, %f, %f %f]\n"
|
||||
"[%f, %f, %f %f]",
|
||||
static_cast<float>(row1.GetX()), static_cast<float>(row1.GetY()), static_cast<float>(row1.GetZ()), static_cast<float>(row1.GetW()),
|
||||
static_cast<float>(row2.GetX()), static_cast<float>(row2.GetY()), static_cast<float>(row2.GetZ()), static_cast<float>(row2.GetW()),
|
||||
static_cast<float>(row3.GetX()), static_cast<float>(row3.GetY()), static_cast<float>(row3.GetZ()), static_cast<float>(row3.GetW()),
|
||||
static_cast<float>(row4.GetX()), static_cast<float>(row4.GetY()), static_cast<float>(row4.GetZ()), static_cast<float>(row4.GetW())
|
||||
);
|
||||
}
|
||||
|
||||
AZStd::string ToString(const AZ::Color& color)
|
||||
{
|
||||
return AZStd::string::format("(R:%d, G:%d, B:%d A:%d)", color.GetR8(), color.GetG8(), color.GetB8(), color.GetA8());
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/std/string/string.h>
|
||||
|
||||
/**
|
||||
* Utility functions for convertings math types into strings.
|
||||
*/
|
||||
namespace AZ
|
||||
{
|
||||
class Vector2;
|
||||
class Vector3;
|
||||
class Vector4;
|
||||
class Quaternion;
|
||||
class Transform;
|
||||
class Matrix3x3;
|
||||
class Matrix4x4;
|
||||
class Color;
|
||||
|
||||
AZStd::string ToString(const Vector2& vector2);
|
||||
AZStd::string ToString(const Vector3& vector3);
|
||||
AZStd::string ToString(const Vector4& vector4);
|
||||
AZStd::string ToString(const Quaternion& quaternion);
|
||||
AZStd::string ToString(const Transform& transform);
|
||||
AZStd::string ToString(const Matrix3x3& matrix33);
|
||||
AZStd::string ToString(const Matrix4x4& matrix44);
|
||||
AZStd::string ToString(const Color& color);
|
||||
}
|
||||
@@ -298,6 +298,8 @@ set(FILES
|
||||
Math/MathUtils.h
|
||||
Math/MathMatrixSerializer.h
|
||||
Math/MathMatrixSerializer.cpp
|
||||
Math/MathStringConversions.h
|
||||
Math/MathStringConversions.cpp
|
||||
Math/MathVectorSerializer.h
|
||||
Math/MathVectorSerializer.cpp
|
||||
Math/Matrix3x3.cpp
|
||||
@@ -364,8 +366,6 @@ set(FILES
|
||||
Math/Color.cpp
|
||||
Math/ColorSerializer.h
|
||||
Math/ColorSerializer.cpp
|
||||
Math/ToString.h
|
||||
Math/ToString.cpp
|
||||
Memory/AllocationRecords.cpp
|
||||
Memory/AllocationRecords.h
|
||||
Memory/AllocatorBase.cpp
|
||||
|
||||
@@ -286,6 +286,13 @@ namespace AZStd
|
||||
str = buf;
|
||||
}
|
||||
|
||||
template<class Str, class BoolType>
|
||||
auto to_string(Str& str, BoolType value)
|
||||
-> std::enable_if_t<AZStd::same_as<AZStd::remove_cvref_t<BoolType>, bool>>
|
||||
{
|
||||
str = value ? "true" : "false";
|
||||
}
|
||||
|
||||
inline AZStd::string to_string(int val) { AZStd::string str; to_string(str, val); return str; }
|
||||
inline AZStd::string to_string(unsigned int val) { AZStd::string str; to_string(str, val); return str; }
|
||||
inline AZStd::string to_string(float val) { AZStd::string str; to_string(str, val); return str; }
|
||||
@@ -295,6 +302,7 @@ namespace AZStd
|
||||
inline AZStd::string to_string(long long val) { AZStd::string str; to_string(str, val); return str; }
|
||||
inline AZStd::string to_string(unsigned long long val) { AZStd::string str; to_string(str, val); return str; }
|
||||
inline AZStd::string to_string(long double val) { AZStd::string str; to_string(str, val); return str; }
|
||||
inline AZStd::string to_string(bool val) { AZStd::string str; to_string(str, val); return str; }
|
||||
|
||||
// In our engine we assume AZStd::string is Utf8 encoded!
|
||||
template<class Allocator>
|
||||
|
||||
@@ -665,6 +665,8 @@ namespace UnitTest
|
||||
EXPECT_EQ("20", AZStd::to_string(static_cast<uint32_t>(20)));
|
||||
EXPECT_EQ("20", AZStd::to_string(static_cast<int64_t>(20)));
|
||||
EXPECT_EQ("20", AZStd::to_string(static_cast<uint64_t>(20)));
|
||||
EXPECT_EQ("false", AZStd::to_string(false));
|
||||
EXPECT_EQ("true", AZStd::to_string(true));
|
||||
|
||||
// wstring to string
|
||||
AZStd::string str1;
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
#include <AzCore/Math/Matrix4x4.h>
|
||||
#include <AzCore/Math/Quaternion.h>
|
||||
#include <AzCore/Math/Sphere.h>
|
||||
#include <AzCore/Math/ToString.h>
|
||||
#include <AzCore/Math/Vector2.h>
|
||||
#include <AzCore/Math/Vector3.h>
|
||||
#include <AzCore/Math/Vector4.h>
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzCore/UnitTest/TestTypes.h>
|
||||
|
||||
#include <AzCore/Math/MathStringConversions.h>
|
||||
#include <AzCore/Math/Aabb.h>
|
||||
#include <AzCore/Math/Color.h>
|
||||
#include <AzCore/Math/Matrix3x3.h>
|
||||
#include <AzCore/Math/Matrix3x4.h>
|
||||
#include <AzCore/Math/Matrix4x4.h>
|
||||
#include <AzCore/Math/Transform.h>
|
||||
#include <AzCore/Math/Quaternion.h>
|
||||
#include <AzCore/Math/Vector2.h>
|
||||
#include <AzCore/Math/Vector3.h>
|
||||
|
||||
namespace UnitTest
|
||||
{
|
||||
class MathStrings : public AllocatorsTestFixture
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
TEST_F(MathStrings, TestVectorStringConverters)
|
||||
{
|
||||
AZ::Vector2 vec2 = AZ::Vector2::CreateOne();
|
||||
AZ::Vector3 vec3 = AZ::Vector3::CreateOne();
|
||||
AZ::Vector4 vec4 = AZ::Vector4::CreateOne();
|
||||
AZ::Quaternion quat = AZ::Quaternion::CreateIdentity();
|
||||
|
||||
EXPECT_EQ(AZStd::to_string(vec2), "1.00000000,1.00000000");
|
||||
EXPECT_EQ(AZStd::to_string(vec3), "1.00000000,1.00000000,1.00000000");
|
||||
EXPECT_EQ(AZStd::to_string(vec4), "1.00000000,1.00000000,1.00000000,1.00000000");
|
||||
EXPECT_EQ(AZStd::to_string(quat), "0.00000000,0.00000000,0.00000000,1.00000000");
|
||||
}
|
||||
|
||||
TEST_F(MathStrings, TestMatrixStringConverters)
|
||||
{
|
||||
AZ::Matrix3x3 mat33 = AZ::Matrix3x3::CreateIdentity();
|
||||
AZ::Matrix4x4 mat44 = AZ::Matrix4x4::CreateIdentity();
|
||||
AZ::Transform xform = AZ::Transform::CreateIdentity();
|
||||
|
||||
EXPECT_EQ(AZStd::to_string(mat33), "1.00000000,0.00000000,0.00000000\n0.00000000,1.00000000,0.00000000\n0.00000000,0.00000000,1.00000000");
|
||||
EXPECT_EQ(AZStd::to_string(mat44), "1.00000000,0.00000000,0.00000000,0.00000000\n0.00000000,1.00000000,0.00000000,0.00000000\n0.00000000,0.00000000,1.00000000,0.00000000\n0.00000000,0.00000000,0.00000000,1.00000000");
|
||||
EXPECT_EQ(AZStd::to_string(xform), "0.00000000,0.00000000,0.00000000\n0.00000000,0.00000000,0.00000000\n0.00000000,0.00000000,0.00000000\n0.00000000,0.00000000,0.00000000");
|
||||
|
||||
}
|
||||
|
||||
TEST_F(MathStrings, TestAabbStringConverter)
|
||||
{
|
||||
AZ::Aabb aabb = AZ::Aabb::CreateFromMinMaxValues(0.f, 0.f, 0.f, 1.f, 1.f, 1.f);
|
||||
EXPECT_EQ(AZStd::to_string(aabb), "0.00000000,0.00000000,0.00000000\n1.00000000,1.00000000,1.00000000");
|
||||
}
|
||||
|
||||
TEST_F(MathStrings, TestColorStringConverter)
|
||||
{
|
||||
EXPECT_EQ(AZStd::to_string(AZ::Colors::Black), "R:0, G:0, B:0 A:0");
|
||||
}
|
||||
}
|
||||
@@ -140,6 +140,7 @@ set(FILES
|
||||
Math/FrustumPerformanceTests.cpp
|
||||
Math/IntersectionTests.cpp
|
||||
Math/MathIntrinsicsTests.cpp
|
||||
Math/MathStringsTests.cpp
|
||||
Math/MathUtilsTests.cpp
|
||||
Math/Matrix3x3PerformanceTests.cpp
|
||||
Math/Matrix3x3Tests.cpp
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <AzFramework/Components/NonUniformScaleComponent.h>
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
#include <AzCore/Math/Transform.h>
|
||||
#include <AzCore/Math/ToString.h>
|
||||
#include <AzCore/Math/MathStringConversions.h>
|
||||
#include <AzCore/Component/Entity.h>
|
||||
|
||||
namespace AzFramework
|
||||
@@ -65,7 +65,7 @@ namespace AzFramework
|
||||
{
|
||||
AZ::Vector3 clampedScale = scale.GetClamp(AZ::Vector3(AZ::MinTransformScale), AZ::Vector3(AZ::MaxTransformScale));
|
||||
AZ_Warning("Non-uniform Scale Component", false, "SetScale value was clamped from %s to %s for entity %s",
|
||||
AZ::ToString(scale).c_str(), AZ::ToString(clampedScale).c_str(), GetEntity()->GetName().c_str());
|
||||
AZStd::to_string(scale).c_str(), AZStd::to_string(clampedScale).c_str(), GetEntity()->GetName().c_str());
|
||||
m_scale = clampedScale;
|
||||
}
|
||||
m_scaleChangedEvent.Signal(m_scale);
|
||||
|
||||
+2
-2
@@ -9,7 +9,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Debug/Trace.h>
|
||||
#include <AzCore/Math/ToString.h>
|
||||
#include <AzCore/Math/MathStringConversions.h>
|
||||
#include <AzCore/std/string/string.h>
|
||||
#include <AzToolsFramework/Viewport/ViewportMessages.h>
|
||||
|
||||
@@ -278,7 +278,7 @@ namespace AzManipulatorTestFramework
|
||||
template<typename DerivedDispatcherT>
|
||||
DerivedDispatcherT* ActionDispatcher<DerivedDispatcherT>::SetEntityWorldTransform(AZ::EntityId entityId, const AZ::Transform& transform)
|
||||
{
|
||||
Log("Setting entity world transform: %s", AZ::ToString(transform).c_str());
|
||||
Log("Setting entity world transform: %s", AZStd::to_string(transform).c_str());
|
||||
SetEntityWorldTransformImpl(entityId, transform);
|
||||
return static_cast<DerivedDispatcherT*>(this);
|
||||
}
|
||||
|
||||
+2
-2
@@ -6,7 +6,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzCore/Math/ToString.h>
|
||||
#include <AzCore/Math/MathStringConversions.h>
|
||||
#include <AzCore/Math/Transform.h>
|
||||
#include <AzCore/Serialization/EditContext.h>
|
||||
#include <AzCore/RTTI/BehaviorContext.h>
|
||||
@@ -112,7 +112,7 @@ namespace AzToolsFramework
|
||||
AZ::Vector3 clampedScale = scale.GetClamp(AZ::Vector3(AZ::MinTransformScale), AZ::Vector3(AZ::MaxTransformScale));
|
||||
AZ_Warning(
|
||||
"Editor Non-uniform Scale Component", false, "SetScale value was clamped from %s to %s for entity %s",
|
||||
AZ::ToString(scale).c_str(), AZ::ToString(clampedScale).c_str(), GetEntity()->GetName().c_str());
|
||||
AZStd::to_string(scale).c_str(), AZStd::to_string(clampedScale).c_str(), GetEntity()->GetName().c_str());
|
||||
m_scale = clampedScale;
|
||||
}
|
||||
m_scaleChangedEvent.Signal(m_scale);
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
*/
|
||||
|
||||
#include <AzCore/Math/IntersectSegment.h>
|
||||
#include <AzCore/Math/ToString.h>
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
#include <AzCore/UnitTest/TestTypes.h>
|
||||
#include <AzFramework/Components/TransformComponent.h>
|
||||
|
||||
@@ -73,64 +73,3 @@ namespace MCore
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
namespace AZStd
|
||||
{
|
||||
void to_string(string& str, bool value)
|
||||
{
|
||||
str = value ? "true" : "false";
|
||||
}
|
||||
|
||||
void to_string(string& str, const AZ::Vector2& value)
|
||||
{
|
||||
str = AZStd::string::format("%.8f,%.8f",
|
||||
static_cast<float>(value.GetX()),
|
||||
static_cast<float>(value.GetY()));
|
||||
}
|
||||
|
||||
void to_string(string& str, const AZ::Vector3& value)
|
||||
{
|
||||
str = AZStd::string::format("%.8f,%.8f,%.8f",
|
||||
static_cast<float>(value.GetX()),
|
||||
static_cast<float>(value.GetY()),
|
||||
static_cast<float>(value.GetZ()));
|
||||
}
|
||||
|
||||
void to_string(string& str, const AZ::Vector4& value)
|
||||
{
|
||||
str = AZStd::string::format("%.8f,%.8f,%.8f,%.8f",
|
||||
static_cast<float>(value.GetX()),
|
||||
static_cast<float>(value.GetY()),
|
||||
static_cast<float>(value.GetZ()),
|
||||
static_cast<float>(value.GetW()));
|
||||
}
|
||||
|
||||
void to_string(string& str, const AZ::Quaternion& value)
|
||||
{
|
||||
str = AZStd::string::format("%.8f,%.8f,%.8f,%.8f",
|
||||
static_cast<float>(value.GetX()),
|
||||
static_cast<float>(value.GetY()),
|
||||
static_cast<float>(value.GetZ()),
|
||||
static_cast<float>(value.GetW()));
|
||||
}
|
||||
|
||||
void to_string(string& str, const AZ::Matrix4x4& value)
|
||||
{
|
||||
str = AZStd::string::format("%.8f,%.8f,%.8f,%.8f\n%.8f,%.8f,%.8f,%.8f\n%.8f,%.8f,%.8f,%.8f\n%.8f,%.8f,%.8f,%.8f",
|
||||
static_cast<float>(value(0, 0)), static_cast<float>(value(1, 0)), static_cast<float>(value(2, 0)), static_cast<float>(value(3, 0)),
|
||||
static_cast<float>(value(0, 1)), static_cast<float>(value(1, 1)), static_cast<float>(value(2, 1)), static_cast<float>(value(3, 1)),
|
||||
static_cast<float>(value(0, 2)), static_cast<float>(value(1, 2)), static_cast<float>(value(2, 2)), static_cast<float>(value(3, 2)),
|
||||
static_cast<float>(value(0, 3)), static_cast<float>(value(1, 3)), static_cast<float>(value(2, 3)), static_cast<float>(value(3, 3)));
|
||||
}
|
||||
|
||||
void to_string(string& str, const AZ::Transform& value)
|
||||
{
|
||||
AZ::Matrix3x4 matrix3x4 = AZ::Matrix3x4::CreateFromTransform(value);
|
||||
|
||||
str = AZStd::string::format("%.8f,%.8f,%.8f\n%.8f,%.8f,%.8f\n%.8f,%.8f,%.8f\n%.8f,%.8f,%.8f",
|
||||
static_cast<float>(matrix3x4(0, 0)), static_cast<float>(matrix3x4(1, 0)), static_cast<float>(matrix3x4(2, 0)),
|
||||
static_cast<float>(matrix3x4(0, 1)), static_cast<float>(matrix3x4(1, 1)), static_cast<float>(matrix3x4(2, 1)),
|
||||
static_cast<float>(matrix3x4(0, 2)), static_cast<float>(matrix3x4(1, 2)), static_cast<float>(matrix3x4(2, 2)),
|
||||
static_cast<float>(matrix3x4(0, 3)), static_cast<float>(matrix3x4(1, 3)), static_cast<float>(matrix3x4(2, 3)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,20 +9,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/std/functional.h>
|
||||
#include <AzCore/std/string/conversions.h>
|
||||
#include <AzCore/Math/MathStringConversions.h>
|
||||
#include <AzCore/std/string/string.h>
|
||||
#include <AzFramework/StringFunc/StringFunc.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
class Matrix4x4;
|
||||
class Quaternion;
|
||||
class Transform;
|
||||
class Vector2;
|
||||
class Vector3;
|
||||
class Vector4;
|
||||
}
|
||||
|
||||
namespace MCore
|
||||
{
|
||||
AZStd::string GenerateUniqueString(const char* prefix, const AZStd::function<bool(const AZStd::string& value)>& validationFunction);
|
||||
@@ -46,22 +36,3 @@ namespace MCore
|
||||
static const char* wordSeparators;
|
||||
};
|
||||
}
|
||||
|
||||
namespace AZStd
|
||||
{
|
||||
void to_string(string& str, bool value);
|
||||
void to_string(string& str, const AZ::Vector2& value);
|
||||
void to_string(string& str, const AZ::Vector3& value);
|
||||
void to_string(string& str, const AZ::Vector4& value);
|
||||
void to_string(string& str, const AZ::Quaternion& value);
|
||||
void to_string(string& str, const AZ::Matrix4x4& value);
|
||||
void to_string(string& str, const AZ::Transform& value);
|
||||
|
||||
inline AZStd::string to_string(bool val) { AZStd::string str; to_string(str, val); return str; }
|
||||
inline AZStd::string to_string(const AZ::Vector2& val) { AZStd::string str; to_string(str, val); return str; }
|
||||
inline AZStd::string to_string(const AZ::Vector3& val) { AZStd::string str; to_string(str, val); return str; }
|
||||
inline AZStd::string to_string(const AZ::Vector4& val) { AZStd::string str; to_string(str, val); return str; }
|
||||
inline AZStd::string to_string(const AZ::Quaternion& val) { AZStd::string str; to_string(str, val); return str; }
|
||||
inline AZStd::string to_string(const AZ::Matrix4x4& val) { AZStd::string str; to_string(str, val); return str; }
|
||||
inline AZStd::string to_string(const AZ::Transform& val) { AZStd::string str; to_string(str, val); return str; }
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include "MultiplayerDebugPerEntityReporter.h"
|
||||
|
||||
#include <AzCore/Component/TransformBus.h>
|
||||
#include <AzCore/Math/ToString.h>
|
||||
#include <AzFramework/Entity/EntityDebugDisplayBus.h>
|
||||
#include <Multiplayer/IMultiplayer.h>
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#include <AzToolsFramework/Manipulators/ManipulatorManager.h>
|
||||
#include <AzToolsFramework/ViewportSelection/EditorSelectionUtil.h>
|
||||
#include <AzCore/Component/TransformBus.h>
|
||||
#include <AzCore/Math/ToString.h>
|
||||
#include <AzFramework/Viewport/ViewportColors.h>
|
||||
#include <AzFramework/Viewport/ViewportConstants.h>
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
#include <AzCore/std/smart_ptr/shared_ptr.h>
|
||||
#include <AzCore/Math/ToString.h>
|
||||
#include <AzCore/Math/MathStringConversions.h>
|
||||
#include <AzFramework/Physics/Utils.h>
|
||||
#include <AzFramework/Physics/Configuration/RigidBodyConfiguration.h>
|
||||
#include <PhysX/NativeTypeIdentifiers.h>
|
||||
@@ -220,13 +220,13 @@ namespace PhysX
|
||||
{
|
||||
AZ_Warning("RigidBody", !computeCenterOfMass,
|
||||
"Rigid body '%s' cannot compute COM because it contains triangle mesh, plane or heightfield shapes, it will default to %s.",
|
||||
GetName().c_str(), AZ::ToString(DefaultCenterOfMass).c_str());
|
||||
GetName().c_str(), AZStd::to_string(DefaultCenterOfMass).c_str());
|
||||
AZ_Warning("RigidBody", !computeMass,
|
||||
"Rigid body '%s' cannot compute Mass because it contains triangle mesh, plane or heightfield shapes, it will default to %0.1f.",
|
||||
GetName().c_str(), DefaultMass);
|
||||
AZ_Warning("RigidBody", !computeInertiaTensor,
|
||||
"Rigid body '%s' cannot compute Inertia because it contains triangle mesh, plane or heightfield shapes, it will default to %s.",
|
||||
GetName().c_str(), AZ::ToString(DefaultInertiaTensor.RetrieveScale()).c_str());
|
||||
GetName().c_str(), AZStd::to_string(DefaultInertiaTensor.RetrieveScale()).c_str());
|
||||
|
||||
SetCenterOfMassOffset(computeCenterOfMass ? DefaultCenterOfMass : centerOfMassOffsetOverride);
|
||||
SetMass(computeMass ? DefaultMass : massOverride);
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include <AzCore/Serialization/Utils.h>
|
||||
#include <AzCore/Component/TransformBus.h>
|
||||
#include <AzCore/Math/SimdMath.h>
|
||||
#include <AzCore/Math/ToString.h>
|
||||
#include <AzCore/Math/MathStringConversions.h>
|
||||
#include <AzFramework/Physics/ShapeConfiguration.h>
|
||||
#include <AzFramework/Physics/SystemBus.h>
|
||||
#include <AzFramework/Physics/Collision/CollisionGroups.h>
|
||||
@@ -222,7 +222,7 @@ namespace PhysX
|
||||
if (!shapeConfiguration.m_scale.IsGreaterThan(AZ::Vector3::CreateZero()))
|
||||
{
|
||||
AZ_Error("PhysX Utils", false, "Negative or zero values are invalid for shape configuration scale values %s",
|
||||
ToString(shapeConfiguration.m_scale).c_str());
|
||||
AZStd::to_string(shapeConfiguration.m_scale).c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -247,7 +247,7 @@ namespace PhysX
|
||||
if (!boxConfig.m_dimensions.IsGreaterThan(AZ::Vector3::CreateZero()))
|
||||
{
|
||||
AZ_Error("PhysX Utils", false, "Negative or zero values are invalid for box dimensions %s",
|
||||
ToString(boxConfig.m_dimensions).c_str());
|
||||
AZStd::to_string(boxConfig.m_dimensions).c_str());
|
||||
return false;
|
||||
}
|
||||
pxGeometry.storeAny(physx::PxBoxGeometry(PxMathConvert(boxConfig.m_dimensions * 0.5f * shapeConfiguration.m_scale)));
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include <AzCore/IO/FileIO.h>
|
||||
#include <AzCore/Math/MathUtils.h>
|
||||
#include <AzCore/Math/Matrix3x4.h>
|
||||
#include <AzCore/Math/ToString.h>
|
||||
#include <AzCore/Math/MathStringConversions.h>
|
||||
#include <AzCore/Math/Transform.h>
|
||||
#include <AzCore/Math/Vector2.h>
|
||||
#include <AzCore/Math/Vector3.h>
|
||||
@@ -1433,8 +1433,7 @@ namespace WhiteBox
|
||||
void TranslateEdge(WhiteBoxMesh& whiteBox, const EdgeHandle edgeHandle, const AZ::Vector3& displacement)
|
||||
{
|
||||
WHITEBOX_LOG(
|
||||
"White Box", "TranslateEdge eh(%s) %s", ToString(edgeHandle).c_str(),
|
||||
AZ::ToString(displacement).c_str());
|
||||
"White Box", "TranslateEdge eh(%s) %s", ToString(edgeHandle).c_str(), AZStd::to_string(displacement).c_str());
|
||||
AZ_PROFILE_FUNCTION(AzToolsFramework);
|
||||
|
||||
const auto vertexHandles = EdgeVertexHandles(whiteBox, edgeHandle);
|
||||
@@ -1674,8 +1673,7 @@ namespace WhiteBox
|
||||
WhiteBoxMesh& whiteBox, const EdgeHandle edgeHandle, const AZ::Vector3& displacement)
|
||||
{
|
||||
WHITEBOX_LOG(
|
||||
"White Box", "TranslateEdgeAppend eh(%s) %s", ToString(edgeHandle).c_str(),
|
||||
AZ::ToString(displacement).c_str());
|
||||
"White Box", "TranslateEdgeAppend eh(%s) %s", ToString(edgeHandle).c_str(), AZStd::to_string(displacement).c_str());
|
||||
AZ_PROFILE_FUNCTION(AzToolsFramework);
|
||||
|
||||
// the new and existing handles required for an edge append
|
||||
@@ -2605,8 +2603,7 @@ namespace WhiteBox
|
||||
void SetVertexPosition(WhiteBoxMesh& whiteBox, const VertexHandle vertexHandle, const AZ::Vector3& position)
|
||||
{
|
||||
WHITEBOX_LOG(
|
||||
"White Box", "SetVertexPosition vh(%s) %s", ToString(vertexHandle).c_str(),
|
||||
AZ::ToString(position).c_str());
|
||||
"White Box", "SetVertexPosition vh(%s) %s", ToString(vertexHandle).c_str(), AZStd::to_string(position).c_str());
|
||||
AZ_PROFILE_FUNCTION(AzToolsFramework);
|
||||
|
||||
whiteBox.mesh.set_point(om_vh(vertexHandle), position);
|
||||
@@ -2616,8 +2613,7 @@ namespace WhiteBox
|
||||
WhiteBoxMesh& whiteBox, const VertexHandle vertexHandle, const AZ::Vector3& position)
|
||||
{
|
||||
WHITEBOX_LOG(
|
||||
"White Box", "SetVertexPositionAndUpdateUVs vh(%s) %s", ToString(vertexHandle).c_str(),
|
||||
AZ::ToString(position).c_str());
|
||||
"White Box", "SetVertexPositionAndUpdateUVs vh(%s) %s", ToString(vertexHandle).c_str(), AZStd::to_string(position).c_str());
|
||||
AZ_PROFILE_FUNCTION(AzToolsFramework);
|
||||
|
||||
SetVertexPosition(whiteBox, vertexHandle, position);
|
||||
@@ -2626,7 +2622,7 @@ namespace WhiteBox
|
||||
|
||||
VertexHandle AddVertex(WhiteBoxMesh& whiteBox, const AZ::Vector3& vertex)
|
||||
{
|
||||
WHITEBOX_LOG("White Box", "AddVertex %s", AZ::ToString(vertex).c_str());
|
||||
WHITEBOX_LOG("White Box", "AddVertex %s", AZStd::to_string(vertex).c_str());
|
||||
AZ_PROFILE_FUNCTION(AzToolsFramework);
|
||||
|
||||
return wb_vh(whiteBox.mesh.add_vertex(vertex));
|
||||
@@ -3362,7 +3358,7 @@ namespace WhiteBox
|
||||
{
|
||||
WHITEBOX_LOG(
|
||||
"White Box", "ScalePolygonRelative ph(%s) pivot %s scale: %f", ToString(polygonHandle).c_str(),
|
||||
AZ::ToString(pivot).c_str(), scaleDelta);
|
||||
AZStd::to_string(pivot).c_str(), scaleDelta);
|
||||
AZ_PROFILE_FUNCTION(AzToolsFramework);
|
||||
|
||||
const AZ::Transform polygonSpace = PolygonSpace(whiteBox, polygonHandle, pivot);
|
||||
|
||||
Reference in New Issue
Block a user