A general-purpose physics engine.
GyPhysics/
├── CMakeLists.txt
├── cmake/
│ └── GyPhysicsWarnings.cmake
├── modules/
│ ├── math/
│ │ ├── include/gy/physics/math/MathTypes.h
│ │ └── tests/MathTypesTest.cpp
│ └── rigid/
│ ├── include/gy/physics/rigid/RigidBody.h
│ ├── src/RigidBody.cpp
│ └── tests/RigidBodyTest.cpp
└── examples/
└── rigid/main.cpp
sudo apt update
sudo apt install build-essential cmake ninja-build libeigen3-devcd /path/GYPhysics
cmake -S . -B build-double -G Ninja -DCMAKE_BUILD_TYPE=Release -DGY_PHYSICS_REAL_TYPE=DOUBLE -DBUILD_TESTING=ON -DGY_PHYSICS_BUILD_EXAMPLES=ON
cmake --build build-double -j "$(nproc)"
ctest --test-dir build-double --output-on-failure
./build-double/examples/rigid/gyphysics_rigid_examplecd /path/GYPhysics
cmake -S . -B build-float -G Ninja -DCMAKE_BUILD_TYPE=Release -DGY_PHYSICS_REAL_TYPE=FLOAT -DBUILD_TESTING=ON -DGY_PHYSICS_BUILD_EXAMPLES=ON
cmake --build build-float -j "$(nproc)"
ctest --test-dir build-float --output-on-failure
./build-float/examples/rigid/gyphysics_rigid_exampleOnly compile and run Math tests:
cd /path/GYPhysics
cmake -S . -B build-double -G Ninja -DCMAKE_BUILD_TYPE=Release -DGY_PHYSICS_REAL_TYPE=DOUBLE -DBUILD_TESTING=ON -DGY_PHYSICS_BUILD_EXAMPLES=ON
cmake --build build-double --target gyphysics_math_tests -j "$(nproc)"
ctest --test-dir build-double -R '^gyphysics\.math$' --output-on-failureOnly compile and run Rigid tests:
cmake -S . -B build-double -G Ninja -DCMAKE_BUILD_TYPE=Release -DGY_PHYSICS_REAL_TYPE=DOUBLE -DBUILD_TESTING=ON -DGY_PHYSICS_BUILD_EXAMPLES=ON
cmake --build build-double --target gyphysics_rigid -j "$(nproc)"
cmake --build build-double --target gyphysics_rigid_tests -j "$(nproc)"
ctest --test-dir build-double -R '^gyphysics\.rigid$' --output-on-failureOnly compile Rigid library:
cmake --build build-double --target gyphysics_rigid| 模块 | CMake 目标 | C++ 命名空间 |
|---|---|---|
| Math | GyPhysics::Math |
gy::physics::math |
| Rigid | GyPhysics::Rigid |
gy::physics::rigid |
RigidBody do not use Eigen::Vector3d or Eigen::Vector3f, use:
gy::physics::math::Real
gy::physics::math::Vector3
gy::physics::math::Matrix3
gy::physics::math::QuaternionWindows Compile and Install: Download MSYS2, and open MSYS2 UCRT64. Install the latest packages in MSYS2 UCRT64. If it suggests close terminal, close and reopen it:
pacman -SyuInstall the required packages:
pacman -S --needed \
mingw-w64-ucrt-x86_64-toolchain \
mingw-w64-ucrt-x86_64-cmake \
mingw-w64-ucrt-x86_64-ninja \
mingw-w64-ucrt-x86_64-eigen3 \
mingw-w64-ucrt-x86_64-clang-tools-extraSuggest use Tsinghua mirror:
sed -i "s#https\?://mirror.msys2.org/#https://mirrors.tuna.tsinghua.edu.cn/msys2/#g" /etc/pacman.d/mirrorlist*
grep -n "tuna" /etc/pacman.d/mirrorlist*
pacman -Syyu
pacman -Syu