diff --git a/.premake/Premake 5.0-beta5/linux/premake5 b/.premake/Premake 5.0-beta5/linux/premake5 new file mode 100755 index 0000000..977ce4c Binary files /dev/null and b/.premake/Premake 5.0-beta5/linux/premake5 differ diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..5358c83 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,32 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Debug MathTestFPU (gdb)", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/bin/1.0.0/Debug/MathTestFPU/MathTestFPU", + "args": [], + "stopAtEntry": false, + "cwd": "${fileDirname}", + "environment": [], + "externalConsole": false, + "MIMode": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + }, + { + "description": "Set Disassembly Flavor to Intel", + "text": "-gdb-set disassembly-flavor intel", + "ignoreFailures": true + } + ] + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 2798997..309e279 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -102,4 +102,51 @@ "__SSE__", ], "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools", + "editor.tokenColorCustomizations": { + "[*Light*]": { + "textMateRules": [ + { + "scope": "ref.matchtext", + "settings": { + "foreground": "#000" + } + } + ] + }, + "[*Dark*]": { + "textMateRules": [ + { + "scope": "ref.matchtext", + "settings": { + "foreground": "#fff" + } + } + ] + }, + "textMateRules": [ + { + "scope": "googletest.failed", + "settings": { + "foreground": "#f00" + } + }, + { + "scope": "googletest.passed", + "settings": { + "foreground": "#0f0" + } + }, + { + "scope": "googletest.run", + "settings": { + "foreground": "#0f0" + } + } + ] + }, + "gtest-adapter.debugConfig": [ + "Debug MathTestFPU (gdb)" + ], + "gtest-adapter.supportLocation": true, + "premake.version": "Premake 5.0-beta5", } \ No newline at end of file diff --git a/Engine/Source/Runtime/Core/Math/Detail/Vector2Decl.inl b/Engine/Source/Runtime/Core/Math/Detail/Vector2Decl.inl index 4406e14..ffc0d5e 100644 --- a/Engine/Source/Runtime/Core/Math/Detail/Vector2Decl.inl +++ b/Engine/Source/Runtime/Core/Math/Detail/Vector2Decl.inl @@ -175,8 +175,8 @@ namespace Phanes::Core::Math::Detail static constexpr bool map(const Phanes::Core::Math::TVector2& v1, const Phanes::Core::Math::TVector2& v2) { - return (Phanes::Core::Math::Abs(v1.x - v2.x) < P_FLT_INAC && - Phanes::Core::Math::Abs(v1.y - v2.y) < P_FLT_INAC); + return (Phanes::Core::Math::Abs(v1.x - v2.x) <= P_FLT_INAC && + Phanes::Core::Math::Abs(v1.y - v2.y) <= P_FLT_INAC); } }; diff --git a/Engine/Source/Runtime/Core/Math/Vector3.hpp b/Engine/Source/Runtime/Core/Math/Vector3.hpp index f4591a2..e2dbba6 100644 --- a/Engine/Source/Runtime/Core/Math/Vector3.hpp +++ b/Engine/Source/Runtime/Core/Math/Vector3.hpp @@ -707,7 +707,7 @@ namespace Phanes::Core::Math { */ template - TVector3& ClampToCubeV(TVector3 v1, T cubeRadius); + TVector3& ClampToCubeV(TVector3& v1, T cubeRadius); /** * Rotates vector around axis diff --git a/Engine/Source/Runtime/Core/Math/Vector3.inl b/Engine/Source/Runtime/Core/Math/Vector3.inl index 89bb6f1..a596963 100644 --- a/Engine/Source/Runtime/Core/Math/Vector3.inl +++ b/Engine/Source/Runtime/Core/Math/Vector3.inl @@ -292,7 +292,7 @@ namespace Phanes::Core::Math } template - TVector3& ClampToCubeV(TVector3 v1, T cubeRadius) + TVector3& ClampToCubeV(TVector3& v1, T cubeRadius) { Detail::compute_vec3_clamp::map(v1, v1, cubeRadius); return v1; diff --git a/MathTestFPU/main.cpp b/Engine/Source/Runtime/Core/Tests/Math/MathTestFPU/main.cpp similarity index 100% rename from MathTestFPU/main.cpp rename to Engine/Source/Runtime/Core/Tests/Math/MathTestFPU/main.cpp diff --git a/MathTestFPU/pch.cpp b/Engine/Source/Runtime/Core/Tests/Math/MathTestFPU/pch.cpp similarity index 100% rename from MathTestFPU/pch.cpp rename to Engine/Source/Runtime/Core/Tests/Math/MathTestFPU/pch.cpp diff --git a/Engine/Source/Runtime/Core/Tests/Math/MathTestFPU/pch.h b/Engine/Source/Runtime/Core/Tests/Math/MathTestFPU/pch.h new file mode 100644 index 0000000..00e3892 --- /dev/null +++ b/Engine/Source/Runtime/Core/Tests/Math/MathTestFPU/pch.h @@ -0,0 +1,7 @@ +// +// pch.h +// + +#pragma once + +#include "googletest/googletest/include/gtest/gtest.h" diff --git a/Engine/Source/Runtime/Core/Tests/Math/MathTestFPU/premake5.lua b/Engine/Source/Runtime/Core/Tests/Math/MathTestFPU/premake5.lua new file mode 100644 index 0000000..1055027 --- /dev/null +++ b/Engine/Source/Runtime/Core/Tests/Math/MathTestFPU/premake5.lua @@ -0,0 +1,39 @@ +project "gtest" + language "C++" + kind "StaticLib" + third_party_boilerplate() + + includedirs { + + PhanesThirdParty .. "/googletest/googletest/include", + PhanesThirdParty .. "/googletest/googletest/include/gtest", + PhanesThirdParty .. "/googletest/googletest" + + } + files { + PhanesThirdParty .. "/googletest/googletest/src/**.cc", + PhanesThirdParty .. "/googletest/googletest/include/gtest/**.h" + } + +project "MathTestFPU" + kind "ConsoleApp" + boilerplate() + + files { + PhanesRuntime .. "/Core/Tests/Math/MathTestFPU/test.cpp" + } + + buildoptions {"-Wno-unused-variable", "-w", "-fpermissive"} + + pchheader (PhanesRuntime .. "/Core/Tests/Math/MathTestFPU/pch.h") + pchsource (PhanesRuntime .. "/Core/Tests/Math/MathTestFPU/pch.cpp") + + links { "gtest" } + dependson { "gtest" } + + includedirs { + PhanesRuntime .. "/Core/Tests/Math/MathTestFPU", + PhanesThirdParty .. "/googletest/googletest/include", + PhanesThirdParty, + PhanesRuntime + } \ No newline at end of file diff --git a/MathTestFPU/test.cpp b/Engine/Source/Runtime/Core/Tests/Math/MathTestFPU/test.cpp similarity index 99% rename from MathTestFPU/test.cpp rename to Engine/Source/Runtime/Core/Tests/Math/MathTestFPU/test.cpp index 53a30c9..ca9879e 100644 --- a/MathTestFPU/test.cpp +++ b/Engine/Source/Runtime/Core/Tests/Math/MathTestFPU/test.cpp @@ -740,7 +740,8 @@ namespace VectorTests EXPECT_TRUE(PMath::CompInverseV(v0) == PMath::Vector3(1.0f / 2.4f, 1.0f / 3.1f, 1.0f / 5.6f)); v0 = PMath::Vector3(2.4f, 3.1f, 5.6f); - EXPECT_TRUE(PMath::ClampToCubeV(v0, 3.2f) == PMath::Vector3(2.4f, 3.1f, 3.2f)); + PMath::Vector3 test = PMath::ClampToCubeV(v0, 3.2f); + EXPECT_TRUE(test == PMath::Vector3(2.4f, 3.1f, 3.2f)); v0 = PMath::Vector3(2.4f, 3.1f, 5.6f); EXPECT_TRUE(PMath::RotateAroundAxisV(v0, PMath::Vector3(0.0f, 0.0f, 1.0f), (float)30.0_deg) == PMath::Vector3(3.628461f, 1.484679f, 5.600000f)) << PMath::ToString(PMath::RotateAroundAxisV(v0, PMath::Vector3(0.0f, 0.0f, 1.0f), (float)30.0_deg)); @@ -933,16 +934,16 @@ namespace MatrixTests PMath::Matrix2 m0 = PMath::Matrix2(1.0f, 5.0f, 3.0f, 2.0f); m0 += 2.0f; - EXPECT_TRUE(m0 == PMath::Matrix2(3.0f, 7.0f, 5.0f, 4.0f)); + EXPECT_TRUE(m0 == PMath::Matrix2(3.0f, 7.0f, 5.0f, 4.0f)) << PMath::ToString(m0); m0 -= 2.0f; - EXPECT_TRUE(m0 == PMath::Matrix2(1.0f, 5.0f, 3.0f, 2.0f)); + EXPECT_TRUE(m0 == PMath::Matrix2(1.0f, 5.0f, 3.0f, 2.0f)) << PMath::ToString(m0); m0 *= 2.0f; - EXPECT_TRUE(m0 == PMath::Matrix2(2.0f, 10.0f, 6.0f, 4.0f)); + EXPECT_TRUE(m0 == PMath::Matrix2(2.0f, 10.0f, 6.0f, 4.0f)) << PMath::ToString(m0); m0 /= 2.0f; - EXPECT_TRUE(m0 == PMath::Matrix2(1.0f, 5.0f, 3.0f, 2.0f)); + EXPECT_TRUE(m0 == PMath::Matrix2(1.0f, 5.0f, 3.0f, 2.0f)) << PMath::ToString(m0); m0 = m0 + 2.0f; @@ -998,7 +999,7 @@ namespace MatrixTests EXPECT_FLOAT_EQ(PMath::Determinant(m0), -13.0f); - EXPECT_TRUE(PMath::InverseV(m0) == PMath::Matrix2(-2.0f / 13.0f, 5.0f / 13.0f, 3.0f / 13.0f, -1.0f / 13.0f)); + EXPECT_TRUE(PMath::InverseV(m0) == PMath::Matrix2(-2.0f / 13.0f, 5.0f / 13.0f, 3.0f / 13.0f, -1.0f / 13.0f)) << PMath::ToString(m0); m0 = PMath::Matrix2(1.0f, 5.0f, 3.0f, 2.0f); EXPECT_TRUE(PMath::TransposeV(m0) == PMath::Matrix2(1.0f, 3.0f, 5.0f, 2.0f)); @@ -1269,4 +1270,11 @@ namespace Plane PMath::Plane pl2 = PMath::Plane(-0.526316f, -0.442105f, -0.726316f, 6.0f); } +} + + +int main(int argc, char** argv) +{ + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); } \ No newline at end of file diff --git a/MathTestFPU/pch.h b/MathTestFPU/pch.h deleted file mode 100644 index 0572a70..0000000 --- a/MathTestFPU/pch.h +++ /dev/null @@ -1,7 +0,0 @@ -// -// pch.h -// - -#pragma once - -#include "gtest/gtest.h" diff --git a/MathTestFPU/premake5.lua b/MathTestFPU/premake5.lua deleted file mode 100644 index 0bf65ef..0000000 --- a/MathTestFPU/premake5.lua +++ /dev/null @@ -1,29 +0,0 @@ -project "MathTestFPU" - kind "ConsoleApp" - boilerplate() - - files { - phanesRoot .. "/MathTestFPU/test.cpp" - } - - buildoptions {"-Wno-unused-variable", "-w", "-fpermissive"} - - pchheader "pch.h" - pchsource "pch.cpp" - - includedirs { - phanesRoot .. "/MathTestFPU", - PhanesRuntime - } - -project "Test" - kind "ConsoleApp" - boilerplate() - - files { - phanesRoot .. "/MathTestFPU/main.cpp" - } - - includedirs { - PhanesRuntime - } \ No newline at end of file diff --git a/premake5.lua b/premake5.lua index c60c7ce..a17b11b 100644 --- a/premake5.lua +++ b/premake5.lua @@ -33,7 +33,8 @@ workspace "PhanesEngine" toolset "gcc" flags { "MultiProcessorCompile" } clangtidy "On" - llvmversion "19.0" + debugger "gdb" + startproject "MathTestFPU" configurations { "Debug", "Release" } @@ -62,6 +63,7 @@ function boilerplate() if PLATFORM == "linux" then defines { "P_LINUX_BUILD" } + buildoptions {"-Wall", "-Wextra", "-Werror"} linux_sse() buildoptions { "-Wno-unused-parameter" , "-fms-extensions" } end @@ -81,6 +83,33 @@ function boilerplate() filter{} end +function third_party_boilerplate() + language "C++" + + location (phanesBuildFiles .. "/%{prj.name}") + targetdir (phanesBin .. "/" .. VERSION .. "/%{cfg.buildcfg}/%{prj.name}") + objdir (phanesInt .. "/" .. VERSION .. "/%{cfg.buildcfg}/%{prj.name}") + + if PLATFORM == "linux" then + buildoptions {"-Wall", "-Wextra", "-Werror"} + linux_sse() + end + + filter "configurations:Debug" + defines { "DEBUG", "TRACE", "P_DEBUG"} + symbols "On" + buildmessage("Building %{prj.name} in debug mode") + + filter "configurations:Release" + defines { "NDEBUG", "P_RELEASE" } + linktimeoptimization "On" + optimize "On" + intrinsics "On" + buildmessage("Building %{prj.name} in release mode") + + filter{} +end + -- actions function action_clean() @@ -97,6 +126,6 @@ newaction { } -- includeProjects here -include "Engine/Source/Runtime/Core/premake5.lua" -include "DevPlayground/premake5.lua" -include "MathTestFPU/premake5.lua" \ No newline at end of file +include (phanesRoot .. "/Engine/Source/Runtime/Core/premake5.lua") +include (phanesRoot .. "/DevPlayground/premake5.lua") +include (PhanesRuntime .. "/Core/Tests/Math/MathTestFPU/premake5.lua") \ No newline at end of file