diff --git a/Code/Framework/AzCore/AzCore/Math/MathStringConversions.cpp b/Code/Framework/AzCore/AzCore/Math/MathStringConversions.cpp new file mode 100644 index 0000000000..9997db09b5 --- /dev/null +++ b/Code/Framework/AzCore/AzCore/Math/MathStringConversions.cpp @@ -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 +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace AZStd +{ + void to_string(string& str, const AZ::Vector2& value) + { + str = AZStd::string::format("%.8f,%.8f", + static_cast(value.GetX()), + static_cast(value.GetY())); + } + + void to_string(string& str, const AZ::Vector3& value) + { + str = AZStd::string::format("%.8f,%.8f,%.8f", + static_cast(value.GetX()), + static_cast(value.GetY()), + static_cast(value.GetZ())); + } + + void to_string(string& str, const AZ::Vector4& value) + { + str = AZStd::string::format("%.8f,%.8f,%.8f,%.8f", + static_cast(value.GetX()), + static_cast(value.GetY()), + static_cast(value.GetZ()), + static_cast(value.GetW())); + } + + void to_string(string& str, const AZ::Quaternion& value) + { + str = AZStd::string::format("%.8f,%.8f,%.8f,%.8f", + static_cast(value.GetX()), + static_cast(value.GetY()), + static_cast(value.GetZ()), + static_cast(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(value(0, 0)), static_cast(value(1, 0)), static_cast(value(2, 0)), + static_cast(value(0, 1)), static_cast(value(1, 1)), static_cast(value(2, 1)), + static_cast(value(0, 2)), static_cast(value(1, 2)), static_cast(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(value(0, 0)), static_cast(value(1, 0)), static_cast(value(2, 0)), static_cast(value(3, 0)), + static_cast(value(0, 1)), static_cast(value(1, 1)), static_cast(value(2, 1)), static_cast(value(3, 1)), + static_cast(value(0, 2)), static_cast(value(1, 2)), static_cast(value(2, 2)), static_cast(value(3, 2)), + static_cast(value(0, 3)), static_cast(value(1, 3)), static_cast(value(2, 3)), static_cast(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(matrix3x4(0, 0)), static_cast(matrix3x4(1, 0)), static_cast(matrix3x4(2, 0)), + static_cast(matrix3x4(0, 1)), static_cast(matrix3x4(1, 1)), static_cast(matrix3x4(2, 1)), + static_cast(matrix3x4(0, 2)), static_cast(matrix3x4(1, 2)), static_cast(matrix3x4(2, 2)), + static_cast(matrix3x4(0, 3)), static_cast(matrix3x4(1, 3)), static_cast(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(value.GetMin().GetX()), static_cast(value.GetMin().GetY()), + static_cast(value.GetMin().GetZ()), static_cast(value.GetMax().GetX()), + static_cast(value.GetMax().GetY()), static_cast(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()); + } +} diff --git a/Code/Framework/AzCore/AzCore/Math/MathStringConversions.h b/Code/Framework/AzCore/AzCore/Math/MathStringConversions.h new file mode 100644 index 0000000000..f4861eba3f --- /dev/null +++ b/Code/Framework/AzCore/AzCore/Math/MathStringConversions.h @@ -0,0 +1,118 @@ +/* + * 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 +#include +#include + +namespace AZ +{ + class Aabb; + class Color; + class Matrix3x3; + class Matrix4x4; + class Quaternion; + class Transform; + class Vector2; + class Vector3; + class Vector4; +} // namespace AZ + +namespace AZStd +{ + //! Prints a Vector2 with precision to 8 decimal places. + void to_string(string& str, const AZ::Vector2& value); + + //! Prints a Vector3 with precision to 8 decimal places. + void to_string(string& str, const AZ::Vector3& value); + + //! Prints a Vector4 with precision to 8 decimal places. + void to_string(string& str, const AZ::Vector4& value); + + //! Prints a Quaternion with precision to 8 decimal places. + 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 places. + 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 places. + 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 places. + void to_string(string& str, const AZ::Transform& value); + + //! Prints an AABB as a pair of Vector3s with precision to 8 decimal places. + 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; + } +} // namespace AZStd diff --git a/Code/Framework/AzCore/AzCore/Math/ToString.cpp b/Code/Framework/AzCore/AzCore/Math/ToString.cpp deleted file mode 100644 index 2a1c94e660..0000000000 --- a/Code/Framework/AzCore/AzCore/Math/ToString.cpp +++ /dev/null @@ -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 -#include -#include -#include -#include -#include -#include -#include - -namespace AZ -{ - AZStd::string ToString(const AZ::Vector2& vector2) - { - return AZStd::string::format("(X:%f, Y:%f)", static_cast(vector2.GetX()), static_cast(vector2.GetY())); - } - - AZStd::string ToString(const AZ::Vector3& vector3) - { - return AZStd::string::format("(X:%f, Y:%f, Z:%f)", static_cast(vector3.GetX()), static_cast(vector3.GetY()), static_cast(vector3.GetZ())); - } - - AZStd::string ToString(const AZ::Vector4& vector4) - { - return AZStd::string::format("(X:%f, Y:%f, Z:%f W:%f)", static_cast(vector4.GetX()), static_cast(vector4.GetY()), static_cast(vector4.GetZ()), static_cast(vector4.GetW())); - } - - AZStd::string ToString(const AZ::Quaternion& quaternion) - { - return AZStd::string::format("(X:%f, Y:%f, Z:%f W:%f)", static_cast(quaternion.GetX()), static_cast(quaternion.GetY()), static_cast(quaternion.GetZ()), static_cast(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(row1.GetX()), static_cast(row1.GetY()), static_cast(row1.GetZ()), - static_cast(row2.GetX()), static_cast(row2.GetY()), static_cast(row2.GetZ()), - static_cast(row3.GetX()), static_cast(row3.GetY()), static_cast(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(row1.GetX()), static_cast(row1.GetY()), static_cast(row1.GetZ()), static_cast(row1.GetW()), - static_cast(row2.GetX()), static_cast(row2.GetY()), static_cast(row2.GetZ()), static_cast(row2.GetW()), - static_cast(row3.GetX()), static_cast(row3.GetY()), static_cast(row3.GetZ()), static_cast(row3.GetW()), - static_cast(row4.GetX()), static_cast(row4.GetY()), static_cast(row4.GetZ()), static_cast(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()); - } -} diff --git a/Code/Framework/AzCore/AzCore/Math/ToString.h b/Code/Framework/AzCore/AzCore/Math/ToString.h deleted file mode 100644 index f7de73f79b..0000000000 --- a/Code/Framework/AzCore/AzCore/Math/ToString.h +++ /dev/null @@ -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 - -/** - * 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); -} diff --git a/Code/Framework/AzCore/AzCore/azcore_files.cmake b/Code/Framework/AzCore/AzCore/azcore_files.cmake index 89923b415f..18117adafb 100644 --- a/Code/Framework/AzCore/AzCore/azcore_files.cmake +++ b/Code/Framework/AzCore/AzCore/azcore_files.cmake @@ -300,6 +300,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 @@ -366,8 +368,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 diff --git a/Code/Framework/AzCore/AzCore/std/string/conversions.h b/Code/Framework/AzCore/AzCore/std/string/conversions.h index be71e12275..9427eaccf6 100644 --- a/Code/Framework/AzCore/AzCore/std/string/conversions.h +++ b/Code/Framework/AzCore/AzCore/std/string/conversions.h @@ -286,6 +286,13 @@ namespace AZStd str = buf; } + template + auto to_string(Str& str, BoolType value) + -> enable_if_t, 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 diff --git a/Code/Framework/AzCore/Tests/AZStd/String.cpp b/Code/Framework/AzCore/Tests/AZStd/String.cpp index f53a90047f..4ecfdcab22 100644 --- a/Code/Framework/AzCore/Tests/AZStd/String.cpp +++ b/Code/Framework/AzCore/Tests/AZStd/String.cpp @@ -665,6 +665,8 @@ namespace UnitTest EXPECT_EQ("20", AZStd::to_string(static_cast(20))); EXPECT_EQ("20", AZStd::to_string(static_cast(20))); EXPECT_EQ("20", AZStd::to_string(static_cast(20))); + EXPECT_EQ("false", AZStd::to_string(false)); + EXPECT_EQ("true", AZStd::to_string(true)); // wstring to string AZStd::string str1; diff --git a/Code/Framework/AzCore/Tests/AZTestShared/Math/MathTestHelpers.cpp b/Code/Framework/AzCore/Tests/AZTestShared/Math/MathTestHelpers.cpp index fc707c9751..e34e586310 100644 --- a/Code/Framework/AzCore/Tests/AZTestShared/Math/MathTestHelpers.cpp +++ b/Code/Framework/AzCore/Tests/AZTestShared/Math/MathTestHelpers.cpp @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include diff --git a/Code/Framework/AzCore/Tests/Math/MathStringsTests.cpp b/Code/Framework/AzCore/Tests/Math/MathStringsTests.cpp new file mode 100644 index 0000000000..c976d1b1df --- /dev/null +++ b/Code/Framework/AzCore/Tests/Math/MathStringsTests.cpp @@ -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 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +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), "1.00000000,0.00000000,0.00000000\n0.00000000,1.00000000,0.00000000\n0.00000000,0.00000000,1.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:255"); + } +} diff --git a/Code/Framework/AzCore/Tests/azcoretests_files.cmake b/Code/Framework/AzCore/Tests/azcoretests_files.cmake index 26181db90b..9566b6a168 100644 --- a/Code/Framework/AzCore/Tests/azcoretests_files.cmake +++ b/Code/Framework/AzCore/Tests/azcoretests_files.cmake @@ -141,6 +141,7 @@ set(FILES Math/FrustumPerformanceTests.cpp Math/IntersectionTests.cpp Math/MathIntrinsicsTests.cpp + Math/MathStringsTests.cpp Math/MathUtilsTests.cpp Math/Matrix3x3PerformanceTests.cpp Math/Matrix3x3Tests.cpp diff --git a/Code/Framework/AzFramework/AzFramework/Components/NonUniformScaleComponent.cpp b/Code/Framework/AzFramework/AzFramework/Components/NonUniformScaleComponent.cpp index 5b27efa616..d539e9b8d2 100644 --- a/Code/Framework/AzFramework/AzFramework/Components/NonUniformScaleComponent.cpp +++ b/Code/Framework/AzFramework/AzFramework/Components/NonUniformScaleComponent.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include 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); diff --git a/Code/Framework/AzManipulatorTestFramework/Include/AzManipulatorTestFramework/ActionDispatcher.h b/Code/Framework/AzManipulatorTestFramework/Include/AzManipulatorTestFramework/ActionDispatcher.h index f056493ffd..207baa9a36 100644 --- a/Code/Framework/AzManipulatorTestFramework/Include/AzManipulatorTestFramework/ActionDispatcher.h +++ b/Code/Framework/AzManipulatorTestFramework/Include/AzManipulatorTestFramework/ActionDispatcher.h @@ -9,7 +9,7 @@ #pragma once #include -#include +#include #include #include @@ -278,7 +278,7 @@ namespace AzManipulatorTestFramework template DerivedDispatcherT* ActionDispatcher::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(this); } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/EditorNonUniformScaleComponent.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/EditorNonUniformScaleComponent.cpp index cc3870e27f..31d330434c 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/EditorNonUniformScaleComponent.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/EditorNonUniformScaleComponent.cpp @@ -6,7 +6,7 @@ * */ -#include +#include #include #include #include @@ -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); diff --git a/Code/Framework/AzToolsFramework/Tests/EditorTransformComponentSelectionTests.cpp b/Code/Framework/AzToolsFramework/Tests/EditorTransformComponentSelectionTests.cpp index 724819b0c2..2c396d4236 100644 --- a/Code/Framework/AzToolsFramework/Tests/EditorTransformComponentSelectionTests.cpp +++ b/Code/Framework/AzToolsFramework/Tests/EditorTransformComponentSelectionTests.cpp @@ -7,7 +7,6 @@ */ #include -#include #include #include #include diff --git a/Gems/EMotionFX/Code/MCore/Source/StringConversions.cpp b/Gems/EMotionFX/Code/MCore/Source/StringConversions.cpp index 5f57a036c2..7013bf872d 100644 --- a/Gems/EMotionFX/Code/MCore/Source/StringConversions.cpp +++ b/Gems/EMotionFX/Code/MCore/Source/StringConversions.cpp @@ -72,60 +72,4 @@ namespace MCore return result; } -} - -namespace AZStd -{ - void to_string(string& str, const AZ::Vector2& value) - { - str = AZStd::string::format("%.8f,%.8f", - static_cast(value.GetX()), - static_cast(value.GetY())); - } - - void to_string(string& str, const AZ::Vector3& value) - { - str = AZStd::string::format("%.8f,%.8f,%.8f", - static_cast(value.GetX()), - static_cast(value.GetY()), - static_cast(value.GetZ())); - } - - void to_string(string& str, const AZ::Vector4& value) - { - str = AZStd::string::format("%.8f,%.8f,%.8f,%.8f", - static_cast(value.GetX()), - static_cast(value.GetY()), - static_cast(value.GetZ()), - static_cast(value.GetW())); - } - - void to_string(string& str, const AZ::Quaternion& value) - { - str = AZStd::string::format("%.8f,%.8f,%.8f,%.8f", - static_cast(value.GetX()), - static_cast(value.GetY()), - static_cast(value.GetZ()), - static_cast(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(value(0, 0)), static_cast(value(1, 0)), static_cast(value(2, 0)), static_cast(value(3, 0)), - static_cast(value(0, 1)), static_cast(value(1, 1)), static_cast(value(2, 1)), static_cast(value(3, 1)), - static_cast(value(0, 2)), static_cast(value(1, 2)), static_cast(value(2, 2)), static_cast(value(3, 2)), - static_cast(value(0, 3)), static_cast(value(1, 3)), static_cast(value(2, 3)), static_cast(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(matrix3x4(0, 0)), static_cast(matrix3x4(1, 0)), static_cast(matrix3x4(2, 0)), - static_cast(matrix3x4(0, 1)), static_cast(matrix3x4(1, 1)), static_cast(matrix3x4(2, 1)), - static_cast(matrix3x4(0, 2)), static_cast(matrix3x4(1, 2)), static_cast(matrix3x4(2, 2)), - static_cast(matrix3x4(0, 3)), static_cast(matrix3x4(1, 3)), static_cast(matrix3x4(2, 3))); - } -} +} \ No newline at end of file diff --git a/Gems/EMotionFX/Code/MCore/Source/StringConversions.h b/Gems/EMotionFX/Code/MCore/Source/StringConversions.h index 01b41091cf..815991796e 100644 --- a/Gems/EMotionFX/Code/MCore/Source/StringConversions.h +++ b/Gems/EMotionFX/Code/MCore/Source/StringConversions.h @@ -9,20 +9,10 @@ #pragma once #include -#include +#include #include #include -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& validationFunction); @@ -45,21 +35,4 @@ namespace MCore static const char* wordSeparators; }; -} - -namespace AZStd -{ - 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(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; } -} +} \ No newline at end of file diff --git a/Gems/Multiplayer/Code/Source/Debug/MultiplayerDebugPerEntityReporter.cpp b/Gems/Multiplayer/Code/Source/Debug/MultiplayerDebugPerEntityReporter.cpp index a53420da84..c85634f151 100644 --- a/Gems/Multiplayer/Code/Source/Debug/MultiplayerDebugPerEntityReporter.cpp +++ b/Gems/Multiplayer/Code/Source/Debug/MultiplayerDebugPerEntityReporter.cpp @@ -9,7 +9,6 @@ #include "MultiplayerDebugPerEntityReporter.h" #include -#include #include #include diff --git a/Gems/PhysX/Code/Editor/ColliderSphereMode.cpp b/Gems/PhysX/Code/Editor/ColliderSphereMode.cpp index 8d69e28726..79d7cef3d4 100644 --- a/Gems/PhysX/Code/Editor/ColliderSphereMode.cpp +++ b/Gems/PhysX/Code/Editor/ColliderSphereMode.cpp @@ -16,7 +16,6 @@ #include #include #include -#include #include #include diff --git a/Gems/PhysX/Code/Source/RigidBody.cpp b/Gems/PhysX/Code/Source/RigidBody.cpp index 5b36376da5..7334f4abc4 100644 --- a/Gems/PhysX/Code/Source/RigidBody.cpp +++ b/Gems/PhysX/Code/Source/RigidBody.cpp @@ -8,7 +8,7 @@ #include #include -#include +#include #include #include #include @@ -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); diff --git a/Gems/PhysX/Code/Source/Utils.cpp b/Gems/PhysX/Code/Source/Utils.cpp index 9848ab0415..1798352493 100644 --- a/Gems/PhysX/Code/Source/Utils.cpp +++ b/Gems/PhysX/Code/Source/Utils.cpp @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include #include @@ -223,7 +223,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; } @@ -248,7 +248,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))); diff --git a/Gems/WhiteBox/Code/Source/Core/WhiteBoxToolApi.cpp b/Gems/WhiteBox/Code/Source/Core/WhiteBoxToolApi.cpp index 8d5078dacd..a5241666a6 100644 --- a/Gems/WhiteBox/Code/Source/Core/WhiteBoxToolApi.cpp +++ b/Gems/WhiteBox/Code/Source/Core/WhiteBoxToolApi.cpp @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include #include @@ -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);