优化

简介

Godot遵循平衡的表现理念。 在效率表现中,总是有需要权衡交易的东西,可用性和灵活性。 一些实际的示例是:

  • 高效地渲染对象很容易,但是当必须渲染大型场景时,它会变得效率低下。 要解决这个问题,必须将可见性计算添加到渲染中,这会使渲染效率降低,但同时渲染的对象也会减少,因此整体效率会提高。
  • 为每个需要渲染的对象配置每种材质的属性也很慢。 为了解决这个问题,对象按材质排序以降低开销,但同时排序会产生开销。
  • 在3D物理学中,会发生类似的情况。 处理大量物理对象(例如SAP)的最佳算法在插入/移除对象和射线投射时很慢。 允许更快插入和移除以及光线投射的算法将无法处理尽可能多的活动对象。

And there are many more examples of this! Game engines strive to be general purpose in nature, so balanced algorithms are always favored over algorithms that might be fast in some situations and slow in others or algorithms that are fast but make usability more difficult.

Godot is not an exception and, while it is designed to have backends swappable for different algorithms, the default ones prioritize balance and flexibility over performance.

With this clear, the aim of this tutorial section is to explain how to get the maximum performance out of Godot. While the tutorials can be read in any order, it is a good idea to start from General optimization tips.