From 76ceaae25bf90b4135abb6015efe0856185913ae Mon Sep 17 00:00:00 2001 From: maelstrom Date: Mon, 21 Apr 2025 23:10:26 +0200 Subject: [PATCH] chore: build reactphysics3d automatically via vcpkg --- CMakePresets.json | 8 +++++++ core/src/rendering/surface.cpp | 4 ++-- editor/mainglwidget.cpp | 6 +++-- vcpkg-configuration.json | 3 +++ vcpkg-overlays/reactphysics3d/portfile.cmake | 23 +++++++++++++++++++ .../reactphysics3d/std_chrono.patch | 12 ++++++++++ vcpkg-overlays/reactphysics3d/vcpkg.json | 18 +++++++++++++++ vcpkg.json | 9 +++++++- 8 files changed, 78 insertions(+), 5 deletions(-) mode change 100644 => 100755 editor/mainglwidget.cpp mode change 100644 => 100755 vcpkg-configuration.json create mode 100755 vcpkg-overlays/reactphysics3d/portfile.cmake create mode 100755 vcpkg-overlays/reactphysics3d/std_chrono.patch create mode 100755 vcpkg-overlays/reactphysics3d/vcpkg.json mode change 100644 => 100755 vcpkg.json diff --git a/CMakePresets.json b/CMakePresets.json index f1fa39b..f6fda18 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -8,6 +8,14 @@ "cacheVariables": { "CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" } + }, + { + "name": "vcpkg-linux", + "generator": "Ninja", + "binaryDir": "${sourceDir}/build", + "cacheVariables": { + "CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" + } } ] } \ No newline at end of file diff --git a/core/src/rendering/surface.cpp b/core/src/rendering/surface.cpp index dd3d873..966edd1 100644 --- a/core/src/rendering/surface.cpp +++ b/core/src/rendering/surface.cpp @@ -1,14 +1,14 @@ #include "surface.h" #include "datatypes/vector.h" -static std::array FACE_NORMALS = {{ +Data::Vector3 FACE_NORMALS[6] = { { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 }, { -1, 0, 0 }, { 0, -1, 0 }, { 0, 0, -1 }, -}}; +}; NormalId faceFromNormal(Data::Vector3 normal) { for (int face = 0; face < 6; face++) { diff --git a/editor/mainglwidget.cpp b/editor/mainglwidget.cpp old mode 100644 new mode 100755 index b8e138e..0d4cdb7 --- a/editor/mainglwidget.cpp +++ b/editor/mainglwidget.cpp @@ -11,6 +11,8 @@ #include "rendering/renderer.h" #include "rendering/shader.h" +#define PI 3.14159 + static Data::CFrame XYZToZXY(glm::vec3(0, 0, 0), -glm::vec3(1, 0, 0), glm::vec3(0, 0, 1)); MainGLWidget::MainGLWidget(QWidget* parent): QOpenGLWidget(parent) { @@ -271,7 +273,7 @@ void MainGLWidget::handleRotationalTransform(QMouseEvent* evt) { // Snap the angle if (snappingFactor() > 0) - angle = roundf(angle * 4 / std::numbers::pi / snappingFactor()) / 4 * std::numbers::pi * snappingFactor(); + angle = roundf(angle * 4 / PI / snappingFactor()) / 4 * PI * snappingFactor(); // Checks if the rotation axis is facing towards, or away from the camera // If it pointing away from the camera, then we need to invert the angle change @@ -483,4 +485,4 @@ float MainGLWidget::snappingFactor() { case GridSnappingMode::SNAP_OFF: return 0; } return 0; -} \ No newline at end of file +} diff --git a/vcpkg-configuration.json b/vcpkg-configuration.json old mode 100644 new mode 100755 index 610f6b3..32d5985 --- a/vcpkg-configuration.json +++ b/vcpkg-configuration.json @@ -10,5 +10,8 @@ "location": "https://github.com/microsoft/vcpkg-ce-catalog/archive/refs/heads/main.zip", "name": "microsoft" } + ], + "overlay-ports": [ + "./vcpkg-overlays" ] } diff --git a/vcpkg-overlays/reactphysics3d/portfile.cmake b/vcpkg-overlays/reactphysics3d/portfile.cmake new file mode 100755 index 0000000..4fcf036 --- /dev/null +++ b/vcpkg-overlays/reactphysics3d/portfile.cmake @@ -0,0 +1,23 @@ +vcpkg_check_linkage(ONLY_STATIC_LIBRARY) + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO DanielChappuis/reactphysics3d + REF "cd958bbc0c6e84a869388cba6613f10cc645b3cb" + SHA512 9856c0e998473e0bfb97af9ced07952bbd4dfef79f7dc388b1ecf9b6c6406f7669333e441fe6cefdf40b32edc5a1b8e4cb35a8c15fccb64c28785aff5fd77113 + HEAD_REF master + PATCHES "std_chrono.patch" +) + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" +) + +vcpkg_cmake_install() + +vcpkg_cmake_config_fixup(PACKAGE_NAME "reactphysics3d" CONFIG_PATH "lib/cmake/ReactPhysics3D") + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") + +# file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE") \ No newline at end of file diff --git a/vcpkg-overlays/reactphysics3d/std_chrono.patch b/vcpkg-overlays/reactphysics3d/std_chrono.patch new file mode 100755 index 0000000..9dcdb55 --- /dev/null +++ b/vcpkg-overlays/reactphysics3d/std_chrono.patch @@ -0,0 +1,12 @@ +diff --git a/include/reactphysics3d/utils/DefaultLogger.h b/include/reactphysics3d/utils/DefaultLogger.h +index 1088d1e..8360f07 100644 +--- a/include/reactphysics3d/utils/DefaultLogger.h ++++ b/include/reactphysics3d/utils/DefaultLogger.h +@@ -37,6 +37,7 @@ + #include + #include + #include ++#include + + /// ReactPhysics3D namespace + namespace reactphysics3d { diff --git a/vcpkg-overlays/reactphysics3d/vcpkg.json b/vcpkg-overlays/reactphysics3d/vcpkg.json new file mode 100755 index 0000000..d472e95 --- /dev/null +++ b/vcpkg-overlays/reactphysics3d/vcpkg.json @@ -0,0 +1,18 @@ +{ + "name": "reactphysics3d", + "version": "0.10.2", + "homepage": "https://github.com/DanielChappuis/reactphysics3d", + "description": "Open source C++ physics engine library in 3D", + "license": "zlib", + "dependencies": [ + { + "name" : "vcpkg-cmake", + "host" : true + }, + { + "name" : "vcpkg-cmake-config", + "host" : true + }, + "fmt" + ] + } \ No newline at end of file diff --git a/vcpkg.json b/vcpkg.json old mode 100644 new mode 100755 index c07fcf7..69bee7a --- a/vcpkg.json +++ b/vcpkg.json @@ -5,6 +5,13 @@ "glm", { "name": "pugixml", "version>=": "1.15" }, "sdl2", - "stb" + "stb", + "reactphysics3d" + ], + "overrides": [ + { + "name": "sdl2", + "version": "2.32.4" + } ] }