JoltPhysics

2025-12-10 0 112

Jolt Physics

A multi core friendly rigid body physics and collision detection library. Suitable for games and VR applications. Used by Horizon Forbidden West and Death Stranding 2: On the Beach.

A YouTube video showing a ragdoll pile simulated with Jolt Physics.

For more demos and videos go to the Samples section.

Design considerations

Why create yet another physics engine? Firstly, it has been a personal learning project. Secondly, I wanted to address some issues that I had with existing physics engines:

  • Games do more than simulating physics. These things happen across multiple threads. We emphasize on concurrently accessing physics data outside of the main simulation update:
    • Sections of the simulation can be loaded / unloaded in the background. We prepare a batch of physics bodies on a background thread without locking or affecting the simulation. We insert the batch into the simulation with a minimal impact on performance.
    • Collision queries can run parallel to adding / removing or updating a body. If a change to a body happened on the same thread, the change will be immediately visible. If the change happened on another thread, the query will see a consistent before or after state. An alternative would be to have a read and write version of the world. This prevents changes from being visible immediately, so we avoid this.
    • Collision queries can run parallel to the main physics simulation. We do a coarse check (broad phase query) before the simulation step and do fine checks (narrow phase query) in the background. This way, long running processes (like navigation mesh generation) can be spread out across multiple frames.
  • Accidental wake up of bodies cause performance problems when loading / unloading content. Therefore, bodies will not automatically wake up when created. Neighboring bodies will not be woken up when bodies are removed. This can be triggered manually if desired.
  • The simulation runs deterministically. You can replicate a simulation to a remote client by merely replicating the inputs to the simulation. Read the Deterministic Simulation section to understand the limits.
  • We try to simulate behavior of rigid bodies in the real world but make approximations. Therefore, this library should mainly be used for games or VR simulations.

Features

  • Simulation of rigid bodies of various shapes using continuous collision detection:
    • Sphere
    • Box
    • Capsule
    • Tapered-capsule
    • Cylinder
    • Tapered-cylinder
    • Convex hull
    • Plane
    • Compound
    • Mesh (triangle)
    • Terrain (height field)
  • Simulation of constraints between bodies:
    • Fixed
    • Point
    • Distance (including springs)
    • Hinge
    • Slider (also called prismatic)
    • Cone
    • Rack and pinion
    • Gear
    • Pulley
    • Smooth spline paths
    • Swing-twist (for humanoid shoulders)
    • 6 DOF
  • Motors to drive the constraints.
  • Collision detection:
    • Casting rays.
    • Testing shapes vs shapes.
    • Casting a shape vs another shape.
    • Broadphase only tests to quickly determine which objects may intersect.
  • Sensors (trigger volumes).
  • Animated ragdolls:
    • Hard keying (kinematic only rigid bodies).
    • Soft keying (setting velocities on dynamic rigid bodies).
    • Driving constraint motors to an animated pose.
    • Mapping a high detail (animation) skeleton onto a low detail (ragdoll) skeleton and vice versa.
  • Game character simulation (capsule)
    • Rigid body character. Moves during the physics simulation. Cheapest option and most accurate collision response between character and dynamic bodies.
    • Virtual character. Does not have a rigid body in the simulation but simulates one using collision checks. Updated outside of the physics update for more control. Less accurate interaction with dynamic bodies.
  • Vehicles
    • Wheeled vehicles.
    • Tracked vehicles.
    • Motorcycles.
  • Soft body simulation (e.g. a soft ball or piece of cloth).
    • Edge constraints.
    • Dihedral bend constraints.
    • Cosserat rod constraints (an edge with an orientation that can be used to orient geometry, e.g. a plant leaf).
    • Tetrahedron volume constraints.
    • Long range attachment constraints (also called tethers).
    • Limiting the simulation to stay within a certain range of a skinned vertex.
    • Internal pressure.
    • Collision with simulated rigid bodies.
    • Collision tests against soft bodies.
  • Water buoyancy calculations.
  • An optional double precision mode that allows large worlds.

Supported platforms

  • Windows (Desktop or UWP) x86/x64/ARM32/ARM64
  • Linux (tested on Ubuntu) x86/x64/ARM32/ARM64/RISC-V64/LoongArch64/PowerPC64LE
  • FreeBSD
  • Android x86/x64/ARM32/ARM64
  • Platform Blue (a popular game console) x64
  • macOS x64/ARM64
  • iOS x64/ARM64
  • MSYS2 MinGW64
  • WebAssembly, see this separate project.

Required CPU features

  • On x86/x64 the minimal requirements are SSE2. The library can be compiled using SSE4.1, SSE4.2, AVX, AVX2, or AVX512.
  • On ARM64 the library uses NEON and FP16. On ARM32 it can be compiled without any special CPU instructions.

Documentation

To get started, look at the HelloWorld example. A HelloWorld example using CMake FetchContent is also available to show how you can integrate Jolt Physics in a CMake project.

Every feature in Jolt has its own sample. Running the Samples application and browsing through the code is a great way to learn about the library!

To learn more about Jolt go to the latest Architecture and API documentation. Documentation for a specific release is also available.

Some algorithms used by Jolt are described in detail in my GDC 2022 talk: Architecting Jolt Physics for \’Horizon Forbidden West\’ (slides, slides with speaker notes, video).

Compiling

  • Compiles with Visual Studio 2019+, Clang 10+ or GCC 9+.
  • Uses C++ 17.
  • Depends only on the standard template library.
  • Doesn\’t use RTTI.
  • Doesn\’t use exceptions.

If you want to run on Platform Blue you\’ll need to provide your own build environment and PlatformBlue.h due to NDA requirements. This file is available on the Platform Blue developer forum.

For build instructions go to the Build section. When upgrading from an older version of the library go to the Release Notes or API Changes sections.

Performance

If you\’re interested in how Jolt scales with multiple CPUs and compares to other physics engines, take a look at this document.

Folder structure

  • Assets – This folder contains assets used by the TestFramework, Samples and JoltViewer.
  • Build – Contains everything needed to build the library, see the Build section.
  • Docs – Contains documentation for the library.
  • HelloWorld – A simple application demonstrating how to use the Jolt Physics library.
  • Jolt – All source code for the library is in this folder.
  • JoltViewer – It is possible to record the output of the physics engine using the DebugRendererRecorder class (a .jor file), this folder contains the source code to an application that can visualize a recording. This is useful for e.g. visualizing the output of the PerformanceTest from different platforms. Currently available on Windows, macOS and Linux.
  • PerformanceTest – Contains a simple application that runs a performance test and collects timing information.
  • Samples – This contains the sample application, see the Samples section. Currently available on Windows, macOS and Linux.
  • TestFramework – A rendering framework to visualize the results of the physics engine. Used by Samples and JoltViewer. Currently available on Windows, macOS and Linux.
  • UnitTests – A set of unit tests to validate the behavior of the physics engine.

Bindings for other languages

  • C here, here and here
  • C#
  • Java or Kotlin
  • JavaScript
  • Rust
  • Zig

Integrations in other engines

  • Godot
  • Source Engine

See a list of projects that use Jolt Physics here.

License

The project is distributed under the MIT license.

Contributions

All contributions are welcome! If you intend to make larger changes, please discuss first in the GitHub Discussion section. For non-trivial changes, we require that you agree to a Contributor Agreement. When you create a PR, CLA assistant will prompt you to sign it.

Note that all PRs will be squashed before merging, so there\’s no need to force-push to git to keep the history clean.

下载源码

通过命令行克隆项目:

git clone https://github.com/jrouwe/JoltPhysics.git

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

申明:本文由第三方发布,内容仅代表作者观点,与本网站无关。对本文以及其中全部或者部分内容的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。本网发布或转载文章出于传递更多信息之目的,并不意味着赞同其观点或证实其描述,也不代表本网对其真实性负责。

左子网 编程相关 JoltPhysics https://www.zuozi.net/33566.html

cpprestsdk
上一篇: cpprestsdk
常见问题
  • 1、自动:拍下后,点击(下载)链接即可下载;2、手动:拍下后,联系卖家发放即可或者联系官方找开发者发货。
查看详情
  • 1、源码默认交易周期:手动发货商品为1-3天,并且用户付款金额将会进入平台担保直到交易完成或者3-7天即可发放,如遇纠纷无限期延长收款金额直至纠纷解决或者退款!;
查看详情
  • 1、描述:源码描述(含标题)与实际源码不一致的(例:货不对板); 2、演示:有演示站时,与实际源码小于95%一致的(但描述中有”不保证完全一样、有变化的可能性”类似显著声明的除外); 3、发货:不发货可无理由退款; 4、安装:免费提供安装服务的源码但卖家不履行的; 5、收费:价格虚标,额外收取其他费用的(但描述中有显著声明或双方交易前有商定的除外); 6、其他:如质量方面的硬性常规问题BUG等。 注:经核实符合上述任一,均支持退款,但卖家予以积极解决问题则除外。
查看详情
  • 1、左子会对双方交易的过程及交易商品的快照进行永久存档,以确保交易的真实、有效、安全! 2、左子无法对如“永久包更新”、“永久技术支持”等类似交易之后的商家承诺做担保,请买家自行鉴别; 3、在源码同时有网站演示与图片演示,且站演与图演不一致时,默认按图演作为纠纷评判依据(特别声明或有商定除外); 4、在没有”无任何正当退款依据”的前提下,商品写有”一旦售出,概不支持退款”等类似的声明,视为无效声明; 5、在未拍下前,双方在QQ上所商定的交易内容,亦可成为纠纷评判依据(商定与描述冲突时,商定为准); 6、因聊天记录可作为纠纷评判依据,故双方联系时,只与对方在左子上所留的QQ、手机号沟通,以防对方不承认自我承诺。 7、虽然交易产生纠纷的几率很小,但一定要保留如聊天记录、手机短信等这样的重要信息,以防产生纠纷时便于左子介入快速处理。
查看详情

相关文章

猜你喜欢
发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务