# 物理引擎

物理引擎是实时模拟物理运动的软件，最常见的是刚体动力学：它检测物体何时碰撞，计算由此产生的力和冲量，并随时间推进物体的位置和旋转。游戏引擎内嵌物理引擎，使物体在重力下加速、对碰撞作出响应，无需手工制作动画就能表现得自然可信。<sup>[1](https://docs.unity3d.com/es/current/Manual/PhysicsSection.html)</sup><sup> • </sup><sup>[2](https://docs.godotengine.org/en/stable/tutorials/physics/physics_introduction.html)</sup>

| 关键事实 | 详情 |
|---|---|
| 核心循环 | 每一步执行碰撞检测、运动积分和约束求解；Box2D 的 `b2World_Step` 是典型示例。<sup>[3](https://box2d.org/documentation/group__world.html)</sup> |
| 时间步进 | 引擎最适合使用较小的固定时间步长；Box2D 建议 1/30 秒或更小，1/60 秒通常能提供高质量结果。<sup>[4](https://box2d.org/documentation/md_simulation.html)</sup> |
| 子步进 | 将一帧划分为多个子步可提高精度，但增加 CPU 开销；Box2D 建议 4 个子步，而 Unreal 的子步进能显著减少布娃娃抖动。<sup>[4](https://box2d.org/documentation/md_simulation.html)</sup><sup> • </sup><sup>[5](https://dev.epicgames.com/documentation/en-us/unreal-engine/physics-sub-stepping-in-unreal-engine)</sup> |
| 穿透与 CCD | 高速物体可能在两步之间穿过薄障碍物；连续碰撞检测扫掠形状并计算撞击时间以防止这种情况。<sup>[4](https://box2d.org/documentation/md_simulation.html)</sup> |
| 确定性 | Godot 明确表示其物理模拟无论使用哪个引擎都不是确定性的：相同情况不保证以相同方式运行。<sup>[2](https://docs.godotengine.org/en/stable/tutorials/physics/physics_introduction.html)</sup> |
| Unity 中的引擎选择 | 内置 3D 物理（集成 Nvidia PhysX）、内置 2D 物理（集成 Box2D），以及面向数据导向项目的 Unity Physics 和 Havok Physics 包。<sup>[1](https://docs.unity3d.com/es/current/Manual/PhysicsSection.html)</sup> |
| Unreal Engine 5 | 使用 Chaos 求解器，提供刚体动力学、碰撞响应、物理约束、异步模拟和网络物理。<sup>[6](https://dev.epicgames.com/documentation/unreal-engine/physics-in-unreal-engine?lang=en-US)</sup> |
| 游戏之外 | Bullet 用于 VR、视觉特效、机器人学和机器学习，提供 PyBullet Python 绑定，并可选通过 OpenCL 在 GPU 上执行碰撞检测和刚体动力学。<sup>[7](https://github.com/bulletphysics/bullet3)</sup> |

## 物理引擎做什么

该领域有两个核心问题。**碰撞检测**回答两个物体是否相交或接触；**碰撞响应**决定接下来发生什么，通常是一个将物体分开并模拟摩擦和弹性的冲量。<sup>[2](https://docs.godotengine.org/en/stable/tutorials/physics/physics_introduction.html)</sup> 引擎用少量接触点近似接触：Box2D 处理凸形状，用 0、1 或 2 个点表示两个形状之间的接触，这些点与共享的接触法线一起组成接触流形。<sup>[4](https://box2d.org/documentation/md_simulation.html)</sup>

**刚体**是标准的模拟对象。刚体有质量且永不形变；附着在同一刚体上的形状彼此之间不会相对移动，也不会相互碰撞。<sup>[4](https://box2d.org/documentation/md_simulation.html)</sup> 用户不直接设置刚体的位置，而是施加力、重力和冲量，由引擎计算由此产生的运动。<sup>[2](https://docs.godotengine.org/en/stable/tutorials/physics/physics_introduction.html)</sup> 在 Bullet 的 API 中，刚体是动态的当且仅当其质量非零；质量为零则使其成为静态。<sup>[8](https://github.com/bulletphysics/bullet3/blob/master/examples/HelloWorld/HelloWorld.cpp)</sup>

**约束**使物体保持关系。关节将物体彼此连接或连接到世界，游戏中的例子包括布娃娃、跷跷板和滑轮；关节可以带有运动范围限制、以规定速度驱动运动直到超过力或力矩限制的马达，以及具有刚度和阻尼的弹簧。<sup>[4](https://box2d.org/documentation/md_simulation.html)</sup><sup> • </sup><sup>[9](https://box2d.org/documentation/)</sup> 接触本身由一种特殊的接触约束处理，该约束自动创建，防止穿透并模拟摩擦和回弹。<sup>[9](https://box2d.org/documentation/)</sup> 约束求解器计算满足这些约束的冲量或力，并将其施加到受约束的物体上。<sup>[10](https://box2d.org/files/ErinCatto_ModelingAndSolvingConstraints_GDC2009.pdf)</sup> Box2D 的求解器是顺序求解器，运行时间为 N 阶，其中 N 是约束数量。<sup>[9](https://box2d.org/documentation/)</sup>

## 时间步进与稳定性

引擎以离散步骤推进时间，步长控制速度、精度和稳定性之间的权衡。Box2D 建议使用 1/30 秒（30 Hz）或更小的固定时间步长，并指出 1/60 秒（60 Hz）通常能提供高质量模拟；较大的步长在低帧率下提高性能但降低质量。<sup>[4](https://box2d.org/documentation/md_simulation.html)</sup>

**子步进**将一帧的时间划分为多个较小的求解器步。在 Box2D 中，子步数是世界步的一个参数，推荐值为 4；更多子步让关节和接触以更精细的细节响应，长关节链的拉伸也更小。剪叉式升降机示例以 8 个子步运行，因此当主步长为 1/60 秒时，其求解器以 480 Hz 运行。<sup>[4](https://box2d.org/documentation/md_simulation.html)</sup>

游戏引擎使这一点复杂化，因为它们以可变帧率渲染。Unreal Engine 5 使用可变帧率以实现硬件可扩展性，这对最适合小固定步长的物理引擎构成挑战；其子步进功能取总帧时间，将其划分为子步，并每帧多次推进模拟。较小的最大子步时间以更高的 CPU 开销换取更稳定的模拟。<sup>[5](https://dev.epicgames.com/documentation/en-us/unreal-engine/physics-sub-stepping-in-unreal-engine)</sup> 子步进对用户是隐藏的，因此引擎必须插值或维护跨子步的调用：如果一帧被划分为 N 个子步，那么为该帧施加的力就必须在 N 个连续模拟步中施加；目标位置必须在子步间插值以保持期望速度。Unreal 还将碰撞回调延迟到最后一个子步，这意味着单帧可能对同一碰撞产生多个回调，例如重叠在同一帧内开始和结束。<sup>[5](https://dev.epicgames.com/documentation/en-us/unreal-engine/physics-sub-stepping-in-unreal-engine)</sup> Unreal 的子步进最明显地改善布娃娃和其他复杂物理资产，文档指示开发者权衡质量提升与 CPU 开销；该功能在移动设备上不受支持。<sup>[5](https://dev.epicgames.com/documentation/en-us/unreal-engine/physics-sub-stepping-in-unreal-engine)</sup>

## 穿透与连续碰撞

离散模拟每步将每个物体移动有限量，因此快速物体可能完全跳过薄障碍物；这种失败称为穿透。<sup>[4](https://box2d.org/documentation/md_simulation.html)</sup> 引擎用连续碰撞检测（CCD）来应对。Box2D 默认在动态和静态物体之间启用 CCD，将形状从旧位置扫掠到新位置并计算撞击时间（TOI）；在步结束时将物体移动到其首次撞击时刻所对应的位置。CCD 通常不在动态物体之间使用，以保持性能合理。标记为子弹的物体对除其他子弹以外的所有物体类型执行 CCD，但文档建议谨慎使用该标记。<sup>[4](https://box2d.org/documentation/md_simulation.html)</sup> Box2D 还使用推测性碰撞，在物体接触之前就创建接触约束。<sup>[9](https://box2d.org/documentation/)</sup>

## 刚体与碰撞对象模型

引擎暴露少量刚体类型。Godot 在 2D 中提供四种碰撞对象类型：`Area2D` 节点检测重叠并可覆盖局部物理属性如重力或阻尼；`StaticBody2D` 参与碰撞但从不因响应而移动；`RigidBody2D` 实现完整的模拟动力学；第四种运动学类型补全了集合，全部继承自 `CollisionObject2D`。<sup>[2](https://docs.godotengine.org/en/stable/tutorials/physics/physics_introduction.html)</sup> 每个 2D 对象和碰撞形状都有对应的 3D 等价物，工作方式大致相同。<sup>[2](https://docs.godotengine.org/en/stable/tutorials/physics/physics_introduction.html)</sup> Godot 的内置 2D 引擎是自定义的，以像素而非米为单位调校，因此其单位和默认稳定值针对像素级开发设定。<sup>[11](https://docs.godotengine.org/en/2.1/learning/features/physics/physics_introduction.html)</sup>

碰撞几何体保持简单。Box2D 的形状基元是圆形、胶囊形、线段和凸多边形，其碰撞算法要求两个碰撞形状中至少有一个具有足够大的正面积；碰撞接口（包括动态包围体树和射线投射）设计为也可在刚体模拟之外使用。<sup>[12](https://box2d.org/documentation/md_collision.html)</sup>

## 实践中的引擎

**Unity** 提供多种实现，按项目类型选择：基于 Nvidia PhysX 集成的内置 3D 物理、基于 Box2D 的内置 2D 物理，以及对于使用面向数据技术栈（DOTS）的项目，提供 Unity Physics 包和作为许可扩展的 Havok Physics for Unity。<sup>[1](https://docs.unity3d.com/es/current/Manual/PhysicsSection.html)</sup> Unity 还允许通过特定本地 `PhysicsScene` 实例上的 `Physics.Simulate(float stepTime)` 手动控制模拟。<sup>[13](https://docs.unity3d.com/jp/current/Manual/physics-optimization-cpu-manual-simulation.html)</sup>

**Unreal Engine 5** 使用 Chaos 作为其物理求解器，位于引擎源码的 Experimental 运行时模块下。Chaos 提供带碰撞响应的刚体动力学、物理约束、阻尼和摩擦、异步物理模拟和网络物理；Chaos 可视化调试器在游戏过程中记录模拟状态，并回放以检查任意帧或子步。<sup>[6](https://dev.epicgames.com/documentation/unreal-engine/physics-in-unreal-engine?lang=en-US)</sup> 专用系统在其上构建，例如 Chaos Vehicles（轻量级车辆物理系统）和 Chaos Fields（使用空间区域通过锚点、应变/力和休眠/禁用场控制模拟属性）。<sup>[14](https://dev.epicgames.com/documentation/unreal-engine/chaos-vehicles)</sup><sup> • </sup><sup>[15](https://dev.epicgames.com/documentation/en-us/unreal-engine/chaos-fields-user-guide-in-unreal-engine)</sup>

**Bullet** 是一个开源 C++ SDK，用于实时碰撞检测和多物理模拟，面向 VR、游戏、视觉特效、机器人学和机器学习。其 PyBullet Python 绑定推荐用于机器人学、强化学习和 VR 工作，可从 URDF、SDF 和 MJCF 格式加载关节体，并提供正向和逆向动力学、运动学和碰撞查询。整个碰撞检测和刚体动力学可通过 OpenCL 在 GPU 上运行，已在 AMD Radeon 7970 或 NVIDIA GTX 680 及更高端台式机 GPU 上测试。<sup>[7](https://github.com/bulletphysics/bullet3)</sup><sup> • </sup><sup>[16](https://github.com/bulletphysics/bullet3/blob/master/docs/pybullet_quickstart_guide/PyBulletQuickstartGuide.md.html)</sup> Bullet 还支持软体，演示涵盖布料、绳索、压力和体积约束以及可变形四面体网格，并于 2020 年左右添加了用于可变形体的有限元方法（FEM）后端。<sup>[17](https://github.com/bulletphysics/bullet3/blob/master/examples/ExampleBrowser/ExampleEntries.cpp)</sup><sup> • </sup><sup>[18](https://github.com/bulletphysics/bullet3/discussions/3918)</sup>

## 确定性与可复现性

用户常假设但引擎通常不保证的一个属性是确定性，即相同输入产生相同输出。Godot 的文档指出，Godot 中的物理模拟无论使用哪个物理引擎都不是确定性的，因为引擎确定性取决于许多因素，因此看似相同的情况不保证以相同方式运行。<sup>[2](https://docs.godotengine.org/en/stable/tutorials/physics/physics_introduction.html)</sup> 这对锁步网络和录制回放很重要，也是引擎提供调试和回放工具（如 Unreal 的 Chaos 可视化调试器）的原因之一。<sup>[6](https://dev.epicgames.com/documentation/unreal-engine/physics-in-unreal-engine?lang=en-US)</sup>

## References

1. [Física, Unity Manual](https://docs.unity3d.com/es/current/Manual/PhysicsSection.html)
2. [Physics introduction, God Engine stable documentation](https://docs.godotengine.org/en/stable/tutorials/physics/physics_introduction.html)
3. [Box2D: World](https://box2d.org/documentation/group__world.html)
4. [Box2D: Simulation](https://box2d.org/documentation/md_simulation.html)
5. [Physics Sub-Stepping in Unreal Engine, Epic Developer Community](https://dev.epicgames.com/documentation/en-us/unreal-engine/physics-sub-stepping-in-unreal-engine)
6. [Physics in Unreal Engine, Epic Developer Community](https://dev.epicgames.com/documentation/unreal-engine/physics-in-unreal-engine?lang=en-US)
7. [bulletphysics/bullet3, GitHub](https://github.com/bulletphysics/bullet3)
8. [HelloWorld.cpp, bullet3 examples](https://github.com/bulletphysics/bullet3/blob/master/examples/HelloWorld/HelloWorld.cpp)
9. [Box2D: Overview](https://box2d.org/documentation/)
10. [Modeling and Solving Constraints (Erin Catto, GDC 2009)](https://box2d.org/files/ErinCatto_ModelingAndSolvingConstraints_GDC2009.pdf)
11. [Physics introduction, Godot 2.1 documentation](https://docs.godotengine.org/en/2.1/learning/features/physics/physics_introduction.html)
12. [Box2D: Collision](https://box2d.org/documentation/md_collision.html)
13. [Manually set physics simulation, Unity Manual](https://docs.unity3d.com/jp/current/Manual/physics-optimization-cpu-manual-simulation.html)
14. [Chaos Vehicles, Epic Developer Community](https://dev.epicgames.com/documentation/unreal-engine/chaos-vehicles)
15. [Chaos Fields User Guide in Unreal Engine, Epic Developer Community](https://dev.epicgames.com/documentation/en-us/unreal-engine/chaos-fields-user-guide-in-unreal-engine)
16. [PyBullet Quickstart Guide, bullet3 docs](https://github.com/bulletphysics/bullet3/blob/master/docs/pybullet_quickstart_guide/PyBulletQuickstartGuide.md.html)
17. [ExampleEntries.cpp, bullet3 examples](https://github.com/bulletphysics/bullet3/blob/master/examples/ExampleBrowser/ExampleEntries.cpp)
18. [How to use FEM? Discussion #3918, bullet3](https://github.com/bulletphysics/bullet3/discussions/3918)

---
*Initially written Sep 17, 2026 · Reviewed: Sep 30, 2026; Oct 15, 2026 · Edited: Sep 30, 2026; Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 物质世界与数学 › 物理学 › 物理学方法、实践与学术共同体 › Applied and interdisciplinary physics › Computational and simulation physics › Physics simulation software and engines › Real-time physics engines

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/physics-engine

English original: https://www.edgepedia.org/physics-engine
